mirror of https://gitee.com/openkylin/linux.git
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: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
616cfb69b9
commit
de8145452e
|
@ -1629,10 +1629,77 @@ static void std_log(const struct v4l2_ctrl *ctrl)
|
|||
})
|
||||
|
||||
/* Validate a new control */
|
||||
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)
|
||||
{
|
||||
struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue