]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
media: hantro: Simplify the controls creation logic
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 25 Jul 2019 14:17:51 +0000 (10:17 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 25 Jul 2019 15:59:27 +0000 (11:59 -0400)
v4l2_ctrl_new_custom() should work for any kind of control, including
standard ones. With that change, we automatically get support for
menu controls.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
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>
drivers/staging/media/hantro/hantro.h
drivers/staging/media/hantro/hantro_drv.c

index 4d7cb7780bde6ceb0762e4b2d9972d04bd762cf9..81e25dfc98b7db805a1133f2019101d404f0b868 100644 (file)
@@ -113,12 +113,10 @@ enum hantro_codec_mode {
 
 /*
  * struct hantro_ctrl - helper type to declare supported controls
- * @id:                V4L2 control ID (V4L2_CID_xxx)
  * @codec:     codec id this control belong to (HANTRO_JPEG_ENCODER, etc.)
  * @cfg:       control configuration
  */
 struct hantro_ctrl {
-       unsigned int id;
        unsigned int codec;
        struct v4l2_ctrl_config cfg;
 };
index 4eae1dbb1ac845a657c5c80e322ca7be5aacbec3..ff2dcbf43e81ab493b70dbf10fd2c2ee13e79097 100644 (file)
@@ -264,31 +264,29 @@ static const struct v4l2_ctrl_ops hantro_ctrl_ops = {
 
 static struct hantro_ctrl controls[] = {
        {
-               .id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
                .codec = HANTRO_JPEG_ENCODER,
                .cfg = {
+                       .id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
                        .min = 5,
                        .max = 100,
                        .step = 1,
                        .def = 50,
+                       .ops = &hantro_ctrl_ops,
                },
        }, {
-               .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
                .codec = HANTRO_MPEG2_DECODER,
                .cfg = {
-                       .elem_size = sizeof(struct v4l2_ctrl_mpeg2_slice_params),
+                       .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
                },
        }, {
-               .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION,
                .codec = HANTRO_MPEG2_DECODER,
                .cfg = {
-                       .elem_size = sizeof(struct v4l2_ctrl_mpeg2_quantization),
+                       .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION,
                },
        }, {
-               .id = V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER,
                .codec = HANTRO_VP8_DECODER,
                .cfg = {
-                       .elem_size = sizeof(struct v4l2_ctrl_vp8_frame_header),
+                       .id = V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER,
                },
        },
 };
@@ -304,22 +302,12 @@ static int hantro_ctrls_setup(struct hantro_dev *vpu,
        for (i = 0; i < num_ctrls; i++) {
                if (!(allowed_codecs & controls[i].codec))
                        continue;
-               if (!controls[i].cfg.elem_size) {
-                       v4l2_ctrl_new_std(&ctx->ctrl_handler,
-                                         &hantro_ctrl_ops,
-                                         controls[i].id, controls[i].cfg.min,
-                                         controls[i].cfg.max,
-                                         controls[i].cfg.step,
-                                         controls[i].cfg.def);
-               } else {
-                       controls[i].cfg.id = controls[i].id;
-                       v4l2_ctrl_new_custom(&ctx->ctrl_handler,
-                                            &controls[i].cfg, NULL);
-               }
 
+               v4l2_ctrl_new_custom(&ctx->ctrl_handler,
+                                    &controls[i].cfg, NULL);
                if (ctx->ctrl_handler.error) {
                        vpu_err("Adding control (%d) failed %d\n",
-                               controls[i].id,
+                               controls[i].cfg.id,
                                ctx->ctrl_handler.error);
                        v4l2_ctrl_handler_free(&ctx->ctrl_handler);
                        return ctx->ctrl_handler.error;