SN9C10x bugfix and small updates. Changes: @ Allocate the correct number of buffer memory bytes for read() * Wakeup interruptible events on DEV_MISCONFIGURED status * Allocate the exact number of buffers (nreadbuffers) in poll() * Documentation updates
Signed-off-by: Luca Risolia <[EMAIL PROTECTED]>
---
diff -uprN -X dontdiff a/Documentation/usb/sn9c102.txt
b/Documentation/usb/sn9c102.txt
--- a/Documentation/usb/sn9c102.txt 2005-01-19 02:32:37.000000000 +0100
+++ b/Documentation/usb/sn9c102.txt 2005-01-19 02:38:57.000000000 +0100
@@ -210,8 +210,8 @@ There are other four entries in the dire
SN9C10x bridge, while the other two control the sensor chip. "reg" and
"i2c_reg" hold the values of the current register index where the following
reading/writing operations are addressed at through "val" and "i2c_val". Their
-use is not intended for end-users. Note that "i2c_reg" and "i2c_val" won't be
-created if the sensor does not actually support the standard I2C protocol or
+use is not intended for end-users. Note that "i2c_reg" and "i2c_val" will not
+be created if the sensor does not actually support the standard I2C protocol or
its registers are not 8-bit long. Also, remember that you must be logged in as
root before writing to them.
@@ -341,15 +341,8 @@ TAS5130D1B Taiwan Advanced Sensor Corpo
All the available control settings of each image sensor are supported through
the V4L2 interface.
-If you think your camera is based on the above hardware and is not actually
-listed in the above table, you may try to add the specific USB VendorID and
-ProductID identifiers to the sn9c102_id_table[] in the file "sn9c102_sensor.h";
-then compile, load the module again and look at the kernel output.
-If this works, please send an email to the author reporting the kernel
-messages, so that a new entry in the list of supported devices can be added.
-
Donations of new models for further testing and support would be much
-appreciated. Non-available hardware won't be supported by the author of this
+appreciated. Non-available hardware will not be supported by the author of this
driver.
diff -uprN -X dontdiff a/drivers/usb/media/sn9c102_core.c
b/drivers/usb/media/sn9c102_core.c
--- a/drivers/usb/media/sn9c102_core.c 2005-01-19 02:32:44.000000000 +0100
+++ b/drivers/usb/media/sn9c102_core.c 2005-01-19 02:56:36.000000000 +0100
@@ -164,8 +164,8 @@ sn9c102_request_buffers(struct sn9c102_d
struct v4l2_rect* r = &(cam->sensor->cropcap.bounds);
const size_t imagesize = cam->module_param.force_munmap ||
io == IO_READ ?
- (p->width * p->height * p->priv)/8 :
- (r->width * r->height * p->priv)/8;
+ (p->width * p->height * p->priv) / 8 :
+ (r->width * r->height * p->priv) / 8;
void* buff = NULL;
u32 i;
@@ -516,8 +516,13 @@ static void sn9c102_urb_complete(struct
wake_up_interruptible(&cam->wait_stream);
}
- if ((cam->state & DEV_DISCONNECTED)||(cam->state & DEV_MISCONFIGURED))
+ if (cam->state & DEV_DISCONNECTED)
+ return;
+
+ if (cam->state & DEV_MISCONFIGURED) {
+ wake_up_interruptible(&cam->wait_frame);
return;
+ }
if (cam->stream == STREAM_OFF || list_empty(&cam->inqueue))
goto resubmit_urb;
@@ -1558,7 +1563,8 @@ sn9c102_read(struct file* filp, char __u
err = wait_event_interruptible
( cam->wait_frame,
(!list_empty(&cam->outqueue)) ||
- (cam->state & DEV_DISCONNECTED) );
+ (cam->state & DEV_DISCONNECTED) ||
+ (cam->state & DEV_MISCONFIGURED) );
if (err) {
up(&cam->fileop_sem);
return err;
@@ -1567,6 +1573,10 @@ sn9c102_read(struct file* filp, char __u
up(&cam->fileop_sem);
return -ENODEV;
}
+ if (cam->state & DEV_MISCONFIGURED) {
+ up(&cam->fileop_sem);
+ return -EIO;
+ }
}
f = list_entry(cam->outqueue.prev, struct sn9c102_frame_t, frame);
@@ -1615,7 +1625,8 @@ static unsigned int sn9c102_poll(struct
}
if (cam->io == IO_NONE) {
- if (!sn9c102_request_buffers(cam, 2, IO_READ)) {
+ if (!sn9c102_request_buffers(cam, cam->nreadbuffers,
+ IO_READ)) {
DBG(1, "poll() failed, not enough memory")
goto error;
}
@@ -1729,7 +1740,7 @@ static int sn9c102_mmap(struct file* fil
}
-static int sn9c102_v4l2_ioctl(struct inode* inode, struct file* filp,
+static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
unsigned int cmd, void __user * arg)
{
struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
@@ -1970,7 +1981,7 @@ static int sn9c102_v4l2_ioctl(struct ino
return -EFAULT;
}
- if (cam->module_param.force_munmap)
+ if (cam->module_param.force_munmap || cam->io == IO_READ)
sn9c102_release_buffers(cam);
err = sn9c102_set_crop(cam, rect);
@@ -1990,7 +2001,7 @@ static int sn9c102_v4l2_ioctl(struct ino
s->pix_format.height = rect->height/scale;
memcpy(&(s->_rect), rect, sizeof(*rect));
- if (cam->module_param.force_munmap &&
+ if ((cam->module_param.force_munmap || cam->io == IO_READ) &&
nbuffers != sn9c102_request_buffers(cam, nbuffers,
cam->io)) {
cam->state |= DEV_MISCONFIGURED;
@@ -2146,7 +2157,7 @@ static int sn9c102_v4l2_ioctl(struct ino
return -EFAULT;
}
- if (cam->module_param.force_munmap)
+ if (cam->module_param.force_munmap || cam->io == IO_READ)
sn9c102_release_buffers(cam);
err += sn9c102_set_pix_format(cam, pix);
@@ -2168,7 +2179,7 @@ static int sn9c102_v4l2_ioctl(struct ino
memcpy(pfmt, pix, sizeof(*pix));
memcpy(&(s->_rect), &rect, sizeof(rect));
- if (cam->module_param.force_munmap &&
+ if ((cam->module_param.force_munmap || cam->io == IO_READ) &&
nbuffers != sn9c102_request_buffers(cam, nbuffers,
cam->io)) {
cam->state |= DEV_MISCONFIGURED;
@@ -2346,11 +2357,14 @@ static int sn9c102_v4l2_ioctl(struct ino
err = wait_event_interruptible
( cam->wait_frame,
(!list_empty(&cam->outqueue)) ||
- (cam->state & DEV_DISCONNECTED) );
+ (cam->state & DEV_DISCONNECTED) ||
+ (cam->state & DEV_MISCONFIGURED) );
if (err)
return err;
if (cam->state & DEV_DISCONNECTED)
return -ENODEV;
+ if (cam->state & DEV_MISCONFIGURED)
+ return -EIO;
}
spin_lock_irqsave(&cam->queue_lock, lock_flags);
@@ -2495,7 +2509,7 @@ static int sn9c102_ioctl(struct inode* i
return -EIO;
}
- err = sn9c102_v4l2_ioctl(inode, filp, cmd, (void __user *)arg);
+ err = sn9c102_ioctl_v4l2(inode, filp, cmd, (void __user *)arg);
up(&cam->fileop_sem);
diff -uprN -X dontdiff a/drivers/usb/media/sn9c102.h
b/drivers/usb/media/sn9c102.h
--- a/drivers/usb/media/sn9c102.h 2005-01-19 02:32:44.000000000 +0100
+++ b/drivers/usb/media/sn9c102.h 2005-01-19 02:56:18.000000000 +0100
@@ -53,11 +53,11 @@
/*****************************************************************************/
#define SN9C102_MODULE_NAME "V4L2 driver for SN9C10x PC Camera Controllers"
-#define SN9C102_MODULE_AUTHOR "(C) 2004 Luca Risolia"
+#define SN9C102_MODULE_AUTHOR "(C) 2004-2005 Luca Risolia"
#define SN9C102_AUTHOR_EMAIL "<[EMAIL PROTECTED]>"
#define SN9C102_MODULE_LICENSE "GPL"
-#define SN9C102_MODULE_VERSION "1:1.22"
-#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 22)
+#define SN9C102_MODULE_VERSION "1:1.23"
+#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 23)
enum sn9c102_bridge {
BRIDGE_SN9C101 = 0x01,
pgpDUj66jarHH.pgp
Description: PGP signature
