Skip to content

Commit

Permalink
staging: vc04_services: isp: Rework lens shading to take a dmabuf
Browse files Browse the repository at this point in the history
This removes the need for the client to use vcsm at all.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
  • Loading branch information
6by9 authored and popcornmix committed Sep 15, 2020
1 parent f1b7361 commit 939a653
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
36 changes: 33 additions & 3 deletions drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "vchiq-mmal/mmal-parameters.h"
#include "vchiq-mmal/mmal-vchiq.h"

#include "vc-sm-cma/vc_sm_knl.h"

#include "bcm2835_isp_ctrls.h"
#include "bcm2835_isp_fmts.h"

Expand Down Expand Up @@ -722,10 +724,38 @@ static int bcm2835_isp_s_ctrl(struct v4l2_ctrl *ctrl)
sizeof(struct bcm2835_isp_custom_ccm));
break;
case V4L2_CID_USER_BCM2835_ISP_LENS_SHADING:
ret = set_isp_param(node, MMAL_PARAMETER_LENS_SHADING_OVERRIDE,
ctrl->p_new.p_u8,
sizeof(struct bcm2835_isp_lens_shading));
{
struct bcm2835_isp_lens_shading ls;
struct dma_buf *dmabuf;
void *vcsm_handle;

memcpy(&ls, ctrl->p_new.p_u8,
sizeof(struct bcm2835_isp_lens_shading));

dmabuf = dma_buf_get(ls.dmabuf);
if (!dmabuf)
return -EINVAL;

ret = vc_sm_cma_import_dmabuf(dmabuf,
&vcsm_handle);
if (ret) {
dma_buf_put(dmabuf);
return -EINVAL;
}

ls.dmabuf = vc_sm_cma_int_handle(vcsm_handle);
if (ls.dmabuf)
ret = set_isp_param(node,
MMAL_PARAMETER_LENS_SHADING_OVERRIDE,
&ls,
sizeof(struct bcm2835_isp_lens_shading));
else
ret = -EINVAL;

vc_sm_cma_free(vcsm_handle);
dma_buf_put(dmabuf);
break;
}
case V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL:
ret = set_isp_param(node, MMAL_PARAMETER_BLACK_LEVEL,
ctrl->p_new.p_u8,
Expand Down
4 changes: 2 additions & 2 deletions include/uapi/linux/bcm2835-isp.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ enum bcm2835_isp_gain_format {
* @grid_stride: Row to row distance (in grid cells) between grid cells
* in the same horizontal location.
* @grid_height: Height of lens shading tables in grid cells.
* @mem_handle_table: Memory handle to the tables.
* @dmabuf: dmabuf file handle containing the table.
* @ref_transform: Reference transform - unsupported, please pass zero.
* @corner_sampled: Whether the gains are sampled at the corner points
* of the grid cells or in the cell centres.
Expand All @@ -120,7 +120,7 @@ struct bcm2835_isp_lens_shading {
__u32 grid_width;
__u32 grid_stride;
__u32 grid_height;
__u32 mem_handle_table;
__s32 dmabuf;
__u32 ref_transform;
__u32 corner_sampled;
__u32 gain_format;
Expand Down

0 comments on commit 939a653

Please sign in to comment.