Commit de814545 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Mauro Carvalho Chehab

media: v4l2-ctrl: Move compound control validation

Rework std_validate moving the compound controls to
its own validation function.

While here, fix the pointer math to account the index parameter.
Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 616cfb69
......@@ -1629,10 +1629,77 @@ static void std_log(const struct v4l2_ctrl *ctrl)
})
/* Validate a new control */
static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
static int std_validate_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;
switch ((u32)ctrl->type) {
case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS:
p_mpeg2_slice_params = p;
switch (p_mpeg2_slice_params->sequence.chroma_format) {
case 1: /* 4:2:0 */
case 2: /* 4:2:2 */
case 3: /* 4:4:4 */
break;
default:
return -EINVAL;
}
switch (p_mpeg2_slice_params->picture.intra_dc_precision) {
case 0: /* 8 bits */
case 1: /* 9 bits */
case 2: /* 10 bits */
case 3: /* 11 bits */
break;
default:
return -EINVAL;
}
switch (p_mpeg2_slice_params->picture.picture_structure) {
case 1: /* interlaced top field */
case 2: /* interlaced bottom field */
case 3: /* progressive */
break;
default:
return -EINVAL;
}
switch (p_mpeg2_slice_params->picture.picture_coding_type) {
case V4L2_MPEG2_PICTURE_CODING_TYPE_I:
case V4L2_MPEG2_PICTURE_CODING_TYPE_P:
case V4L2_MPEG2_PICTURE_CODING_TYPE_B:
break;
default:
return -EINVAL;
}
break;
case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION:
break;
case V4L2_CTRL_TYPE_FWHT_PARAMS:
break;
case V4L2_CTRL_TYPE_H264_SPS:
case V4L2_CTRL_TYPE_H264_PPS:
case V4L2_CTRL_TYPE_H264_SCALING_MATRIX:
case V4L2_CTRL_TYPE_H264_SLICE_PARAMS:
case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
break;
default:
return -EINVAL;
}
return 0;
}
static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
union v4l2_ctrl_ptr ptr)
{
size_t len;
u64 offset;
s64 val;
......@@ -1695,63 +1762,8 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
return -ERANGE;
return 0;
case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS:
p_mpeg2_slice_params = ptr.p;
switch (p_mpeg2_slice_params->sequence.chroma_format) {
case 1: /* 4:2:0 */
case 2: /* 4:2:2 */
case 3: /* 4:4:4 */
break;
default:
return -EINVAL;
}
switch (p_mpeg2_slice_params->picture.intra_dc_precision) {
case 0: /* 8 bits */
case 1: /* 9 bits */
case 2: /* 10 bits */
case 3: /* 11 bits */
break;
default:
return -EINVAL;
}
switch (p_mpeg2_slice_params->picture.picture_structure) {
case 1: /* interlaced top field */
case 2: /* interlaced bottom field */
case 3: /* progressive */
break;
default:
return -EINVAL;
}
switch (p_mpeg2_slice_params->picture.picture_coding_type) {
case V4L2_MPEG2_PICTURE_CODING_TYPE_I:
case V4L2_MPEG2_PICTURE_CODING_TYPE_P:
case V4L2_MPEG2_PICTURE_CODING_TYPE_B:
break;
default:
return -EINVAL;
}
return 0;
case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION:
return 0;
case V4L2_CTRL_TYPE_FWHT_PARAMS:
return 0;
case V4L2_CTRL_TYPE_H264_SPS:
case V4L2_CTRL_TYPE_H264_PPS:
case V4L2_CTRL_TYPE_H264_SCALING_MATRIX:
case V4L2_CTRL_TYPE_H264_SLICE_PARAMS:
case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
return 0;
default:
return -EINVAL;
return std_validate_compound(ctrl, idx, ptr);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment