1 From df5051094f02f536291e84f2820e9680cc98687d Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Mon, 20 Sep 2021 15:00:51 +0100
4 Subject: [PATCH] staging: bcm2835-codec: Ensure all ctrls are set on
7 Currently the code was only setting some controls from
8 bcm2835_codec_set_ctrls, but it's simpler to use
9 v4l2_ctrl_handler_setup to avoid forgetting to adding new
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
14 .../bcm2835-codec/bcm2835-v4l2-codec.c | 51 +++++++------------
15 1 file changed, 19 insertions(+), 32 deletions(-)
17 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
18 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
19 @@ -2437,33 +2437,6 @@ static const struct v4l2_ioctl_ops bcm28
20 .vidioc_enum_framesizes = vidioc_enum_framesizes,
23 -static int bcm2835_codec_set_ctrls(struct bcm2835_codec_ctx *ctx)
26 - * Query the control handler for the value of the various controls and
29 - const u32 control_ids[] = {
30 - V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
31 - V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER,
32 - V4L2_CID_MPEG_VIDEO_HEADER_MODE,
33 - V4L2_CID_MPEG_VIDEO_H264_I_PERIOD,
34 - V4L2_CID_MPEG_VIDEO_H264_LEVEL,
35 - V4L2_CID_MPEG_VIDEO_H264_PROFILE,
39 - for (i = 0; i < ARRAY_SIZE(control_ids); i++) {
40 - struct v4l2_ctrl *ctrl;
42 - ctrl = v4l2_ctrl_find(&ctx->hdl, control_ids[i]);
44 - bcm2835_codec_s_ctrl(ctrl);
50 static int bcm2835_codec_create_component(struct bcm2835_codec_ctx *ctx)
52 struct bcm2835_codec_dev *dev = ctx->dev;
53 @@ -2567,9 +2540,6 @@ static int bcm2835_codec_create_componen
54 ctx->q_data[V4L2_M2M_SRC].sizeimage,
55 ctx->component->output[0].minimum_buffer.size);
57 - /* Now we have a component we can set all the ctrls */
58 - bcm2835_codec_set_ctrls(ctx);
60 /* Enable SPS Timing header so framerate information is encoded
63 @@ -2598,6 +2568,10 @@ static int bcm2835_codec_create_componen
64 ctx->q_data[V4L2_M2M_DST].sizeimage,
65 ctx->component->output[0].minimum_buffer.size);
68 + /* Now we have a component we can set all the ctrls */
69 + ret = v4l2_ctrl_handler_setup(&ctx->hdl);
71 v4l2_dbg(2, debug, &dev->v4l2_dev, "%s: component created as %s\n",
72 __func__, components[dev->role]);
74 @@ -3099,7 +3073,9 @@ static int bcm2835_codec_open(struct fil
75 file->private_data = &ctx->fh;
78 - if (dev->role == ENCODE) {
79 + switch (dev->role) {
83 v4l2_ctrl_handler_init(hdl, 9);
85 @@ -3158,7 +3134,10 @@ static int bcm2835_codec_open(struct fil
87 ctx->fh.ctrl_handler = hdl;
88 v4l2_ctrl_handler_setup(hdl);
89 - } else if (dev->role == DECODE) {
94 v4l2_ctrl_handler_init(hdl, 1);
96 v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
97 @@ -3171,6 +3150,14 @@ static int bcm2835_codec_open(struct fil
98 ctx->fh.ctrl_handler = hdl;
99 v4l2_ctrl_handler_setup(hdl);
105 + v4l2_ctrl_handler_init(hdl, 0);
110 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);