Skip to content

Commit cf76bb4

Browse files
ndufresnemchehab
authored andcommitted
media: rkvdec: Move H264 SPS validation in rkvdec-h264
No functional change, this moves H264 specific validation into the H264 specific code. This is in preparation of improving this validation and reusing it when VIDIOC_STREAMON is called. Signed-off-by: Nicolas Dufresne <[email protected]> Reviewed-by: Ezequiel Garcia <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent a074aa4 commit cf76bb4

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

drivers/staging/media/rkvdec/rkvdec-h264.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,9 +1137,32 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx)
11371137
return 0;
11381138
}
11391139

1140+
static int rkvdec_h264_try_ctrl(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl)
1141+
{
1142+
if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) {
1143+
const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;
1144+
/*
1145+
* TODO: The hardware supports 10-bit and 4:2:2 profiles,
1146+
* but it's currently broken in the driver.
1147+
* Reject them for now, until it's fixed.
1148+
*/
1149+
if (sps->chroma_format_idc > 1)
1150+
/* Only 4:0:0 and 4:2:0 are supported */
1151+
return -EINVAL;
1152+
if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
1153+
/* Luma and chroma bit depth mismatch */
1154+
return -EINVAL;
1155+
if (sps->bit_depth_luma_minus8 != 0)
1156+
/* Only 8-bit is supported */
1157+
return -EINVAL;
1158+
}
1159+
return 0;
1160+
}
1161+
11401162
const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops = {
11411163
.adjust_fmt = rkvdec_h264_adjust_fmt,
11421164
.start = rkvdec_h264_start,
11431165
.stop = rkvdec_h264_stop,
11441166
.run = rkvdec_h264_run,
1167+
.try_ctrl = rkvdec_h264_try_ctrl,
11451168
};

drivers/staging/media/rkvdec/rkvdec.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,12 @@
2929

3030
static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
3131
{
32-
if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) {
33-
const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;
34-
/*
35-
* TODO: The hardware supports 10-bit and 4:2:2 profiles,
36-
* but it's currently broken in the driver.
37-
* Reject them for now, until it's fixed.
38-
*/
39-
if (sps->chroma_format_idc > 1)
40-
/* Only 4:0:0 and 4:2:0 are supported */
41-
return -EINVAL;
42-
if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
43-
/* Luma and chroma bit depth mismatch */
44-
return -EINVAL;
45-
if (sps->bit_depth_luma_minus8 != 0)
46-
/* Only 8-bit is supported */
47-
return -EINVAL;
48-
}
32+
struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
33+
const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc;
34+
35+
if (desc->ops->try_ctrl)
36+
return desc->ops->try_ctrl(ctx, ctrl);
37+
4938
return 0;
5039
}
5140

drivers/staging/media/rkvdec/rkvdec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct rkvdec_coded_fmt_ops {
7272
void (*done)(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *src_buf,
7373
struct vb2_v4l2_buffer *dst_buf,
7474
enum vb2_buffer_state result);
75+
int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl);
7576
};
7677

7778
struct rkvdec_coded_fmt_desc {

0 commit comments

Comments
 (0)