aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-02-02 09:25:31 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-02-18 09:14:53 -0500
commit057596eea8402aa8f7a670bf3195665aa8267204 (patch)
tree1c42fca7337e9b4000cb5d2fc2f9f7b53c7de31e /drivers/media/video
parent1a4e30c3eaffb83218977477bb83d54316844acb (diff)
V4L/DVB (7133): Fix Kconfig dependencies
As pointed by Adrian Bunk, with I2C=m and VIDEO_DEV=y, videodev brokes. This patch moves the functions that videodev needs from v4l2-common. It also fixes some Kconfig changes. After this patch, I2C=m / VIDEO_DEV=y will make v4l2 core statically linked into kernel. v4l2-common will be m, and all V4L drivers will also be m. This approach is very conservative, since it is possible to have V4L drivers that don't need I2C or v4l2-common. The better is to map what drivers really need v4l2-common, making them to select v4l2-common, and allowing the others to be 'y', 'm' and 'n'. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/Kconfig4
-rw-r--r--drivers/media/video/v4l2-common.c351
-rw-r--r--drivers/media/video/videodev.c444
3 files changed, 399 insertions, 400 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index a2e8987a6195..37072a21d8c9 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -4,14 +4,14 @@
4 4
5menuconfig VIDEO_CAPTURE_DRIVERS 5menuconfig VIDEO_CAPTURE_DRIVERS
6 bool "Video capture adapters" 6 bool "Video capture adapters"
7 depends on VIDEO_DEV 7 depends on VIDEO_V4L2
8 default y 8 default y
9 ---help--- 9 ---help---
10 Say Y here to enable selecting the video adapters for 10 Say Y here to enable selecting the video adapters for
11 webcams, analog TV, and hybrid analog/digital TV. 11 webcams, analog TV, and hybrid analog/digital TV.
12 Some of those devices also supports FM radio. 12 Some of those devices also supports FM radio.
13 13
14if VIDEO_CAPTURE_DRIVERS && VIDEO_DEV 14if VIDEO_CAPTURE_DRIVERS && VIDEO_V4L2
15 15
16config VIDEO_ADV_DEBUG 16config VIDEO_ADV_DEBUG
17 bool "Enable advanced debug functionality" 17 bool "Enable advanced debug functionality"
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 4a8fc170138b..34deb68ae568 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -56,7 +56,6 @@
56#include <asm/pgtable.h> 56#include <asm/pgtable.h>
57#include <asm/io.h> 57#include <asm/io.h>
58#include <asm/div64.h> 58#include <asm/div64.h>
59#include <linux/video_decoder.h>
60#define __OLD_VIDIOC_ /* To allow fixing old calls*/ 59#define __OLD_VIDIOC_ /* To allow fixing old calls*/
61#include <media/v4l2-common.h> 60#include <media/v4l2-common.h>
62#include <media/v4l2-chip-ident.h> 61#include <media/v4l2-chip-ident.h>
@@ -81,107 +80,6 @@ MODULE_LICENSE("GPL");
81 * Video Standard Operations (contributed by Michael Schimek) 80 * Video Standard Operations (contributed by Michael Schimek)
82 */ 81 */
83 82
84char *v4l2_norm_to_name(v4l2_std_id id)
85{
86 char *name;
87 u32 myid = id;
88
89 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
90 64 bit comparations. So, on that architecture, with some gcc variants,
91 compilation fails. Currently, the max value is 30bit wide.
92 */
93 BUG_ON(myid != id);
94
95 switch (myid) {
96 case V4L2_STD_PAL:
97 name="PAL"; break;
98 case V4L2_STD_PAL_BG:
99 name="PAL-BG"; break;
100 case V4L2_STD_PAL_DK:
101 name="PAL-DK"; break;
102 case V4L2_STD_PAL_B:
103 name="PAL-B"; break;
104 case V4L2_STD_PAL_B1:
105 name="PAL-B1"; break;
106 case V4L2_STD_PAL_G:
107 name="PAL-G"; break;
108 case V4L2_STD_PAL_H:
109 name="PAL-H"; break;
110 case V4L2_STD_PAL_I:
111 name="PAL-I"; break;
112 case V4L2_STD_PAL_D:
113 name="PAL-D"; break;
114 case V4L2_STD_PAL_D1:
115 name="PAL-D1"; break;
116 case V4L2_STD_PAL_K:
117 name="PAL-K"; break;
118 case V4L2_STD_PAL_M:
119 name="PAL-M"; break;
120 case V4L2_STD_PAL_N:
121 name="PAL-N"; break;
122 case V4L2_STD_PAL_Nc:
123 name="PAL-Nc"; break;
124 case V4L2_STD_PAL_60:
125 name="PAL-60"; break;
126 case V4L2_STD_NTSC:
127 name="NTSC"; break;
128 case V4L2_STD_NTSC_M:
129 name="NTSC-M"; break;
130 case V4L2_STD_NTSC_M_JP:
131 name="NTSC-M-JP"; break;
132 case V4L2_STD_NTSC_443:
133 name="NTSC-443"; break;
134 case V4L2_STD_NTSC_M_KR:
135 name="NTSC-M-KR"; break;
136 case V4L2_STD_SECAM:
137 name="SECAM"; break;
138 case V4L2_STD_SECAM_DK:
139 name="SECAM-DK"; break;
140 case V4L2_STD_SECAM_B:
141 name="SECAM-B"; break;
142 case V4L2_STD_SECAM_D:
143 name="SECAM-D"; break;
144 case V4L2_STD_SECAM_G:
145 name="SECAM-G"; break;
146 case V4L2_STD_SECAM_H:
147 name="SECAM-H"; break;
148 case V4L2_STD_SECAM_K:
149 name="SECAM-K"; break;
150 case V4L2_STD_SECAM_K1:
151 name="SECAM-K1"; break;
152 case V4L2_STD_SECAM_L:
153 name="SECAM-L"; break;
154 case V4L2_STD_SECAM_LC:
155 name="SECAM-LC"; break;
156 default:
157 name="Unknown"; break;
158 }
159
160 return name;
161}
162
163/* Fill in the fields of a v4l2_standard structure according to the
164 'id' and 'transmission' parameters. Returns negative on error. */
165int v4l2_video_std_construct(struct v4l2_standard *vs,
166 int id, char *name)
167{
168 u32 index = vs->index;
169
170 memset(vs, 0, sizeof(struct v4l2_standard));
171 vs->index = index;
172 vs->id = id;
173 if (id & V4L2_STD_525_60) {
174 vs->frameperiod.numerator = 1001;
175 vs->frameperiod.denominator = 30000;
176 vs->framelines = 525;
177 } else {
178 vs->frameperiod.numerator = 1;
179 vs->frameperiod.denominator = 25;
180 vs->framelines = 625;
181 }
182 strlcpy(vs->name,name,sizeof(vs->name));
183 return 0;
184}
185 83
186/* ----------------------------------------------------------------- */ 84/* ----------------------------------------------------------------- */
187/* priority handling */ 85/* priority handling */
@@ -195,6 +93,7 @@ int v4l2_prio_init(struct v4l2_prio_state *global)
195 memset(global,0,sizeof(*global)); 93 memset(global,0,sizeof(*global));
196 return 0; 94 return 0;
197} 95}
96EXPORT_SYMBOL(v4l2_prio_init);
198 97
199int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, 98int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
200 enum v4l2_priority new) 99 enum v4l2_priority new)
@@ -210,11 +109,13 @@ int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
210 *local = new; 109 *local = new;
211 return 0; 110 return 0;
212} 111}
112EXPORT_SYMBOL(v4l2_prio_change);
213 113
214int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local) 114int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local)
215{ 115{
216 return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT); 116 return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT);
217} 117}
118EXPORT_SYMBOL(v4l2_prio_open);
218 119
219int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local) 120int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local)
220{ 121{
@@ -222,6 +123,7 @@ int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local)
222 atomic_dec(&global->prios[*local]); 123 atomic_dec(&global->prios[*local]);
223 return 0; 124 return 0;
224} 125}
126EXPORT_SYMBOL(v4l2_prio_close);
225 127
226enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) 128enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
227{ 129{
@@ -233,6 +135,7 @@ enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
233 return V4L2_PRIORITY_BACKGROUND; 135 return V4L2_PRIORITY_BACKGROUND;
234 return V4L2_PRIORITY_UNSET; 136 return V4L2_PRIORITY_UNSET;
235} 137}
138EXPORT_SYMBOL(v4l2_prio_max);
236 139
237int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local) 140int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local)
238{ 141{
@@ -240,220 +143,7 @@ int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local)
240 return -EBUSY; 143 return -EBUSY;
241 return 0; 144 return 0;
242} 145}
243 146EXPORT_SYMBOL(v4l2_prio_check);
244
245/* ----------------------------------------------------------------- */
246/* some arrays for pretty-printing debug messages of enum types */
247
248char *v4l2_field_names[] = {
249 [V4L2_FIELD_ANY] = "any",
250 [V4L2_FIELD_NONE] = "none",
251 [V4L2_FIELD_TOP] = "top",
252 [V4L2_FIELD_BOTTOM] = "bottom",
253 [V4L2_FIELD_INTERLACED] = "interlaced",
254 [V4L2_FIELD_SEQ_TB] = "seq-tb",
255 [V4L2_FIELD_SEQ_BT] = "seq-bt",
256 [V4L2_FIELD_ALTERNATE] = "alternate",
257 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
258 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
259};
260
261char *v4l2_type_names[] = {
262 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
263 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
264 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
265 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
266 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
267 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
268 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
269 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over",
270};
271
272/* ------------------------------------------------------------------ */
273/* debug help functions */
274
275#ifdef CONFIG_VIDEO_V4L1_COMPAT
276static const char *v4l1_ioctls[] = {
277 [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
278 [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN",
279 [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN",
280 [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER",
281 [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER",
282 [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT",
283 [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT",
284 [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE",
285 [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN",
286 [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN",
287 [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF",
288 [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF",
289 [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY",
290 [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ",
291 [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ",
292 [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO",
293 [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO",
294 [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC",
295 [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE",
296 [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF",
297 [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT",
298 [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE",
299 [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE",
300 [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE",
301 [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
302 [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO",
303 [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
304 [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT",
305 [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT"
306};
307#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
308#endif
309
310static const char *v4l2_ioctls[] = {
311 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
312 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
313 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
314 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
315 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
316 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
317 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
318 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
319 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
320 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
321 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
322 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
323 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
324 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
325 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
326 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
327 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
328 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
329 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
330 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
331 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
332 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
333 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
334 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
335 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
336 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
337 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
338 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
339 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
340 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
341 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
342 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
343 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
344 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
345 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
346 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
347 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
348 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
349 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
350 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
351 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
352 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
353 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
354 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
355 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
356 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
357 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
358 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
359 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
360 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
361 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
362 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
363 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
364 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
365 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
366#if 1
367 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
368 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
369 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
370 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
371 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
372
373 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
374 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
375
376 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT",
377#endif
378};
379#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
380
381static const char *v4l2_int_ioctls[] = {
382#ifdef CONFIG_VIDEO_V4L1_COMPAT
383 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
384 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
385 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
386 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
387 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
388 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
389 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
390 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
391 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
392 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
393 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
394#endif
395 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
396
397 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
398 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
399 [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG",
400
401 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
402 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
403 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
404 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
405 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
406 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
407 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
408 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
409 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
410 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
411 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
412 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING",
413 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
414 [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT",
415 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT",
416 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT",
417};
418#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
419
420/* Common ioctl debug function. This function can be used by
421 external ioctl messages as well as internal V4L ioctl */
422void v4l_printk_ioctl(unsigned int cmd)
423{
424 char *dir;
425
426 switch (_IOC_DIR(cmd)) {
427 case _IOC_NONE: dir = "--"; break;
428 case _IOC_READ: dir = "r-"; break;
429 case _IOC_WRITE: dir = "-w"; break;
430 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
431 default: dir = "*ERR*"; break;
432 }
433 switch (_IOC_TYPE(cmd)) {
434 case 'd':
435 printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n",
436 (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ?
437 v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
438 break;
439#ifdef CONFIG_VIDEO_V4L1_COMPAT
440 case 'v':
441 printk("v4l1 ioctl %s, dir=%s (0x%08x)\n",
442 (_IOC_NR(cmd) < V4L1_IOCTLS) ?
443 v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
444 break;
445#endif
446 case 'V':
447 printk("v4l2 ioctl %s, dir=%s (0x%08x)\n",
448 (_IOC_NR(cmd) < V4L2_IOCTLS) ?
449 v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
450 break;
451
452 default:
453 printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n",
454 _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
455 }
456}
457 147
458/* ----------------------------------------------------------------- */ 148/* ----------------------------------------------------------------- */
459 149
@@ -482,6 +172,7 @@ int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
482 } 172 }
483 return 0; 173 return 0;
484} 174}
175EXPORT_SYMBOL(v4l2_ctrl_check);
485 176
486/* Returns NULL or a character pointer array containing the menu for 177/* Returns NULL or a character pointer array containing the menu for
487 the given control ID. The pointer array ends with a NULL pointer. 178 the given control ID. The pointer array ends with a NULL pointer.
@@ -642,6 +333,7 @@ const char **v4l2_ctrl_get_menu(u32 id)
642 return NULL; 333 return NULL;
643 } 334 }
644} 335}
336EXPORT_SYMBOL(v4l2_ctrl_get_menu);
645 337
646/* Fill in a struct v4l2_queryctrl */ 338/* Fill in a struct v4l2_queryctrl */
647int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) 339int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def)
@@ -764,6 +456,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
764 snprintf(qctrl->name, sizeof(qctrl->name), name); 456 snprintf(qctrl->name, sizeof(qctrl->name), name);
765 return 0; 457 return 0;
766} 458}
459EXPORT_SYMBOL(v4l2_ctrl_query_fill);
767 460
768/* Fill in a struct v4l2_queryctrl with standard values based on 461/* Fill in a struct v4l2_queryctrl with standard values based on
769 the control ID. */ 462 the control ID. */
@@ -898,6 +591,7 @@ int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl)
898 return -EINVAL; 591 return -EINVAL;
899 } 592 }
900} 593}
594EXPORT_SYMBOL(v4l2_ctrl_query_fill_std);
901 595
902/* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and 596/* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and
903 the menu. The qctrl pointer may be NULL, in which case it is ignored. */ 597 the menu. The qctrl pointer may be NULL, in which case it is ignored. */
@@ -916,6 +610,7 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc
916 qmenu->reserved = 0; 610 qmenu->reserved = 0;
917 return 0; 611 return 0;
918} 612}
613EXPORT_SYMBOL(v4l2_ctrl_query_menu);
919 614
920/* ctrl_classes points to an array of u32 pointers, the last element is 615/* ctrl_classes points to an array of u32 pointers, the last element is
921 a NULL pointer. Each u32 array is a 0-terminated array of control IDs. 616 a NULL pointer. Each u32 array is a 0-terminated array of control IDs.
@@ -966,6 +661,7 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id)
966 return 0; 661 return 0;
967 return **ctrl_classes; 662 return **ctrl_classes;
968} 663}
664EXPORT_SYMBOL(v4l2_ctrl_next);
969 665
970int v4l2_chip_match_host(u32 match_type, u32 match_chip) 666int v4l2_chip_match_host(u32 match_type, u32 match_chip)
971{ 667{
@@ -1038,26 +734,3 @@ int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver
1038} 734}
1039EXPORT_SYMBOL(v4l2_i2c_attach); 735EXPORT_SYMBOL(v4l2_i2c_attach);
1040#endif 736#endif
1041
1042/* ----------------------------------------------------------------- */
1043
1044EXPORT_SYMBOL(v4l2_norm_to_name);
1045EXPORT_SYMBOL(v4l2_video_std_construct);
1046
1047EXPORT_SYMBOL(v4l2_prio_init);
1048EXPORT_SYMBOL(v4l2_prio_change);
1049EXPORT_SYMBOL(v4l2_prio_open);
1050EXPORT_SYMBOL(v4l2_prio_close);
1051EXPORT_SYMBOL(v4l2_prio_max);
1052EXPORT_SYMBOL(v4l2_prio_check);
1053
1054EXPORT_SYMBOL(v4l2_field_names);
1055EXPORT_SYMBOL(v4l2_type_names);
1056EXPORT_SYMBOL(v4l_printk_ioctl);
1057
1058EXPORT_SYMBOL(v4l2_ctrl_next);
1059EXPORT_SYMBOL(v4l2_ctrl_check);
1060EXPORT_SYMBOL(v4l2_ctrl_get_menu);
1061EXPORT_SYMBOL(v4l2_ctrl_query_menu);
1062EXPORT_SYMBOL(v4l2_ctrl_query_fill);
1063EXPORT_SYMBOL(v4l2_ctrl_query_fill_std);
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 28655f8983c6..0d9b63762a48 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -46,10 +46,373 @@
46#include <linux/videodev.h> 46#include <linux/videodev.h>
47#endif 47#endif
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <linux/video_decoder.h>
49 50
50#define VIDEO_NUM_DEVICES 256 51#define VIDEO_NUM_DEVICES 256
51#define VIDEO_NAME "video4linux" 52#define VIDEO_NAME "video4linux"
52 53
54/* video4linux standard ID conversion to standard name
55 */
56char *v4l2_norm_to_name(v4l2_std_id id)
57{
58 char *name;
59 u32 myid = id;
60
61 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
62 64 bit comparations. So, on that architecture, with some gcc
63 variants, compilation fails. Currently, the max value is 30bit wide.
64 */
65 BUG_ON(myid != id);
66
67 switch (myid) {
68 case V4L2_STD_PAL:
69 name = "PAL";
70 break;
71 case V4L2_STD_PAL_BG:
72 name = "PAL-BG";
73 break;
74 case V4L2_STD_PAL_DK:
75 name = "PAL-DK";
76 break;
77 case V4L2_STD_PAL_B:
78 name = "PAL-B";
79 break;
80 case V4L2_STD_PAL_B1:
81 name = "PAL-B1";
82 break;
83 case V4L2_STD_PAL_G:
84 name = "PAL-G";
85 break;
86 case V4L2_STD_PAL_H:
87 name = "PAL-H";
88 break;
89 case V4L2_STD_PAL_I:
90 name = "PAL-I";
91 break;
92 case V4L2_STD_PAL_D:
93 name = "PAL-D";
94 break;
95 case V4L2_STD_PAL_D1:
96 name = "PAL-D1";
97 break;
98 case V4L2_STD_PAL_K:
99 name = "PAL-K";
100 break;
101 case V4L2_STD_PAL_M:
102 name = "PAL-M";
103 break;
104 case V4L2_STD_PAL_N:
105 name = "PAL-N";
106 break;
107 case V4L2_STD_PAL_Nc:
108 name = "PAL-Nc";
109 break;
110 case V4L2_STD_PAL_60:
111 name = "PAL-60";
112 break;
113 case V4L2_STD_NTSC:
114 name = "NTSC";
115 break;
116 case V4L2_STD_NTSC_M:
117 name = "NTSC-M";
118 break;
119 case V4L2_STD_NTSC_M_JP:
120 name = "NTSC-M-JP";
121 break;
122 case V4L2_STD_NTSC_443:
123 name = "NTSC-443";
124 break;
125 case V4L2_STD_NTSC_M_KR:
126 name = "NTSC-M-KR";
127 break;
128 case V4L2_STD_SECAM:
129 name = "SECAM";
130 break;
131 case V4L2_STD_SECAM_DK:
132 name = "SECAM-DK";
133 break;
134 case V4L2_STD_SECAM_B:
135 name = "SECAM-B";
136 break;
137 case V4L2_STD_SECAM_D:
138 name = "SECAM-D";
139 break;
140 case V4L2_STD_SECAM_G:
141 name = "SECAM-G";
142 break;
143 case V4L2_STD_SECAM_H:
144 name = "SECAM-H";
145 break;
146 case V4L2_STD_SECAM_K:
147 name = "SECAM-K";
148 break;
149 case V4L2_STD_SECAM_K1:
150 name = "SECAM-K1";
151 break;
152 case V4L2_STD_SECAM_L:
153 name = "SECAM-L";
154 break;
155 case V4L2_STD_SECAM_LC:
156 name = "SECAM-LC";
157 break;
158 default:
159 name = "Unknown";
160 break;
161 }
162
163 return name;
164}
165EXPORT_SYMBOL(v4l2_norm_to_name);
166
167/* Fill in the fields of a v4l2_standard structure according to the
168 'id' and 'transmission' parameters. Returns negative on error. */
169int v4l2_video_std_construct(struct v4l2_standard *vs,
170 int id, char *name)
171{
172 u32 index = vs->index;
173
174 memset(vs, 0, sizeof(struct v4l2_standard));
175 vs->index = index;
176 vs->id = id;
177 if (id & V4L2_STD_525_60) {
178 vs->frameperiod.numerator = 1001;
179 vs->frameperiod.denominator = 30000;
180 vs->framelines = 525;
181 } else {
182 vs->frameperiod.numerator = 1;
183 vs->frameperiod.denominator = 25;
184 vs->framelines = 625;
185 }
186 strlcpy(vs->name, name, sizeof(vs->name));
187 return 0;
188}
189EXPORT_SYMBOL(v4l2_video_std_construct);
190
191/* ----------------------------------------------------------------- */
192/* some arrays for pretty-printing debug messages of enum types */
193
194char *v4l2_field_names[] = {
195 [V4L2_FIELD_ANY] = "any",
196 [V4L2_FIELD_NONE] = "none",
197 [V4L2_FIELD_TOP] = "top",
198 [V4L2_FIELD_BOTTOM] = "bottom",
199 [V4L2_FIELD_INTERLACED] = "interlaced",
200 [V4L2_FIELD_SEQ_TB] = "seq-tb",
201 [V4L2_FIELD_SEQ_BT] = "seq-bt",
202 [V4L2_FIELD_ALTERNATE] = "alternate",
203 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
204 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
205};
206EXPORT_SYMBOL(v4l2_field_names);
207
208char *v4l2_type_names[] = {
209 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
210 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
211 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
212 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
213 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
214 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
215 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
216 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over",
217};
218EXPORT_SYMBOL(v4l2_type_names);
219
220static char *v4l2_memory_names[] = {
221 [V4L2_MEMORY_MMAP] = "mmap",
222 [V4L2_MEMORY_USERPTR] = "userptr",
223 [V4L2_MEMORY_OVERLAY] = "overlay",
224};
225
226#define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \
227 arr[a] : "unknown")
228
229/* ------------------------------------------------------------------ */
230/* debug help functions */
231
232#ifdef CONFIG_VIDEO_V4L1_COMPAT
233static const char *v4l1_ioctls[] = {
234 [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
235 [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN",
236 [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN",
237 [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER",
238 [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER",
239 [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT",
240 [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT",
241 [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE",
242 [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN",
243 [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN",
244 [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF",
245 [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF",
246 [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY",
247 [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ",
248 [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ",
249 [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO",
250 [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO",
251 [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC",
252 [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE",
253 [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF",
254 [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT",
255 [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE",
256 [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE",
257 [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE",
258 [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
259 [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO",
260 [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
261 [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT",
262 [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT"
263};
264#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
265#endif
266
267static const char *v4l2_ioctls[] = {
268 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
269 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
270 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
271 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
272 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
273 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
274 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
275 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
276 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
277 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
278 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
279 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
280 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
281 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
282 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
283 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
284 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
285 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
286 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
287 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
288 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
289 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
290 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
291 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
292 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
293 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
294 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
295 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
296 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
297 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
298 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
299 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
300 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
301 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
302 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
303 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
304 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
305 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
306 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
307 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
308 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
309 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
310 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
311 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
312 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
313 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
314 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
315 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
316 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
317 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
318 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
319 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
320 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
321 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
322 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
323#if 1
324 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
325 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
326 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
327 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
328 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
329
330 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
331 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
332
333 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT",
334#endif
335};
336#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
337
338static const char *v4l2_int_ioctls[] = {
339#ifdef CONFIG_VIDEO_V4L1_COMPAT
340 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
341 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
342 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
343 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
344 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
345 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
346 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
347 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
348 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
349 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
350 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
351#endif
352 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
353
354 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
355 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
356 [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG",
357
358 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
359 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
360 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
361 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
362 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
363 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
364 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
365 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
366 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
367 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
368 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
369 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING",
370 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
371 [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT",
372 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT",
373 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT",
374};
375#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
376
377/* Common ioctl debug function. This function can be used by
378 external ioctl messages as well as internal V4L ioctl */
379void v4l_printk_ioctl(unsigned int cmd)
380{
381 char *dir;
382
383 switch (_IOC_DIR(cmd)) {
384 case _IOC_NONE: dir = "--"; break;
385 case _IOC_READ: dir = "r-"; break;
386 case _IOC_WRITE: dir = "-w"; break;
387 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
388 default: dir = "*ERR*"; break;
389 }
390 switch (_IOC_TYPE(cmd)) {
391 case 'd':
392 printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n",
393 (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ?
394 v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
395 break;
396#ifdef CONFIG_VIDEO_V4L1_COMPAT
397 case 'v':
398 printk("v4l1 ioctl %s, dir=%s (0x%08x)\n",
399 (_IOC_NR(cmd) < V4L1_IOCTLS) ?
400 v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
401 break;
402#endif
403 case 'V':
404 printk("v4l2 ioctl %s, dir=%s (0x%08x)\n",
405 (_IOC_NR(cmd) < V4L2_IOCTLS) ?
406 v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
407 break;
408
409 default:
410 printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n",
411 _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
412 }
413}
414EXPORT_SYMBOL(v4l_printk_ioctl);
415
53/* 416/*
54 * sysfs stuff 417 * sysfs stuff
55 */ 418 */
@@ -69,11 +432,13 @@ struct video_device *video_device_alloc(void)
69 vfd = kzalloc(sizeof(*vfd),GFP_KERNEL); 432 vfd = kzalloc(sizeof(*vfd),GFP_KERNEL);
70 return vfd; 433 return vfd;
71} 434}
435EXPORT_SYMBOL(video_device_alloc);
72 436
73void video_device_release(struct video_device *vfd) 437void video_device_release(struct video_device *vfd)
74{ 438{
75 kfree(vfd); 439 kfree(vfd);
76} 440}
441EXPORT_SYMBOL(video_device_release);
77 442
78static void video_release(struct device *cd) 443static void video_release(struct device *cd)
79{ 444{
@@ -110,6 +475,7 @@ struct video_device* video_devdata(struct file *file)
110{ 475{
111 return video_device[iminor(file->f_path.dentry->d_inode)]; 476 return video_device[iminor(file->f_path.dentry->d_inode)];
112} 477}
478EXPORT_SYMBOL(video_devdata);
113 479
114/* 480/*
115 * Open a video device - FIXME: Obsoleted 481 * Open a video device - FIXME: Obsoleted
@@ -278,6 +644,7 @@ out:
278 kfree(mbuf); 644 kfree(mbuf);
279 return err; 645 return err;
280} 646}
647EXPORT_SYMBOL(video_usercopy);
281 648
282/* 649/*
283 * open/release helper functions -- handle exclusive opens 650 * open/release helper functions -- handle exclusive opens
@@ -297,6 +664,7 @@ int video_exclusive_open(struct inode *inode, struct file *file)
297 mutex_unlock(&vfl->lock); 664 mutex_unlock(&vfl->lock);
298 return retval; 665 return retval;
299} 666}
667EXPORT_SYMBOL(video_exclusive_open);
300 668
301int video_exclusive_release(struct inode *inode, struct file *file) 669int video_exclusive_release(struct inode *inode, struct file *file)
302{ 670{
@@ -305,41 +673,7 @@ int video_exclusive_release(struct inode *inode, struct file *file)
305 vfl->users--; 673 vfl->users--;
306 return 0; 674 return 0;
307} 675}
308 676EXPORT_SYMBOL(video_exclusive_release);
309static char *v4l2_memory_names[] = {
310 [V4L2_MEMORY_MMAP] = "mmap",
311 [V4L2_MEMORY_USERPTR] = "userptr",
312 [V4L2_MEMORY_OVERLAY] = "overlay",
313};
314
315
316/* FIXME: Those stuff are replicated also on v4l2-common.c */
317static char *v4l2_type_names_FIXME[] = {
318 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
319 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
320 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
321 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
322 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
323 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
324 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-capture",
325 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over",
326 [V4L2_BUF_TYPE_PRIVATE] = "private",
327};
328
329static char *v4l2_field_names_FIXME[] = {
330 [V4L2_FIELD_ANY] = "any",
331 [V4L2_FIELD_NONE] = "none",
332 [V4L2_FIELD_TOP] = "top",
333 [V4L2_FIELD_BOTTOM] = "bottom",
334 [V4L2_FIELD_INTERLACED] = "interlaced",
335 [V4L2_FIELD_SEQ_TB] = "seq-tb",
336 [V4L2_FIELD_SEQ_BT] = "seq-bt",
337 [V4L2_FIELD_ALTERNATE] = "alternate",
338 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
339 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
340};
341
342#define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown"
343 677
344static void dbgbuf(unsigned int cmd, struct video_device *vfd, 678static void dbgbuf(unsigned int cmd, struct video_device *vfd,
345 struct v4l2_buffer *p) 679 struct v4l2_buffer *p)
@@ -354,10 +688,10 @@ static void dbgbuf(unsigned int cmd, struct video_device *vfd,
354 (int)(p->timestamp.tv_sec%60), 688 (int)(p->timestamp.tv_sec%60),
355 p->timestamp.tv_usec, 689 p->timestamp.tv_usec,
356 p->index, 690 p->index,
357 prt_names(p->type,v4l2_type_names_FIXME), 691 prt_names(p->type, v4l2_type_names),
358 p->bytesused,p->flags, 692 p->bytesused, p->flags,
359 p->field,p->sequence, 693 p->field, p->sequence,
360 prt_names(p->memory,v4l2_memory_names), 694 prt_names(p->memory, v4l2_memory_names),
361 p->m.userptr, p->length); 695 p->m.userptr, p->length);
362 dbgarg2 ("timecode= %02d:%02d:%02d type=%d, " 696 dbgarg2 ("timecode= %02d:%02d:%02d type=%d, "
363 "flags=0x%08d, frames=%d, userbits=0x%08x\n", 697 "flags=0x%08d, frames=%d, userbits=0x%08x\n",
@@ -382,8 +716,8 @@ static inline void v4l_print_pix_fmt (struct video_device *vfd,
382 (fmt->pixelformat >> 8) & 0xff, 716 (fmt->pixelformat >> 8) & 0xff,
383 (fmt->pixelformat >> 16) & 0xff, 717 (fmt->pixelformat >> 16) & 0xff,
384 (fmt->pixelformat >> 24) & 0xff, 718 (fmt->pixelformat >> 24) & 0xff,
385 prt_names(fmt->field,v4l2_field_names_FIXME), 719 prt_names(fmt->field, v4l2_field_names),
386 fmt->bytesperline,fmt->sizeimage,fmt->colorspace); 720 fmt->bytesperline, fmt->sizeimage, fmt->colorspace);
387}; 721};
388 722
389 723
@@ -597,7 +931,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
597 931
598 /* FIXME: Should be one dump per type */ 932 /* FIXME: Should be one dump per type */
599 dbgarg (cmd, "type=%s\n", prt_names(type, 933 dbgarg (cmd, "type=%s\n", prt_names(type,
600 v4l2_type_names_FIXME)); 934 v4l2_type_names));
601 935
602 switch (type) { 936 switch (type) {
603 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 937 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -650,7 +984,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
650 984
651 /* FIXME: Should be one dump per type */ 985 /* FIXME: Should be one dump per type */
652 dbgarg (cmd, "type=%s\n", prt_names(f->type, 986 dbgarg (cmd, "type=%s\n", prt_names(f->type,
653 v4l2_type_names_FIXME)); 987 v4l2_type_names));
654 988
655 switch (f->type) { 989 switch (f->type) {
656 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 990 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -702,7 +1036,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
702 1036
703 /* FIXME: Should be one dump per type */ 1037 /* FIXME: Should be one dump per type */
704 dbgarg (cmd, "type=%s\n", prt_names(f->type, 1038 dbgarg (cmd, "type=%s\n", prt_names(f->type,
705 v4l2_type_names_FIXME)); 1039 v4l2_type_names));
706 switch (f->type) { 1040 switch (f->type) {
707 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1041 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
708 if (vfd->vidioc_try_fmt_cap) 1042 if (vfd->vidioc_try_fmt_cap)
@@ -768,8 +1102,8 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
768 ret=vfd->vidioc_reqbufs(file, fh, p); 1102 ret=vfd->vidioc_reqbufs(file, fh, p);
769 dbgarg (cmd, "count=%d, type=%s, memory=%s\n", 1103 dbgarg (cmd, "count=%d, type=%s, memory=%s\n",
770 p->count, 1104 p->count,
771 prt_names(p->type,v4l2_type_names_FIXME), 1105 prt_names(p->type, v4l2_type_names),
772 prt_names(p->memory,v4l2_memory_names)); 1106 prt_names(p->memory, v4l2_memory_names));
773 break; 1107 break;
774 } 1108 }
775 case VIDIOC_QUERYBUF: 1109 case VIDIOC_QUERYBUF:
@@ -858,7 +1192,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
858 enum v4l2_buf_type i = *(int *)arg; 1192 enum v4l2_buf_type i = *(int *)arg;
859 if (!vfd->vidioc_streamon) 1193 if (!vfd->vidioc_streamon)
860 break; 1194 break;
861 dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME)); 1195 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
862 ret=vfd->vidioc_streamon(file, fh,i); 1196 ret=vfd->vidioc_streamon(file, fh,i);
863 break; 1197 break;
864 } 1198 }
@@ -868,7 +1202,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
868 1202
869 if (!vfd->vidioc_streamoff) 1203 if (!vfd->vidioc_streamoff)
870 break; 1204 break;
871 dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME)); 1205 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
872 ret=vfd->vidioc_streamoff(file, fh, i); 1206 ret=vfd->vidioc_streamoff(file, fh, i);
873 break; 1207 break;
874 } 1208 }
@@ -1624,7 +1958,7 @@ out:
1624 kfree(mbuf); 1958 kfree(mbuf);
1625 return err; 1959 return err;
1626} 1960}
1627 1961EXPORT_SYMBOL(video_ioctl2);
1628 1962
1629static const struct file_operations video_fops; 1963static const struct file_operations video_fops;
1630 1964
@@ -1743,6 +2077,7 @@ fail_minor:
1743 mutex_unlock(&videodev_lock); 2077 mutex_unlock(&videodev_lock);
1744 return ret; 2078 return ret;
1745} 2079}
2080EXPORT_SYMBOL(video_register_device);
1746 2081
1747/** 2082/**
1748 * video_unregister_device - unregister a video4linux device 2083 * video_unregister_device - unregister a video4linux device
@@ -1762,6 +2097,7 @@ void video_unregister_device(struct video_device *vfd)
1762 device_unregister(&vfd->class_dev); 2097 device_unregister(&vfd->class_dev);
1763 mutex_unlock(&videodev_lock); 2098 mutex_unlock(&videodev_lock);
1764} 2099}
2100EXPORT_SYMBOL(video_unregister_device);
1765 2101
1766/* 2102/*
1767 * Video fs operations 2103 * Video fs operations
@@ -1806,16 +2142,6 @@ static void __exit videodev_exit(void)
1806module_init(videodev_init) 2142module_init(videodev_init)
1807module_exit(videodev_exit) 2143module_exit(videodev_exit)
1808 2144
1809EXPORT_SYMBOL(video_register_device);
1810EXPORT_SYMBOL(video_unregister_device);
1811EXPORT_SYMBOL(video_devdata);
1812EXPORT_SYMBOL(video_usercopy);
1813EXPORT_SYMBOL(video_exclusive_open);
1814EXPORT_SYMBOL(video_exclusive_release);
1815EXPORT_SYMBOL(video_ioctl2);
1816EXPORT_SYMBOL(video_device_alloc);
1817EXPORT_SYMBOL(video_device_release);
1818
1819MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>"); 2145MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>");
1820MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2"); 2146MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2");
1821MODULE_LICENSE("GPL"); 2147MODULE_LICENSE("GPL");