git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
drivers
/
media
/
video
/
c-qcam.c
diff --git
a/drivers/media/video/c-qcam.c
b/drivers/media/video/c-qcam.c
index
9976db4
..
a3989bd
100644
(file)
--- a/
drivers/media/video/c-qcam.c
+++ b/
drivers/media/video/c-qcam.c
@@
-16,7
+16,7
@@
*
* The parport parameter controls which parports will be scanned.
* Scanning all parports causes some printers to print a garbage page.
*
* The parport parameter controls which parports will be scanned.
* Scanning all parports causes some printers to print a garbage page.
- * -- March 14, 1999 Billy Donahue <billy@escape.com>
+ * -- March 14, 1999 Billy Donahue <billy@escape.com>
*
* Fixed data format to BGR, added force_rgb parameter. Added missing
* parport_unregister_driver() on module removal.
*
* Fixed data format to BGR, added force_rgb parameter. Added missing
* parport_unregister_driver() on module removal.
@@
-34,7
+34,9
@@
#include <linux/parport.h>
#include <linux/sched.h>
#include <linux/videodev.h>
#include <linux/parport.h>
#include <linux/sched.h>
#include <linux/videodev.h>
-#include <asm/semaphore.h>
+#include <media/v4l2-common.h>
+#include <linux/mutex.h>
+
#include <asm/uaccess.h>
struct qcam_device {
#include <asm/uaccess.h>
struct qcam_device {
@@
-47,7
+49,7
@@
struct qcam_device {
int contrast, brightness, whitebal;
int top, left;
unsigned int bidirectional;
int contrast, brightness, whitebal;
int top, left;
unsigned int bidirectional;
- struct
semaphore
lock;
+ struct
mutex
lock;
};
/* cameras maximum */
};
/* cameras maximum */
@@
-87,7
+89,7
@@
static inline unsigned int qcam_ready2(struct qcam_device *qcam)
return (parport_read_data(qcam->pport) & 0x1)?1:0;
}
return (parport_read_data(qcam->pport) & 0x1)?1:0;
}
-static unsigned int qcam_await_ready1(struct qcam_device *qcam,
+static unsigned int qcam_await_ready1(struct qcam_device *qcam,
int value)
{
unsigned long oldjiffies = jiffies;
int value)
{
unsigned long oldjiffies = jiffies;
@@
-97,7
+99,7
@@
static unsigned int qcam_await_ready1(struct qcam_device *qcam,
if (qcam_ready1(qcam) == value)
return 0;
if (qcam_ready1(qcam) == value)
return 0;
- /* If the camera didn't respond within 1/25 second, poll slowly
+ /* If the camera didn't respond within 1/25 second, poll slowly
for a while. */
for (i = 0; i < 50; i++)
{
for a while. */
for (i = 0; i < 50; i++)
{
@@
-122,7
+124,7
@@
static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value)
if (qcam_ready2(qcam) == value)
return 0;
if (qcam_ready2(qcam) == value)
return 0;
- /* If the camera didn't respond within 1/25 second, poll slowly
+ /* If the camera didn't respond within 1/25 second, poll slowly
for a while. */
for (i = 0; i < 50; i++)
{
for a while. */
for (i = 0; i < 50; i++)
{
@@
-156,12
+158,12
@@
static int qcam_write_data(struct qcam_device *qcam, unsigned int data)
unsigned int idata;
parport_write_data(qcam->pport, data);
idata = qcam_read_data(qcam);
unsigned int idata;
parport_write_data(qcam->pport, data);
idata = qcam_read_data(qcam);
- if (data != idata)
+ if (data != idata)
{
{
- printk(KERN_WARNING "cqcam: sent %x but received %x\n", data,
+ printk(KERN_WARNING "cqcam: sent %x but received %x\n", data,
idata);
return 1;
idata);
return 1;
- }
+ }
return 0;
}
return 0;
}
@@
-192,12
+194,12
@@
static int qc_detect(struct qcam_device *qcam)
no device was found". Fix this one day. */
if (qcam->pport->probe_info[0].class == PARPORT_CLASS_MEDIA
&& qcam->pport->probe_info[0].model
no device was found". Fix this one day. */
if (qcam->pport->probe_info[0].class == PARPORT_CLASS_MEDIA
&& qcam->pport->probe_info[0].model
- && !strcmp(qcam->pdev->port->probe_info[0].model,
+ && !strcmp(qcam->pdev->port->probe_info[0].model,
"Color QuickCam 2.0")) {
printk(KERN_DEBUG "QuickCam: Found by IEEE1284 probe.\n");
return 1;
}
"Color QuickCam 2.0")) {
printk(KERN_DEBUG "QuickCam: Found by IEEE1284 probe.\n");
return 1;
}
-
+
if (probe < 2)
return 0;
if (probe < 2)
return 0;
@@
-205,11
+207,11
@@
static int qc_detect(struct qcam_device *qcam)
/* look for a heartbeat */
ostat = stat = parport_read_status(qcam->pport);
/* look for a heartbeat */
ostat = stat = parport_read_status(qcam->pport);
- for (i=0; i<250; i++)
+ for (i=0; i<250; i++)
{
mdelay(1);
stat = parport_read_status(qcam->pport);
{
mdelay(1);
stat = parport_read_status(qcam->pport);
- if (ostat != stat)
+ if (ostat != stat)
{
if (++count >= 3) return 1;
ostat = stat;
{
if (++count >= 3) return 1;
ostat = stat;
@@
-225,11
+227,11
@@
static int qc_detect(struct qcam_device *qcam)
count = 0;
ostat = stat = parport_read_status(qcam->pport);
count = 0;
ostat = stat = parport_read_status(qcam->pport);
- for (i=0; i<250; i++)
+ for (i=0; i<250; i++)
{
mdelay(1);
stat = parport_read_status(qcam->pport);
{
mdelay(1);
stat = parport_read_status(qcam->pport);
- if (ostat != stat)
+ if (ostat != stat)
{
if (++count >= 3) return 1;
ostat = stat;
{
if (++count >= 3) return 1;
ostat = stat;
@@
-246,7
+248,7
@@
static void qc_reset(struct qcam_device *qcam)
parport_write_control(qcam->pport, 0x8);
mdelay(1);
parport_write_control(qcam->pport, 0xc);
parport_write_control(qcam->pport, 0x8);
mdelay(1);
parport_write_control(qcam->pport, 0xc);
- mdelay(1);
+ mdelay(1);
}
/* Reset the QuickCam and program for brightness, contrast,
}
/* Reset the QuickCam and program for brightness, contrast,
@@
-257,7
+259,7
@@
static void qc_setup(struct qcam_device *q)
qc_reset(q);
/* Set the brightness. */
qc_reset(q);
/* Set the brightness. */
-
qcam_set(q, 11, q->brightness);
+ qcam_set(q, 11, q->brightness);
/* Set the height and width. These refer to the actual
CCD area *before* applying the selected decimation. */
/* Set the height and width. These refer to the actual
CCD area *before* applying the selected decimation. */
@@
-271,12
+273,12
@@
static void qc_setup(struct qcam_device *q)
/* Set contrast and white balance. */
qcam_set(q, 0x19, q->contrast);
qcam_set(q, 0x1f, q->whitebal);
/* Set contrast and white balance. */
qcam_set(q, 0x19, q->contrast);
qcam_set(q, 0x1f, q->whitebal);
-
+
/* Set the speed. */
qcam_set(q, 45, 2);
}
/* Set the speed. */
qcam_set(q, 45, 2);
}
-/* Read some bytes from the camera and put them in the buffer.
+/* Read some bytes from the camera and put them in the buffer.
nbytes should be a multiple of 3, because bidirectional mode gives
us three bytes at a time. */
nbytes should be a multiple of 3, because bidirectional mode gives
us three bytes at a time. */
@@
-382,7
+384,7
@@
static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
if (qcam_set(q, 7, (q->mode | (is_bi_dir?1:0)) + 1))
return -EIO;
if (qcam_set(q, 7, (q->mode | (is_bi_dir?1:0)) + 1))
return -EIO;
-
+
lines = q->height;
pixelsperline = q->width;
bitsperxfer = (is_bi_dir) ? 24 : 8;
lines = q->height;
pixelsperline = q->width;
bitsperxfer = (is_bi_dir) ? 24 : 8;
@@
-498,7
+500,7
@@
static int qcam_do_ioctl(struct inode *inode, struct file *file,
{
struct video_device *dev = video_devdata(file);
struct qcam_device *qcam=(struct qcam_device *)dev;
{
struct video_device *dev = video_devdata(file);
struct qcam_device *qcam=(struct qcam_device *)dev;
-
+
switch(cmd)
{
case VIDIOCGCAP:
switch(cmd)
{
case VIDIOCGCAP:
@@
-573,7
+575,7
@@
static int qcam_do_ioctl(struct inode *inode, struct file *file,
*/
if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24)
return -EINVAL;
*/
if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24)
return -EINVAL;
-
+
/*
* Now load the camera.
*/
/*
* Now load the camera.
*/
@@
-581,11
+583,11
@@
static int qcam_do_ioctl(struct inode *inode, struct file *file,
qcam->contrast = p->contrast>>8;
qcam->whitebal = p->whiteness>>8;
qcam->contrast = p->contrast>>8;
qcam->whitebal = p->whiteness>>8;
- down(&qcam->lock);
+ mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
parport_claim_or_block(qcam->pdev);
- qc_setup(qcam);
+ qc_setup(qcam);
parport_release(qcam->pdev);
parport_release(qcam->pdev);
-
up
(&qcam->lock);
+
mutex_unlock
(&qcam->lock);
return 0;
}
case VIDIOCSWIN:
return 0;
}
case VIDIOCSWIN:
@@
-600,11
+602,11
@@
static int qcam_do_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
if(vw->width<80||vw->width>320)
return -EINVAL;
return -EINVAL;
if(vw->width<80||vw->width>320)
return -EINVAL;
-
+
qcam->width = 80;
qcam->height = 60;
qcam->mode = QC_DECIMATION_4;
qcam->width = 80;
qcam->height = 60;
qcam->mode = QC_DECIMATION_4;
-
+
if(vw->width>=160 && vw->height>=120)
{
qcam->width = 160;
if(vw->width>=160 && vw->height>=120)
{
qcam->width = 160;
@@
-626,13
+628,13
@@
static int qcam_do_ioctl(struct inode *inode, struct file *file,
qcam->mode = QC_BILLIONS | QC_DECIMATION_1;
}
#endif
qcam->mode = QC_BILLIONS | QC_DECIMATION_1;
}
#endif
- /* Ok we figured out what to use from our
+ /* Ok we figured out what to use from our
wide choice */
wide choice */
-
down
(&qcam->lock);
+
mutex_lock
(&qcam->lock);
parport_claim_or_block(qcam->pdev);
qc_setup(qcam);
parport_release(qcam->pdev);
parport_claim_or_block(qcam->pdev);
qc_setup(qcam);
parport_release(qcam->pdev);
-
up
(&qcam->lock);
+
mutex_unlock
(&qcam->lock);
return 0;
}
case VIDIOCGWIN:
return 0;
}
case VIDIOCGWIN:
@@
-672,12
+674,12
@@
static ssize_t qcam_read(struct file *file, char __user *buf,
struct qcam_device *qcam=(struct qcam_device *)v;
int len;
struct qcam_device *qcam=(struct qcam_device *)v;
int len;
-
down
(&qcam->lock);
+
mutex_lock
(&qcam->lock);
parport_claim_or_block(qcam->pdev);
/* Probably should have a semaphore against multiple users */
parport_claim_or_block(qcam->pdev);
/* Probably should have a semaphore against multiple users */
- len = qc_capture(qcam, buf,count);
+ len = qc_capture(qcam, buf,count);
parport_release(qcam->pdev);
parport_release(qcam->pdev);
-
up
(&qcam->lock);
+
mutex_unlock
(&qcam->lock);
return len;
}
return len;
}
@@
-706,7
+708,7
@@
static struct video_device qcam_template=
static struct qcam_device *qcam_init(struct parport *port)
{
struct qcam_device *q;
static struct qcam_device *qcam_init(struct parport *port)
{
struct qcam_device *q;
-
+
q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
if(q==NULL)
return NULL;
q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
if(q==NULL)
return NULL;
@@
-717,17
+719,17
@@
static struct qcam_device *qcam_init(struct parport *port)
q->bidirectional = (q->pport->modes & PARPORT_MODE_TRISTATE)?1:0;
q->bidirectional = (q->pport->modes & PARPORT_MODE_TRISTATE)?1:0;
- if (q->pdev == NULL)
+ if (q->pdev == NULL)
{
printk(KERN_ERR "c-qcam: couldn't register for %s.\n",
port->name);
kfree(q);
return NULL;
}
{
printk(KERN_ERR "c-qcam: couldn't register for %s.\n",
port->name);
kfree(q);
return NULL;
}
-
+
memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
-
init_MUTEX
(&q->lock);
+
mutex_init
(&q->lock);
q->width = q->ccd_width = 320;
q->height = q->ccd_height = 240;
q->mode = QC_MILLIONS | QC_DECIMATION_1;
q->width = q->ccd_width = 320;
q->height = q->ccd_height = 240;
q->mode = QC_MILLIONS | QC_DECIMATION_1;
@@
-765,11
+767,11
@@
static int init_cqcam(struct parport *port)
qcam = qcam_init(port);
if (qcam==NULL)
return -ENODEV;
qcam = qcam_init(port);
if (qcam==NULL)
return -ENODEV;
-
+
parport_claim_or_block(qcam->pdev);
qc_reset(qcam);
parport_claim_or_block(qcam->pdev);
qc_reset(qcam);
-
+
if (probe && qc_detect(qcam)==0)
{
parport_release(qcam->pdev);
if (probe && qc_detect(qcam)==0)
{
parport_release(qcam->pdev);
@@
-781,7
+783,7
@@
static int init_cqcam(struct parport *port)
qc_setup(qcam);
parport_release(qcam->pdev);
qc_setup(qcam);
parport_release(qcam->pdev);
-
+
if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1)
{
printk(KERN_ERR "Unable to register Colour QuickCam on %s\n",
if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1)
{
printk(KERN_ERR "Unable to register Colour QuickCam on %s\n",
@@
-791,9
+793,9
@@
static int init_cqcam(struct parport *port)
return -ENODEV;
}
return -ENODEV;
}
- printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
+ printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
qcam->vdev.minor, qcam->pport->name);
qcam->vdev.minor, qcam->pport->name);
-
+
qcams[num_cams++] = qcam;
return 0;
qcams[num_cams++] = qcam;
return 0;