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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
#ifndef _V4L2_CTL_H
#define _V4L2_CTL_H
#ifdef ANDROID
#include <android-config.h>
#else
#include <config.h>
#endif
#include <string>
#include <linux/videodev2.h>
#ifndef NO_LIBV4L2
#include <libv4l2.h>
#else
#define v4l2_open(file, oflag, ...) (-1)
#define v4l2_close(fd) (-1)
#define v4l2_ioctl(fd, request, ...) (-1)
#define v4l2_mmap(start, length, prot, flags, fd, offset) (MAP_FAILED)
#define v4l2_munmap(_start, length) (-1)
#endif
/* Available options.
Please keep the first part (options < 128) in alphabetical order.
That makes it easier to see which short options are still free.
In general the lower case is used to set something and the upper
case is used to retrieve a setting. */
enum Option {
OptGetSlicedVbiFormat = 'B',
OptSetSlicedVbiFormat = 'b',
OptGetCtrl = 'C',
OptSetCtrl = 'c',
OptSetDevice = 'd',
OptGetDriverInfo = 'D',
OptSetOutDevice = 'e',
OptGetFreq = 'F',
OptSetFreq = 'f',
OptHelp = 'h',
OptGetInput = 'I',
OptSetInput = 'i',
OptConcise = 'k',
OptListCtrls = 'l',
OptListCtrlsMenus = 'L',
OptListOutputs = 'N',
OptListInputs = 'n',
OptGetOutput = 'O',
OptSetOutput = 'o',
OptGetParm = 'P',
OptSetParm = 'p',
OptSubset = 'r',
OptGetStandard = 'S',
OptSetStandard = 's',
OptGetTuner = 'T',
OptSetTuner = 't',
OptGetVideoFormat = 'V',
OptSetVideoFormat = 'v',
OptUseWrapper = 'w',
OptGetSlicedVbiOutFormat = 128,
OptGetOverlayFormat,
OptGetVbiFormat,
OptGetVbiOutFormat,
OptGetSdrFormat,
OptGetSdrOutFormat,
OptGetVideoOutFormat,
OptSetSlicedVbiOutFormat,
OptSetOverlayFormat,
OptSetVbiFormat,
OptSetVbiOutFormat,
OptSetSdrFormat,
OptSetSdrOutFormat,
OptSetVideoOutFormat,
OptTryVideoOutFormat,
OptTrySlicedVbiOutFormat,
OptTrySlicedVbiFormat,
OptTryVideoFormat,
OptTryOverlayFormat,
OptTryVbiFormat,
OptTryVbiOutFormat,
OptTrySdrFormat,
OptTrySdrOutFormat,
OptAll,
OptListStandards,
OptListFormats,
OptListFormatsExt,
OptListFields,
OptListFrameSizes,
OptListFrameIntervals,
OptListOverlayFormats,
OptListSdrFormats,
OptListSdrOutFormats,
OptListOutFormats,
OptListOutFields,
OptClearClips,
OptClearBitmap,
OptAddClip,
OptAddBitmap,
OptFindFb,
OptLogStatus,
OptVerbose,
OptSilent,
OptGetSlicedVbiCap,
OptGetSlicedVbiOutCap,
OptGetFBuf,
OptSetFBuf,
OptGetCrop,
OptSetCrop,
OptGetOutputCrop,
OptSetOutputCrop,
OptGetOverlayCrop,
OptSetOverlayCrop,
OptGetOutputOverlayCrop,
OptSetOutputOverlayCrop,
OptGetSelection,
OptSetSelection,
OptGetOutputSelection,
OptSetOutputSelection,
OptGetAudioInput,
OptSetAudioInput,
OptGetAudioOutput,
OptSetAudioOutput,
OptListAudioOutputs,
OptListAudioInputs,
OptGetCropCap,
OptGetOutputCropCap,
OptGetOverlayCropCap,
OptGetOutputOverlayCropCap,
OptOverlay,
OptSleep,
OptGetJpegComp,
OptSetJpegComp,
OptGetModulator,
OptSetModulator,
OptListFreqBands,
OptListDevices,
OptGetOutputParm,
OptSetOutputParm,
OptQueryStandard,
OptPollForEvent,
OptWaitForEvent,
OptGetPriority,
OptSetPriority,
OptListDvTimings,
OptQueryDvTimings,
OptGetDvTimings,
OptSetDvBtTimings,
OptGetDvTimingsCap,
OptSetEdid,
OptClearEdid,
OptGetEdid,
OptInfoEdid,
OptFixEdidChecksums,
OptFreqSeek,
OptEncoderCmd,
OptTryEncoderCmd,
OptDecoderCmd,
OptTryDecoderCmd,
OptTunerIndex,
OptListBuffers,
OptListBuffersOut,
OptListBuffersVbi,
OptListBuffersSlicedVbi,
OptListBuffersVbiOut,
OptListBuffersSlicedVbiOut,
OptListBuffersSdr,
OptListBuffersSdrOut,
OptStreamCount,
OptStreamSkip,
OptStreamLoop,
OptStreamPoll,
OptStreamTo,
OptStreamToHost,
OptStreamMmap,
OptStreamUser,
OptStreamDmaBuf,
OptStreamFrom,
OptStreamFromHost,
OptStreamOutPattern,
OptStreamOutSquare,
OptStreamOutBorder,
OptStreamOutInsertSAV,
OptStreamOutInsertEAV,
OptStreamOutHorSpeed,
OptStreamOutVertSpeed,
OptStreamOutPercFill,
OptStreamOutAlphaComponent,
OptStreamOutAlphaRedOnly,
OptStreamOutRGBLimitedRange,
OptStreamOutPixelAspect,
OptStreamOutVideoAspect,
OptStreamOutMmap,
OptStreamOutUser,
OptStreamOutDmaBuf,
OptListPatterns,
OptHelpTuner,
OptHelpIO,
OptHelpStds,
OptHelpVidCap,
OptHelpVidOut,
OptHelpOverlay,
OptHelpVbi,
OptHelpSdr,
OptHelpSelection,
OptHelpMisc,
OptHelpStreaming,
OptHelpEdid,
OptHelpAll,
OptLast = 512
};
extern char options[OptLast];
extern unsigned capabilities;
extern unsigned out_capabilities;
extern unsigned priv_magic;
extern unsigned out_priv_magic;
extern bool is_multiplanar;
extern __u32 vidcap_buftype;
extern __u32 vidout_buftype;
extern int verbose;
typedef struct {
unsigned flag;
const char *str;
} flag_def;
/* fmts specified */
#define FmtWidth (1L<<0)
#define FmtHeight (1L<<1)
#define FmtChromaKey (1L<<2)
#define FmtGlobalAlpha (1L<<3)
#define FmtPixelFormat (1L<<4)
#define FmtLeft (1L<<5)
#define FmtTop (1L<<6)
#define FmtField (1L<<7)
#define FmtColorspace (1L<<8)
#define FmtYCbCr (1L<<9)
#define FmtQuantization (1L<<10)
#define FmtFlags (1L<<11)
#define FmtBytesPerLine (1L<<12)
#define FmtXferFunc (1L<<13)
// v4l2-ctl.cpp
int doioctl_name(int fd, unsigned long int request, void *parm, const char *name);
int test_ioctl(int fd, int cmd, void *arg);
std::string flags2s(unsigned val, const flag_def *def);
int parse_subopt(char **subs, const char * const *subopts, char **value);
std::string std2s(v4l2_std_id std);
std::string buftype2s(int type);
std::string fcc2s(unsigned int val);
std::string fmtdesc2s(unsigned flags);
std::string colorspace2s(int val);
std::string service2s(unsigned service);
std::string field2s(int val);
void print_v4lstd(v4l2_std_id std);
__u32 parse_field(const char *s);
int parse_fmt(char *optarg, __u32 &width, __u32 &height, __u32 &pixelformat,
__u32 &field, __u32 &colorspace, __u32 &xfer, __u32 &ycbcr,
__u32 &quantization, __u32 &flags, __u32 *bytesperline);
__u32 find_pixel_format(int fd, unsigned index, bool output, bool mplane);
void printfmt(const struct v4l2_format &vfmt);
void print_video_formats(int fd, __u32 type);
#define doioctl(n, r, p) doioctl_name(n, r, p, #r)
// v4l2-ctl-common.cpp
void common_usage(void);
void common_cmd(int ch, char *optarg);
void common_set(int fd);
void common_get(int fd);
void common_list(int fd);
void common_process_controls(int fd);
void common_control_event(const struct v4l2_event *ev);
int common_find_ctrl_id(const char *name);
// v4l2-ctl-tuner.cpp
void tuner_usage(void);
void tuner_cmd(int ch, char *optarg);
void tuner_set(int fd);
void tuner_get(int fd);
// v4l2-ctl-io.cpp
void io_usage(void);
void io_cmd(int ch, char *optarg);
void io_set(int fd);
void io_get(int fd);
void io_list(int fd);
// v4l2-ctl-stds.cpp
void stds_usage(void);
void stds_cmd(int ch, char *optarg);
void stds_set(int fd);
void stds_get(int fd);
void stds_list(int fd);
// v4l2-ctl-vidcap.cpp
void vidcap_usage(void);
void vidcap_cmd(int ch, char *optarg);
void vidcap_set(int fd);
void vidcap_get(int fd);
void vidcap_list(int fd);
// v4l2-ctl-vidout.cpp
void vidout_usage(void);
void vidout_cmd(int ch, char *optarg);
void vidout_set(int fd);
void vidout_get(int fd);
void vidout_list(int fd);
// v4l2-ctl-overlay.cpp
void overlay_usage(void);
void overlay_cmd(int ch, char *optarg);
void overlay_set(int fd);
void overlay_get(int fd);
void overlay_list(int fd);
// v4l2-ctl-vbi.cpp
void vbi_usage(void);
void vbi_cmd(int ch, char *optarg);
void vbi_set(int fd);
void vbi_get(int fd);
void vbi_list(int fd);
// v4l2-ctl-sdr.cpp
void sdr_usage(void);
void sdr_cmd(int ch, char *optarg);
void sdr_set(int fd);
void sdr_get(int fd);
void sdr_list(int fd);
// v4l2-ctl-selection.cpp
void selection_usage(void);
void selection_cmd(int ch, char *optarg);
void selection_set(int fd);
void selection_get(int fd);
// v4l2-ctl-misc.cpp
// This one is also used by the streaming code.
extern struct v4l2_decoder_cmd dec_cmd;
void misc_usage(void);
void misc_cmd(int ch, char *optarg);
void misc_set(int fd);
void misc_get(int fd);
// v4l2-ctl-streaming.cpp
void streaming_usage(void);
void streaming_cmd(int ch, char *optarg);
void streaming_set(int fd, int out_fd);
void streaming_list(int fd, int out_fd);
// v4l2-ctl-edid.cpp
void edid_usage(void);
void edid_cmd(int ch, char *optarg);
void edid_set(int fd);
void edid_get(int fd);
/* v4l2-ctl-modes.cpp */
bool calc_cvt_modeline(int image_width, int image_height,
int refresh_rate, int reduced_blanking,
bool interlaced, bool reduced_fps,
struct v4l2_bt_timings *cvt);
bool calc_gtf_modeline(int image_width, int image_height,
int refresh_rate, bool reduced_blanking,
bool interlaced, struct v4l2_bt_timings *gtf);
#endif
|