aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-03-22 03:36:04 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:51:26 -0400
commit1d61aac0996d96847e17263a41d34ab54bf8e103 (patch)
tree0a7c1403be71e1ebc6e0e7d3f43b669d37144ef5
parent51224aa436238940e09e479db9c600cecfbebd20 (diff)
V4L/DVB: bw-qcam: coding style cleanup
Clean up the coding style before we convert this driver to V4L2. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/bw-qcam.c452
1 files changed, 207 insertions, 245 deletions
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 9e39bc5f7b00..3c9e754d73a0 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -80,8 +80,8 @@ OTHER DEALINGS IN THE SOFTWARE.
80 80
81#include "bw-qcam.h" 81#include "bw-qcam.h"
82 82
83static unsigned int maxpoll=250; /* Maximum busy-loop count for qcam I/O */ 83static unsigned int maxpoll = 250; /* Maximum busy-loop count for qcam I/O */
84static unsigned int yieldlines=4; /* Yield after this many during capture */ 84static unsigned int yieldlines = 4; /* Yield after this many during capture */
85static int video_nr = -1; 85static int video_nr = -1;
86static unsigned int force_init; /* Whether to probe aggressively */ 86static unsigned int force_init; /* Whether to probe aggressively */
87 87
@@ -156,7 +156,7 @@ static int qc_calibrate(struct qcam_device *q)
156 mdelay(1); 156 mdelay(1);
157 schedule(); 157 schedule();
158 count++; 158 count++;
159 } while (value == 0xff && count<2048); 159 } while (value == 0xff && count < 2048);
160 160
161 q->whitebal = value; 161 q->whitebal = value;
162 return value; 162 return value;
@@ -170,16 +170,15 @@ static struct qcam_device *qcam_init(struct parport *port)
170 struct qcam_device *q; 170 struct qcam_device *q;
171 171
172 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL); 172 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
173 if(q==NULL) 173 if (q == NULL)
174 return NULL; 174 return NULL;
175 175
176 q->pport = port; 176 q->pport = port;
177 q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL, 177 q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL,
178 NULL, 0, NULL); 178 NULL, 0, NULL);
179 if (q->pdev == NULL) 179 if (q->pdev == NULL) {
180 {
181 printk(KERN_ERR "bw-qcam: couldn't register for %s.\n", 180 printk(KERN_ERR "bw-qcam: couldn't register for %s.\n",
182 port->name); 181 port->name);
183 kfree(q); 182 kfree(q);
184 return NULL; 183 return NULL;
185 } 184 }
@@ -247,12 +246,10 @@ static int qc_readparam(struct qcam_device *q)
247static int qc_waithand(struct qcam_device *q, int val) 246static int qc_waithand(struct qcam_device *q, int val)
248{ 247{
249 int status; 248 int status;
250 int runs=0; 249 int runs = 0;
251 250
252 if (val) 251 if (val) {
253 { 252 while (!((status = read_lpstatus(q)) & 8)) {
254 while (!((status = read_lpstatus(q)) & 8))
255 {
256 /* 1000 is enough spins on the I/O for all normal 253 /* 1000 is enough spins on the I/O for all normal
257 cases, at that point we start to poll slowly 254 cases, at that point we start to poll slowly
258 until the camera wakes up. However, we are 255 until the camera wakes up. However, we are
@@ -260,18 +257,13 @@ static int qc_waithand(struct qcam_device *q, int val)
260 setting it lower is much better for interactive 257 setting it lower is much better for interactive
261 response. */ 258 response. */
262 259
263 if(runs++>maxpoll) 260 if (runs++ > maxpoll)
264 {
265 msleep_interruptible(5); 261 msleep_interruptible(5);
266 } 262 if (runs > (maxpoll + 1000)) /* 5 seconds */
267 if(runs>(maxpoll+1000)) /* 5 seconds */
268 return -1; 263 return -1;
269 } 264 }
270 } 265 } else {
271 else 266 while (((status = read_lpstatus(q)) & 8)) {
272 {
273 while (((status = read_lpstatus(q)) & 8))
274 {
275 /* 1000 is enough spins on the I/O for all normal 267 /* 1000 is enough spins on the I/O for all normal
276 cases, at that point we start to poll slowly 268 cases, at that point we start to poll slowly
277 until the camera wakes up. However, we are 269 until the camera wakes up. However, we are
@@ -279,11 +271,9 @@ static int qc_waithand(struct qcam_device *q, int val)
279 setting it lower is much better for interactive 271 setting it lower is much better for interactive
280 response. */ 272 response. */
281 273
282 if(runs++>maxpoll) 274 if (runs++ > maxpoll)
283 {
284 msleep_interruptible(5); 275 msleep_interruptible(5);
285 } 276 if (runs++ > (maxpoll + 1000)) /* 5 seconds */
286 if(runs++>(maxpoll+1000)) /* 5 seconds */
287 return -1; 277 return -1;
288 } 278 }
289 } 279 }
@@ -299,10 +289,9 @@ static int qc_waithand(struct qcam_device *q, int val)
299static unsigned int qc_waithand2(struct qcam_device *q, int val) 289static unsigned int qc_waithand2(struct qcam_device *q, int val)
300{ 290{
301 unsigned int status; 291 unsigned int status;
302 int runs=0; 292 int runs = 0;
303 293
304 do 294 do {
305 {
306 status = read_lpdata(q); 295 status = read_lpdata(q);
307 /* 1000 is enough spins on the I/O for all normal 296 /* 1000 is enough spins on the I/O for all normal
308 cases, at that point we start to poll slowly 297 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 setting it lower is much better for interactive 300 setting it lower is much better for interactive
312 response. */ 301 response. */
313 302
314 if(runs++>maxpoll) 303 if (runs++ > maxpoll)
315 {
316 msleep_interruptible(5); 304 msleep_interruptible(5);
317 } 305 if (runs++ > (maxpoll + 1000)) /* 5 seconds */
318 if(runs++>(maxpoll+1000)) /* 5 seconds */
319 return 0; 306 return 0;
320 } 307 } while ((status & 1) != val);
321 while ((status & 1) != val);
322 308
323 return status; 309 return status;
324} 310}
@@ -342,8 +328,7 @@ static int qc_detect(struct qcam_device *q)
342 328
343 lastreg = reg = read_lpstatus(q) & 0xf0; 329 lastreg = reg = read_lpstatus(q) & 0xf0;
344 330
345 for (i = 0; i < 500; i++) 331 for (i = 0; i < 500; i++) {
346 {
347 reg = read_lpstatus(q) & 0xf0; 332 reg = read_lpstatus(q) & 0xf0;
348 if (reg != lastreg) 333 if (reg != lastreg)
349 count++; 334 count++;
@@ -357,7 +342,7 @@ static int qc_detect(struct qcam_device *q)
357 won't be flashing these bits. Possibly unloading the module 342 won't be flashing these bits. Possibly unloading the module
358 in the middle of a grab? Or some timeout condition? 343 in the middle of a grab? Or some timeout condition?
359 I've seen this parameter as low as 19 on my 450Mhz box - mpc */ 344 I've seen this parameter as low as 19 on my 450Mhz box - mpc */
360 printk("Debugging: QCam detection counter <30-200 counts as detected>: %d\n", count); 345 printk(KERN_DEBUG "Debugging: QCam detection counter <30-200 counts as detected>: %d\n", count);
361 return 1; 346 return 1;
362#endif 347#endif
363 348
@@ -367,7 +352,7 @@ static int qc_detect(struct qcam_device *q)
367 return 1; /* found */ 352 return 1; /* found */
368 } else { 353 } else {
369 printk(KERN_ERR "No Quickcam found on port %s\n", 354 printk(KERN_ERR "No Quickcam found on port %s\n",
370 q->pport->name); 355 q->pport->name);
371 printk(KERN_DEBUG "Quickcam detection counter: %u\n", count); 356 printk(KERN_DEBUG "Quickcam detection counter: %u\n", count);
372 return 0; /* not found */ 357 return 0; /* not found */
373 } 358 }
@@ -381,26 +366,24 @@ static int qc_detect(struct qcam_device *q)
381 366
382static void qc_reset(struct qcam_device *q) 367static void qc_reset(struct qcam_device *q)
383{ 368{
384 switch (q->port_mode & QC_FORCE_MASK) 369 switch (q->port_mode & QC_FORCE_MASK) {
385 { 370 case QC_FORCE_UNIDIR:
386 case QC_FORCE_UNIDIR: 371 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
387 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; 372 break;
388 break;
389 373
390 case QC_FORCE_BIDIR: 374 case QC_FORCE_BIDIR:
391 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; 375 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
392 break; 376 break;
393 377
394 case QC_ANY: 378 case QC_ANY:
395 write_lpcontrol(q, 0x20); 379 write_lpcontrol(q, 0x20);
396 write_lpdata(q, 0x75); 380 write_lpdata(q, 0x75);
397 381
398 if (read_lpdata(q) != 0x75) { 382 if (read_lpdata(q) != 0x75)
399 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; 383 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
400 } else { 384 else
401 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; 385 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
402 } 386 break;
403 break;
404 } 387 }
405 388
406 write_lpcontrol(q, 0xb); 389 write_lpcontrol(q, 0xb);
@@ -423,36 +406,33 @@ static int qc_setscanmode(struct qcam_device *q)
423{ 406{
424 int old_mode = q->mode; 407 int old_mode = q->mode;
425 408
426 switch (q->transfer_scale) 409 switch (q->transfer_scale) {
427 { 410 case 1:
428 case 1: 411 q->mode = 0;
429 q->mode = 0; 412 break;
430 break; 413 case 2:
431 case 2: 414 q->mode = 4;
432 q->mode = 4; 415 break;
433 break; 416 case 4:
434 case 4: 417 q->mode = 8;
435 q->mode = 8; 418 break;
436 break;
437 } 419 }
438 420
439 switch (q->bpp) 421 switch (q->bpp) {
440 { 422 case 4:
441 case 4: 423 break;
442 break; 424 case 6:
443 case 6: 425 q->mode += 2;
444 q->mode += 2; 426 break;
445 break;
446 } 427 }
447 428
448 switch (q->port_mode & QC_MODE_MASK) 429 switch (q->port_mode & QC_MODE_MASK) {
449 { 430 case QC_BIDIR:
450 case QC_BIDIR: 431 q->mode += 1;
451 q->mode += 1; 432 break;
452 break; 433 case QC_NOTSET:
453 case QC_NOTSET: 434 case QC_UNIDIR:
454 case QC_UNIDIR: 435 break;
455 break;
456 } 436 }
457 437
458 if (q->mode != old_mode) 438 if (q->mode != old_mode)
@@ -493,7 +473,7 @@ static void qc_set(struct qcam_device *q)
493 } else { 473 } else {
494 val = q->width * q->bpp; 474 val = q->width * q->bpp;
495 val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) * 475 val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
496 q->transfer_scale; 476 q->transfer_scale;
497 } 477 }
498 val = DIV_ROUND_UP(val, val2); 478 val = DIV_ROUND_UP(val, val2);
499 qc_command(q, 0x13); 479 qc_command(q, 0x13);
@@ -521,85 +501,80 @@ static void qc_set(struct qcam_device *q)
521 501
522static inline int qc_readbytes(struct qcam_device *q, char buffer[]) 502static inline int qc_readbytes(struct qcam_device *q, char buffer[])
523{ 503{
524 int ret=1; 504 int ret = 1;
525 unsigned int hi, lo; 505 unsigned int hi, lo;
526 unsigned int hi2, lo2; 506 unsigned int hi2, lo2;
527 static int state; 507 static int state;
528 508
529 if (buffer == NULL) 509 if (buffer == NULL) {
530 {
531 state = 0; 510 state = 0;
532 return 0; 511 return 0;
533 } 512 }
534 513
535 switch (q->port_mode & QC_MODE_MASK) 514 switch (q->port_mode & QC_MODE_MASK) {
536 { 515 case QC_BIDIR: /* Bi-directional Port */
537 case QC_BIDIR: /* Bi-directional Port */ 516 write_lpcontrol(q, 0x26);
538 write_lpcontrol(q, 0x26); 517 lo = (qc_waithand2(q, 1) >> 1);
539 lo = (qc_waithand2(q, 1) >> 1); 518 hi = (read_lpstatus(q) >> 3) & 0x1f;
540 hi = (read_lpstatus(q) >> 3) & 0x1f; 519 write_lpcontrol(q, 0x2e);
541 write_lpcontrol(q, 0x2e); 520 lo2 = (qc_waithand2(q, 0) >> 1);
542 lo2 = (qc_waithand2(q, 0) >> 1); 521 hi2 = (read_lpstatus(q) >> 3) & 0x1f;
543 hi2 = (read_lpstatus(q) >> 3) & 0x1f; 522 switch (q->bpp) {
544 switch (q->bpp) 523 case 4:
545 { 524 buffer[0] = lo & 0xf;
546 case 4: 525 buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3);
547 buffer[0] = lo & 0xf; 526 buffer[2] = (hi & 0x1e) >> 1;
548 buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3); 527 buffer[3] = lo2 & 0xf;
549 buffer[2] = (hi & 0x1e) >> 1; 528 buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3);
550 buffer[3] = lo2 & 0xf; 529 buffer[5] = (hi2 & 0x1e) >> 1;
551 buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3); 530 ret = 6;
552 buffer[5] = (hi2 & 0x1e) >> 1; 531 break;
553 ret = 6; 532 case 6:
554 break; 533 buffer[0] = lo & 0x3f;
555 case 6: 534 buffer[1] = ((lo & 0x40) >> 6) | (hi << 1);
556 buffer[0] = lo & 0x3f; 535 buffer[2] = lo2 & 0x3f;
557 buffer[1] = ((lo & 0x40) >> 6) | (hi << 1); 536 buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1);
558 buffer[2] = lo2 & 0x3f; 537 ret = 4;
559 buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1);
560 ret = 4;
561 break;
562 }
563 break; 538 break;
539 }
540 break;
541
542 case QC_UNIDIR: /* Unidirectional Port */
543 write_lpcontrol(q, 6);
544 lo = (qc_waithand(q, 1) & 0xf0) >> 4;
545 write_lpcontrol(q, 0xe);
546 hi = (qc_waithand(q, 0) & 0xf0) >> 4;
564 547
565 case QC_UNIDIR: /* Unidirectional Port */ 548 switch (q->bpp) {
566 write_lpcontrol(q, 6); 549 case 4:
567 lo = (qc_waithand(q, 1) & 0xf0) >> 4; 550 buffer[0] = lo;
568 write_lpcontrol(q, 0xe); 551 buffer[1] = hi;
569 hi = (qc_waithand(q, 0) & 0xf0) >> 4; 552 ret = 2;
570 553 break;
571 switch (q->bpp) 554 case 6:
572 { 555 switch (state) {
573 case 4: 556 case 0:
574 buffer[0] = lo; 557 buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
575 buffer[1] = hi; 558 q->saved_bits = (hi & 3) << 4;
576 ret = 2; 559 state = 1;
577 break; 560 ret = 1;
578 case 6: 561 break;
579 switch (state) 562 case 1:
580 { 563 buffer[0] = lo | q->saved_bits;
581 case 0: 564 q->saved_bits = hi << 2;
582 buffer[0] = (lo << 2) | ((hi & 0xc) >> 2); 565 state = 2;
583 q->saved_bits = (hi & 3) << 4; 566 ret = 1;
584 state = 1; 567 break;
585 ret = 1; 568 case 2:
586 break; 569 buffer[0] = ((lo & 0xc) >> 2) | q->saved_bits;
587 case 1: 570 buffer[1] = ((lo & 3) << 4) | hi;
588 buffer[0] = lo | q->saved_bits; 571 state = 0;
589 q->saved_bits = hi << 2; 572 ret = 2;
590 state = 2; 573 break;
591 ret = 1;
592 break;
593 case 2:
594 buffer[0] = ((lo & 0xc) >> 2) | q->saved_bits;
595 buffer[1] = ((lo & 3) << 4) | hi;
596 state = 0;
597 ret = 2;
598 break;
599 }
600 break;
601 } 574 }
602 break; 575 break;
576 }
577 break;
603 } 578 }
604 return ret; 579 return ret;
605} 580}
@@ -615,7 +590,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
615 * n=2^(bit depth)-1. Ask me for more details if you don't understand 590 * n=2^(bit depth)-1. Ask me for more details if you don't understand
616 * this. */ 591 * this. */
617 592
618static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long len) 593static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long len)
619{ 594{
620 int i, j, k, yield; 595 int i, j, k, yield;
621 int bytes; 596 int bytes;
@@ -623,9 +598,9 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
623 int divisor; 598 int divisor;
624 int pixels_per_line; 599 int pixels_per_line;
625 int pixels_read = 0; 600 int pixels_read = 0;
626 int got=0; 601 int got = 0;
627 char buffer[6]; 602 char buffer[6];
628 int shift=8-q->bpp; 603 int shift = 8 - q->bpp;
629 char invert; 604 char invert;
630 605
631 if (q->mode == -1) 606 if (q->mode == -1)
@@ -634,13 +609,12 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
634 qc_command(q, 0x7); 609 qc_command(q, 0x7);
635 qc_command(q, q->mode); 610 qc_command(q, q->mode);
636 611
637 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) 612 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
638 {
639 write_lpcontrol(q, 0x2e); /* turn port around */ 613 write_lpcontrol(q, 0x2e); /* turn port around */
640 write_lpcontrol(q, 0x26); 614 write_lpcontrol(q, 0x26);
641 (void) qc_waithand(q, 1); 615 qc_waithand(q, 1);
642 write_lpcontrol(q, 0x2e); 616 write_lpcontrol(q, 0x2e);
643 (void) qc_waithand(q, 0); 617 qc_waithand(q, 0);
644 } 618 }
645 619
646 /* strange -- should be 15:63 below, but 4bpp is odd */ 620 /* 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 pixels_per_line = q->width / q->transfer_scale; 624 pixels_per_line = q->width / q->transfer_scale;
651 transperline = q->width * q->bpp; 625 transperline = q->width * q->bpp;
652 divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) * 626 divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
653 q->transfer_scale; 627 q->transfer_scale;
654 transperline = DIV_ROUND_UP(transperline, divisor); 628 transperline = DIV_ROUND_UP(transperline, divisor);
655 629
656 for (i = 0, yield = yieldlines; i < linestotrans; i++) 630 for (i = 0, yield = yieldlines; i < linestotrans; i++) {
657 { 631 for (pixels_read = j = 0; j < transperline; j++) {
658 for (pixels_read = j = 0; j < transperline; j++)
659 {
660 bytes = qc_readbytes(q, buffer); 632 bytes = qc_readbytes(q, buffer);
661 for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) 633 for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) {
662 {
663 int o; 634 int o;
664 if (buffer[k] == 0 && invert == 16) 635 if (buffer[k] == 0 && invert == 16) {
665 {
666 /* 4bpp is odd (again) -- inverter is 16, not 15, but output 636 /* 4bpp is odd (again) -- inverter is 16, not 15, but output
667 must be 0-15 -- bls */ 637 must be 0-15 -- bls */
668 buffer[k] = 16; 638 buffer[k] = 16;
669 } 639 }
670 o=i*pixels_per_line + pixels_read + k; 640 o = i * pixels_per_line + pixels_read + k;
671 if(o<len) 641 if (o < len) {
672 {
673 got++; 642 got++;
674 put_user((invert - buffer[k])<<shift, buf+o); 643 put_user((invert - buffer[k]) << shift, buf + o);
675 } 644 }
676 } 645 }
677 pixels_read += bytes; 646 pixels_read += bytes;
678 } 647 }
679 (void) qc_readbytes(q, NULL); /* reset state machine */ 648 qc_readbytes(q, NULL); /* reset state machine */
680 649
681 /* Grabbing an entire frame from the quickcam is a lengthy 650 /* Grabbing an entire frame from the quickcam is a lengthy
682 process. We don't (usually) want to busy-block the 651 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 } 659 }
691 } 660 }
692 661
693 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) 662 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
694 {
695 write_lpcontrol(q, 2); 663 write_lpcontrol(q, 2);
696 write_lpcontrol(q, 6); 664 write_lpcontrol(q, 6);
697 udelay(3); 665 udelay(3);
698 write_lpcontrol(q, 0xe); 666 write_lpcontrol(q, 0xe);
699 } 667 }
700 if(got<len) 668 if (got < len)
701 return got; 669 return got;
702 return len; 670 return len;
703} 671}
@@ -709,11 +677,10 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
709static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) 677static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
710{ 678{
711 struct video_device *dev = video_devdata(file); 679 struct video_device *dev = video_devdata(file);
712 struct qcam_device *qcam=(struct qcam_device *)dev; 680 struct qcam_device *qcam = (struct qcam_device *)dev;
713 681
714 switch(cmd) 682 switch (cmd) {
715 { 683 case VIDIOCGCAP:
716 case VIDIOCGCAP:
717 { 684 {
718 struct video_capability *b = arg; 685 struct video_capability *b = arg;
719 strcpy(b->name, "Quickcam"); 686 strcpy(b->name, "Quickcam");
@@ -726,73 +693,73 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
726 b->minheight = 60; 693 b->minheight = 60;
727 return 0; 694 return 0;
728 } 695 }
729 case VIDIOCGCHAN: 696 case VIDIOCGCHAN:
730 { 697 {
731 struct video_channel *v = arg; 698 struct video_channel *v = arg;
732 if(v->channel!=0) 699 if (v->channel != 0)
733 return -EINVAL; 700 return -EINVAL;
734 v->flags=0; 701 v->flags = 0;
735 v->tuners=0; 702 v->tuners = 0;
736 /* Good question.. its composite or SVHS so.. */ 703 /* Good question.. its composite or SVHS so.. */
737 v->type = VIDEO_TYPE_CAMERA; 704 v->type = VIDEO_TYPE_CAMERA;
738 strcpy(v->name, "Camera"); 705 strcpy(v->name, "Camera");
739 return 0; 706 return 0;
740 } 707 }
741 case VIDIOCSCHAN: 708 case VIDIOCSCHAN:
742 { 709 {
743 struct video_channel *v = arg; 710 struct video_channel *v = arg;
744 if(v->channel!=0) 711 if (v->channel != 0)
745 return -EINVAL; 712 return -EINVAL;
746 return 0; 713 return 0;
747 } 714 }
748 case VIDIOCGTUNER: 715 case VIDIOCGTUNER:
749 { 716 {
750 struct video_tuner *v = arg; 717 struct video_tuner *v = arg;
751 if(v->tuner) 718 if (v->tuner)
752 return -EINVAL; 719 return -EINVAL;
753 strcpy(v->name, "Format"); 720 strcpy(v->name, "Format");
754 v->rangelow=0; 721 v->rangelow = 0;
755 v->rangehigh=0; 722 v->rangehigh = 0;
756 v->flags= 0; 723 v->flags = 0;
757 v->mode = VIDEO_MODE_AUTO; 724 v->mode = VIDEO_MODE_AUTO;
758 return 0; 725 return 0;
759 } 726 }
760 case VIDIOCSTUNER: 727 case VIDIOCSTUNER:
761 { 728 {
762 struct video_tuner *v = arg; 729 struct video_tuner *v = arg;
763 if(v->tuner) 730 if (v->tuner)
764 return -EINVAL; 731 return -EINVAL;
765 if(v->mode!=VIDEO_MODE_AUTO) 732 if (v->mode != VIDEO_MODE_AUTO)
766 return -EINVAL; 733 return -EINVAL;
767 return 0; 734 return 0;
768 } 735 }
769 case VIDIOCGPICT: 736 case VIDIOCGPICT:
770 { 737 {
771 struct video_picture *p = arg; 738 struct video_picture *p = arg;
772 p->colour=0x8000; 739 p->colour = 0x8000;
773 p->hue=0x8000; 740 p->hue = 0x8000;
774 p->brightness=qcam->brightness<<8; 741 p->brightness = qcam->brightness << 8;
775 p->contrast=qcam->contrast<<8; 742 p->contrast = qcam->contrast << 8;
776 p->whiteness=qcam->whitebal<<8; 743 p->whiteness = qcam->whitebal << 8;
777 p->depth=qcam->bpp; 744 p->depth = qcam->bpp;
778 p->palette=VIDEO_PALETTE_GREY; 745 p->palette = VIDEO_PALETTE_GREY;
779 return 0; 746 return 0;
780 } 747 }
781 case VIDIOCSPICT: 748 case VIDIOCSPICT:
782 { 749 {
783 struct video_picture *p = arg; 750 struct video_picture *p = arg;
784 if(p->palette!=VIDEO_PALETTE_GREY) 751 if (p->palette != VIDEO_PALETTE_GREY)
785 return -EINVAL; 752 return -EINVAL;
786 if(p->depth!=4 && p->depth!=6) 753 if (p->depth != 4 && p->depth != 6)
787 return -EINVAL; 754 return -EINVAL;
788 755
789 /* 756 /*
790 * Now load the camera. 757 * Now load the camera.
791 */ 758 */
792 759
793 qcam->brightness = p->brightness>>8; 760 qcam->brightness = p->brightness >> 8;
794 qcam->contrast = p->contrast>>8; 761 qcam->contrast = p->contrast >> 8;
795 qcam->whitebal = p->whiteness>>8; 762 qcam->whitebal = p->whiteness >> 8;
796 qcam->bpp = p->depth; 763 qcam->bpp = p->depth;
797 764
798 mutex_lock(&qcam->lock); 765 mutex_lock(&qcam->lock);
@@ -802,28 +769,25 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
802 769
803 return 0; 770 return 0;
804 } 771 }
805 case VIDIOCSWIN: 772 case VIDIOCSWIN:
806 { 773 {
807 struct video_window *vw = arg; 774 struct video_window *vw = arg;
808 if(vw->flags) 775 if (vw->flags)
809 return -EINVAL; 776 return -EINVAL;
810 if(vw->clipcount) 777 if (vw->clipcount)
811 return -EINVAL; 778 return -EINVAL;
812 if(vw->height<60||vw->height>240) 779 if (vw->height < 60 || vw->height > 240)
813 return -EINVAL; 780 return -EINVAL;
814 if(vw->width<80||vw->width>320) 781 if (vw->width < 80 || vw->width > 320)
815 return -EINVAL; 782 return -EINVAL;
816 783
817 qcam->width = 320; 784 qcam->width = 320;
818 qcam->height = 240; 785 qcam->height = 240;
819 qcam->transfer_scale = 4; 786 qcam->transfer_scale = 4;
820 787
821 if(vw->width>=160 && vw->height>=120) 788 if (vw->width >= 160 && vw->height >= 120)
822 {
823 qcam->transfer_scale = 2; 789 qcam->transfer_scale = 2;
824 } 790 if (vw->width >= 320 && vw->height >= 240) {
825 if(vw->width>=320 && vw->height>=240)
826 {
827 qcam->width = 320; 791 qcam->width = 320;
828 qcam->height = 240; 792 qcam->height = 240;
829 qcam->transfer_scale = 1; 793 qcam->transfer_scale = 1;
@@ -839,41 +803,42 @@ static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
839 /* Ok we figured out what to use from our wide choice */ 803 /* Ok we figured out what to use from our wide choice */
840 return 0; 804 return 0;
841 } 805 }
842 case VIDIOCGWIN: 806 case VIDIOCGWIN:
843 { 807 {
844 struct video_window *vw = arg; 808 struct video_window *vw = arg;
809
845 memset(vw, 0, sizeof(*vw)); 810 memset(vw, 0, sizeof(*vw));
846 vw->width=qcam->width/qcam->transfer_scale; 811 vw->width = qcam->width / qcam->transfer_scale;
847 vw->height=qcam->height/qcam->transfer_scale; 812 vw->height = qcam->height / qcam->transfer_scale;
848 return 0; 813 return 0;
849 } 814 }
850 case VIDIOCKEY: 815 case VIDIOCKEY:
851 return 0; 816 return 0;
852 case VIDIOCCAPTURE: 817 case VIDIOCCAPTURE:
853 case VIDIOCGFBUF: 818 case VIDIOCGFBUF:
854 case VIDIOCSFBUF: 819 case VIDIOCSFBUF:
855 case VIDIOCGFREQ: 820 case VIDIOCGFREQ:
856 case VIDIOCSFREQ: 821 case VIDIOCSFREQ:
857 case VIDIOCGAUDIO: 822 case VIDIOCGAUDIO:
858 case VIDIOCSAUDIO: 823 case VIDIOCSAUDIO:
859 return -EINVAL; 824 return -EINVAL;
860 default: 825 default:
861 return -ENOIOCTLCMD; 826 return -ENOIOCTLCMD;
862 } 827 }
863 return 0; 828 return 0;
864} 829}
865 830
866static long qcam_ioctl(struct file *file, 831static long qcam_ioctl(struct file *file,
867 unsigned int cmd, unsigned long arg) 832 unsigned int cmd, unsigned long arg)
868{ 833{
869 return video_usercopy(file, cmd, arg, qcam_do_ioctl); 834 return video_usercopy(file, cmd, arg, qcam_do_ioctl);
870} 835}
871 836
872static ssize_t qcam_read(struct file *file, char __user *buf, 837static ssize_t qcam_read(struct file *file, char __user *buf,
873 size_t count, loff_t *ppos) 838 size_t count, loff_t *ppos)
874{ 839{
875 struct video_device *v = video_devdata(file); 840 struct video_device *v = video_devdata(file);
876 struct qcam_device *qcam=(struct qcam_device *)v; 841 struct qcam_device *qcam = (struct qcam_device *)v;
877 int len; 842 int len;
878 parport_claim_or_block(qcam->pdev); 843 parport_claim_or_block(qcam->pdev);
879 844
@@ -885,7 +850,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
885 if (qcam->status & QC_PARAM_CHANGE) 850 if (qcam->status & QC_PARAM_CHANGE)
886 qc_set(qcam); 851 qc_set(qcam);
887 852
888 len=qc_capture(qcam, buf,count); 853 len = qc_capture(qcam, buf, count);
889 854
890 mutex_unlock(&qcam->lock); 855 mutex_unlock(&qcam->lock);
891 856
@@ -917,8 +882,7 @@ static const struct v4l2_file_operations qcam_fops = {
917 .ioctl = qcam_ioctl, 882 .ioctl = qcam_ioctl,
918 .read = qcam_read, 883 .read = qcam_read,
919}; 884};
920static struct video_device qcam_template= 885static struct video_device qcam_template = {
921{
922 .name = "Connectix Quickcam", 886 .name = "Connectix Quickcam",
923 .fops = &qcam_fops, 887 .fops = &qcam_fops,
924 .release = video_device_release_empty, 888 .release = video_device_release_empty,
@@ -932,22 +896,20 @@ static int init_bwqcam(struct parport *port)
932{ 896{
933 struct qcam_device *qcam; 897 struct qcam_device *qcam;
934 898
935 if (num_cams == MAX_CAMS) 899 if (num_cams == MAX_CAMS) {
936 {
937 printk(KERN_ERR "Too many Quickcams (max %d)\n", MAX_CAMS); 900 printk(KERN_ERR "Too many Quickcams (max %d)\n", MAX_CAMS);
938 return -ENOSPC; 901 return -ENOSPC;
939 } 902 }
940 903
941 qcam=qcam_init(port); 904 qcam = qcam_init(port);
942 if(qcam==NULL) 905 if (qcam == NULL)
943 return -ENODEV; 906 return -ENODEV;
944 907
945 parport_claim_or_block(qcam->pdev); 908 parport_claim_or_block(qcam->pdev);
946 909
947 qc_reset(qcam); 910 qc_reset(qcam);
948 911
949 if(qc_detect(qcam)==0) 912 if (qc_detect(qcam) == 0) {
950 {
951 parport_release(qcam->pdev); 913 parport_release(qcam->pdev);
952 parport_unregister_device(qcam->pdev); 914 parport_unregister_device(qcam->pdev);
953 kfree(qcam); 915 kfree(qcam);
@@ -1045,12 +1007,12 @@ static int __init init_bw_qcams(void)
1045#ifdef MODULE 1007#ifdef MODULE
1046 /* Do some sanity checks on the module parameters. */ 1008 /* Do some sanity checks on the module parameters. */
1047 if (maxpoll > 5000) { 1009 if (maxpoll > 5000) {
1048 printk("Connectix Quickcam max-poll was above 5000. Using 5000.\n"); 1010 printk(KERN_INFO "Connectix Quickcam max-poll was above 5000. Using 5000.\n");
1049 maxpoll = 5000; 1011 maxpoll = 5000;
1050 } 1012 }
1051 1013
1052 if (yieldlines < 1) { 1014 if (yieldlines < 1) {
1053 printk("Connectix Quickcam yieldlines was less than 1. Using 1.\n"); 1015 printk(KERN_INFO "Connectix Quickcam yieldlines was less than 1. Using 1.\n");
1054 yieldlines = 1; 1016 yieldlines = 1;
1055 } 1017 }
1056#endif 1018#endif