Just like codec-specific controls validation, controls initialization for codecs is quite specific so move it to a specific helper for MPEG-2 for increased clarity. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@xxxxxxxxxxx> --- drivers/media/v4l2-core/v4l2-ctrls.c | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 824126267c44..84916b6889e2 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1494,11 +1494,29 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, } } +static void std_init_mpeg2(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr) +{ + struct v4l2_ctrl_mpeg2_slice_params *slice_params = + ptr.p_mpeg2_slice_params; + + switch ((u32)ctrl->type) { + case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS: + /* 4:2:0 */ + slice_params->sequence.chroma_format = 1; + /* 8 bits */ + slice_params->picture.intra_dc_precision = 0; + /* interlaced top field */ + slice_params->picture.picture_structure = 1; + 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) { - struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; - /* * The cast is needed to get rid of a gcc warning complaining that * V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS is not part of the @@ -1530,15 +1548,8 @@ static void std_init(const struct v4l2_ctrl *ctrl, u32 idx, 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; + case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: + std_init_mpeg2(ctrl, idx, ptr); break; default: idx *= ctrl->elem_size; -- 2.21.0 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel