1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
From aceebc39876d7cec8f2b4289a09ddeb94a5697d9 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dsteve@broadcom.com>
Date: Mon, 9 Dec 2013 11:03:54 +0000
Subject: [PATCH 139/174] V4L2: Add support for inline H264 headers
Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER
to control H264 inline headers.
Requires firmware fix to work correctly, otherwise format
has to be set to H264 before this parameter is set.
Signed-off-by: Dave Stevenson <dsteve@broadcom.com>
---
drivers/media/platform/bcm2835/bcm2835-camera.h | 2 +-
drivers/media/platform/bcm2835/controls.c | 115 ++++++++++++++++++-----
drivers/media/platform/bcm2835/mmal-parameters.h | 11 ++-
3 files changed, 103 insertions(+), 25 deletions(-)
--- a/drivers/media/platform/bcm2835/bcm2835-camera.h
+++ b/drivers/media/platform/bcm2835/bcm2835-camera.h
@@ -15,7 +15,7 @@
* core driver device
*/
-#define V4L2_CTRL_COUNT 20 /* number of v4l controls */
+#define V4L2_CTRL_COUNT 21 /* number of v4l controls */
enum {
MMAL_COMPONENT_CAMERA = 0,
--- a/drivers/media/platform/bcm2835/controls.c
+++ b/drivers/media/platform/bcm2835/controls.c
@@ -96,6 +96,7 @@ struct bm2835_mmal_v4l2_ctrl {
const s64 *imenu; /* integer menu array */
u32 mmal_id; /* mmal parameter id */
bm2835_mmal_v4l2_ctrl_cb *setter;
+ bool ignore_errors;
};
struct v4l2_to_mmal_effects_setting {
@@ -606,12 +607,29 @@ static int ctrl_set_image_encode_output(
&u32_value, sizeof(u32_value));
}
+static int ctrl_set_video_encode_param_output(struct bm2835_mmal_dev *dev,
+ struct v4l2_ctrl *ctrl,
+ const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl)
+{
+ u32 u32_value;
+ struct vchiq_mmal_port *vid_enc_ctl;
+
+ vid_enc_ctl = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0];
+
+ u32_value = ctrl->val;
+
+ return vchiq_mmal_port_parameter_set(dev->instance, vid_enc_ctl,
+ mmal_ctrl->mmal_id,
+ &u32_value, sizeof(u32_value));
+}
+
static int bm2835_mmal_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct bm2835_mmal_dev *dev =
container_of(ctrl->handler, struct bm2835_mmal_dev,
ctrl_handler);
const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl = ctrl->priv;
+ int ret;
if ((mmal_ctrl == NULL) ||
(mmal_ctrl->id != ctrl->id) ||
@@ -620,7 +638,10 @@ static int bm2835_mmal_s_ctrl(struct v4l
return -EINVAL;
}
- return mmal_ctrl->setter(dev, ctrl, mmal_ctrl);
+ ret = mmal_ctrl->setter(dev, ctrl, mmal_ctrl);
+ if (mmal_ctrl->ignore_errors)
+ ret = 0;
+ return ret;
}
static const struct v4l2_ctrl_ops bm2835_mmal_ctrl_ops = {
@@ -633,32 +654,44 @@ static const struct bm2835_mmal_v4l2_ctr
{
V4L2_CID_SATURATION, MMAL_CONTROL_TYPE_STD,
-100, 100, 0, 1, NULL,
- MMAL_PARAMETER_SATURATION, &ctrl_set_rational
+ MMAL_PARAMETER_SATURATION,
+ &ctrl_set_rational,
+ false
},
{
V4L2_CID_SHARPNESS, MMAL_CONTROL_TYPE_STD,
-100, 100, 0, 1, NULL,
- MMAL_PARAMETER_SHARPNESS, &ctrl_set_rational
+ MMAL_PARAMETER_SHARPNESS,
+ &ctrl_set_rational,
+ false
},
{
V4L2_CID_CONTRAST, MMAL_CONTROL_TYPE_STD,
-100, 100, 0, 1, NULL,
- MMAL_PARAMETER_CONTRAST, &ctrl_set_rational
+ MMAL_PARAMETER_CONTRAST,
+ &ctrl_set_rational,
+ false
},
{
V4L2_CID_BRIGHTNESS, MMAL_CONTROL_TYPE_STD,
0, 100, 50, 1, NULL,
- MMAL_PARAMETER_BRIGHTNESS, &ctrl_set_rational
+ MMAL_PARAMETER_BRIGHTNESS,
+ &ctrl_set_rational,
+ false
},
{
V4L2_CID_ISO_SENSITIVITY, MMAL_CONTROL_TYPE_INT_MENU,
0, ARRAY_SIZE(iso_qmenu) - 1, 0, 1, iso_qmenu,
- MMAL_PARAMETER_ISO, &ctrl_set_value_menu
+ MMAL_PARAMETER_ISO,
+ &ctrl_set_value_menu,
+ false
},
{
V4L2_CID_IMAGE_STABILIZATION, MMAL_CONTROL_TYPE_STD,
0, 1, 0, 1, NULL,
- MMAL_PARAMETER_VIDEO_STABILISATION, &ctrl_set_value
+ MMAL_PARAMETER_VIDEO_STABILISATION,
+ &ctrl_set_value,
+ false
},
/* {
0, MMAL_CONTROL_TYPE_CLUSTER, 3, 1, 0, NULL, 0, NULL
@@ -666,7 +699,9 @@ static const struct bm2835_mmal_v4l2_ctr
*/ {
V4L2_CID_EXPOSURE_AUTO, MMAL_CONTROL_TYPE_STD_MENU,
~0x03, 3, V4L2_EXPOSURE_AUTO, 0, NULL,
- MMAL_PARAMETER_EXPOSURE_MODE, &ctrl_set_exposure
+ MMAL_PARAMETER_EXPOSURE_MODE,
+ &ctrl_set_exposure,
+ false
},
/* todo this needs mixing in with set exposure
{
@@ -677,86 +712,120 @@ static const struct bm2835_mmal_v4l2_ctr
V4L2_CID_EXPOSURE_ABSOLUTE, MMAL_CONTROL_TYPE_STD,
/* Units of 100usecs */
1, 1*1000*10, 100*10, 1, NULL,
- MMAL_PARAMETER_SHUTTER_SPEED, &ctrl_set_exposure
+ MMAL_PARAMETER_SHUTTER_SPEED,
+ &ctrl_set_exposure,
+ false
},
{
V4L2_CID_AUTO_EXPOSURE_BIAS, MMAL_CONTROL_TYPE_INT_MENU,
0, ARRAY_SIZE(ev_bias_qmenu) - 1,
(ARRAY_SIZE(ev_bias_qmenu)+1)/2 - 1, 0, ev_bias_qmenu,
- MMAL_PARAMETER_EXPOSURE_COMP, &ctrl_set_value_ev
+ MMAL_PARAMETER_EXPOSURE_COMP,
+ &ctrl_set_value_ev,
+ false
},
{
V4L2_CID_EXPOSURE_METERING,
MMAL_CONTROL_TYPE_STD_MENU,
~0x7, 2, V4L2_EXPOSURE_METERING_AVERAGE, 0, NULL,
- MMAL_PARAMETER_EXP_METERING_MODE, &ctrl_set_metering_mode
+ MMAL_PARAMETER_EXP_METERING_MODE,
+ &ctrl_set_metering_mode,
+ false
},
{
V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,
MMAL_CONTROL_TYPE_STD_MENU,
~0x3fe, 9, V4L2_WHITE_BALANCE_AUTO, 0, NULL,
- MMAL_PARAMETER_AWB_MODE, &ctrl_set_awb_mode
+ MMAL_PARAMETER_AWB_MODE,
+ &ctrl_set_awb_mode,
+ false
},
{
V4L2_CID_COLORFX, MMAL_CONTROL_TYPE_STD_MENU,
0, 15, V4L2_COLORFX_NONE, 0, NULL,
- MMAL_PARAMETER_IMAGE_EFFECT, &ctrl_set_image_effect
+ MMAL_PARAMETER_IMAGE_EFFECT,
+ &ctrl_set_image_effect,
+ false
},
{
V4L2_CID_COLORFX_CBCR, MMAL_CONTROL_TYPE_STD,
0, 0xffff, 0x8080, 1, NULL,
- MMAL_PARAMETER_COLOUR_EFFECT, &ctrl_set_colfx
+ MMAL_PARAMETER_COLOUR_EFFECT,
+ &ctrl_set_colfx,
+ false
},
{
V4L2_CID_ROTATE, MMAL_CONTROL_TYPE_STD,
0, 360, 0, 90, NULL,
- MMAL_PARAMETER_ROTATION, &ctrl_set_rotate
+ MMAL_PARAMETER_ROTATION,
+ &ctrl_set_rotate,
+ false
},
{
V4L2_CID_HFLIP, MMAL_CONTROL_TYPE_STD,
0, 1, 0, 1, NULL,
- MMAL_PARAMETER_MIRROR, &ctrl_set_flip
+ MMAL_PARAMETER_MIRROR,
+ &ctrl_set_flip,
+ false
},
{
V4L2_CID_VFLIP, MMAL_CONTROL_TYPE_STD,
0, 1, 0, 1, NULL,
- MMAL_PARAMETER_MIRROR, &ctrl_set_flip
+ MMAL_PARAMETER_MIRROR,
+ &ctrl_set_flip,
+ false
},
{
V4L2_CID_MPEG_VIDEO_BITRATE_MODE, MMAL_CONTROL_TYPE_STD_MENU,
0, ARRAY_SIZE(bitrate_mode_qmenu) - 1,
0, 0, bitrate_mode_qmenu,
- MMAL_PARAMETER_RATECONTROL, &ctrl_set_bitrate_mode
+ MMAL_PARAMETER_RATECONTROL,
+ &ctrl_set_bitrate_mode,
+ false
},
{
V4L2_CID_MPEG_VIDEO_BITRATE, MMAL_CONTROL_TYPE_STD,
25*1000, 25*1000*1000, 10*1000*1000, 25*1000, NULL,
- MMAL_PARAMETER_VIDEO_BIT_RATE, &ctrl_set_bitrate
+ MMAL_PARAMETER_VIDEO_BIT_RATE,
+ &ctrl_set_bitrate,
+ false
},
{
V4L2_CID_JPEG_COMPRESSION_QUALITY, MMAL_CONTROL_TYPE_STD,
1, 100,
30, 1, NULL,
- MMAL_PARAMETER_JPEG_Q_FACTOR, &ctrl_set_image_encode_output
+ MMAL_PARAMETER_JPEG_Q_FACTOR,
+ &ctrl_set_image_encode_output,
+ false
},
{
V4L2_CID_POWER_LINE_FREQUENCY, MMAL_CONTROL_TYPE_STD_MENU,
0, ARRAY_SIZE(mains_freq_qmenu) - 1,
1, 1, NULL,
- MMAL_PARAMETER_FLICKER_AVOID, &ctrl_set_flicker_avoidance
+ MMAL_PARAMETER_FLICKER_AVOID,
+ &ctrl_set_flicker_avoidance,
+ false
+ },
+ {
+ V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER, MMAL_CONTROL_TYPE_STD,
+ 0, 1,
+ 0, 1, NULL,
+ MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER,
+ &ctrl_set_video_encode_param_output,
+ true /* Errors ignored as requires latest firmware to work */
},
};
int bm2835_mmal_set_all_camera_controls(struct bm2835_mmal_dev *dev)
{
int c;
- int ret;
+ int ret = 0;
for (c = 0; c < V4L2_CTRL_COUNT; c++) {
if ((dev->ctrls[c]) && (v4l2_ctrls[c].setter)) {
ret = v4l2_ctrls[c].setter(dev, dev->ctrls[c],
&v4l2_ctrls[c]);
- if (ret)
+ if (!v4l2_ctrls[c]. ignore_errors && ret)
break;
}
}
--- a/drivers/media/platform/bcm2835/mmal-parameters.h
+++ b/drivers/media/platform/bcm2835/mmal-parameters.h
@@ -421,7 +421,16 @@ enum mmal_parameter_video_type {
MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER,
/** @ref MMAL_PARAMETER_BYTES_T */
- MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3
+ MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3,
+
+ /**< @ref MMAL_PARAMETER_BOOLEAN_T */
+ MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS,
+
+ /**< @ref MMAL_PARAMETER_BOOLEAN_T */
+ MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG,
+
+ /**< @ref MMAL_PARAMETER_BOOLEAN_T */
+ MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER
};
/** Valid mirror modes */
|