1 From 3ad45d26aba6f69f82220f59824b4d8422b2b220 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 14 Feb 2023 15:35:43 +0000
4 Subject: [PATCH] vc04_services: bcm2835_codec: Ignore READ_ONLY ctrls
7 In adding the MPEG2/MPEG4/H264 level and profile controls to
8 the decoder, they weren't declared as read-only, nor handlers
9 added to bcm2835_codec_s_ctrl. That resulted in an error message
10 "Invalid control" being logged every time v4l2_ctrl_handler_setup
11 was called from bcm2835_codec_create_component.
13 Define those controls as read only, and exit early from s_ctrl
14 on read only controls.
16 Fixes: "media: bcm2835-v4l2-codec: Add profile & level ctrls to decode"
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
19 .../bcm2835-codec/bcm2835-v4l2-codec.c | 127 ++++++++++--------
20 1 file changed, 68 insertions(+), 59 deletions(-)
22 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
23 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
24 @@ -2224,6 +2224,9 @@ static int bcm2835_codec_s_ctrl(struct v
25 container_of(ctrl->handler, struct bcm2835_codec_ctx, hdl);
28 + if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)
32 case V4L2_CID_MPEG_VIDEO_BITRATE:
33 ctx->bitrate = ctrl->val;
34 @@ -2376,7 +2379,7 @@ static int bcm2835_codec_s_ctrl(struct v
38 - v4l2_err(&ctx->dev->v4l2_dev, "Invalid control\n");
39 + v4l2_err(&ctx->dev->v4l2_dev, "Invalid control %08x\n", ctrl->id);
43 @@ -3198,74 +3201,80 @@ static int queue_init(void *priv, struct
44 static void dec_add_profile_ctrls(struct bcm2835_codec_dev *const dev,
45 struct v4l2_ctrl_handler *const hdl)
47 + struct v4l2_ctrl *ctrl;
49 const struct bcm2835_codec_fmt_list *const list = &dev->supported_fmts[0];
51 for (i = 0; i < list->num_entries; ++i) {
52 switch (list->list[i].fourcc) {
53 case V4L2_PIX_FMT_H264:
54 - v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
55 - V4L2_CID_MPEG_VIDEO_H264_LEVEL,
56 - V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
57 - ~(BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_0) |
58 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1B) |
59 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_1) |
60 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_2) |
61 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_3) |
62 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_0) |
63 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_1) |
64 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_2) |
65 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_0) |
66 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_1) |
67 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_2) |
68 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_0) |
69 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_1) |
70 - BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_2)),
71 - V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
72 - v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
73 - V4L2_CID_MPEG_VIDEO_H264_PROFILE,
74 - V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
75 - ~(BIT(V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) |
76 - BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) |
77 - BIT(V4L2_MPEG_VIDEO_H264_PROFILE_MAIN) |
78 - BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH)),
79 - V4L2_MPEG_VIDEO_H264_PROFILE_HIGH);
80 + ctrl = v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
81 + V4L2_CID_MPEG_VIDEO_H264_LEVEL,
82 + V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
83 + ~(BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_0) |
84 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1B) |
85 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_1) |
86 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_2) |
87 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_3) |
88 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_0) |
89 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_1) |
90 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_2) |
91 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_0) |
92 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_1) |
93 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_2) |
94 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_0) |
95 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_1) |
96 + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_2)),
97 + V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
98 + ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
99 + ctrl = v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
100 + V4L2_CID_MPEG_VIDEO_H264_PROFILE,
101 + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
102 + ~(BIT(V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) |
103 + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) |
104 + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_MAIN) |
105 + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH)),
106 + V4L2_MPEG_VIDEO_H264_PROFILE_HIGH);
107 + ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
109 case V4L2_PIX_FMT_MPEG2:
110 - v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
111 - V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL,
112 - V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH,
113 - ~(BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW) |
114 - BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN) |
115 - BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH_1440) |
116 - BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH)),
117 - V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN);
118 - v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
119 - V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE,
120 - V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN,
121 - ~(BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE) |
122 - BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN)),
123 - V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN);
124 + ctrl = v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
125 + V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL,
126 + V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH,
127 + ~(BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW) |
128 + BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN) |
129 + BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH_1440) |
130 + BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH)),
131 + V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN);
132 + ctrl = v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
133 + V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE,
134 + V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN,
135 + ~(BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE) |
136 + BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN)),
137 + V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN);
138 + ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
140 case V4L2_PIX_FMT_MPEG4:
141 - v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
142 - V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL,
143 - V4L2_MPEG_VIDEO_MPEG4_LEVEL_5,
144 - ~(BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_0) |
145 - BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B) |
146 - BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_1) |
147 - BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_2) |
148 - BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_3) |
149 - BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_3B) |
150 - BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_4) |
151 - BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_5)),
152 - V4L2_MPEG_VIDEO_MPEG4_LEVEL_4);
153 - v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
154 - V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE,
155 - V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE,
156 - ~(BIT(V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE) |
157 - BIT(V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE)),
158 - V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE);
159 + ctrl = v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
160 + V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL,
161 + V4L2_MPEG_VIDEO_MPEG4_LEVEL_5,
162 + ~(BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_0) |
163 + BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B) |
164 + BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_1) |
165 + BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_2) |
166 + BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_3) |
167 + BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_3B) |
168 + BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_4) |
169 + BIT(V4L2_MPEG_VIDEO_MPEG4_LEVEL_5)),
170 + V4L2_MPEG_VIDEO_MPEG4_LEVEL_4);
171 + ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
172 + ctrl = v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
173 + V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE,
174 + V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE,
175 + ~(BIT(V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE) |
176 + BIT(V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE)),
177 + V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE);
178 + ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
180 /* No profiles defined by V4L2 */
181 case V4L2_PIX_FMT_H263: