aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sonixj.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r--drivers/media/video/gspca/sonixj.c293
1 files changed, 142 insertions, 151 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 4cb1421b8807..30e840dca481 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -24,8 +24,8 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) 27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.5"; 28static const char version[] = "2.1.7";
29 29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); 31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
@@ -512,42 +512,40 @@ static const __u8 qtable4[] = {
512 0x29, 0x29, 0x29, 0x29 512 0x29, 0x29, 0x29, 0x29
513}; 513};
514 514
515static void reg_r(struct usb_device *dev, 515/* read <len> bytes (len < sizeof gspca_dev->usb_buf) to gspca_dev->usb_buf */
516 __u16 value, 516static void reg_r(struct gspca_dev *gspca_dev,
517 __u8 *buffer, int len) 517 __u16 value, int len)
518{ 518{
519 usb_control_msg(dev, 519 usb_control_msg(gspca_dev->dev,
520 usb_rcvctrlpipe(dev, 0), 520 usb_rcvctrlpipe(gspca_dev->dev, 0),
521 0, 521 0,
522 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 522 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
523 value, 0, 523 value, 0,
524 buffer, len, 524 gspca_dev->usb_buf, len,
525 500); 525 500);
526} 526}
527 527
528static void reg_w(struct usb_device *dev, 528static void reg_w(struct gspca_dev *gspca_dev,
529 __u16 value, 529 __u16 value,
530 const __u8 *buffer, 530 const __u8 *buffer,
531 int len) 531 int len)
532{ 532{
533 if (len < 16) { 533 if (len <= sizeof gspca_dev->usb_buf) {
534 __u8 tmpbuf[16]; 534 memcpy(gspca_dev->usb_buf, buffer, len);
535 535 usb_control_msg(gspca_dev->dev,
536 memcpy(tmpbuf, buffer, len); 536 usb_sndctrlpipe(gspca_dev->dev, 0),
537 usb_control_msg(dev,
538 usb_sndctrlpipe(dev, 0),
539 0x08, 537 0x08,
540 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 538 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
541 value, 0, 539 value, 0,
542 tmpbuf, len, 540 gspca_dev->usb_buf, len,
543 500); 541 500);
544 } else { 542 } else {
545 __u8 *tmpbuf; 543 __u8 *tmpbuf;
546 544
547 tmpbuf = kmalloc(len, GFP_KERNEL); 545 tmpbuf = kmalloc(len, GFP_KERNEL);
548 memcpy(tmpbuf, buffer, len); 546 memcpy(tmpbuf, buffer, len);
549 usb_control_msg(dev, 547 usb_control_msg(gspca_dev->dev,
550 usb_sndctrlpipe(dev, 0), 548 usb_sndctrlpipe(gspca_dev->dev, 0),
551 0x08, 549 0x08,
552 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 550 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
553 value, 0, 551 value, 0,
@@ -557,12 +555,11 @@ static void reg_w(struct usb_device *dev,
557 } 555 }
558} 556}
559 557
560/* write 2 bytes */ 558/* I2C write 2 bytes */
561static void i2c_w2(struct gspca_dev *gspca_dev, 559static void i2c_w2(struct gspca_dev *gspca_dev,
562 const __u8 *buffer) 560 const __u8 *buffer)
563{ 561{
564 struct sd *sd = (struct sd *) gspca_dev; 562 struct sd *sd = (struct sd *) gspca_dev;
565 struct usb_device *dev = gspca_dev->dev;
566 __u8 mode[8]; 563 __u8 mode[8];
567 564
568 /* is i2c ready */ 565 /* is i2c ready */
@@ -574,22 +571,21 @@ static void i2c_w2(struct gspca_dev *gspca_dev,
574 mode[5] = 0; 571 mode[5] = 0;
575 mode[6] = 0; 572 mode[6] = 0;
576 mode[7] = 0x10; 573 mode[7] = 0x10;
577 reg_w(dev, 0x08, mode, 8); 574 reg_w(gspca_dev, 0x08, mode, 8);
578} 575}
579 576
580/* write 8 bytes */ 577/* I2C write 8 bytes */
581static void i2c_w8(struct usb_device *dev, const __u8 *buffer) 578static void i2c_w8(struct gspca_dev *gspca_dev,
579 const __u8 *buffer)
582{ 580{
583 reg_w(dev, 0x08, buffer, 8); 581 reg_w(gspca_dev, 0x08, buffer, 8);
584 msleep(1); 582 msleep(1);
585} 583}
586 584
587/* read 5 bytes */ 585/* read 5 bytes in gspca_dev->usb_buf */
588static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg, 586static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg)
589 __u8 *buffer)
590{ 587{
591 struct sd *sd = (struct sd *) gspca_dev; 588 struct sd *sd = (struct sd *) gspca_dev;
592 struct usb_device *dev = gspca_dev->dev;
593 __u8 mode[8]; 589 __u8 mode[8];
594 590
595 mode[0] = sd->i2c_ctrl_reg | 0x10; 591 mode[0] = sd->i2c_ctrl_reg | 0x10;
@@ -600,40 +596,39 @@ static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg,
600 mode[5] = 0; 596 mode[5] = 0;
601 mode[6] = 0; 597 mode[6] = 0;
602 mode[7] = 0x10; 598 mode[7] = 0x10;
603 i2c_w8(dev, mode); 599 i2c_w8(gspca_dev, mode);
604 mode[0] = sd->i2c_ctrl_reg | (5 << 4) | 0x02; 600 mode[0] = sd->i2c_ctrl_reg | (5 << 4) | 0x02;
605 mode[2] = 0; 601 mode[2] = 0;
606 i2c_w8(dev, mode); 602 i2c_w8(gspca_dev, mode);
607 reg_r(dev, 0x0a, buffer, 5); 603 reg_r(gspca_dev, 0x0a, 5);
608} 604}
609 605
610static int probesensor(struct gspca_dev *gspca_dev) 606static int probesensor(struct gspca_dev *gspca_dev)
611{ 607{
612 struct sd *sd = (struct sd *) gspca_dev; 608 struct sd *sd = (struct sd *) gspca_dev;
613 struct usb_device *dev = gspca_dev->dev;
614 __u8 reg02; 609 __u8 reg02;
615 static const __u8 datasend[] = { 2, 0 }; 610 static const __u8 datasend[] = { 2, 0 };
616 /* reg val1 val2 val3 val4 */ 611 /* reg val1 val2 val3 val4 */
617 __u8 datarecd[6];
618 612
619 i2c_w2(gspca_dev, datasend); 613 i2c_w2(gspca_dev, datasend);
620/* should write 0xa1 0x11 0x02 0x00 0x00 0x00 0x00 the 0x10 is add by i2cw */ 614/* should write 0xa1 0x11 0x02 0x00 0x00 0x00 0x00 the 0x10 is add by i2cw */
621 msleep(10); 615 msleep(10);
622 reg02 = 0x66; 616 reg02 = 0x66;
623 reg_w(dev, 0x02, &reg02, 1); /* Gpio on */ 617 reg_w(gspca_dev, 0x02, &reg02, 1); /* Gpio on */
624 msleep(10); 618 msleep(10);
625 i2c_r5(gspca_dev, 0, datarecd); /* read sensor id */ 619 i2c_r5(gspca_dev, 0); /* read sensor id */
626 if (datarecd[0] == 0x02 620 if (gspca_dev->usb_buf[0] == 0x02
627 && datarecd[1] == 0x09 621 && gspca_dev->usb_buf[1] == 0x09
628 && datarecd[2] == 0x01 622 && gspca_dev->usb_buf[2] == 0x01
629 && datarecd[3] == 0x00 623 && gspca_dev->usb_buf[3] == 0x00
630 && datarecd[4] == 0x00) { 624 && gspca_dev->usb_buf[4] == 0x00) {
631 PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R"); 625 PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R");
632 sd->sensor = SENSOR_HV7131R; 626 sd->sensor = SENSOR_HV7131R;
633 return SENSOR_HV7131R; 627 return SENSOR_HV7131R;
634 } 628 }
635 PDEBUG(D_PROBE, "Find Sensor %d %d %d", 629 PDEBUG(D_PROBE, "Find Sensor %d %d %d",
636 datarecd[0], datarecd[1], datarecd[2]); 630 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
631 gspca_dev->usb_buf[2]);
637 PDEBUG(D_PROBE, "Sensor sn9c102P Not found"); 632 PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
638 return -ENODEV; 633 return -ENODEV;
639} 634}
@@ -642,7 +637,6 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
642 const __u8 *sn9c1xx) 637 const __u8 *sn9c1xx)
643{ 638{
644 struct sd *sd = (struct sd *) gspca_dev; 639 struct sd *sd = (struct sd *) gspca_dev;
645 struct usb_device *dev = gspca_dev->dev;
646 __u8 data; 640 __u8 data;
647 __u8 regF1; 641 __u8 regF1;
648 const __u8 *reg9a; 642 const __u8 *reg9a;
@@ -655,14 +649,15 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
655 649
656 650
657 regF1 = 0x00; 651 regF1 = 0x00;
658 reg_w(dev, 0xf1, &regF1, 1); 652 reg_w(gspca_dev, 0xf1, &regF1, 1);
659 653
660 reg_w(dev, 0x01, &sn9c1xx[0], 1); /*fixme:jfm was [1] en v1*/ 654 reg_w(gspca_dev, 0x01, &sn9c1xx[0], 1);
655 /*fixme:jfm was [1] en v1*/
661 656
662 /* configure gpio */ 657 /* configure gpio */
663 reg_w(dev, 0x01, &sn9c1xx[1], 2); 658 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
664 reg_w(dev, 0x08, &sn9c1xx[8], 2); 659 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
665 reg_w(dev, 0x17, &sn9c1xx[0x17], 3); 660 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 3);
666 switch (sd->customid) { 661 switch (sd->customid) {
667 case SN9C325: 662 case SN9C325:
668 reg9a = reg9a_sn9c325; 663 reg9a = reg9a_sn9c325;
@@ -674,37 +669,37 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
674 reg9a = reg9a_def; 669 reg9a = reg9a_def;
675 break; 670 break;
676 } 671 }
677 reg_w(dev, 0x9a, reg9a, 6); 672 reg_w(gspca_dev, 0x9a, reg9a, 6);
678 673
679 data = 0x60; /*fixme:jfm 60 00 00 (3) */ 674 data = 0x60; /*fixme:jfm 60 00 00 (3) */
680 reg_w(dev, 0xd4, &data, 1); 675 reg_w(gspca_dev, 0xd4, &data, 1);
681 676
682 reg_w(dev, 0x03, &sn9c1xx[3], 0x0f); 677 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
683 678
684 switch (sd->customid) { 679 switch (sd->customid) {
685 case SN9C120: /* from win trace */ 680 case SN9C120: /* from win trace */
686 data = 0x61; 681 data = 0x61;
687 reg_w(dev, 0x01, &data, 1); 682 reg_w(gspca_dev, 0x01, &data, 1);
688 data = 0x20; 683 data = 0x20;
689 reg_w(dev, 0x17, &data, 1); 684 reg_w(gspca_dev, 0x17, &data, 1);
690 data = 0x60; 685 data = 0x60;
691 reg_w(dev, 0x01, &data, 1); 686 reg_w(gspca_dev, 0x01, &data, 1);
692 break; 687 break;
693 case SN9C325: 688 case SN9C325:
694 data = 0x43; 689 data = 0x43;
695 reg_w(dev, 0x01, &data, 1); 690 reg_w(gspca_dev, 0x01, &data, 1);
696 data = 0xae; 691 data = 0xae;
697 reg_w(dev, 0x17, &data, 1); 692 reg_w(gspca_dev, 0x17, &data, 1);
698 data = 0x42; 693 data = 0x42;
699 reg_w(dev, 0x01, &data, 1); 694 reg_w(gspca_dev, 0x01, &data, 1);
700 break; 695 break;
701 default: 696 default:
702 data = 0x43; 697 data = 0x43;
703 reg_w(dev, 0x01, &data, 1); 698 reg_w(gspca_dev, 0x01, &data, 1);
704 data = 0x61; 699 data = 0x61;
705 reg_w(dev, 0x17, &data, 1); 700 reg_w(gspca_dev, 0x17, &data, 1);
706 data = 0x42; 701 data = 0x42;
707 reg_w(dev, 0x01, &data, 1); 702 reg_w(gspca_dev, 0x01, &data, 1);
708 } 703 }
709 704
710 if (sd->sensor == SENSOR_HV7131R) { 705 if (sd->sensor == SENSOR_HV7131R) {
@@ -717,24 +712,22 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
717static void hv7131R_InitSensor(struct gspca_dev *gspca_dev) 712static void hv7131R_InitSensor(struct gspca_dev *gspca_dev)
718{ 713{
719 int i = 0; 714 int i = 0;
720 struct usb_device *dev = gspca_dev->dev;
721 static const __u8 SetSensorClk[] = /* 0x08 Mclk */ 715 static const __u8 SetSensorClk[] = /* 0x08 Mclk */
722 { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 }; 716 { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 };
723 717
724 while (hv7131r_sensor_init[i][0]) { 718 while (hv7131r_sensor_init[i][0]) {
725 i2c_w8(dev, hv7131r_sensor_init[i]); 719 i2c_w8(gspca_dev, hv7131r_sensor_init[i]);
726 i++; 720 i++;
727 } 721 }
728 i2c_w8(dev, SetSensorClk); 722 i2c_w8(gspca_dev, SetSensorClk);
729} 723}
730 724
731static void mi0360_InitSensor(struct gspca_dev *gspca_dev) 725static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
732{ 726{
733 int i = 0; 727 int i = 0;
734 struct usb_device *dev = gspca_dev->dev;
735 728
736 while (mi0360_sensor_init[i][0]) { 729 while (mi0360_sensor_init[i][0]) {
737 i2c_w8(dev, mi0360_sensor_init[i]); 730 i2c_w8(gspca_dev, mi0360_sensor_init[i]);
738 i++; 731 i++;
739 } 732 }
740} 733}
@@ -742,21 +735,19 @@ static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
742static void mo4000_InitSensor(struct gspca_dev *gspca_dev) 735static void mo4000_InitSensor(struct gspca_dev *gspca_dev)
743{ 736{
744 int i = 0; 737 int i = 0;
745 struct usb_device *dev = gspca_dev->dev;
746 738
747 while (mo4000_sensor_init[i][0]) { 739 while (mo4000_sensor_init[i][0]) {
748 i2c_w8(dev, mo4000_sensor_init[i]); 740 i2c_w8(gspca_dev, mo4000_sensor_init[i]);
749 i++; 741 i++;
750 } 742 }
751} 743}
752 744
753static void ov7648_InitSensor(struct gspca_dev *gspca_dev) 745static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
754{ 746{
755 struct usb_device *dev = gspca_dev->dev;
756 int i = 0; 747 int i = 0;
757 748
758 while (ov7648_sensor_init[i][0]) { 749 while (ov7648_sensor_init[i][0]) {
759 i2c_w8(dev, ov7648_sensor_init[i]); 750 i2c_w8(gspca_dev, ov7648_sensor_init[i]);
760 i++; 751 i++;
761 } 752 }
762} 753}
@@ -764,10 +755,9 @@ static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
764static void ov7660_InitSensor(struct gspca_dev *gspca_dev) 755static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
765{ 756{
766 int i = 0; 757 int i = 0;
767 struct usb_device *dev = gspca_dev->dev;
768 758
769 while (ov7660_sensor_init[i][0]) { 759 while (ov7660_sensor_init[i][0]) {
770 i2c_w8(dev, ov7660_sensor_init[i]); 760 i2c_w8(gspca_dev, ov7660_sensor_init[i]);
771 i++; 761 i++;
772 } 762 }
773} 763}
@@ -1005,51 +995,52 @@ static int sd_config(struct gspca_dev *gspca_dev,
1005static int sd_open(struct gspca_dev *gspca_dev) 995static int sd_open(struct gspca_dev *gspca_dev)
1006{ 996{
1007 struct sd *sd = (struct sd *) gspca_dev; 997 struct sd *sd = (struct sd *) gspca_dev;
1008 struct usb_device *dev = gspca_dev->dev;
1009/* const __u8 *sn9c1xx; */ 998/* const __u8 *sn9c1xx; */
1010 __u8 regF1; 999 __u8 regF1;
1011 __u8 regGpio[] = { 0x29, 0x74 }; 1000 __u8 regGpio[] = { 0x29, 0x74 };
1012 1001
1013 /* setup a selector by customid */ 1002 /* setup a selector by customid */
1014 regF1 = 0x01; 1003 regF1 = 0x01;
1015 reg_w(dev, 0xf1, &regF1, 1); 1004 reg_w(gspca_dev, 0xf1, &regF1, 1);
1016 reg_r(dev, 0x00, &regF1, 1); /* -> regF1 = 0x00 */ 1005 reg_r(gspca_dev, 0x00, 1); /* -> regF1 = 0x00 */
1017 reg_w(dev, 0xf1, &regF1, 1); 1006 regF1 = gspca_dev->usb_buf[0];
1018 reg_r(dev, 0x00, &regF1, 1); 1007 reg_w(gspca_dev, 0xf1, &regF1, 1);
1008 reg_r(gspca_dev, 0x00, 1);
1009 regF1 = gspca_dev->usb_buf[0];
1019 switch (sd->customid) { 1010 switch (sd->customid) {
1020 case SN9C102P: 1011 case SN9C102P:
1021 if (regF1 != 0x11) 1012 if (regF1 != 0x11)
1022 return -ENODEV; 1013 return -ENODEV;
1023 reg_w(dev, 0x02, &regGpio[1], 1); 1014 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1024 break; 1015 break;
1025 case SN9C105: 1016 case SN9C105:
1026 if (regF1 != 0x11) 1017 if (regF1 != 0x11)
1027 return -ENODEV; 1018 return -ENODEV;
1028 reg_w(dev, 0x02, regGpio, 2); 1019 reg_w(gspca_dev, 0x02, regGpio, 2);
1029 break; 1020 break;
1030 case SN9C110: 1021 case SN9C110:
1031 if (regF1 != 0x12) 1022 if (regF1 != 0x12)
1032 return -ENODEV; 1023 return -ENODEV;
1033 regGpio[1] = 0x62; 1024 regGpio[1] = 0x62;
1034 reg_w(dev, 0x02, &regGpio[1], 1); 1025 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1035 break; 1026 break;
1036 case SN9C120: 1027 case SN9C120:
1037 if (regF1 != 0x12) 1028 if (regF1 != 0x12)
1038 return -ENODEV; 1029 return -ENODEV;
1039 regGpio[1] = 0x70; 1030 regGpio[1] = 0x70;
1040 reg_w(dev, 0x02, regGpio, 2); 1031 reg_w(gspca_dev, 0x02, regGpio, 2);
1041 break; 1032 break;
1042 default: 1033 default:
1043/* case SN9C325: */ 1034/* case SN9C325: */
1044 if (regF1 != 0x12) 1035 if (regF1 != 0x12)
1045 return -ENODEV; 1036 return -ENODEV;
1046 regGpio[1] = 0x62; 1037 regGpio[1] = 0x62;
1047 reg_w(dev, 0x02, &regGpio[1], 1); 1038 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1048 break; 1039 break;
1049 } 1040 }
1050 1041
1051 regF1 = 0x01; 1042 regF1 = 0x01;
1052 reg_w(dev, 0xf1, &regF1, 1); 1043 reg_w(gspca_dev, 0xf1, &regF1, 1);
1053 1044
1054 return 0; 1045 return 0;
1055} 1046}
@@ -1073,7 +1064,7 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev,
1073 Expodoit[3] = expo >> 16; 1064 Expodoit[3] = expo >> 16;
1074 Expodoit[4] = expo >> 8; 1065 Expodoit[4] = expo >> 8;
1075 Expodoit[5] = expo; 1066 Expodoit[5] = expo;
1076 i2c_w8(gspca_dev->dev, Expodoit); 1067 i2c_w8(gspca_dev, Expodoit);
1077 break; 1068 break;
1078 } 1069 }
1079 case SENSOR_MI0360: { 1070 case SENSOR_MI0360: {
@@ -1086,9 +1077,9 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev,
1086 expo = 0x0001; 1077 expo = 0x0001;
1087 expoMi[3] = expo >> 8; 1078 expoMi[3] = expo >> 8;
1088 expoMi[4] = expo; 1079 expoMi[4] = expo;
1089 i2c_w8(gspca_dev->dev, expoMi); 1080 i2c_w8(gspca_dev, expoMi);
1090 i2c_w8(gspca_dev->dev, doit); 1081 i2c_w8(gspca_dev, doit);
1091 i2c_w8(gspca_dev->dev, sensorgo); 1082 i2c_w8(gspca_dev, sensorgo);
1092 break; 1083 break;
1093 } 1084 }
1094 case SENSOR_MO4000: { 1085 case SENSOR_MO4000: {
@@ -1102,11 +1093,11 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev,
1102 else if (expo < 0x0001) 1093 else if (expo < 0x0001)
1103 expo = 0x0001; 1094 expo = 0x0001;
1104 expoMof[3] = (expo & 0x03fc) >> 2; 1095 expoMof[3] = (expo & 0x03fc) >> 2;
1105 i2c_w8(gspca_dev->dev, expoMof); 1096 i2c_w8(gspca_dev, expoMof);
1106 expoMo10[3] = ((expo & 0x1c00) >> 10) 1097 expoMo10[3] = ((expo & 0x1c00) >> 10)
1107 | ((expo & 0x0003) << 4); 1098 | ((expo & 0x0003) << 4);
1108 i2c_w8(gspca_dev->dev, expoMo10); 1099 i2c_w8(gspca_dev, expoMo10);
1109 i2c_w8(gspca_dev->dev, gainMo); 1100 i2c_w8(gspca_dev, gainMo);
1110 PDEBUG(D_CONF, "set exposure %d", 1101 PDEBUG(D_CONF, "set exposure %d",
1111 ((expoMo10[3] & 0x07) << 10) 1102 ((expoMo10[3] & 0x07) << 10)
1112 | (expoMof[3] << 2) 1103 | (expoMof[3] << 2)
@@ -1145,7 +1136,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1145 } 1136 }
1146 1137
1147 k2 = sd->brightness >> 10; 1138 k2 = sd->brightness >> 10;
1148 reg_w(gspca_dev->dev, 0x96, &k2, 1); 1139 reg_w(gspca_dev, 0x96, &k2, 1);
1149} 1140}
1150 1141
1151static void setcontrast(struct gspca_dev *gspca_dev) 1142static void setcontrast(struct gspca_dev *gspca_dev)
@@ -1160,7 +1151,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
1160 contrast[2] = k2; 1151 contrast[2] = k2;
1161 contrast[0] = (k2 + 1) >> 1; 1152 contrast[0] = (k2 + 1) >> 1;
1162 contrast[4] = (k2 + 1) / 5; 1153 contrast[4] = (k2 + 1) / 5;
1163 reg_w(gspca_dev->dev, 0x84, contrast, 6); 1154 reg_w(gspca_dev, 0x84, contrast, 6);
1164} 1155}
1165 1156
1166static void setcolors(struct gspca_dev *gspca_dev) 1157static void setcolors(struct gspca_dev *gspca_dev)
@@ -1174,14 +1165,13 @@ static void setcolors(struct gspca_dev *gspca_dev)
1174 data = (colour + 32) & 0x7f; /* blue */ 1165 data = (colour + 32) & 0x7f; /* blue */
1175 else 1166 else
1176 data = (-colour + 32) & 0x7f; /* red */ 1167 data = (-colour + 32) & 0x7f; /* red */
1177 reg_w(gspca_dev->dev, 0x05, &data, 1); 1168 reg_w(gspca_dev, 0x05, &data, 1);
1178} 1169}
1179 1170
1180/* -- start the camera -- */ 1171/* -- start the camera -- */
1181static void sd_start(struct gspca_dev *gspca_dev) 1172static void sd_start(struct gspca_dev *gspca_dev)
1182{ 1173{
1183 struct sd *sd = (struct sd *) gspca_dev; 1174 struct sd *sd = (struct sd *) gspca_dev;
1184 struct usb_device *dev = gspca_dev->dev;
1185 int i; 1175 int i;
1186 __u8 data; 1176 __u8 data;
1187 __u8 reg1; 1177 __u8 reg1;
@@ -1203,45 +1193,45 @@ static void sd_start(struct gspca_dev *gspca_dev)
1203/*fixme:jfm this sequence should appear at end of sd_start */ 1193/*fixme:jfm this sequence should appear at end of sd_start */
1204/* with 1194/* with
1205 data = 0x44; 1195 data = 0x44;
1206 reg_w(dev, 0x01, &data, 1); */ 1196 reg_w(gspca_dev, 0x01, &data, 1); */
1207 reg_w(dev, 0x15, &sn9c1xx[0x15], 1); 1197 reg_w(gspca_dev, 0x15, &sn9c1xx[0x15], 1);
1208 reg_w(dev, 0x16, &sn9c1xx[0x16], 1); 1198 reg_w(gspca_dev, 0x16, &sn9c1xx[0x16], 1);
1209 reg_w(dev, 0x12, &sn9c1xx[0x12], 1); 1199 reg_w(gspca_dev, 0x12, &sn9c1xx[0x12], 1);
1210 reg_w(dev, 0x13, &sn9c1xx[0x13], 1); 1200 reg_w(gspca_dev, 0x13, &sn9c1xx[0x13], 1);
1211 reg_w(dev, 0x18, &sn9c1xx[0x18], 1); 1201 reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1);
1212 reg_w(dev, 0xd2, &DC29[0], 1); 1202 reg_w(gspca_dev, 0xd2, &DC29[0], 1);
1213 reg_w(dev, 0xd3, &DC29[1], 1); 1203 reg_w(gspca_dev, 0xd3, &DC29[1], 1);
1214 reg_w(dev, 0xc6, &DC29[2], 1); 1204 reg_w(gspca_dev, 0xc6, &DC29[2], 1);
1215 reg_w(dev, 0xc7, &DC29[3], 1); 1205 reg_w(gspca_dev, 0xc7, &DC29[3], 1);
1216 reg_w(dev, 0xc8, &DC29[4], 1); 1206 reg_w(gspca_dev, 0xc8, &DC29[4], 1);
1217 reg_w(dev, 0xc9, &DC29[5], 1); 1207 reg_w(gspca_dev, 0xc9, &DC29[5], 1);
1218/*fixme:jfm end of ending sequence */ 1208/*fixme:jfm end of ending sequence */
1219 reg_w(dev, 0x18, &sn9c1xx[0x18], 1); 1209 reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1);
1220 if (sd->customid == SN9C325) 1210 if (sd->customid == SN9C325)
1221 data = 0xae; 1211 data = 0xae;
1222 else 1212 else
1223 data = 0x60; 1213 data = 0x60;
1224 reg_w(dev, 0x17, &data, 1); 1214 reg_w(gspca_dev, 0x17, &data, 1);
1225 reg_w(dev, 0x05, &sn9c1xx[5], 1); 1215 reg_w(gspca_dev, 0x05, &sn9c1xx[5], 1);
1226 reg_w(dev, 0x07, &sn9c1xx[7], 1); 1216 reg_w(gspca_dev, 0x07, &sn9c1xx[7], 1);
1227 reg_w(dev, 0x06, &sn9c1xx[6], 1); 1217 reg_w(gspca_dev, 0x06, &sn9c1xx[6], 1);
1228 reg_w(dev, 0x14, &sn9c1xx[0x14], 1); 1218 reg_w(gspca_dev, 0x14, &sn9c1xx[0x14], 1);
1229 if (sd->customid == SN9C325) { 1219 if (sd->customid == SN9C325) {
1230 reg_w(dev, 0x20, regsn20_sn9c325, 0x11); 1220 reg_w(gspca_dev, 0x20, regsn20_sn9c325, 0x11);
1231 for (i = 0; i < 8; i++) 1221 for (i = 0; i < 8; i++)
1232 reg_w(dev, 0x84, reg84_sn9c325, 0x15); 1222 reg_w(gspca_dev, 0x84, reg84_sn9c325, 0x15);
1233 data = 0x0a; 1223 data = 0x0a;
1234 reg_w(dev, 0x9a, &data, 1); 1224 reg_w(gspca_dev, 0x9a, &data, 1);
1235 data = 0x60; 1225 data = 0x60;
1236 reg_w(dev, 0x99, &data, 1); 1226 reg_w(gspca_dev, 0x99, &data, 1);
1237 } else { 1227 } else {
1238 reg_w(dev, 0x20, regsn20, 0x11); 1228 reg_w(gspca_dev, 0x20, regsn20, 0x11);
1239 for (i = 0; i < 8; i++) 1229 for (i = 0; i < 8; i++)
1240 reg_w(dev, 0x84, reg84, 0x15); 1230 reg_w(gspca_dev, 0x84, reg84, 0x15);
1241 data = 0x08; 1231 data = 0x08;
1242 reg_w(dev, 0x9a, &data, 1); 1232 reg_w(gspca_dev, 0x9a, &data, 1);
1243 data = 0x59; 1233 data = 0x59;
1244 reg_w(dev, 0x99, &data, 1); 1234 reg_w(gspca_dev, 0x99, &data, 1);
1245 } 1235 }
1246 1236
1247 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 1237 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
@@ -1294,38 +1284,38 @@ static void sd_start(struct gspca_dev *gspca_dev)
1294 } 1284 }
1295 break; 1285 break;
1296 } 1286 }
1297 reg_w(dev, 0xc0, C0, 6); 1287 reg_w(gspca_dev, 0xc0, C0, 6);
1298 switch (sd->customid) { 1288 switch (sd->customid) {
1299 case SN9C120: /*jfm ?? */ 1289 case SN9C120: /*jfm ?? */
1300 reg_w(dev, 0xca, CA_sn9c120, 4); 1290 reg_w(gspca_dev, 0xca, CA_sn9c120, 4);
1301 break; 1291 break;
1302 default: 1292 default:
1303 reg_w(dev, 0xca, CA, 4); 1293 reg_w(gspca_dev, 0xca, CA, 4);
1304 break; 1294 break;
1305 } 1295 }
1306 switch (sd->customid) { 1296 switch (sd->customid) {
1307 case SN9C120: /*jfm ?? */ 1297 case SN9C120: /*jfm ?? */
1308 case SN9C325: 1298 case SN9C325:
1309 reg_w(dev, 0xce, CE_sn9c325, 4); 1299 reg_w(gspca_dev, 0xce, CE_sn9c325, 4);
1310 break; 1300 break;
1311 default: 1301 default:
1312 reg_w(dev, 0xce, CE, 4); 1302 reg_w(gspca_dev, 0xce, CE, 4);
1313 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */ 1303 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
1314 break; 1304 break;
1315 } 1305 }
1316 1306
1317 /* here change size mode 0 -> VGA; 1 -> CIF */ 1307 /* here change size mode 0 -> VGA; 1 -> CIF */
1318 data = 0x40 | sn9c1xx[0x18] | (mode << 4); 1308 data = 0x40 | sn9c1xx[0x18] | (mode << 4);
1319 reg_w(dev, 0x18, &data, 1); 1309 reg_w(gspca_dev, 0x18, &data, 1);
1320 1310
1321 reg_w(dev, 0x100, qtable4, 0x40); 1311 reg_w(gspca_dev, 0x100, qtable4, 0x40);
1322 reg_w(dev, 0x140, qtable4 + 0x40, 0x40); 1312 reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40);
1323 1313
1324 data = sn9c1xx[0x18] | (mode << 4); 1314 data = sn9c1xx[0x18] | (mode << 4);
1325 reg_w(dev, 0x18, &data, 1); 1315 reg_w(gspca_dev, 0x18, &data, 1);
1326 1316
1327 reg_w(dev, 0x17, &reg17, 1); 1317 reg_w(gspca_dev, 0x17, &reg17, 1);
1328 reg_w(dev, 0x01, &reg1, 1); 1318 reg_w(gspca_dev, 0x01, &reg1, 1);
1329 setbrightness(gspca_dev); 1319 setbrightness(gspca_dev);
1330 setcontrast(gspca_dev); 1320 setcontrast(gspca_dev);
1331} 1321}
@@ -1333,7 +1323,6 @@ static void sd_start(struct gspca_dev *gspca_dev)
1333static void sd_stopN(struct gspca_dev *gspca_dev) 1323static void sd_stopN(struct gspca_dev *gspca_dev)
1334{ 1324{
1335 struct sd *sd = (struct sd *) gspca_dev; 1325 struct sd *sd = (struct sd *) gspca_dev;
1336 struct usb_device *dev = gspca_dev->dev;
1337 static const __u8 stophv7131[] = 1326 static const __u8 stophv7131[] =
1338 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; 1327 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
1339 static const __u8 stopmi0360[] = 1328 static const __u8 stopmi0360[] =
@@ -1345,11 +1334,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1345 data = 0x0b; 1334 data = 0x0b;
1346 switch (sd->sensor) { 1335 switch (sd->sensor) {
1347 case SENSOR_HV7131R: 1336 case SENSOR_HV7131R:
1348 i2c_w8(dev, stophv7131); 1337 i2c_w8(gspca_dev, stophv7131);
1349 data = 0x2b; 1338 data = 0x2b;
1350 break; 1339 break;
1351 case SENSOR_MI0360: 1340 case SENSOR_MI0360:
1352 i2c_w8(dev, stopmi0360); 1341 i2c_w8(gspca_dev, stopmi0360);
1353 data = 0x29; 1342 data = 0x29;
1354 break; 1343 break;
1355 case SENSOR_MO4000: 1344 case SENSOR_MO4000:
@@ -1362,12 +1351,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1362 break; 1351 break;
1363 } 1352 }
1364 sn9c1xx = sn_tb[(int) sd->sensor]; 1353 sn9c1xx = sn_tb[(int) sd->sensor];
1365 reg_w(dev, 0x01, &sn9c1xx[1], 1); 1354 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1);
1366 reg_w(dev, 0x17, &sn9c1xx[0x17], 1); 1355 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 1);
1367 reg_w(dev, 0x01, &sn9c1xx[1], 1); 1356 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1);
1368 reg_w(dev, 0x01, &data, 1); 1357 reg_w(gspca_dev, 0x01, &data, 1);
1369 regF1 = 0x01; 1358 regF1 = 0x01;
1370 reg_w(dev, 0xf1, &regF1, 1); 1359 reg_w(gspca_dev, 0xf1, &regF1, 1);
1371} 1360}
1372 1361
1373static void sd_stop0(struct gspca_dev *gspca_dev) 1362static void sd_stop0(struct gspca_dev *gspca_dev)
@@ -1463,33 +1452,35 @@ static unsigned int getexposure(struct gspca_dev *gspca_dev)
1463{ 1452{
1464 struct sd *sd = (struct sd *) gspca_dev; 1453 struct sd *sd = (struct sd *) gspca_dev;
1465 __u8 hexpo, mexpo, lexpo; 1454 __u8 hexpo, mexpo, lexpo;
1466 __u8 expo[6];
1467 1455
1468 switch (sd->sensor) { 1456 switch (sd->sensor) {
1469 case SENSOR_HV7131R: 1457 case SENSOR_HV7131R:
1470 /* read sensor exposure */ 1458 /* read sensor exposure */
1471 i2c_r5(gspca_dev, 0x25, expo); 1459 i2c_r5(gspca_dev, 0x25);
1472 return (expo[0] << 16) | (expo[1] << 8) | expo[2]; 1460 return (gspca_dev->usb_buf[0] << 16)
1461 | (gspca_dev->usb_buf[1] << 8)
1462 | gspca_dev->usb_buf[2];
1473 case SENSOR_MI0360: 1463 case SENSOR_MI0360:
1474 /* read sensor exposure */ 1464 /* read sensor exposure */
1475 i2c_r5(gspca_dev, 0x09, expo); 1465 i2c_r5(gspca_dev, 0x09);
1476 return (expo[0] << 8) | expo[1]; 1466 return (gspca_dev->usb_buf[0] << 8)
1467 | gspca_dev->usb_buf[1];
1477 case SENSOR_MO4000: 1468 case SENSOR_MO4000:
1478 i2c_r5(gspca_dev, 0x0e, expo); 1469 i2c_r5(gspca_dev, 0x0e);
1479 hexpo = 0; /* expo[1] & 0x07; */ 1470 hexpo = 0; /* gspca_dev->usb_buf[1] & 0x07; */
1480 mexpo = 0x40; /* expo[2] &0xff; */ 1471 mexpo = 0x40; /* gspca_dev->usb_buf[2] & 0xff; */
1481 lexpo = (expo[1] & 0x30) >> 4; 1472 lexpo = (gspca_dev->usb_buf[1] & 0x30) >> 4;
1482 PDEBUG(D_CONF, "exposure %d", 1473 PDEBUG(D_CONF, "exposure %d",
1483 (hexpo << 10) | (mexpo << 2) | lexpo); 1474 (hexpo << 10) | (mexpo << 2) | lexpo);
1484 return (hexpo << 10) | (mexpo << 2) | lexpo; 1475 return (hexpo << 10) | (mexpo << 2) | lexpo;
1485 default: 1476 default:
1486/* case SENSOR_OV7660: */ 1477/* case SENSOR_OV7660: */
1487 /* read sensor exposure */ 1478 /* read sensor exposure */
1488 i2c_r5(gspca_dev, 0x04, expo); 1479 i2c_r5(gspca_dev, 0x04);
1489 hexpo = expo[3] & 0x2f; 1480 hexpo = gspca_dev->usb_buf[3] & 0x2f;
1490 lexpo = expo[0] & 0x02; 1481 lexpo = gspca_dev->usb_buf[0] & 0x02;
1491 i2c_r5(gspca_dev, 0x08, expo); 1482 i2c_r5(gspca_dev, 0x08);
1492 mexpo = expo[2]; 1483 mexpo = gspca_dev->usb_buf[2];
1493 return (hexpo << 10) | (mexpo << 2) | lexpo; 1484 return (hexpo << 10) | (mexpo << 2) | lexpo;
1494 } 1485 }
1495} 1486}