Commit 1d61aac0 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB: bw-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 51224aa4
...@@ -80,8 +80,8 @@ OTHER DEALINGS IN THE SOFTWARE. ...@@ -80,8 +80,8 @@ OTHER DEALINGS IN THE SOFTWARE.
#include "bw-qcam.h" #include "bw-qcam.h"
static unsigned int maxpoll=250; /* Maximum busy-loop count for qcam I/O */ static unsigned int maxpoll = 250; /* Maximum busy-loop count for qcam I/O */
static unsigned int yieldlines=4; /* Yield after this many during capture */ static unsigned int yieldlines = 4; /* Yield after this many during capture */
static int video_nr = -1; static int video_nr = -1;
static unsigned int force_init; /* Whether to probe aggressively */ static unsigned int force_init; /* Whether to probe aggressively */
...@@ -156,7 +156,7 @@ static int qc_calibrate(struct qcam_device *q) ...@@ -156,7 +156,7 @@ static int qc_calibrate(struct qcam_device *q)
mdelay(1); mdelay(1);
schedule(); schedule();
count++; count++;
} while (value == 0xff && count<2048); } while (value == 0xff && count < 2048);
q->whitebal = value; q->whitebal = value;
return value; return value;
...@@ -170,16 +170,15 @@ static struct qcam_device *qcam_init(struct parport *port) ...@@ -170,16 +170,15 @@ 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, "bw-qcam", NULL, NULL, q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL,
NULL, 0, NULL); NULL, 0, NULL);
if (q->pdev == NULL) if (q->pdev == NULL) {
{
printk(KERN_ERR "bw-qcam: couldn't register for %s.\n", printk(KERN_ERR "bw-qcam: couldn't register for %s.\n",
port->name); port->name);
kfree(q); kfree(q);
return NULL; return NULL;
} }
...@@ -247,12 +246,10 @@ static int qc_readparam(struct qcam_device *q) ...@@ -247,12 +246,10 @@ static int qc_readparam(struct qcam_device *q)
static int qc_waithand(struct qcam_device *q, int val) static int qc_waithand(struct qcam_device *q, int val)
{ {
int status; int status;
int runs=0; int runs = 0;
if (val) if (val) {
{ while (!((status = read_lpstatus(q)) & 8)) {
while (!((status = read_lpstatus(q)) & 8))
{
/* 1000 is enough spins on the I/O for all normal /* 1000 is enough spins on the I/O for all normal
cases, at that point we start to poll slowly cases, at that point we start to poll slowly
until the camera wakes up. However, we are until the camera wakes up. However, we are
...@@ -260,18 +257,13 @@ static int qc_waithand(struct qcam_device *q, int val) ...@@ -260,18 +257,13 @@ static int qc_waithand(struct qcam_device *q, int val)
setting it lower is much better for interactive setting it lower is much better for interactive
response. */ response. */
if(runs++>maxpoll) if (runs++ > maxpoll)
{
msleep_interruptible(5); msleep_interruptible(5);
} if (runs > (maxpoll + 1000)) /* 5 seconds */
if(runs>(maxpoll+1000)) /* 5 seconds */
return -1; return -1;
} }
} } else {
else while (((status = read_lpstatus(q)) & 8)) {
{
while (((status = read_lpstatus(q)) & 8))
{
/* 1000 is enough spins on the I/O for all normal /* 1000 is enough spins on the I/O for all normal
cases, at that point we start to poll slowly cases, at that point we start to poll slowly
until the camera wakes up. However, we are until the camera wakes up. However, we are
...@@ -279,11 +271,9 @@ static int qc_waithand(struct qcam_device *q, int val) ...@@ -279,11 +271,9 @@ static int qc_waithand(struct qcam_device *q, int val)
setting it lower is much better for interactive setting it lower is much better for interactive
response. */ response. */
if(runs++>maxpoll) if (runs++ > maxpoll)
{
msleep_interruptible(5); msleep_interruptible(5);
} if (runs++ > (maxpoll + 1000)) /* 5 seconds */
if(runs++>(maxpoll+1000)) /* 5 seconds */
return -1; return -1;
} }
} }
...@@ -299,10 +289,9 @@ static int qc_waithand(struct qcam_device *q, int val) ...@@ -299,10 +289,9 @@ static int qc_waithand(struct qcam_device *q, int val)
static unsigned int qc_waithand2(struct qcam_device *q, int val) static unsigned int qc_waithand2(struct qcam_device *q, int val)
{ {
unsigned int status; unsigned int status;
int runs=0; int runs = 0;
do do {
{
status = read_lpdata(q); status = read_lpdata(q);
/* 1000 is enough spins on the I/O for all normal /* 1000 is enough spins on the I/O for all normal
cases, at that point we start to poll slowly cases, at that point we start to poll slowly
...@@ -311,14 +300,11 @@ static unsigned int qc_waithand2(struct qcam_device *q, int val) ...@@ -311,14 +300,11 @@ static unsigned int qc_waithand2(struct qcam_device *q, int val)
setting it lower is much better for interactive setting it lower is much better for interactive
response. */ response. */
if(runs++>maxpoll) if (runs++ > maxpoll)
{
msleep_interruptible(5); msleep_interruptible(5);
} if (runs++ > (maxpoll + 1000)) /* 5 seconds */
if(runs++>(maxpoll+1000)) /* 5 seconds */
return 0; return 0;
} } while ((status & 1) != val);
while ((status & 1) != val);
return status; return status;
} }
...@@ -342,8 +328,7 @@ static int qc_detect(struct qcam_device *q) ...@@ -342,8 +328,7 @@ static int qc_detect(struct qcam_device *q)
lastreg = reg = read_lpstatus(q) & 0xf0; lastreg = reg = read_lpstatus(q) & 0xf0;
for (i = 0; i < 500; i++) for (i = 0; i < 500; i++) {
{
reg = read_lpstatus(q) & 0xf0; reg = read_lpstatus(q) & 0xf0;
if (reg != lastreg) if (reg != lastreg)
count++; count++;
...@@ -357,7 +342,7 @@ static int qc_detect(struct qcam_device *q) ...@@ -357,7 +342,7 @@ static int qc_detect(struct qcam_device *q)
won't be flashing these bits. Possibly unloading the module won't be flashing these bits. Possibly unloading the module
in the middle of a grab? Or some timeout condition? in the middle of a grab? Or some timeout condition?
I've seen this parameter as low as 19 on my 450Mhz box - mpc */ I've seen this parameter as low as 19 on my 450Mhz box - mpc */
printk("Debugging: QCam detection counter <30-200 counts as detected>: %d\n", count); printk(KERN_DEBUG "Debugging: QCam detection counter <30-200 counts as detected>: %d\n", count);
return 1; return 1;
#endif #endif
...@@ -367,7 +352,7 @@ static int qc_detect(struct qcam_device *q) ...@@ -367,7 +352,7 @@ static int qc_detect(struct qcam_device *q)
return 1; /* found */ return 1; /* found */
} else { } else {
printk(KERN_ERR "No Quickcam found on port %s\n", printk(KERN_ERR "No Quickcam found on port %s\n",
q->pport->name); q->pport->name);
printk(KERN_DEBUG "Quickcam detection counter: %u\n", count); printk(KERN_DEBUG "Quickcam detection counter: %u\n", count);
return 0; /* not found */ return 0; /* not found */
} }
...@@ -381,26 +366,24 @@ static int qc_detect(struct qcam_device *q) ...@@ -381,26 +366,24 @@ static int qc_detect(struct qcam_device *q)
static void qc_reset(struct qcam_device *q) static void qc_reset(struct qcam_device *q)
{ {
switch (q->port_mode & QC_FORCE_MASK) switch (q->port_mode & QC_FORCE_MASK) {
{ case QC_FORCE_UNIDIR:
case QC_FORCE_UNIDIR: q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; break;
break;
case QC_FORCE_BIDIR: case QC_FORCE_BIDIR:
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
break; break;
case QC_ANY: case QC_ANY:
write_lpcontrol(q, 0x20); write_lpcontrol(q, 0x20);
write_lpdata(q, 0x75); write_lpdata(q, 0x75);
if (read_lpdata(q) != 0x75) { if (read_lpdata(q) != 0x75)
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
} else { else
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
} break;
break;
} }
write_lpcontrol(q, 0xb); write_lpcontrol(q, 0xb);
...@@ -423,36 +406,33 @@ static int qc_setscanmode(struct qcam_device *q) ...@@ -423,36 +406,33 @@ static int qc_setscanmode(struct qcam_device *q)
{ {
int old_mode = q->mode; int old_mode = q->mode;
switch (q->transfer_scale) switch (q->transfer_scale) {
{ case 1:
case 1: q->mode = 0;
q->mode = 0; break;
break; case 2:
case 2: q->mode = 4;
q->mode = 4; break;
break; case 4:
case 4: q->mode = 8;
q->mode = 8; break;
break;
} }
switch (q->bpp) switch (q->bpp) {
{ case 4:
case 4: break;
break; case 6:
case 6: q->mode += 2;
q->mode += 2; break;
break;
} }
switch (q->port_mode & QC_MODE_MASK) switch (q->port_mode & QC_MODE_MASK) {
{ case QC_BIDIR:
case QC_BIDIR: q->mode += 1;
q->mode += 1; break;
break; case QC_NOTSET:
case QC_NOTSET: case QC_UNIDIR:
case QC_UNIDIR: break;
break;
} }
if (q->mode != old_mode) if (q->mode != old_mode)
...@@ -493,7 +473,7 @@ static void qc_set(struct qcam_device *q) ...@@ -493,7 +473,7 @@ static void qc_set(struct qcam_device *q)
} else { } else {
val = q->width * q->bpp; val = q->width * q->bpp;
val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) * val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
q->transfer_scale; q->transfer_scale;
} }
val = DIV_ROUND_UP(val, val2); val = DIV_ROUND_UP(val, val2);
qc_command(q, 0x13); qc_command(q, 0x13);
...@@ -521,85 +501,80 @@ static void qc_set(struct qcam_device *q) ...@@ -521,85 +501,80 @@ static void qc_set(struct qcam_device *q)
static inline int qc_readbytes(struct qcam_device *q, char buffer[]) static inline int qc_readbytes(struct qcam_device *q, char buffer[])
{ {
int ret=1; int ret = 1;
unsigned int hi, lo; unsigned int hi, lo;
unsigned int hi2, lo2; unsigned int hi2, lo2;
static int state; static int state;
if (buffer == NULL) if (buffer == NULL) {
{
state = 0; state = 0;
return 0; return 0;
} }
switch (q->port_mode & QC_MODE_MASK) switch (q->port_mode & QC_MODE_MASK) {
{ case QC_BIDIR: /* Bi-directional Port */
case QC_BIDIR: /* Bi-directional Port */ write_lpcontrol(q, 0x26);
write_lpcontrol(q, 0x26); lo = (qc_waithand2(q, 1) >> 1);
lo = (qc_waithand2(q, 1) >> 1); hi = (read_lpstatus(q) >> 3) & 0x1f;
hi = (read_lpstatus(q) >> 3) & 0x1f; write_lpcontrol(q, 0x2e);
write_lpcontrol(q, 0x2e); lo2 = (qc_waithand2(q, 0) >> 1);
lo2 = (qc_waithand2(q, 0) >> 1); hi2 = (read_lpstatus(q) >> 3) & 0x1f;
hi2 = (read_lpstatus(q) >> 3) & 0x1f; switch (q->bpp) {
switch (q->bpp) case 4:
{ buffer[0] = lo & 0xf;
case 4: buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3);
buffer[0] = lo & 0xf; buffer[2] = (hi & 0x1e) >> 1;
buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3); buffer[3] = lo2 & 0xf;
buffer[2] = (hi & 0x1e) >> 1; buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3);
buffer[3] = lo2 & 0xf; buffer[5] = (hi2 & 0x1e) >> 1;
buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3); ret = 6;
buffer[5] = (hi2 & 0x1e) >> 1; break;
ret = 6; case 6:
break; buffer[0] = lo & 0x3f;
case 6: buffer[1] = ((lo & 0x40) >> 6) | (hi << 1);
buffer[0] = lo & 0x3f; buffer[2] = lo2 & 0x3f;
buffer[1] = ((lo & 0x40) >> 6) | (hi << 1); buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1);
buffer[2] = lo2 & 0x3f; ret = 4;
buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1);
ret = 4;
break;
}
break; break;
}
break;
case QC_UNIDIR: /* Unidirectional Port */
write_lpcontrol(q, 6);
lo = (qc_waithand(q, 1) & 0xf0) >> 4;
write_lpcontrol(q, 0xe);
hi = (qc_waithand(q, 0) & 0xf0) >> 4;
case QC_UNIDIR: /* Unidirectional Port */ switch (q->bpp) {
write_lpcontrol(q, 6); case 4:
lo = (qc_waithand(q, 1) & 0xf0) >> 4; buffer[0] = lo;
write_lpcontrol(q, 0xe); buffer[1] = hi;
hi = (qc_waithand(q, 0) & 0xf0) >> 4; ret = 2;
break;
switch (q->bpp) case 6:
{ switch (state) {
case 4: case 0:
buffer[0] = lo; buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
buffer[1] = hi; q->saved_bits = (hi & 3) << 4;
ret = 2; state = 1;
break; ret = 1;
case 6: break;
switch (state) case 1:
{ buffer[0] = lo | q->saved_bits;
case 0: q->saved_bits = hi << 2;
buffer[0] = (lo << 2) | ((hi & 0xc) >> 2); state = 2;
q->saved_bits = (hi & 3) << 4; ret = 1;
state = 1; break;
ret = 1; case 2:
break; buffer[0] = ((lo & 0xc) >> 2) | q->saved_bits;
case 1: buffer[1] = ((lo & 3) << 4) | hi;
buffer[0] = lo | q->saved_bits; state = 0;
q->saved_bits = hi << 2; ret = 2;
state = 2; break;
ret = 1;
break;
case 2:
buffer[0] = ((lo & 0xc) >> 2) | q->saved_bits;
buffer[1] = ((lo & 3) << 4) | hi;
state = 0;
ret = 2;
break;
}
break;
} }
break; break;
}
break;
} }
return ret; return ret;
} }
...@@ -615,7 +590,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[]) ...@@ -615,7 +590,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
* n=2^(bit depth)-1. Ask me for more details if you don't understand * n=2^(bit depth)-1. Ask me for more details if you don't understand
* this. */ * this. */
static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long len) static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long len)
{ {
int i, j, k, yield; int i, j, k, yield;
int bytes; int bytes;
...@@ -623,9 +598,9 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l ...@@ -623,9 +598,9 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
int divisor; int divisor;
int pixels_per_line; int pixels_per_line;
int pixels_read = 0; int pixels_read = 0;
int got=0; int got = 0;
char buffer[6]; char buffer[6];
int shift=8-q->bpp; int shift = 8 - q->bpp;
char invert; char invert;
if (q->mode == -1) if (q->mode == -1)
...@@ -634,13 +609,12 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l ...@@ -634,13 +609,12 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
qc_command(q, 0x7); qc_command(q, 0x7);
qc_command(q, q->mode); qc_command(q, q->mode);
if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
{
write_lpcontrol(q, 0x2e); /* turn port around */ write_lpcontrol(q, 0x2e); /* turn port around */
write_lpcontrol(q, 0x26); write_lpcontrol(q, 0x26);
(void) qc_waithand(q, 1); qc_waithand(q, 1);
write_lpcontrol(q, 0x2e); write_lpcontrol(q, 0x2e);
(void) qc_waithand(q, 0); qc_waithand(q, 0);
} }
/* strange -- should be 15:63 below, but 4bpp is odd */ /* strange -- should be 15:63 below, but 4bpp is odd */
...@@ -650,33 +624,28 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l ...@@ -650,33 +624,28 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
pixels_per_line = q->width / q->transfer_scale; pixels_per_line = q->width / q->transfer_scale;
transperline = q->width * q->bpp; transperline = q->width * q->bpp;
divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) * divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
q->transfer_scale; q->transfer_scale;
transperline = DIV_ROUND_UP(transperline, divisor); transperline = DIV_ROUND_UP(transperline, divisor);
for (i = 0, yield = yieldlines; i < linestotrans; i++) for (i = 0, yield = yieldlines; i < linestotrans; i++) {
{ for (pixels_read = j = 0; j < transperline; j++) {
for (pixels_read = j = 0; j < transperline; j++)
{
bytes = qc_readbytes(q, buffer); bytes = qc_readbytes(q, buffer);
for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) {
{
int o; int o;
if (buffer[k] == 0 && invert == 16) if (buffer[k] == 0 && invert == 16) {
{
/* 4bpp is odd (again) -- inverter is 16, not 15, but output /* 4bpp is odd (again) -- inverter is 16, not 15, but output
must be 0-15 -- bls */ must be 0-15 -- bls */
buffer[k] = 16; buffer[k] = 16;
} }
o=i*pixels_per_line + pixels_read + k; o = i * pixels_per_line + pixels_read + k;
if(o<len) if (o < len) {
{
got++; got++;
put_user((invert - buffer[k])<<shift, buf+o); put_user((invert - buffer[k]) << shift, buf + o);
} }
} }
pixels_read += bytes; pixels_read += bytes;
} }
(void) qc_readbytes(q, NULL); /* reset state machine */ qc_readbytes(q, NULL); /* reset state machine */
/* Grabbing an entire frame from the quickcam is a lengthy /* Grabbing an entire frame from the quickcam is a lengthy
process. We don't (usually) want to busy-block the process. We don't (usually) want to busy-block the
...@@ -690,14 +659,13 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l ...@@ -690,14 +659,13 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
} }
} }
if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
{
write_lpcontrol(q, 2); write_lpcontrol(q, 2);
write_lpcontrol(q, 6); write_lpcontrol(q, 6);
udelay(3); udelay(3);
write_lpcontrol(q, 0xe); write_lpcontrol(q, 0xe);
} }
if(got<len) if (got < len)
return got; return got;
return len; return len;
} }
...@@ -709,11 +677,10 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l ...@@ -709,11 +677,10 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
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");
...@@ -726,73 +693,73 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) ...@@ -726,73 +693,73 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
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) if (v->channel != 0)
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
case VIDIOCGTUNER: case VIDIOCGTUNER:
{ {
struct video_tuner *v = arg; struct video_tuner *v = arg;
if(v->tuner) if (v->tuner)
return -EINVAL; return -EINVAL;
strcpy(v->name, "Format"); strcpy(v->name, "Format");
v->rangelow=0; v->rangelow = 0;
v->rangehigh=0; v->rangehigh = 0;
v->flags= 0; v->flags = 0;
v->mode = VIDEO_MODE_AUTO; v->mode = VIDEO_MODE_AUTO;
return 0; return 0;
} }
case VIDIOCSTUNER: case VIDIOCSTUNER:
{ {
struct video_tuner *v = arg; struct video_tuner *v = arg;
if(v->tuner) if (v->tuner)
return -EINVAL; return -EINVAL;
if(v->mode!=VIDEO_MODE_AUTO) if (v->mode != VIDEO_MODE_AUTO)
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
case VIDIOCGPICT: case VIDIOCGPICT:
{ {
struct video_picture *p = arg; struct video_picture *p = arg;
p->colour=0x8000; p->colour = 0x8000;
p->hue=0x8000; p->hue = 0x8000;
p->brightness=qcam->brightness<<8; p->brightness = qcam->brightness << 8;
p->contrast=qcam->contrast<<8; p->contrast = qcam->contrast << 8;
p->whiteness=qcam->whitebal<<8; p->whiteness = qcam->whitebal << 8;
p->depth=qcam->bpp; p->depth = qcam->bpp;
p->palette=VIDEO_PALETTE_GREY; p->palette = VIDEO_PALETTE_GREY;
return 0; return 0;
} }
case VIDIOCSPICT: case VIDIOCSPICT:
{ {
struct video_picture *p = arg; struct video_picture *p = arg;
if(p->palette!=VIDEO_PALETTE_GREY) if (p->palette != VIDEO_PALETTE_GREY)
return -EINVAL; return -EINVAL;
if(p->depth!=4 && p->depth!=6) if (p->depth != 4 && p->depth != 6)
return -EINVAL; return -EINVAL;
/* /*
* Now load the camera. * Now load the camera.
*/ */
qcam->brightness = p->brightness>>8; qcam->brightness = p->brightness >> 8;
qcam->contrast = p->contrast>>8; qcam->contrast = p->contrast >> 8;
qcam->whitebal = p->whiteness>>8; qcam->whitebal = p->whiteness >> 8;
qcam->bpp = p->depth; qcam->bpp = p->depth;
mutex_lock(&qcam->lock); mutex_lock(&qcam->lock);
...@@ -802,28 +769,25 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) ...@@ -802,28 +769,25 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
return 0; return 0;
} }
case VIDIOCSWIN: case VIDIOCSWIN:
{ {
struct video_window *vw = arg; struct video_window *vw = arg;
if(vw->flags) if (vw->flags)
return -EINVAL; return -EINVAL;
if(vw->clipcount) if (vw->clipcount)
return -EINVAL; return -EINVAL;
if(vw->height<60||vw->height>240) if (vw->height < 60 || vw->height > 240)
return -EINVAL; return -EINVAL;
if(vw->width<80||vw->width>320) if (vw->width < 80 || vw->width > 320)
return -EINVAL; return -EINVAL;
qcam->width = 320; qcam->width = 320;
qcam->height = 240; qcam->height = 240;
qcam->transfer_scale = 4; qcam->transfer_scale = 4;
if(vw->width>=160 && vw->height>=120) if (vw->width >= 160 && vw->height >= 120)
{
qcam->transfer_scale = 2; qcam->transfer_scale = 2;
} if (vw->width >= 320 && vw->height >= 240) {
if(vw->width>=320 && vw->height>=240)
{
qcam->width = 320; qcam->width = 320;
qcam->height = 240; qcam->height = 240;
qcam->transfer_scale = 1; qcam->transfer_scale = 1;
...@@ -839,41 +803,42 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) ...@@ -839,41 +803,42 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
/* Ok we figured out what to use from our wide choice */ /* Ok we figured out what to use from our wide choice */
return 0; return 0;
} }
case VIDIOCGWIN: case VIDIOCGWIN:
{ {
struct video_window *vw = arg; struct video_window *vw = arg;
memset(vw, 0, sizeof(*vw)); memset(vw, 0, sizeof(*vw));
vw->width=qcam->width/qcam->transfer_scale; vw->width = qcam->width / qcam->transfer_scale;
vw->height=qcam->height/qcam->transfer_scale; vw->height = qcam->height / qcam->transfer_scale;
return 0; return 0;
} }
case VIDIOCKEY: case VIDIOCKEY:
return 0; return 0;
case VIDIOCCAPTURE: case VIDIOCCAPTURE:
case VIDIOCGFBUF: case VIDIOCGFBUF:
case VIDIOCSFBUF: case VIDIOCSFBUF:
case VIDIOCGFREQ: case VIDIOCGFREQ:
case VIDIOCSFREQ: case VIDIOCSFREQ:
case VIDIOCGAUDIO: case VIDIOCGAUDIO:
case VIDIOCSAUDIO: case VIDIOCSAUDIO:
return -EINVAL; return -EINVAL;
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
return 0; return 0;
} }
static long qcam_ioctl(struct file *file, static long qcam_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
return video_usercopy(file, cmd, arg, qcam_do_ioctl); return video_usercopy(file, cmd, arg, qcam_do_ioctl);
} }
static ssize_t qcam_read(struct file *file, char __user *buf, 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;
parport_claim_or_block(qcam->pdev); parport_claim_or_block(qcam->pdev);
...@@ -885,7 +850,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf, ...@@ -885,7 +850,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
if (qcam->status & QC_PARAM_CHANGE) if (qcam->status & QC_PARAM_CHANGE)
qc_set(qcam); qc_set(qcam);
len=qc_capture(qcam, buf,count); len = qc_capture(qcam, buf, count);
mutex_unlock(&qcam->lock); mutex_unlock(&qcam->lock);
...@@ -917,8 +882,7 @@ static const struct v4l2_file_operations qcam_fops = { ...@@ -917,8 +882,7 @@ static const struct v4l2_file_operations qcam_fops = {
.ioctl = qcam_ioctl, .ioctl = qcam_ioctl,
.read = qcam_read, .read = qcam_read,
}; };
static struct video_device qcam_template= static struct video_device qcam_template = {
{
.name = "Connectix Quickcam", .name = "Connectix Quickcam",
.fops = &qcam_fops, .fops = &qcam_fops,
.release = video_device_release_empty, .release = video_device_release_empty,
...@@ -932,22 +896,20 @@ static int init_bwqcam(struct parport *port) ...@@ -932,22 +896,20 @@ static int init_bwqcam(struct parport *port)
{ {
struct qcam_device *qcam; struct qcam_device *qcam;
if (num_cams == MAX_CAMS) if (num_cams == MAX_CAMS) {
{
printk(KERN_ERR "Too many Quickcams (max %d)\n", MAX_CAMS); printk(KERN_ERR "Too many Quickcams (max %d)\n", MAX_CAMS);
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(qc_detect(qcam)==0) if (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);
...@@ -1045,12 +1007,12 @@ static int __init init_bw_qcams(void) ...@@ -1045,12 +1007,12 @@ static int __init init_bw_qcams(void)
#ifdef MODULE #ifdef MODULE
/* Do some sanity checks on the module parameters. */ /* Do some sanity checks on the module parameters. */
if (maxpoll > 5000) { if (maxpoll > 5000) {
printk("Connectix Quickcam max-poll was above 5000. Using 5000.\n"); printk(KERN_INFO "Connectix Quickcam max-poll was above 5000. Using 5000.\n");
maxpoll = 5000; maxpoll = 5000;
} }
if (yieldlines < 1) { if (yieldlines < 1) {
printk("Connectix Quickcam yieldlines was less than 1. Using 1.\n"); printk(KERN_INFO "Connectix Quickcam yieldlines was less than 1. Using 1.\n");
yieldlines = 1; yieldlines = 1;
} }
#endif #endif
......
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