Skip to content

Commit 65de64f

Browse files
6by9popcornmix
authored andcommitted
staging: vc04_services: isp: Rework lens shading to take a dmabuf
This removes the need for the client to use vcsm at all. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 1e5fc9f commit 65de64f

2 files changed

Lines changed: 35 additions & 5 deletions

File tree

‎drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "vchiq-mmal/mmal-parameters.h"
2222
#include "vchiq-mmal/mmal-vchiq.h"
2323

24+
#include "vc-sm-cma/vc_sm_knl.h"
25+
2426
#include "bcm2835_isp_ctrls.h"
2527
#include "bcm2835_isp_fmts.h"
2628

@@ -722,10 +724,38 @@ static int bcm2835_isp_s_ctrl(struct v4l2_ctrl *ctrl)
722724
sizeof(struct bcm2835_isp_custom_ccm));
723725
break;
724726
case V4L2_CID_USER_BCM2835_ISP_LENS_SHADING:
725-
ret = set_isp_param(node, MMAL_PARAMETER_LENS_SHADING_OVERRIDE,
726-
ctrl->p_new.p_u8,
727-
sizeof(struct bcm2835_isp_lens_shading));
727+
{
728+
struct bcm2835_isp_lens_shading ls;
729+
struct dma_buf *dmabuf;
730+
void *vcsm_handle;
731+
732+
memcpy(&ls, ctrl->p_new.p_u8,
733+
sizeof(struct bcm2835_isp_lens_shading));
734+
735+
dmabuf = dma_buf_get(ls.dmabuf);
736+
if (!dmabuf)
737+
return -EINVAL;
738+
739+
ret = vc_sm_cma_import_dmabuf(dmabuf,
740+
&vcsm_handle);
741+
if (ret) {
742+
dma_buf_put(dmabuf);
743+
return -EINVAL;
744+
}
745+
746+
ls.dmabuf = vc_sm_cma_int_handle(vcsm_handle);
747+
if (ls.dmabuf)
748+
ret = set_isp_param(node,
749+
MMAL_PARAMETER_LENS_SHADING_OVERRIDE,
750+
&ls,
751+
sizeof(struct bcm2835_isp_lens_shading));
752+
else
753+
ret = -EINVAL;
754+
755+
vc_sm_cma_free(vcsm_handle);
756+
dma_buf_put(dmabuf);
728757
break;
758+
}
729759
case V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL:
730760
ret = set_isp_param(node, MMAL_PARAMETER_BLACK_LEVEL,
731761
ctrl->p_new.p_u8,

‎include/uapi/linux/bcm2835-isp.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ enum bcm2835_isp_gain_format {
108108
* @grid_stride: Row to row distance (in grid cells) between grid cells
109109
* in the same horizontal location.
110110
* @grid_height: Height of lens shading tables in grid cells.
111-
* @mem_handle_table: Memory handle to the tables.
111+
* @dmabuf: dmabuf file handle containing the table.
112112
* @ref_transform: Reference transform - unsupported, please pass zero.
113113
* @corner_sampled: Whether the gains are sampled at the corner points
114114
* of the grid cells or in the cell centres.
@@ -120,7 +120,7 @@ struct bcm2835_isp_lens_shading {
120120
__u32 grid_width;
121121
__u32 grid_stride;
122122
__u32 grid_height;
123-
__u32 mem_handle_table;
123+
__s32 dmabuf;
124124
__u32 ref_transform;
125125
__u32 corner_sampled;
126126
__u32 gain_format;

0 commit comments

Comments
 (0)