blob: d330fa985bcc2049e4fbba5d16dc6af496583789 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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/config.h>
48#include <linux/module.h>
49#include <linux/types.h>
50#include <linux/kernel.h>
51#include <linux/sched.h>
52#include <linux/smp_lock.h>
53#include <linux/mm.h>
54#include <linux/string.h>
55#include <linux/errno.h>
56#include <asm/uaccess.h>
57#include <asm/system.h>
58#include <asm/pgtable.h>
59#include <asm/io.h>
60#include <asm/div64.h>
Michael Krufky5e453dc2006-01-09 15:32:31 -020061#include <linux/video_decoder.h>
62#include <media/v4l2-common.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
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
75MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr");
76MODULE_DESCRIPTION("misc helper functions for v4l2 device drivers");
77MODULE_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
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90/* Fill in the fields of a v4l2_standard structure according to the
91 'id' and 'transmission' parameters. Returns negative on error. */
92int 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;
Mauro Carvalho Chehab3ed33c32006-02-27 00:08:52 -0300100 if (id & V4L2_STD_525_60) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113/* ----------------------------------------------------------------- */
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
120int v4l2_prio_init(struct v4l2_prio_state *global)
121{
122 memset(global,0,sizeof(*global));
123 return 0;
124}
125
126int 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
141int 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
146int 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
153enum 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
164int 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/* ----------------------------------------------------------------- */
Mauro Carvalho Chehab2e0d4472006-02-27 00:08:58 -0300173/* some arrays for pretty-printing debug messages of enum types */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175char *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
186char *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
Mauro Carvalho Chehab2e0d4472006-02-27 00:08:58 -0300194static 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
Michael Krufky5e453dc2006-01-09 15:32:31 -0200202/* ------------------------------------------------------------------ */
203/* debug help functions */
204
205#ifdef HAVE_V4L1
206static 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"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236};
Michael Krufky5e453dc2006-01-09 15:32:31 -0200237#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
238#endif
239
240static 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};
298#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
299
300static const char *v4l2_int_ioctls[] = {
301#ifdef HAVE_VIDEO_DECODER
302 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
303 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
304 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
305 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
306 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
307 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
308 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
309 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
310 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
311 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
312 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
313#endif
314 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
Michael Krufky5e453dc2006-01-09 15:32:31 -0200315
316 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
317 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
318 [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG",
319
Hans Verkuil3bbe5a82006-04-01 15:27:52 -0300320 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
Michael Krufky5e453dc2006-01-09 15:32:31 -0200321 [_IOC_NR(VIDIOC_INT_S_REGISTER)] = "VIDIOC_INT_S_REGISTER",
322 [_IOC_NR(VIDIOC_INT_G_REGISTER)] = "VIDIOC_INT_G_REGISTER",
323 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
324 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
325 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
326 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
327 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
328 [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)] = "VIDIOC_INT_G_CHIP_IDENT",
Hans Verkuil3bbe5a82006-04-01 15:27:52 -0300329 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
330 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
331 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
332 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
333 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
334 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING"
Michael Krufky5e453dc2006-01-09 15:32:31 -0200335};
336#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
337
Mauro Carvalho Chehab0bbb9c12006-02-27 00:08:55 -0300338static void v4l_print_pix_fmt (char *s, struct v4l2_pix_format *fmt)
339{
340 printk ("%s: width=%d, height=%d, format=%d, field=%s, "
341 "bytesperline=%d sizeimage=%d, colorspace=%d\n", s,
342 fmt->width,fmt->height,fmt->pixelformat,
Mauro Carvalho Chehab2e0d4472006-02-27 00:08:58 -0300343 prt_names(fmt->field,v4l2_field_names),
Mauro Carvalho Chehab0bbb9c12006-02-27 00:08:55 -0300344 fmt->bytesperline,fmt->sizeimage,fmt->colorspace);
345};
346
Michael Krufky5e453dc2006-01-09 15:32:31 -0200347/* Common ioctl debug function. This function can be used by
348 external ioctl messages as well as internal V4L ioctl */
349void v4l_printk_ioctl(unsigned int cmd)
350{
351 char *dir;
352
353 switch (_IOC_DIR(cmd)) {
354 case _IOC_NONE: dir = "--"; break;
355 case _IOC_READ: dir = "r-"; break;
356 case _IOC_WRITE: dir = "-w"; break;
357 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
358 default: dir = "*ERR*"; break;
359 }
360 switch (_IOC_TYPE(cmd)) {
361 case 'd':
362 printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n",
363 (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ?
364 v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
365 break;
366#ifdef HAVE_V4L1
367 case 'v':
368 printk("v4l1 ioctl %s, dir=%s (0x%08x)\n",
369 (_IOC_NR(cmd) < V4L1_IOCTLS) ?
370 v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
371 break;
372#endif
373 case 'V':
374 printk("v4l2 ioctl %s, dir=%s (0x%08x)\n",
375 (_IOC_NR(cmd) < V4L2_IOCTLS) ?
376 v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
377 break;
378
379 default:
380 printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n",
381 _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
382 }
383}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300385/* Common ioctl debug function. This function can be used by
386 external ioctl messages as well as internal V4L ioctl and its
387 arguments */
388void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
389{
390 printk(s);
391 printk(": ");
392 v4l_printk_ioctl(cmd);
393 switch (cmd) {
394 case VIDIOC_INT_G_CHIP_IDENT:
395 {
396 enum v4l2_chip_ident *p=arg;
397 printk ("%s: chip ident=%d\n", s, *p);
398 break;
399 }
400 case VIDIOC_G_PRIORITY:
401 case VIDIOC_S_PRIORITY:
402 {
403 enum v4l2_priority *p=arg;
404 printk ("%s: priority=%d\n", s, *p);
405 break;
406 }
407 case VIDIOC_INT_S_TUNER_MODE:
408 {
409 enum v4l2_tuner_type *p=arg;
410 printk ("%s: tuner type=%d\n", s, *p);
411 break;
412 }
413 case DECODER_SET_VBI_BYPASS:
414 case DECODER_ENABLE_OUTPUT:
415 case DECODER_GET_STATUS:
416 case DECODER_SET_OUTPUT:
417 case DECODER_SET_INPUT:
418 case DECODER_SET_GPIO:
419 case DECODER_SET_NORM:
420 case VIDIOCCAPTURE:
421 case VIDIOCSYNC:
422 case VIDIOCSWRITEMODE:
423 case TUNER_SET_TYPE_ADDR:
424 case TUNER_SET_STANDBY:
425 case TDA9887_SET_CONFIG:
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300426 case VIDIOC_OVERLAY_OLD:
427 case VIDIOC_STREAMOFF:
428 case VIDIOC_G_OUTPUT:
429 case VIDIOC_S_OUTPUT:
430 case VIDIOC_STREAMON:
431 case VIDIOC_G_INPUT:
432 case VIDIOC_OVERLAY:
433 case VIDIOC_S_INPUT:
434 {
435 int *p=arg;
436 printk ("%s: value=%d\n", s, *p);
437 break;
438 }
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300439 case VIDIOC_G_AUDIO:
440 case VIDIOC_S_AUDIO:
441 case VIDIOC_ENUMAUDIO:
442 case VIDIOC_G_AUDIO_OLD:
443 {
444 struct v4l2_audio *p=arg;
445
446 printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n",
447 s,p->index, p->name,p->capability, p->mode);
448 break;
449 }
450 case VIDIOC_G_AUDOUT:
451 case VIDIOC_S_AUDOUT:
452 case VIDIOC_ENUMAUDOUT:
453 case VIDIOC_G_AUDOUT_OLD:
454 {
455 struct v4l2_audioout *p=arg;
456 printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n", s,
457 p->index, p->name, p->capability,p->mode);
458 break;
459 }
460 case VIDIOC_QBUF:
461 case VIDIOC_DQBUF:
462 case VIDIOC_QUERYBUF:
463 {
464 struct v4l2_buffer *p=arg;
465 struct v4l2_timecode *tc=&p->timecode;
Mauro Carvalho Chehab0bbb9c12006-02-27 00:08:55 -0300466 printk ("%s: %02ld:%02d:%02d.%08ld index=%d, type=%s, "
Hans Verkuil2474ed42006-03-19 12:35:57 -0300467 "bytesused=%d, flags=0x%08x, "
Mauro Carvalho Chehab2e0d4472006-02-27 00:08:58 -0300468 "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx\n",
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300469 s,
470 (p->timestamp.tv_sec/3600),
471 (int)(p->timestamp.tv_sec/60)%60,
472 (int)(p->timestamp.tv_sec%60),
473 p->timestamp.tv_usec,
Mauro Carvalho Chehab0bbb9c12006-02-27 00:08:55 -0300474 p->index,
Mauro Carvalho Chehab2e0d4472006-02-27 00:08:58 -0300475 prt_names(p->type,v4l2_type_names),
Mauro Carvalho Chehab0bbb9c12006-02-27 00:08:55 -0300476 p->bytesused,p->flags,
Mauro Carvalho Chehab2e0d4472006-02-27 00:08:58 -0300477 p->field,p->sequence,
478 prt_names(p->memory,v4l2_memory_names),
479 p->m.userptr);
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300480 printk ("%s: timecode= %02d:%02d:%02d type=%d, "
Andrew Morton22fe0872006-03-25 09:24:19 -0300481 "flags=0x%08x, frames=%d, userbits=0x%p\n",
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300482 s,tc->hours,tc->minutes,tc->seconds,
Andrew Morton52459532006-03-22 15:01:59 -0300483 tc->type, tc->flags, tc->frames, tc->userbits);
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300484 break;
485 }
486 case VIDIOC_QUERYCAP:
487 {
488 struct v4l2_capability *p=arg;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300489 printk ("%s: driver=%s, card=%s, bus=%s, version=0x%08x, "
490 "capabilities=0x%08x\n", s,
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300491 p->driver,p->card,p->bus_info,
492 p->version,
493 p->capabilities);
494 break;
495 }
496 case VIDIOC_G_CTRL:
497 case VIDIOC_S_CTRL:
498 case VIDIOC_S_CTRL_OLD:
499 {
500 struct v4l2_control *p=arg;
501 printk ("%s: id=%d, value=%d\n", s, p->id, p->value);
502 break;
503 }
504 case VIDIOC_G_CROP:
505 case VIDIOC_S_CROP:
506 {
507 struct v4l2_crop *p=arg;
508 /*FIXME: Should also show rect structs */
509 printk ("%s: type=%d\n", s, p->type);
510 break;
511 }
512 case VIDIOC_CROPCAP:
513 case VIDIOC_CROPCAP_OLD:
514 {
515 struct v4l2_cropcap *p=arg;
516 /*FIXME: Should also show rect structs */
517 printk ("%s: type=%d\n", s, p->type);
518 break;
519 }
520 case VIDIOC_INT_DECODE_VBI_LINE:
521 {
522 struct v4l2_decode_vbi_line *p=arg;
523 printk ("%s: is_second_field=%d, ptr=0x%08lx, line=%d, "
524 "type=%d\n", s,
525 p->is_second_field,(unsigned long)p->p,p->line,p->type);
526 break;
527 }
528 case VIDIOC_ENUM_FMT:
529 {
530 struct v4l2_fmtdesc *p=arg;
531 printk ("%s: index=%d, type=%d, flags=%d, description=%s,"
532 " pixelformat=%d\n", s,
533 p->index, p->type, p->flags,p->description,
534 p->pixelformat);
535
536 break;
537 }
538 case VIDIOC_G_FMT:
539 case VIDIOC_S_FMT:
540 case VIDIOC_TRY_FMT:
541 {
542 struct v4l2_format *p=arg;
Mauro Carvalho Chehab0bbb9c12006-02-27 00:08:55 -0300543 printk ("%s: type=%s\n", s,
Mauro Carvalho Chehab2e0d4472006-02-27 00:08:58 -0300544 prt_names(p->type,v4l2_type_names));
Mauro Carvalho Chehab0bbb9c12006-02-27 00:08:55 -0300545 switch (p->type) {
546 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
547 v4l_print_pix_fmt (s, &p->fmt.pix);
548 break;
549 default:
550 break;
551 }
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300552 }
553 case VIDIOC_G_FBUF:
554 case VIDIOC_S_FBUF:
555 {
556 struct v4l2_framebuffer *p=arg;
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300557 printk ("%s: capability=%d, flags=%d, base=0x%08lx\n", s,
558 p->capability,p->flags, (unsigned long)p->base);
Mauro Carvalho Chehab0bbb9c12006-02-27 00:08:55 -0300559 v4l_print_pix_fmt (s, &p->fmt);
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300560 break;
561 }
562 case VIDIOC_G_FREQUENCY:
563 case VIDIOC_S_FREQUENCY:
564 {
565 struct v4l2_frequency *p=arg;
566 printk ("%s: tuner=%d, type=%d, frequency=%d\n", s,
567 p->tuner,p->type,p->frequency);
568 break;
569 }
570 case VIDIOC_ENUMINPUT:
571 {
572 struct v4l2_input *p=arg;
573 printk ("%s: index=%d, name=%s, type=%d, audioset=%d, "
Andrew Morton52459532006-03-22 15:01:59 -0300574 "tuner=%d, std=%Ld, status=%d\n", s,
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300575 p->index,p->name,p->type,p->audioset,
Andrew Morton52459532006-03-22 15:01:59 -0300576 p->tuner,
577 (unsigned long long)p->std,
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300578 p->status);
579 break;
580 }
581 case VIDIOC_G_JPEGCOMP:
582 case VIDIOC_S_JPEGCOMP:
583 {
584 struct v4l2_jpegcompression *p=arg;
585 printk ("%s: quality=%d, APPn=%d, APP_len=%d, COM_len=%d,"
586 " jpeg_markers=%d\n", s,
587 p->quality,p->APPn,p->APP_len,
588 p->COM_len,p->jpeg_markers);
589 break;
590 }
591 case VIDIOC_G_MODULATOR:
592 case VIDIOC_S_MODULATOR:
593 {
594 struct v4l2_modulator *p=arg;
595 printk ("%s: index=%d, name=%s, capability=%d, rangelow=%d,"
596 " rangehigh=%d, txsubchans=%d\n", s,
597 p->index, p->name,p->capability,p->rangelow,
598 p->rangehigh,p->txsubchans);
599 break;
600 }
601 case VIDIOC_G_MPEGCOMP:
602 case VIDIOC_S_MPEGCOMP:
603 {
604 struct v4l2_mpeg_compression *p=arg;
605 /*FIXME: Several fields not shown */
606 printk ("%s: ts_pid_pmt=%d, ts_pid_audio=%d, ts_pid_video=%d, "
607 "ts_pid_pcr=%d, ps_size=%d, au_sample_rate=%d, "
608 "au_pesid=%c, vi_frame_rate=%d, vi_frames_per_gop=%d, "
609 "vi_bframes_count=%d, vi_pesid=%c\n", s,
610 p->ts_pid_pmt,p->ts_pid_audio, p->ts_pid_video,
611 p->ts_pid_pcr, p->ps_size, p->au_sample_rate,
612 p->au_pesid, p->vi_frame_rate,
613 p->vi_frames_per_gop, p->vi_bframes_count,
614 p->vi_pesid);
615 break;
616 }
617 case VIDIOC_ENUMOUTPUT:
618 {
619 struct v4l2_output *p=arg;
620 printk ("%s: index=%d, name=%s,type=%d, audioset=%d, "
Andrew Morton52459532006-03-22 15:01:59 -0300621 "modulator=%d, std=%Ld\n",
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300622 s,p->index,p->name,p->type,p->audioset,
Andrew Morton52459532006-03-22 15:01:59 -0300623 p->modulator,
624 (unsigned long long)p->std);
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300625 break;
626 }
627 case VIDIOC_QUERYCTRL:
628 {
629 struct v4l2_queryctrl *p=arg;
630 printk ("%s: id=%d, type=%d, name=%s, min/max=%d/%d,"
631 " step=%d, default=%d, flags=0x%08x\n", s,
632 p->id,p->type,p->name,p->minimum,p->maximum,
633 p->step,p->default_value,p->flags);
634 break;
635 }
636 case VIDIOC_QUERYMENU:
637 {
638 struct v4l2_querymenu *p=arg;
639 printk ("%s: id=%d, index=%d, name=%s\n", s,
640 p->id,p->index,p->name);
641 break;
642 }
643 case VIDIOC_INT_G_REGISTER:
644 case VIDIOC_INT_S_REGISTER:
645 {
646 struct v4l2_register *p=arg;
647 printk ("%s: i2c_id=%d, reg=%lu, val=%d\n", s,
648 p->i2c_id,p->reg,p->val);
649
650 break;
651 }
652 case VIDIOC_REQBUFS:
653 {
654 struct v4l2_requestbuffers *p=arg;
Mauro Carvalho Chehab2e0d4472006-02-27 00:08:58 -0300655 printk ("%s: count=%d, type=%s, memory=%s\n", s,
656 p->count,
657 prt_names(p->type,v4l2_type_names),
658 prt_names(p->memory,v4l2_memory_names));
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300659 break;
660 }
661 case VIDIOC_INT_S_AUDIO_ROUTING:
662 case VIDIOC_INT_S_VIDEO_ROUTING:
663 case VIDIOC_INT_G_AUDIO_ROUTING:
664 case VIDIOC_INT_G_VIDEO_ROUTING:
665 {
666 struct v4l2_routing *p=arg;
Hans Verkuil2474ed42006-03-19 12:35:57 -0300667 printk ("%s: input=0x%x, output=0x%x\n", s, p->input, p->output);
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300668 break;
669 }
670 case VIDIOC_G_SLICED_VBI_CAP:
671 {
672 struct v4l2_sliced_vbi_cap *p=arg;
673 printk ("%s: service_set=%d\n", s,
674 p->service_set);
675 break;
676 }
677 case VIDIOC_INT_S_VBI_DATA:
678 case VIDIOC_INT_G_VBI_DATA:
679 {
680 struct v4l2_sliced_vbi_data *p=arg;
681 printk ("%s: id=%d, field=%d, line=%d\n", s,
682 p->id, p->field, p->line);
683 break;
684 }
685 case VIDIOC_ENUMSTD:
686 {
687 struct v4l2_standard *p=arg;
Andrew Morton52459532006-03-22 15:01:59 -0300688 printk ("%s: index=%d, id=%Ld, name=%s, fps=%d/%d, "
689 "framelines=%d\n", s, p->index,
690 (unsigned long long)p->id, p->name,
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300691 p->frameperiod.numerator,
692 p->frameperiod.denominator,
693 p->framelines);
694
695 break;
696 }
697 case VIDIOC_G_PARM:
698 case VIDIOC_S_PARM:
699 case VIDIOC_S_PARM_OLD:
700 {
701 struct v4l2_streamparm *p=arg;
702 printk ("%s: type=%d\n", s, p->type);
703
704 break;
705 }
706 case VIDIOC_G_TUNER:
707 case VIDIOC_S_TUNER:
708 {
709 struct v4l2_tuner *p=arg;
710 printk ("%s: index=%d, name=%s, type=%d, capability=%d, "
711 "rangelow=%d, rangehigh=%d, signal=%d, afc=%d, "
712 "rxsubchans=%d, audmode=%d\n", s,
713 p->index, p->name, p->type,
714 p->capability, p->rangelow,p->rangehigh,
715 p->rxsubchans, p->audmode, p->signal,
716 p->afc);
717 break;
718 }
719 case VIDIOCGVBIFMT:
720 case VIDIOCSVBIFMT:
721 {
722 struct vbi_format *p=arg;
723 printk ("%s: sampling_rate=%d, samples_per_line=%d, "
724 "sample_format=%d, start=%d/%d, count=%d/%d, flags=%d\n", s,
725 p->sampling_rate,p->samples_per_line,
726 p->sample_format,p->start[0],p->start[1],
727 p->count[0],p->count[1],p->flags);
728 break;
729 }
730 case VIDIOCGAUDIO:
731 case VIDIOCSAUDIO:
732 {
733 struct video_audio *p=arg;
734 printk ("%s: audio=%d, volume=%d, bass=%d, treble=%d, "
735 "flags=%d, name=%s, mode=%d, balance=%d, step=%d\n",
736 s,p->audio,p->volume,p->bass, p->treble,
737 p->flags,p->name,p->mode,p->balance,p->step);
738 break;
739 }
740 case VIDIOCGFBUF:
741 case VIDIOCSFBUF:
742 {
743 struct video_buffer *p=arg;
744 printk ("%s: base=%08lx, height=%d, width=%d, depth=%d, "
745 "bytesperline=%d\n", s,
746 (unsigned long) p->base, p->height, p->width,
747 p->depth,p->bytesperline);
748 break;
749 }
750 case VIDIOCGCAP:
751 {
752 struct video_capability *p=arg;
753 printk ("%s: name=%s, type=%d, channels=%d, audios=%d, "
754 "maxwidth=%d, maxheight=%d, minwidth=%d, minheight=%d\n",
755 s,p->name,p->type,p->channels,p->audios,
756 p->maxwidth,p->maxheight,p->minwidth,
757 p->minheight);
758
759 break;
760 }
761 case VIDIOCGCAPTURE:
762 case VIDIOCSCAPTURE:
763 {
764 struct video_capture *p=arg;
765 printk ("%s: x=%d, y=%d, width=%d, height=%d, decimation=%d,"
766 " flags=%d\n", s,
767 p->x, p->y,p->width, p->height,
768 p->decimation,p->flags);
769 break;
770 }
771 case VIDIOCGCHAN:
772 case VIDIOCSCHAN:
773 {
774 struct video_channel *p=arg;
775 printk ("%s: channel=%d, name=%s, tuners=%d, flags=%d, "
776 "type=%d, norm=%d\n", s,
777 p->channel,p->name,p->tuners,
778 p->flags,p->type,p->norm);
779
780 break;
781 }
782 case VIDIOCSMICROCODE:
783 {
784 struct video_code *p=arg;
785 printk ("%s: loadwhat=%s, datasize=%d\n", s,
786 p->loadwhat,p->datasize);
787 break;
788 }
789 case DECODER_GET_CAPABILITIES:
790 {
791 struct video_decoder_capability *p=arg;
792 printk ("%s: flags=%d, inputs=%d, outputs=%d\n", s,
793 p->flags,p->inputs,p->outputs);
794 break;
795 }
796 case DECODER_INIT:
797 {
798 struct video_decoder_init *p=arg;
799 printk ("%s: len=%c\n", s, p->len);
800 break;
801 }
802 case VIDIOCGPLAYINFO:
803 {
804 struct video_info *p=arg;
805 printk ("%s: frame_count=%d, h_size=%d, v_size=%d, "
806 "smpte_timecode=%d, picture_type=%d, "
807 "temporal_reference=%d, user_data=%s\n", s,
808 p->frame_count, p->h_size,
809 p->v_size, p->smpte_timecode,
810 p->picture_type, p->temporal_reference,
811 p->user_data);
812 break;
813 }
814 case VIDIOCKEY:
815 {
816 struct video_key *p=arg;
817 printk ("%s: key=%s, flags=%d\n", s,
818 p->key, p->flags);
819 break;
820 }
821 case VIDIOCGMBUF:
822 {
823 struct video_mbuf *p=arg;
824 printk ("%s: size=%d, frames=%d, offsets=0x%08lx\n", s,
825 p->size,
826 p->frames,
827 (unsigned long)p->offsets);
828 break;
829 }
830 case VIDIOCMCAPTURE:
831 {
832 struct video_mmap *p=arg;
833 printk ("%s: frame=%d, height=%d, width=%d, format=%d\n", s,
834 p->frame,
835 p->height, p->width,
836 p->format);
837 break;
838 }
839 case VIDIOCGPICT:
840 case VIDIOCSPICT:
841 case DECODER_SET_PICTURE:
842 {
843 struct video_picture *p=arg;
844
845 printk ("%s: brightness=%d, hue=%d, colour=%d, contrast=%d,"
846 " whiteness=%d, depth=%d, palette=%d\n", s,
847 p->brightness, p->hue, p->colour,
848 p->contrast, p->whiteness, p->depth,
849 p->palette);
850 break;
851 }
852 case VIDIOCSPLAYMODE:
853 {
854 struct video_play_mode *p=arg;
855 printk ("%s: mode=%d, p1=%d, p2=%d\n", s,
856 p->mode,p->p1,p->p2);
857 break;
858 }
859 case VIDIOCGTUNER:
860 case VIDIOCSTUNER:
861 {
862 struct video_tuner *p=arg;
863 printk ("%s: tuner=%d, name=%s, rangelow=%ld, rangehigh=%ld, "
864 "flags=%d, mode=%d, signal=%d\n", s,
865 p->tuner, p->name,p->rangelow, p->rangehigh,
866 p->flags,p->mode, p->signal);
867 break;
868 }
869 case VIDIOCGUNIT:
870 {
871 struct video_unit *p=arg;
872 printk ("%s: video=%d, vbi=%d, radio=%d, audio=%d, "
873 "teletext=%d\n", s,
874 p->video,p->vbi,p->radio,p->audio,p->teletext);
875 break;
876 }
877 case VIDIOCGWIN:
878 case VIDIOCSWIN:
879 {
880 struct video_window *p=arg;
881 printk ("%s: x=%d, y=%d, width=%d, height=%d, chromakey=%d,"
882 " flags=%d, clipcount=%d\n", s,
883 p->x, p->y,p->width, p->height,
884 p->chromakey,p->flags,
885 p->clipcount);
886 break;
887 }
888 case VIDIOC_INT_AUDIO_CLOCK_FREQ:
889 case VIDIOC_INT_I2S_CLOCK_FREQ:
890 case VIDIOC_INT_S_STANDBY:
891 {
892 u32 *p=arg;
893
894 printk ("%s: value=%d\n", s, *p);
895 break;
896 }
897 case VIDIOCGFREQ:
898 case VIDIOCSFREQ:
899 {
900 unsigned long *p=arg;
901 printk ("%s: value=%lu\n", s, *p);
902 break;
903 }
904 case VIDIOC_G_STD:
905 case VIDIOC_S_STD:
906 case VIDIOC_QUERYSTD:
907 {
908 v4l2_std_id *p=arg;
909
Andrew Morton52459532006-03-22 15:01:59 -0300910 printk ("%s: value=%Lu\n", s, (unsigned long long)*p);
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300911 break;
912 }
913 }
914}
915
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916/* ----------------------------------------------------------------- */
917
918EXPORT_SYMBOL(v4l2_video_std_construct);
919
920EXPORT_SYMBOL(v4l2_prio_init);
921EXPORT_SYMBOL(v4l2_prio_change);
922EXPORT_SYMBOL(v4l2_prio_open);
923EXPORT_SYMBOL(v4l2_prio_close);
924EXPORT_SYMBOL(v4l2_prio_max);
925EXPORT_SYMBOL(v4l2_prio_check);
926
927EXPORT_SYMBOL(v4l2_field_names);
928EXPORT_SYMBOL(v4l2_type_names);
Michael Krufky5e453dc2006-01-09 15:32:31 -0200929EXPORT_SYMBOL(v4l_printk_ioctl);
Mauro Carvalho Chehab41f38b42006-02-27 00:08:49 -0300930EXPORT_SYMBOL(v4l_printk_ioctl_arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931
932/*
933 * Local variables:
934 * c-basic-offset: 8
935 * End:
936 */