97da4b03adebdb304a95ea56eacfda921a9413e5
[openwrt/staging/neocturne.git] /
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
5 streamon
6
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
10 controls to the list.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 ---
14 .../bcm2835-codec/bcm2835-v4l2-codec.c | 51 +++++++------------
15 1 file changed, 19 insertions(+), 32 deletions(-)
16
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,
21 };
22
23 -static int bcm2835_codec_set_ctrls(struct bcm2835_codec_ctx *ctx)
24 -{
25 - /*
26 - * Query the control handler for the value of the various controls and
27 - * set them.
28 - */
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,
36 - };
37 - int i;
38 -
39 - for (i = 0; i < ARRAY_SIZE(control_ids); i++) {
40 - struct v4l2_ctrl *ctrl;
41 -
42 - ctrl = v4l2_ctrl_find(&ctx->hdl, control_ids[i]);
43 - if (ctrl)
44 - bcm2835_codec_s_ctrl(ctrl);
45 - }
46 -
47 - return 0;
48 -}
49 -
50 static int bcm2835_codec_create_component(struct bcm2835_codec_ctx *ctx)
51 {
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);
56
57 - /* Now we have a component we can set all the ctrls */
58 - bcm2835_codec_set_ctrls(ctx);
59 -
60 /* Enable SPS Timing header so framerate information is encoded
61 * in the H264 header.
62 */
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);
66 }
67 +
68 + /* Now we have a component we can set all the ctrls */
69 + ret = v4l2_ctrl_handler_setup(&ctx->hdl);
70 +
71 v4l2_dbg(2, debug, &dev->v4l2_dev, "%s: component created as %s\n",
72 __func__, components[dev->role]);
73
74 @@ -3099,7 +3073,9 @@ static int bcm2835_codec_open(struct fil
75 file->private_data = &ctx->fh;
76 ctx->dev = dev;
77 hdl = &ctx->hdl;
78 - if (dev->role == ENCODE) {
79 + switch (dev->role) {
80 + case ENCODE:
81 + {
82 /* Encode controls */
83 v4l2_ctrl_handler_init(hdl, 9);
84
85 @@ -3158,7 +3134,10 @@ static int bcm2835_codec_open(struct fil
86 }
87 ctx->fh.ctrl_handler = hdl;
88 v4l2_ctrl_handler_setup(hdl);
89 - } else if (dev->role == DECODE) {
90 + }
91 + break;
92 + case DECODE:
93 + {
94 v4l2_ctrl_handler_init(hdl, 1);
95
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);
100 }
101 + break;
102 + case ISP:
103 + case DEINTERLACE:
104 + {
105 + v4l2_ctrl_handler_init(hdl, 0);
106 + }
107 + break;
108 + }
109
110 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
111