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

V4L/DVB (5063): ZC0301 driver updates.

- Implement audio ioctl's and VIDIOC_ENUM_FRAMESIZES
- Documentation updates
- Generic improvements

Signed-off-by: Luca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by

Luca Risolia and committed by
Mauro Carvalho Chehab
7e3a0660 f327ebbd

+64 -25
+5 -5
Documentation/video4linux/zc0301.txt
··· 23 23 24 24 1. Copyright 25 25 ============ 26 - Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> 26 + Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> 27 27 28 28 29 29 2. Disclaimer ··· 125 125 6. Module loading 126 126 ================= 127 127 To use the driver, it is necessary to load the "zc0301" module into memory 128 - after every other module required: "videodev", "usbcore" and, depending on 129 - the USB host controller you have, "ehci-hcd", "uhci-hcd" or "ohci-hcd". 128 + after every other module required: "videodev", "v4l2_common", "compat_ioctl32", 129 + "usbcore" and, depending on the USB host controller you have, "ehci-hcd", 130 + "uhci-hcd" or "ohci-hcd". 130 131 131 132 Loading can be done as shown below: 132 133 ··· 212 211 0x041e 0x4036 213 212 0x041e 0x403a 214 213 0x0458 0x7007 215 - 0x0458 0x700C 214 + 0x0458 0x700c 216 215 0x0458 0x700f 217 216 0x046d 0x08ae 218 217 0x055f 0xd003 219 218 0x055f 0xd004 220 - 0x046d 0x08ae 221 219 0x0ac8 0x0301 222 220 0x0ac8 0x301b 223 221 0x0ac8 0x303b
+2 -2
drivers/media/video/zc0301/zc0301.h
··· 1 1 /*************************************************************************** 2 - * V4L2 driver for ZC0301 Image Processor and Control Chip * 2 + * V4L2 driver for ZC0301[P] Image Processor and Control Chip * 3 3 * * 4 - * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> * 4 + * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 5 * * 6 6 * This program is free software; you can redistribute it and/or modify * 7 7 * it under the terms of the GNU General Public License as published by *
+47 -8
drivers/media/video/zc0301/zc0301_core.c
··· 1 1 /*************************************************************************** 2 2 * Video4Linux2 driver for ZC0301[P] Image Processor and Control Chip * 3 3 * * 4 - * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> * 4 + * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 5 * * 6 6 * Informations about the chip internals needed to enable the I2C protocol * 7 7 * have been taken from the documentation of the ZC030x Video4Linux1 * ··· 52 52 #define ZC0301_MODULE_AUTHOR "(C) 2006 Luca Risolia" 53 53 #define ZC0301_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 54 54 #define ZC0301_MODULE_LICENSE "GPL" 55 - #define ZC0301_MODULE_VERSION "1:1.05" 56 - #define ZC0301_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 5) 55 + #define ZC0301_MODULE_VERSION "1:1.07" 56 + #define ZC0301_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 7) 57 57 58 58 /*****************************************************************************/ 59 59 ··· 89 89 "\ndetected camera." 90 90 "\n 0 = do not force memory unmapping" 91 91 "\n 1 = force memory unmapping (save memory)" 92 - "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." 92 + "\nDefault value is "__MODULE_STRING(ZC0301_FORCE_MUNMAP)"." 93 93 "\n"); 94 94 95 95 static unsigned int frame_timeout[] = {[0 ... ZC0301_MAX_DEVICES-1] = ··· 136 136 137 137 cam->nbuffers = count; 138 138 while (cam->nbuffers > 0) { 139 - if ((buff = vmalloc_32(cam->nbuffers * PAGE_ALIGN(imagesize)))) 139 + if ((buff = vmalloc_32_user(cam->nbuffers * 140 + PAGE_ALIGN(imagesize)))) 140 141 break; 141 142 cam->nbuffers--; 142 143 } ··· 431 430 struct usb_host_interface* altsetting = usb_altnum_to_altsetting( 432 431 usb_ifnum_to_if(udev, 0), 433 432 ZC0301_ALTERNATE_SETTING); 434 - const unsigned int psz = altsetting->endpoint[0].desc.wMaxPacketSize; 433 + const unsigned int psz = le16_to_cpu(altsetting-> 434 + endpoint[0].desc.wMaxPacketSize); 435 435 struct urb* urb; 436 436 s8 i, j; 437 437 int err = 0; ··· 491 489 return 0; 492 490 493 491 free_urbs: 494 - for (i = 0; i < ZC0301_URBS; i++) 492 + for (i = 0; (i < ZC0301_URBS) && cam->urb[i]; i++) 495 493 usb_free_urb(cam->urb[i]); 496 494 497 495 free_buffers: ··· 1290 1288 1291 1289 1292 1290 static int 1291 + zc0301_vidioc_enum_framesizes(struct zc0301_device* cam, void __user * arg) 1292 + { 1293 + struct v4l2_frmsizeenum frmsize; 1294 + 1295 + if (copy_from_user(&frmsize, arg, sizeof(frmsize))) 1296 + return -EFAULT; 1297 + 1298 + if (frmsize.index != 0 && frmsize.index != 1) 1299 + return -EINVAL; 1300 + 1301 + if (frmsize.pixel_format != V4L2_PIX_FMT_JPEG) 1302 + return -EINVAL; 1303 + 1304 + frmsize.type = V4L2_FRMSIZE_TYPE_DISCRETE; 1305 + 1306 + if (frmsize.index == 1) { 1307 + frmsize.discrete.width = cam->sensor.cropcap.defrect.width; 1308 + frmsize.discrete.height = cam->sensor.cropcap.defrect.height; 1309 + } 1310 + memset(&frmsize.reserved, 0, sizeof(frmsize.reserved)); 1311 + 1312 + if (copy_to_user(arg, &frmsize, sizeof(frmsize))) 1313 + return -EFAULT; 1314 + 1315 + return 0; 1316 + } 1317 + 1318 + 1319 + static int 1293 1320 zc0301_vidioc_enum_fmt(struct zc0301_device* cam, void __user * arg) 1294 1321 { 1295 1322 struct v4l2_fmtdesc fmtd; 1296 1323 1297 1324 if (copy_from_user(&fmtd, arg, sizeof(fmtd))) 1298 1325 return -EFAULT; 1326 + 1327 + if (fmtd.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1328 + return -EINVAL; 1299 1329 1300 1330 if (fmtd.index == 0) { 1301 1331 strcpy(fmtd.description, "JPEG"); ··· 1829 1795 case VIDIOC_S_FMT: 1830 1796 return zc0301_vidioc_try_s_fmt(cam, cmd, arg); 1831 1797 1798 + case VIDIOC_ENUM_FRAMESIZES: 1799 + return zc0301_vidioc_enum_framesizes(cam, arg); 1800 + 1832 1801 case VIDIOC_G_JPEGCOMP: 1833 1802 return zc0301_vidioc_g_jpegcomp(cam, arg); 1834 1803 ··· 1867 1830 case VIDIOC_QUERYSTD: 1868 1831 case VIDIOC_ENUMSTD: 1869 1832 case VIDIOC_QUERYMENU: 1833 + case VIDIOC_ENUM_FRAMEINTERVALS: 1870 1834 return -EINVAL; 1871 1835 1872 1836 default: ··· 1914 1876 .open = zc0301_open, 1915 1877 .release = zc0301_release, 1916 1878 .ioctl = zc0301_ioctl, 1879 + .compat_ioctl = v4l_compat_ioctl32, 1917 1880 .read = zc0301_read, 1918 1881 .poll = zc0301_poll, 1919 1882 .mmap = zc0301_mmap, ··· 1952 1913 mutex_init(&cam->dev_mutex); 1953 1914 1954 1915 DBG(2, "ZC0301[P] Image Processor and Control Chip detected " 1955 - "(vid/pid 0x%04X/0x%04X)",id->idVendor, id->idProduct); 1916 + "(vid/pid 0x%04X:0x%04X)",id->idVendor, id->idProduct); 1956 1917 1957 1918 for (i = 0; zc0301_sensor_table[i]; i++) { 1958 1919 err = zc0301_sensor_table[i](cam);
+2 -2
drivers/media/video/zc0301/zc0301_pas202bcb.c
··· 1 1 /*************************************************************************** 2 - * Plug-in for PAS202BCB image sensor connected to the ZC0301[P] Image * 2 + * Plug-in for PAS202BCB image sensor connected to the ZC0301 Image * 3 3 * Processor and Control Chip * 4 4 * * 5 - * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 + * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> * 6 6 * * 7 7 * Initialization values of the ZC0301[P] have been taken from the SPCA5XX * 8 8 * driver maintained by Michel Xhaard <mxhaard@magic.fr> *
+2 -2
drivers/media/video/zc0301/zc0301_pb0330.c
··· 1 1 /*************************************************************************** 2 - * Plug-in for PB-0330 image sensor connected to the ZC0301[P] Image * 2 + * Plug-in for PB-0330 image sensor connected to the ZC0301P Image * 3 3 * Processor and Control Chip * 4 4 * * 5 - * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 + * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> * 6 6 * * 7 7 * Initialization values of the ZC0301[P] have been taken from the SPCA5XX * 8 8 * driver maintained by Michel Xhaard <mxhaard@magic.fr> *
+6 -6
drivers/media/video/zc0301/zc0301_sensor.h
··· 1 1 /*************************************************************************** 2 - * API for image sensors connected to the ZC0301 Image Processor and * 2 + * API for image sensors connected to the ZC0301[P] Image Processor and * 3 3 * Control Chip * 4 4 * * 5 - * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 + * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> * 6 6 * * 7 7 * This program is free software; you can redistribute it and/or modify * 8 8 * it under the terms of the GNU General Public License as published by * ··· 70 70 { ZC0301_USB_DEVICE(0x041e, 0x4036, 0xff), }, /* HV7131 */ \ 71 71 { ZC0301_USB_DEVICE(0x041e, 0x403a, 0xff), }, /* HV7131 */ \ 72 72 { ZC0301_USB_DEVICE(0x0458, 0x7007, 0xff), }, /* TAS5130 */ \ 73 - { ZC0301_USB_DEVICE(0x0458, 0x700C, 0xff), }, /* TAS5130 */ \ 73 + { ZC0301_USB_DEVICE(0x0458, 0x700c, 0xff), }, /* TAS5130 */ \ 74 74 { ZC0301_USB_DEVICE(0x0458, 0x700f, 0xff), }, /* TAS5130 */ \ 75 75 { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \ 76 76 { ZC0301_USB_DEVICE(0x055f, 0xd003, 0xff), }, /* TAS5130 */ \ ··· 93 93 94 94 /*****************************************************************************/ 95 95 96 - #define ZC0301_MAX_CTRLS V4L2_CID_LASTP1-V4L2_CID_BASE+10 97 - #define ZC0301_V4L2_CID_DAC_MAGNITUDE V4L2_CID_PRIVATE_BASE 98 - #define ZC0301_V4L2_CID_GREEN_BALANCE V4L2_CID_PRIVATE_BASE + 1 96 + #define ZC0301_MAX_CTRLS (V4L2_CID_LASTP1 - V4L2_CID_BASE + 10) 97 + #define ZC0301_V4L2_CID_DAC_MAGNITUDE (V4L2_CID_PRIVATE_BASE + 0) 98 + #define ZC0301_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE + 1) 99 99 100 100 struct zc0301_sensor { 101 101 char name[32];