]> git.baikalelectronics.ru Git - kernel.git/commitdiff
media: rkvdec: Move H264 SPS validation in rkvdec-h264
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 13 May 2022 20:29:13 +0000 (22:29 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Tue, 17 May 2022 08:06:08 +0000 (10:06 +0200)
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 <nicolas.dufresne@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/rkvdec/rkvdec-h264.c
drivers/staging/media/rkvdec/rkvdec.c
drivers/staging/media/rkvdec/rkvdec.h

index 8d44a884a52e0532d0609909d61ef742eb233089..0dcbcb1bac8092f1f9d96a16568cc786dd3b790c 100644 (file)
@@ -1137,9 +1137,32 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx)
        return 0;
 }
 
+static int rkvdec_h264_try_ctrl(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl)
+{
+       if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) {
+               const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;
+               /*
+                * TODO: The hardware supports 10-bit and 4:2:2 profiles,
+                * but it's currently broken in the driver.
+                * Reject them for now, until it's fixed.
+                */
+               if (sps->chroma_format_idc > 1)
+                       /* Only 4:0:0 and 4:2:0 are supported */
+                       return -EINVAL;
+               if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
+                       /* Luma and chroma bit depth mismatch */
+                       return -EINVAL;
+               if (sps->bit_depth_luma_minus8 != 0)
+                       /* Only 8-bit is supported */
+                       return -EINVAL;
+       }
+       return 0;
+}
+
 const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops = {
        .adjust_fmt = rkvdec_h264_adjust_fmt,
        .start = rkvdec_h264_start,
        .stop = rkvdec_h264_stop,
        .run = rkvdec_h264_run,
+       .try_ctrl = rkvdec_h264_try_ctrl,
 };
index 2df8cf4883e2adc11d413bcd5079dc4698fff998..e3d44d5b35f361b91cf01c77dd61d083d6686b00 100644 (file)
 
 static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
 {
-       if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) {
-               const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;
-               /*
-                * TODO: The hardware supports 10-bit and 4:2:2 profiles,
-                * but it's currently broken in the driver.
-                * Reject them for now, until it's fixed.
-                */
-               if (sps->chroma_format_idc > 1)
-                       /* Only 4:0:0 and 4:2:0 are supported */
-                       return -EINVAL;
-               if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
-                       /* Luma and chroma bit depth mismatch */
-                       return -EINVAL;
-               if (sps->bit_depth_luma_minus8 != 0)
-                       /* Only 8-bit is supported */
-                       return -EINVAL;
-       }
+       struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
+       const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc;
+
+       if (desc->ops->try_ctrl)
+               return desc->ops->try_ctrl(ctx, ctrl);
+
        return 0;
 }
 
index 2f4ea1786b9347c89a8a9d55eaf494a541277b81..9df0fba799a484833d3c3c1ea7deda92a96e4941 100644 (file)
@@ -72,6 +72,7 @@ struct rkvdec_coded_fmt_ops {
        void (*done)(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *src_buf,
                     struct vb2_v4l2_buffer *dst_buf,
                     enum vb2_buffer_state result);
+       int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl);
 };
 
 struct rkvdec_coded_fmt_desc {