8748214797eb713e1be588822e3399156a108699
[openwrt/staging/mans0n.git] /
1 From 7504f92483407233d9093e164d8f001db5c374e5 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 8 May 2020 22:05:29 +0100
4 Subject: [PATCH] staging: vc04_services: isp: Rework lens shading to
5 take a dmabuf
6
7 This removes the need for the client to use vcsm at all.
8
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
10 ---
11 .../bcm2835-isp/bcm2835-v4l2-isp.c | 36 +++++++++++++++++--
12 include/uapi/linux/bcm2835-isp.h | 4 +--
13 2 files changed, 35 insertions(+), 5 deletions(-)
14
15 --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
16 +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
17 @@ -21,6 +21,8 @@
18 #include "vchiq-mmal/mmal-parameters.h"
19 #include "vchiq-mmal/mmal-vchiq.h"
20
21 +#include "vc-sm-cma/vc_sm_knl.h"
22 +
23 #include "bcm2835_isp_ctrls.h"
24 #include "bcm2835_isp_fmts.h"
25
26 @@ -722,10 +724,38 @@ static int bcm2835_isp_s_ctrl(struct v4l
27 sizeof(struct bcm2835_isp_custom_ccm));
28 break;
29 case V4L2_CID_USER_BCM2835_ISP_LENS_SHADING:
30 - ret = set_isp_param(node, MMAL_PARAMETER_LENS_SHADING_OVERRIDE,
31 - ctrl->p_new.p_u8,
32 - sizeof(struct bcm2835_isp_lens_shading));
33 + {
34 + struct bcm2835_isp_lens_shading ls;
35 + struct dma_buf *dmabuf;
36 + void *vcsm_handle;
37 +
38 + memcpy(&ls, ctrl->p_new.p_u8,
39 + sizeof(struct bcm2835_isp_lens_shading));
40 +
41 + dmabuf = dma_buf_get(ls.dmabuf);
42 + if (!dmabuf)
43 + return -EINVAL;
44 +
45 + ret = vc_sm_cma_import_dmabuf(dmabuf,
46 + &vcsm_handle);
47 + if (ret) {
48 + dma_buf_put(dmabuf);
49 + return -EINVAL;
50 + }
51 +
52 + ls.dmabuf = vc_sm_cma_int_handle(vcsm_handle);
53 + if (ls.dmabuf)
54 + ret = set_isp_param(node,
55 + MMAL_PARAMETER_LENS_SHADING_OVERRIDE,
56 + &ls,
57 + sizeof(struct bcm2835_isp_lens_shading));
58 + else
59 + ret = -EINVAL;
60 +
61 + vc_sm_cma_free(vcsm_handle);
62 + dma_buf_put(dmabuf);
63 break;
64 + }
65 case V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL:
66 ret = set_isp_param(node, MMAL_PARAMETER_BLACK_LEVEL,
67 ctrl->p_new.p_u8,
68 --- a/include/uapi/linux/bcm2835-isp.h
69 +++ b/include/uapi/linux/bcm2835-isp.h
70 @@ -108,7 +108,7 @@ enum bcm2835_isp_gain_format {
71 * @grid_stride: Row to row distance (in grid cells) between grid cells
72 * in the same horizontal location.
73 * @grid_height: Height of lens shading tables in grid cells.
74 - * @mem_handle_table: Memory handle to the tables.
75 + * @dmabuf: dmabuf file handle containing the table.
76 * @ref_transform: Reference transform - unsupported, please pass zero.
77 * @corner_sampled: Whether the gains are sampled at the corner points
78 * of the grid cells or in the cell centres.
79 @@ -120,7 +120,7 @@ struct bcm2835_isp_lens_shading {
80 __u32 grid_width;
81 __u32 grid_stride;
82 __u32 grid_height;
83 - __u32 mem_handle_table;
84 + __s32 dmabuf;
85 __u32 ref_transform;
86 __u32 corner_sampled;
87 __u32 gain_format;