Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] V4L: remove V4L1 compatibility mode

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
08af245d b69a219e

+9 -2116
-15
drivers/media/Kconfig
··· 53 53 54 54 If you are unsure as to whether this is required, answer Y. 55 55 56 - config VIDEO_V4L1_COMPAT 57 - bool "Enable Video For Linux API 1 compatible Layer" if !VIDEO_ALLOW_V4L1 58 - depends on VIDEO_DEV 59 - default y 60 - ---help--- 61 - Enables a compatibility API used by most V4L2 devices to allow 62 - its usage with legacy applications that supports only V4L1 api. 63 - 64 - Documentation for the original API is included in the file 65 - <Documentation/video4linux/API.html>. 66 - 67 - User tools for this are available from 68 - <ftp://ftp.uk.linux.org/pub/linux/video4linux/>. 69 - 70 - If you are unsure as to whether this is required, answer Y. 71 56 72 57 # 73 58 # DVB Core
-32
drivers/media/common/saa7146_video.c
··· 1129 1129 core, g_chip_ident, chip); 1130 1130 } 1131 1131 1132 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1133 - static int vidiocgmbuf(struct file *file, void *__fh, struct video_mbuf *mbuf) 1134 - { 1135 - struct saa7146_fh *fh = __fh; 1136 - struct videobuf_queue *q = &fh->video_q; 1137 - int err, i; 1138 - 1139 - /* fixme: number of capture buffers and sizes for v4l apps */ 1140 - int gbuffers = 2; 1141 - int gbufsize = 768 * 576 * 4; 1142 - 1143 - DEB_D(("VIDIOCGMBUF \n")); 1144 - 1145 - q = &fh->video_q; 1146 - err = videobuf_mmap_setup(q, gbuffers, gbufsize, 1147 - V4L2_MEMORY_MMAP); 1148 - if (err < 0) 1149 - return err; 1150 - 1151 - gbuffers = err; 1152 - memset(mbuf, 0, sizeof(*mbuf)); 1153 - mbuf->frames = gbuffers; 1154 - mbuf->size = gbuffers * gbufsize; 1155 - for (i = 0; i < gbuffers; i++) 1156 - mbuf->offsets[i] = i * gbufsize; 1157 - return 0; 1158 - } 1159 - #endif 1160 - 1161 1132 const struct v4l2_ioctl_ops saa7146_video_ioctl_ops = { 1162 1133 .vidioc_querycap = vidioc_querycap, 1163 1134 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, ··· 1157 1186 .vidioc_streamon = vidioc_streamon, 1158 1187 .vidioc_streamoff = vidioc_streamoff, 1159 1188 .vidioc_g_parm = vidioc_g_parm, 1160 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1161 - .vidiocgmbuf = vidiocgmbuf, 1162 - #endif 1163 1189 }; 1164 1190 1165 1191 /*********************************************************************************/
-4
drivers/media/video/Makefile
··· 22 22 23 23 obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o 24 24 25 - ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y) 26 - obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o 27 - endif 28 - 29 25 # All i2c modules must come first: 30 26 31 27 obj-$(CONFIG_VIDEO_TUNER) += tuner.o
-12
drivers/media/video/au0828/au0828-video.c
··· 1809 1809 return videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & O_NONBLOCK); 1810 1810 } 1811 1811 1812 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1813 - static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 1814 - { 1815 - struct au0828_fh *fh = priv; 1816 - 1817 - return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8); 1818 - } 1819 - #endif 1820 - 1821 1812 static struct v4l2_file_operations au0828_v4l_fops = { 1822 1813 .owner = THIS_MODULE, 1823 1814 .open = au0828_v4l2_open, ··· 1852 1861 .vidioc_s_register = vidioc_s_register, 1853 1862 #endif 1854 1863 .vidioc_g_chip_ident = vidioc_g_chip_ident, 1855 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1856 - .vidiocgmbuf = vidiocgmbuf, 1857 - #endif 1858 1864 }; 1859 1865 1860 1866 static const struct video_device au0828_video_template = {
-28
drivers/media/video/bt8xx/bttv-driver.c
··· 2597 2597 return setup_window_lock(fh, btv, &f->fmt.win, 1); 2598 2598 } 2599 2599 2600 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 2601 - static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 2602 - { 2603 - int retval; 2604 - unsigned int i; 2605 - struct bttv_fh *fh = priv; 2606 - 2607 - retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, 2608 - V4L2_MEMORY_MMAP); 2609 - if (retval < 0) { 2610 - return retval; 2611 - } 2612 - 2613 - gbuffers = retval; 2614 - memset(mbuf, 0, sizeof(*mbuf)); 2615 - mbuf->frames = gbuffers; 2616 - mbuf->size = gbuffers * gbufsize; 2617 - 2618 - for (i = 0; i < gbuffers; i++) 2619 - mbuf->offsets[i] = i * gbufsize; 2620 - 2621 - return 0; 2622 - } 2623 - #endif 2624 - 2625 2600 static int bttv_querycap(struct file *file, void *priv, 2626 2601 struct v4l2_capability *cap) 2627 2602 { ··· 3329 3354 .vidioc_streamoff = bttv_streamoff, 3330 3355 .vidioc_g_tuner = bttv_g_tuner, 3331 3356 .vidioc_s_tuner = bttv_s_tuner, 3332 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 3333 - .vidiocgmbuf = vidiocgmbuf, 3334 - #endif 3335 3357 .vidioc_g_crop = bttv_g_crop, 3336 3358 .vidioc_s_crop = bttv_s_crop, 3337 3359 .vidioc_g_fbuf = bttv_g_fbuf,
-38
drivers/media/video/cpia2/cpia2_v4l.c
··· 419 419 420 420 /****************************************************************************** 421 421 * 422 - * ioctl_get_mbuf 423 - * 424 - *****************************************************************************/ 425 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 426 - static int ioctl_get_mbuf(void *arg, struct camera_data *cam) 427 - { 428 - struct video_mbuf *vm; 429 - int i; 430 - vm = arg; 431 - 432 - memset(vm, 0, sizeof(*vm)); 433 - vm->size = cam->frame_size*cam->num_frames; 434 - vm->frames = cam->num_frames; 435 - for (i = 0; i < cam->num_frames; i++) 436 - vm->offsets[i] = cam->frame_size * i; 437 - 438 - return 0; 439 - } 440 - #endif 441 - 442 - /****************************************************************************** 443 - * 444 422 * ioctl_set_gpio 445 423 * 446 424 *****************************************************************************/ ··· 1358 1380 } 1359 1381 break; 1360 1382 } 1361 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1362 - case VIDIOCGMBUF: 1363 - { 1364 - struct cpia2_fh *fh = file->private_data; 1365 - if(fh->prio != V4L2_PRIORITY_RECORD) { 1366 - mutex_unlock(&cam->busy_lock); 1367 - return -EBUSY; 1368 - } 1369 - break; 1370 - } 1371 - #endif 1372 1383 default: 1373 1384 break; 1374 1385 } ··· 1367 1400 case CPIA2_IOC_SET_GPIO: 1368 1401 retval = ioctl_set_gpio(arg, cam); 1369 1402 break; 1370 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1371 - case VIDIOCGMBUF: /* mmap interface */ 1372 - retval = ioctl_get_mbuf(arg, cam); 1373 - break; 1374 - #endif 1375 1403 case VIDIOC_QUERYCAP: 1376 1404 retval = ioctl_querycap(arg,cam); 1377 1405 break;
-12
drivers/media/video/cx231xx/cx231xx-video.c
··· 2044 2044 return videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & O_NONBLOCK); 2045 2045 } 2046 2046 2047 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 2048 - static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 2049 - { 2050 - struct cx231xx_fh *fh = priv; 2051 - 2052 - return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8); 2053 - } 2054 - #endif 2055 - 2056 2047 /* ----------------------------------------------------------- */ 2057 2048 /* RADIO ESPECIFIC IOCTLS */ 2058 2049 /* ----------------------------------------------------------- */ ··· 2497 2506 #ifdef CONFIG_VIDEO_ADV_DEBUG 2498 2507 .vidioc_g_register = vidioc_g_register, 2499 2508 .vidioc_s_register = vidioc_s_register, 2500 - #endif 2501 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 2502 - .vidiocgmbuf = vidiocgmbuf, 2503 2509 #endif 2504 2510 }; 2505 2511
-32
drivers/media/video/cx23885/cx23885-video.c
··· 1024 1024 return 0; 1025 1025 } 1026 1026 1027 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1028 - static int vidiocgmbuf(struct file *file, void *priv, 1029 - struct video_mbuf *mbuf) 1030 - { 1031 - struct cx23885_fh *fh = priv; 1032 - struct videobuf_queue *q; 1033 - struct v4l2_requestbuffers req; 1034 - unsigned int i; 1035 - int err; 1036 - 1037 - q = get_queue(fh); 1038 - memset(&req, 0, sizeof(req)); 1039 - req.type = q->type; 1040 - req.count = 8; 1041 - req.memory = V4L2_MEMORY_MMAP; 1042 - err = videobuf_reqbufs(q, &req); 1043 - if (err < 0) 1044 - return err; 1045 - 1046 - mbuf->frames = req.count; 1047 - mbuf->size = 0; 1048 - for (i = 0; i < mbuf->frames; i++) { 1049 - mbuf->offsets[i] = q->bufs[i]->boff; 1050 - mbuf->size += q->bufs[i]->bsize; 1051 - } 1052 - return 0; 1053 - } 1054 - #endif 1055 - 1056 1027 static int vidioc_reqbufs(struct file *file, void *priv, 1057 1028 struct v4l2_requestbuffers *p) 1058 1029 { ··· 1398 1427 .vidioc_s_ctrl = vidioc_s_ctrl, 1399 1428 .vidioc_streamon = vidioc_streamon, 1400 1429 .vidioc_streamoff = vidioc_streamoff, 1401 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1402 - .vidiocgmbuf = vidiocgmbuf, 1403 - #endif 1404 1430 .vidioc_g_tuner = vidioc_g_tuner, 1405 1431 .vidioc_s_tuner = vidioc_s_tuner, 1406 1432 .vidioc_g_frequency = vidioc_g_frequency,
-12
drivers/media/video/cx88/cx88-video.c
··· 1179 1179 return 0; 1180 1180 } 1181 1181 1182 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1183 - static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf) 1184 - { 1185 - struct cx8800_fh *fh = priv; 1186 - 1187 - return videobuf_cgmbuf (get_queue(fh), mbuf, 8); 1188 - } 1189 - #endif 1190 - 1191 1182 static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) 1192 1183 { 1193 1184 struct cx8800_fh *fh = priv; ··· 1722 1731 .vidioc_s_ctrl = vidioc_s_ctrl, 1723 1732 .vidioc_streamon = vidioc_streamon, 1724 1733 .vidioc_streamoff = vidioc_streamoff, 1725 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1726 - .vidiocgmbuf = vidiocgmbuf, 1727 - #endif 1728 1734 .vidioc_g_tuner = vidioc_g_tuner, 1729 1735 .vidioc_s_tuner = vidioc_s_tuner, 1730 1736 .vidioc_g_frequency = vidioc_g_frequency,
-16
drivers/media/video/em28xx/em28xx-video.c
··· 1934 1934 O_NONBLOCK); 1935 1935 } 1936 1936 1937 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1938 - static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 1939 - { 1940 - struct em28xx_fh *fh = priv; 1941 - 1942 - if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 1943 - return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8); 1944 - else 1945 - return videobuf_cgmbuf(&fh->vb_vbiq, mbuf, 8); 1946 - } 1947 - #endif 1948 - 1949 - 1950 1937 /* ----------------------------------------------------------- */ 1951 1938 /* RADIO ESPECIFIC IOCTLS */ 1952 1939 /* ----------------------------------------------------------- */ ··· 2345 2358 .vidioc_g_register = vidioc_g_register, 2346 2359 .vidioc_s_register = vidioc_s_register, 2347 2360 .vidioc_g_chip_ident = vidioc_g_chip_ident, 2348 - #endif 2349 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 2350 - .vidiocgmbuf = vidiocgmbuf, 2351 2361 #endif 2352 2362 }; 2353 2363
+2 -2
drivers/media/video/pvrusb2/pvrusb2-v4l2.c
··· 852 852 #endif 853 853 854 854 default : 855 - ret = v4l_compat_translate_ioctl(file, cmd, 856 - arg, pvr2_v4l2_do_ioctl); 855 + ret = -EINVAL; 856 + break; 857 857 } 858 858 859 859 pvr2_hdw_commit_ctl(hdw);
-17
drivers/media/video/pwc/pwc-v4l.c
··· 362 362 363 363 364 364 switch (cmd) { 365 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 366 - /* mmap() functions */ 367 - case VIDIOCGMBUF: 368 - { 369 - /* Tell the user program how much memory is needed for a mmap() */ 370 - struct video_mbuf *vm = arg; 371 - int i; 372 - 373 - memset(vm, 0, sizeof(*vm)); 374 - vm->size = pwc_mbufs * pdev->len_per_image; 375 - vm->frames = pwc_mbufs; /* double buffering should be enough for most applications */ 376 - for (i = 0; i < pwc_mbufs; i++) 377 - vm->offsets[i] = i * pdev->len_per_image; 378 - break; 379 - } 380 - #endif 381 - 382 365 /* V4L2 Layer */ 383 366 case VIDIOC_QUERYCAP: 384 367 {
-12
drivers/media/video/s2255drv.c
··· 1097 1097 return rc; 1098 1098 } 1099 1099 1100 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1101 - static int vidioc_cgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 1102 - { 1103 - struct s2255_fh *fh = priv; 1104 - 1105 - return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8); 1106 - } 1107 - #endif 1108 - 1109 1100 /* write to the configuration pipe, synchronously */ 1110 1101 static int s2255_write_config(struct usb_device *udev, unsigned char *pbuf, 1111 1102 int size) ··· 1900 1909 .vidioc_s_ctrl = vidioc_s_ctrl, 1901 1910 .vidioc_streamon = vidioc_streamon, 1902 1911 .vidioc_streamoff = vidioc_streamoff, 1903 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1904 - .vidiocgmbuf = vidioc_cgmbuf, 1905 - #endif 1906 1912 .vidioc_s_jpegcomp = vidioc_s_jpegcomp, 1907 1913 .vidioc_g_jpegcomp = vidioc_g_jpegcomp, 1908 1914 .vidioc_s_parm = vidioc_s_parm,
-11
drivers/media/video/saa7134/saa7134-video.c
··· 2211 2211 return 0; 2212 2212 } 2213 2213 2214 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 2215 - static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 2216 - { 2217 - struct saa7134_fh *fh = file->private_data; 2218 - return videobuf_cgmbuf(saa7134_queue(fh), mbuf, 8); 2219 - } 2220 - #endif 2221 - 2222 2214 static int saa7134_reqbufs(struct file *file, void *priv, 2223 2215 struct v4l2_requestbuffers *p) 2224 2216 { ··· 2448 2456 .vidioc_streamoff = saa7134_streamoff, 2449 2457 .vidioc_g_tuner = saa7134_g_tuner, 2450 2458 .vidioc_s_tuner = saa7134_s_tuner, 2451 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 2452 - .vidiocgmbuf = vidiocgmbuf, 2453 - #endif 2454 2459 .vidioc_g_crop = saa7134_g_crop, 2455 2460 .vidioc_s_crop = saa7134_s_crop, 2456 2461 .vidioc_g_fbuf = saa7134_g_fbuf,
-3
drivers/media/video/usbvision/usbvision-video.c
··· 1273 1273 .vidioc_s_ctrl = vidioc_s_ctrl, 1274 1274 .vidioc_streamon = vidioc_streamon, 1275 1275 .vidioc_streamoff = vidioc_streamoff, 1276 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1277 - /* .vidiocgmbuf = vidiocgmbuf, */ 1278 - #endif 1279 1276 .vidioc_g_tuner = vidioc_g_tuner, 1280 1277 .vidioc_s_tuner = vidioc_s_tuner, 1281 1278 .vidioc_g_frequency = vidioc_g_frequency,
+2 -5
drivers/media/video/uvc/uvc_v4l2.c
··· 1035 1035 return uvc_xu_ctrl_query(chain, arg, 1); 1036 1036 1037 1037 default: 1038 - if ((ret = v4l_compat_translate_ioctl(file, cmd, arg, 1039 - uvc_v4l2_do_ioctl)) == -ENOIOCTLCMD) 1040 - uvc_trace(UVC_TRACE_IOCTL, "Unknown ioctl 0x%08x\n", 1041 - cmd); 1042 - return ret; 1038 + uvc_trace(UVC_TRACE_IOCTL, "Unknown ioctl 0x%08x\n", cmd); 1039 + return -EINVAL; 1043 1040 } 1044 1041 1045 1042 return ret;
-1277
drivers/media/video/v4l1-compat.c
··· 1 - /* 2 - * 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 <bill@thedirks.org> 15 - * et al. 16 - * 17 - */ 18 - 19 - 20 - #include <linux/init.h> 21 - #include <linux/module.h> 22 - #include <linux/types.h> 23 - #include <linux/kernel.h> 24 - #include <linux/sched.h> 25 - #include <linux/mm.h> 26 - #include <linux/fs.h> 27 - #include <linux/file.h> 28 - #include <linux/string.h> 29 - #include <linux/errno.h> 30 - #include <linux/slab.h> 31 - #include <linux/videodev.h> 32 - #include <media/v4l2-common.h> 33 - #include <media/v4l2-ioctl.h> 34 - 35 - #include <asm/uaccess.h> 36 - #include <asm/system.h> 37 - #include <asm/pgtable.h> 38 - 39 - static unsigned int debug; 40 - module_param(debug, int, 0644); 41 - MODULE_PARM_DESC(debug, "enable debug messages"); 42 - MODULE_AUTHOR("Bill Dirks"); 43 - MODULE_DESCRIPTION("v4l(1) compatibility layer for v4l2 drivers."); 44 - MODULE_LICENSE("GPL"); 45 - 46 - #define dprintk(fmt, arg...) \ 47 - do { \ 48 - if (debug) \ 49 - printk(KERN_DEBUG "v4l1-compat: " fmt , ## arg);\ 50 - } while (0) 51 - 52 - /* 53 - * I O C T L T R A N S L A T I O N 54 - * 55 - * From here on down is the code for translating the numerous 56 - * ioctl commands from the old API to the new API. 57 - */ 58 - 59 - static int 60 - get_v4l_control(struct file *file, 61 - int cid, 62 - v4l2_kioctl drv) 63 - { 64 - struct v4l2_queryctrl qctrl2; 65 - struct v4l2_control ctrl2; 66 - int err; 67 - 68 - qctrl2.id = cid; 69 - err = drv(file, VIDIOC_QUERYCTRL, &qctrl2); 70 - if (err < 0) 71 - dprintk("VIDIOC_QUERYCTRL: %d\n", err); 72 - if (err == 0 && !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) { 73 - ctrl2.id = qctrl2.id; 74 - err = drv(file, VIDIOC_G_CTRL, &ctrl2); 75 - if (err < 0) { 76 - dprintk("VIDIOC_G_CTRL: %d\n", err); 77 - return 0; 78 - } 79 - return DIV_ROUND_CLOSEST((ctrl2.value-qctrl2.minimum) * 65535, 80 - qctrl2.maximum - qctrl2.minimum); 81 - } 82 - return 0; 83 - } 84 - 85 - static int 86 - set_v4l_control(struct file *file, 87 - int cid, 88 - int value, 89 - v4l2_kioctl drv) 90 - { 91 - struct v4l2_queryctrl qctrl2; 92 - struct v4l2_control ctrl2; 93 - int err; 94 - 95 - qctrl2.id = cid; 96 - err = drv(file, VIDIOC_QUERYCTRL, &qctrl2); 97 - if (err < 0) 98 - dprintk("VIDIOC_QUERYCTRL: %d\n", err); 99 - if (err == 0 && 100 - !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED) && 101 - !(qctrl2.flags & V4L2_CTRL_FLAG_GRABBED)) { 102 - if (value < 0) 103 - value = 0; 104 - if (value > 65535) 105 - value = 65535; 106 - if (value && qctrl2.type == V4L2_CTRL_TYPE_BOOLEAN) 107 - value = 65535; 108 - ctrl2.id = qctrl2.id; 109 - ctrl2.value = 110 - (value * (qctrl2.maximum - qctrl2.minimum) 111 - + 32767) 112 - / 65535; 113 - ctrl2.value += qctrl2.minimum; 114 - err = drv(file, VIDIOC_S_CTRL, &ctrl2); 115 - if (err < 0) 116 - dprintk("VIDIOC_S_CTRL: %d\n", err); 117 - } 118 - return 0; 119 - } 120 - 121 - /* ----------------------------------------------------------------- */ 122 - 123 - static const unsigned int palette2pixelformat[] = { 124 - [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY, 125 - [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555, 126 - [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565, 127 - [VIDEO_PALETTE_RGB24] = V4L2_PIX_FMT_BGR24, 128 - [VIDEO_PALETTE_RGB32] = V4L2_PIX_FMT_BGR32, 129 - /* yuv packed pixel */ 130 - [VIDEO_PALETTE_YUYV] = V4L2_PIX_FMT_YUYV, 131 - [VIDEO_PALETTE_YUV422] = V4L2_PIX_FMT_YUYV, 132 - [VIDEO_PALETTE_UYVY] = V4L2_PIX_FMT_UYVY, 133 - /* yuv planar */ 134 - [VIDEO_PALETTE_YUV410P] = V4L2_PIX_FMT_YUV410, 135 - [VIDEO_PALETTE_YUV420] = V4L2_PIX_FMT_YUV420, 136 - [VIDEO_PALETTE_YUV420P] = V4L2_PIX_FMT_YUV420, 137 - [VIDEO_PALETTE_YUV411P] = V4L2_PIX_FMT_YUV411P, 138 - [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P, 139 - }; 140 - 141 - static unsigned int __pure 142 - palette_to_pixelformat(unsigned int palette) 143 - { 144 - if (palette < ARRAY_SIZE(palette2pixelformat)) 145 - return palette2pixelformat[palette]; 146 - else 147 - return 0; 148 - } 149 - 150 - static unsigned int __attribute_const__ 151 - pixelformat_to_palette(unsigned int pixelformat) 152 - { 153 - int palette = 0; 154 - switch (pixelformat) { 155 - case V4L2_PIX_FMT_GREY: 156 - palette = VIDEO_PALETTE_GREY; 157 - break; 158 - case V4L2_PIX_FMT_RGB555: 159 - palette = VIDEO_PALETTE_RGB555; 160 - break; 161 - case V4L2_PIX_FMT_RGB565: 162 - palette = VIDEO_PALETTE_RGB565; 163 - break; 164 - case V4L2_PIX_FMT_BGR24: 165 - palette = VIDEO_PALETTE_RGB24; 166 - break; 167 - case V4L2_PIX_FMT_BGR32: 168 - palette = VIDEO_PALETTE_RGB32; 169 - break; 170 - /* yuv packed pixel */ 171 - case V4L2_PIX_FMT_YUYV: 172 - palette = VIDEO_PALETTE_YUYV; 173 - break; 174 - case V4L2_PIX_FMT_UYVY: 175 - palette = VIDEO_PALETTE_UYVY; 176 - break; 177 - /* yuv planar */ 178 - case V4L2_PIX_FMT_YUV410: 179 - palette = VIDEO_PALETTE_YUV420; 180 - break; 181 - case V4L2_PIX_FMT_YUV420: 182 - palette = VIDEO_PALETTE_YUV420; 183 - break; 184 - case V4L2_PIX_FMT_YUV411P: 185 - palette = VIDEO_PALETTE_YUV411P; 186 - break; 187 - case V4L2_PIX_FMT_YUV422P: 188 - palette = VIDEO_PALETTE_YUV422P; 189 - break; 190 - } 191 - return palette; 192 - } 193 - 194 - /* ----------------------------------------------------------------- */ 195 - 196 - static int poll_one(struct file *file, struct poll_wqueues *pwq) 197 - { 198 - int retval = 1; 199 - poll_table *table; 200 - 201 - poll_initwait(pwq); 202 - table = &pwq->pt; 203 - for (;;) { 204 - int mask; 205 - mask = file->f_op->poll(file, table); 206 - if (mask & POLLIN) 207 - break; 208 - table = NULL; 209 - if (signal_pending(current)) { 210 - retval = -ERESTARTSYS; 211 - break; 212 - } 213 - poll_schedule(pwq, TASK_INTERRUPTIBLE); 214 - } 215 - poll_freewait(pwq); 216 - return retval; 217 - } 218 - 219 - static int count_inputs( 220 - struct file *file, 221 - v4l2_kioctl drv) 222 - { 223 - struct v4l2_input input2; 224 - int i; 225 - 226 - for (i = 0;; i++) { 227 - memset(&input2, 0, sizeof(input2)); 228 - input2.index = i; 229 - if (0 != drv(file, VIDIOC_ENUMINPUT, &input2)) 230 - break; 231 - } 232 - return i; 233 - } 234 - 235 - static int check_size( 236 - struct file *file, 237 - v4l2_kioctl drv, 238 - int *maxw, 239 - int *maxh) 240 - { 241 - struct v4l2_fmtdesc desc2; 242 - struct v4l2_format fmt2; 243 - 244 - memset(&desc2, 0, sizeof(desc2)); 245 - memset(&fmt2, 0, sizeof(fmt2)); 246 - 247 - desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 248 - if (0 != drv(file, VIDIOC_ENUM_FMT, &desc2)) 249 - goto done; 250 - 251 - fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 252 - fmt2.fmt.pix.width = 10000; 253 - fmt2.fmt.pix.height = 10000; 254 - fmt2.fmt.pix.pixelformat = desc2.pixelformat; 255 - if (0 != drv(file, VIDIOC_TRY_FMT, &fmt2)) 256 - goto done; 257 - 258 - *maxw = fmt2.fmt.pix.width; 259 - *maxh = fmt2.fmt.pix.height; 260 - 261 - done: 262 - return 0; 263 - } 264 - 265 - /* ----------------------------------------------------------------- */ 266 - 267 - static noinline long v4l1_compat_get_capabilities( 268 - struct video_capability *cap, 269 - struct file *file, 270 - v4l2_kioctl drv) 271 - { 272 - long err; 273 - struct v4l2_framebuffer fbuf; 274 - struct v4l2_capability *cap2; 275 - 276 - cap2 = kzalloc(sizeof(*cap2), GFP_KERNEL); 277 - if (!cap2) { 278 - err = -ENOMEM; 279 - return err; 280 - } 281 - memset(cap, 0, sizeof(*cap)); 282 - memset(&fbuf, 0, sizeof(fbuf)); 283 - 284 - err = drv(file, VIDIOC_QUERYCAP, cap2); 285 - if (err < 0) { 286 - dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %ld\n", err); 287 - goto done; 288 - } 289 - if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { 290 - err = drv(file, VIDIOC_G_FBUF, &fbuf); 291 - if (err < 0) { 292 - dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %ld\n", err); 293 - memset(&fbuf, 0, sizeof(fbuf)); 294 - } 295 - err = 0; 296 - } 297 - 298 - memcpy(cap->name, cap2->card, 299 - min(sizeof(cap->name), sizeof(cap2->card))); 300 - cap->name[sizeof(cap->name) - 1] = 0; 301 - if (cap2->capabilities & V4L2_CAP_VIDEO_CAPTURE) 302 - cap->type |= VID_TYPE_CAPTURE; 303 - if (cap2->capabilities & V4L2_CAP_TUNER) 304 - cap->type |= VID_TYPE_TUNER; 305 - if (cap2->capabilities & V4L2_CAP_VBI_CAPTURE) 306 - cap->type |= VID_TYPE_TELETEXT; 307 - if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) 308 - cap->type |= VID_TYPE_OVERLAY; 309 - if (fbuf.capability & V4L2_FBUF_CAP_LIST_CLIPPING) 310 - cap->type |= VID_TYPE_CLIPPING; 311 - 312 - cap->channels = count_inputs(file, drv); 313 - check_size(file, drv, 314 - &cap->maxwidth, &cap->maxheight); 315 - cap->audios = 0; /* FIXME */ 316 - cap->minwidth = 48; /* FIXME */ 317 - cap->minheight = 32; /* FIXME */ 318 - 319 - done: 320 - kfree(cap2); 321 - return err; 322 - } 323 - 324 - static noinline long v4l1_compat_get_frame_buffer( 325 - struct video_buffer *buffer, 326 - struct file *file, 327 - v4l2_kioctl drv) 328 - { 329 - long err; 330 - struct v4l2_framebuffer fbuf; 331 - 332 - memset(buffer, 0, sizeof(*buffer)); 333 - memset(&fbuf, 0, sizeof(fbuf)); 334 - 335 - err = drv(file, VIDIOC_G_FBUF, &fbuf); 336 - if (err < 0) { 337 - dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %ld\n", err); 338 - goto done; 339 - } 340 - buffer->base = fbuf.base; 341 - buffer->height = fbuf.fmt.height; 342 - buffer->width = fbuf.fmt.width; 343 - 344 - switch (fbuf.fmt.pixelformat) { 345 - case V4L2_PIX_FMT_RGB332: 346 - buffer->depth = 8; 347 - break; 348 - case V4L2_PIX_FMT_RGB555: 349 - buffer->depth = 15; 350 - break; 351 - case V4L2_PIX_FMT_RGB565: 352 - buffer->depth = 16; 353 - break; 354 - case V4L2_PIX_FMT_BGR24: 355 - buffer->depth = 24; 356 - break; 357 - case V4L2_PIX_FMT_BGR32: 358 - buffer->depth = 32; 359 - break; 360 - default: 361 - buffer->depth = 0; 362 - } 363 - if (fbuf.fmt.bytesperline) { 364 - buffer->bytesperline = fbuf.fmt.bytesperline; 365 - if (!buffer->depth && buffer->width) 366 - buffer->depth = ((fbuf.fmt.bytesperline<<3) 367 - + (buffer->width-1)) 368 - / buffer->width; 369 - } else { 370 - buffer->bytesperline = 371 - (buffer->width * buffer->depth + 7) & 7; 372 - buffer->bytesperline >>= 3; 373 - } 374 - done: 375 - return err; 376 - } 377 - 378 - static noinline long v4l1_compat_set_frame_buffer( 379 - struct video_buffer *buffer, 380 - struct file *file, 381 - v4l2_kioctl drv) 382 - { 383 - long err; 384 - struct v4l2_framebuffer fbuf; 385 - 386 - memset(&fbuf, 0, sizeof(fbuf)); 387 - fbuf.base = buffer->base; 388 - fbuf.fmt.height = buffer->height; 389 - fbuf.fmt.width = buffer->width; 390 - switch (buffer->depth) { 391 - case 8: 392 - fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB332; 393 - break; 394 - case 15: 395 - fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB555; 396 - break; 397 - case 16: 398 - fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565; 399 - break; 400 - case 24: 401 - fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR24; 402 - break; 403 - case 32: 404 - fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR32; 405 - break; 406 - } 407 - fbuf.fmt.bytesperline = buffer->bytesperline; 408 - err = drv(file, VIDIOC_S_FBUF, &fbuf); 409 - if (err < 0) 410 - dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %ld\n", err); 411 - return err; 412 - } 413 - 414 - static noinline long v4l1_compat_get_win_cap_dimensions( 415 - struct video_window *win, 416 - struct file *file, 417 - v4l2_kioctl drv) 418 - { 419 - long err; 420 - struct v4l2_format *fmt; 421 - 422 - fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); 423 - if (!fmt) { 424 - err = -ENOMEM; 425 - return err; 426 - } 427 - memset(win, 0, sizeof(*win)); 428 - 429 - fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; 430 - err = drv(file, VIDIOC_G_FMT, fmt); 431 - if (err < 0) 432 - dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %ld\n", err); 433 - if (err == 0) { 434 - win->x = fmt->fmt.win.w.left; 435 - win->y = fmt->fmt.win.w.top; 436 - win->width = fmt->fmt.win.w.width; 437 - win->height = fmt->fmt.win.w.height; 438 - win->chromakey = fmt->fmt.win.chromakey; 439 - win->clips = NULL; 440 - win->clipcount = 0; 441 - goto done; 442 - } 443 - 444 - fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 445 - err = drv(file, VIDIOC_G_FMT, fmt); 446 - if (err < 0) { 447 - dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %ld\n", err); 448 - goto done; 449 - } 450 - win->x = 0; 451 - win->y = 0; 452 - win->width = fmt->fmt.pix.width; 453 - win->height = fmt->fmt.pix.height; 454 - win->chromakey = 0; 455 - win->clips = NULL; 456 - win->clipcount = 0; 457 - done: 458 - kfree(fmt); 459 - return err; 460 - } 461 - 462 - static noinline long v4l1_compat_set_win_cap_dimensions( 463 - struct video_window *win, 464 - struct file *file, 465 - v4l2_kioctl drv) 466 - { 467 - long err, err1, err2; 468 - struct v4l2_format *fmt; 469 - 470 - fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); 471 - if (!fmt) { 472 - err = -ENOMEM; 473 - return err; 474 - } 475 - fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 476 - drv(file, VIDIOC_STREAMOFF, &fmt->type); 477 - err1 = drv(file, VIDIOC_G_FMT, fmt); 478 - if (err1 < 0) 479 - dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %ld\n", err1); 480 - if (err1 == 0) { 481 - fmt->fmt.pix.width = win->width; 482 - fmt->fmt.pix.height = win->height; 483 - fmt->fmt.pix.field = V4L2_FIELD_ANY; 484 - fmt->fmt.pix.bytesperline = 0; 485 - err = drv(file, VIDIOC_S_FMT, fmt); 486 - if (err < 0) 487 - dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %ld\n", 488 - err); 489 - win->width = fmt->fmt.pix.width; 490 - win->height = fmt->fmt.pix.height; 491 - } 492 - 493 - memset(fmt, 0, sizeof(*fmt)); 494 - fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; 495 - fmt->fmt.win.w.left = win->x; 496 - fmt->fmt.win.w.top = win->y; 497 - fmt->fmt.win.w.width = win->width; 498 - fmt->fmt.win.w.height = win->height; 499 - fmt->fmt.win.chromakey = win->chromakey; 500 - fmt->fmt.win.clips = (void __user *)win->clips; 501 - fmt->fmt.win.clipcount = win->clipcount; 502 - err2 = drv(file, VIDIOC_S_FMT, fmt); 503 - if (err2 < 0) 504 - dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %ld\n", err2); 505 - 506 - if (err1 != 0 && err2 != 0) 507 - err = err1; 508 - else 509 - err = 0; 510 - kfree(fmt); 511 - return err; 512 - } 513 - 514 - static noinline long v4l1_compat_turn_preview_on_off( 515 - int *on, 516 - struct file *file, 517 - v4l2_kioctl drv) 518 - { 519 - long err; 520 - enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; 521 - 522 - if (0 == *on) { 523 - /* dirty hack time. But v4l1 has no STREAMOFF 524 - * equivalent in the API, and this one at 525 - * least comes close ... */ 526 - drv(file, VIDIOC_STREAMOFF, &captype); 527 - } 528 - err = drv(file, VIDIOC_OVERLAY, on); 529 - if (err < 0) 530 - dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %ld\n", err); 531 - return err; 532 - } 533 - 534 - static noinline long v4l1_compat_get_input_info( 535 - struct video_channel *chan, 536 - struct file *file, 537 - v4l2_kioctl drv) 538 - { 539 - long err; 540 - struct v4l2_input input2; 541 - v4l2_std_id sid; 542 - 543 - memset(&input2, 0, sizeof(input2)); 544 - input2.index = chan->channel; 545 - err = drv(file, VIDIOC_ENUMINPUT, &input2); 546 - if (err < 0) { 547 - dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " 548 - "channel=%d err=%ld\n", chan->channel, err); 549 - goto done; 550 - } 551 - chan->channel = input2.index; 552 - memcpy(chan->name, input2.name, 553 - min(sizeof(chan->name), sizeof(input2.name))); 554 - chan->name[sizeof(chan->name) - 1] = 0; 555 - chan->tuners = (input2.type == V4L2_INPUT_TYPE_TUNER) ? 1 : 0; 556 - chan->flags = (chan->tuners) ? VIDEO_VC_TUNER : 0; 557 - switch (input2.type) { 558 - case V4L2_INPUT_TYPE_TUNER: 559 - chan->type = VIDEO_TYPE_TV; 560 - break; 561 - default: 562 - case V4L2_INPUT_TYPE_CAMERA: 563 - chan->type = VIDEO_TYPE_CAMERA; 564 - break; 565 - } 566 - chan->norm = 0; 567 - /* Note: G_STD might not be present for radio receivers, 568 - * so we should ignore any errors. */ 569 - if (drv(file, VIDIOC_G_STD, &sid) == 0) { 570 - if (sid & V4L2_STD_PAL) 571 - chan->norm = VIDEO_MODE_PAL; 572 - if (sid & V4L2_STD_NTSC) 573 - chan->norm = VIDEO_MODE_NTSC; 574 - if (sid & V4L2_STD_SECAM) 575 - chan->norm = VIDEO_MODE_SECAM; 576 - if (sid == V4L2_STD_ALL) 577 - chan->norm = VIDEO_MODE_AUTO; 578 - } 579 - done: 580 - return err; 581 - } 582 - 583 - static noinline long v4l1_compat_set_input( 584 - struct video_channel *chan, 585 - struct file *file, 586 - v4l2_kioctl drv) 587 - { 588 - long err; 589 - v4l2_std_id sid = 0; 590 - 591 - err = drv(file, VIDIOC_S_INPUT, &chan->channel); 592 - if (err < 0) 593 - dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %ld\n", err); 594 - switch (chan->norm) { 595 - case VIDEO_MODE_PAL: 596 - sid = V4L2_STD_PAL; 597 - break; 598 - case VIDEO_MODE_NTSC: 599 - sid = V4L2_STD_NTSC; 600 - break; 601 - case VIDEO_MODE_SECAM: 602 - sid = V4L2_STD_SECAM; 603 - break; 604 - case VIDEO_MODE_AUTO: 605 - sid = V4L2_STD_ALL; 606 - break; 607 - } 608 - if (0 != sid) { 609 - err = drv(file, VIDIOC_S_STD, &sid); 610 - if (err < 0) 611 - dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %ld\n", err); 612 - } 613 - return err; 614 - } 615 - 616 - static noinline long v4l1_compat_get_picture( 617 - struct video_picture *pict, 618 - struct file *file, 619 - v4l2_kioctl drv) 620 - { 621 - long err; 622 - struct v4l2_format *fmt; 623 - 624 - fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); 625 - if (!fmt) { 626 - err = -ENOMEM; 627 - return err; 628 - } 629 - 630 - pict->brightness = get_v4l_control(file, 631 - V4L2_CID_BRIGHTNESS, drv); 632 - pict->hue = get_v4l_control(file, 633 - V4L2_CID_HUE, drv); 634 - pict->contrast = get_v4l_control(file, 635 - V4L2_CID_CONTRAST, drv); 636 - pict->colour = get_v4l_control(file, 637 - V4L2_CID_SATURATION, drv); 638 - pict->whiteness = get_v4l_control(file, 639 - V4L2_CID_WHITENESS, drv); 640 - 641 - fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 642 - err = drv(file, VIDIOC_G_FMT, fmt); 643 - if (err < 0) { 644 - dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %ld\n", err); 645 - goto done; 646 - } 647 - 648 - if (fmt->fmt.pix.width) 649 - { 650 - pict->depth = ((fmt->fmt.pix.bytesperline << 3) 651 - + (fmt->fmt.pix.width - 1)) 652 - / fmt->fmt.pix.width; 653 - } else { 654 - err = -EINVAL; 655 - goto done; 656 - } 657 - 658 - pict->palette = pixelformat_to_palette( 659 - fmt->fmt.pix.pixelformat); 660 - done: 661 - kfree(fmt); 662 - return err; 663 - } 664 - 665 - static noinline long v4l1_compat_set_picture( 666 - struct video_picture *pict, 667 - struct file *file, 668 - v4l2_kioctl drv) 669 - { 670 - long err; 671 - struct v4l2_framebuffer fbuf; 672 - int mem_err = 0, ovl_err = 0; 673 - struct v4l2_format *fmt; 674 - 675 - fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); 676 - if (!fmt) { 677 - err = -ENOMEM; 678 - return err; 679 - } 680 - memset(&fbuf, 0, sizeof(fbuf)); 681 - 682 - set_v4l_control(file, 683 - V4L2_CID_BRIGHTNESS, pict->brightness, drv); 684 - set_v4l_control(file, 685 - V4L2_CID_HUE, pict->hue, drv); 686 - set_v4l_control(file, 687 - V4L2_CID_CONTRAST, pict->contrast, drv); 688 - set_v4l_control(file, 689 - V4L2_CID_SATURATION, pict->colour, drv); 690 - set_v4l_control(file, 691 - V4L2_CID_WHITENESS, pict->whiteness, drv); 692 - /* 693 - * V4L1 uses this ioctl to set both memory capture and overlay 694 - * pixel format, while V4L2 has two different ioctls for this. 695 - * Some cards may not support one or the other, and may support 696 - * different pixel formats for memory vs overlay. 697 - */ 698 - 699 - fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 700 - err = drv(file, VIDIOC_G_FMT, fmt); 701 - /* If VIDIOC_G_FMT failed, then the driver likely doesn't 702 - support memory capture. Trying to set the memory capture 703 - parameters would be pointless. */ 704 - if (err < 0) { 705 - dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %ld\n", err); 706 - mem_err = -1000; /* didn't even try */ 707 - } else if (fmt->fmt.pix.pixelformat != 708 - palette_to_pixelformat(pict->palette)) { 709 - fmt->fmt.pix.pixelformat = palette_to_pixelformat( 710 - pict->palette); 711 - mem_err = drv(file, VIDIOC_S_FMT, fmt); 712 - if (mem_err < 0) 713 - dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n", 714 - mem_err); 715 - } 716 - 717 - err = drv(file, VIDIOC_G_FBUF, &fbuf); 718 - /* If VIDIOC_G_FBUF failed, then the driver likely doesn't 719 - support overlay. Trying to set the overlay parameters 720 - would be quite pointless. */ 721 - if (err < 0) { 722 - dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %ld\n", err); 723 - ovl_err = -1000; /* didn't even try */ 724 - } else if (fbuf.fmt.pixelformat != 725 - palette_to_pixelformat(pict->palette)) { 726 - fbuf.fmt.pixelformat = palette_to_pixelformat( 727 - pict->palette); 728 - ovl_err = drv(file, VIDIOC_S_FBUF, &fbuf); 729 - if (ovl_err < 0) 730 - dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n", 731 - ovl_err); 732 - } 733 - if (ovl_err < 0 && mem_err < 0) { 734 - /* ioctl failed, couldn't set either parameter */ 735 - if (mem_err != -1000) 736 - err = mem_err; 737 - else if (ovl_err == -EPERM) 738 - err = 0; 739 - else 740 - err = ovl_err; 741 - } else 742 - err = 0; 743 - kfree(fmt); 744 - return err; 745 - } 746 - 747 - static noinline long v4l1_compat_get_tuner( 748 - struct video_tuner *tun, 749 - struct file *file, 750 - v4l2_kioctl drv) 751 - { 752 - long err; 753 - int i; 754 - struct v4l2_tuner tun2; 755 - struct v4l2_standard std2; 756 - v4l2_std_id sid; 757 - 758 - memset(&tun2, 0, sizeof(tun2)); 759 - err = drv(file, VIDIOC_G_TUNER, &tun2); 760 - if (err < 0) { 761 - dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %ld\n", err); 762 - goto done; 763 - } 764 - memcpy(tun->name, tun2.name, 765 - min(sizeof(tun->name), sizeof(tun2.name))); 766 - tun->name[sizeof(tun->name) - 1] = 0; 767 - tun->rangelow = tun2.rangelow; 768 - tun->rangehigh = tun2.rangehigh; 769 - tun->flags = 0; 770 - tun->mode = VIDEO_MODE_AUTO; 771 - 772 - for (i = 0; i < 64; i++) { 773 - memset(&std2, 0, sizeof(std2)); 774 - std2.index = i; 775 - if (0 != drv(file, VIDIOC_ENUMSTD, &std2)) 776 - break; 777 - if (std2.id & V4L2_STD_PAL) 778 - tun->flags |= VIDEO_TUNER_PAL; 779 - if (std2.id & V4L2_STD_NTSC) 780 - tun->flags |= VIDEO_TUNER_NTSC; 781 - if (std2.id & V4L2_STD_SECAM) 782 - tun->flags |= VIDEO_TUNER_SECAM; 783 - } 784 - 785 - /* Note: G_STD might not be present for radio receivers, 786 - * so we should ignore any errors. */ 787 - if (drv(file, VIDIOC_G_STD, &sid) == 0) { 788 - if (sid & V4L2_STD_PAL) 789 - tun->mode = VIDEO_MODE_PAL; 790 - if (sid & V4L2_STD_NTSC) 791 - tun->mode = VIDEO_MODE_NTSC; 792 - if (sid & V4L2_STD_SECAM) 793 - tun->mode = VIDEO_MODE_SECAM; 794 - } 795 - 796 - if (tun2.capability & V4L2_TUNER_CAP_LOW) 797 - tun->flags |= VIDEO_TUNER_LOW; 798 - if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) 799 - tun->flags |= VIDEO_TUNER_STEREO_ON; 800 - tun->signal = tun2.signal; 801 - done: 802 - return err; 803 - } 804 - 805 - static noinline long v4l1_compat_select_tuner( 806 - struct video_tuner *tun, 807 - struct file *file, 808 - v4l2_kioctl drv) 809 - { 810 - long err; 811 - struct v4l2_tuner t;/*84 bytes on x86_64*/ 812 - memset(&t, 0, sizeof(t)); 813 - 814 - t.index = tun->tuner; 815 - 816 - err = drv(file, VIDIOC_S_TUNER, &t); 817 - if (err < 0) 818 - dprintk("VIDIOCSTUNER / VIDIOC_S_TUNER: %ld\n", err); 819 - return err; 820 - } 821 - 822 - static noinline long v4l1_compat_get_frequency( 823 - unsigned long *freq, 824 - struct file *file, 825 - v4l2_kioctl drv) 826 - { 827 - long err; 828 - struct v4l2_frequency freq2; 829 - memset(&freq2, 0, sizeof(freq2)); 830 - 831 - freq2.tuner = 0; 832 - err = drv(file, VIDIOC_G_FREQUENCY, &freq2); 833 - if (err < 0) 834 - dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %ld\n", err); 835 - if (0 == err) 836 - *freq = freq2.frequency; 837 - return err; 838 - } 839 - 840 - static noinline long v4l1_compat_set_frequency( 841 - unsigned long *freq, 842 - struct file *file, 843 - v4l2_kioctl drv) 844 - { 845 - long err; 846 - struct v4l2_frequency freq2; 847 - memset(&freq2, 0, sizeof(freq2)); 848 - 849 - drv(file, VIDIOC_G_FREQUENCY, &freq2); 850 - freq2.frequency = *freq; 851 - err = drv(file, VIDIOC_S_FREQUENCY, &freq2); 852 - if (err < 0) 853 - dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %ld\n", err); 854 - return err; 855 - } 856 - 857 - static noinline long v4l1_compat_get_audio( 858 - struct video_audio *aud, 859 - struct file *file, 860 - v4l2_kioctl drv) 861 - { 862 - long err; 863 - int i; 864 - struct v4l2_queryctrl qctrl2; 865 - struct v4l2_audio aud2; 866 - struct v4l2_tuner tun2; 867 - memset(&aud2, 0, sizeof(aud2)); 868 - 869 - err = drv(file, VIDIOC_G_AUDIO, &aud2); 870 - if (err < 0) { 871 - dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %ld\n", err); 872 - goto done; 873 - } 874 - memcpy(aud->name, aud2.name, 875 - min(sizeof(aud->name), sizeof(aud2.name))); 876 - aud->name[sizeof(aud->name) - 1] = 0; 877 - aud->audio = aud2.index; 878 - aud->flags = 0; 879 - i = get_v4l_control(file, V4L2_CID_AUDIO_VOLUME, drv); 880 - if (i >= 0) { 881 - aud->volume = i; 882 - aud->flags |= VIDEO_AUDIO_VOLUME; 883 - } 884 - i = get_v4l_control(file, V4L2_CID_AUDIO_BASS, drv); 885 - if (i >= 0) { 886 - aud->bass = i; 887 - aud->flags |= VIDEO_AUDIO_BASS; 888 - } 889 - i = get_v4l_control(file, V4L2_CID_AUDIO_TREBLE, drv); 890 - if (i >= 0) { 891 - aud->treble = i; 892 - aud->flags |= VIDEO_AUDIO_TREBLE; 893 - } 894 - i = get_v4l_control(file, V4L2_CID_AUDIO_BALANCE, drv); 895 - if (i >= 0) { 896 - aud->balance = i; 897 - aud->flags |= VIDEO_AUDIO_BALANCE; 898 - } 899 - i = get_v4l_control(file, V4L2_CID_AUDIO_MUTE, drv); 900 - if (i >= 0) { 901 - if (i) 902 - aud->flags |= VIDEO_AUDIO_MUTE; 903 - aud->flags |= VIDEO_AUDIO_MUTABLE; 904 - } 905 - aud->step = 1; 906 - qctrl2.id = V4L2_CID_AUDIO_VOLUME; 907 - if (drv(file, VIDIOC_QUERYCTRL, &qctrl2) == 0 && 908 - !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) 909 - aud->step = qctrl2.step; 910 - aud->mode = 0; 911 - 912 - memset(&tun2, 0, sizeof(tun2)); 913 - err = drv(file, VIDIOC_G_TUNER, &tun2); 914 - if (err < 0) { 915 - dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %ld\n", err); 916 - err = 0; 917 - goto done; 918 - } 919 - 920 - if (tun2.rxsubchans & V4L2_TUNER_SUB_LANG2) 921 - aud->mode = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; 922 - else if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) 923 - aud->mode = VIDEO_SOUND_STEREO; 924 - else if (tun2.rxsubchans & V4L2_TUNER_SUB_MONO) 925 - aud->mode = VIDEO_SOUND_MONO; 926 - done: 927 - return err; 928 - } 929 - 930 - static noinline long v4l1_compat_set_audio( 931 - struct video_audio *aud, 932 - struct file *file, 933 - v4l2_kioctl drv) 934 - { 935 - long err; 936 - struct v4l2_audio aud2; 937 - struct v4l2_tuner tun2; 938 - 939 - memset(&aud2, 0, sizeof(aud2)); 940 - memset(&tun2, 0, sizeof(tun2)); 941 - 942 - aud2.index = aud->audio; 943 - err = drv(file, VIDIOC_S_AUDIO, &aud2); 944 - if (err < 0) { 945 - dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %ld\n", err); 946 - goto done; 947 - } 948 - 949 - set_v4l_control(file, V4L2_CID_AUDIO_VOLUME, 950 - aud->volume, drv); 951 - set_v4l_control(file, V4L2_CID_AUDIO_BASS, 952 - aud->bass, drv); 953 - set_v4l_control(file, V4L2_CID_AUDIO_TREBLE, 954 - aud->treble, drv); 955 - set_v4l_control(file, V4L2_CID_AUDIO_BALANCE, 956 - aud->balance, drv); 957 - set_v4l_control(file, V4L2_CID_AUDIO_MUTE, 958 - !!(aud->flags & VIDEO_AUDIO_MUTE), drv); 959 - 960 - err = drv(file, VIDIOC_G_TUNER, &tun2); 961 - if (err < 0) 962 - dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %ld\n", err); 963 - if (err == 0) { 964 - switch (aud->mode) { 965 - default: 966 - case VIDEO_SOUND_MONO: 967 - case VIDEO_SOUND_LANG1: 968 - tun2.audmode = V4L2_TUNER_MODE_MONO; 969 - break; 970 - case VIDEO_SOUND_STEREO: 971 - tun2.audmode = V4L2_TUNER_MODE_STEREO; 972 - break; 973 - case VIDEO_SOUND_LANG2: 974 - tun2.audmode = V4L2_TUNER_MODE_LANG2; 975 - break; 976 - } 977 - err = drv(file, VIDIOC_S_TUNER, &tun2); 978 - if (err < 0) 979 - dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %ld\n", err); 980 - } 981 - err = 0; 982 - done: 983 - return err; 984 - } 985 - 986 - static noinline long v4l1_compat_capture_frame( 987 - struct video_mmap *mm, 988 - struct file *file, 989 - v4l2_kioctl drv) 990 - { 991 - long err; 992 - enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; 993 - struct v4l2_buffer buf; 994 - struct v4l2_format *fmt; 995 - 996 - fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); 997 - if (!fmt) { 998 - err = -ENOMEM; 999 - return err; 1000 - } 1001 - memset(&buf, 0, sizeof(buf)); 1002 - 1003 - fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1004 - err = drv(file, VIDIOC_G_FMT, fmt); 1005 - if (err < 0) { 1006 - dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %ld\n", err); 1007 - goto done; 1008 - } 1009 - if (mm->width != fmt->fmt.pix.width || 1010 - mm->height != fmt->fmt.pix.height || 1011 - palette_to_pixelformat(mm->format) != 1012 - fmt->fmt.pix.pixelformat) { 1013 - /* New capture format... */ 1014 - fmt->fmt.pix.width = mm->width; 1015 - fmt->fmt.pix.height = mm->height; 1016 - fmt->fmt.pix.pixelformat = 1017 - palette_to_pixelformat(mm->format); 1018 - fmt->fmt.pix.field = V4L2_FIELD_ANY; 1019 - fmt->fmt.pix.bytesperline = 0; 1020 - err = drv(file, VIDIOC_S_FMT, fmt); 1021 - if (err < 0) { 1022 - dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %ld\n", err); 1023 - goto done; 1024 - } 1025 - } 1026 - buf.index = mm->frame; 1027 - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1028 - err = drv(file, VIDIOC_QUERYBUF, &buf); 1029 - if (err < 0) { 1030 - dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %ld\n", err); 1031 - goto done; 1032 - } 1033 - err = drv(file, VIDIOC_QBUF, &buf); 1034 - if (err < 0) { 1035 - dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %ld\n", err); 1036 - goto done; 1037 - } 1038 - err = drv(file, VIDIOC_STREAMON, &captype); 1039 - if (err < 0) 1040 - dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %ld\n", err); 1041 - done: 1042 - kfree(fmt); 1043 - return err; 1044 - } 1045 - 1046 - static noinline long v4l1_compat_sync( 1047 - int *i, 1048 - struct file *file, 1049 - v4l2_kioctl drv) 1050 - { 1051 - long err; 1052 - enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1053 - struct v4l2_buffer buf; 1054 - struct poll_wqueues *pwq; 1055 - 1056 - memset(&buf, 0, sizeof(buf)); 1057 - buf.index = *i; 1058 - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1059 - err = drv(file, VIDIOC_QUERYBUF, &buf); 1060 - if (err < 0) { 1061 - /* No such buffer */ 1062 - dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %ld\n", err); 1063 - goto done; 1064 - } 1065 - if (!(buf.flags & V4L2_BUF_FLAG_MAPPED)) { 1066 - /* Buffer is not mapped */ 1067 - err = -EINVAL; 1068 - goto done; 1069 - } 1070 - 1071 - /* make sure capture actually runs so we don't block forever */ 1072 - err = drv(file, VIDIOC_STREAMON, &captype); 1073 - if (err < 0) { 1074 - dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %ld\n", err); 1075 - goto done; 1076 - } 1077 - 1078 - pwq = kmalloc(sizeof(*pwq), GFP_KERNEL); 1079 - /* Loop as long as the buffer is queued, but not done */ 1080 - while ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE)) 1081 - == V4L2_BUF_FLAG_QUEUED) { 1082 - err = poll_one(file, pwq); 1083 - if (err < 0 || /* error or sleep was interrupted */ 1084 - err == 0) /* timeout? Shouldn't occur. */ 1085 - break; 1086 - err = drv(file, VIDIOC_QUERYBUF, &buf); 1087 - if (err < 0) 1088 - dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %ld\n", err); 1089 - } 1090 - kfree(pwq); 1091 - if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */ 1092 - goto done; 1093 - do { 1094 - err = drv(file, VIDIOC_DQBUF, &buf); 1095 - if (err < 0) 1096 - dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %ld\n", err); 1097 - } while (err == 0 && buf.index != *i); 1098 - done: 1099 - return err; 1100 - } 1101 - 1102 - static noinline long v4l1_compat_get_vbi_format( 1103 - struct vbi_format *fmt, 1104 - struct file *file, 1105 - v4l2_kioctl drv) 1106 - { 1107 - long err; 1108 - struct v4l2_format *fmt2; 1109 - 1110 - fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); 1111 - if (!fmt2) { 1112 - err = -ENOMEM; 1113 - return err; 1114 - } 1115 - fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; 1116 - 1117 - err = drv(file, VIDIOC_G_FMT, fmt2); 1118 - if (err < 0) { 1119 - dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %ld\n", err); 1120 - goto done; 1121 - } 1122 - if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { 1123 - err = -EINVAL; 1124 - goto done; 1125 - } 1126 - memset(fmt, 0, sizeof(*fmt)); 1127 - fmt->samples_per_line = fmt2->fmt.vbi.samples_per_line; 1128 - fmt->sampling_rate = fmt2->fmt.vbi.sampling_rate; 1129 - fmt->sample_format = VIDEO_PALETTE_RAW; 1130 - fmt->start[0] = fmt2->fmt.vbi.start[0]; 1131 - fmt->count[0] = fmt2->fmt.vbi.count[0]; 1132 - fmt->start[1] = fmt2->fmt.vbi.start[1]; 1133 - fmt->count[1] = fmt2->fmt.vbi.count[1]; 1134 - fmt->flags = fmt2->fmt.vbi.flags & 0x03; 1135 - done: 1136 - kfree(fmt2); 1137 - return err; 1138 - } 1139 - 1140 - static noinline long v4l1_compat_set_vbi_format( 1141 - struct vbi_format *fmt, 1142 - struct file *file, 1143 - v4l2_kioctl drv) 1144 - { 1145 - long err; 1146 - struct v4l2_format *fmt2 = NULL; 1147 - 1148 - if (VIDEO_PALETTE_RAW != fmt->sample_format) { 1149 - err = -EINVAL; 1150 - return err; 1151 - } 1152 - 1153 - fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); 1154 - if (!fmt2) { 1155 - err = -ENOMEM; 1156 - return err; 1157 - } 1158 - fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; 1159 - fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line; 1160 - fmt2->fmt.vbi.sampling_rate = fmt->sampling_rate; 1161 - fmt2->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; 1162 - fmt2->fmt.vbi.start[0] = fmt->start[0]; 1163 - fmt2->fmt.vbi.count[0] = fmt->count[0]; 1164 - fmt2->fmt.vbi.start[1] = fmt->start[1]; 1165 - fmt2->fmt.vbi.count[1] = fmt->count[1]; 1166 - fmt2->fmt.vbi.flags = fmt->flags; 1167 - err = drv(file, VIDIOC_TRY_FMT, fmt2); 1168 - if (err < 0) { 1169 - dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %ld\n", err); 1170 - goto done; 1171 - } 1172 - 1173 - if (fmt2->fmt.vbi.samples_per_line != fmt->samples_per_line || 1174 - fmt2->fmt.vbi.sampling_rate != fmt->sampling_rate || 1175 - fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY || 1176 - fmt2->fmt.vbi.start[0] != fmt->start[0] || 1177 - fmt2->fmt.vbi.count[0] != fmt->count[0] || 1178 - fmt2->fmt.vbi.start[1] != fmt->start[1] || 1179 - fmt2->fmt.vbi.count[1] != fmt->count[1] || 1180 - fmt2->fmt.vbi.flags != fmt->flags) { 1181 - err = -EINVAL; 1182 - goto done; 1183 - } 1184 - err = drv(file, VIDIOC_S_FMT, fmt2); 1185 - if (err < 0) 1186 - dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %ld\n", err); 1187 - done: 1188 - kfree(fmt2); 1189 - return err; 1190 - } 1191 - 1192 - /* 1193 - * This function is exported. 1194 - */ 1195 - long 1196 - v4l_compat_translate_ioctl(struct file *file, 1197 - int cmd, 1198 - void *arg, 1199 - v4l2_kioctl drv) 1200 - { 1201 - long err; 1202 - 1203 - switch (cmd) { 1204 - case VIDIOCGCAP: /* capability */ 1205 - err = v4l1_compat_get_capabilities(arg, file, drv); 1206 - break; 1207 - case VIDIOCGFBUF: /* get frame buffer */ 1208 - err = v4l1_compat_get_frame_buffer(arg, file, drv); 1209 - break; 1210 - case VIDIOCSFBUF: /* set frame buffer */ 1211 - err = v4l1_compat_set_frame_buffer(arg, file, drv); 1212 - break; 1213 - case VIDIOCGWIN: /* get window or capture dimensions */ 1214 - err = v4l1_compat_get_win_cap_dimensions(arg, file, drv); 1215 - break; 1216 - case VIDIOCSWIN: /* set window and/or capture dimensions */ 1217 - err = v4l1_compat_set_win_cap_dimensions(arg, file, drv); 1218 - break; 1219 - case VIDIOCCAPTURE: /* turn on/off preview */ 1220 - err = v4l1_compat_turn_preview_on_off(arg, file, drv); 1221 - break; 1222 - case VIDIOCGCHAN: /* get input information */ 1223 - err = v4l1_compat_get_input_info(arg, file, drv); 1224 - break; 1225 - case VIDIOCSCHAN: /* set input */ 1226 - err = v4l1_compat_set_input(arg, file, drv); 1227 - break; 1228 - case VIDIOCGPICT: /* get tone controls & partial capture format */ 1229 - err = v4l1_compat_get_picture(arg, file, drv); 1230 - break; 1231 - case VIDIOCSPICT: /* set tone controls & partial capture format */ 1232 - err = v4l1_compat_set_picture(arg, file, drv); 1233 - break; 1234 - case VIDIOCGTUNER: /* get tuner information */ 1235 - err = v4l1_compat_get_tuner(arg, file, drv); 1236 - break; 1237 - case VIDIOCSTUNER: /* select a tuner input */ 1238 - err = v4l1_compat_select_tuner(arg, file, drv); 1239 - break; 1240 - case VIDIOCGFREQ: /* get frequency */ 1241 - err = v4l1_compat_get_frequency(arg, file, drv); 1242 - break; 1243 - case VIDIOCSFREQ: /* set frequency */ 1244 - err = v4l1_compat_set_frequency(arg, file, drv); 1245 - break; 1246 - case VIDIOCGAUDIO: /* get audio properties/controls */ 1247 - err = v4l1_compat_get_audio(arg, file, drv); 1248 - break; 1249 - case VIDIOCSAUDIO: /* set audio controls */ 1250 - err = v4l1_compat_set_audio(arg, file, drv); 1251 - break; 1252 - case VIDIOCMCAPTURE: /* capture a frame */ 1253 - err = v4l1_compat_capture_frame(arg, file, drv); 1254 - break; 1255 - case VIDIOCSYNC: /* wait for a frame */ 1256 - err = v4l1_compat_sync(arg, file, drv); 1257 - break; 1258 - case VIDIOCGVBIFMT: /* query VBI data capture format */ 1259 - err = v4l1_compat_get_vbi_format(arg, file, drv); 1260 - break; 1261 - case VIDIOCSVBIFMT: 1262 - err = v4l1_compat_set_vbi_format(arg, file, drv); 1263 - break; 1264 - default: 1265 - err = -ENOIOCTLCMD; 1266 - break; 1267 - } 1268 - 1269 - return err; 1270 - } 1271 - EXPORT_SYMBOL(v4l_compat_translate_ioctl); 1272 - 1273 - /* 1274 - * Local variables: 1275 - * c-basic-offset: 8 1276 - * End: 1277 - */
-325
drivers/media/video/v4l2-compat-ioctl32.c
··· 22 22 23 23 #ifdef CONFIG_COMPAT 24 24 25 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 26 - struct video_tuner32 { 27 - compat_int_t tuner; 28 - char name[32]; 29 - compat_ulong_t rangelow, rangehigh; 30 - u32 flags; /* It is really u32 in videodev.h */ 31 - u16 mode, signal; 32 - }; 33 - 34 - static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) 35 - { 36 - if (!access_ok(VERIFY_READ, up, sizeof(struct video_tuner32)) || 37 - get_user(kp->tuner, &up->tuner) || 38 - copy_from_user(kp->name, up->name, 32) || 39 - get_user(kp->rangelow, &up->rangelow) || 40 - get_user(kp->rangehigh, &up->rangehigh) || 41 - get_user(kp->flags, &up->flags) || 42 - get_user(kp->mode, &up->mode) || 43 - get_user(kp->signal, &up->signal)) 44 - return -EFAULT; 45 - return 0; 46 - } 47 - 48 - static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) 49 - { 50 - if (!access_ok(VERIFY_WRITE, up, sizeof(struct video_tuner32)) || 51 - put_user(kp->tuner, &up->tuner) || 52 - copy_to_user(up->name, kp->name, 32) || 53 - put_user(kp->rangelow, &up->rangelow) || 54 - put_user(kp->rangehigh, &up->rangehigh) || 55 - put_user(kp->flags, &up->flags) || 56 - put_user(kp->mode, &up->mode) || 57 - put_user(kp->signal, &up->signal)) 58 - return -EFAULT; 59 - return 0; 60 - } 61 - 62 - struct video_buffer32 { 63 - compat_caddr_t base; 64 - compat_int_t height, width, depth, bytesperline; 65 - }; 66 - 67 - static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) 68 - { 69 - u32 tmp; 70 - 71 - if (!access_ok(VERIFY_READ, up, sizeof(struct video_buffer32)) || 72 - get_user(tmp, &up->base) || 73 - get_user(kp->height, &up->height) || 74 - get_user(kp->width, &up->width) || 75 - get_user(kp->depth, &up->depth) || 76 - get_user(kp->bytesperline, &up->bytesperline)) 77 - return -EFAULT; 78 - 79 - /* This is actually a physical address stored 80 - * as a void pointer. 81 - */ 82 - kp->base = (void *)(unsigned long) tmp; 83 - 84 - return 0; 85 - } 86 - 87 - static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) 88 - { 89 - u32 tmp = (u32)((unsigned long)kp->base); 90 - 91 - if (!access_ok(VERIFY_WRITE, up, sizeof(struct video_buffer32)) || 92 - put_user(tmp, &up->base) || 93 - put_user(kp->height, &up->height) || 94 - put_user(kp->width, &up->width) || 95 - put_user(kp->depth, &up->depth) || 96 - put_user(kp->bytesperline, &up->bytesperline)) 97 - return -EFAULT; 98 - return 0; 99 - } 100 - 101 - struct video_clip32 { 102 - s32 x, y, width, height; /* It's really s32 in videodev.h */ 103 - compat_caddr_t next; 104 - }; 105 - 106 - struct video_window32 { 107 - u32 x, y, width, height, chromakey, flags; 108 - compat_caddr_t clips; 109 - compat_int_t clipcount; 110 - }; 111 - 112 - static int get_video_window32(struct video_window *kp, struct video_window32 __user *up) 113 - { 114 - struct video_clip __user *uclips; 115 - struct video_clip __user *kclips; 116 - compat_caddr_t p; 117 - int nclips; 118 - 119 - if (!access_ok(VERIFY_READ, up, sizeof(struct video_window32))) 120 - return -EFAULT; 121 - 122 - if (get_user(nclips, &up->clipcount)) 123 - return -EFAULT; 124 - 125 - if (!access_ok(VERIFY_READ, up, sizeof(struct video_window32)) || 126 - get_user(kp->x, &up->x) || 127 - get_user(kp->y, &up->y) || 128 - get_user(kp->width, &up->width) || 129 - get_user(kp->height, &up->height) || 130 - get_user(kp->chromakey, &up->chromakey) || 131 - get_user(kp->flags, &up->flags) || 132 - get_user(kp->clipcount, &up->clipcount)) 133 - return -EFAULT; 134 - 135 - nclips = kp->clipcount; 136 - kp->clips = NULL; 137 - 138 - if (nclips == 0) 139 - return 0; 140 - if (get_user(p, &up->clips)) 141 - return -EFAULT; 142 - uclips = compat_ptr(p); 143 - 144 - /* If nclips < 0, then it is a clipping bitmap of size 145 - VIDEO_CLIPMAP_SIZE */ 146 - if (nclips < 0) { 147 - if (!access_ok(VERIFY_READ, uclips, VIDEO_CLIPMAP_SIZE)) 148 - return -EFAULT; 149 - kp->clips = compat_alloc_user_space(VIDEO_CLIPMAP_SIZE); 150 - if (copy_in_user(kp->clips, uclips, VIDEO_CLIPMAP_SIZE)) 151 - return -EFAULT; 152 - return 0; 153 - } 154 - 155 - /* Otherwise it is an array of video_clip structs. */ 156 - if (!access_ok(VERIFY_READ, uclips, nclips * sizeof(struct video_clip))) 157 - return -EFAULT; 158 - 159 - kp->clips = compat_alloc_user_space(nclips * sizeof(struct video_clip)); 160 - kclips = kp->clips; 161 - while (nclips--) { 162 - int err; 163 - 164 - err = copy_in_user(&kclips->x, &uclips->x, sizeof(kclips->x)); 165 - err |= copy_in_user(&kclips->y, &uclips->y, sizeof(kclips->y)); 166 - err |= copy_in_user(&kclips->width, &uclips->width, sizeof(kclips->width)); 167 - err |= copy_in_user(&kclips->height, &uclips->height, sizeof(kclips->height)); 168 - kclips->next = NULL; 169 - if (err) 170 - return -EFAULT; 171 - kclips++; 172 - uclips++; 173 - } 174 - return 0; 175 - } 176 - 177 - /* You get back everything except the clips... */ 178 - static int put_video_window32(struct video_window *kp, struct video_window32 __user *up) 179 - { 180 - if (!access_ok(VERIFY_WRITE, up, sizeof(struct video_window32)) || 181 - put_user(kp->x, &up->x) || 182 - put_user(kp->y, &up->y) || 183 - put_user(kp->width, &up->width) || 184 - put_user(kp->height, &up->height) || 185 - put_user(kp->chromakey, &up->chromakey) || 186 - put_user(kp->flags, &up->flags) || 187 - put_user(kp->clipcount, &up->clipcount)) 188 - return -EFAULT; 189 - return 0; 190 - } 191 - 192 - struct video_code32 { 193 - char loadwhat[16]; /* name or tag of file being passed */ 194 - compat_int_t datasize; 195 - compat_uptr_t data; 196 - }; 197 - 198 - static struct video_code __user *get_microcode32(struct video_code32 *kp) 199 - { 200 - struct video_code __user *up; 201 - 202 - up = compat_alloc_user_space(sizeof(*up)); 203 - 204 - /* 205 - * NOTE! We don't actually care if these fail. If the 206 - * user address is invalid, the native ioctl will do 207 - * the error handling for us 208 - */ 209 - (void) copy_to_user(up->loadwhat, kp->loadwhat, sizeof(up->loadwhat)); 210 - (void) put_user(kp->datasize, &up->datasize); 211 - (void) put_user(compat_ptr(kp->data), &up->data); 212 - return up; 213 - } 214 - 215 - #define VIDIOCGTUNER32 _IOWR('v', 4, struct video_tuner32) 216 - #define VIDIOCSTUNER32 _IOW('v', 5, struct video_tuner32) 217 - #define VIDIOCGWIN32 _IOR('v', 9, struct video_window32) 218 - #define VIDIOCSWIN32 _IOW('v', 10, struct video_window32) 219 - #define VIDIOCGFBUF32 _IOR('v', 11, struct video_buffer32) 220 - #define VIDIOCSFBUF32 _IOW('v', 12, struct video_buffer32) 221 - #define VIDIOCGFREQ32 _IOR('v', 14, u32) 222 - #define VIDIOCSFREQ32 _IOW('v', 15, u32) 223 - #define VIDIOCSMICROCODE32 _IOW('v', 27, struct video_code32) 224 - 225 - #define VIDIOCCAPTURE32 _IOW('v', 8, s32) 226 - #define VIDIOCSYNC32 _IOW('v', 18, s32) 227 - #define VIDIOCSWRITEMODE32 _IOW('v', 25, s32) 228 - 229 - #endif 230 - 231 25 static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 232 26 { 233 27 long ret = -ENOIOCTLCMD; ··· 535 741 static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 536 742 { 537 743 union { 538 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 539 - struct video_tuner vt; 540 - struct video_buffer vb; 541 - struct video_window vw; 542 - struct video_code32 vc; 543 - struct video_audio va; 544 - #endif 545 744 struct v4l2_format v2f; 546 745 struct v4l2_buffer v2b; 547 746 struct v4l2_framebuffer v2fb; ··· 550 763 551 764 /* First, convert the command. */ 552 765 switch (cmd) { 553 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 554 - case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break; 555 - case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break; 556 - case VIDIOCGWIN32: cmd = VIDIOCGWIN; break; 557 - case VIDIOCSWIN32: cmd = VIDIOCSWIN; break; 558 - case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break; 559 - case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break; 560 - case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break; 561 - case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break; 562 - case VIDIOCSMICROCODE32: cmd = VIDIOCSMICROCODE; break; 563 - #endif 564 766 case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break; 565 767 case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break; 566 768 case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break; ··· 576 800 } 577 801 578 802 switch (cmd) { 579 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 580 - case VIDIOCSTUNER: 581 - case VIDIOCGTUNER: 582 - err = get_video_tuner32(&karg.vt, up); 583 - compatible_arg = 0; 584 - break; 585 - 586 - case VIDIOCSFBUF: 587 - err = get_video_buffer32(&karg.vb, up); 588 - compatible_arg = 0; 589 - break; 590 - 591 - case VIDIOCSWIN: 592 - err = get_video_window32(&karg.vw, up); 593 - compatible_arg = 0; 594 - break; 595 - 596 - case VIDIOCGWIN: 597 - case VIDIOCGFBUF: 598 - case VIDIOCGFREQ: 599 - compatible_arg = 0; 600 - break; 601 - 602 - case VIDIOCSMICROCODE: 603 - /* Copy the 32-bit "video_code32" to kernel space */ 604 - if (copy_from_user(&karg.vc, up, sizeof(karg.vc))) 605 - return -EFAULT; 606 - /* Convert the 32-bit version to a 64-bit version in user space */ 607 - up = get_microcode32(&karg.vc); 608 - break; 609 - 610 - case VIDIOCSFREQ: 611 - err = get_user(karg.vx, (u32 __user *)up); 612 - compatible_arg = 0; 613 - break; 614 - 615 - case VIDIOCCAPTURE: 616 - case VIDIOCSYNC: 617 - case VIDIOCSWRITEMODE: 618 - #endif 619 803 case VIDIOC_OVERLAY: 620 804 case VIDIOC_STREAMON: 621 805 case VIDIOC_STREAMOFF: ··· 658 922 return err; 659 923 660 924 switch (cmd) { 661 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 662 - case VIDIOCGTUNER: 663 - err = put_video_tuner32(&karg.vt, up); 664 - break; 665 - 666 - case VIDIOCGWIN: 667 - err = put_video_window32(&karg.vw, up); 668 - break; 669 - 670 - case VIDIOCGFBUF: 671 - err = put_video_buffer32(&karg.vb, up); 672 - break; 673 - 674 - case VIDIOCGFREQ: 675 - err = put_user(((u32)karg.vx), (u32 __user *)up); 676 - break; 677 - #endif 678 925 case VIDIOC_S_INPUT: 679 926 case VIDIOC_S_OUTPUT: 680 927 case VIDIOC_G_INPUT: ··· 700 981 return ret; 701 982 702 983 switch (cmd) { 703 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 704 - case VIDIOCGCAP: 705 - case VIDIOCGCHAN: 706 - case VIDIOCSCHAN: 707 - case VIDIOCGTUNER32: 708 - case VIDIOCSTUNER32: 709 - case VIDIOCGPICT: 710 - case VIDIOCSPICT: 711 - case VIDIOCCAPTURE32: 712 - case VIDIOCGWIN32: 713 - case VIDIOCSWIN32: 714 - case VIDIOCGFBUF32: 715 - case VIDIOCSFBUF32: 716 - case VIDIOCKEY: 717 - case VIDIOCGFREQ32: 718 - case VIDIOCSFREQ32: 719 - case VIDIOCGAUDIO: 720 - case VIDIOCSAUDIO: 721 - case VIDIOCSYNC32: 722 - case VIDIOCMCAPTURE: 723 - case VIDIOCGMBUF: 724 - case VIDIOCGUNIT: 725 - case VIDIOCGCAPTURE: 726 - case VIDIOCSCAPTURE: 727 - case VIDIOCSPLAYMODE: 728 - case VIDIOCSWRITEMODE32: 729 - case VIDIOCGPLAYINFO: 730 - case VIDIOCSMICROCODE32: 731 - case VIDIOCGVBIFMT: 732 - case VIDIOCSVBIFMT: 733 - #endif 734 984 #ifdef __OLD_VIDIOC_ 735 985 case VIDIOC_OVERLAY32_OLD: 736 986 case VIDIOC_S_PARM_OLD: ··· 784 1096 ret = do_video_ioctl(file, cmd, arg); 785 1097 break; 786 1098 787 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 788 - /* BTTV specific... */ 789 - case _IOW('v', BASE_VIDIOCPRIVATE+0, char [256]): 790 - case _IOR('v', BASE_VIDIOCPRIVATE+1, char [256]): 791 - case _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int): 792 - case _IOW('v' , BASE_VIDIOCPRIVATE+3, char [16]): /* struct bttv_pll_info */ 793 - case _IOR('v' , BASE_VIDIOCPRIVATE+4, int): 794 - case _IOR('v' , BASE_VIDIOCPRIVATE+5, int): 795 - case _IOR('v' , BASE_VIDIOCPRIVATE+6, int): 796 - case _IOR('v' , BASE_VIDIOCPRIVATE+7, int): 797 - ret = native_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); 798 - break; 799 - #endif 800 1099 default: 801 1100 printk(KERN_WARNING "compat_ioctl32: " 802 1101 "unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",
-86
drivers/media/video/v4l2-ioctl.c
··· 18 18 #include <linux/kernel.h> 19 19 20 20 #define __OLD_VIDIOC_ /* To allow fixing old calls */ 21 - #include <linux/videodev.h> 22 21 #include <linux/videodev2.h> 23 22 24 - #ifdef CONFIG_VIDEO_V4L1 25 - #include <linux/videodev.h> 26 - #endif 27 23 #include <media/v4l2-common.h> 28 24 #include <media/v4l2-ioctl.h> 29 25 #include <media/v4l2-ctrls.h> ··· 179 183 180 184 /* ------------------------------------------------------------------ */ 181 185 /* debug help functions */ 182 - 183 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 184 - static const char *v4l1_ioctls[] = { 185 - [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP", 186 - [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN", 187 - [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN", 188 - [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER", 189 - [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER", 190 - [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT", 191 - [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT", 192 - [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE", 193 - [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN", 194 - [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN", 195 - [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF", 196 - [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF", 197 - [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY", 198 - [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ", 199 - [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ", 200 - [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO", 201 - [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO", 202 - [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC", 203 - [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE", 204 - [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF", 205 - [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT", 206 - [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE", 207 - [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE", 208 - [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE", 209 - [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE", 210 - [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO", 211 - [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE", 212 - [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT", 213 - [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT" 214 - }; 215 - #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) 216 - #endif 217 - 218 186 static const char *v4l2_ioctls[] = { 219 187 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP", 220 188 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED", ··· 270 310 case 'd': 271 311 type = "v4l2_int"; 272 312 break; 273 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 274 - case 'v': 275 - if (_IOC_NR(cmd) >= V4L1_IOCTLS) { 276 - type = "v4l1"; 277 - break; 278 - } 279 - printk("%s", v4l1_ioctls[_IOC_NR(cmd)]); 280 - return; 281 - #endif 282 313 case 'V': 283 314 if (_IOC_NR(cmd) >= V4L2_IOCTLS) { 284 315 type = "v4l2"; ··· 573 622 return -EINVAL; 574 623 } 575 624 576 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 577 - /******************************************************** 578 - All other V4L1 calls are handled by v4l1_compat module. 579 - Those calls will be translated into V4L2 calls, and 580 - __video_do_ioctl will be called again, with one or more 581 - V4L2 ioctls. 582 - ********************************************************/ 583 - if (_IOC_TYPE(cmd) == 'v' && cmd != VIDIOCGMBUF && 584 - _IOC_NR(cmd) < BASE_VIDIOCPRIVATE) { 585 - return v4l_compat_translate_ioctl(file, cmd, arg, 586 - __video_do_ioctl); 587 - } 588 - #endif 589 - 590 625 if ((vfd->debug & V4L2_DEBUG_IOCTL) && 591 626 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { 592 627 v4l_print_ioctl(vfd->name, cmd); ··· 580 643 } 581 644 582 645 switch (cmd) { 583 - 584 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 585 - /*********************************************************** 586 - Handles calls to the obsoleted V4L1 API 587 - Due to the nature of VIDIOCGMBUF, each driver that supports 588 - V4L1 should implement its own handler for this ioctl. 589 - ***********************************************************/ 590 - 591 - /* --- streaming capture ------------------------------------- */ 592 - case VIDIOCGMBUF: 593 - { 594 - struct video_mbuf *p = arg; 595 - 596 - if (!ops->vidiocgmbuf) 597 - break; 598 - ret = ops->vidiocgmbuf(file, fh, p); 599 - if (!ret) 600 - dbgarg(cmd, "size=%d, frames=%d, offsets=0x%08lx\n", 601 - p->size, p->frames, 602 - (unsigned long)p->offsets); 603 - break; 604 - } 605 - #endif 606 646 607 647 /* --- capabilities ------------------------------------------ */ 608 648 case VIDIOC_QUERYCAP:
-13
drivers/media/video/via-camera.c
··· 1161 1161 return ret; 1162 1162 } 1163 1163 1164 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1165 - static int viacam_vidiocgmbuf(struct file *filp, void *priv, 1166 - struct video_mbuf *mbuf) 1167 - { 1168 - struct via_camera *cam = priv; 1169 - 1170 - return videobuf_cgmbuf(&cam->vb_queue, mbuf, 6); 1171 - } 1172 - #endif 1173 - 1174 1164 /* G/S_PARM */ 1175 1165 1176 1166 static int viacam_g_parm(struct file *filp, void *priv, ··· 1241 1251 .vidioc_s_parm = viacam_s_parm, 1242 1252 .vidioc_enum_framesizes = viacam_enum_framesizes, 1243 1253 .vidioc_enum_frameintervals = viacam_enum_frameintervals, 1244 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1245 - .vidiocgmbuf = viacam_vidiocgmbuf, 1246 - #endif 1247 1254 }; 1248 1255 1249 1256 /*----------------------------------------------------------------------------*/
-30
drivers/media/video/videobuf-core.c
··· 1202 1202 return rc; 1203 1203 } 1204 1204 EXPORT_SYMBOL_GPL(videobuf_mmap_mapper); 1205 - 1206 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1207 - int videobuf_cgmbuf(struct videobuf_queue *q, 1208 - struct video_mbuf *mbuf, int count) 1209 - { 1210 - struct v4l2_requestbuffers req; 1211 - int rc, i; 1212 - 1213 - MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 1214 - 1215 - memset(&req, 0, sizeof(req)); 1216 - req.type = q->type; 1217 - req.count = count; 1218 - req.memory = V4L2_MEMORY_MMAP; 1219 - rc = videobuf_reqbufs(q, &req); 1220 - if (rc < 0) 1221 - return rc; 1222 - 1223 - mbuf->frames = req.count; 1224 - mbuf->size = 0; 1225 - for (i = 0; i < mbuf->frames; i++) { 1226 - mbuf->offsets[i] = q->bufs[i]->boff; 1227 - mbuf->size += PAGE_ALIGN(q->bufs[i]->bsize); 1228 - } 1229 - 1230 - return 0; 1231 - } 1232 - EXPORT_SYMBOL_GPL(videobuf_cgmbuf); 1233 - #endif 1234 -
-23
drivers/media/video/videobuf-dma-sg.c
··· 570 570 } 571 571 572 572 last = first; 573 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 574 - if (size != (vma->vm_end - vma->vm_start)) { 575 - /* look for last buffer to map */ 576 - for (last = first + 1; last < VIDEO_MAX_FRAME; last++) { 577 - if (NULL == q->bufs[last]) 578 - continue; 579 - if (V4L2_MEMORY_MMAP != q->bufs[last]->memory) 580 - continue; 581 - if (q->bufs[last]->map) { 582 - retval = -EBUSY; 583 - goto done; 584 - } 585 - size += PAGE_ALIGN(q->bufs[last]->bsize); 586 - if (size == (vma->vm_end - vma->vm_start)) 587 - break; 588 - } 589 - if (VIDEO_MAX_FRAME == last) { 590 - dprintk(1, "mmap app bug: size invalid [size=0x%lx]\n", 591 - (vma->vm_end - vma->vm_start)); 592 - goto done; 593 - } 594 - } 595 - #endif 596 573 597 574 /* create mapping + update buffer list */ 598 575 retval = -ENOMEM;
-12
drivers/media/video/vivi.c
··· 870 870 file->f_flags & O_NONBLOCK); 871 871 } 872 872 873 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 874 - static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 875 - { 876 - struct vivi_dev *dev = video_drvdata(file); 877 - 878 - return videobuf_cgmbuf(&dev->vb_vidq, mbuf, 8); 879 - } 880 - #endif 881 - 882 873 static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 883 874 { 884 875 struct vivi_dev *dev = video_drvdata(file); ··· 1096 1105 .vidioc_queryctrl = vidioc_queryctrl, 1097 1106 .vidioc_g_ctrl = vidioc_g_ctrl, 1098 1107 .vidioc_s_ctrl = vidioc_s_ctrl, 1099 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1100 - .vidiocgmbuf = vidiocgmbuf, 1101 - #endif 1102 1108 }; 1103 1109 1104 1110 static struct video_device vivi_template = {
-31
drivers/staging/cx25821/cx25821-video.c
··· 1188 1188 return 0; 1189 1189 } 1190 1190 1191 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1192 - int cx25821_vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 1193 - { 1194 - struct cx25821_fh *fh = priv; 1195 - struct videobuf_queue *q; 1196 - struct v4l2_requestbuffers req; 1197 - unsigned int i; 1198 - int err; 1199 - 1200 - q = get_queue(fh); 1201 - memset(&req, 0, sizeof(req)); 1202 - req.type = q->type; 1203 - req.count = 8; 1204 - req.memory = V4L2_MEMORY_MMAP; 1205 - err = videobuf_reqbufs(q, &req); 1206 - if (err < 0) 1207 - return err; 1208 - 1209 - mbuf->frames = req.count; 1210 - mbuf->size = 0; 1211 - for (i = 0; i < mbuf->frames; i++) { 1212 - mbuf->offsets[i] = q->bufs[i]->boff; 1213 - mbuf->size += q->bufs[i]->bsize; 1214 - } 1215 - return 0; 1216 - } 1217 - #endif 1218 - 1219 1191 int cx25821_vidioc_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) 1220 1192 { 1221 1193 struct cx25821_fh *fh = priv; ··· 1988 2016 .vidioc_log_status = vidioc_log_status, 1989 2017 .vidioc_g_priority = cx25821_vidioc_g_priority, 1990 2018 .vidioc_s_priority = cx25821_vidioc_s_priority, 1991 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1992 - .vidiocgmbuf = cx25821_vidiocgmbuf, 1993 - #endif 1994 2019 #ifdef TUNER_FLAG 1995 2020 .vidioc_g_tuner = cx25821_vidioc_g_tuner, 1996 2021 .vidioc_s_tuner = cx25821_vidioc_s_tuner,
-6
drivers/staging/cx25821/cx25821-video.h
··· 40 40 #include <media/v4l2-common.h> 41 41 #include <media/v4l2-ioctl.h> 42 42 43 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 44 - /* Include V4L1 specific functions. Should be removed soon */ 45 - #include <linux/videodev.h> 46 - #endif 47 - 48 43 #define TUNER_FLAG 49 44 50 45 #define VIDEO_DEBUG 0 ··· 129 134 struct v4l2_capability *cap); 130 135 extern int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv, 131 136 struct v4l2_fmtdesc *f); 132 - extern int cx25821_vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf); 133 137 extern int cx25821_vidioc_reqbufs(struct file *file, void *priv, 134 138 struct v4l2_requestbuffers *p); 135 139 extern int cx25821_vidioc_querybuf(struct file *file, void *priv,
-3
drivers/staging/dt3155v4l/dt3155v4l.c
··· 876 876 .vidioc_s_crop = dt3155_ioc_s_crop, 877 877 .vidioc_enum_framesizes = dt3155_ioc_enum_framesizes, 878 878 .vidioc_enum_frameintervals = dt3155_ioc_enum_frameintervals, 879 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 880 - .vidiocgmbuf = iocgmbuf, 881 - #endif 882 879 */ 883 880 }; 884 881
-12
drivers/staging/tm6000/tm6000-video.c
··· 986 986 file->f_flags & O_NONBLOCK); 987 987 } 988 988 989 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 990 - static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 991 - { 992 - struct tm6000_fh *fh = priv; 993 - 994 - return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8); 995 - } 996 - #endif 997 - 998 989 static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 999 990 { 1000 991 struct tm6000_fh *fh = priv; ··· 1429 1438 .vidioc_querybuf = vidioc_querybuf, 1430 1439 .vidioc_qbuf = vidioc_qbuf, 1431 1440 .vidioc_dqbuf = vidioc_dqbuf, 1432 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 1433 - .vidiocgmbuf = vidiocgmbuf, 1434 - #endif 1435 1441 }; 1436 1442 1437 1443 static struct video_device tm6000_template = {
+2 -20
include/linux/videodev.h
··· 16 16 #include <linux/ioctl.h> 17 17 #include <linux/videodev2.h> 18 18 19 - #if defined(__MIN_V4L1) && defined (__KERNEL__) 20 - 21 - /* 22 - * Used by those V4L2 core functions that need a minimum V4L1 support, 23 - * in order to allow V4L1 Compatibilty code compilation. 24 - */ 25 - 26 - struct video_mbuf 27 - { 28 - int size; /* Total memory to map */ 29 - int frames; /* Frames */ 30 - int offsets[VIDEO_MAX_FRAME]; 31 - }; 32 - 33 - #define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */ 34 - 35 - #else 36 - #if defined(CONFIG_VIDEO_V4L1_COMPAT) || !defined (__KERNEL__) 19 + #if defined(CONFIG_VIDEO_V4L1) || defined(CONFIG_VIDEO_V4L1_MODULE) || !defined(__KERNEL__) 37 20 38 21 #define VID_TYPE_CAPTURE 1 /* Can capture */ 39 22 #define VID_TYPE_TUNER 2 /* Can tune */ ··· 311 328 #define VID_PLAY_RESET 13 312 329 #define VID_PLAY_END_MARK 14 313 330 314 - #endif /* CONFIG_VIDEO_V4L1_COMPAT */ 315 - #endif /* __MIN_V4L1 */ 331 + #endif /* CONFIG_VIDEO_V4L1 */ 316 332 317 333 #endif /* __LINUX_VIDEODEV_H */ 318 334
+3 -19
include/media/v4l2-ioctl.h
··· 14 14 #include <linux/device.h> 15 15 #include <linux/mutex.h> 16 16 #include <linux/compiler.h> /* need __user */ 17 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 18 - #define __MIN_V4L1 19 - #include <linux/videodev.h> 20 - #else 21 17 #include <linux/videodev2.h> 22 - #endif 23 18 24 19 struct v4l2_fh; 25 20 ··· 108 113 109 114 110 115 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); 111 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 112 - /* buffer type is struct vidio_mbuf * */ 113 - int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p); 114 - #endif 115 116 int (*vidioc_g_fbuf) (struct file *file, void *fh, 116 117 struct v4l2_framebuffer *a); 117 118 int (*vidioc_s_fbuf) (struct file *file, void *fh, ··· 291 300 extern const char *v4l2_field_names[]; 292 301 extern const char *v4l2_type_names[]; 293 302 294 - /* Compatibility layer interface -- v4l1-compat module */ 295 - typedef long (*v4l2_kioctl)(struct file *file, 296 - unsigned int cmd, void *arg); 297 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 298 - long v4l_compat_translate_ioctl(struct file *file, 299 - int cmd, void *arg, v4l2_kioctl driver_ioctl); 300 - #else 301 - #define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL) 302 - #endif 303 - 304 303 #ifdef CONFIG_COMPAT 305 304 /* 32 Bits compatibility layer for 64 bits processors */ 306 305 extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, 307 306 unsigned long arg); 308 307 #endif 308 + 309 + typedef long (*v4l2_kioctl)(struct file *file, 310 + unsigned int cmd, void *arg); 309 311 310 312 /* Include support for obsoleted stuff */ 311 313 extern long video_usercopy(struct file *file, unsigned int cmd,
-8
include/media/videobuf-core.h
··· 17 17 #define _VIDEOBUF_CORE_H 18 18 19 19 #include <linux/poll.h> 20 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 21 - #define __MIN_V4L1 22 - #include <linux/videodev.h> 23 - #endif 24 20 #include <linux/videodev2.h> 25 21 26 22 #define UNSET (-1U) ··· 208 212 struct v4l2_buffer *b); 209 213 int videobuf_dqbuf(struct videobuf_queue *q, 210 214 struct v4l2_buffer *b, int nonblocking); 211 - #ifdef CONFIG_VIDEO_V4L1_COMPAT 212 - int videobuf_cgmbuf(struct videobuf_queue *q, 213 - struct video_mbuf *mbuf, int count); 214 - #endif 215 215 int videobuf_streamon(struct videobuf_queue *q); 216 216 int videobuf_streamoff(struct videobuf_queue *q); 217 217