From d1dc49370f8371b00e682ac409aa1987ce641e93 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Delgado Date: Mon, 7 Oct 2019 12:06:31 -0300 Subject: media: add V4L2_CTRL_TYPE_AREA control type This type contains the width and the height of a rectangular area. Reviewed-by: Jacopo Mondi Signed-off-by: Ricardo Ribalda Delgado Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-ctrls.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index fb0883836548..c9ca867ef32b 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -50,6 +50,7 @@ struct poll_table_struct; * @p_h264_slice_params: Pointer to a struct v4l2_ctrl_h264_slice_params. * @p_h264_decode_params: Pointer to a struct v4l2_ctrl_h264_decode_params. * @p_vp8_frame_header: Pointer to a VP8 frame header structure. + * @p_area: Pointer to an area. * @p: Pointer to a compound value. */ union v4l2_ctrl_ptr { @@ -68,6 +69,7 @@ union v4l2_ctrl_ptr { struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; struct v4l2_ctrl_h264_decode_params *p_h264_decode_params; struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; + struct v4l2_area *p_area; void *p; }; @@ -1087,6 +1089,46 @@ static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) return rval; } +/** + * __v4l2_ctrl_s_ctrl_area() - Unlocked variant of v4l2_ctrl_s_ctrl_area(). + * + * @ctrl: The control. + * @area: The new area. + * + * This sets the control's new area safely by going through the control + * framework. This function assumes the control's handler is already locked, + * allowing it to be used from within the &v4l2_ctrl_ops functions. + * + * This function is for area type controls only. + */ +int __v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl, + const struct v4l2_area *area); + +/** + * v4l2_ctrl_s_ctrl_area() - Helper function to set a control's area value + * from within a driver. + * + * @ctrl: The control. + * @area: The new area. + * + * This sets the control's new area safely by going through the control + * framework. This function will lock the control's handler, so it cannot be + * used from within the &v4l2_ctrl_ops functions. + * + * This function is for area type controls only. + */ +static inline int v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl, + const struct v4l2_area *area) +{ + int rval; + + v4l2_ctrl_lock(ctrl); + rval = __v4l2_ctrl_s_ctrl_area(ctrl, area); + v4l2_ctrl_unlock(ctrl); + + return rval; +} + /* Internal helper functions that deal with control events. */ extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; -- cgit v1.2.3-59-g8ed1b