aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sunplus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/sunplus.c')
-rw-r--r--drivers/media/video/gspca/sunplus.c237
1 files changed, 114 insertions, 123 deletions
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index 72bf3b4f0a31..716df6b15fc5 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -460,13 +460,17 @@ static void reg_r(struct gspca_dev *gspca_dev,
460 u16 index, 460 u16 index,
461 u16 len) 461 u16 len)
462{ 462{
463 int ret;
464
463#ifdef GSPCA_DEBUG 465#ifdef GSPCA_DEBUG
464 if (len > USB_BUF_SZ) { 466 if (len > USB_BUF_SZ) {
465 err("reg_r: buffer overflow"); 467 err("reg_r: buffer overflow");
466 return; 468 return;
467 } 469 }
468#endif 470#endif
469 usb_control_msg(gspca_dev->dev, 471 if (gspca_dev->usb_err < 0)
472 return;
473 ret = usb_control_msg(gspca_dev->dev,
470 usb_rcvctrlpipe(gspca_dev->dev, 0), 474 usb_rcvctrlpipe(gspca_dev->dev, 0),
471 req, 475 req,
472 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 476 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
@@ -474,6 +478,10 @@ static void reg_r(struct gspca_dev *gspca_dev,
474 index, 478 index,
475 len ? gspca_dev->usb_buf : NULL, len, 479 len ? gspca_dev->usb_buf : NULL, len,
476 500); 480 500);
481 if (ret < 0) {
482 PDEBUG(D_ERR, "reg_r err %d", ret);
483 gspca_dev->usb_err = ret;
484 }
477} 485}
478 486
479/* write one byte */ 487/* write one byte */
@@ -483,40 +491,55 @@ static void reg_w_1(struct gspca_dev *gspca_dev,
483 u16 index, 491 u16 index,
484 u16 byte) 492 u16 byte)
485{ 493{
494 int ret;
495
496 if (gspca_dev->usb_err < 0)
497 return;
486 gspca_dev->usb_buf[0] = byte; 498 gspca_dev->usb_buf[0] = byte;
487 usb_control_msg(gspca_dev->dev, 499 ret = usb_control_msg(gspca_dev->dev,
488 usb_sndctrlpipe(gspca_dev->dev, 0), 500 usb_sndctrlpipe(gspca_dev->dev, 0),
489 req, 501 req,
490 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 502 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
491 value, index, 503 value, index,
492 gspca_dev->usb_buf, 1, 504 gspca_dev->usb_buf, 1,
493 500); 505 500);
506 if (ret < 0) {
507 PDEBUG(D_ERR, "reg_w_1 err %d", ret);
508 gspca_dev->usb_err = ret;
509 }
494} 510}
495 511
496/* write req / index / value */ 512/* write req / index / value */
497static int reg_w_riv(struct usb_device *dev, 513static void reg_w_riv(struct gspca_dev *gspca_dev,
498 u8 req, u16 index, u16 value) 514 u8 req, u16 index, u16 value)
499{ 515{
516 struct usb_device *dev = gspca_dev->dev;
500 int ret; 517 int ret;
501 518
519 if (gspca_dev->usb_err < 0)
520 return;
502 ret = usb_control_msg(dev, 521 ret = usb_control_msg(dev,
503 usb_sndctrlpipe(dev, 0), 522 usb_sndctrlpipe(dev, 0),
504 req, 523 req,
505 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 524 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
506 value, index, NULL, 0, 500); 525 value, index, NULL, 0, 500);
507 PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d", 526 if (ret < 0) {
508 req, index, value, ret); 527 PDEBUG(D_ERR, "reg_w_riv err %d", ret);
509 if (ret < 0) 528 gspca_dev->usb_err = ret;
510 PDEBUG(D_ERR, "reg write: error %d", ret); 529 return;
511 return ret; 530 }
531 PDEBUG(D_USBO, "reg_w_riv: 0x%02x,0x%04x:0x%04x",
532 req, index, value);
512} 533}
513 534
514/* read 1 byte */ 535/* read 1 byte */
515static int reg_r_1(struct gspca_dev *gspca_dev, 536static u8 reg_r_1(struct gspca_dev *gspca_dev,
516 u16 value) /* wValue */ 537 u16 value) /* wValue */
517{ 538{
518 int ret; 539 int ret;
519 540
541 if (gspca_dev->usb_err < 0)
542 return 0;
520 ret = usb_control_msg(gspca_dev->dev, 543 ret = usb_control_msg(gspca_dev->dev,
521 usb_rcvctrlpipe(gspca_dev->dev, 0), 544 usb_rcvctrlpipe(gspca_dev->dev, 0),
522 0x20, /* request */ 545 0x20, /* request */
@@ -527,19 +550,22 @@ static int reg_r_1(struct gspca_dev *gspca_dev,
527 500); /* timeout */ 550 500); /* timeout */
528 if (ret < 0) { 551 if (ret < 0) {
529 PDEBUG(D_ERR, "reg_r_1 err %d", ret); 552 PDEBUG(D_ERR, "reg_r_1 err %d", ret);
553 gspca_dev->usb_err = ret;
530 return 0; 554 return 0;
531 } 555 }
532 return gspca_dev->usb_buf[0]; 556 return gspca_dev->usb_buf[0];
533} 557}
534 558
535/* read 1 or 2 bytes - returns < 0 if error */ 559/* read 1 or 2 bytes */
536static int reg_r_12(struct gspca_dev *gspca_dev, 560static u16 reg_r_12(struct gspca_dev *gspca_dev,
537 u8 req, /* bRequest */ 561 u8 req, /* bRequest */
538 u16 index, /* wIndex */ 562 u16 index, /* wIndex */
539 u16 length) /* wLength (1 or 2 only) */ 563 u16 length) /* wLength (1 or 2 only) */
540{ 564{
541 int ret; 565 int ret;
542 566
567 if (gspca_dev->usb_err < 0)
568 return 0;
543 gspca_dev->usb_buf[1] = 0; 569 gspca_dev->usb_buf[1] = 0;
544 ret = usb_control_msg(gspca_dev->dev, 570 ret = usb_control_msg(gspca_dev->dev,
545 usb_rcvctrlpipe(gspca_dev->dev, 0), 571 usb_rcvctrlpipe(gspca_dev->dev, 0),
@@ -550,62 +576,44 @@ static int reg_r_12(struct gspca_dev *gspca_dev,
550 gspca_dev->usb_buf, length, 576 gspca_dev->usb_buf, length,
551 500); 577 500);
552 if (ret < 0) { 578 if (ret < 0) {
553 PDEBUG(D_ERR, "reg_read err %d", ret); 579 PDEBUG(D_ERR, "reg_r_12 err %d", ret);
554 return -1; 580 gspca_dev->usb_err = ret;
581 return 0;
555 } 582 }
556 return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; 583 return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0];
557} 584}
558 585
559static int write_vector(struct gspca_dev *gspca_dev, 586static void write_vector(struct gspca_dev *gspca_dev,
560 const struct cmd *data, int ncmds) 587 const struct cmd *data, int ncmds)
561{ 588{
562 struct usb_device *dev = gspca_dev->dev;
563 int ret;
564
565 while (--ncmds >= 0) { 589 while (--ncmds >= 0) {
566 ret = reg_w_riv(dev, data->req, data->idx, data->val); 590 reg_w_riv(gspca_dev, data->req, data->idx, data->val);
567 if (ret < 0) {
568 PDEBUG(D_ERR,
569 "Register write failed for 0x%02x, 0x%04x, 0x%04x",
570 data->req, data->val, data->idx);
571 return ret;
572 }
573 data++; 591 data++;
574 } 592 }
575 return 0;
576} 593}
577 594
578static int spca50x_setup_qtable(struct gspca_dev *gspca_dev, 595static void setup_qtable(struct gspca_dev *gspca_dev,
579 const u8 qtable[2][64]) 596 const u8 qtable[2][64])
580{ 597{
581 struct usb_device *dev = gspca_dev->dev; 598 int i;
582 int i, err;
583 599
584 /* loop over y components */ 600 /* loop over y components */
585 for (i = 0; i < 64; i++) { 601 for (i = 0; i < 64; i++)
586 err = reg_w_riv(dev, 0x00, 0x2800 + i, qtable[0][i]); 602 reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]);
587 if (err < 0)
588 return err;
589 }
590 603
591 /* loop over c components */ 604 /* loop over c components */
592 for (i = 0; i < 64; i++) { 605 for (i = 0; i < 64; i++)
593 err = reg_w_riv(dev, 0x00, 0x2840 + i, qtable[1][i]); 606 reg_w_riv(gspca_dev, 0x00, 0x2840 + i, qtable[1][i]);
594 if (err < 0)
595 return err;
596 }
597 return 0;
598} 607}
599 608
600static void spca504_acknowledged_command(struct gspca_dev *gspca_dev, 609static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
601 u8 req, u16 idx, u16 val) 610 u8 req, u16 idx, u16 val)
602{ 611{
603 struct usb_device *dev = gspca_dev->dev; 612 u16 notdone;
604 int notdone;
605 613
606 reg_w_riv(dev, req, idx, val); 614 reg_w_riv(gspca_dev, req, idx, val);
607 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 615 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
608 reg_w_riv(dev, req, idx, val); 616 reg_w_riv(gspca_dev, req, idx, val);
609 617
610 PDEBUG(D_FRAM, "before wait 0x%04x", notdone); 618 PDEBUG(D_FRAM, "before wait 0x%04x", notdone);
611 619
@@ -616,23 +624,22 @@ static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
616 624
617static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, 625static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
618 u8 req, 626 u8 req,
619 u16 idx, u16 val, u8 stat, u8 count) 627 u16 idx, u16 val, u16 endcode, u8 count)
620{ 628{
621 struct usb_device *dev = gspca_dev->dev; 629 u16 status;
622 int status;
623 u8 endcode;
624 630
625 reg_w_riv(dev, req, idx, val); 631 reg_w_riv(gspca_dev, req, idx, val);
626 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 632 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
627 endcode = stat; 633 if (gspca_dev->usb_err < 0)
628 PDEBUG(D_FRAM, "Status 0x%x Need 0x%04x", status, stat); 634 return;
635 PDEBUG(D_FRAM, "Status 0x%04x Need 0x%04x", status, endcode);
629 if (!count) 636 if (!count)
630 return; 637 return;
631 count = 200; 638 count = 200;
632 while (--count > 0) { 639 while (--count > 0) {
633 msleep(10); 640 msleep(10);
634 /* gsmart mini2 write a each wait setting 1 ms is enough */ 641 /* gsmart mini2 write a each wait setting 1 ms is enough */
635/* reg_w_riv(dev, req, idx, val); */ 642/* reg_w_riv(gspca_dev, req, idx, val); */
636 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 643 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
637 if (status == endcode) { 644 if (status == endcode) {
638 PDEBUG(D_FRAM, "status 0x%04x after wait %d", 645 PDEBUG(D_FRAM, "status 0x%04x after wait %d",
@@ -642,7 +649,7 @@ static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
642 } 649 }
643} 650}
644 651
645static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev) 652static void spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
646{ 653{
647 int count = 10; 654 int count = 10;
648 655
@@ -652,7 +659,6 @@ static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
652 break; 659 break;
653 msleep(10); 660 msleep(10);
654 } 661 }
655 return gspca_dev->usb_buf[0];
656} 662}
657 663
658static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev) 664static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
@@ -686,28 +692,26 @@ static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
686static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) 692static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
687{ 693{
688 struct sd *sd = (struct sd *) gspca_dev; 694 struct sd *sd = (struct sd *) gspca_dev;
689 struct usb_device *dev = gspca_dev->dev;
690 u8 Size; 695 u8 Size;
691 int rc;
692 696
693 Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; 697 Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
694 switch (sd->bridge) { 698 switch (sd->bridge) {
695 case BRIDGE_SPCA533: 699 case BRIDGE_SPCA533:
696 reg_w_riv(dev, 0x31, 0, 0); 700 reg_w_riv(gspca_dev, 0x31, 0, 0);
697 spca504B_WaitCmdStatus(gspca_dev); 701 spca504B_WaitCmdStatus(gspca_dev);
698 rc = spca504B_PollingDataReady(gspca_dev); 702 spca504B_PollingDataReady(gspca_dev);
699 spca50x_GetFirmware(gspca_dev); 703 spca50x_GetFirmware(gspca_dev);
700 reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */ 704 reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */
701 reg_r(gspca_dev, 0x24, 8, 1); 705 reg_r(gspca_dev, 0x24, 8, 1);
702 706
703 reg_w_1(gspca_dev, 0x25, 0, 4, Size); 707 reg_w_1(gspca_dev, 0x25, 0, 4, Size);
704 reg_r(gspca_dev, 0x25, 4, 1); /* size */ 708 reg_r(gspca_dev, 0x25, 4, 1); /* size */
705 rc = spca504B_PollingDataReady(gspca_dev); 709 spca504B_PollingDataReady(gspca_dev);
706 710
707 /* Init the cam width height with some values get on init ? */ 711 /* Init the cam width height with some values get on init ? */
708 reg_w_riv(dev, 0x31, 0, 0x04); 712 reg_w_riv(gspca_dev, 0x31, 0, 0x04);
709 spca504B_WaitCmdStatus(gspca_dev); 713 spca504B_WaitCmdStatus(gspca_dev);
710 rc = spca504B_PollingDataReady(gspca_dev); 714 spca504B_PollingDataReady(gspca_dev);
711 break; 715 break;
712 default: 716 default:
713/* case BRIDGE_SPCA504B: */ 717/* case BRIDGE_SPCA504B: */
@@ -716,7 +720,7 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
716 reg_r(gspca_dev, 0x25, 4, 1); /* size */ 720 reg_r(gspca_dev, 0x25, 4, 1); /* size */
717 reg_w_1(gspca_dev, 0x27, 0, 0, 6); 721 reg_w_1(gspca_dev, 0x27, 0, 0, 6);
718 reg_r(gspca_dev, 0x27, 0, 1); /* type */ 722 reg_r(gspca_dev, 0x27, 0, 1); /* type */
719 rc = spca504B_PollingDataReady(gspca_dev); 723 spca504B_PollingDataReady(gspca_dev);
720 break; 724 break;
721 case BRIDGE_SPCA504: 725 case BRIDGE_SPCA504:
722 Size += 3; 726 Size += 3;
@@ -733,8 +737,8 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
733 break; 737 break;
734 case BRIDGE_SPCA504C: 738 case BRIDGE_SPCA504C:
735 /* capture mode */ 739 /* capture mode */
736 reg_w_riv(dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00); 740 reg_w_riv(gspca_dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00);
737 reg_w_riv(dev, 0x20, 0x01, 0x0500 | (Size & 0x0f)); 741 reg_w_riv(gspca_dev, 0x20, 0x01, 0x0500 | (Size & 0x0f));
738 break; 742 break;
739 } 743 }
740} 744}
@@ -762,37 +766,33 @@ static void spca504B_setQtable(struct gspca_dev *gspca_dev)
762static void setbrightness(struct gspca_dev *gspca_dev) 766static void setbrightness(struct gspca_dev *gspca_dev)
763{ 767{
764 struct sd *sd = (struct sd *) gspca_dev; 768 struct sd *sd = (struct sd *) gspca_dev;
765 struct usb_device *dev = gspca_dev->dev;
766 u16 reg; 769 u16 reg;
767 770
768 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f0 : 0x21a7; 771 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f0 : 0x21a7;
769 reg_w_riv(dev, 0x00, reg, sd->brightness); 772 reg_w_riv(gspca_dev, 0x00, reg, sd->brightness);
770} 773}
771 774
772static void setcontrast(struct gspca_dev *gspca_dev) 775static void setcontrast(struct gspca_dev *gspca_dev)
773{ 776{
774 struct sd *sd = (struct sd *) gspca_dev; 777 struct sd *sd = (struct sd *) gspca_dev;
775 struct usb_device *dev = gspca_dev->dev;
776 u16 reg; 778 u16 reg;
777 779
778 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f1 : 0x21a8; 780 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f1 : 0x21a8;
779 reg_w_riv(dev, 0x00, reg, sd->contrast); 781 reg_w_riv(gspca_dev, 0x00, reg, sd->contrast);
780} 782}
781 783
782static void setcolors(struct gspca_dev *gspca_dev) 784static void setcolors(struct gspca_dev *gspca_dev)
783{ 785{
784 struct sd *sd = (struct sd *) gspca_dev; 786 struct sd *sd = (struct sd *) gspca_dev;
785 struct usb_device *dev = gspca_dev->dev;
786 u16 reg; 787 u16 reg;
787 788
788 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f6 : 0x21ae; 789 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f6 : 0x21ae;
789 reg_w_riv(dev, 0x00, reg, sd->colors); 790 reg_w_riv(gspca_dev, 0x00, reg, sd->colors);
790} 791}
791 792
792static void init_ctl_reg(struct gspca_dev *gspca_dev) 793static void init_ctl_reg(struct gspca_dev *gspca_dev)
793{ 794{
794 struct sd *sd = (struct sd *) gspca_dev; 795 struct sd *sd = (struct sd *) gspca_dev;
795 struct usb_device *dev = gspca_dev->dev;
796 int pollreg = 1; 796 int pollreg = 1;
797 797
798 setbrightness(gspca_dev); 798 setbrightness(gspca_dev);
@@ -807,14 +807,14 @@ static void init_ctl_reg(struct gspca_dev *gspca_dev)
807 default: 807 default:
808/* case BRIDGE_SPCA533: */ 808/* case BRIDGE_SPCA533: */
809/* case BRIDGE_SPCA504B: */ 809/* case BRIDGE_SPCA504B: */
810 reg_w_riv(dev, 0, 0x00, 0x21ad); /* hue */ 810 reg_w_riv(gspca_dev, 0, 0x00, 0x21ad); /* hue */
811 reg_w_riv(dev, 0, 0x01, 0x21ac); /* sat/hue */ 811 reg_w_riv(gspca_dev, 0, 0x01, 0x21ac); /* sat/hue */
812 reg_w_riv(dev, 0, 0x00, 0x21a3); /* gamma */ 812 reg_w_riv(gspca_dev, 0, 0x00, 0x21a3); /* gamma */
813 break; 813 break;
814 case BRIDGE_SPCA536: 814 case BRIDGE_SPCA536:
815 reg_w_riv(dev, 0, 0x40, 0x20f5); 815 reg_w_riv(gspca_dev, 0, 0x40, 0x20f5);
816 reg_w_riv(dev, 0, 0x01, 0x20f4); 816 reg_w_riv(gspca_dev, 0, 0x01, 0x20f4);
817 reg_w_riv(dev, 0, 0x00, 0x2089); 817 reg_w_riv(gspca_dev, 0, 0x00, 0x2089);
818 break; 818 break;
819 } 819 }
820 if (pollreg) 820 if (pollreg)
@@ -881,18 +881,17 @@ static int sd_config(struct gspca_dev *gspca_dev,
881static int sd_init(struct gspca_dev *gspca_dev) 881static int sd_init(struct gspca_dev *gspca_dev)
882{ 882{
883 struct sd *sd = (struct sd *) gspca_dev; 883 struct sd *sd = (struct sd *) gspca_dev;
884 struct usb_device *dev = gspca_dev->dev; 884 int i;
885 int i, err_code;
886 u8 info[6]; 885 u8 info[6];
887 886
888 switch (sd->bridge) { 887 switch (sd->bridge) {
889 case BRIDGE_SPCA504B: 888 case BRIDGE_SPCA504B:
890 reg_w_riv(dev, 0x1d, 0x00, 0); 889 reg_w_riv(gspca_dev, 0x1d, 0x00, 0);
891 reg_w_riv(dev, 0, 0x01, 0x2306); 890 reg_w_riv(gspca_dev, 0, 0x01, 0x2306);
892 reg_w_riv(dev, 0, 0x00, 0x0d04); 891 reg_w_riv(gspca_dev, 0, 0x00, 0x0d04);
893 reg_w_riv(dev, 0, 0x00, 0x2000); 892 reg_w_riv(gspca_dev, 0, 0x00, 0x2000);
894 reg_w_riv(dev, 0, 0x13, 0x2301); 893 reg_w_riv(gspca_dev, 0, 0x13, 0x2301);
895 reg_w_riv(dev, 0, 0x00, 0x2306); 894 reg_w_riv(gspca_dev, 0, 0x00, 0x2306);
896 /* fall thru */ 895 /* fall thru */
897 case BRIDGE_SPCA533: 896 case BRIDGE_SPCA533:
898 spca504B_PollingDataReady(gspca_dev); 897 spca504B_PollingDataReady(gspca_dev);
@@ -904,13 +903,13 @@ static int sd_init(struct gspca_dev *gspca_dev)
904 reg_w_1(gspca_dev, 0x24, 0, 0, 0); 903 reg_w_1(gspca_dev, 0x24, 0, 0, 0);
905 reg_r(gspca_dev, 0x24, 0, 1); 904 reg_r(gspca_dev, 0x24, 0, 1);
906 spca504B_PollingDataReady(gspca_dev); 905 spca504B_PollingDataReady(gspca_dev);
907 reg_w_riv(dev, 0x34, 0, 0); 906 reg_w_riv(gspca_dev, 0x34, 0, 0);
908 spca504B_WaitCmdStatus(gspca_dev); 907 spca504B_WaitCmdStatus(gspca_dev);
909 break; 908 break;
910 case BRIDGE_SPCA504C: /* pccam600 */ 909 case BRIDGE_SPCA504C: /* pccam600 */
911 PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)"); 910 PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)");
912 reg_w_riv(dev, 0xe0, 0x0000, 0x0000); 911 reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0000);
913 reg_w_riv(dev, 0xe0, 0x0000, 0x0001); /* reset */ 912 reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0001); /* reset */
914 spca504_wait_status(gspca_dev); 913 spca504_wait_status(gspca_dev);
915 if (sd->subtype == LogitechClickSmart420) 914 if (sd->subtype == LogitechClickSmart420)
916 write_vector(gspca_dev, 915 write_vector(gspca_dev,
@@ -919,12 +918,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
919 else 918 else
920 write_vector(gspca_dev, spca504_pccam600_open_data, 919 write_vector(gspca_dev, spca504_pccam600_open_data,
921 ARRAY_SIZE(spca504_pccam600_open_data)); 920 ARRAY_SIZE(spca504_pccam600_open_data));
922 err_code = spca50x_setup_qtable(gspca_dev, 921 setup_qtable(gspca_dev, qtable_creative_pccam);
923 qtable_creative_pccam);
924 if (err_code < 0) {
925 PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed");
926 return err_code;
927 }
928 break; 922 break;
929 default: 923 default:
930/* case BRIDGE_SPCA504: */ 924/* case BRIDGE_SPCA504: */
@@ -958,29 +952,24 @@ static int sd_init(struct gspca_dev *gspca_dev)
958 6, 0, 0x86, 1); */ 952 6, 0, 0x86, 1); */
959/* spca504A_acknowledged_command (gspca_dev, 0x24, 953/* spca504A_acknowledged_command (gspca_dev, 0x24,
960 0, 0, 0x9D, 1); */ 954 0, 0, 0x9D, 1); */
961 reg_w_riv(dev, 0x00, 0x270c, 0x05); /* L92 sno1t.txt */ 955 reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
962 reg_w_riv(dev, 0x00, 0x2310, 0x05); 956 /* L92 sno1t.txt */
957 reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
963 spca504A_acknowledged_command(gspca_dev, 0x01, 958 spca504A_acknowledged_command(gspca_dev, 0x01,
964 0x0f, 0, 0xff, 0); 959 0x0f, 0, 0xff, 0);
965 } 960 }
966 /* setup qtable */ 961 /* setup qtable */
967 reg_w_riv(dev, 0, 0x2000, 0); 962 reg_w_riv(gspca_dev, 0, 0x2000, 0);
968 reg_w_riv(dev, 0, 0x2883, 1); 963 reg_w_riv(gspca_dev, 0, 0x2883, 1);
969 err_code = spca50x_setup_qtable(gspca_dev, 964 setup_qtable(gspca_dev, qtable_spca504_default);
970 qtable_spca504_default);
971 if (err_code < 0) {
972 PDEBUG(D_ERR, "spca50x_setup_qtable failed");
973 return err_code;
974 }
975 break; 965 break;
976 } 966 }
977 return 0; 967 return gspca_dev->usb_err;
978} 968}
979 969
980static int sd_start(struct gspca_dev *gspca_dev) 970static int sd_start(struct gspca_dev *gspca_dev)
981{ 971{
982 struct sd *sd = (struct sd *) gspca_dev; 972 struct sd *sd = (struct sd *) gspca_dev;
983 struct usb_device *dev = gspca_dev->dev;
984 int enable; 973 int enable;
985 int i; 974 int i;
986 u8 info[6]; 975 u8 info[6];
@@ -1005,13 +994,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
1005 case MegapixV4: 994 case MegapixV4:
1006 case LogitechClickSmart820: 995 case LogitechClickSmart820:
1007 case MegaImageVI: 996 case MegaImageVI:
1008 reg_w_riv(dev, 0xf0, 0, 0); 997 reg_w_riv(gspca_dev, 0xf0, 0, 0);
1009 spca504B_WaitCmdStatus(gspca_dev); 998 spca504B_WaitCmdStatus(gspca_dev);
1010 reg_r(gspca_dev, 0xf0, 4, 0); 999 reg_r(gspca_dev, 0xf0, 4, 0);
1011 spca504B_WaitCmdStatus(gspca_dev); 1000 spca504B_WaitCmdStatus(gspca_dev);
1012 break; 1001 break;
1013 default: 1002 default:
1014 reg_w_riv(dev, 0x31, 0, 0x04); 1003 reg_w_riv(gspca_dev, 0x31, 0, 0x04);
1015 spca504B_WaitCmdStatus(gspca_dev); 1004 spca504B_WaitCmdStatus(gspca_dev);
1016 spca504B_PollingDataReady(gspca_dev); 1005 spca504B_PollingDataReady(gspca_dev);
1017 break; 1006 break;
@@ -1048,8 +1037,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
1048 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); 1037 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
1049 } 1038 }
1050 spca504B_SetSizeType(gspca_dev); 1039 spca504B_SetSizeType(gspca_dev);
1051 reg_w_riv(dev, 0x00, 0x270c, 0x05); /* L92 sno1t.txt */ 1040 reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
1052 reg_w_riv(dev, 0x00, 0x2310, 0x05); 1041 /* L92 sno1t.txt */
1042 reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
1053 break; 1043 break;
1054 case BRIDGE_SPCA504C: 1044 case BRIDGE_SPCA504C:
1055 if (sd->subtype == LogitechClickSmart420) { 1045 if (sd->subtype == LogitechClickSmart420) {
@@ -1061,36 +1051,37 @@ static int sd_start(struct gspca_dev *gspca_dev)
1061 ARRAY_SIZE(spca504_pccam600_init_data)); 1051 ARRAY_SIZE(spca504_pccam600_init_data));
1062 } 1052 }
1063 enable = (sd->autogain ? 0x04 : 0x01); 1053 enable = (sd->autogain ? 0x04 : 0x01);
1064 reg_w_riv(dev, 0x0c, 0x0000, enable); /* auto exposure */ 1054 reg_w_riv(gspca_dev, 0x0c, 0x0000, enable);
1065 reg_w_riv(dev, 0xb0, 0x0000, enable); /* auto whiteness */ 1055 /* auto exposure */
1056 reg_w_riv(gspca_dev, 0xb0, 0x0000, enable);
1057 /* auto whiteness */
1066 1058
1067 /* set default exposure compensation and whiteness balance */ 1059 /* set default exposure compensation and whiteness balance */
1068 reg_w_riv(dev, 0x30, 0x0001, 800); /* ~ 20 fps */ 1060 reg_w_riv(gspca_dev, 0x30, 0x0001, 800); /* ~ 20 fps */
1069 reg_w_riv(dev, 0x30, 0x0002, 1600); 1061 reg_w_riv(gspca_dev, 0x30, 0x0002, 1600);
1070 spca504B_SetSizeType(gspca_dev); 1062 spca504B_SetSizeType(gspca_dev);
1071 break; 1063 break;
1072 } 1064 }
1073 init_ctl_reg(gspca_dev); 1065 init_ctl_reg(gspca_dev);
1074 return 0; 1066 return gspca_dev->usb_err;
1075} 1067}
1076 1068
1077static void sd_stopN(struct gspca_dev *gspca_dev) 1069static void sd_stopN(struct gspca_dev *gspca_dev)
1078{ 1070{
1079 struct sd *sd = (struct sd *) gspca_dev; 1071 struct sd *sd = (struct sd *) gspca_dev;
1080 struct usb_device *dev = gspca_dev->dev;
1081 1072
1082 switch (sd->bridge) { 1073 switch (sd->bridge) {
1083 default: 1074 default:
1084/* case BRIDGE_SPCA533: */ 1075/* case BRIDGE_SPCA533: */
1085/* case BRIDGE_SPCA536: */ 1076/* case BRIDGE_SPCA536: */
1086/* case BRIDGE_SPCA504B: */ 1077/* case BRIDGE_SPCA504B: */
1087 reg_w_riv(dev, 0x31, 0, 0); 1078 reg_w_riv(gspca_dev, 0x31, 0, 0);
1088 spca504B_WaitCmdStatus(gspca_dev); 1079 spca504B_WaitCmdStatus(gspca_dev);
1089 spca504B_PollingDataReady(gspca_dev); 1080 spca504B_PollingDataReady(gspca_dev);
1090 break; 1081 break;
1091 case BRIDGE_SPCA504: 1082 case BRIDGE_SPCA504:
1092 case BRIDGE_SPCA504C: 1083 case BRIDGE_SPCA504C:
1093 reg_w_riv(dev, 0x00, 0x2000, 0x0000); 1084 reg_w_riv(gspca_dev, 0x00, 0x2000, 0x0000);
1094 1085
1095 if (sd->subtype == AiptekMiniPenCam13) { 1086 if (sd->subtype == AiptekMiniPenCam13) {
1096 /* spca504a aiptek */ 1087 /* spca504a aiptek */
@@ -1102,7 +1093,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1102 0x0f, 0x00, 0xff, 1); 1093 0x0f, 0x00, 0xff, 1);
1103 } else { 1094 } else {
1104 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); 1095 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
1105 reg_w_riv(dev, 0x01, 0x000f, 0x0000); 1096 reg_w_riv(gspca_dev, 0x01, 0x000f, 0x0000);
1106 } 1097 }
1107 break; 1098 break;
1108 } 1099 }
@@ -1216,7 +1207,7 @@ static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1216 sd->brightness = val; 1207 sd->brightness = val;
1217 if (gspca_dev->streaming) 1208 if (gspca_dev->streaming)
1218 setbrightness(gspca_dev); 1209 setbrightness(gspca_dev);
1219 return 0; 1210 return gspca_dev->usb_err;
1220} 1211}
1221 1212
1222static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) 1213static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
@@ -1234,7 +1225,7 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
1234 sd->contrast = val; 1225 sd->contrast = val;
1235 if (gspca_dev->streaming) 1226 if (gspca_dev->streaming)
1236 setcontrast(gspca_dev); 1227 setcontrast(gspca_dev);
1237 return 0; 1228 return gspca_dev->usb_err;
1238} 1229}
1239 1230
1240static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) 1231static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
@@ -1252,7 +1243,7 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
1252 sd->colors = val; 1243 sd->colors = val;
1253 if (gspca_dev->streaming) 1244 if (gspca_dev->streaming)
1254 setcolors(gspca_dev); 1245 setcolors(gspca_dev);
1255 return 0; 1246 return gspca_dev->usb_err;
1256} 1247}
1257 1248
1258static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) 1249static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
@@ -1292,7 +1283,7 @@ static int sd_set_jcomp(struct gspca_dev *gspca_dev,
1292 sd->quality = jcomp->quality; 1283 sd->quality = jcomp->quality;
1293 if (gspca_dev->streaming) 1284 if (gspca_dev->streaming)
1294 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 1285 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
1295 return 0; 1286 return gspca_dev->usb_err;
1296} 1287}
1297 1288
1298static int sd_get_jcomp(struct gspca_dev *gspca_dev, 1289static int sd_get_jcomp(struct gspca_dev *gspca_dev,