aboutsummaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorEzequiel Garcia2019-06-18 19:17:31 -0400
committerMauro Carvalho Chehab2019-06-24 15:00:01 -0400
commitba74edc6def24325af256eea8e8790ce6cdb838d (patch)
tree092293d60282a92ab35ec708f86974d1d14db2c7 /drivers/media
parentfd5b4046c7bb3073a2aa03d994cdb698586c5588 (diff)
media: v4l2-ctrl: Move compound control initialization
Rework std_init adding an explicit initialization for compound controls. While here, make sure the control is initialized to zero, before providing default values for all its fields. Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 2d7525e2d9eb..29b86d7448dc 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1494,10 +1494,13 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx,
}
}
-static void std_init(const struct v4l2_ctrl *ctrl, u32 idx,
- union v4l2_ctrl_ptr ptr)
+static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx,
+ union v4l2_ctrl_ptr ptr)
{
struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
+ void *p = ptr.p + idx * ctrl->elem_size;
+
+ memset(p, 0, ctrl->elem_size);
/*
* The cast is needed to get rid of a gcc warning complaining that
@@ -1505,6 +1508,22 @@ static void std_init(const struct v4l2_ctrl *ctrl, u32 idx,
* v4l2_ctrl_type enum.
*/
switch ((u32)ctrl->type) {
+ case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS:
+ p_mpeg2_slice_params = p;
+ /* 4:2:0 */
+ p_mpeg2_slice_params->sequence.chroma_format = 1;
+ /* interlaced top field */
+ p_mpeg2_slice_params->picture.picture_structure = 1;
+ p_mpeg2_slice_params->picture.picture_coding_type =
+ V4L2_MPEG2_PICTURE_CODING_TYPE_I;
+ break;
+ }
+}
+
+static void std_init(const struct v4l2_ctrl *ctrl, u32 idx,
+ union v4l2_ctrl_ptr ptr)
+{
+ switch (ctrl->type) {
case V4L2_CTRL_TYPE_STRING:
idx *= ctrl->elem_size;
memset(ptr.p_char + idx, ' ', ctrl->minimum);
@@ -1533,20 +1552,8 @@ static void std_init(const struct v4l2_ctrl *ctrl, u32 idx,
case V4L2_CTRL_TYPE_U32:
ptr.p_u32[idx] = ctrl->default_value;
break;
- case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS:
- p_mpeg2_slice_params = ptr.p;
- /* 4:2:0 */
- p_mpeg2_slice_params->sequence.chroma_format = 1;
- /* 8 bits */
- p_mpeg2_slice_params->picture.intra_dc_precision = 0;
- /* interlaced top field */
- p_mpeg2_slice_params->picture.picture_structure = 1;
- p_mpeg2_slice_params->picture.picture_coding_type =
- V4L2_MPEG2_PICTURE_CODING_TYPE_I;
- break;
default:
- idx *= ctrl->elem_size;
- memset(ptr.p + idx, 0, ctrl->elem_size);
+ std_init_compound(ctrl, idx, ptr);
break;
}
}