media: v4l2-ctrls: add __v4l2_ctrl_s_ctrl_compound()

Rather than creating new compound control helpers for each new
type, create one generic function and just create defines on
top.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Hans Verkuil
2020-03-03 12:02:00 +01:00
committed by Mauro Carvalho Chehab
parent 7c3bae3f43
commit b2b1046f1d
2 changed files with 34 additions and 25 deletions

View File

@@ -4253,18 +4253,18 @@ int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
}
EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_string);
int __v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl,
const struct v4l2_area *area)
int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
enum v4l2_ctrl_type type, const void *p)
{
lockdep_assert_held(ctrl->handler->lock);
/* It's a driver bug if this happens. */
if (WARN_ON(ctrl->type != V4L2_CTRL_TYPE_AREA))
if (WARN_ON(ctrl->type != type))
return -EINVAL;
*ctrl->p_new.p_area = *area;
memcpy(ctrl->p_new.p, p, ctrl->elems * ctrl->elem_size);
return set_ctrl(NULL, ctrl, 0);
}
EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_area);
EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_compound);
void v4l2_ctrl_request_complete(struct media_request *req,
struct v4l2_ctrl_handler *main_hdl)