aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-07-18 07:46:19 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-23 18:00:23 -0400
commit600176176101fc6e0e0c7468efa83203e8d3e015 (patch)
tree8d28215d2bd92e2692716a4e50ac1a1260230004 /drivers/media/video
parent2864462eaf027ff10c1df1ce57d3518332e9083c (diff)
V4L/DVB (8435): gspca: Delay after reset for ov7660 and USB traces in sonixj.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/gspca/sonixj.c246
1 files changed, 118 insertions, 128 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 3e68b9926956..aa4d10b823ea 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -361,6 +361,7 @@ static const __u8 mo4000_sensor_init[][8] = {
361}; 361};
362static const __u8 ov7660_sensor_init[][8] = { 362static const __u8 ov7660_sensor_init[][8] = {
363 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ 363 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
364/* (delay 20ms) */
364 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, 365 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
365 /* Outformat ?? rawRGB */ 366 /* Outformat ?? rawRGB */
366 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ 367 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
@@ -539,13 +540,31 @@ static void reg_r(struct gspca_dev *gspca_dev,
539 value, 0, 540 value, 0,
540 gspca_dev->usb_buf, len, 541 gspca_dev->usb_buf, len,
541 500); 542 500);
543 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
542} 544}
543 545
546static void reg_w1(struct gspca_dev *gspca_dev,
547 __u16 value,
548 __u8 data)
549{
550 PDEBUG(D_USBO, "reg_w1 [%02x] = %02x", value, data);
551 gspca_dev->usb_buf[0] = data;
552 usb_control_msg(gspca_dev->dev,
553 usb_sndctrlpipe(gspca_dev->dev, 0),
554 0x08,
555 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
556 value,
557 0,
558 gspca_dev->usb_buf, 1,
559 500);
560}
544static void reg_w(struct gspca_dev *gspca_dev, 561static void reg_w(struct gspca_dev *gspca_dev,
545 __u16 value, 562 __u16 value,
546 const __u8 *buffer, 563 const __u8 *buffer,
547 int len) 564 int len)
548{ 565{
566 PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..",
567 value, buffer[0], buffer[1]);
549 if (len <= sizeof gspca_dev->usb_buf) { 568 if (len <= sizeof gspca_dev->usb_buf) {
550 memcpy(gspca_dev->usb_buf, buffer, len); 569 memcpy(gspca_dev->usb_buf, buffer, len);
551 usb_control_msg(gspca_dev->dev, 570 usb_control_msg(gspca_dev->dev,
@@ -571,31 +590,42 @@ static void reg_w(struct gspca_dev *gspca_dev,
571 } 590 }
572} 591}
573 592
574/* I2C write 2 bytes */ 593/* I2C write 1 byte */
575static void i2c_w2(struct gspca_dev *gspca_dev, 594static void i2c_w1(struct gspca_dev *gspca_dev, __u8 reg, __u8 val)
576 const __u8 *buffer)
577{ 595{
578 struct sd *sd = (struct sd *) gspca_dev; 596 struct sd *sd = (struct sd *) gspca_dev;
579 __u8 mode[8];
580 597
581 /* is i2c ready */ 598 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
582 mode[0] = 0x81 | (2 << 4); 599 gspca_dev->usb_buf[0] = 0x81 | (2 << 4); /* = a1 */
583 mode[1] = sd->i2c_base; 600 gspca_dev->usb_buf[1] = sd->i2c_base;
584 mode[2] = buffer[0]; 601 gspca_dev->usb_buf[2] = reg;
585 mode[3] = buffer[1]; 602 gspca_dev->usb_buf[3] = val;
586 mode[4] = 0; 603 gspca_dev->usb_buf[4] = 0;
587 mode[5] = 0; 604 gspca_dev->usb_buf[5] = 0;
588 mode[6] = 0; 605 gspca_dev->usb_buf[6] = 0;
589 mode[7] = 0x10; 606 gspca_dev->usb_buf[7] = 0x10;
590 reg_w(gspca_dev, 0x08, mode, 8); 607 usb_control_msg(gspca_dev->dev,
608 usb_sndctrlpipe(gspca_dev->dev, 0),
609 0x08,
610 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
611 0x08, /* value = i2c */
612 0,
613 gspca_dev->usb_buf, 8,
614 500);
591} 615}
592 616
593/* I2C write 8 bytes */ 617/* I2C write 8 bytes */
594static void i2c_w8(struct gspca_dev *gspca_dev, 618static void i2c_w8(struct gspca_dev *gspca_dev,
595 const __u8 *buffer) 619 const __u8 *buffer)
596{ 620{
597 reg_w(gspca_dev, 0x08, buffer, 8); 621 memcpy(gspca_dev->usb_buf, buffer, 8);
598 msleep(1); 622 usb_control_msg(gspca_dev->dev,
623 usb_sndctrlpipe(gspca_dev->dev, 0),
624 0x08,
625 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
626 0x08, 0, /* value, index */
627 gspca_dev->usb_buf, 8,
628 500);
599} 629}
600 630
601/* read 5 bytes in gspca_dev->usb_buf */ 631/* read 5 bytes in gspca_dev->usb_buf */
@@ -613,24 +643,21 @@ static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg)
613 mode[6] = 0; 643 mode[6] = 0;
614 mode[7] = 0x10; 644 mode[7] = 0x10;
615 i2c_w8(gspca_dev, mode); 645 i2c_w8(gspca_dev, mode);
646 msleep(2);
616 mode[0] = 0x81 | (5 << 4) | 0x02; 647 mode[0] = 0x81 | (5 << 4) | 0x02;
617 mode[2] = 0; 648 mode[2] = 0;
618 i2c_w8(gspca_dev, mode); 649 i2c_w8(gspca_dev, mode);
650 msleep(2);
619 reg_r(gspca_dev, 0x0a, 5); 651 reg_r(gspca_dev, 0x0a, 5);
620} 652}
621 653
622static int probesensor(struct gspca_dev *gspca_dev) 654static int probesensor(struct gspca_dev *gspca_dev)
623{ 655{
624 struct sd *sd = (struct sd *) gspca_dev; 656 struct sd *sd = (struct sd *) gspca_dev;
625 __u8 reg02;
626 static const __u8 datasend[] = { 2, 0 };
627 /* reg val1 val2 val3 val4 */
628 657
629 i2c_w2(gspca_dev, datasend); 658 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
630/* should write 0xa1 0x11 0x02 0x00 0x00 0x00 0x00 the 0x10 is add by i2cw */
631 msleep(10); 659 msleep(10);
632 reg02 = 0x66; 660 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
633 reg_w(gspca_dev, 0x02, &reg02, 1); /* Gpio on */
634 msleep(10); 661 msleep(10);
635 i2c_r5(gspca_dev, 0); /* read sensor id */ 662 i2c_r5(gspca_dev, 0); /* read sensor id */
636 if (gspca_dev->usb_buf[0] == 0x02 663 if (gspca_dev->usb_buf[0] == 0x02
@@ -642,7 +669,7 @@ static int probesensor(struct gspca_dev *gspca_dev)
642 sd->sensor = SENSOR_HV7131R; 669 sd->sensor = SENSOR_HV7131R;
643 return SENSOR_HV7131R; 670 return SENSOR_HV7131R;
644 } 671 }
645 PDEBUG(D_PROBE, "Find Sensor %d %d %d", 672 PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
646 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], 673 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
647 gspca_dev->usb_buf[2]); 674 gspca_dev->usb_buf[2]);
648 PDEBUG(D_PROBE, "Sensor sn9c102P Not found"); 675 PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
@@ -653,8 +680,6 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
653 const __u8 *sn9c1xx) 680 const __u8 *sn9c1xx)
654{ 681{
655 struct sd *sd = (struct sd *) gspca_dev; 682 struct sd *sd = (struct sd *) gspca_dev;
656 __u8 data;
657 __u8 regF1;
658 const __u8 *reg9a; 683 const __u8 *reg9a;
659 static const __u8 reg9a_def[] = 684 static const __u8 reg9a_def[] =
660 {0x08, 0x40, 0x20, 0x10, 0x00, 0x04}; 685 {0x08, 0x40, 0x20, 0x10, 0x00, 0x04};
@@ -663,15 +688,13 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
663 static const __u8 reg9a_sn9c325[] = 688 static const __u8 reg9a_sn9c325[] =
664 {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20}; 689 {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20};
665 690
666 691 reg_w1(gspca_dev, 0xf1, 0x00);
667 regF1 = 0x00; 692 reg_w1(gspca_dev, 0x01, sn9c1xx[0]); /*fixme:jfm was [1] en v1*/
668 reg_w(gspca_dev, 0xf1, &regF1, 1);
669 reg_w(gspca_dev, 0x01, &sn9c1xx[0], 1); /*fixme:jfm was [1] en v1*/
670 693
671 /* configure gpio */ 694 /* configure gpio */
672 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); 695 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
673 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); 696 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
674 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm was 3 */ 697 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
675 switch (sd->bridge) { 698 switch (sd->bridge) {
676 case BRIDGE_SN9C325: 699 case BRIDGE_SN9C325:
677 reg9a = reg9a_sn9c325; 700 reg9a = reg9a_sn9c325;
@@ -685,35 +708,25 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
685 } 708 }
686 reg_w(gspca_dev, 0x9a, reg9a, 6); 709 reg_w(gspca_dev, 0x9a, reg9a, 6);
687 710
688 data = 0x60; /*fixme:jfm 60 00 00 (3) */ 711 reg_w1(gspca_dev, 0xd4, 0x60); /*fixme:jfm 60 00 00 (3) ? */
689 reg_w(gspca_dev, 0xd4, &data, 1);
690 712
691 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); 713 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
692 714
693 switch (sd->bridge) { 715 switch (sd->bridge) {
694 case BRIDGE_SN9C120: /* from win trace */ 716 case BRIDGE_SN9C120: /* from win trace */
695 data = 0x61; 717 reg_w1(gspca_dev, 0x01, 0x61);
696 reg_w(gspca_dev, 0x01, &data, 1); 718 reg_w1(gspca_dev, 0x17, 0x20);
697 data = 0x20; 719 reg_w1(gspca_dev, 0x01, 0x60);
698 reg_w(gspca_dev, 0x17, &data, 1);
699 data = 0x60;
700 reg_w(gspca_dev, 0x01, &data, 1);
701 break; 720 break;
702 case BRIDGE_SN9C325: 721 case BRIDGE_SN9C325:
703 data = 0x43; 722 reg_w1(gspca_dev, 0x01, 0x43);
704 reg_w(gspca_dev, 0x01, &data, 1); 723 reg_w1(gspca_dev, 0x17, 0xae);
705 data = 0xae; 724 reg_w1(gspca_dev, 0x01, 0x42);
706 reg_w(gspca_dev, 0x17, &data, 1);
707 data = 0x42;
708 reg_w(gspca_dev, 0x01, &data, 1);
709 break; 725 break;
710 default: 726 default:
711 data = 0x43; 727 reg_w1(gspca_dev, 0x01, 0x43);
712 reg_w(gspca_dev, 0x01, &data, 1); 728 reg_w1(gspca_dev, 0x17, 0x61);
713 data = 0x61; 729 reg_w1(gspca_dev, 0x01, 0x42);
714 reg_w(gspca_dev, 0x17, &data, 1);
715 data = 0x42;
716 reg_w(gspca_dev, 0x01, &data, 1);
717 } 730 }
718 731
719 if (sd->sensor == SENSOR_HV7131R) { 732 if (sd->sensor == SENSOR_HV7131R) {
@@ -770,6 +783,9 @@ static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
770{ 783{
771 int i = 0; 784 int i = 0;
772 785
786 i2c_w8(gspca_dev, ov7660_sensor_init[i]); /* reset SCCB */
787 i++;
788 msleep(20);
773 while (ov7660_sensor_init[i][0]) { 789 while (ov7660_sensor_init[i][0]) {
774 i2c_w8(gspca_dev, ov7660_sensor_init[i]); 790 i2c_w8(gspca_dev, ov7660_sensor_init[i]);
775 i++; 791 i++;
@@ -782,13 +798,11 @@ static int sd_config(struct gspca_dev *gspca_dev,
782{ 798{
783 struct sd *sd = (struct sd *) gspca_dev; 799 struct sd *sd = (struct sd *) gspca_dev;
784 struct cam *cam; 800 struct cam *cam;
785 __u16 vendor;
786 __u16 product; 801 __u16 product;
787 802
788 vendor = id->idVendor;
789 product = id->idProduct; 803 product = id->idProduct;
790 sd->sensor = -1; 804 sd->sensor = -1;
791 switch (vendor) { 805 switch (id->idVendor) {
792 case 0x0458: /* Genius */ 806 case 0x0458: /* Genius */
793/* switch (product) { 807/* switch (product) {
794 case 0x7025: */ 808 case 0x7025: */
@@ -960,7 +974,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
960 } 974 }
961 if (sd->sensor < 0) { 975 if (sd->sensor < 0) {
962 PDEBUG(D_ERR, "Invalid vendor/product %04x:%04x", 976 PDEBUG(D_ERR, "Invalid vendor/product %04x:%04x",
963 vendor, product); 977 id->idVendor, product);
964 return -EINVAL; 978 return -EINVAL;
965 } 979 }
966 980
@@ -983,34 +997,26 @@ static int sd_open(struct gspca_dev *gspca_dev)
983{ 997{
984 struct sd *sd = (struct sd *) gspca_dev; 998 struct sd *sd = (struct sd *) gspca_dev;
985/* const __u8 *sn9c1xx; */ 999/* const __u8 *sn9c1xx; */
986 __u8 regF1;
987 __u8 regGpio[] = { 0x29, 0x74 }; 1000 __u8 regGpio[] = { 0x29, 0x74 };
1001 __u8 regF1;
988 1002
989 /* setup a selector by bridge */ 1003 /* setup a selector by bridge */
990 regF1 = 0x01; 1004 reg_w1(gspca_dev, 0xf1, 0x01);
991 reg_w(gspca_dev, 0xf1, &regF1, 1);
992 reg_r(gspca_dev, 0x00, 1); /* -> regF1 = 0x00 */ 1005 reg_r(gspca_dev, 0x00, 1); /* -> regF1 = 0x00 */
993 regF1 = gspca_dev->usb_buf[0]; 1006 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
994 reg_w(gspca_dev, 0xf1, &regF1, 1);
995 reg_r(gspca_dev, 0x00, 1); 1007 reg_r(gspca_dev, 0x00, 1);
996 regF1 = gspca_dev->usb_buf[0]; 1008 regF1 = gspca_dev->usb_buf[0];
997 switch (sd->bridge) { 1009 switch (sd->bridge) {
998 case BRIDGE_SN9C102P: 1010 case BRIDGE_SN9C102P:
999 if (regF1 != 0x11) 1011 if (regF1 != 0x11)
1000 return -ENODEV; 1012 return -ENODEV;
1001 reg_w(gspca_dev, 0x02, &regGpio[1], 1); 1013 reg_w1(gspca_dev, 0x02, regGpio[1]);
1002 break; 1014 break;
1003 case BRIDGE_SN9C105: 1015 case BRIDGE_SN9C105:
1004 if (regF1 != 0x11) 1016 if (regF1 != 0x11)
1005 return -ENODEV; 1017 return -ENODEV;
1006 reg_w(gspca_dev, 0x02, regGpio, 2); 1018 reg_w(gspca_dev, 0x02, regGpio, 2);
1007 break; 1019 break;
1008 case BRIDGE_SN9C110:
1009 if (regF1 != 0x12)
1010 return -ENODEV;
1011 regGpio[1] = 0x62;
1012 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1013 break;
1014 case BRIDGE_SN9C120: 1020 case BRIDGE_SN9C120:
1015 if (regF1 != 0x12) 1021 if (regF1 != 0x12)
1016 return -ENODEV; 1022 return -ENODEV;
@@ -1018,16 +1024,15 @@ static int sd_open(struct gspca_dev *gspca_dev)
1018 reg_w(gspca_dev, 0x02, regGpio, 2); 1024 reg_w(gspca_dev, 0x02, regGpio, 2);
1019 break; 1025 break;
1020 default: 1026 default:
1027/* case BRIDGE_SN9C110: */
1021/* case BRIDGE_SN9C325: */ 1028/* case BRIDGE_SN9C325: */
1022 if (regF1 != 0x12) 1029 if (regF1 != 0x12)
1023 return -ENODEV; 1030 return -ENODEV;
1024 regGpio[1] = 0x62; 1031 reg_w1(gspca_dev, 0x02, 0x62);
1025 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1026 break; 1032 break;
1027 } 1033 }
1028 1034
1029 regF1 = 0x01; 1035 reg_w1(gspca_dev, 0xf1, 0x01);
1030 reg_w(gspca_dev, 0xf1, &regF1, 1);
1031 1036
1032 return 0; 1037 return 0;
1033} 1038}
@@ -1123,7 +1128,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1123 } 1128 }
1124 1129
1125 k2 = sd->brightness >> 10; 1130 k2 = sd->brightness >> 10;
1126 reg_w(gspca_dev, 0x96, &k2, 1); 1131 reg_w1(gspca_dev, 0x96, k2);
1127} 1132}
1128 1133
1129static void setcontrast(struct gspca_dev *gspca_dev) 1134static void setcontrast(struct gspca_dev *gspca_dev)
@@ -1152,7 +1157,7 @@ static void setcolors(struct gspca_dev *gspca_dev)
1152 data = (colour + 32) & 0x7f; /* blue */ 1157 data = (colour + 32) & 0x7f; /* blue */
1153 else 1158 else
1154 data = (-colour + 32) & 0x7f; /* red */ 1159 data = (-colour + 32) & 0x7f; /* red */
1155 reg_w(gspca_dev, 0x05, &data, 1); 1160 reg_w1(gspca_dev, 0x05, data);
1156} 1161}
1157 1162
1158/* -- start the camera -- */ 1163/* -- start the camera -- */
@@ -1165,7 +1170,6 @@ static void sd_start(struct gspca_dev *gspca_dev)
1165 __u8 reg17; 1170 __u8 reg17;
1166 const __u8 *sn9c1xx; 1171 const __u8 *sn9c1xx;
1167 int mode; 1172 int mode;
1168 static const __u8 DC29[] = { 0x6a, 0x50, 0x00, 0x00, 0x50, 0x3c };
1169 static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; 1173 static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1170 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; 1174 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1171 static const __u8 CA_sn9c120[] = 1175 static const __u8 CA_sn9c120[] =
@@ -1179,21 +1183,20 @@ static void sd_start(struct gspca_dev *gspca_dev)
1179 1183
1180/*fixme:jfm this sequence should appear at end of sd_start */ 1184/*fixme:jfm this sequence should appear at end of sd_start */
1181/* with 1185/* with
1182 data = 0x44; 1186 reg_w1(gspca_dev, 0x01, 0x44); */
1183 reg_w(gspca_dev, 0x01, &data, 1); */ 1187 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
1184 reg_w(gspca_dev, 0x15, &sn9c1xx[0x15], 1); 1188 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
1185 reg_w(gspca_dev, 0x16, &sn9c1xx[0x16], 1); 1189 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1186 reg_w(gspca_dev, 0x12, &sn9c1xx[0x12], 1); 1190 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1187 reg_w(gspca_dev, 0x13, &sn9c1xx[0x13], 1); 1191 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1188 reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1); 1192 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
1189 reg_w(gspca_dev, 0xd2, &DC29[0], 1); 1193 reg_w1(gspca_dev, 0xd3, 0x50);
1190 reg_w(gspca_dev, 0xd3, &DC29[1], 1); 1194 reg_w1(gspca_dev, 0xc6, 0x00);
1191 reg_w(gspca_dev, 0xc6, &DC29[2], 1); 1195 reg_w1(gspca_dev, 0xc7, 0x00);
1192 reg_w(gspca_dev, 0xc7, &DC29[3], 1); 1196 reg_w1(gspca_dev, 0xc8, 0x50);
1193 reg_w(gspca_dev, 0xc8, &DC29[4], 1); 1197 reg_w1(gspca_dev, 0xc9, 0x3c);
1194 reg_w(gspca_dev, 0xc9, &DC29[5], 1);
1195/*fixme:jfm end of ending sequence */ 1198/*fixme:jfm end of ending sequence */
1196 reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1); 1199 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1197 switch (sd->bridge) { 1200 switch (sd->bridge) {
1198 case BRIDGE_SN9C325: 1201 case BRIDGE_SN9C325:
1199 data = 0xae; 1202 data = 0xae;
@@ -1205,11 +1208,11 @@ static void sd_start(struct gspca_dev *gspca_dev)
1205 data = 0x60; 1208 data = 0x60;
1206 break; 1209 break;
1207 } 1210 }
1208 reg_w(gspca_dev, 0x17, &data, 1); 1211 reg_w1(gspca_dev, 0x17, data);
1209 reg_w(gspca_dev, 0x05, &sn9c1xx[5], 1); 1212 reg_w1(gspca_dev, 0x05, sn9c1xx[5]);
1210 reg_w(gspca_dev, 0x07, &sn9c1xx[7], 1); 1213 reg_w1(gspca_dev, 0x07, sn9c1xx[7]);
1211 reg_w(gspca_dev, 0x06, &sn9c1xx[6], 1); 1214 reg_w1(gspca_dev, 0x06, sn9c1xx[6]);
1212 reg_w(gspca_dev, 0x14, &sn9c1xx[0x14], 1); 1215 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
1213 switch (sd->bridge) { 1216 switch (sd->bridge) {
1214 case BRIDGE_SN9C325: 1217 case BRIDGE_SN9C325:
1215 reg_w(gspca_dev, 0x20, regsn20_sn9c325, 1218 reg_w(gspca_dev, 0x20, regsn20_sn9c325,
@@ -1217,10 +1220,8 @@ static void sd_start(struct gspca_dev *gspca_dev)
1217 for (i = 0; i < 8; i++) 1220 for (i = 0; i < 8; i++)
1218 reg_w(gspca_dev, 0x84, reg84_sn9c325, 1221 reg_w(gspca_dev, 0x84, reg84_sn9c325,
1219 sizeof reg84_sn9c325); 1222 sizeof reg84_sn9c325);
1220 data = 0x0a; 1223 reg_w1(gspca_dev, 0x9a, 0x0a);
1221 reg_w(gspca_dev, 0x9a, &data, 1); 1224 reg_w1(gspca_dev, 0x99, 0x60);
1222 data = 0x60;
1223 reg_w(gspca_dev, 0x99, &data, 1);
1224 break; 1225 break;
1225 case BRIDGE_SN9C120: 1226 case BRIDGE_SN9C120:
1226 reg_w(gspca_dev, 0x20, regsn20_sn9c120, 1227 reg_w(gspca_dev, 0x20, regsn20_sn9c120,
@@ -1233,39 +1234,30 @@ static void sd_start(struct gspca_dev *gspca_dev)
1233 sizeof reg84_sn9c120_2); 1234 sizeof reg84_sn9c120_2);
1234 reg_w(gspca_dev, 0x84, reg84_sn9c120_3, 1235 reg_w(gspca_dev, 0x84, reg84_sn9c120_3,
1235 sizeof reg84_sn9c120_3); 1236 sizeof reg84_sn9c120_3);
1236 data = 0x05; 1237 reg_w1(gspca_dev, 0x9a, 0x05);
1237 reg_w(gspca_dev, 0x9a, &data, 1); 1238 reg_w1(gspca_dev, 0x99, 0x5b);
1238 data = 0x5b;
1239 reg_w(gspca_dev, 0x99, &data, 1);
1240 break; 1239 break;
1241 default: 1240 default:
1242 reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20); 1241 reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20);
1243 for (i = 0; i < 8; i++) 1242 for (i = 0; i < 8; i++)
1244 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 1243 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1245 data = 0x08; 1244 reg_w1(gspca_dev, 0x9a, 0x08);
1246 reg_w(gspca_dev, 0x9a, &data, 1); 1245 reg_w1(gspca_dev, 0x99, 0x59);
1247 data = 0x59;
1248 reg_w(gspca_dev, 0x99, &data, 1);
1249 break; 1246 break;
1250 } 1247 }
1251 1248
1252 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 1249 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1253 reg1 = 0x02; 1250 if (mode)
1251 reg1 = 0x46; /* 320 clk 48Mhz */
1252 else
1253 reg1 = 0x06; /* 640 clk 24Mz */
1254 reg17 = 0x61; 1254 reg17 = 0x61;
1255 switch (sd->sensor) { 1255 switch (sd->sensor) {
1256 case SENSOR_HV7131R: 1256 case SENSOR_HV7131R:
1257 hv7131R_InitSensor(gspca_dev); 1257 hv7131R_InitSensor(gspca_dev);
1258 if (mode)
1259 reg1 = 0x46; /* 320 clk 48Mhz */
1260 else
1261 reg1 = 0x06; /* 640 clk 24Mz */
1262 break; 1258 break;
1263 case SENSOR_MI0360: 1259 case SENSOR_MI0360:
1264 mi0360_InitSensor(gspca_dev); 1260 mi0360_InitSensor(gspca_dev);
1265 if (mode)
1266 reg1 = 0x46; /* 320 clk 48Mhz */
1267 else
1268 reg1 = 0x06; /* 640 clk 24Mz */
1269 break; 1261 break;
1270 case SENSOR_MO4000: 1262 case SENSOR_MO4000:
1271 mo4000_InitSensor(gspca_dev); 1263 mo4000_InitSensor(gspca_dev);
@@ -1274,13 +1266,13 @@ static void sd_start(struct gspca_dev *gspca_dev)
1274 reg1 = 0x06; /* clk 24Mz */ 1266 reg1 = 0x06; /* clk 24Mz */
1275 } else { 1267 } else {
1276 reg17 = 0x22; /* 640 MCKSIZE */ 1268 reg17 = 0x22; /* 640 MCKSIZE */
1277 reg1 = 0x06; /* 640 clk 24Mz */ 1269/* reg1 = 0x06; * 640 clk 24Mz (done) */
1278 } 1270 }
1279 break; 1271 break;
1280 case SENSOR_OV7648: 1272 case SENSOR_OV7648:
1273 ov7648_InitSensor(gspca_dev);
1281 reg17 = 0xa2; 1274 reg17 = 0xa2;
1282 reg1 = 0x44; 1275 reg1 = 0x44;
1283 ov7648_InitSensor(gspca_dev);
1284/* if (mode) 1276/* if (mode)
1285 ; * 320x2... 1277 ; * 320x2...
1286 else 1278 else
@@ -1292,7 +1284,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
1292 if (mode) { 1284 if (mode) {
1293/* reg17 = 0x21; * 320 */ 1285/* reg17 = 0x21; * 320 */
1294/* reg1 = 0x44; */ 1286/* reg1 = 0x44; */
1295 reg1 = 0x46; 1287/* reg1 = 0x46; (done) */
1296 } else { 1288 } else {
1297 reg17 = 0xa2; /* 640 */ 1289 reg17 = 0xa2; /* 640 */
1298 reg1 = 0x40; 1290 reg1 = 0x40;
@@ -1321,16 +1313,16 @@ static void sd_start(struct gspca_dev *gspca_dev)
1321 1313
1322 /* here change size mode 0 -> VGA; 1 -> CIF */ 1314 /* here change size mode 0 -> VGA; 1 -> CIF */
1323 data = 0x40 | sn9c1xx[0x18] | (mode << 4); 1315 data = 0x40 | sn9c1xx[0x18] | (mode << 4);
1324 reg_w(gspca_dev, 0x18, &data, 1); 1316 reg_w1(gspca_dev, 0x18, data);
1325 1317
1326 reg_w(gspca_dev, 0x100, qtable4, 0x40); 1318 reg_w(gspca_dev, 0x100, qtable4, 0x40);
1327 reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40); 1319 reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40);
1328 1320
1329 data = sn9c1xx[0x18] | (mode << 4); 1321 data = sn9c1xx[0x18] | (mode << 4);
1330 reg_w(gspca_dev, 0x18, &data, 1); 1322 reg_w1(gspca_dev, 0x18, data);
1331 1323
1332 reg_w(gspca_dev, 0x17, &reg17, 1); 1324 reg_w1(gspca_dev, 0x17, reg17);
1333 reg_w(gspca_dev, 0x01, &reg1, 1); 1325 reg_w1(gspca_dev, 0x01, reg1);
1334 setbrightness(gspca_dev); 1326 setbrightness(gspca_dev);
1335 setcontrast(gspca_dev); 1327 setcontrast(gspca_dev);
1336} 1328}
@@ -1342,7 +1334,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1342 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; 1334 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
1343 static const __u8 stopmi0360[] = 1335 static const __u8 stopmi0360[] =
1344 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; 1336 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
1345 __u8 regF1;
1346 __u8 data; 1337 __u8 data;
1347 const __u8 *sn9c1xx; 1338 const __u8 *sn9c1xx;
1348 1339
@@ -1366,12 +1357,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1366 break; 1357 break;
1367 } 1358 }
1368 sn9c1xx = sn_tb[(int) sd->sensor]; 1359 sn9c1xx = sn_tb[(int) sd->sensor];
1369 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1); 1360 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1370 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 1); 1361 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
1371 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1); 1362 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1372 reg_w(gspca_dev, 0x01, &data, 1); 1363 reg_w1(gspca_dev, 0x01, data);
1373 regF1 = 0x01; 1364 reg_w1(gspca_dev, 0xf1, 0x01);
1374 reg_w(gspca_dev, 0xf1, &regF1, 1);
1375} 1365}
1376 1366
1377static void sd_stop0(struct gspca_dev *gspca_dev) 1367static void sd_stop0(struct gspca_dev *gspca_dev)