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:
committed by
Mauro Carvalho Chehab
parent
7c3bae3f43
commit
b2b1046f1d
@@ -4253,18 +4253,18 @@ int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_string);
|
EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_string);
|
||||||
|
|
||||||
int __v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl,
|
int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
|
||||||
const struct v4l2_area *area)
|
enum v4l2_ctrl_type type, const void *p)
|
||||||
{
|
{
|
||||||
lockdep_assert_held(ctrl->handler->lock);
|
lockdep_assert_held(ctrl->handler->lock);
|
||||||
|
|
||||||
/* It's a driver bug if this happens. */
|
/* 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;
|
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);
|
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,
|
void v4l2_ctrl_request_complete(struct media_request *req,
|
||||||
struct v4l2_ctrl_handler *main_hdl)
|
struct v4l2_ctrl_handler *main_hdl)
|
||||||
|
|||||||
@@ -1113,45 +1113,54 @@ static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __v4l2_ctrl_s_ctrl_area() - Unlocked variant of v4l2_ctrl_s_ctrl_area().
|
* __v4l2_ctrl_s_ctrl_compound() - Unlocked variant to set a compound control
|
||||||
*
|
*
|
||||||
* @ctrl: The control.
|
* @ctrl: The control.
|
||||||
* @area: The new area.
|
* @type: The type of the data.
|
||||||
|
* @p: The new compound payload.
|
||||||
*
|
*
|
||||||
* This sets the control's new area safely by going through the control
|
* This sets the control's new compound payload safely by going through the
|
||||||
* framework. This function assumes the control's handler is already locked,
|
* control framework. This function assumes the control's handler is already
|
||||||
* allowing it to be used from within the &v4l2_ctrl_ops functions.
|
* locked, allowing it to be used from within the &v4l2_ctrl_ops functions.
|
||||||
*
|
*
|
||||||
* This function is for area type controls only.
|
* This function is for compound type controls only.
|
||||||
*/
|
*/
|
||||||
int __v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl,
|
int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
|
||||||
const struct v4l2_area *area);
|
enum v4l2_ctrl_type type, const void *p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* v4l2_ctrl_s_ctrl_area() - Helper function to set a control's area value
|
* v4l2_ctrl_s_ctrl_compound() - Helper function to set a compound control
|
||||||
* from within a driver.
|
* from within a driver.
|
||||||
*
|
*
|
||||||
* @ctrl: The control.
|
* @ctrl: The control.
|
||||||
* @area: The new area.
|
* @type: The type of the data.
|
||||||
|
* @p: The new compound payload.
|
||||||
*
|
*
|
||||||
* This sets the control's new area safely by going through the control
|
* This sets the control's new compound payload safely by going through the
|
||||||
* framework. This function will lock the control's handler, so it cannot be
|
* control framework. This function will lock the control's handler, so it
|
||||||
* used from within the &v4l2_ctrl_ops functions.
|
* cannot be used from within the &v4l2_ctrl_ops functions.
|
||||||
*
|
*
|
||||||
* This function is for area type controls only.
|
* This function is for compound type controls only.
|
||||||
*/
|
*/
|
||||||
static inline int v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl,
|
static inline int v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
|
||||||
const struct v4l2_area *area)
|
enum v4l2_ctrl_type type,
|
||||||
|
const void *p)
|
||||||
{
|
{
|
||||||
int rval;
|
int rval;
|
||||||
|
|
||||||
v4l2_ctrl_lock(ctrl);
|
v4l2_ctrl_lock(ctrl);
|
||||||
rval = __v4l2_ctrl_s_ctrl_area(ctrl, area);
|
rval = __v4l2_ctrl_s_ctrl_compound(ctrl, type, p);
|
||||||
v4l2_ctrl_unlock(ctrl);
|
v4l2_ctrl_unlock(ctrl);
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Helper defines for area type controls */
|
||||||
|
#define __v4l2_ctrl_s_ctrl_area(ctrl, area) \
|
||||||
|
__v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area))
|
||||||
|
#define v4l2_ctrl_s_ctrl_area(ctrl, area) \
|
||||||
|
v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area))
|
||||||
|
|
||||||
/* Internal helper functions that deal with control events. */
|
/* Internal helper functions that deal with control events. */
|
||||||
extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
|
extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user