V4L/DVB (4829): v4l2_type_names table is incomplete
[linux-2.6] / drivers / media / video / v4l2-common.c
1 /*
2  *      Video for Linux Two
3  *
4  *      A generic video device interface for the LINUX operating system
5  *      using a set of device structures/vectors for low level operations.
6  *
7  *      This file replaces the videodev.c file that comes with the
8  *      regular kernel distribution.
9  *
10  *      This program is free software; you can redistribute it and/or
11  *      modify it under the terms of the GNU General Public License
12  *      as published by the Free Software Foundation; either version
13  *      2 of the License, or (at your option) any later version.
14  *
15  * Author:      Bill Dirks <bdirks@pacbell.net>
16  *              based on code by Alan Cox, <alan@cymru.net>
17  *
18  */
19
20 /*
21  * Video capture interface for Linux
22  *
23  *      A generic video device interface for the LINUX operating system
24  *      using a set of device structures/vectors for low level operations.
25  *
26  *              This program is free software; you can redistribute it and/or
27  *              modify it under the terms of the GNU General Public License
28  *              as published by the Free Software Foundation; either version
29  *              2 of the License, or (at your option) any later version.
30  *
31  * Author:      Alan Cox, <alan@redhat.com>
32  *
33  * Fixes:
34  */
35
36 /*
37  * Video4linux 1/2 integration by Justin Schoeman
38  * <justin@suntiger.ee.up.ac.za>
39  * 2.4 PROCFS support ported from 2.4 kernels by
40  *  Iñaki García Etxebarria <garetxe@euskalnet.net>
41  * Makefile fix by "W. Michael Petullo" <mike@flyn.org>
42  * 2.4 devfs support ported from 2.4 kernels by
43  *  Dan Merillat <dan@merillat.org>
44  * Added Gerd Knorrs v4l1 enhancements (Justin Schoeman)
45  */
46
47 #include <linux/module.h>
48 #include <linux/types.h>
49 #include <linux/kernel.h>
50 #include <linux/sched.h>
51 #include <linux/smp_lock.h>
52 #include <linux/mm.h>
53 #include <linux/string.h>
54 #include <linux/errno.h>
55 #include <asm/uaccess.h>
56 #include <asm/system.h>
57 #include <asm/pgtable.h>
58 #include <asm/io.h>
59 #include <asm/div64.h>
60 #include <linux/video_decoder.h>
61 #define __OLD_VIDIOC_ /* To allow fixing old calls*/
62 #include <media/v4l2-common.h>
63
64 #ifdef CONFIG_KMOD
65 #include <linux/kmod.h>
66 #endif
67
68 #if defined(CONFIG_UST) || defined(CONFIG_UST_MODULE)
69 #include <linux/ust.h>
70 #endif
71
72
73 #include <linux/videodev.h>
74
75 MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr");
76 MODULE_DESCRIPTION("misc helper functions for v4l2 device drivers");
77 MODULE_LICENSE("GPL");
78
79 /*
80  *
81  *      V 4 L 2   D R I V E R   H E L P E R   A P I
82  *
83  */
84
85 /*
86  *  Video Standard Operations (contributed by Michael Schimek)
87  */
88
89
90 /* Fill in the fields of a v4l2_standard structure according to the
91    'id' and 'transmission' parameters.  Returns negative on error.  */
92 int v4l2_video_std_construct(struct v4l2_standard *vs,
93                              int id, char *name)
94 {
95         u32 index = vs->index;
96
97         memset(vs, 0, sizeof(struct v4l2_standard));
98         vs->index = index;
99         vs->id    = id;
100         if (id & V4L2_STD_525_60) {
101                 vs->frameperiod.numerator = 1001;
102                 vs->frameperiod.denominator = 30000;
103                 vs->framelines = 525;
104         } else {
105                 vs->frameperiod.numerator = 1;
106                 vs->frameperiod.denominator = 25;
107                 vs->framelines = 625;
108         }
109         strlcpy(vs->name,name,sizeof(vs->name));
110         return 0;
111 }
112
113 /* ----------------------------------------------------------------- */
114 /* priority handling                                                 */
115
116 #define V4L2_PRIO_VALID(val) (val == V4L2_PRIORITY_BACKGROUND   || \
117                               val == V4L2_PRIORITY_INTERACTIVE  || \
118                               val == V4L2_PRIORITY_RECORD)
119
120 int v4l2_prio_init(struct v4l2_prio_state *global)
121 {
122         memset(global,0,sizeof(*global));
123         return 0;
124 }
125
126 int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
127                      enum v4l2_priority new)
128 {
129         if (!V4L2_PRIO_VALID(new))
130                 return -EINVAL;
131         if (*local == new)
132                 return 0;
133
134         atomic_inc(&global->prios[new]);
135         if (V4L2_PRIO_VALID(*local))
136                 atomic_dec(&global->prios[*local]);
137         *local = new;
138         return 0;
139 }
140
141 int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local)
142 {
143         return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT);
144 }
145
146 int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local)
147 {
148         if (V4L2_PRIO_VALID(*local))
149                 atomic_dec(&global->prios[*local]);
150         return 0;
151 }
152
153 enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
154 {
155         if (atomic_read(&global->prios[V4L2_PRIORITY_RECORD]) > 0)
156                 return V4L2_PRIORITY_RECORD;
157         if (atomic_read(&global->prios[V4L2_PRIORITY_INTERACTIVE]) > 0)
158                 return V4L2_PRIORITY_INTERACTIVE;
159         if (atomic_read(&global->prios[V4L2_PRIORITY_BACKGROUND]) > 0)
160                 return V4L2_PRIORITY_BACKGROUND;
161         return V4L2_PRIORITY_UNSET;
162 }
163
164 int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local)
165 {
166         if (*local < v4l2_prio_max(global))
167                 return -EBUSY;
168         return 0;
169 }
170
171
172 /* ----------------------------------------------------------------- */
173 /* some arrays for pretty-printing debug messages of enum types      */
174
175 char *v4l2_field_names[] = {
176         [V4L2_FIELD_ANY]        = "any",
177         [V4L2_FIELD_NONE]       = "none",
178         [V4L2_FIELD_TOP]        = "top",
179         [V4L2_FIELD_BOTTOM]     = "bottom",
180         [V4L2_FIELD_INTERLACED] = "interlaced",
181         [V4L2_FIELD_SEQ_TB]     = "seq-tb",
182         [V4L2_FIELD_SEQ_BT]     = "seq-bt",
183         [V4L2_FIELD_ALTERNATE]  = "alternate",
184 };
185
186 char *v4l2_type_names[] = {
187         [V4L2_BUF_TYPE_VIDEO_CAPTURE]      = "video-cap",
188         [V4L2_BUF_TYPE_VIDEO_OVERLAY]      = "video-over",
189         [V4L2_BUF_TYPE_VIDEO_OUTPUT]       = "video-out",
190         [V4L2_BUF_TYPE_VBI_CAPTURE]        = "vbi-cap",
191         [V4L2_BUF_TYPE_VBI_OUTPUT]         = "vbi-out",
192         [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
193         [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT]  = "slicec-vbi-out",
194 };
195
196 static char *v4l2_memory_names[] = {
197         [V4L2_MEMORY_MMAP]    = "mmap",
198         [V4L2_MEMORY_USERPTR] = "userptr",
199         [V4L2_MEMORY_OVERLAY] = "overlay",
200 };
201
202 #define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown"
203
204 /* ------------------------------------------------------------------ */
205 /* debug help functions                                               */
206
207 #ifdef CONFIG_VIDEO_V4L1_COMPAT
208 static const char *v4l1_ioctls[] = {
209         [_IOC_NR(VIDIOCGCAP)]       = "VIDIOCGCAP",
210         [_IOC_NR(VIDIOCGCHAN)]      = "VIDIOCGCHAN",
211         [_IOC_NR(VIDIOCSCHAN)]      = "VIDIOCSCHAN",
212         [_IOC_NR(VIDIOCGTUNER)]     = "VIDIOCGTUNER",
213         [_IOC_NR(VIDIOCSTUNER)]     = "VIDIOCSTUNER",
214         [_IOC_NR(VIDIOCGPICT)]      = "VIDIOCGPICT",
215         [_IOC_NR(VIDIOCSPICT)]      = "VIDIOCSPICT",
216         [_IOC_NR(VIDIOCCAPTURE)]    = "VIDIOCCAPTURE",
217         [_IOC_NR(VIDIOCGWIN)]       = "VIDIOCGWIN",
218         [_IOC_NR(VIDIOCSWIN)]       = "VIDIOCSWIN",
219         [_IOC_NR(VIDIOCGFBUF)]      = "VIDIOCGFBUF",
220         [_IOC_NR(VIDIOCSFBUF)]      = "VIDIOCSFBUF",
221         [_IOC_NR(VIDIOCKEY)]        = "VIDIOCKEY",
222         [_IOC_NR(VIDIOCGFREQ)]      = "VIDIOCGFREQ",
223         [_IOC_NR(VIDIOCSFREQ)]      = "VIDIOCSFREQ",
224         [_IOC_NR(VIDIOCGAUDIO)]     = "VIDIOCGAUDIO",
225         [_IOC_NR(VIDIOCSAUDIO)]     = "VIDIOCSAUDIO",
226         [_IOC_NR(VIDIOCSYNC)]       = "VIDIOCSYNC",
227         [_IOC_NR(VIDIOCMCAPTURE)]   = "VIDIOCMCAPTURE",
228         [_IOC_NR(VIDIOCGMBUF)]      = "VIDIOCGMBUF",
229         [_IOC_NR(VIDIOCGUNIT)]      = "VIDIOCGUNIT",
230         [_IOC_NR(VIDIOCGCAPTURE)]   = "VIDIOCGCAPTURE",
231         [_IOC_NR(VIDIOCSCAPTURE)]   = "VIDIOCSCAPTURE",
232         [_IOC_NR(VIDIOCSPLAYMODE)]  = "VIDIOCSPLAYMODE",
233         [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
234         [_IOC_NR(VIDIOCGPLAYINFO)]  = "VIDIOCGPLAYINFO",
235         [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
236         [_IOC_NR(VIDIOCGVBIFMT)]    = "VIDIOCGVBIFMT",
237         [_IOC_NR(VIDIOCSVBIFMT)]    = "VIDIOCSVBIFMT"
238 };
239 #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
240 #endif
241
242 static const char *v4l2_ioctls[] = {
243         [_IOC_NR(VIDIOC_QUERYCAP)]         = "VIDIOC_QUERYCAP",
244         [_IOC_NR(VIDIOC_RESERVED)]         = "VIDIOC_RESERVED",
245         [_IOC_NR(VIDIOC_ENUM_FMT)]         = "VIDIOC_ENUM_FMT",
246         [_IOC_NR(VIDIOC_G_FMT)]            = "VIDIOC_G_FMT",
247         [_IOC_NR(VIDIOC_S_FMT)]            = "VIDIOC_S_FMT",
248         [_IOC_NR(VIDIOC_G_MPEGCOMP)]       = "VIDIOC_G_MPEGCOMP",
249         [_IOC_NR(VIDIOC_S_MPEGCOMP)]       = "VIDIOC_S_MPEGCOMP",
250         [_IOC_NR(VIDIOC_REQBUFS)]          = "VIDIOC_REQBUFS",
251         [_IOC_NR(VIDIOC_QUERYBUF)]         = "VIDIOC_QUERYBUF",
252         [_IOC_NR(VIDIOC_G_FBUF)]           = "VIDIOC_G_FBUF",
253         [_IOC_NR(VIDIOC_S_FBUF)]           = "VIDIOC_S_FBUF",
254         [_IOC_NR(VIDIOC_OVERLAY)]          = "VIDIOC_OVERLAY",
255         [_IOC_NR(VIDIOC_QBUF)]             = "VIDIOC_QBUF",
256         [_IOC_NR(VIDIOC_DQBUF)]            = "VIDIOC_DQBUF",
257         [_IOC_NR(VIDIOC_STREAMON)]         = "VIDIOC_STREAMON",
258         [_IOC_NR(VIDIOC_STREAMOFF)]        = "VIDIOC_STREAMOFF",
259         [_IOC_NR(VIDIOC_G_PARM)]           = "VIDIOC_G_PARM",
260         [_IOC_NR(VIDIOC_S_PARM)]           = "VIDIOC_S_PARM",
261         [_IOC_NR(VIDIOC_G_STD)]            = "VIDIOC_G_STD",
262         [_IOC_NR(VIDIOC_S_STD)]            = "VIDIOC_S_STD",
263         [_IOC_NR(VIDIOC_ENUMSTD)]          = "VIDIOC_ENUMSTD",
264         [_IOC_NR(VIDIOC_ENUMINPUT)]        = "VIDIOC_ENUMINPUT",
265         [_IOC_NR(VIDIOC_G_CTRL)]           = "VIDIOC_G_CTRL",
266         [_IOC_NR(VIDIOC_S_CTRL)]           = "VIDIOC_S_CTRL",
267         [_IOC_NR(VIDIOC_G_TUNER)]          = "VIDIOC_G_TUNER",
268         [_IOC_NR(VIDIOC_S_TUNER)]          = "VIDIOC_S_TUNER",
269         [_IOC_NR(VIDIOC_G_AUDIO)]          = "VIDIOC_G_AUDIO",
270         [_IOC_NR(VIDIOC_S_AUDIO)]          = "VIDIOC_S_AUDIO",
271         [_IOC_NR(VIDIOC_QUERYCTRL)]        = "VIDIOC_QUERYCTRL",
272         [_IOC_NR(VIDIOC_QUERYMENU)]        = "VIDIOC_QUERYMENU",
273         [_IOC_NR(VIDIOC_G_INPUT)]          = "VIDIOC_G_INPUT",
274         [_IOC_NR(VIDIOC_S_INPUT)]          = "VIDIOC_S_INPUT",
275         [_IOC_NR(VIDIOC_G_OUTPUT)]         = "VIDIOC_G_OUTPUT",
276         [_IOC_NR(VIDIOC_S_OUTPUT)]         = "VIDIOC_S_OUTPUT",
277         [_IOC_NR(VIDIOC_ENUMOUTPUT)]       = "VIDIOC_ENUMOUTPUT",
278         [_IOC_NR(VIDIOC_G_AUDOUT)]         = "VIDIOC_G_AUDOUT",
279         [_IOC_NR(VIDIOC_S_AUDOUT)]         = "VIDIOC_S_AUDOUT",
280         [_IOC_NR(VIDIOC_G_MODULATOR)]      = "VIDIOC_G_MODULATOR",
281         [_IOC_NR(VIDIOC_S_MODULATOR)]      = "VIDIOC_S_MODULATOR",
282         [_IOC_NR(VIDIOC_G_FREQUENCY)]      = "VIDIOC_G_FREQUENCY",
283         [_IOC_NR(VIDIOC_S_FREQUENCY)]      = "VIDIOC_S_FREQUENCY",
284         [_IOC_NR(VIDIOC_CROPCAP)]          = "VIDIOC_CROPCAP",
285         [_IOC_NR(VIDIOC_G_CROP)]           = "VIDIOC_G_CROP",
286         [_IOC_NR(VIDIOC_S_CROP)]           = "VIDIOC_S_CROP",
287         [_IOC_NR(VIDIOC_G_JPEGCOMP)]       = "VIDIOC_G_JPEGCOMP",
288         [_IOC_NR(VIDIOC_S_JPEGCOMP)]       = "VIDIOC_S_JPEGCOMP",
289         [_IOC_NR(VIDIOC_QUERYSTD)]         = "VIDIOC_QUERYSTD",
290         [_IOC_NR(VIDIOC_TRY_FMT)]          = "VIDIOC_TRY_FMT",
291         [_IOC_NR(VIDIOC_ENUMAUDIO)]        = "VIDIOC_ENUMAUDIO",
292         [_IOC_NR(VIDIOC_ENUMAUDOUT)]       = "VIDIOC_ENUMAUDOUT",
293         [_IOC_NR(VIDIOC_G_PRIORITY)]       = "VIDIOC_G_PRIORITY",
294         [_IOC_NR(VIDIOC_S_PRIORITY)]       = "VIDIOC_S_PRIORITY",
295 #if 1
296         [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
297 #endif
298         [_IOC_NR(VIDIOC_LOG_STATUS)]       = "VIDIOC_LOG_STATUS",
299         [_IOC_NR(VIDIOC_G_EXT_CTRLS)]      = "VIDIOC_G_EXT_CTRLS",
300         [_IOC_NR(VIDIOC_S_EXT_CTRLS)]      = "VIDIOC_S_EXT_CTRLS",
301         [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)]    = "VIDIOC_TRY_EXT_CTRLS"
302 };
303 #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
304
305 static const char *v4l2_int_ioctls[] = {
306 #ifdef CONFIG_VIDEO_V4L1_COMPAT
307         [_IOC_NR(DECODER_GET_CAPABILITIES)]    = "DECODER_GET_CAPABILITIES",
308         [_IOC_NR(DECODER_GET_STATUS)]          = "DECODER_GET_STATUS",
309         [_IOC_NR(DECODER_SET_NORM)]            = "DECODER_SET_NORM",
310         [_IOC_NR(DECODER_SET_INPUT)]           = "DECODER_SET_INPUT",
311         [_IOC_NR(DECODER_SET_OUTPUT)]          = "DECODER_SET_OUTPUT",
312         [_IOC_NR(DECODER_ENABLE_OUTPUT)]       = "DECODER_ENABLE_OUTPUT",
313         [_IOC_NR(DECODER_SET_PICTURE)]         = "DECODER_SET_PICTURE",
314         [_IOC_NR(DECODER_SET_GPIO)]            = "DECODER_SET_GPIO",
315         [_IOC_NR(DECODER_INIT)]                = "DECODER_INIT",
316         [_IOC_NR(DECODER_SET_VBI_BYPASS)]      = "DECODER_SET_VBI_BYPASS",
317         [_IOC_NR(DECODER_DUMP)]                = "DECODER_DUMP",
318 #endif
319         [_IOC_NR(AUDC_SET_RADIO)]              = "AUDC_SET_RADIO",
320
321         [_IOC_NR(TUNER_SET_TYPE_ADDR)]         = "TUNER_SET_TYPE_ADDR",
322         [_IOC_NR(TUNER_SET_STANDBY)]           = "TUNER_SET_STANDBY",
323         [_IOC_NR(TDA9887_SET_CONFIG)]          = "TDA9887_SET_CONFIG",
324
325         [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)]     = "VIDIOC_INT_S_TUNER_MODE",
326         [_IOC_NR(VIDIOC_INT_S_REGISTER)]       = "VIDIOC_INT_S_REGISTER",
327         [_IOC_NR(VIDIOC_INT_G_REGISTER)]       = "VIDIOC_INT_G_REGISTER",
328         [_IOC_NR(VIDIOC_INT_RESET)]            = "VIDIOC_INT_RESET",
329         [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
330         [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)]  = "VIDIOC_INT_DECODE_VBI_LINE",
331         [_IOC_NR(VIDIOC_INT_S_VBI_DATA)]       = "VIDIOC_INT_S_VBI_DATA",
332         [_IOC_NR(VIDIOC_INT_G_VBI_DATA)]       = "VIDIOC_INT_G_VBI_DATA",
333         [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)]     = "VIDIOC_INT_G_CHIP_IDENT",
334         [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)]   = "VIDIOC_INT_I2S_CLOCK_FREQ",
335         [_IOC_NR(VIDIOC_INT_S_STANDBY)]        = "VIDIOC_INT_S_STANDBY",
336         [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)]  = "VIDIOC_INT_S_AUDIO_ROUTING",
337         [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)]  = "VIDIOC_INT_G_AUDIO_ROUTING",
338         [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)]  = "VIDIOC_INT_S_VIDEO_ROUTING",
339         [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)]  = "VIDIOC_INT_G_VIDEO_ROUTING",
340         [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)]   = "VIDIOC_INT_S_CRYSTAL_FREQ"
341 };
342 #define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
343
344 static void v4l_print_pix_fmt (char *s, struct v4l2_pix_format *fmt)
345 {
346         printk ("%s: width=%d, height=%d, format=%d, field=%s, "
347                 "bytesperline=%d sizeimage=%d, colorspace=%d\n", s,
348                 fmt->width,fmt->height,fmt->pixelformat,
349                 prt_names(fmt->field,v4l2_field_names),
350                 fmt->bytesperline,fmt->sizeimage,fmt->colorspace);
351 };
352
353 /* Common ioctl debug function. This function can be used by
354    external ioctl messages as well as internal V4L ioctl */
355 void v4l_printk_ioctl(unsigned int cmd)
356 {
357         char *dir;
358
359         switch (_IOC_DIR(cmd)) {
360         case _IOC_NONE:              dir = "--"; break;
361         case _IOC_READ:              dir = "r-"; break;
362         case _IOC_WRITE:             dir = "-w"; break;
363         case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
364         default:                     dir = "*ERR*"; break;
365         }
366         switch (_IOC_TYPE(cmd)) {
367         case 'd':
368                 printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n",
369                        (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ?
370                        v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
371                 break;
372 #ifdef CONFIG_VIDEO_V4L1_COMPAT
373         case 'v':
374                 printk("v4l1 ioctl %s, dir=%s (0x%08x)\n",
375                        (_IOC_NR(cmd) < V4L1_IOCTLS) ?
376                        v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
377                 break;
378 #endif
379         case 'V':
380                 printk("v4l2 ioctl %s, dir=%s (0x%08x)\n",
381                        (_IOC_NR(cmd) < V4L2_IOCTLS) ?
382                        v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
383                 break;
384
385         default:
386                 printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n",
387                        _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
388         }
389 }
390
391 /* Common ioctl debug function. This function can be used by
392    external ioctl messages as well as internal V4L ioctl and its
393    arguments */
394 void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
395 {
396         printk(s);
397         printk(": ");
398         v4l_printk_ioctl(cmd);
399         switch (cmd) {
400         case VIDIOC_INT_G_CHIP_IDENT:
401         {
402                 enum v4l2_chip_ident  *p=arg;
403                 printk ("%s: chip ident=%d\n", s, *p);
404                 break;
405         }
406         case VIDIOC_G_PRIORITY:
407         case VIDIOC_S_PRIORITY:
408         {
409                 enum v4l2_priority *p=arg;
410                 printk ("%s: priority=%d\n", s, *p);
411                 break;
412         }
413         case VIDIOC_INT_S_TUNER_MODE:
414         {
415                 enum v4l2_tuner_type *p=arg;
416                 printk ("%s: tuner type=%d\n", s, *p);
417                 break;
418         }
419 #ifdef CONFIG_VIDEO_V4L1_COMPAT
420         case DECODER_SET_VBI_BYPASS:
421         case DECODER_ENABLE_OUTPUT:
422         case DECODER_GET_STATUS:
423         case DECODER_SET_OUTPUT:
424         case DECODER_SET_INPUT:
425         case DECODER_SET_GPIO:
426         case DECODER_SET_NORM:
427         case VIDIOCCAPTURE:
428         case VIDIOCSYNC:
429         case VIDIOCSWRITEMODE:
430 #endif
431         case TUNER_SET_TYPE_ADDR:
432         case TUNER_SET_STANDBY:
433         case TDA9887_SET_CONFIG:
434 #ifdef __OLD_VIDIOC_
435         case VIDIOC_OVERLAY_OLD:
436 #endif
437         case VIDIOC_STREAMOFF:
438         case VIDIOC_G_OUTPUT:
439         case VIDIOC_S_OUTPUT:
440         case VIDIOC_STREAMON:
441         case VIDIOC_G_INPUT:
442         case VIDIOC_OVERLAY:
443         case VIDIOC_S_INPUT:
444         {
445                 int *p=arg;
446                 printk ("%s: value=%d\n", s, *p);
447                 break;
448         }
449         case VIDIOC_G_AUDIO:
450         case VIDIOC_S_AUDIO:
451         case VIDIOC_ENUMAUDIO:
452 #ifdef __OLD_VIDIOC_
453         case VIDIOC_G_AUDIO_OLD:
454 #endif
455         {
456                 struct v4l2_audio *p=arg;
457
458                 printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n",
459                         s,p->index, p->name,p->capability, p->mode);
460                 break;
461         }
462         case VIDIOC_G_AUDOUT:
463         case VIDIOC_S_AUDOUT:
464         case VIDIOC_ENUMAUDOUT:
465 #ifdef __OLD_VIDIOC_
466         case VIDIOC_G_AUDOUT_OLD:
467 #endif
468         {
469                 struct v4l2_audioout *p=arg;
470                 printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n", s,
471                                 p->index, p->name, p->capability,p->mode);
472                 break;
473         }
474         case VIDIOC_QBUF:
475         case VIDIOC_DQBUF:
476         case VIDIOC_QUERYBUF:
477         {
478                 struct v4l2_buffer *p=arg;
479                 struct v4l2_timecode *tc=&p->timecode;
480                 printk ("%s: %02ld:%02d:%02d.%08ld index=%d, type=%s, "
481                         "bytesused=%d, flags=0x%08x, "
482                         "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx\n",
483                                 s,
484                                 (p->timestamp.tv_sec/3600),
485                                 (int)(p->timestamp.tv_sec/60)%60,
486                                 (int)(p->timestamp.tv_sec%60),
487                                 p->timestamp.tv_usec,
488                                 p->index,
489                                 prt_names(p->type,v4l2_type_names),
490                                 p->bytesused,p->flags,
491                                 p->field,p->sequence,
492                                 prt_names(p->memory,v4l2_memory_names),
493                                 p->m.userptr);
494                 printk ("%s: timecode= %02d:%02d:%02d type=%d, "
495                         "flags=0x%08x, frames=%d, userbits=0x%08x\n",
496                                 s,tc->hours,tc->minutes,tc->seconds,
497                                 tc->type, tc->flags, tc->frames, *(__u32 *) tc->userbits);
498                 break;
499         }
500         case VIDIOC_QUERYCAP:
501         {
502                 struct v4l2_capability *p=arg;
503                 printk ("%s: driver=%s, card=%s, bus=%s, version=0x%08x, "
504                         "capabilities=0x%08x\n", s,
505                                 p->driver,p->card,p->bus_info,
506                                 p->version,
507                                 p->capabilities);
508                 break;
509         }
510         case VIDIOC_G_CTRL:
511         case VIDIOC_S_CTRL:
512 #ifdef __OLD_VIDIOC_
513         case VIDIOC_S_CTRL_OLD:
514 #endif
515         {
516                 struct v4l2_control *p=arg;
517                 printk ("%s: id=%d, value=%d\n", s, p->id, p->value);
518                 break;
519         }
520         case VIDIOC_G_EXT_CTRLS:
521         case VIDIOC_S_EXT_CTRLS:
522         case VIDIOC_TRY_EXT_CTRLS:
523         {
524                 struct v4l2_ext_controls *p = arg;
525                 int i;
526
527                 printk("%s: ctrl_class=%d, count=%d\n", s, p->ctrl_class, p->count);
528                 for (i = 0; i < p->count; i++) {
529                         struct v4l2_ext_control *c = &p->controls[i];
530                         if (cmd == VIDIOC_G_EXT_CTRLS)
531                                 printk("%s: id=%d\n", s, c->id);
532                         else
533                                 printk("%s: id=%d, value=%d\n", s, c->id, c->value);
534                 }
535                 break;
536         }
537         case VIDIOC_G_CROP:
538         case VIDIOC_S_CROP:
539         {
540                 struct v4l2_crop *p=arg;
541                 /*FIXME: Should also show rect structs */
542                 printk ("%s: type=%d\n", s, p->type);
543                 break;
544         }
545         case VIDIOC_CROPCAP:
546 #ifdef __OLD_VIDIOC_
547         case VIDIOC_CROPCAP_OLD:
548 #endif
549         {
550                 struct v4l2_cropcap *p=arg;
551                 /*FIXME: Should also show rect structs */
552                 printk ("%s: type=%d\n", s, p->type);
553                 break;
554         }
555         case VIDIOC_INT_DECODE_VBI_LINE:
556         {
557                 struct v4l2_decode_vbi_line *p=arg;
558                 printk ("%s: is_second_field=%d, ptr=0x%08lx, line=%d, "
559                         "type=%d\n", s,
560                                 p->is_second_field,(unsigned long)p->p,p->line,p->type);
561                 break;
562         }
563         case VIDIOC_ENUM_FMT:
564         {
565                 struct v4l2_fmtdesc *p=arg;
566                 printk ("%s: index=%d, type=%d, flags=%d, description=%s,"
567                         " pixelformat=%d\n", s,
568                                 p->index, p->type, p->flags,p->description,
569                                 p->pixelformat);
570
571                 break;
572         }
573         case VIDIOC_G_FMT:
574         case VIDIOC_S_FMT:
575         case VIDIOC_TRY_FMT:
576         {
577                 struct v4l2_format *p=arg;
578                 printk ("%s: type=%s\n", s,
579                                 prt_names(p->type,v4l2_type_names));
580                 switch (p->type) {
581                 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
582                         v4l_print_pix_fmt (s, &p->fmt.pix);
583                         break;
584                 default:
585                         break;
586                 }
587         }
588         case VIDIOC_G_FBUF:
589         case VIDIOC_S_FBUF:
590         {
591                 struct v4l2_framebuffer *p=arg;
592                 printk ("%s: capability=%d, flags=%d, base=0x%08lx\n", s,
593                                 p->capability,p->flags, (unsigned long)p->base);
594                 v4l_print_pix_fmt (s, &p->fmt);
595                 break;
596         }
597         case VIDIOC_G_FREQUENCY:
598         case VIDIOC_S_FREQUENCY:
599         {
600                 struct v4l2_frequency *p=arg;
601                 printk ("%s: tuner=%d, type=%d, frequency=%d\n", s,
602                                 p->tuner,p->type,p->frequency);
603                 break;
604         }
605         case VIDIOC_ENUMINPUT:
606         {
607                 struct v4l2_input *p=arg;
608                 printk ("%s: index=%d, name=%s, type=%d, audioset=%d, "
609                         "tuner=%d, std=%Ld, status=%d\n", s,
610                                 p->index,p->name,p->type,p->audioset,
611                                 p->tuner,
612                                 (unsigned long long)p->std,
613                                 p->status);
614                 break;
615         }
616         case VIDIOC_G_JPEGCOMP:
617         case VIDIOC_S_JPEGCOMP:
618         {
619                 struct v4l2_jpegcompression *p=arg;
620                 printk ("%s: quality=%d, APPn=%d, APP_len=%d, COM_len=%d,"
621                         " jpeg_markers=%d\n", s,
622                                 p->quality,p->APPn,p->APP_len,
623                                 p->COM_len,p->jpeg_markers);
624                 break;
625         }
626         case VIDIOC_G_MODULATOR:
627         case VIDIOC_S_MODULATOR:
628         {
629                 struct v4l2_modulator *p=arg;
630                 printk ("%s: index=%d, name=%s, capability=%d, rangelow=%d,"
631                         " rangehigh=%d, txsubchans=%d\n", s,
632                                 p->index, p->name,p->capability,p->rangelow,
633                                 p->rangehigh,p->txsubchans);
634                 break;
635         }
636         case VIDIOC_G_MPEGCOMP:
637         case VIDIOC_S_MPEGCOMP:
638         {
639                 struct v4l2_mpeg_compression *p=arg;
640                 /*FIXME: Several fields not shown */
641                 printk ("%s: ts_pid_pmt=%d, ts_pid_audio=%d, ts_pid_video=%d, "
642                         "ts_pid_pcr=%d, ps_size=%d, au_sample_rate=%d, "
643                         "au_pesid=%c, vi_frame_rate=%d, vi_frames_per_gop=%d, "
644                         "vi_bframes_count=%d, vi_pesid=%c\n", s,
645                                 p->ts_pid_pmt,p->ts_pid_audio, p->ts_pid_video,
646                                 p->ts_pid_pcr, p->ps_size, p->au_sample_rate,
647                                 p->au_pesid, p->vi_frame_rate,
648                                 p->vi_frames_per_gop, p->vi_bframes_count,
649                                 p->vi_pesid);
650                 break;
651         }
652         case VIDIOC_ENUMOUTPUT:
653         {
654                 struct v4l2_output *p=arg;
655                 printk ("%s: index=%d, name=%s,type=%d, audioset=%d, "
656                         "modulator=%d, std=%Ld\n",
657                                 s,p->index,p->name,p->type,p->audioset,
658                                 p->modulator,
659                                 (unsigned long long)p->std);
660                 break;
661         }
662         case VIDIOC_QUERYCTRL:
663         {
664                 struct v4l2_queryctrl *p=arg;
665                 printk ("%s: id=%d, type=%d, name=%s, min/max=%d/%d,"
666                         " step=%d, default=%d, flags=0x%08x\n", s,
667                                 p->id,p->type,p->name,p->minimum,p->maximum,
668                                 p->step,p->default_value,p->flags);
669                 break;
670         }
671         case VIDIOC_QUERYMENU:
672         {
673                 struct v4l2_querymenu *p=arg;
674                 printk ("%s: id=%d, index=%d, name=%s\n", s,
675                                 p->id,p->index,p->name);
676                 break;
677         }
678         case VIDIOC_INT_G_REGISTER:
679         case VIDIOC_INT_S_REGISTER:
680         {
681                 struct v4l2_register *p=arg;
682                 printk ("%s: i2c_id=%d, reg=%lu, val=%d\n", s,
683                                 p->i2c_id,p->reg,p->val);
684
685                 break;
686         }
687         case VIDIOC_REQBUFS:
688         {
689                 struct v4l2_requestbuffers *p=arg;
690                 printk ("%s: count=%d, type=%s, memory=%s\n", s,
691                                 p->count,
692                                 prt_names(p->type,v4l2_type_names),
693                                 prt_names(p->memory,v4l2_memory_names));
694                 break;
695         }
696         case VIDIOC_INT_S_AUDIO_ROUTING:
697         case VIDIOC_INT_S_VIDEO_ROUTING:
698         case VIDIOC_INT_G_AUDIO_ROUTING:
699         case VIDIOC_INT_G_VIDEO_ROUTING:
700         {
701                 struct v4l2_routing  *p=arg;
702                 printk ("%s: input=0x%x, output=0x%x\n", s, p->input, p->output);
703                 break;
704         }
705         case VIDIOC_INT_S_CRYSTAL_FREQ:
706         {
707                 struct v4l2_crystal_freq *p=arg;
708                 printk ("%s: freq=%u, flags=0x%x\n", s, p->freq, p->flags);
709                 break;
710         }
711         case VIDIOC_G_SLICED_VBI_CAP:
712         {
713                 struct v4l2_sliced_vbi_cap *p=arg;
714                 printk ("%s: service_set=%d\n", s,
715                                 p->service_set);
716                 break;
717         }
718         case VIDIOC_INT_S_VBI_DATA:
719         case VIDIOC_INT_G_VBI_DATA:
720         {
721                 struct v4l2_sliced_vbi_data  *p=arg;
722                 printk ("%s: id=%d, field=%d, line=%d\n", s,
723                                 p->id, p->field, p->line);
724                 break;
725         }
726         case VIDIOC_ENUMSTD:
727         {
728                 struct v4l2_standard *p=arg;
729                 printk ("%s: index=%d, id=%Ld, name=%s, fps=%d/%d, "
730                         "framelines=%d\n", s, p->index,
731                                 (unsigned long long)p->id, p->name,
732                                 p->frameperiod.numerator,
733                                 p->frameperiod.denominator,
734                                 p->framelines);
735
736                 break;
737         }
738         case VIDIOC_G_PARM:
739         case VIDIOC_S_PARM:
740 #ifdef __OLD_VIDIOC_
741         case VIDIOC_S_PARM_OLD:
742 #endif
743         {
744                 struct v4l2_streamparm *p=arg;
745                 printk ("%s: type=%d\n", s, p->type);
746
747                 break;
748         }
749         case VIDIOC_G_TUNER:
750         case VIDIOC_S_TUNER:
751         {
752                 struct v4l2_tuner *p=arg;
753                 printk ("%s: index=%d, name=%s, type=%d, capability=%d, "
754                         "rangelow=%d, rangehigh=%d, signal=%d, afc=%d, "
755                         "rxsubchans=%d, audmode=%d\n", s,
756                                 p->index, p->name, p->type,
757                                 p->capability, p->rangelow,p->rangehigh,
758                                 p->rxsubchans, p->audmode, p->signal,
759                                 p->afc);
760                 break;
761         }
762 #ifdef CONFIG_VIDEO_V4L1_COMPAT
763         case VIDIOCGVBIFMT:
764         case VIDIOCSVBIFMT:
765         {
766                 struct vbi_format *p=arg;
767                 printk ("%s: sampling_rate=%d, samples_per_line=%d, "
768                         "sample_format=%d, start=%d/%d, count=%d/%d, flags=%d\n", s,
769                                 p->sampling_rate,p->samples_per_line,
770                                 p->sample_format,p->start[0],p->start[1],
771                                 p->count[0],p->count[1],p->flags);
772                 break;
773         }
774         case VIDIOCGAUDIO:
775         case VIDIOCSAUDIO:
776         {
777                 struct video_audio *p=arg;
778                 printk ("%s: audio=%d, volume=%d, bass=%d, treble=%d, "
779                         "flags=%d, name=%s, mode=%d, balance=%d, step=%d\n",
780                                 s,p->audio,p->volume,p->bass, p->treble,
781                                 p->flags,p->name,p->mode,p->balance,p->step);
782                 break;
783         }
784         case VIDIOCGFBUF:
785         case VIDIOCSFBUF:
786         {
787                 struct video_buffer *p=arg;
788                 printk ("%s: base=%08lx, height=%d, width=%d, depth=%d, "
789                         "bytesperline=%d\n", s,
790                                 (unsigned long) p->base, p->height, p->width,
791                                 p->depth,p->bytesperline);
792                 break;
793         }
794         case VIDIOCGCAP:
795         {
796                 struct video_capability *p=arg;
797                 printk ("%s: name=%s, type=%d, channels=%d, audios=%d, "
798                         "maxwidth=%d, maxheight=%d, minwidth=%d, minheight=%d\n",
799                                 s,p->name,p->type,p->channels,p->audios,
800                                 p->maxwidth,p->maxheight,p->minwidth,
801                                 p->minheight);
802
803                 break;
804         }
805         case VIDIOCGCAPTURE:
806         case VIDIOCSCAPTURE:
807         {
808                 struct video_capture *p=arg;
809                 printk ("%s: x=%d, y=%d, width=%d, height=%d, decimation=%d,"
810                         " flags=%d\n", s,
811                                 p->x, p->y,p->width, p->height,
812                                 p->decimation,p->flags);
813                 break;
814         }
815         case VIDIOCGCHAN:
816         case VIDIOCSCHAN:
817         {
818                 struct video_channel *p=arg;
819                 printk ("%s: channel=%d, name=%s, tuners=%d, flags=%d, "
820                         "type=%d, norm=%d\n", s,
821                                 p->channel,p->name,p->tuners,
822                                 p->flags,p->type,p->norm);
823
824                 break;
825         }
826         case VIDIOCSMICROCODE:
827         {
828                 struct video_code *p=arg;
829                 printk ("%s: loadwhat=%s, datasize=%d\n", s,
830                                 p->loadwhat,p->datasize);
831                 break;
832         }
833         case DECODER_GET_CAPABILITIES:
834         {
835                 struct video_decoder_capability *p=arg;
836                 printk ("%s: flags=%d, inputs=%d, outputs=%d\n", s,
837                                 p->flags,p->inputs,p->outputs);
838                 break;
839         }
840         case DECODER_INIT:
841         {
842                 struct video_decoder_init *p=arg;
843                 printk ("%s: len=%c\n", s, p->len);
844                 break;
845         }
846         case VIDIOCGPLAYINFO:
847         {
848                 struct video_info *p=arg;
849                 printk ("%s: frame_count=%d, h_size=%d, v_size=%d, "
850                         "smpte_timecode=%d, picture_type=%d, "
851                         "temporal_reference=%d, user_data=%s\n", s,
852                                 p->frame_count, p->h_size,
853                                 p->v_size, p->smpte_timecode,
854                                 p->picture_type, p->temporal_reference,
855                                 p->user_data);
856                 break;
857         }
858         case VIDIOCKEY:
859         {
860                 struct video_key *p=arg;
861                 printk ("%s: key=%s, flags=%d\n", s,
862                                 p->key, p->flags);
863                 break;
864         }
865         case VIDIOCGMBUF:
866         {
867                 struct video_mbuf *p=arg;
868                 printk ("%s: size=%d, frames=%d, offsets=0x%08lx\n", s,
869                                 p->size,
870                                 p->frames,
871                                 (unsigned long)p->offsets);
872                 break;
873         }
874         case VIDIOCMCAPTURE:
875         {
876                 struct video_mmap *p=arg;
877                 printk ("%s: frame=%d, height=%d, width=%d, format=%d\n", s,
878                                 p->frame,
879                                 p->height, p->width,
880                                 p->format);
881                 break;
882         }
883         case VIDIOCGPICT:
884         case VIDIOCSPICT:
885         case DECODER_SET_PICTURE:
886         {
887                 struct video_picture *p=arg;
888
889                 printk ("%s: brightness=%d, hue=%d, colour=%d, contrast=%d,"
890                         " whiteness=%d, depth=%d, palette=%d\n", s,
891                                 p->brightness, p->hue, p->colour,
892                                 p->contrast, p->whiteness, p->depth,
893                                 p->palette);
894                 break;
895         }
896         case VIDIOCSPLAYMODE:
897         {
898                 struct video_play_mode *p=arg;
899                 printk ("%s: mode=%d, p1=%d, p2=%d\n", s,
900                                 p->mode,p->p1,p->p2);
901                 break;
902         }
903         case VIDIOCGTUNER:
904         case VIDIOCSTUNER:
905         {
906                 struct video_tuner *p=arg;
907                 printk ("%s: tuner=%d, name=%s, rangelow=%ld, rangehigh=%ld, "
908                         "flags=%d, mode=%d, signal=%d\n", s,
909                                 p->tuner, p->name,p->rangelow, p->rangehigh,
910                                 p->flags,p->mode, p->signal);
911                 break;
912         }
913         case VIDIOCGUNIT:
914         {
915                 struct video_unit *p=arg;
916                 printk ("%s: video=%d, vbi=%d, radio=%d, audio=%d, "
917                         "teletext=%d\n", s,
918                                 p->video,p->vbi,p->radio,p->audio,p->teletext);
919                 break;
920         }
921         case VIDIOCGWIN:
922         case VIDIOCSWIN:
923         {
924                 struct video_window *p=arg;
925                 printk ("%s: x=%d, y=%d, width=%d, height=%d, chromakey=%d,"
926                         " flags=%d, clipcount=%d\n", s,
927                                 p->x, p->y,p->width, p->height,
928                                 p->chromakey,p->flags,
929                                 p->clipcount);
930                 break;
931         }
932         case VIDIOCGFREQ:
933         case VIDIOCSFREQ:
934         {
935                 unsigned long *p=arg;
936                 printk ("%s: value=%lu\n", s, *p);
937                 break;
938         }
939 #endif
940         case VIDIOC_INT_AUDIO_CLOCK_FREQ:
941         case VIDIOC_INT_I2S_CLOCK_FREQ:
942         case VIDIOC_INT_S_STANDBY:
943         case VIDIOC_INT_RESET:
944         {
945                 u32 *p=arg;
946
947                 printk ("%s: value=%d\n", s, *p);
948                 break;
949         }
950         case VIDIOC_G_STD:
951         case VIDIOC_S_STD:
952         case VIDIOC_QUERYSTD:
953         {
954                 v4l2_std_id *p=arg;
955
956                 printk ("%s: value=%Lu\n", s, (unsigned long long)*p);
957                 break;
958         }
959         }
960 }
961
962 /* ----------------------------------------------------------------- */
963
964 /* Helper functions for control handling                             */
965
966 /* Check for correctness of the ctrl's value based on the data from
967    struct v4l2_queryctrl and the available menu items. Note that
968    menu_items may be NULL, in that case it is ignored. */
969 int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
970                 const char **menu_items)
971 {
972         if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED)
973                 return -EINVAL;
974         if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED)
975                 return -EBUSY;
976         if (qctrl->type == V4L2_CTRL_TYPE_BUTTON ||
977             qctrl->type == V4L2_CTRL_TYPE_INTEGER64 ||
978             qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS)
979                 return 0;
980         if (ctrl->value < qctrl->minimum || ctrl->value > qctrl->maximum)
981                 return -ERANGE;
982         if (qctrl->type == V4L2_CTRL_TYPE_MENU && menu_items != NULL) {
983                 if (menu_items[ctrl->value] == NULL ||
984                     menu_items[ctrl->value][0] == '\0')
985                         return -EINVAL;
986         }
987         return 0;
988 }
989
990 /* Returns NULL or a character pointer array containing the menu for
991    the given control ID. The pointer array ends with a NULL pointer.
992    An empty string signifies a menu entry that is invalid. This allows
993    drivers to disable certain options if it is not supported. */
994 const char **v4l2_ctrl_get_menu(u32 id)
995 {
996         static const char *mpeg_audio_sampling_freq[] = {
997                 "44.1 kHz",
998                 "48 kHz",
999                 "32 kHz",
1000                 NULL
1001         };
1002         static const char *mpeg_audio_encoding[] = {
1003                 "Layer I",
1004                 "Layer II",
1005                 "Layer III",
1006                 NULL
1007         };
1008         static const char *mpeg_audio_l1_bitrate[] = {
1009                 "32 kbps",
1010                 "64 kbps",
1011                 "96 kbps",
1012                 "128 kbps",
1013                 "160 kbps",
1014                 "192 kbps",
1015                 "224 kbps",
1016                 "256 kbps",
1017                 "288 kbps",
1018                 "320 kbps",
1019                 "352 kbps",
1020                 "384 kbps",
1021                 "416 kbps",
1022                 "448 kbps",
1023                 NULL
1024         };
1025         static const char *mpeg_audio_l2_bitrate[] = {
1026                 "32 kbps",
1027                 "48 kbps",
1028                 "56 kbps",
1029                 "64 kbps",
1030                 "80 kbps",
1031                 "96 kbps",
1032                 "112 kbps",
1033                 "128 kbps",
1034                 "160 kbps",
1035                 "192 kbps",
1036                 "224 kbps",
1037                 "256 kbps",
1038                 "320 kbps",
1039                 "384 kbps",
1040                 NULL
1041         };
1042         static const char *mpeg_audio_l3_bitrate[] = {
1043                 "32 kbps",
1044                 "40 kbps",
1045                 "48 kbps",
1046                 "56 kbps",
1047                 "64 kbps",
1048                 "80 kbps",
1049                 "96 kbps",
1050                 "112 kbps",
1051                 "128 kbps",
1052                 "160 kbps",
1053                 "192 kbps",
1054                 "224 kbps",
1055                 "256 kbps",
1056                 "320 kbps",
1057                 NULL
1058         };
1059         static const char *mpeg_audio_mode[] = {
1060                 "Stereo",
1061                 "Joint Stereo",
1062                 "Dual",
1063                 "Mono",
1064                 NULL
1065         };
1066         static const char *mpeg_audio_mode_extension[] = {
1067                 "Bound 4",
1068                 "Bound 8",
1069                 "Bound 12",
1070                 "Bound 16",
1071                 NULL
1072         };
1073         static const char *mpeg_audio_emphasis[] = {
1074                 "No Emphasis",
1075                 "50/15 us",
1076                 "CCITT J17",
1077                 NULL
1078         };
1079         static const char *mpeg_audio_crc[] = {
1080                 "No CRC",
1081                 "16-bit CRC",
1082                 NULL
1083         };
1084         static const char *mpeg_video_encoding[] = {
1085                 "MPEG-1",
1086                 "MPEG-2",
1087                 NULL
1088         };
1089         static const char *mpeg_video_aspect[] = {
1090                 "1x1",
1091                 "4x3",
1092                 "16x9",
1093                 "2.21x1",
1094                 NULL
1095         };
1096         static const char *mpeg_video_bitrate_mode[] = {
1097                 "Variable Bitrate",
1098                 "Constant Bitrate",
1099                 NULL
1100         };
1101         static const char *mpeg_stream_type[] = {
1102                 "MPEG-2 Program Stream",
1103                 "MPEG-2 Transport Stream",
1104                 "MPEG-1 System Stream",
1105                 "MPEG-2 DVD-compatible Stream",
1106                 "MPEG-1 VCD-compatible Stream",
1107                 "MPEG-2 SVCD-compatible Stream",
1108                 NULL
1109         };
1110         static const char *mpeg_stream_vbi_fmt[] = {
1111                 "No VBI",
1112                 "Private packet, IVTV format",
1113                 NULL
1114         };
1115
1116         switch (id) {
1117                 case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
1118                         return mpeg_audio_sampling_freq;
1119                 case V4L2_CID_MPEG_AUDIO_ENCODING:
1120                         return mpeg_audio_encoding;
1121                 case V4L2_CID_MPEG_AUDIO_L1_BITRATE:
1122                         return mpeg_audio_l1_bitrate;
1123                 case V4L2_CID_MPEG_AUDIO_L2_BITRATE:
1124                         return mpeg_audio_l2_bitrate;
1125                 case V4L2_CID_MPEG_AUDIO_L3_BITRATE:
1126                         return mpeg_audio_l3_bitrate;
1127                 case V4L2_CID_MPEG_AUDIO_MODE:
1128                         return mpeg_audio_mode;
1129                 case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION:
1130                         return mpeg_audio_mode_extension;
1131                 case V4L2_CID_MPEG_AUDIO_EMPHASIS:
1132                         return mpeg_audio_emphasis;
1133                 case V4L2_CID_MPEG_AUDIO_CRC:
1134                         return mpeg_audio_crc;
1135                 case V4L2_CID_MPEG_VIDEO_ENCODING:
1136                         return mpeg_video_encoding;
1137                 case V4L2_CID_MPEG_VIDEO_ASPECT:
1138                         return mpeg_video_aspect;
1139                 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
1140                         return mpeg_video_bitrate_mode;
1141                 case V4L2_CID_MPEG_STREAM_TYPE:
1142                         return mpeg_stream_type;
1143                 case V4L2_CID_MPEG_STREAM_VBI_FMT:
1144                         return mpeg_stream_vbi_fmt;
1145                 default:
1146                         return NULL;
1147         }
1148 }
1149
1150 /* Fill in a struct v4l2_queryctrl */
1151 int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def)
1152 {
1153         const char *name;
1154
1155         qctrl->flags = 0;
1156         switch (qctrl->id) {
1157         /* USER controls */
1158         case V4L2_CID_USER_CLASS:       name = "User Controls"; break;
1159         case V4L2_CID_AUDIO_VOLUME:     name = "Volume"; break;
1160         case V4L2_CID_AUDIO_MUTE:       name = "Mute"; break;
1161         case V4L2_CID_AUDIO_BALANCE:    name = "Balance"; break;
1162         case V4L2_CID_AUDIO_BASS:       name = "Bass"; break;
1163         case V4L2_CID_AUDIO_TREBLE:     name = "Treble"; break;
1164         case V4L2_CID_AUDIO_LOUDNESS:   name = "Loudness"; break;
1165         case V4L2_CID_BRIGHTNESS:       name = "Brightness"; break;
1166         case V4L2_CID_CONTRAST:         name = "Contrast"; break;
1167         case V4L2_CID_SATURATION:       name = "Saturation"; break;
1168         case V4L2_CID_HUE:              name = "Hue"; break;
1169
1170         /* MPEG controls */
1171         case V4L2_CID_MPEG_CLASS:               name = "MPEG Encoder Controls"; break;
1172         case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: name = "Audio Sampling Frequency"; break;
1173         case V4L2_CID_MPEG_AUDIO_ENCODING:      name = "Audio Encoding Layer"; break;
1174         case V4L2_CID_MPEG_AUDIO_L1_BITRATE:    name = "Audio Layer I Bitrate"; break;
1175         case V4L2_CID_MPEG_AUDIO_L2_BITRATE:    name = "Audio Layer II Bitrate"; break;
1176         case V4L2_CID_MPEG_AUDIO_L3_BITRATE:    name = "Audio Layer III Bitrate"; break;
1177         case V4L2_CID_MPEG_AUDIO_MODE:          name = "Audio Stereo Mode"; break;
1178         case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: name = "Audio Stereo Mode Extension"; break;
1179         case V4L2_CID_MPEG_AUDIO_EMPHASIS:      name = "Audio Emphasis"; break;
1180         case V4L2_CID_MPEG_AUDIO_CRC:           name = "Audio CRC"; break;
1181         case V4L2_CID_MPEG_VIDEO_ENCODING:      name = "Video Encoding"; break;
1182         case V4L2_CID_MPEG_VIDEO_ASPECT:        name = "Video Aspect"; break;
1183         case V4L2_CID_MPEG_VIDEO_B_FRAMES:      name = "Video B Frames"; break;
1184         case V4L2_CID_MPEG_VIDEO_GOP_SIZE:      name = "Video GOP Size"; break;
1185         case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE:   name = "Video GOP Closure"; break;
1186         case V4L2_CID_MPEG_VIDEO_PULLDOWN:      name = "Video Pulldown"; break;
1187         case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:  name = "Video Bitrate Mode"; break;
1188         case V4L2_CID_MPEG_VIDEO_BITRATE:       name = "Video Bitrate"; break;
1189         case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK:  name = "Video Peak Bitrate"; break;
1190         case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: name = "Video Temporal Decimation"; break;
1191         case V4L2_CID_MPEG_STREAM_TYPE:         name = "Stream Type"; break;
1192         case V4L2_CID_MPEG_STREAM_PID_PMT:      name = "Stream PMT Program ID"; break;
1193         case V4L2_CID_MPEG_STREAM_PID_AUDIO:    name = "Stream Audio Program ID"; break;
1194         case V4L2_CID_MPEG_STREAM_PID_VIDEO:    name = "Stream Video Program ID"; break;
1195         case V4L2_CID_MPEG_STREAM_PID_PCR:      name = "Stream PCR Program ID"; break;
1196         case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: name = "Stream PES Audio ID"; break;
1197         case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: name = "Stream PES Video ID"; break;
1198         case V4L2_CID_MPEG_STREAM_VBI_FMT:      name = "Stream VBI Format"; break;
1199
1200         default:
1201                 return -EINVAL;
1202         }
1203         switch (qctrl->id) {
1204         case V4L2_CID_AUDIO_MUTE:
1205         case V4L2_CID_AUDIO_LOUDNESS:
1206         case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE:
1207         case V4L2_CID_MPEG_VIDEO_PULLDOWN:
1208                 qctrl->type = V4L2_CTRL_TYPE_BOOLEAN;
1209                 min = 0;
1210                 max = step = 1;
1211                 break;
1212         case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
1213         case V4L2_CID_MPEG_AUDIO_ENCODING:
1214         case V4L2_CID_MPEG_AUDIO_L1_BITRATE:
1215         case V4L2_CID_MPEG_AUDIO_L2_BITRATE:
1216         case V4L2_CID_MPEG_AUDIO_L3_BITRATE:
1217         case V4L2_CID_MPEG_AUDIO_MODE:
1218         case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION:
1219         case V4L2_CID_MPEG_AUDIO_EMPHASIS:
1220         case V4L2_CID_MPEG_AUDIO_CRC:
1221         case V4L2_CID_MPEG_VIDEO_ENCODING:
1222         case V4L2_CID_MPEG_VIDEO_ASPECT:
1223         case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
1224         case V4L2_CID_MPEG_STREAM_TYPE:
1225         case V4L2_CID_MPEG_STREAM_VBI_FMT:
1226                 qctrl->type = V4L2_CTRL_TYPE_MENU;
1227                 step = 1;
1228                 break;
1229         case V4L2_CID_USER_CLASS:
1230         case V4L2_CID_MPEG_CLASS:
1231                 qctrl->type = V4L2_CTRL_TYPE_CTRL_CLASS;
1232                 qctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
1233                 min = max = step = def = 0;
1234                 break;
1235         default:
1236                 qctrl->type = V4L2_CTRL_TYPE_INTEGER;
1237                 break;
1238         }
1239         switch (qctrl->id) {
1240         case V4L2_CID_MPEG_AUDIO_ENCODING:
1241         case V4L2_CID_MPEG_AUDIO_MODE:
1242         case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
1243         case V4L2_CID_MPEG_VIDEO_B_FRAMES:
1244         case V4L2_CID_MPEG_STREAM_TYPE:
1245                 qctrl->flags |= V4L2_CTRL_FLAG_UPDATE;
1246                 break;
1247         case V4L2_CID_AUDIO_VOLUME:
1248         case V4L2_CID_AUDIO_BALANCE:
1249         case V4L2_CID_AUDIO_BASS:
1250         case V4L2_CID_AUDIO_TREBLE:
1251         case V4L2_CID_BRIGHTNESS:
1252         case V4L2_CID_CONTRAST:
1253         case V4L2_CID_SATURATION:
1254         case V4L2_CID_HUE:
1255                 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER;
1256                 break;
1257         }
1258         qctrl->minimum = min;
1259         qctrl->maximum = max;
1260         qctrl->step = step;
1261         qctrl->default_value = def;
1262         qctrl->reserved[0] = qctrl->reserved[1] = 0;
1263         snprintf(qctrl->name, sizeof(qctrl->name), name);
1264         return 0;
1265 }
1266
1267 /* Fill in a struct v4l2_queryctrl with standard values based on
1268    the control ID. */
1269 int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl)
1270 {
1271         switch (qctrl->id) {
1272         /* USER controls */
1273         case V4L2_CID_USER_CLASS:
1274         case V4L2_CID_MPEG_CLASS:
1275                 return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0);
1276         case V4L2_CID_AUDIO_VOLUME:
1277                 return v4l2_ctrl_query_fill(qctrl, 0, 65535, 65535 / 100, 58880);
1278         case V4L2_CID_AUDIO_MUTE:
1279         case V4L2_CID_AUDIO_LOUDNESS:
1280                 return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 0);
1281         case V4L2_CID_AUDIO_BALANCE:
1282         case V4L2_CID_AUDIO_BASS:
1283         case V4L2_CID_AUDIO_TREBLE:
1284                 return v4l2_ctrl_query_fill(qctrl, 0, 65535, 65535 / 100, 32768);
1285         case V4L2_CID_BRIGHTNESS:
1286                 return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 128);
1287         case V4L2_CID_CONTRAST:
1288         case V4L2_CID_SATURATION:
1289                 return v4l2_ctrl_query_fill(qctrl, 0, 127, 1, 64);
1290         case V4L2_CID_HUE:
1291                 return v4l2_ctrl_query_fill(qctrl, -128, 127, 1, 0);
1292
1293         /* MPEG controls */
1294         case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
1295                 return v4l2_ctrl_query_fill(qctrl,
1296                                 V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100,
1297                                 V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000, 1,
1298                                 V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000);
1299         case V4L2_CID_MPEG_AUDIO_ENCODING:
1300                 return v4l2_ctrl_query_fill(qctrl,
1301                                 V4L2_MPEG_AUDIO_ENCODING_LAYER_1,
1302                                 V4L2_MPEG_AUDIO_ENCODING_LAYER_3, 1,
1303                                 V4L2_MPEG_AUDIO_ENCODING_LAYER_2);
1304         case V4L2_CID_MPEG_AUDIO_L1_BITRATE:
1305                 return v4l2_ctrl_query_fill(qctrl,
1306                                 V4L2_MPEG_AUDIO_L1_BITRATE_32K,
1307                                 V4L2_MPEG_AUDIO_L1_BITRATE_448K, 1,
1308                                 V4L2_MPEG_AUDIO_L1_BITRATE_256K);
1309         case V4L2_CID_MPEG_AUDIO_L2_BITRATE:
1310                 return v4l2_ctrl_query_fill(qctrl,
1311                                 V4L2_MPEG_AUDIO_L2_BITRATE_32K,
1312                                 V4L2_MPEG_AUDIO_L2_BITRATE_384K, 1,
1313                                 V4L2_MPEG_AUDIO_L2_BITRATE_224K);
1314         case V4L2_CID_MPEG_AUDIO_L3_BITRATE:
1315                 return v4l2_ctrl_query_fill(qctrl,
1316                                 V4L2_MPEG_AUDIO_L3_BITRATE_32K,
1317                                 V4L2_MPEG_AUDIO_L3_BITRATE_320K, 1,
1318                                 V4L2_MPEG_AUDIO_L3_BITRATE_192K);
1319         case V4L2_CID_MPEG_AUDIO_MODE:
1320                 return v4l2_ctrl_query_fill(qctrl,
1321                                 V4L2_MPEG_AUDIO_MODE_STEREO,
1322                                 V4L2_MPEG_AUDIO_MODE_MONO, 1,
1323                                 V4L2_MPEG_AUDIO_MODE_STEREO);
1324         case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION:
1325                 return v4l2_ctrl_query_fill(qctrl,
1326                                 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4,
1327                                 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16, 1,
1328                                 V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4);
1329         case V4L2_CID_MPEG_AUDIO_EMPHASIS:
1330                 return v4l2_ctrl_query_fill(qctrl,
1331                                 V4L2_MPEG_AUDIO_EMPHASIS_NONE,
1332                                 V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17, 1,
1333                                 V4L2_MPEG_AUDIO_EMPHASIS_NONE);
1334         case V4L2_CID_MPEG_AUDIO_CRC:
1335                 return v4l2_ctrl_query_fill(qctrl,
1336                                 V4L2_MPEG_AUDIO_CRC_NONE,
1337                                 V4L2_MPEG_AUDIO_CRC_CRC16, 1,
1338                                 V4L2_MPEG_AUDIO_CRC_NONE);
1339         case V4L2_CID_MPEG_VIDEO_ENCODING:
1340                 return v4l2_ctrl_query_fill(qctrl,
1341                                 V4L2_MPEG_VIDEO_ENCODING_MPEG_1,
1342                                 V4L2_MPEG_VIDEO_ENCODING_MPEG_2, 1,
1343                                 V4L2_MPEG_VIDEO_ENCODING_MPEG_2);
1344         case V4L2_CID_MPEG_VIDEO_ASPECT:
1345                 return v4l2_ctrl_query_fill(qctrl,
1346                                 V4L2_MPEG_VIDEO_ASPECT_1x1,
1347                                 V4L2_MPEG_VIDEO_ASPECT_221x100, 1,
1348                                 V4L2_MPEG_VIDEO_ASPECT_4x3);
1349         case V4L2_CID_MPEG_VIDEO_B_FRAMES:
1350                 return v4l2_ctrl_query_fill(qctrl, 0, 33, 1, 2);
1351         case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
1352                 return v4l2_ctrl_query_fill(qctrl, 1, 34, 1, 12);
1353         case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE:
1354                 return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 1);
1355         case V4L2_CID_MPEG_VIDEO_PULLDOWN:
1356                 return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 0);
1357         case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
1358                 return v4l2_ctrl_query_fill(qctrl,
1359                                 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR,
1360                                 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, 1,
1361                                 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR);
1362         case V4L2_CID_MPEG_VIDEO_BITRATE:
1363                 return v4l2_ctrl_query_fill(qctrl, 0, 27000000, 1, 6000000);
1364         case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK:
1365                 return v4l2_ctrl_query_fill(qctrl, 0, 27000000, 1, 8000000);
1366         case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION:
1367                 return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0);
1368         case V4L2_CID_MPEG_STREAM_TYPE:
1369                 return v4l2_ctrl_query_fill(qctrl,
1370                                 V4L2_MPEG_STREAM_TYPE_MPEG2_PS,
1371                                 V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD, 1,
1372                                 V4L2_MPEG_STREAM_TYPE_MPEG2_PS);
1373         case V4L2_CID_MPEG_STREAM_PID_PMT:
1374                 return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 16);
1375         case V4L2_CID_MPEG_STREAM_PID_AUDIO:
1376                 return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 260);
1377         case V4L2_CID_MPEG_STREAM_PID_VIDEO:
1378                 return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 256);
1379         case V4L2_CID_MPEG_STREAM_PID_PCR:
1380                 return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 259);
1381         case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO:
1382                 return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0);
1383         case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO:
1384                 return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0);
1385         case V4L2_CID_MPEG_STREAM_VBI_FMT:
1386                 return v4l2_ctrl_query_fill(qctrl,
1387                                 V4L2_MPEG_STREAM_VBI_FMT_NONE,
1388                                 V4L2_MPEG_STREAM_VBI_FMT_IVTV, 1,
1389                                 V4L2_MPEG_STREAM_VBI_FMT_NONE);
1390         default:
1391                 return -EINVAL;
1392         }
1393 }
1394
1395 /* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and
1396    the menu. The qctrl pointer may be NULL, in which case it is ignored. */
1397 int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qctrl,
1398                const char **menu_items)
1399 {
1400         int i;
1401
1402         if (menu_items == NULL ||
1403             (qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum)))
1404                 return -EINVAL;
1405         for (i = 0; i < qmenu->index && menu_items[i]; i++) ;
1406         if (menu_items[i] == NULL || menu_items[i][0] == '\0')
1407                 return -EINVAL;
1408         snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]);
1409         qmenu->reserved = 0;
1410         return 0;
1411 }
1412
1413 /* ctrl_classes points to an array of u32 pointers, the last element is
1414    a NULL pointer. Each u32 array is a 0-terminated array of control IDs.
1415    Each array must be sorted low to high and belong to the same control
1416    class. The array of u32 pointer must also be sorted, from low class IDs
1417    to high class IDs.
1418
1419    This function returns the first ID that follows after the given ID.
1420    When no more controls are available 0 is returned. */
1421 u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id)
1422 {
1423         u32 ctrl_class;
1424         const u32 *pctrl;
1425
1426         /* if no query is desired, then just return the control ID */
1427         if ((id & V4L2_CTRL_FLAG_NEXT_CTRL) == 0)
1428                 return id;
1429         if (ctrl_classes == NULL)
1430                 return 0;
1431         id &= V4L2_CTRL_ID_MASK;
1432         ctrl_class = V4L2_CTRL_ID2CLASS(id);
1433         id++;   /* select next control */
1434         /* find first class that matches (or is greater than) the class of
1435            the ID */
1436         while (*ctrl_classes && V4L2_CTRL_ID2CLASS(**ctrl_classes) < ctrl_class)
1437                 ctrl_classes++;
1438         /* no more classes */
1439         if (*ctrl_classes == NULL)
1440                 return 0;
1441         pctrl = *ctrl_classes;
1442         /* find first ctrl within the class that is >= ID */
1443         while (*pctrl && *pctrl < id) pctrl++;
1444         if (*pctrl)
1445                 return *pctrl;
1446         /* we are at the end of the controls of the current class. */
1447         /* continue with next class if available */
1448         ctrl_classes++;
1449         if (*ctrl_classes == NULL)
1450                 return 0;
1451         return **ctrl_classes;
1452 }
1453
1454 /* ----------------------------------------------------------------- */
1455
1456 EXPORT_SYMBOL(v4l2_video_std_construct);
1457
1458 EXPORT_SYMBOL(v4l2_prio_init);
1459 EXPORT_SYMBOL(v4l2_prio_change);
1460 EXPORT_SYMBOL(v4l2_prio_open);
1461 EXPORT_SYMBOL(v4l2_prio_close);
1462 EXPORT_SYMBOL(v4l2_prio_max);
1463 EXPORT_SYMBOL(v4l2_prio_check);
1464
1465 EXPORT_SYMBOL(v4l2_field_names);
1466 EXPORT_SYMBOL(v4l2_type_names);
1467 EXPORT_SYMBOL(v4l_printk_ioctl);
1468 EXPORT_SYMBOL(v4l_printk_ioctl_arg);
1469
1470 EXPORT_SYMBOL(v4l2_ctrl_next);
1471 EXPORT_SYMBOL(v4l2_ctrl_check);
1472 EXPORT_SYMBOL(v4l2_ctrl_get_menu);
1473 EXPORT_SYMBOL(v4l2_ctrl_query_menu);
1474 EXPORT_SYMBOL(v4l2_ctrl_query_fill);
1475 EXPORT_SYMBOL(v4l2_ctrl_query_fill_std);
1476
1477 /*
1478  * Local variables:
1479  * c-basic-offset: 8
1480  * End:
1481  */