]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
ac19ecc6 | 2 | * |
1da177e4 LT |
3 | * Video for Linux Two |
4 | * Backward Compatibility Layer | |
5 | * | |
6 | * Support subroutines for providing V4L2 drivers with backward | |
7 | * compatibility with applications using the old API. | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU General Public License | |
11 | * as published by the Free Software Foundation; either version | |
12 | * 2 of the License, or (at your option) any later version. | |
13 | * | |
14 | * Author: Bill Dirks <bdirks@pacbell.net> | |
15 | * et al. | |
16 | * | |
17 | */ | |
18 | ||
1da177e4 LT |
19 | |
20 | #include <linux/init.h> | |
21 | #include <linux/module.h> | |
ac19ecc6 | 22 | #include <linux/moduleparam.h> |
1da177e4 LT |
23 | #include <linux/types.h> |
24 | #include <linux/kernel.h> | |
25 | #include <linux/sched.h> | |
26 | #include <linux/smp_lock.h> | |
27 | #include <linux/mm.h> | |
28 | #include <linux/fs.h> | |
29 | #include <linux/file.h> | |
30 | #include <linux/string.h> | |
31 | #include <linux/errno.h> | |
32 | #include <linux/slab.h> | |
33 | #include <linux/videodev.h> | |
5e87efa3 | 34 | #include <media/v4l2-common.h> |
1da177e4 LT |
35 | |
36 | #include <asm/uaccess.h> | |
37 | #include <asm/system.h> | |
38 | #include <asm/pgtable.h> | |
39 | ||
40 | #ifdef CONFIG_KMOD | |
41 | #include <linux/kmod.h> | |
42 | #endif | |
43 | ||
44 | static unsigned int debug = 0; | |
45 | module_param(debug, int, 0644); | |
46 | MODULE_PARM_DESC(debug,"enable debug messages"); | |
47 | MODULE_AUTHOR("Bill Dirks"); | |
48 | MODULE_DESCRIPTION("v4l(1) compatibility layer for v4l2 drivers."); | |
49 | MODULE_LICENSE("GPL"); | |
50 | ||
51 | #define dprintk(fmt, arg...) if (debug) \ | |
52 | printk(KERN_DEBUG "v4l1-compat: " fmt , ## arg) | |
53 | ||
54 | /* | |
55 | * I O C T L T R A N S L A T I O N | |
56 | * | |
57 | * From here on down is the code for translating the numerous | |
58 | * ioctl commands from the old API to the new API. | |
59 | */ | |
60 | ||
61 | static int | |
62 | get_v4l_control(struct inode *inode, | |
63 | struct file *file, | |
64 | int cid, | |
65 | v4l2_kioctl drv) | |
66 | { | |
67 | struct v4l2_queryctrl qctrl2; | |
68 | struct v4l2_control ctrl2; | |
69 | int err; | |
70 | ||
71 | qctrl2.id = cid; | |
72 | err = drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2); | |
73 | if (err < 0) | |
74 | dprintk("VIDIOC_QUERYCTRL: %d\n",err); | |
75 | if (err == 0 && | |
76 | !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) | |
77 | { | |
78 | ctrl2.id = qctrl2.id; | |
79 | err = drv(inode, file, VIDIOC_G_CTRL, &ctrl2); | |
80 | if (err < 0) { | |
81 | dprintk("VIDIOC_G_CTRL: %d\n",err); | |
82 | return 0; | |
83 | } | |
84 | return ((ctrl2.value - qctrl2.minimum) * 65535 | |
85 | + (qctrl2.maximum - qctrl2.minimum) / 2) | |
86 | / (qctrl2.maximum - qctrl2.minimum); | |
87 | } | |
88 | return 0; | |
89 | } | |
90 | ||
91 | static int | |
92 | set_v4l_control(struct inode *inode, | |
93 | struct file *file, | |
94 | int cid, | |
95 | int value, | |
96 | v4l2_kioctl drv) | |
97 | { | |
98 | struct v4l2_queryctrl qctrl2; | |
99 | struct v4l2_control ctrl2; | |
100 | int err; | |
101 | ||
102 | qctrl2.id = cid; | |
103 | err = drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2); | |
104 | if (err < 0) | |
105 | dprintk("VIDIOC_QUERYCTRL: %d\n",err); | |
106 | if (err == 0 && | |
107 | !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED) && | |
108 | !(qctrl2.flags & V4L2_CTRL_FLAG_GRABBED)) | |
109 | { | |
110 | if (value < 0) | |
111 | value = 0; | |
112 | if (value > 65535) | |
113 | value = 65535; | |
114 | if (value && qctrl2.type == V4L2_CTRL_TYPE_BOOLEAN) | |
115 | value = 65535; | |
116 | ctrl2.id = qctrl2.id; | |
117 | ctrl2.value = | |
118 | (value * (qctrl2.maximum - qctrl2.minimum) | |
119 | + 32767) | |
120 | / 65535; | |
121 | ctrl2.value += qctrl2.minimum; | |
122 | err = drv(inode, file, VIDIOC_S_CTRL, &ctrl2); | |
123 | if (err < 0) | |
124 | dprintk("VIDIOC_S_CTRL: %d\n",err); | |
125 | } | |
126 | return 0; | |
127 | } | |
128 | ||
129 | /* ----------------------------------------------------------------- */ | |
130 | ||
131 | static int palette2pixelformat[] = { | |
132 | [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY, | |
133 | [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555, | |
134 | [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565, | |
135 | [VIDEO_PALETTE_RGB24] = V4L2_PIX_FMT_BGR24, | |
136 | [VIDEO_PALETTE_RGB32] = V4L2_PIX_FMT_BGR32, | |
137 | /* yuv packed pixel */ | |
138 | [VIDEO_PALETTE_YUYV] = V4L2_PIX_FMT_YUYV, | |
139 | [VIDEO_PALETTE_YUV422] = V4L2_PIX_FMT_YUYV, | |
140 | [VIDEO_PALETTE_UYVY] = V4L2_PIX_FMT_UYVY, | |
141 | /* yuv planar */ | |
142 | [VIDEO_PALETTE_YUV410P] = V4L2_PIX_FMT_YUV410, | |
143 | [VIDEO_PALETTE_YUV420] = V4L2_PIX_FMT_YUV420, | |
144 | [VIDEO_PALETTE_YUV420P] = V4L2_PIX_FMT_YUV420, | |
145 | [VIDEO_PALETTE_YUV411P] = V4L2_PIX_FMT_YUV411P, | |
146 | [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P, | |
147 | }; | |
148 | ||
149 | static unsigned int | |
150 | palette_to_pixelformat(unsigned int palette) | |
151 | { | |
152 | if (palette < ARRAY_SIZE(palette2pixelformat)) | |
153 | return palette2pixelformat[palette]; | |
154 | else | |
155 | return 0; | |
156 | } | |
157 | ||
158 | static unsigned int | |
159 | pixelformat_to_palette(int pixelformat) | |
160 | { | |
161 | int palette = 0; | |
162 | switch (pixelformat) | |
163 | { | |
164 | case V4L2_PIX_FMT_GREY: | |
165 | palette = VIDEO_PALETTE_GREY; | |
166 | break; | |
167 | case V4L2_PIX_FMT_RGB555: | |
168 | palette = VIDEO_PALETTE_RGB555; | |
169 | break; | |
170 | case V4L2_PIX_FMT_RGB565: | |
171 | palette = VIDEO_PALETTE_RGB565; | |
172 | break; | |
173 | case V4L2_PIX_FMT_BGR24: | |
174 | palette = VIDEO_PALETTE_RGB24; | |
175 | break; | |
176 | case V4L2_PIX_FMT_BGR32: | |
177 | palette = VIDEO_PALETTE_RGB32; | |
178 | break; | |
179 | /* yuv packed pixel */ | |
180 | case V4L2_PIX_FMT_YUYV: | |
181 | palette = VIDEO_PALETTE_YUYV; | |
182 | break; | |
183 | case V4L2_PIX_FMT_UYVY: | |
184 | palette = VIDEO_PALETTE_UYVY; | |
185 | break; | |
186 | /* yuv planar */ | |
187 | case V4L2_PIX_FMT_YUV410: | |
188 | palette = VIDEO_PALETTE_YUV420; | |
189 | break; | |
190 | case V4L2_PIX_FMT_YUV420: | |
191 | palette = VIDEO_PALETTE_YUV420; | |
192 | break; | |
193 | case V4L2_PIX_FMT_YUV411P: | |
194 | palette = VIDEO_PALETTE_YUV411P; | |
195 | break; | |
196 | case V4L2_PIX_FMT_YUV422P: | |
197 | palette = VIDEO_PALETTE_YUV422P; | |
198 | break; | |
199 | } | |
200 | return palette; | |
201 | } | |
202 | ||
203 | /* ----------------------------------------------------------------- */ | |
204 | ||
205 | static int poll_one(struct file *file) | |
206 | { | |
207 | int retval = 1; | |
208 | poll_table *table; | |
209 | struct poll_wqueues pwq; | |
210 | ||
211 | poll_initwait(&pwq); | |
212 | table = &pwq.pt; | |
213 | for (;;) { | |
214 | int mask; | |
215 | set_current_state(TASK_INTERRUPTIBLE); | |
216 | mask = file->f_op->poll(file, table); | |
217 | if (mask & POLLIN) | |
218 | break; | |
219 | table = NULL; | |
220 | if (signal_pending(current)) { | |
221 | retval = -ERESTARTSYS; | |
222 | break; | |
223 | } | |
224 | schedule(); | |
225 | } | |
226 | set_current_state(TASK_RUNNING); | |
227 | poll_freewait(&pwq); | |
228 | return retval; | |
229 | } | |
230 | ||
231 | static int count_inputs(struct inode *inode, | |
232 | struct file *file, | |
233 | v4l2_kioctl drv) | |
234 | { | |
235 | struct v4l2_input input2; | |
236 | int i; | |
237 | ||
238 | for (i = 0;; i++) { | |
239 | memset(&input2,0,sizeof(input2)); | |
240 | input2.index = i; | |
241 | if (0 != drv(inode,file,VIDIOC_ENUMINPUT, &input2)) | |
242 | break; | |
243 | } | |
244 | return i; | |
245 | } | |
246 | ||
247 | static int check_size(struct inode *inode, | |
248 | struct file *file, | |
249 | v4l2_kioctl drv, | |
250 | int *maxw, int *maxh) | |
251 | { | |
252 | struct v4l2_fmtdesc desc2; | |
253 | struct v4l2_format fmt2; | |
254 | ||
255 | memset(&desc2,0,sizeof(desc2)); | |
256 | memset(&fmt2,0,sizeof(fmt2)); | |
257 | ||
258 | desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |
259 | if (0 != drv(inode,file,VIDIOC_ENUM_FMT, &desc2)) | |
260 | goto done; | |
261 | ||
262 | fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |
263 | fmt2.fmt.pix.width = 10000; | |
264 | fmt2.fmt.pix.height = 10000; | |
265 | fmt2.fmt.pix.pixelformat = desc2.pixelformat; | |
266 | if (0 != drv(inode,file,VIDIOC_TRY_FMT, &fmt2)) | |
267 | goto done; | |
268 | ||
269 | *maxw = fmt2.fmt.pix.width; | |
270 | *maxh = fmt2.fmt.pix.height; | |
271 | ||
272 | done: | |
273 | return 0; | |
274 | } | |
275 | ||
276 | /* ----------------------------------------------------------------- */ | |
277 | ||
278 | /* | |
279 | * This function is exported. | |
280 | */ | |
281 | int | |
282 | v4l_compat_translate_ioctl(struct inode *inode, | |
283 | struct file *file, | |
284 | int cmd, | |
285 | void *arg, | |
286 | v4l2_kioctl drv) | |
287 | { | |
288 | struct v4l2_capability *cap2 = NULL; | |
289 | struct v4l2_format *fmt2 = NULL; | |
290 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |
291 | ||
292 | struct v4l2_framebuffer fbuf2; | |
293 | struct v4l2_input input2; | |
294 | struct v4l2_tuner tun2; | |
295 | struct v4l2_standard std2; | |
296 | struct v4l2_frequency freq2; | |
297 | struct v4l2_audio aud2; | |
298 | struct v4l2_queryctrl qctrl2; | |
299 | struct v4l2_buffer buf2; | |
300 | v4l2_std_id sid; | |
301 | int i, err = 0; | |
302 | ||
303 | switch (cmd) { | |
304 | case VIDIOCGCAP: /* capability */ | |
305 | { | |
306 | struct video_capability *cap = arg; | |
307 | ||
7408187d | 308 | cap2 = kzalloc(sizeof(*cap2),GFP_KERNEL); |
1da177e4 | 309 | memset(cap, 0, sizeof(*cap)); |
1da177e4 LT |
310 | memset(&fbuf2, 0, sizeof(fbuf2)); |
311 | ||
312 | err = drv(inode, file, VIDIOC_QUERYCAP, cap2); | |
313 | if (err < 0) { | |
314 | dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n",err); | |
315 | break; | |
316 | } | |
317 | if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { | |
318 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); | |
319 | if (err < 0) { | |
320 | dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n",err); | |
321 | memset(&fbuf2, 0, sizeof(fbuf2)); | |
322 | } | |
323 | err = 0; | |
324 | } | |
325 | ||
326 | memcpy(cap->name, cap2->card, | |
327 | min(sizeof(cap->name), sizeof(cap2->card))); | |
328 | cap->name[sizeof(cap->name) - 1] = 0; | |
329 | if (cap2->capabilities & V4L2_CAP_VIDEO_CAPTURE) | |
330 | cap->type |= VID_TYPE_CAPTURE; | |
331 | if (cap2->capabilities & V4L2_CAP_TUNER) | |
332 | cap->type |= VID_TYPE_TUNER; | |
333 | if (cap2->capabilities & V4L2_CAP_VBI_CAPTURE) | |
334 | cap->type |= VID_TYPE_TELETEXT; | |
335 | if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) | |
336 | cap->type |= VID_TYPE_OVERLAY; | |
337 | if (fbuf2.capability & V4L2_FBUF_CAP_LIST_CLIPPING) | |
338 | cap->type |= VID_TYPE_CLIPPING; | |
339 | ||
340 | cap->channels = count_inputs(inode,file,drv); | |
341 | check_size(inode,file,drv, | |
342 | &cap->maxwidth,&cap->maxheight); | |
343 | cap->audios = 0; /* FIXME */ | |
344 | cap->minwidth = 48; /* FIXME */ | |
345 | cap->minheight = 32; /* FIXME */ | |
346 | break; | |
347 | } | |
348 | case VIDIOCGFBUF: /* get frame buffer */ | |
349 | { | |
350 | struct video_buffer *buffer = arg; | |
351 | ||
352 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); | |
353 | if (err < 0) { | |
354 | dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n",err); | |
355 | break; | |
356 | } | |
357 | buffer->base = fbuf2.base; | |
358 | buffer->height = fbuf2.fmt.height; | |
359 | buffer->width = fbuf2.fmt.width; | |
360 | ||
361 | switch (fbuf2.fmt.pixelformat) { | |
362 | case V4L2_PIX_FMT_RGB332: | |
363 | buffer->depth = 8; | |
364 | break; | |
365 | case V4L2_PIX_FMT_RGB555: | |
366 | buffer->depth = 15; | |
367 | break; | |
368 | case V4L2_PIX_FMT_RGB565: | |
369 | buffer->depth = 16; | |
370 | break; | |
371 | case V4L2_PIX_FMT_BGR24: | |
372 | buffer->depth = 24; | |
373 | break; | |
374 | case V4L2_PIX_FMT_BGR32: | |
375 | buffer->depth = 32; | |
376 | break; | |
377 | default: | |
378 | buffer->depth = 0; | |
379 | } | |
380 | if (0 != fbuf2.fmt.bytesperline) | |
381 | buffer->bytesperline = fbuf2.fmt.bytesperline; | |
382 | else { | |
383 | buffer->bytesperline = | |
384 | (buffer->width * buffer->depth + 7) & 7; | |
385 | buffer->bytesperline >>= 3; | |
386 | } | |
387 | break; | |
388 | } | |
389 | case VIDIOCSFBUF: /* set frame buffer */ | |
390 | { | |
391 | struct video_buffer *buffer = arg; | |
392 | ||
393 | memset(&fbuf2, 0, sizeof(fbuf2)); | |
394 | fbuf2.base = buffer->base; | |
395 | fbuf2.fmt.height = buffer->height; | |
396 | fbuf2.fmt.width = buffer->width; | |
397 | switch (buffer->depth) { | |
398 | case 8: | |
399 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB332; | |
400 | break; | |
401 | case 15: | |
402 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB555; | |
403 | break; | |
404 | case 16: | |
405 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB565; | |
406 | break; | |
407 | case 24: | |
408 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_BGR24; | |
409 | break; | |
410 | case 32: | |
411 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_BGR32; | |
412 | break; | |
413 | } | |
414 | fbuf2.fmt.bytesperline = buffer->bytesperline; | |
415 | err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); | |
416 | if (err < 0) | |
417 | dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n",err); | |
418 | break; | |
419 | } | |
420 | case VIDIOCGWIN: /* get window or capture dimensions */ | |
421 | { | |
422 | struct video_window *win = arg; | |
423 | ||
7408187d | 424 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
1da177e4 | 425 | memset(win,0,sizeof(*win)); |
1da177e4 LT |
426 | |
427 | fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; | |
428 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | |
429 | if (err < 0) | |
430 | dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n",err); | |
431 | if (err == 0) { | |
432 | win->x = fmt2->fmt.win.w.left; | |
433 | win->y = fmt2->fmt.win.w.top; | |
434 | win->width = fmt2->fmt.win.w.width; | |
435 | win->height = fmt2->fmt.win.w.height; | |
436 | win->chromakey = fmt2->fmt.win.chromakey; | |
437 | win->clips = NULL; | |
438 | win->clipcount = 0; | |
439 | break; | |
440 | } | |
441 | ||
442 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |
443 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | |
444 | if (err < 0) { | |
445 | dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n",err); | |
446 | break; | |
447 | } | |
448 | win->x = 0; | |
449 | win->y = 0; | |
450 | win->width = fmt2->fmt.pix.width; | |
451 | win->height = fmt2->fmt.pix.height; | |
452 | win->chromakey = 0; | |
453 | win->clips = NULL; | |
454 | win->clipcount = 0; | |
455 | break; | |
456 | } | |
457 | case VIDIOCSWIN: /* set window and/or capture dimensions */ | |
458 | { | |
459 | struct video_window *win = arg; | |
460 | int err1,err2; | |
461 | ||
7408187d | 462 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
1da177e4 LT |
463 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
464 | drv(inode, file, VIDIOC_STREAMOFF, &fmt2->type); | |
465 | err1 = drv(inode, file, VIDIOC_G_FMT, fmt2); | |
466 | if (err1 < 0) | |
467 | dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n",err); | |
468 | if (err1 == 0) { | |
469 | fmt2->fmt.pix.width = win->width; | |
470 | fmt2->fmt.pix.height = win->height; | |
471 | fmt2->fmt.pix.field = V4L2_FIELD_ANY; | |
472 | fmt2->fmt.pix.bytesperline = 0; | |
473 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | |
474 | if (err < 0) | |
475 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n", | |
476 | err); | |
477 | win->width = fmt2->fmt.pix.width; | |
478 | win->height = fmt2->fmt.pix.height; | |
479 | } | |
480 | ||
481 | memset(fmt2,0,sizeof(*fmt2)); | |
482 | fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; | |
483 | fmt2->fmt.win.w.left = win->x; | |
484 | fmt2->fmt.win.w.top = win->y; | |
485 | fmt2->fmt.win.w.width = win->width; | |
486 | fmt2->fmt.win.w.height = win->height; | |
487 | fmt2->fmt.win.chromakey = win->chromakey; | |
488 | fmt2->fmt.win.clips = (void __user *)win->clips; | |
489 | fmt2->fmt.win.clipcount = win->clipcount; | |
490 | err2 = drv(inode, file, VIDIOC_S_FMT, fmt2); | |
491 | if (err2 < 0) | |
492 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n",err); | |
493 | ||
494 | if (err1 != 0 && err2 != 0) | |
495 | err = err1; | |
496 | break; | |
497 | } | |
498 | case VIDIOCCAPTURE: /* turn on/off preview */ | |
499 | { | |
500 | int *on = arg; | |
501 | ||
502 | if (0 == *on) { | |
503 | /* dirty hack time. But v4l1 has no STREAMOFF | |
504 | * equivalent in the API, and this one at | |
505 | * least comes close ... */ | |
506 | drv(inode, file, VIDIOC_STREAMOFF, &captype); | |
507 | } | |
508 | err = drv(inode, file, VIDIOC_OVERLAY, arg); | |
509 | if (err < 0) | |
510 | dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n",err); | |
511 | break; | |
512 | } | |
513 | case VIDIOCGCHAN: /* get input information */ | |
514 | { | |
515 | struct video_channel *chan = arg; | |
516 | ||
517 | memset(&input2,0,sizeof(input2)); | |
518 | input2.index = chan->channel; | |
519 | err = drv(inode, file, VIDIOC_ENUMINPUT, &input2); | |
520 | if (err < 0) { | |
521 | dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " | |
522 | "channel=%d err=%d\n",chan->channel,err); | |
523 | break; | |
524 | } | |
525 | chan->channel = input2.index; | |
526 | memcpy(chan->name, input2.name, | |
527 | min(sizeof(chan->name), sizeof(input2.name))); | |
528 | chan->name[sizeof(chan->name) - 1] = 0; | |
529 | chan->tuners = (input2.type == V4L2_INPUT_TYPE_TUNER) ? 1 : 0; | |
530 | chan->flags = (chan->tuners) ? VIDEO_VC_TUNER : 0; | |
531 | switch (input2.type) { | |
532 | case V4L2_INPUT_TYPE_TUNER: | |
533 | chan->type = VIDEO_TYPE_TV; | |
534 | break; | |
535 | default: | |
536 | case V4L2_INPUT_TYPE_CAMERA: | |
537 | chan->type = VIDEO_TYPE_CAMERA; | |
538 | break; | |
539 | } | |
540 | chan->norm = 0; | |
541 | err = drv(inode, file, VIDIOC_G_STD, &sid); | |
542 | if (err < 0) | |
543 | dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %d\n",err); | |
544 | if (err == 0) { | |
545 | if (sid & V4L2_STD_PAL) | |
546 | chan->norm = VIDEO_MODE_PAL; | |
547 | if (sid & V4L2_STD_NTSC) | |
548 | chan->norm = VIDEO_MODE_NTSC; | |
549 | if (sid & V4L2_STD_SECAM) | |
550 | chan->norm = VIDEO_MODE_SECAM; | |
551 | } | |
552 | break; | |
553 | } | |
554 | case VIDIOCSCHAN: /* set input */ | |
555 | { | |
556 | struct video_channel *chan = arg; | |
557 | ||
558 | sid = 0; | |
559 | err = drv(inode, file, VIDIOC_S_INPUT, &chan->channel); | |
560 | if (err < 0) | |
561 | dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n",err); | |
562 | switch (chan->norm) { | |
563 | case VIDEO_MODE_PAL: | |
564 | sid = V4L2_STD_PAL; | |
565 | break; | |
566 | case VIDEO_MODE_NTSC: | |
567 | sid = V4L2_STD_NTSC; | |
568 | break; | |
569 | case VIDEO_MODE_SECAM: | |
570 | sid = V4L2_STD_SECAM; | |
571 | break; | |
572 | } | |
573 | if (0 != sid) { | |
574 | err = drv(inode, file, VIDIOC_S_STD, &sid); | |
575 | if (err < 0) | |
576 | dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n",err); | |
577 | } | |
578 | break; | |
579 | } | |
580 | case VIDIOCGPICT: /* get tone controls & partial capture format */ | |
581 | { | |
582 | struct video_picture *pict = arg; | |
583 | ||
584 | pict->brightness = get_v4l_control(inode, file, | |
585 | V4L2_CID_BRIGHTNESS,drv); | |
586 | pict->hue = get_v4l_control(inode, file, | |
587 | V4L2_CID_HUE, drv); | |
588 | pict->contrast = get_v4l_control(inode, file, | |
589 | V4L2_CID_CONTRAST, drv); | |
590 | pict->colour = get_v4l_control(inode, file, | |
591 | V4L2_CID_SATURATION, drv); | |
592 | pict->whiteness = get_v4l_control(inode, file, | |
593 | V4L2_CID_WHITENESS, drv); | |
594 | ||
7408187d | 595 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
1da177e4 LT |
596 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
597 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | |
598 | if (err < 0) { | |
599 | dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n",err); | |
600 | break; | |
601 | } | |
8a016dcc MCC |
602 | |
603 | pict->depth = ((fmt2->fmt.pix.bytesperline<<3) | |
604 | + (fmt2->fmt.pix.width-1) ) | |
605 | /fmt2->fmt.pix.width; | |
1da177e4 LT |
606 | pict->palette = pixelformat_to_palette( |
607 | fmt2->fmt.pix.pixelformat); | |
608 | break; | |
609 | } | |
610 | case VIDIOCSPICT: /* set tone controls & partial capture format */ | |
611 | { | |
612 | struct video_picture *pict = arg; | |
613 | ||
614 | set_v4l_control(inode, file, | |
615 | V4L2_CID_BRIGHTNESS, pict->brightness, drv); | |
616 | set_v4l_control(inode, file, | |
617 | V4L2_CID_HUE, pict->hue, drv); | |
618 | set_v4l_control(inode, file, | |
619 | V4L2_CID_CONTRAST, pict->contrast, drv); | |
620 | set_v4l_control(inode, file, | |
621 | V4L2_CID_SATURATION, pict->colour, drv); | |
622 | set_v4l_control(inode, file, | |
623 | V4L2_CID_WHITENESS, pict->whiteness, drv); | |
624 | ||
7408187d | 625 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
1da177e4 LT |
626 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
627 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | |
628 | if (err < 0) | |
629 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err); | |
630 | if (fmt2->fmt.pix.pixelformat != | |
631 | palette_to_pixelformat(pict->palette)) { | |
632 | fmt2->fmt.pix.pixelformat = palette_to_pixelformat( | |
633 | pict->palette); | |
634 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | |
635 | if (err < 0) | |
636 | dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",err); | |
637 | } | |
638 | ||
639 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); | |
640 | if (err < 0) | |
641 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err); | |
642 | if (fbuf2.fmt.pixelformat != | |
643 | palette_to_pixelformat(pict->palette)) { | |
644 | fbuf2.fmt.pixelformat = palette_to_pixelformat( | |
645 | pict->palette); | |
646 | err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); | |
647 | if (err < 0) | |
648 | dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",err); | |
649 | err = 0; /* likely fails for non-root */ | |
650 | } | |
651 | break; | |
652 | } | |
653 | case VIDIOCGTUNER: /* get tuner information */ | |
654 | { | |
655 | struct video_tuner *tun = arg; | |
656 | ||
657 | memset(&tun2,0,sizeof(tun2)); | |
658 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); | |
659 | if (err < 0) { | |
660 | dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n",err); | |
661 | break; | |
662 | } | |
663 | memcpy(tun->name, tun2.name, | |
664 | min(sizeof(tun->name), sizeof(tun2.name))); | |
665 | tun->name[sizeof(tun->name) - 1] = 0; | |
666 | tun->rangelow = tun2.rangelow; | |
667 | tun->rangehigh = tun2.rangehigh; | |
668 | tun->flags = 0; | |
669 | tun->mode = VIDEO_MODE_AUTO; | |
670 | ||
671 | for (i = 0; i < 64; i++) { | |
672 | memset(&std2,0,sizeof(std2)); | |
673 | std2.index = i; | |
674 | if (0 != drv(inode, file, VIDIOC_ENUMSTD, &std2)) | |
675 | break; | |
676 | if (std2.id & V4L2_STD_PAL) | |
677 | tun->flags |= VIDEO_TUNER_PAL; | |
678 | if (std2.id & V4L2_STD_NTSC) | |
679 | tun->flags |= VIDEO_TUNER_NTSC; | |
680 | if (std2.id & V4L2_STD_SECAM) | |
681 | tun->flags |= VIDEO_TUNER_SECAM; | |
682 | } | |
683 | ||
684 | err = drv(inode, file, VIDIOC_G_STD, &sid); | |
685 | if (err < 0) | |
686 | dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %d\n",err); | |
687 | if (err == 0) { | |
688 | if (sid & V4L2_STD_PAL) | |
689 | tun->mode = VIDEO_MODE_PAL; | |
690 | if (sid & V4L2_STD_NTSC) | |
691 | tun->mode = VIDEO_MODE_NTSC; | |
692 | if (sid & V4L2_STD_SECAM) | |
693 | tun->mode = VIDEO_MODE_SECAM; | |
694 | } | |
695 | ||
696 | if (tun2.capability & V4L2_TUNER_CAP_LOW) | |
697 | tun->flags |= VIDEO_TUNER_LOW; | |
698 | if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) | |
699 | tun->flags |= VIDEO_TUNER_STEREO_ON; | |
700 | tun->signal = tun2.signal; | |
701 | break; | |
702 | } | |
703 | case VIDIOCSTUNER: /* select a tuner input */ | |
704 | { | |
1da177e4 | 705 | err = 0; |
1da177e4 LT |
706 | break; |
707 | } | |
708 | case VIDIOCGFREQ: /* get frequency */ | |
709 | { | |
376f269e | 710 | unsigned long *freq = arg; |
1da177e4 LT |
711 | |
712 | freq2.tuner = 0; | |
713 | err = drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); | |
714 | if (err < 0) | |
715 | dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n",err); | |
716 | if (0 == err) | |
717 | *freq = freq2.frequency; | |
718 | break; | |
719 | } | |
720 | case VIDIOCSFREQ: /* set frequency */ | |
721 | { | |
376f269e | 722 | unsigned long *freq = arg; |
1da177e4 LT |
723 | |
724 | freq2.tuner = 0; | |
725 | drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); | |
726 | freq2.frequency = *freq; | |
727 | err = drv(inode, file, VIDIOC_S_FREQUENCY, &freq2); | |
728 | if (err < 0) | |
729 | dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n",err); | |
730 | break; | |
731 | } | |
732 | case VIDIOCGAUDIO: /* get audio properties/controls */ | |
733 | { | |
734 | struct video_audio *aud = arg; | |
735 | ||
736 | err = drv(inode, file, VIDIOC_G_AUDIO, &aud2); | |
737 | if (err < 0) { | |
738 | dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n",err); | |
739 | break; | |
740 | } | |
741 | memcpy(aud->name, aud2.name, | |
742 | min(sizeof(aud->name), sizeof(aud2.name))); | |
743 | aud->name[sizeof(aud->name) - 1] = 0; | |
744 | aud->audio = aud2.index; | |
745 | aud->flags = 0; | |
746 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, drv); | |
747 | if (i >= 0) { | |
748 | aud->volume = i; | |
749 | aud->flags |= VIDEO_AUDIO_VOLUME; | |
750 | } | |
751 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_BASS, drv); | |
752 | if (i >= 0) { | |
753 | aud->bass = i; | |
754 | aud->flags |= VIDEO_AUDIO_BASS; | |
755 | } | |
756 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_TREBLE, drv); | |
757 | if (i >= 0) { | |
758 | aud->treble = i; | |
759 | aud->flags |= VIDEO_AUDIO_TREBLE; | |
760 | } | |
761 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_BALANCE, drv); | |
762 | if (i >= 0) { | |
763 | aud->balance = i; | |
764 | aud->flags |= VIDEO_AUDIO_BALANCE; | |
765 | } | |
766 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_MUTE, drv); | |
767 | if (i >= 0) { | |
768 | if (i) | |
769 | aud->flags |= VIDEO_AUDIO_MUTE; | |
770 | aud->flags |= VIDEO_AUDIO_MUTABLE; | |
771 | } | |
772 | aud->step = 1; | |
773 | qctrl2.id = V4L2_CID_AUDIO_VOLUME; | |
774 | if (drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2) == 0 && | |
775 | !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) | |
776 | aud->step = qctrl2.step; | |
777 | aud->mode = 0; | |
ac19ecc6 MCC |
778 | |
779 | memset(&tun2,0,sizeof(tun2)); | |
1da177e4 LT |
780 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); |
781 | if (err < 0) { | |
782 | dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n",err); | |
783 | err = 0; | |
784 | break; | |
785 | } | |
ac19ecc6 | 786 | |
1da177e4 LT |
787 | if (tun2.rxsubchans & V4L2_TUNER_SUB_LANG2) |
788 | aud->mode = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | |
789 | else if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) | |
790 | aud->mode = VIDEO_SOUND_STEREO; | |
791 | else if (tun2.rxsubchans & V4L2_TUNER_SUB_MONO) | |
792 | aud->mode = VIDEO_SOUND_MONO; | |
793 | break; | |
794 | } | |
795 | case VIDIOCSAUDIO: /* set audio controls */ | |
796 | { | |
797 | struct video_audio *aud = arg; | |
798 | ||
799 | memset(&aud2,0,sizeof(aud2)); | |
800 | memset(&tun2,0,sizeof(tun2)); | |
801 | ||
802 | aud2.index = aud->audio; | |
803 | err = drv(inode, file, VIDIOC_S_AUDIO, &aud2); | |
804 | if (err < 0) { | |
805 | dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n",err); | |
806 | break; | |
807 | } | |
808 | ||
809 | set_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, | |
810 | aud->volume, drv); | |
811 | set_v4l_control(inode, file, V4L2_CID_AUDIO_BASS, | |
812 | aud->bass, drv); | |
813 | set_v4l_control(inode, file, V4L2_CID_AUDIO_TREBLE, | |
814 | aud->treble, drv); | |
815 | set_v4l_control(inode, file, V4L2_CID_AUDIO_BALANCE, | |
816 | aud->balance, drv); | |
817 | set_v4l_control(inode, file, V4L2_CID_AUDIO_MUTE, | |
818 | !!(aud->flags & VIDEO_AUDIO_MUTE), drv); | |
819 | ||
820 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); | |
821 | if (err < 0) | |
822 | dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %d\n",err); | |
823 | if (err == 0) { | |
824 | switch (aud->mode) { | |
825 | default: | |
826 | case VIDEO_SOUND_MONO: | |
827 | case VIDEO_SOUND_LANG1: | |
828 | tun2.audmode = V4L2_TUNER_MODE_MONO; | |
829 | break; | |
830 | case VIDEO_SOUND_STEREO: | |
831 | tun2.audmode = V4L2_TUNER_MODE_STEREO; | |
832 | break; | |
833 | case VIDEO_SOUND_LANG2: | |
834 | tun2.audmode = V4L2_TUNER_MODE_LANG2; | |
835 | break; | |
836 | } | |
837 | err = drv(inode, file, VIDIOC_S_TUNER, &tun2); | |
838 | if (err < 0) | |
839 | dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n",err); | |
840 | } | |
841 | err = 0; | |
842 | break; | |
843 | } | |
1da177e4 LT |
844 | case VIDIOCMCAPTURE: /* capture a frame */ |
845 | { | |
846 | struct video_mmap *mm = arg; | |
847 | ||
7408187d | 848 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
1da177e4 | 849 | memset(&buf2,0,sizeof(buf2)); |
1da177e4 LT |
850 | |
851 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |
852 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | |
853 | if (err < 0) { | |
854 | dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n",err); | |
855 | break; | |
856 | } | |
857 | if (mm->width != fmt2->fmt.pix.width || | |
858 | mm->height != fmt2->fmt.pix.height || | |
859 | palette_to_pixelformat(mm->format) != | |
860 | fmt2->fmt.pix.pixelformat) | |
861 | {/* New capture format... */ | |
862 | fmt2->fmt.pix.width = mm->width; | |
863 | fmt2->fmt.pix.height = mm->height; | |
864 | fmt2->fmt.pix.pixelformat = | |
865 | palette_to_pixelformat(mm->format); | |
866 | fmt2->fmt.pix.field = V4L2_FIELD_ANY; | |
867 | fmt2->fmt.pix.bytesperline = 0; | |
868 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | |
869 | if (err < 0) { | |
870 | dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n",err); | |
871 | break; | |
872 | } | |
873 | } | |
874 | buf2.index = mm->frame; | |
875 | buf2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |
876 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); | |
877 | if (err < 0) { | |
878 | dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n",err); | |
879 | break; | |
880 | } | |
881 | err = drv(inode, file, VIDIOC_QBUF, &buf2); | |
882 | if (err < 0) { | |
883 | dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n",err); | |
884 | break; | |
885 | } | |
886 | err = drv(inode, file, VIDIOC_STREAMON, &captype); | |
887 | if (err < 0) | |
888 | dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n",err); | |
889 | break; | |
890 | } | |
891 | case VIDIOCSYNC: /* wait for a frame */ | |
892 | { | |
893 | int *i = arg; | |
894 | ||
895 | buf2.index = *i; | |
896 | buf2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |
897 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); | |
898 | if (err < 0) { | |
899 | /* No such buffer */ | |
900 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n",err); | |
901 | break; | |
902 | } | |
903 | if (!(buf2.flags & V4L2_BUF_FLAG_MAPPED)) { | |
904 | /* Buffer is not mapped */ | |
905 | err = -EINVAL; | |
906 | break; | |
907 | } | |
908 | ||
909 | /* make sure capture actually runs so we don't block forever */ | |
910 | err = drv(inode, file, VIDIOC_STREAMON, &captype); | |
911 | if (err < 0) { | |
912 | dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n",err); | |
913 | break; | |
914 | } | |
915 | ||
916 | /* Loop as long as the buffer is queued, but not done */ | |
917 | while ((buf2.flags & | |
918 | (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE)) | |
919 | == V4L2_BUF_FLAG_QUEUED) | |
920 | { | |
921 | err = poll_one(file); | |
922 | if (err < 0 || /* error or sleep was interrupted */ | |
923 | err == 0) /* timeout? Shouldn't occur. */ | |
924 | break; | |
925 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); | |
926 | if (err < 0) | |
927 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n",err); | |
928 | } | |
929 | if (!(buf2.flags & V4L2_BUF_FLAG_DONE)) /* not done */ | |
930 | break; | |
931 | do { | |
932 | err = drv(inode, file, VIDIOC_DQBUF, &buf2); | |
933 | if (err < 0) | |
934 | dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n",err); | |
935 | } while (err == 0 && buf2.index != *i); | |
936 | break; | |
937 | } | |
938 | ||
939 | case VIDIOCGVBIFMT: /* query VBI data capture format */ | |
940 | { | |
941 | struct vbi_format *fmt = arg; | |
942 | ||
7408187d | 943 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
1da177e4 LT |
944 | fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; |
945 | ||
946 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | |
947 | if (err < 0) { | |
948 | dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err); | |
949 | break; | |
950 | } | |
67f1570a MS |
951 | if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { |
952 | err = -EINVAL; | |
953 | break; | |
954 | } | |
1da177e4 LT |
955 | memset(fmt, 0, sizeof(*fmt)); |
956 | fmt->samples_per_line = fmt2->fmt.vbi.samples_per_line; | |
957 | fmt->sampling_rate = fmt2->fmt.vbi.sampling_rate; | |
958 | fmt->sample_format = VIDEO_PALETTE_RAW; | |
959 | fmt->start[0] = fmt2->fmt.vbi.start[0]; | |
960 | fmt->count[0] = fmt2->fmt.vbi.count[0]; | |
961 | fmt->start[1] = fmt2->fmt.vbi.start[1]; | |
962 | fmt->count[1] = fmt2->fmt.vbi.count[1]; | |
963 | fmt->flags = fmt2->fmt.vbi.flags & 0x03; | |
4ac97914 | 964 | break; |
1da177e4 LT |
965 | } |
966 | case VIDIOCSVBIFMT: | |
967 | { | |
968 | struct vbi_format *fmt = arg; | |
969 | ||
67f1570a MS |
970 | if (VIDEO_PALETTE_RAW != fmt->sample_format) { |
971 | err = -EINVAL; | |
972 | break; | |
973 | } | |
974 | ||
7408187d | 975 | fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); |
1da177e4 LT |
976 | |
977 | fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; | |
978 | fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line; | |
979 | fmt2->fmt.vbi.sampling_rate = fmt->sampling_rate; | |
980 | fmt2->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | |
981 | fmt2->fmt.vbi.start[0] = fmt->start[0]; | |
982 | fmt2->fmt.vbi.count[0] = fmt->count[0]; | |
983 | fmt2->fmt.vbi.start[1] = fmt->start[1]; | |
984 | fmt2->fmt.vbi.count[1] = fmt->count[1]; | |
985 | fmt2->fmt.vbi.flags = fmt->flags; | |
986 | err = drv(inode, file, VIDIOC_TRY_FMT, fmt2); | |
987 | if (err < 0) { | |
988 | dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err); | |
989 | break; | |
990 | } | |
991 | ||
992 | if (fmt2->fmt.vbi.samples_per_line != fmt->samples_per_line || | |
993 | fmt2->fmt.vbi.sampling_rate != fmt->sampling_rate || | |
67f1570a | 994 | fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY || |
1da177e4 LT |
995 | fmt2->fmt.vbi.start[0] != fmt->start[0] || |
996 | fmt2->fmt.vbi.count[0] != fmt->count[0] || | |
997 | fmt2->fmt.vbi.start[1] != fmt->start[1] || | |
998 | fmt2->fmt.vbi.count[1] != fmt->count[1] || | |
999 | fmt2->fmt.vbi.flags != fmt->flags) { | |
1000 | err = -EINVAL; | |
1001 | break; | |
1002 | } | |
1003 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | |
1004 | if (err < 0) | |
1005 | dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err); | |
1006 | break; | |
1007 | } | |
1008 | ||
1009 | default: | |
1010 | err = -ENOIOCTLCMD; | |
1011 | break; | |
1012 | } | |
1013 | ||
2ea75330 JJ |
1014 | kfree(cap2); |
1015 | kfree(fmt2); | |
1da177e4 LT |
1016 | return err; |
1017 | } | |
1018 | ||
1019 | EXPORT_SYMBOL(v4l_compat_translate_ioctl); | |
1020 | ||
1021 | /* | |
1022 | * Local variables: | |
1023 | * c-basic-offset: 8 | |
1024 | * End: | |
1025 | */ |