[PATCH] USB: ZC0301 driver updates
"Cosmetic" driver updates for the ZC0301 driver: - Fix stream_interrupt() (and work around a possible kernel bug); - Fix vidioc_enum_input() and split vidioc_gs_input() in two parts; - Use wait_event_interruptible_timeout() instead of wait_event_interruptible() when waiting for video frames; - replace erroneous wake_up_interruptible(&wait_stream) with wake_up(&wait_stream); - Cosmetic cleanups in the documentation. Signed-off-by: Luca Risolia <luca.risolia@studio.unibo.it> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
addf36fec0
commit
9e47a52bf3
4 changed files with 37 additions and 29 deletions
|
@ -67,8 +67,7 @@ Some of the features of the driver are:
|
||||||
- available mmap or read/poll methods for video streaming through isochronous
|
- available mmap or read/poll methods for video streaming through isochronous
|
||||||
data transfers;
|
data transfers;
|
||||||
- automatic detection of image sensor;
|
- automatic detection of image sensor;
|
||||||
- video formats is standard JPEG in various compression qualities
|
- video format is standard JPEG;
|
||||||
(see also "Notes for V4L2 application developers" paragraph);
|
|
||||||
- full support for the capabilities of every possible image sensors that can
|
- full support for the capabilities of every possible image sensors that can
|
||||||
be connected to the ZC0301 bridges, including, for istance, red, green,
|
be connected to the ZC0301 bridges, including, for istance, red, green,
|
||||||
blue and global gain adjustments and exposure control (see "Supported
|
blue and global gain adjustments and exposure control (see "Supported
|
||||||
|
@ -226,10 +225,6 @@ The same number of buffers as before will be allocated again to match the size
|
||||||
of the new video frames, so you have to map the buffers again before any I/O
|
of the new video frames, so you have to map the buffers again before any I/O
|
||||||
attempts on them.
|
attempts on them.
|
||||||
|
|
||||||
This driver supports the standard JPEG video format. The current compression
|
|
||||||
quality may vary from 0 to 3 and can be selected or queried thanks to the
|
|
||||||
VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2 ioctl's.
|
|
||||||
|
|
||||||
|
|
||||||
10. Contact information
|
10. Contact information
|
||||||
=======================
|
=======================
|
||||||
|
@ -242,9 +237,9 @@ the fingerprint is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'.
|
||||||
|
|
||||||
11. Credits
|
11. Credits
|
||||||
===========
|
===========
|
||||||
- Informations about the chip internals to enable the I2C protocol have been
|
- Informations about the chip internals needed to enable the I2C protocol have
|
||||||
taken from the documentation of the ZC030x Video4Linux1 driver written by
|
been taken from the documentation of the ZC030x Video4Linux1 driver written
|
||||||
Andrew Birkett <andy@nobugs.org>;
|
by Andrew Birkett <andy@nobugs.org>;
|
||||||
- Initialization values of the ZC0301 connected to the PAS202BCB image sensor
|
- Initialization values of the ZC0301 controller connected to the PAS202BCB
|
||||||
have been taken from the SPCA5XX driver maintained by
|
image sensor have been taken from the SPCA5XX driver maintained by
|
||||||
Michel Xhaard <mxhaard@magic.fr>
|
Michel Xhaard <mxhaard@magic.fr>.
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#define ZC0301_MAX_DEVICES 64
|
#define ZC0301_MAX_DEVICES 64
|
||||||
#define ZC0301_FORCE_MUNMAP 0
|
#define ZC0301_FORCE_MUNMAP 0
|
||||||
#define ZC0301_MAX_FRAMES 32
|
#define ZC0301_MAX_FRAMES 32
|
||||||
#define ZC0301_COMPRESSION_QUALITY 2
|
#define ZC0301_COMPRESSION_QUALITY 0
|
||||||
#define ZC0301_URBS 2
|
#define ZC0301_URBS 2
|
||||||
#define ZC0301_ISO_PACKETS 7
|
#define ZC0301_ISO_PACKETS 7
|
||||||
#define ZC0301_ALTERNATE_SETTING 7
|
#define ZC0301_ALTERNATE_SETTING 7
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
* *
|
* *
|
||||||
* Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
|
* Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
|
||||||
* *
|
* *
|
||||||
* Informations about the chip internals to enable the I2C protocol have *
|
* Informations about the chip internals needed to enable the I2C protocol *
|
||||||
* been taken from the documentation of the ZC030x Video4Linux1 driver *
|
* have been taken from the documentation of the ZC030x Video4Linux1 *
|
||||||
* written by Andrew Birkett <andy@nobugs.org> *
|
* driver written by Andrew Birkett <andy@nobugs.org> *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
@ -54,8 +54,8 @@
|
||||||
#define ZC0301_MODULE_AUTHOR "(C) 2006 Luca Risolia"
|
#define ZC0301_MODULE_AUTHOR "(C) 2006 Luca Risolia"
|
||||||
#define ZC0301_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
|
#define ZC0301_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
|
||||||
#define ZC0301_MODULE_LICENSE "GPL"
|
#define ZC0301_MODULE_LICENSE "GPL"
|
||||||
#define ZC0301_MODULE_VERSION "1:1.00"
|
#define ZC0301_MODULE_VERSION "1:1.01"
|
||||||
#define ZC0301_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 0)
|
#define ZC0301_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 1)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ static void zc0301_urb_complete(struct urb *urb, struct pt_regs* regs)
|
||||||
if ((*f))
|
if ((*f))
|
||||||
(*f)->state = F_QUEUED;
|
(*f)->state = F_QUEUED;
|
||||||
DBG(3, "Stream interrupted");
|
DBG(3, "Stream interrupted");
|
||||||
wake_up_interruptible(&cam->wait_stream);
|
wake_up(&cam->wait_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cam->state & DEV_DISCONNECTED)
|
if (cam->state & DEV_DISCONNECTED)
|
||||||
|
@ -526,7 +526,7 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
|
||||||
ZC0301_URB_TIMEOUT);
|
ZC0301_URB_TIMEOUT);
|
||||||
if (cam->state & DEV_DISCONNECTED)
|
if (cam->state & DEV_DISCONNECTED)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
else if (!timeout) {
|
else if (cam->stream != STREAM_OFF) {
|
||||||
cam->state |= DEV_MISCONFIGURED;
|
cam->state |= DEV_MISCONFIGURED;
|
||||||
DBG(1, "URB timeout reached. The camera is misconfigured. To "
|
DBG(1, "URB timeout reached. The camera is misconfigured. To "
|
||||||
"use it, close and open /dev/video%d again.",
|
"use it, close and open /dev/video%d again.",
|
||||||
|
@ -547,8 +547,7 @@ zc0301_set_compression(struct zc0301_device* cam,
|
||||||
|
|
||||||
if ((r = zc0301_read_reg(cam, 0x0008)) < 0)
|
if ((r = zc0301_read_reg(cam, 0x0008)) < 0)
|
||||||
err += r;
|
err += r;
|
||||||
err += zc0301_write_reg(cam, 0x0008,
|
err += zc0301_write_reg(cam, 0x0008, r | 0x11 | compression->quality);
|
||||||
r | 0x11 | (compression->quality >> 1));
|
|
||||||
|
|
||||||
return err ? -EIO : 0;
|
return err ? -EIO : 0;
|
||||||
}
|
}
|
||||||
|
@ -737,8 +736,7 @@ static int zc0301_release(struct inode* inode, struct file* filp)
|
||||||
|
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
zc0301_read(struct file* filp, char __user * buf,
|
zc0301_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
|
||||||
size_t count, loff_t* f_pos)
|
|
||||||
{
|
{
|
||||||
struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
|
struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
|
||||||
struct zc0301_frame_t* f, * i;
|
struct zc0301_frame_t* f, * i;
|
||||||
|
@ -1019,6 +1017,7 @@ zc0301_vidioc_enuminput(struct zc0301_device* cam, void __user * arg)
|
||||||
|
|
||||||
memset(&i, 0, sizeof(i));
|
memset(&i, 0, sizeof(i));
|
||||||
strcpy(i.name, "Camera");
|
strcpy(i.name, "Camera");
|
||||||
|
i.type = V4L2_INPUT_TYPE_CAMERA;
|
||||||
|
|
||||||
if (copy_to_user(arg, &i, sizeof(i)))
|
if (copy_to_user(arg, &i, sizeof(i)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
@ -1028,7 +1027,19 @@ zc0301_vidioc_enuminput(struct zc0301_device* cam, void __user * arg)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
zc0301_vidioc_gs_input(struct zc0301_device* cam, void __user * arg)
|
zc0301_vidioc_g_input(struct zc0301_device* cam, void __user * arg)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
if (copy_to_user(arg, &index, sizeof(index)))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
zc0301_vidioc_s_input(struct zc0301_device* cam, void __user * arg)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
@ -1446,7 +1457,7 @@ zc0301_vidioc_s_jpegcomp(struct zc0301_device* cam, void __user * arg)
|
||||||
if (copy_from_user(&jc, arg, sizeof(jc)))
|
if (copy_from_user(&jc, arg, sizeof(jc)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (jc.quality < 0 || jc.quality > 3)
|
if (jc.quality != 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (cam->stream == STREAM_ON)
|
if (cam->stream == STREAM_ON)
|
||||||
|
@ -1738,8 +1749,10 @@ static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp,
|
||||||
return zc0301_vidioc_enuminput(cam, arg);
|
return zc0301_vidioc_enuminput(cam, arg);
|
||||||
|
|
||||||
case VIDIOC_G_INPUT:
|
case VIDIOC_G_INPUT:
|
||||||
|
return zc0301_vidioc_g_input(cam, arg);
|
||||||
|
|
||||||
case VIDIOC_S_INPUT:
|
case VIDIOC_S_INPUT:
|
||||||
return zc0301_vidioc_gs_input(cam, arg);
|
return zc0301_vidioc_s_input(cam, arg);
|
||||||
|
|
||||||
case VIDIOC_QUERYCTRL:
|
case VIDIOC_QUERYCTRL:
|
||||||
return zc0301_vidioc_query_ctrl(cam, arg);
|
return zc0301_vidioc_query_ctrl(cam, arg);
|
||||||
|
@ -1980,7 +1993,7 @@ static void zc0301_usb_disconnect(struct usb_interface* intf)
|
||||||
zc0301_stop_transfer(cam);
|
zc0301_stop_transfer(cam);
|
||||||
cam->state |= DEV_DISCONNECTED;
|
cam->state |= DEV_DISCONNECTED;
|
||||||
wake_up_interruptible(&cam->wait_frame);
|
wake_up_interruptible(&cam->wait_frame);
|
||||||
wake_up_interruptible(&cam->wait_stream);
|
wake_up(&cam->wait_stream);
|
||||||
} else {
|
} else {
|
||||||
cam->state |= DEV_DISCONNECTED;
|
cam->state |= DEV_DISCONNECTED;
|
||||||
zc0301_release_resources(cam);
|
zc0301_release_resources(cam);
|
||||||
|
|
|
@ -318,7 +318,7 @@ static struct zc0301_sensor pas202bcb = {
|
||||||
.width = 640,
|
.width = 640,
|
||||||
.height = 480,
|
.height = 480,
|
||||||
.pixelformat = V4L2_PIX_FMT_JPEG,
|
.pixelformat = V4L2_PIX_FMT_JPEG,
|
||||||
.priv = 16,
|
.priv = 8,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue