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