Commit 51224aa4 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB: c-qcam: coding style cleanup

Clean up the coding style before we convert this driver to V4L2.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 380de498
...@@ -79,17 +79,17 @@ static inline void qcam_set_ack(struct qcam_device *qcam, unsigned int i) ...@@ -79,17 +79,17 @@ static inline void qcam_set_ack(struct qcam_device *qcam, unsigned int i)
{ {
/* note: the QC specs refer to the PCAck pin by voltage, not /* note: the QC specs refer to the PCAck pin by voltage, not
software level. PC ports have builtin inverters. */ software level. PC ports have builtin inverters. */
parport_frob_control(qcam->pport, 8, i?8:0); parport_frob_control(qcam->pport, 8, i ? 8 : 0);
} }
static inline unsigned int qcam_ready1(struct qcam_device *qcam) static inline unsigned int qcam_ready1(struct qcam_device *qcam)
{ {
return (parport_read_status(qcam->pport) & 0x8)?1:0; return (parport_read_status(qcam->pport) & 0x8) ? 1 : 0;
} }
static inline unsigned int qcam_ready2(struct qcam_device *qcam) 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,
...@@ -99,14 +99,13 @@ static unsigned int qcam_await_ready1(struct qcam_device *qcam, ...@@ -99,14 +99,13 @@ static unsigned int qcam_await_ready1(struct qcam_device *qcam,
unsigned int i; unsigned int i;
for (oldjiffies = jiffies; for (oldjiffies = jiffies;
time_before(jiffies, oldjiffies + msecs_to_jiffies(40)); ) time_before(jiffies, oldjiffies + msecs_to_jiffies(40));)
if (qcam_ready1(qcam) == value) if (qcam_ready1(qcam) == value)
return 0; 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 a while. */
for (i = 0; i < 50; i++) for (i = 0; i < 50; i++) {
{
if (qcam_ready1(qcam) == value) if (qcam_ready1(qcam) == value)
return 0; return 0;
msleep_interruptible(100); msleep_interruptible(100);
...@@ -125,14 +124,13 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value) ...@@ -125,14 +124,13 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value)
unsigned int i; unsigned int i;
for (oldjiffies = jiffies; for (oldjiffies = jiffies;
time_before(jiffies, oldjiffies + msecs_to_jiffies(40)); ) time_before(jiffies, oldjiffies + msecs_to_jiffies(40));)
if (qcam_ready2(qcam) == value) if (qcam_ready2(qcam) == value)
return 0; 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 a while. */
for (i = 0; i < 50; i++) for (i = 0; i < 50; i++) {
{
if (qcam_ready2(qcam) == value) if (qcam_ready2(qcam) == value)
return 0; return 0;
msleep_interruptible(100); msleep_interruptible(100);
...@@ -149,22 +147,25 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value) ...@@ -149,22 +147,25 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value)
static int qcam_read_data(struct qcam_device *qcam) static int qcam_read_data(struct qcam_device *qcam)
{ {
unsigned int idata; unsigned int idata;
qcam_set_ack(qcam, 0); qcam_set_ack(qcam, 0);
if (qcam_await_ready1(qcam, 1)) return -1; if (qcam_await_ready1(qcam, 1))
return -1;
idata = parport_read_status(qcam->pport) & 0xf0; idata = parport_read_status(qcam->pport) & 0xf0;
qcam_set_ack(qcam, 1); qcam_set_ack(qcam, 1);
if (qcam_await_ready1(qcam, 0)) return -1; if (qcam_await_ready1(qcam, 0))
idata |= (parport_read_status(qcam->pport) >> 4); return -1;
idata |= parport_read_status(qcam->pport) >> 4;
return idata; return idata;
} }
static int qcam_write_data(struct qcam_device *qcam, unsigned int data) static int qcam_write_data(struct qcam_device *qcam, unsigned int data)
{ {
unsigned int idata; unsigned int idata;
parport_write_data(qcam->pport, data); parport_write_data(qcam->pport, data);
idata = qcam_read_data(qcam); 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); idata);
return 1; return 1;
...@@ -212,13 +213,12 @@ static int qc_detect(struct qcam_device *qcam) ...@@ -212,13 +213,12 @@ static int qc_detect(struct qcam_device *qcam)
/* look for a heartbeat */ /* look for a heartbeat */
ostat = stat = parport_read_status(qcam->pport); ostat = stat = parport_read_status(qcam->pport);
for (i=0; i<250; i++) for (i = 0; i < 250; i++) {
{
mdelay(1); mdelay(1);
stat = parport_read_status(qcam->pport); stat = parport_read_status(qcam->pport);
if (ostat != stat) if (ostat != stat) {
{ if (++count >= 3)
if (++count >= 3) return 1; return 1;
ostat = stat; ostat = stat;
} }
} }
...@@ -232,13 +232,12 @@ static int qc_detect(struct qcam_device *qcam) ...@@ -232,13 +232,12 @@ static int qc_detect(struct qcam_device *qcam)
count = 0; count = 0;
ostat = stat = parport_read_status(qcam->pport); ostat = stat = parport_read_status(qcam->pport);
for (i=0; i<250; i++) for (i = 0; i < 250; i++) {
{
mdelay(1); mdelay(1);
stat = parport_read_status(qcam->pport); stat = parport_read_status(qcam->pport);
if (ostat != stat) if (ostat != stat) {
{ if (++count >= 3)
if (++count >= 3) return 1; return 1;
ostat = stat; ostat = stat;
} }
} }
...@@ -263,7 +262,7 @@ static void qc_setup(struct qcam_device *q) ...@@ -263,7 +262,7 @@ static void qc_setup(struct qcam_device *q)
{ {
qc_reset(q); qc_reset(q);
/* Set the brightness. */ /* 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 /* Set the height and width. These refer to the actual
...@@ -292,25 +291,25 @@ static unsigned int qcam_read_bytes(struct qcam_device *q, unsigned char *buf, u ...@@ -292,25 +291,25 @@ static unsigned int qcam_read_bytes(struct qcam_device *q, unsigned char *buf, u
unsigned int bytes = 0; unsigned int bytes = 0;
qcam_set_ack(q, 0); qcam_set_ack(q, 0);
if (q->bidirectional) if (q->bidirectional) {
{
/* It's a bidirectional port */ /* It's a bidirectional port */
while (bytes < nbytes) while (bytes < nbytes) {
{
unsigned int lo1, hi1, lo2, hi2; unsigned int lo1, hi1, lo2, hi2;
unsigned char r, g, b; unsigned char r, g, b;
if (qcam_await_ready2(q, 1)) return bytes; if (qcam_await_ready2(q, 1))
return bytes;
lo1 = parport_read_data(q->pport) >> 1; lo1 = parport_read_data(q->pport) >> 1;
hi1 = ((parport_read_status(q->pport) >> 3) & 0x1f) ^ 0x10; hi1 = ((parport_read_status(q->pport) >> 3) & 0x1f) ^ 0x10;
qcam_set_ack(q, 1); qcam_set_ack(q, 1);
if (qcam_await_ready2(q, 0)) return bytes; if (qcam_await_ready2(q, 0))
return bytes;
lo2 = parport_read_data(q->pport) >> 1; lo2 = parport_read_data(q->pport) >> 1;
hi2 = ((parport_read_status(q->pport) >> 3) & 0x1f) ^ 0x10; hi2 = ((parport_read_status(q->pport) >> 3) & 0x1f) ^ 0x10;
qcam_set_ack(q, 0); qcam_set_ack(q, 0);
r = (lo1 | ((hi1 & 1)<<7)); r = lo1 | ((hi1 & 1) << 7);
g = ((hi1 & 0x1e)<<3) | ((hi2 & 0x1e)>>1); g = ((hi1 & 0x1e) << 3) | ((hi2 & 0x1e) >> 1);
b = (lo2 | ((hi2 & 1)<<7)); b = lo2 | ((hi2 & 1) << 7);
if (force_rgb) { if (force_rgb) {
buf[bytes++] = r; buf[bytes++] = r;
buf[bytes++] = g; buf[bytes++] = g;
...@@ -321,21 +320,20 @@ static unsigned int qcam_read_bytes(struct qcam_device *q, unsigned char *buf, u ...@@ -321,21 +320,20 @@ static unsigned int qcam_read_bytes(struct qcam_device *q, unsigned char *buf, u
buf[bytes++] = r; buf[bytes++] = r;
} }
} }
} } else {
else
{
/* It's a unidirectional port */ /* It's a unidirectional port */
int i = 0, n = bytes; int i = 0, n = bytes;
unsigned char rgb[3]; unsigned char rgb[3];
while (bytes < nbytes) while (bytes < nbytes) {
{
unsigned int hi, lo; unsigned int hi, lo;
if (qcam_await_ready1(q, 1)) return bytes; if (qcam_await_ready1(q, 1))
return bytes;
hi = (parport_read_status(q->pport) & 0xf0); hi = (parport_read_status(q->pport) & 0xf0);
qcam_set_ack(q, 1); qcam_set_ack(q, 1);
if (qcam_await_ready1(q, 0)) return bytes; if (qcam_await_ready1(q, 0))
return bytes;
lo = (parport_read_status(q->pport) & 0xf0); lo = (parport_read_status(q->pport) & 0xf0);
qcam_set_ack(q, 0); qcam_set_ack(q, 0);
/* flip some bits */ /* flip some bits */
...@@ -374,28 +372,26 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le ...@@ -374,28 +372,26 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
return -EFAULT; return -EFAULT;
/* Wait for camera to become ready */ /* Wait for camera to become ready */
for (;;) for (;;) {
{
int i = qcam_get(q, 41); int i = qcam_get(q, 41);
if (i == -1) { if (i == -1) {
qc_setup(q); qc_setup(q);
return -EIO; return -EIO;
} }
if ((i & 0x80) == 0) if ((i & 0x80) == 0)
break; break;
else schedule();
schedule();
} }
if (qcam_set(q, 7, (q->mode | (is_bi_dir?1:0)) + 1)) if (qcam_set(q, 7, (q->mode | (is_bi_dir ? 1 : 0)) + 1))
return -EIO; return -EIO;
lines = q->height; lines = q->height;
pixelsperline = q->width; pixelsperline = q->width;
bitsperxfer = (is_bi_dir) ? 24 : 8; bitsperxfer = (is_bi_dir) ? 24 : 8;
if (is_bi_dir) if (is_bi_dir) {
{
/* Turn the port around */ /* Turn the port around */
parport_data_reverse(q->pport); parport_data_reverse(q->pport);
mdelay(3); mdelay(3);
...@@ -413,16 +409,17 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le ...@@ -413,16 +409,17 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
wantlen = lines * pixelsperline * 24 / 8; wantlen = lines * pixelsperline * 24 / 8;
while (wantlen) while (wantlen) {
{
size_t t, s; size_t t, s;
s = (wantlen > BUFSZ)?BUFSZ:wantlen;
s = (wantlen > BUFSZ) ? BUFSZ : wantlen;
t = qcam_read_bytes(q, tmpbuf, s); t = qcam_read_bytes(q, tmpbuf, s);
if (outptr < len) if (outptr < len) {
{
size_t sz = len - outptr; size_t sz = len - outptr;
if (sz > t) sz = t;
if (__copy_to_user(buf+outptr, tmpbuf, sz)) if (sz > t)
sz = t;
if (__copy_to_user(buf + outptr, tmpbuf, sz))
break; break;
outptr += sz; outptr += sz;
} }
...@@ -434,33 +431,31 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le ...@@ -434,33 +431,31 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
len = outptr; len = outptr;
if (wantlen) if (wantlen) {
{ printk(KERN_ERR "qcam: short read.\n");
printk("qcam: short read.\n");
if (is_bi_dir) if (is_bi_dir)
parport_data_forward(q->pport); parport_data_forward(q->pport);
qc_setup(q); qc_setup(q);
return len; return len;
} }
if (is_bi_dir) if (is_bi_dir) {
{
int l; int l;
do { do {
l = qcam_read_bytes(q, tmpbuf, 3); l = qcam_read_bytes(q, tmpbuf, 3);
cond_resched(); cond_resched();
} while (l && (tmpbuf[0] == 0x7e || tmpbuf[1] == 0x7e || tmpbuf[2] == 0x7e)); } while (l && (tmpbuf[0] == 0x7e || tmpbuf[1] == 0x7e || tmpbuf[2] == 0x7e));
if (force_rgb) { if (force_rgb) {
if (tmpbuf[0] != 0xe || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xf) if (tmpbuf[0] != 0xe || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xf)
printk("qcam: bad EOF\n"); printk(KERN_ERR "qcam: bad EOF\n");
} else { } else {
if (tmpbuf[0] != 0xf || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xe) if (tmpbuf[0] != 0xf || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xe)
printk("qcam: bad EOF\n"); printk(KERN_ERR "qcam: bad EOF\n");
} }
qcam_set_ack(q, 0); qcam_set_ack(q, 0);
if (qcam_await_ready1(q, 1)) if (qcam_await_ready1(q, 1)) {
{ printk(KERN_ERR "qcam: no ack after EOF\n");
printk("qcam: no ack after EOF\n");
parport_data_forward(q->pport); parport_data_forward(q->pport);
qc_setup(q); qc_setup(q);
return len; return len;
...@@ -468,27 +463,25 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le ...@@ -468,27 +463,25 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
parport_data_forward(q->pport); parport_data_forward(q->pport);
mdelay(3); mdelay(3);
qcam_set_ack(q, 1); qcam_set_ack(q, 1);
if (qcam_await_ready1(q, 0)) if (qcam_await_ready1(q, 0)) {
{ printk(KERN_ERR "qcam: no ack to port turnaround\n");
printk("qcam: no ack to port turnaround\n");
qc_setup(q); qc_setup(q);
return len; return len;
} }
} } else {
else
{
int l; int l;
do { do {
l = qcam_read_bytes(q, tmpbuf, 1); l = qcam_read_bytes(q, tmpbuf, 1);
cond_resched(); cond_resched();
} while (l && tmpbuf[0] == 0x7e); } while (l && tmpbuf[0] == 0x7e);
l = qcam_read_bytes(q, tmpbuf+1, 2); l = qcam_read_bytes(q, tmpbuf + 1, 2);
if (force_rgb) { if (force_rgb) {
if (tmpbuf[0] != 0xe || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xf) if (tmpbuf[0] != 0xe || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xf)
printk("qcam: bad EOF\n"); printk(KERN_ERR "qcam: bad EOF\n");
} else { } else {
if (tmpbuf[0] != 0xf || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xe) if (tmpbuf[0] != 0xf || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xe)
printk("qcam: bad EOF\n"); printk(KERN_ERR "qcam: bad EOF\n");
} }
} }
...@@ -503,164 +496,166 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le ...@@ -503,164 +496,166 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
{ {
struct video_device *dev = video_devdata(file); struct video_device *dev = video_devdata(file);
struct qcam_device *qcam=(struct qcam_device *)dev; struct qcam_device *qcam = (struct qcam_device *)dev;
switch(cmd) switch (cmd) {
case VIDIOCGCAP:
{ {
case VIDIOCGCAP: struct video_capability *b = arg;
{
struct video_capability *b = arg; strcpy(b->name, "Quickcam");
strcpy(b->name, "Quickcam"); b->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
b->type = VID_TYPE_CAPTURE|VID_TYPE_SCALES; b->channels = 1;
b->channels = 1; b->audios = 0;
b->audios = 0; b->maxwidth = 320;
b->maxwidth = 320; b->maxheight = 240;
b->maxheight = 240; b->minwidth = 80;
b->minwidth = 80; b->minheight = 60;
b->minheight = 60; return 0;
return 0; }
} case VIDIOCGCHAN:
case VIDIOCGCHAN: {
{ struct video_channel *v = arg;
struct video_channel *v = arg;
if(v->channel!=0) if (v->channel != 0)
return -EINVAL; return -EINVAL;
v->flags=0; v->flags = 0;
v->tuners=0; v->tuners = 0;
/* Good question.. its composite or SVHS so.. */ /* Good question.. its composite or SVHS so.. */
v->type = VIDEO_TYPE_CAMERA; v->type = VIDEO_TYPE_CAMERA;
strcpy(v->name, "Camera"); strcpy(v->name, "Camera");
return 0; return 0;
} }
case VIDIOCSCHAN: case VIDIOCSCHAN:
{ {
struct video_channel *v = arg; struct video_channel *v = arg;
if(v->channel!=0)
return -EINVAL; if (v->channel != 0)
return 0; return -EINVAL;
} return 0;
case VIDIOCGTUNER: }
{ case VIDIOCGTUNER:
struct video_tuner *v = arg; {
if(v->tuner) struct video_tuner *v = arg;
return -EINVAL;
memset(v,0,sizeof(*v)); if (v->tuner)
strcpy(v->name, "Format"); return -EINVAL;
v->mode = VIDEO_MODE_AUTO; memset(v, 0, sizeof(*v));
return 0; strcpy(v->name, "Format");
} v->mode = VIDEO_MODE_AUTO;
case VIDIOCSTUNER: return 0;
{ }
struct video_tuner *v = arg; case VIDIOCSTUNER:
if(v->tuner) {
return -EINVAL; struct video_tuner *v = arg;
if(v->mode!=VIDEO_MODE_AUTO)
return -EINVAL; if (v->tuner)
return 0; return -EINVAL;
} if (v->mode != VIDEO_MODE_AUTO)
case VIDIOCGPICT: return -EINVAL;
{ return 0;
struct video_picture *p = arg; }
p->colour=0x8000; case VIDIOCGPICT:
p->hue=0x8000; {
p->brightness=qcam->brightness<<8; struct video_picture *p = arg;
p->contrast=qcam->contrast<<8;
p->whiteness=qcam->whitebal<<8; p->colour = 0x8000;
p->depth=24; p->hue = 0x8000;
p->palette=VIDEO_PALETTE_RGB24; p->brightness = qcam->brightness << 8;
return 0; p->contrast = qcam->contrast << 8;
p->whiteness = qcam->whitebal << 8;
p->depth = 24;
p->palette = VIDEO_PALETTE_RGB24;
return 0;
}
case VIDIOCSPICT:
{
struct video_picture *p = arg;
/*
* Sanity check args
*/
if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24)
return -EINVAL;
/*
* Now load the camera.
*/
qcam->brightness = p->brightness >> 8;
qcam->contrast = p->contrast >> 8;
qcam->whitebal = p->whiteness >> 8;
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
qc_setup(qcam);
parport_release(qcam->pdev);
mutex_unlock(&qcam->lock);
return 0;
}
case VIDIOCSWIN:
{
struct video_window *vw = arg;
if (vw->flags)
return -EINVAL;
if (vw->clipcount)
return -EINVAL;
if (vw->height < 60 || vw->height > 240)
return -EINVAL;
if (vw->width < 80 || vw->width > 320)
return -EINVAL;
qcam->width = 80;
qcam->height = 60;
qcam->mode = QC_DECIMATION_4;
if (vw->width >= 160 && vw->height >= 120) {
qcam->width = 160;
qcam->height = 120;
qcam->mode = QC_DECIMATION_2;
} }
case VIDIOCSPICT: if (vw->width >= 320 && vw->height >= 240) {
{ qcam->width = 320;
struct video_picture *p = arg; qcam->height = 240;
qcam->mode = QC_DECIMATION_1;
/*
* Sanity check args
*/
if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24)
return -EINVAL;
/*
* Now load the camera.
*/
qcam->brightness = p->brightness>>8;
qcam->contrast = p->contrast>>8;
qcam->whitebal = p->whiteness>>8;
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
qc_setup(qcam);
parport_release(qcam->pdev);
mutex_unlock(&qcam->lock);
return 0;
} }
case VIDIOCSWIN: qcam->mode |= QC_MILLIONS;
{
struct video_window *vw = arg;
if(vw->flags)
return -EINVAL;
if(vw->clipcount)
return -EINVAL;
if(vw->height<60||vw->height>240)
return -EINVAL;
if(vw->width<80||vw->width>320)
return -EINVAL;
qcam->width = 80;
qcam->height = 60;
qcam->mode = QC_DECIMATION_4;
if(vw->width>=160 && vw->height>=120)
{
qcam->width = 160;
qcam->height = 120;
qcam->mode = QC_DECIMATION_2;
}
if(vw->width>=320 && vw->height>=240)
{
qcam->width = 320;
qcam->height = 240;
qcam->mode = QC_DECIMATION_1;
}
qcam->mode |= QC_MILLIONS;
#if 0 #if 0
if(vw->width>=640 && vw->height>=480) if (vw->width >= 640 && vw->height >= 480) {
{ qcam->width = 640;
qcam->width = 640; qcam->height = 480;
qcam->height = 480; qcam->mode = QC_BILLIONS | QC_DECIMATION_1;
qcam->mode = QC_BILLIONS | QC_DECIMATION_1;
}
#endif
/* Ok we figured out what to use from our
wide choice */
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
qc_setup(qcam);
parport_release(qcam->pdev);
mutex_unlock(&qcam->lock);
return 0;
}
case VIDIOCGWIN:
{
struct video_window *vw = arg;
memset(vw, 0, sizeof(*vw));
vw->width=qcam->width;
vw->height=qcam->height;
return 0;
} }
case VIDIOCKEY: #endif
return 0; /* Ok we figured out what to use from our
case VIDIOCCAPTURE: wide choice */
case VIDIOCGFBUF: mutex_lock(&qcam->lock);
case VIDIOCSFBUF: parport_claim_or_block(qcam->pdev);
case VIDIOCGFREQ: qc_setup(qcam);
case VIDIOCSFREQ: parport_release(qcam->pdev);
case VIDIOCGAUDIO: mutex_unlock(&qcam->lock);
case VIDIOCSAUDIO: return 0;
return -EINVAL; }
default: case VIDIOCGWIN:
return -ENOIOCTLCMD; {
struct video_window *vw = arg;
memset(vw, 0, sizeof(*vw));
vw->width = qcam->width;
vw->height = qcam->height;
return 0;
}
case VIDIOCKEY:
return 0;
case VIDIOCCAPTURE:
case VIDIOCGFBUF:
case VIDIOCSFBUF:
case VIDIOCGFREQ:
case VIDIOCSFREQ:
case VIDIOCGAUDIO:
case VIDIOCSAUDIO:
return -EINVAL;
default:
return -ENOIOCTLCMD;
} }
return 0; return 0;
} }
...@@ -675,13 +670,13 @@ static ssize_t qcam_read(struct file *file, char __user *buf, ...@@ -675,13 +670,13 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct video_device *v = video_devdata(file); struct video_device *v = video_devdata(file);
struct qcam_device *qcam=(struct qcam_device *)v; struct qcam_device *qcam = (struct qcam_device *)v;
int len; int len;
mutex_lock(&qcam->lock); mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev); parport_claim_or_block(qcam->pdev);
/* Probably should have a semaphore against multiple users */ /* 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);
mutex_unlock(&qcam->lock); mutex_unlock(&qcam->lock);
return len; return len;
...@@ -713,8 +708,7 @@ static const struct v4l2_file_operations qcam_fops = { ...@@ -713,8 +708,7 @@ static const struct v4l2_file_operations qcam_fops = {
.read = qcam_read, .read = qcam_read,
}; };
static struct video_device qcam_template= static struct video_device qcam_template = {
{
.name = "Colour QuickCam", .name = "Colour QuickCam",
.fops = &qcam_fops, .fops = &qcam_fops,
.release = video_device_release_empty, .release = video_device_release_empty,
...@@ -727,17 +721,16 @@ static struct qcam_device *qcam_init(struct parport *port) ...@@ -727,17 +721,16 @@ static struct qcam_device *qcam_init(struct parport *port)
struct qcam_device *q; struct qcam_device *q;
q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL); q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
if(q==NULL) if (q == NULL)
return NULL; return NULL;
q->pport = port; q->pport = port;
q->pdev = parport_register_device(port, "c-qcam", NULL, NULL, q->pdev = parport_register_device(port, "c-qcam", NULL, NULL,
NULL, 0, NULL); NULL, 0, NULL);
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", printk(KERN_ERR "c-qcam: couldn't register for %s.\n",
port->name); port->name);
kfree(q); kfree(q);
...@@ -765,12 +758,11 @@ static int init_cqcam(struct parport *port) ...@@ -765,12 +758,11 @@ static int init_cqcam(struct parport *port)
{ {
struct qcam_device *qcam; struct qcam_device *qcam;
if (parport[0] != -1) if (parport[0] != -1) {
{
/* The user gave specific instructions */ /* The user gave specific instructions */
int i, found = 0; int i, found = 0;
for (i = 0; i < MAX_CAMS && parport[i] != -1; i++)
{ for (i = 0; i < MAX_CAMS && parport[i] != -1; i++) {
if (parport[0] == port->number) if (parport[0] == port->number)
found = 1; found = 1;
} }
...@@ -782,15 +774,14 @@ static int init_cqcam(struct parport *port) ...@@ -782,15 +774,14 @@ static int init_cqcam(struct parport *port)
return -ENOSPC; return -ENOSPC;
qcam = qcam_init(port); qcam = qcam_init(port);
if (qcam==NULL) if (qcam == NULL)
return -ENODEV; return -ENODEV;
parport_claim_or_block(qcam->pdev); parport_claim_or_block(qcam->pdev);
qc_reset(qcam); qc_reset(qcam);
if (probe && qc_detect(qcam)==0) if (probe && qc_detect(qcam) == 0) {
{
parport_release(qcam->pdev); parport_release(qcam->pdev);
parport_unregister_device(qcam->pdev); parport_unregister_device(qcam->pdev);
kfree(qcam); kfree(qcam);
...@@ -840,14 +831,14 @@ static struct parport_driver cqcam_driver = { ...@@ -840,14 +831,14 @@ static struct parport_driver cqcam_driver = {
.detach = cq_detach, .detach = cq_detach,
}; };
static int __init cqcam_init (void) static int __init cqcam_init(void)
{ {
printk(BANNER "\n"); printk(BANNER "\n");
return parport_register_driver(&cqcam_driver); return parport_register_driver(&cqcam_driver);
} }
static void __exit cqcam_cleanup (void) static void __exit cqcam_cleanup(void)
{ {
unsigned int i; unsigned int i;
...@@ -862,9 +853,9 @@ MODULE_DESCRIPTION(BANNER); ...@@ -862,9 +853,9 @@ MODULE_DESCRIPTION(BANNER);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
/* FIXME: parport=auto would never have worked, surely? --RR */ /* FIXME: parport=auto would never have worked, surely? --RR */
MODULE_PARM_DESC(parport ,"parport=<auto|n[,n]...> for port detection method\n\ MODULE_PARM_DESC(parport, "parport=<auto|n[,n]...> for port detection method\n"
probe=<0|1|2> for camera detection method\n\ "probe=<0|1|2> for camera detection method\n"
force_rgb=<0|1> for RGB data format (default BGR)"); "force_rgb=<0|1> for RGB data format (default BGR)");
module_param_array(parport, int, NULL, 0); module_param_array(parport, int, NULL, 0);
module_param(probe, int, 0); module_param(probe, int, 0);
module_param(force_rgb, bool, 0); module_param(force_rgb, bool, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment