Commit 7e3a0660700ad47ee6e296fe7090d771becfcf96
Committed by
Mauro Carvalho Chehab
1 parent
f327ebbd00
Exists in
master
and in
7 other branches
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>
Showing 6 changed files with 64 additions and 25 deletions Side-by-side Diff
Documentation/video4linux/zc0301.txt
... | ... | @@ -23,7 +23,7 @@ |
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,8 +125,9 @@ |
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 | |
133 | 134 | |
... | ... | @@ -211,12 +212,11 @@ |
211 | 212 | 0x041e 0x4036 |
212 | 213 | 0x041e 0x403a |
213 | 214 | 0x0458 0x7007 |
214 | -0x0458 0x700C | |
215 | +0x0458 0x700c | |
215 | 216 | 0x0458 0x700f |
216 | 217 | 0x046d 0x08ae |
217 | 218 | 0x055f 0xd003 |
218 | 219 | 0x055f 0xd004 |
219 | -0x046d 0x08ae | |
220 | 220 | 0x0ac8 0x0301 |
221 | 221 | 0x0ac8 0x301b |
222 | 222 | 0x0ac8 0x303b |
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 * |
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,8 +52,8 @@ |
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,7 +89,7 @@ |
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,7 +136,8 @@ |
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 | } |
... | ... | @@ -430,7 +431,8 @@ |
430 | 431 | struct usb_host_interface* altsetting = usb_altnum_to_altsetting( |
431 | 432 | usb_ifnum_to_if(udev, 0), |
432 | 433 | ZC0301_ALTERNATE_SETTING); |
433 | - const unsigned int psz = altsetting->endpoint[0].desc.wMaxPacketSize; | |
434 | + const unsigned int psz = le16_to_cpu(altsetting-> | |
435 | + endpoint[0].desc.wMaxPacketSize); | |
434 | 436 | struct urb* urb; |
435 | 437 | s8 i, j; |
436 | 438 | int err = 0; |
... | ... | @@ -489,7 +491,7 @@ |
489 | 491 | return 0; |
490 | 492 | |
491 | 493 | free_urbs: |
492 | - for (i = 0; i < ZC0301_URBS; i++) | |
494 | + for (i = 0; (i < ZC0301_URBS) && cam->urb[i]; i++) | |
493 | 495 | usb_free_urb(cam->urb[i]); |
494 | 496 | |
495 | 497 | free_buffers: |
... | ... | @@ -1288,6 +1290,35 @@ |
1288 | 1290 | |
1289 | 1291 | |
1290 | 1292 | static int |
1293 | +zc0301_vidioc_enum_framesizes(struct zc0301_device* cam, void __user * arg) | |
1294 | +{ | |
1295 | + struct v4l2_frmsizeenum frmsize; | |
1296 | + | |
1297 | + if (copy_from_user(&frmsize, arg, sizeof(frmsize))) | |
1298 | + return -EFAULT; | |
1299 | + | |
1300 | + if (frmsize.index != 0 && frmsize.index != 1) | |
1301 | + return -EINVAL; | |
1302 | + | |
1303 | + if (frmsize.pixel_format != V4L2_PIX_FMT_JPEG) | |
1304 | + return -EINVAL; | |
1305 | + | |
1306 | + frmsize.type = V4L2_FRMSIZE_TYPE_DISCRETE; | |
1307 | + | |
1308 | + if (frmsize.index == 1) { | |
1309 | + frmsize.discrete.width = cam->sensor.cropcap.defrect.width; | |
1310 | + frmsize.discrete.height = cam->sensor.cropcap.defrect.height; | |
1311 | + } | |
1312 | + memset(&frmsize.reserved, 0, sizeof(frmsize.reserved)); | |
1313 | + | |
1314 | + if (copy_to_user(arg, &frmsize, sizeof(frmsize))) | |
1315 | + return -EFAULT; | |
1316 | + | |
1317 | + return 0; | |
1318 | +} | |
1319 | + | |
1320 | + | |
1321 | +static int | |
1291 | 1322 | zc0301_vidioc_enum_fmt(struct zc0301_device* cam, void __user * arg) |
1292 | 1323 | { |
1293 | 1324 | struct v4l2_fmtdesc fmtd; |
... | ... | @@ -1295,6 +1326,9 @@ |
1295 | 1326 | if (copy_from_user(&fmtd, arg, sizeof(fmtd))) |
1296 | 1327 | return -EFAULT; |
1297 | 1328 | |
1329 | + if (fmtd.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | |
1330 | + return -EINVAL; | |
1331 | + | |
1298 | 1332 | if (fmtd.index == 0) { |
1299 | 1333 | strcpy(fmtd.description, "JPEG"); |
1300 | 1334 | fmtd.pixelformat = V4L2_PIX_FMT_JPEG; |
... | ... | @@ -1795,6 +1829,9 @@ |
1795 | 1829 | case VIDIOC_S_FMT: |
1796 | 1830 | return zc0301_vidioc_try_s_fmt(cam, cmd, arg); |
1797 | 1831 | |
1832 | + case VIDIOC_ENUM_FRAMESIZES: | |
1833 | + return zc0301_vidioc_enum_framesizes(cam, arg); | |
1834 | + | |
1798 | 1835 | case VIDIOC_G_JPEGCOMP: |
1799 | 1836 | return zc0301_vidioc_g_jpegcomp(cam, arg); |
1800 | 1837 | |
... | ... | @@ -1830,6 +1867,7 @@ |
1830 | 1867 | case VIDIOC_QUERYSTD: |
1831 | 1868 | case VIDIOC_ENUMSTD: |
1832 | 1869 | case VIDIOC_QUERYMENU: |
1870 | + case VIDIOC_ENUM_FRAMEINTERVALS: | |
1833 | 1871 | return -EINVAL; |
1834 | 1872 | |
1835 | 1873 | default: |
... | ... | @@ -1876,6 +1914,7 @@ |
1876 | 1914 | .open = zc0301_open, |
1877 | 1915 | .release = zc0301_release, |
1878 | 1916 | .ioctl = zc0301_ioctl, |
1917 | + .compat_ioctl = v4l_compat_ioctl32, | |
1879 | 1918 | .read = zc0301_read, |
1880 | 1919 | .poll = zc0301_poll, |
1881 | 1920 | .mmap = zc0301_mmap, |
... | ... | @@ -1913,7 +1952,7 @@ |
1913 | 1952 | mutex_init(&cam->dev_mutex); |
1914 | 1953 | |
1915 | 1954 | DBG(2, "ZC0301[P] Image Processor and Control Chip detected " |
1916 | - "(vid/pid 0x%04X/0x%04X)",id->idVendor, id->idProduct); | |
1955 | + "(vid/pid 0x%04X:0x%04X)",id->idVendor, id->idProduct); | |
1917 | 1956 | |
1918 | 1957 | for (i = 0; zc0301_sensor_table[i]; i++) { |
1919 | 1958 | err = zc0301_sensor_table[i](cam); |
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> * |
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> * |
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,7 +70,7 @@ |
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,9 +93,9 @@ |
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]; |