aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sonixj.c
diff options
context:
space:
mode:
authorJean-François Moine <moinejf@free.fr>2010-10-01 06:51:24 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:06:21 -0400
commita067db847335207bd059f5b93bcbbb04910d8a69 (patch)
treeebcebbfd8c78c14b7147509bedb5f186744107fa /drivers/media/video/gspca/sonixj.c
parent294d8b4a969b834f0d02c623eef050a0f3c1e209 (diff)
V4L/DVB: gspca - sonixj: Add sensor mi0360b
Signed-off-by: Jean-François Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r--drivers/media/video/gspca/sonixj.c114
1 files changed, 112 insertions, 2 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 6e04ac79f401..3c699ac5233f 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -75,6 +75,7 @@ enum sensors {
75 SENSOR_GC0307, 75 SENSOR_GC0307,
76 SENSOR_HV7131R, 76 SENSOR_HV7131R,
77 SENSOR_MI0360, 77 SENSOR_MI0360,
78 SENSOR_MI0360B,
78 SENSOR_MO4000, 79 SENSOR_MO4000,
79 SENSOR_MT9V111, 80 SENSOR_MT9V111,
80 SENSOR_OM6802, 81 SENSOR_OM6802,
@@ -302,6 +303,10 @@ static const __u32 ctrl_dis[] = {
302 (1 << VFLIP_IDX) | 303 (1 << VFLIP_IDX) |
303 (1 << FREQ_IDX), 304 (1 << FREQ_IDX),
304 305
306[SENSOR_MI0360B] = (1 << INFRARED_IDX) |
307 (1 << VFLIP_IDX) |
308 (1 << FREQ_IDX),
309
305[SENSOR_MO4000] = (1 << INFRARED_IDX) | 310[SENSOR_MO4000] = (1 << INFRARED_IDX) |
306 (1 << VFLIP_IDX) | 311 (1 << VFLIP_IDX) |
307 (1 << FREQ_IDX), 312 (1 << FREQ_IDX),
@@ -411,6 +416,17 @@ static const u8 sn_mi0360[0x1c] = {
411 0x06, 0x00, 0x00, 0x00 416 0x06, 0x00, 0x00, 0x00
412}; 417};
413 418
419static const u8 sn_mi0360b[0x1c] = {
420/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
421 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
422/* reg8 reg9 rega regb regc regd rege regf */
423 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
424/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
425 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
426/* reg18 reg19 reg1a reg1b */
427 0x06, 0x00, 0x00, 0x00
428};
429
414static const u8 sn_mo4000[0x1c] = { 430static const u8 sn_mo4000[0x1c] = {
415/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ 431/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
416 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, 432 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
@@ -527,6 +543,7 @@ static const u8 *sn_tb[] = {
527[SENSOR_GC0307] = sn_gc0307, 543[SENSOR_GC0307] = sn_gc0307,
528[SENSOR_HV7131R] = sn_hv7131, 544[SENSOR_HV7131R] = sn_hv7131,
529[SENSOR_MI0360] = sn_mi0360, 545[SENSOR_MI0360] = sn_mi0360,
546[SENSOR_MI0360B] = sn_mi0360b,
530[SENSOR_MO4000] = sn_mo4000, 547[SENSOR_MO4000] = sn_mo4000,
531[SENSOR_MT9V111] = sn_mt9v111, 548[SENSOR_MT9V111] = sn_mt9v111,
532[SENSOR_OM6802] = sn_om6802, 549[SENSOR_OM6802] = sn_om6802,
@@ -747,6 +764,62 @@ static const u8 mi0360_sensor_init[][8] = {
747 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ 764 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
748 {} 765 {}
749}; 766};
767static const u8 mi0360b_sensor_init[][8] = {
768 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
769 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
770 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
771 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
772 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
773 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
774 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
775 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
777 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
778 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
779 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
780 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
781 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
783 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
784 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
785 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
786 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
787 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
789 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
792 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
793 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
794 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
795 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
796 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
797 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
798 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
799 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
800 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
801 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
802 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
803
804 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
805 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
806 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
807 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
808 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
809 {}
810};
811static const u8 mi0360b_sensor_param1[][8] = {
812 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
813 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
814 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
815 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
816
817 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
818 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
819 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
820 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
821 {}
822};
750static const u8 mo4000_sensor_init[][8] = { 823static const u8 mo4000_sensor_init[][8] = {
751 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, 824 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
752 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, 825 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
@@ -1310,6 +1383,7 @@ static const u8 (*sensor_init[])[8] = {
1310[SENSOR_GC0307] = gc0307_sensor_init, 1383[SENSOR_GC0307] = gc0307_sensor_init,
1311[SENSOR_HV7131R] = hv7131r_sensor_init, 1384[SENSOR_HV7131R] = hv7131r_sensor_init,
1312[SENSOR_MI0360] = mi0360_sensor_init, 1385[SENSOR_MI0360] = mi0360_sensor_init,
1386[SENSOR_MI0360B] = mi0360b_sensor_init,
1313[SENSOR_MO4000] = mo4000_sensor_init, 1387[SENSOR_MO4000] = mo4000_sensor_init,
1314[SENSOR_MT9V111] = mt9v111_sensor_init, 1388[SENSOR_MT9V111] = mt9v111_sensor_init,
1315[SENSOR_OM6802] = om6802_sensor_init, 1389[SENSOR_OM6802] = om6802_sensor_init,
@@ -1571,6 +1645,10 @@ static void mi0360_probe(struct gspca_dev *gspca_dev)
1571 if (gspca_dev->usb_err < 0) 1645 if (gspca_dev->usb_err < 0)
1572 return; 1646 return;
1573 switch (val) { 1647 switch (val) {
1648 case 0x8221:
1649 PDEBUG(D_PROBE, "Sensor mi0360b");
1650 sd->sensor = SENSOR_MI0360B;
1651 break;
1574 case 0x823a: 1652 case 0x823a:
1575 PDEBUG(D_PROBE, "Sensor mt9v111"); 1653 PDEBUG(D_PROBE, "Sensor mt9v111");
1576 sd->sensor = SENSOR_MT9V111; 1654 sd->sensor = SENSOR_MT9V111;
@@ -1744,6 +1822,12 @@ static void bridge_init(struct gspca_dev *gspca_dev,
1744 reg_w1(gspca_dev, 0x01, 0x40); 1822 reg_w1(gspca_dev, 0x01, 0x40);
1745 msleep(50); 1823 msleep(50);
1746 break; 1824 break;
1825 case SENSOR_MI0360B:
1826 reg_w1(gspca_dev, 0x01, 0x61);
1827 reg_w1(gspca_dev, 0x17, 0x60);
1828 reg_w1(gspca_dev, 0x01, 0x60);
1829 reg_w1(gspca_dev, 0x01, 0x40);
1830 break;
1747 case SENSOR_MT9V111: 1831 case SENSOR_MT9V111:
1748 reg_w1(gspca_dev, 0x01, 0x61); 1832 reg_w1(gspca_dev, 0x01, 0x61);
1749 reg_w1(gspca_dev, 0x17, 0x61); 1833 reg_w1(gspca_dev, 0x17, 0x61);
@@ -1961,7 +2045,8 @@ static u32 setexposure(struct gspca_dev *gspca_dev,
1961 i2c_w8(gspca_dev, Expodoit); 2045 i2c_w8(gspca_dev, Expodoit);
1962 break; 2046 break;
1963 } 2047 }
1964 case SENSOR_MI0360: { 2048 case SENSOR_MI0360:
2049 case SENSOR_MI0360B: {
1965 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ 2050 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
1966 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 }; 2051 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
1967 static const u8 doit[] = /* update sensor */ 2052 static const u8 doit[] = /* update sensor */
@@ -2061,6 +2146,10 @@ static void setbrightness(struct gspca_dev *gspca_dev)
2061 expo = sd->brightness >> 4; 2146 expo = sd->brightness >> 4;
2062 sd->exposure = setexposure(gspca_dev, expo); 2147 sd->exposure = setexposure(gspca_dev, expo);
2063 break; 2148 break;
2149 case SENSOR_MI0360B:
2150 expo = sd->brightness >> 6;
2151 sd->exposure = setexposure(gspca_dev, expo);
2152 break;
2064 case SENSOR_GC0307: 2153 case SENSOR_GC0307:
2065 case SENSOR_MT9V111: 2154 case SENSOR_MT9V111:
2066 expo = sd->brightness >> 8; 2155 expo = sd->brightness >> 8;
@@ -2096,12 +2185,21 @@ static void setcolors(struct gspca_dev *gspca_dev)
2096{ 2185{
2097 struct sd *sd = (struct sd *) gspca_dev; 2186 struct sd *sd = (struct sd *) gspca_dev;
2098 int i, v; 2187 int i, v;
2188 const s16 *uv;
2099 u8 reg8a[12]; /* U & V gains */ 2189 u8 reg8a[12]; /* U & V gains */
2100 static const s16 uv[6] = { /* same as reg84 in signed decimal */ 2190 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
2101 -24, -38, 64, /* UR UG UB */ 2191 -24, -38, 64, /* UR UG UB */
2102 62, -51, -9 /* VR VG VB */ 2192 62, -51, -9 /* VR VG VB */
2103 }; 2193 };
2194 static const s16 uv_mi0360b[6] = {
2195 -20, -38, 64, /* UR UG UB */
2196 60, -51, -9 /* VR VG VB */
2197 };
2104 2198
2199 if (sd->sensor == SENSOR_MI0360B)
2200 uv = uv_mi0360b;
2201 else
2202 uv = uv_com;
2105 for (i = 0; i < 6; i++) { 2203 for (i = 0; i < 6; i++) {
2106 v = uv[i] * sd->colors / COLOR_DEF; 2204 v = uv[i] * sd->colors / COLOR_DEF;
2107 reg8a[i * 2] = v; 2205 reg8a[i * 2] = v;
@@ -2135,6 +2233,7 @@ static void setgamma(struct gspca_dev *gspca_dev)
2135 gamma_base = gamma_spec_0; 2233 gamma_base = gamma_spec_0;
2136 break; 2234 break;
2137 case SENSOR_HV7131R: 2235 case SENSOR_HV7131R:
2236 case SENSOR_MI0360B:
2138 case SENSOR_MT9V111: 2237 case SENSOR_MT9V111:
2139 gamma_base = gamma_spec_1; 2238 gamma_base = gamma_spec_1;
2140 break; 2239 break;
@@ -2383,6 +2482,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2383 reg17 = 0xa2; 2482 reg17 = 0xa2;
2384 break; 2483 break;
2385 case SENSOR_MT9V111: 2484 case SENSOR_MT9V111:
2485 case SENSOR_MI0360B:
2386 reg17 = 0xe0; 2486 reg17 = 0xe0;
2387 break; 2487 break;
2388 case SENSOR_ADCM1700: 2488 case SENSOR_ADCM1700:
@@ -2424,6 +2524,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2424 break; 2524 break;
2425 case SENSOR_GC0307: 2525 case SENSOR_GC0307:
2426 case SENSOR_MT9V111: 2526 case SENSOR_MT9V111:
2527 case SENSOR_MI0360B:
2427 reg_w1(gspca_dev, 0x9a, 0x07); 2528 reg_w1(gspca_dev, 0x9a, 0x07);
2428 break; 2529 break;
2429 case SENSOR_OV7630: 2530 case SENSOR_OV7630:
@@ -2463,6 +2564,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
2463 reg17 = 0xa2; 2564 reg17 = 0xa2;
2464 reg1 = 0x44; 2565 reg1 = 0x44;
2465 break; 2566 break;
2567 case SENSOR_MI0360B:
2568 init = mi0360b_sensor_param1;
2569 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2570 reg17 = 0xe2;
2571 break;
2466 case SENSOR_MO4000: 2572 case SENSOR_MO4000:
2467 if (mode) { 2573 if (mode) {
2468/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ 2574/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
@@ -2617,6 +2723,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2617 data = 0x2b; 2723 data = 0x2b;
2618 break; 2724 break;
2619 case SENSOR_MI0360: 2725 case SENSOR_MI0360:
2726 case SENSOR_MI0360B:
2620 i2c_w8(gspca_dev, stopmi0360); 2727 i2c_w8(gspca_dev, stopmi0360);
2621 data = 0x29; 2728 data = 0x29;
2622 break; 2729 break;
@@ -2690,6 +2797,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
2690 default: 2797 default:
2691/* case SENSOR_MO4000: */ 2798/* case SENSOR_MO4000: */
2692/* case SENSOR_MI0360: */ 2799/* case SENSOR_MI0360: */
2800/* case SENSOR_MI0360B: */
2693/* case SENSOR_MT9V111: */ 2801/* case SENSOR_MT9V111: */
2694 expotimes = sd->exposure; 2802 expotimes = sd->exposure;
2695 expotimes += (luma_mean - delta) >> 6; 2803 expotimes += (luma_mean - delta) >> 6;
@@ -3054,6 +3162,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
3054 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, 3162 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
3055/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ 3163/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
3056 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)}, 3164 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
3165 /* or MT9V111 */
3057/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ 3166/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
3058/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ 3167/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
3059/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */ 3168/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
@@ -3086,6 +3195,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
3086/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */ 3195/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
3087#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 3196#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
3088 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)}, 3197 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
3198 /* or MT9V111 / MI0360B */
3089#endif 3199#endif
3090/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ 3200/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3091 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, 3201 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},