diff options
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 416 |
1 files changed, 184 insertions, 232 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 330dadc00106..e23de57e2c73 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -63,7 +63,10 @@ struct sd { | |||
63 | #define QUALITY_DEF 80 | 63 | #define QUALITY_DEF 80 |
64 | u8 jpegqual; /* webcam quality */ | 64 | u8 jpegqual; /* webcam quality */ |
65 | 65 | ||
66 | u8 reg01; | ||
67 | u8 reg17; | ||
66 | u8 reg18; | 68 | u8 reg18; |
69 | u8 flags; | ||
67 | 70 | ||
68 | s8 ag_cnt; | 71 | s8 ag_cnt; |
69 | #define AG_CNT_START 13 | 72 | #define AG_CNT_START 13 |
@@ -96,6 +99,22 @@ enum sensors { | |||
96 | SENSOR_SP80708, | 99 | SENSOR_SP80708, |
97 | }; | 100 | }; |
98 | 101 | ||
102 | /* device flags */ | ||
103 | #define PDN_INV 1 /* inverse pin S_PWR_DN / sn_xxx tables */ | ||
104 | |||
105 | /* sn9c1xx definitions */ | ||
106 | /* register 0x01 */ | ||
107 | #define S_PWR_DN 0x01 /* sensor power down */ | ||
108 | #define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */ | ||
109 | #define V_TX_EN 0x04 /* video transfer enable */ | ||
110 | #define LED 0x08 /* output to pin LED */ | ||
111 | #define SCL_SEL_OD 0x20 /* open-drain mode */ | ||
112 | #define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */ | ||
113 | /* register 0x17 */ | ||
114 | #define MCK_SIZE_MASK 0x1f /* sensor master clock */ | ||
115 | #define SEN_CLK_EN 0x20 /* enable sensor clock */ | ||
116 | #define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */ | ||
117 | |||
99 | /* V4L2 controls supported by the driver */ | 118 | /* V4L2 controls supported by the driver */ |
100 | static void setbrightness(struct gspca_dev *gspca_dev); | 119 | static void setbrightness(struct gspca_dev *gspca_dev); |
101 | static void setcontrast(struct gspca_dev *gspca_dev); | 120 | static void setcontrast(struct gspca_dev *gspca_dev); |
@@ -1755,141 +1774,6 @@ static void po2030n_probe(struct gspca_dev *gspca_dev) | |||
1755 | } | 1774 | } |
1756 | } | 1775 | } |
1757 | 1776 | ||
1758 | static void bridge_init(struct gspca_dev *gspca_dev, | ||
1759 | const u8 *sn9c1xx) | ||
1760 | { | ||
1761 | struct sd *sd = (struct sd *) gspca_dev; | ||
1762 | u8 reg0102[2]; | ||
1763 | const u8 *reg9a; | ||
1764 | static const u8 reg9a_def[] = | ||
1765 | {0x00, 0x40, 0x20, 0x00, 0x00, 0x00}; | ||
1766 | static const u8 reg9a_spec[] = | ||
1767 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; | ||
1768 | static const u8 regd4[] = {0x60, 0x00, 0x00}; | ||
1769 | |||
1770 | /* sensor clock already enabled in sd_init */ | ||
1771 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ | ||
1772 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | ||
1773 | |||
1774 | /* configure gpio */ | ||
1775 | reg0102[0] = sn9c1xx[1]; | ||
1776 | reg0102[1] = sn9c1xx[2]; | ||
1777 | if (gspca_dev->audio) | ||
1778 | reg0102[1] |= 0x04; /* keep the audio connection */ | ||
1779 | reg_w(gspca_dev, 0x01, reg0102, 2); | ||
1780 | reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); | ||
1781 | reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); | ||
1782 | switch (sd->sensor) { | ||
1783 | case SENSOR_GC0307: | ||
1784 | case SENSOR_OV7660: | ||
1785 | case SENSOR_PO1030: | ||
1786 | case SENSOR_PO2030N: | ||
1787 | case SENSOR_SOI768: | ||
1788 | case SENSOR_SP80708: | ||
1789 | reg9a = reg9a_spec; | ||
1790 | break; | ||
1791 | default: | ||
1792 | reg9a = reg9a_def; | ||
1793 | break; | ||
1794 | } | ||
1795 | reg_w(gspca_dev, 0x9a, reg9a, 6); | ||
1796 | |||
1797 | reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); | ||
1798 | |||
1799 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); | ||
1800 | |||
1801 | switch (sd->sensor) { | ||
1802 | case SENSOR_ADCM1700: | ||
1803 | reg_w1(gspca_dev, 0x01, 0x43); | ||
1804 | reg_w1(gspca_dev, 0x17, 0x62); | ||
1805 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1806 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1807 | break; | ||
1808 | case SENSOR_GC0307: | ||
1809 | msleep(50); | ||
1810 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1811 | reg_w1(gspca_dev, 0x17, 0x22); | ||
1812 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1813 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1814 | msleep(50); | ||
1815 | break; | ||
1816 | case SENSOR_MI0360B: | ||
1817 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1818 | reg_w1(gspca_dev, 0x17, 0x60); | ||
1819 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1820 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1821 | break; | ||
1822 | case SENSOR_MT9V111: | ||
1823 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1824 | reg_w1(gspca_dev, 0x17, 0x61); | ||
1825 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1826 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1827 | break; | ||
1828 | case SENSOR_OM6802: | ||
1829 | msleep(10); | ||
1830 | reg_w1(gspca_dev, 0x02, 0x73); | ||
1831 | reg_w1(gspca_dev, 0x17, 0x60); | ||
1832 | reg_w1(gspca_dev, 0x01, 0x22); | ||
1833 | msleep(100); | ||
1834 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1835 | reg_w1(gspca_dev, 0x17, 0x64); | ||
1836 | reg_w1(gspca_dev, 0x17, 0x64); | ||
1837 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1838 | msleep(10); | ||
1839 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1840 | i2c_w8(gspca_dev, om6802_init0[0]); | ||
1841 | i2c_w8(gspca_dev, om6802_init0[1]); | ||
1842 | msleep(15); | ||
1843 | reg_w1(gspca_dev, 0x02, 0x71); | ||
1844 | msleep(150); | ||
1845 | break; | ||
1846 | case SENSOR_OV7630: | ||
1847 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1848 | reg_w1(gspca_dev, 0x17, 0xe2); | ||
1849 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1850 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1851 | break; | ||
1852 | case SENSOR_OV7648: | ||
1853 | reg_w1(gspca_dev, 0x01, 0x63); | ||
1854 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1855 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1856 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1857 | break; | ||
1858 | case SENSOR_PO1030: | ||
1859 | case SENSOR_SOI768: | ||
1860 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1861 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1862 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1863 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1864 | break; | ||
1865 | case SENSOR_PO2030N: | ||
1866 | case SENSOR_OV7660: | ||
1867 | reg_w1(gspca_dev, 0x01, 0x63); | ||
1868 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1869 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1870 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1871 | break; | ||
1872 | case SENSOR_SP80708: | ||
1873 | reg_w1(gspca_dev, 0x01, 0x63); | ||
1874 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1875 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1876 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1877 | msleep(100); | ||
1878 | reg_w1(gspca_dev, 0x02, 0x62); | ||
1879 | break; | ||
1880 | default: | ||
1881 | /* case SENSOR_HV7131R: */ | ||
1882 | /* case SENSOR_MI0360: */ | ||
1883 | /* case SENSOR_MO4000: */ | ||
1884 | reg_w1(gspca_dev, 0x01, 0x43); | ||
1885 | reg_w1(gspca_dev, 0x17, 0x61); | ||
1886 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1887 | if (sd->sensor == SENSOR_HV7131R) | ||
1888 | hv7131r_probe(gspca_dev); | ||
1889 | break; | ||
1890 | } | ||
1891 | } | ||
1892 | |||
1893 | /* this function is called at probe time */ | 1777 | /* this function is called at probe time */ |
1894 | static int sd_config(struct gspca_dev *gspca_dev, | 1778 | static int sd_config(struct gspca_dev *gspca_dev, |
1895 | const struct usb_device_id *id) | 1779 | const struct usb_device_id *id) |
@@ -1898,7 +1782,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1898 | struct cam *cam; | 1782 | struct cam *cam; |
1899 | 1783 | ||
1900 | sd->bridge = id->driver_info >> 16; | 1784 | sd->bridge = id->driver_info >> 16; |
1901 | sd->sensor = id->driver_info; | 1785 | sd->sensor = id->driver_info >> 8; |
1786 | sd->flags = id->driver_info; | ||
1902 | 1787 | ||
1903 | cam = &gspca_dev->cam; | 1788 | cam = &gspca_dev->cam; |
1904 | if (sd->sensor == SENSOR_ADCM1700) { | 1789 | if (sd->sensor == SENSOR_ADCM1700) { |
@@ -1929,7 +1814,7 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1929 | /* setup a selector by bridge */ | 1814 | /* setup a selector by bridge */ |
1930 | reg_w1(gspca_dev, 0xf1, 0x01); | 1815 | reg_w1(gspca_dev, 0xf1, 0x01); |
1931 | reg_r(gspca_dev, 0x00, 1); | 1816 | reg_r(gspca_dev, 0x00, 1); |
1932 | reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]); | 1817 | reg_w1(gspca_dev, 0xf1, 0x00); |
1933 | reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ | 1818 | reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ |
1934 | regF1 = gspca_dev->usb_buf[0]; | 1819 | regF1 = gspca_dev->usb_buf[0]; |
1935 | if (gspca_dev->usb_err < 0) | 1820 | if (gspca_dev->usb_err < 0) |
@@ -2423,10 +2308,17 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2423 | { | 2308 | { |
2424 | struct sd *sd = (struct sd *) gspca_dev; | 2309 | struct sd *sd = (struct sd *) gspca_dev; |
2425 | int i; | 2310 | int i; |
2426 | u8 reg1, reg17; | 2311 | u8 reg01, reg17; |
2312 | u8 reg0102[2]; | ||
2427 | const u8 *sn9c1xx; | 2313 | const u8 *sn9c1xx; |
2428 | const u8 (*init)[8]; | 2314 | const u8 (*init)[8]; |
2315 | const u8 *reg9a; | ||
2429 | int mode; | 2316 | int mode; |
2317 | static const u8 reg9a_def[] = | ||
2318 | {0x00, 0x40, 0x20, 0x00, 0x00, 0x00}; | ||
2319 | static const u8 reg9a_spec[] = | ||
2320 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; | ||
2321 | static const u8 regd4[] = {0x60, 0x00, 0x00}; | ||
2430 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; | 2322 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
2431 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; | 2323 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
2432 | static const u8 CA_adcm1700[] = | 2324 | static const u8 CA_adcm1700[] = |
@@ -2448,7 +2340,85 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2448 | 2340 | ||
2449 | /* initialize the bridge */ | 2341 | /* initialize the bridge */ |
2450 | sn9c1xx = sn_tb[sd->sensor]; | 2342 | sn9c1xx = sn_tb[sd->sensor]; |
2451 | bridge_init(gspca_dev, sn9c1xx); | 2343 | |
2344 | /* sensor clock already enabled in sd_init */ | ||
2345 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ | ||
2346 | reg01 = sn9c1xx[1]; | ||
2347 | if (sd->flags & PDN_INV) | ||
2348 | reg01 ^= S_PDN_INV; /* power down inverted */ | ||
2349 | reg_w1(gspca_dev, 0x01, reg01); | ||
2350 | |||
2351 | /* configure gpio */ | ||
2352 | reg0102[0] = reg01; | ||
2353 | reg0102[1] = sn9c1xx[2]; | ||
2354 | if (gspca_dev->audio) | ||
2355 | reg0102[1] |= 0x04; /* keep the audio connection */ | ||
2356 | reg_w(gspca_dev, 0x01, reg0102, 2); | ||
2357 | reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); | ||
2358 | reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); | ||
2359 | switch (sd->sensor) { | ||
2360 | case SENSOR_GC0307: | ||
2361 | case SENSOR_OV7660: | ||
2362 | case SENSOR_PO1030: | ||
2363 | case SENSOR_PO2030N: | ||
2364 | case SENSOR_SOI768: | ||
2365 | case SENSOR_SP80708: | ||
2366 | reg9a = reg9a_spec; | ||
2367 | break; | ||
2368 | default: | ||
2369 | reg9a = reg9a_def; | ||
2370 | break; | ||
2371 | } | ||
2372 | reg_w(gspca_dev, 0x9a, reg9a, 6); | ||
2373 | |||
2374 | reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); | ||
2375 | |||
2376 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); | ||
2377 | |||
2378 | reg17 = sn9c1xx[0x17]; | ||
2379 | switch (sd->sensor) { | ||
2380 | case SENSOR_GC0307: | ||
2381 | msleep(50); /*fixme: is it useful? */ | ||
2382 | break; | ||
2383 | case SENSOR_OM6802: | ||
2384 | msleep(10); | ||
2385 | reg_w1(gspca_dev, 0x02, 0x73); | ||
2386 | reg17 |= SEN_CLK_EN; | ||
2387 | reg_w1(gspca_dev, 0x17, reg17); | ||
2388 | reg_w1(gspca_dev, 0x01, 0x22); | ||
2389 | msleep(100); | ||
2390 | reg01 = SCL_SEL_OD | S_PDN_INV; | ||
2391 | reg17 &= MCK_SIZE_MASK; | ||
2392 | reg17 |= 0x04; /* clock / 4 */ | ||
2393 | break; | ||
2394 | } | ||
2395 | reg01 |= SYS_SEL_48M; | ||
2396 | reg_w1(gspca_dev, 0x01, reg01); | ||
2397 | reg17 |= SEN_CLK_EN; | ||
2398 | reg_w1(gspca_dev, 0x17, reg17); | ||
2399 | reg01 &= ~S_PWR_DN; /* sensor power on */ | ||
2400 | reg_w1(gspca_dev, 0x01, reg01); | ||
2401 | reg01 &= ~SYS_SEL_48M; | ||
2402 | reg_w1(gspca_dev, 0x01, reg01); | ||
2403 | |||
2404 | switch (sd->sensor) { | ||
2405 | case SENSOR_HV7131R: | ||
2406 | hv7131r_probe(gspca_dev); /*fixme: is it useful? */ | ||
2407 | break; | ||
2408 | case SENSOR_OM6802: | ||
2409 | msleep(10); | ||
2410 | reg_w1(gspca_dev, 0x01, reg01); | ||
2411 | i2c_w8(gspca_dev, om6802_init0[0]); | ||
2412 | i2c_w8(gspca_dev, om6802_init0[1]); | ||
2413 | msleep(15); | ||
2414 | reg_w1(gspca_dev, 0x02, 0x71); | ||
2415 | msleep(150); | ||
2416 | break; | ||
2417 | case SENSOR_SP80708: | ||
2418 | msleep(100); | ||
2419 | reg_w1(gspca_dev, 0x02, 0x62); | ||
2420 | break; | ||
2421 | } | ||
2452 | 2422 | ||
2453 | /* initialize the sensor */ | 2423 | /* initialize the sensor */ |
2454 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); | 2424 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); |
@@ -2476,30 +2446,11 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2476 | } | 2446 | } |
2477 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); | 2447 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
2478 | switch (sd->sensor) { | 2448 | switch (sd->sensor) { |
2479 | case SENSOR_GC0307: | 2449 | case SENSOR_OM6802: |
2480 | reg17 = 0xa2; | 2450 | /* case SENSOR_OV7648: * fixme: sometimes */ |
2481 | break; | ||
2482 | case SENSOR_MT9V111: | ||
2483 | case SENSOR_MI0360B: | ||
2484 | reg17 = 0xe0; | ||
2485 | break; | ||
2486 | case SENSOR_ADCM1700: | ||
2487 | case SENSOR_OV7630: | ||
2488 | reg17 = 0xe2; | ||
2489 | break; | ||
2490 | case SENSOR_OV7648: | ||
2491 | reg17 = 0x20; | ||
2492 | break; | ||
2493 | case SENSOR_OV7660: | ||
2494 | case SENSOR_SOI768: | ||
2495 | reg17 = 0xa0; | ||
2496 | break; | ||
2497 | case SENSOR_PO1030: | ||
2498 | case SENSOR_PO2030N: | ||
2499 | reg17 = 0xa0; | ||
2500 | break; | 2451 | break; |
2501 | default: | 2452 | default: |
2502 | reg17 = 0x60; | 2453 | reg17 |= DEF_EN; |
2503 | break; | 2454 | break; |
2504 | } | 2455 | } |
2505 | reg_w1(gspca_dev, 0x17, reg17); | 2456 | reg_w1(gspca_dev, 0x17, reg17); |
@@ -2546,95 +2497,67 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2546 | 2497 | ||
2547 | init = NULL; | 2498 | init = NULL; |
2548 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; | 2499 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; |
2549 | if (mode) | 2500 | reg01 |= SYS_SEL_48M | V_TX_EN; |
2550 | reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */ | 2501 | reg17 &= ~MCK_SIZE_MASK; |
2551 | else | 2502 | reg17 |= 0x02; /* clock / 2 */ |
2552 | reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */ | ||
2553 | reg17 = 0x61; /* 0x:20: enable sensor clock */ | ||
2554 | switch (sd->sensor) { | 2503 | switch (sd->sensor) { |
2555 | case SENSOR_ADCM1700: | 2504 | case SENSOR_ADCM1700: |
2556 | init = adcm1700_sensor_param1; | 2505 | init = adcm1700_sensor_param1; |
2557 | reg1 = 0x46; | ||
2558 | reg17 = 0xe2; | ||
2559 | break; | 2506 | break; |
2560 | case SENSOR_GC0307: | 2507 | case SENSOR_GC0307: |
2561 | init = gc0307_sensor_param1; | 2508 | init = gc0307_sensor_param1; |
2562 | reg17 = 0xa2; | 2509 | break; |
2563 | reg1 = 0x44; | 2510 | case SENSOR_HV7131R: |
2511 | case SENSOR_MI0360: | ||
2512 | if (mode) | ||
2513 | reg01 |= SYS_SEL_48M; /* 320x240: clk 48Mhz */ | ||
2514 | else | ||
2515 | reg01 &= ~SYS_SEL_48M; /* 640x480: clk 24Mhz */ | ||
2516 | reg17 &= ~MCK_SIZE_MASK; | ||
2517 | reg17 |= 0x01; /* clock / 1 */ | ||
2564 | break; | 2518 | break; |
2565 | case SENSOR_MI0360B: | 2519 | case SENSOR_MI0360B: |
2566 | init = mi0360b_sensor_param1; | 2520 | init = mi0360b_sensor_param1; |
2567 | reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */ | ||
2568 | reg17 = 0xe2; | ||
2569 | break; | 2521 | break; |
2570 | case SENSOR_MO4000: | 2522 | case SENSOR_MO4000: |
2571 | if (mode) { | 2523 | if (mode) { /* if 320x240 */ |
2572 | /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ | 2524 | reg01 &= ~SYS_SEL_48M; /* clk 24Mz */ |
2573 | reg1 = 0x06; /* clk 24Mz */ | 2525 | reg17 &= ~MCK_SIZE_MASK; |
2574 | } else { | 2526 | reg17 |= 0x01; /* clock / 1 */ |
2575 | reg17 = 0x22; /* 640 MCKSIZE */ | ||
2576 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | ||
2577 | } | 2527 | } |
2578 | break; | 2528 | break; |
2579 | case SENSOR_MT9V111: | 2529 | case SENSOR_MT9V111: |
2580 | init = mt9v111_sensor_param1; | 2530 | init = mt9v111_sensor_param1; |
2581 | if (mode) { | ||
2582 | reg1 = 0x04; /* 320 clk 48Mhz */ | ||
2583 | } else { | ||
2584 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | ||
2585 | reg17 = 0xc2; | ||
2586 | } | ||
2587 | break; | 2531 | break; |
2588 | case SENSOR_OM6802: | 2532 | case SENSOR_OM6802: |
2589 | init = om6802_sensor_param1; | 2533 | init = om6802_sensor_param1; |
2590 | reg17 = 0x64; /* 640 MCKSIZE */ | 2534 | if (!mode) { /* if 640x480 */ |
2535 | reg17 &= ~MCK_SIZE_MASK; | ||
2536 | reg17 |= 0x01; /* clock / 4 */ | ||
2537 | } | ||
2591 | break; | 2538 | break; |
2592 | case SENSOR_OV7630: | 2539 | case SENSOR_OV7630: |
2593 | init = ov7630_sensor_param1; | 2540 | init = ov7630_sensor_param1; |
2594 | reg17 = 0xe2; | ||
2595 | reg1 = 0x44; | ||
2596 | break; | 2541 | break; |
2597 | case SENSOR_OV7648: | 2542 | case SENSOR_OV7648: |
2598 | init = ov7648_sensor_param1; | 2543 | init = ov7648_sensor_param1; |
2599 | reg17 = 0x21; | 2544 | reg17 &= ~MCK_SIZE_MASK; |
2600 | /* reg1 = 0x42; * 42 - 46? */ | 2545 | reg17 |= 0x01; /* clock / 1 */ |
2601 | break; | 2546 | break; |
2602 | case SENSOR_OV7660: | 2547 | case SENSOR_OV7660: |
2603 | init = ov7660_sensor_param1; | 2548 | init = ov7660_sensor_param1; |
2604 | if (sd->bridge == BRIDGE_SN9C120) { | ||
2605 | if (mode) { /* 320x240 - 160x120 */ | ||
2606 | reg17 = 0xa2; | ||
2607 | reg1 = 0x44; /* 48 Mhz, video trf eneble */ | ||
2608 | } | ||
2609 | } else { | ||
2610 | reg17 = 0x22; | ||
2611 | reg1 = 0x06; /* 24 Mhz, video trf eneble | ||
2612 | * inverse power down */ | ||
2613 | } | ||
2614 | break; | 2549 | break; |
2615 | case SENSOR_PO1030: | 2550 | case SENSOR_PO1030: |
2616 | init = po1030_sensor_param1; | 2551 | init = po1030_sensor_param1; |
2617 | reg17 = 0xa2; | ||
2618 | reg1 = 0x44; | ||
2619 | break; | 2552 | break; |
2620 | case SENSOR_PO2030N: | 2553 | case SENSOR_PO2030N: |
2621 | init = po2030n_sensor_param1; | 2554 | init = po2030n_sensor_param1; |
2622 | reg1 = 0x46; | ||
2623 | reg17 = 0xa2; | ||
2624 | break; | 2555 | break; |
2625 | case SENSOR_SOI768: | 2556 | case SENSOR_SOI768: |
2626 | init = soi768_sensor_param1; | 2557 | init = soi768_sensor_param1; |
2627 | reg1 = 0x44; | ||
2628 | reg17 = 0xa2; | ||
2629 | break; | 2558 | break; |
2630 | case SENSOR_SP80708: | 2559 | case SENSOR_SP80708: |
2631 | init = sp80708_sensor_param1; | 2560 | init = sp80708_sensor_param1; |
2632 | if (mode) { | ||
2633 | /*?? reg1 = 0x04; * 320 clk 48Mhz */ | ||
2634 | } else { | ||
2635 | reg1 = 0x46; /* 640 clk 48Mz */ | ||
2636 | reg17 = 0xa2; | ||
2637 | } | ||
2638 | break; | 2561 | break; |
2639 | } | 2562 | } |
2640 | 2563 | ||
@@ -2684,7 +2607,9 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2684 | setjpegqual(gspca_dev); | 2607 | setjpegqual(gspca_dev); |
2685 | 2608 | ||
2686 | reg_w1(gspca_dev, 0x17, reg17); | 2609 | reg_w1(gspca_dev, 0x17, reg17); |
2687 | reg_w1(gspca_dev, 0x01, reg1); | 2610 | reg_w1(gspca_dev, 0x01, reg01); |
2611 | sd->reg01 = reg01; | ||
2612 | sd->reg17 = reg17; | ||
2688 | 2613 | ||
2689 | sethvflip(gspca_dev); | 2614 | sethvflip(gspca_dev); |
2690 | setbrightness(gspca_dev); | 2615 | setbrightness(gspca_dev); |
@@ -2706,41 +2631,64 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
2706 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; | 2631 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
2707 | static const u8 stopsoi768[] = | 2632 | static const u8 stopsoi768[] = |
2708 | { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 }; | 2633 | { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 }; |
2709 | u8 data; | 2634 | u8 reg01; |
2710 | const u8 *sn9c1xx; | 2635 | u8 reg17; |
2711 | 2636 | ||
2712 | data = 0x0b; | 2637 | reg01 = sd->reg01; |
2638 | reg17 = sd->reg17 & ~SEN_CLK_EN; | ||
2713 | switch (sd->sensor) { | 2639 | switch (sd->sensor) { |
2640 | case SENSOR_ADCM1700: | ||
2714 | case SENSOR_GC0307: | 2641 | case SENSOR_GC0307: |
2715 | data = 0x29; | 2642 | case SENSOR_PO2030N: |
2643 | case SENSOR_SP80708: | ||
2644 | reg01 |= LED; | ||
2645 | reg_w1(gspca_dev, 0x01, reg01); | ||
2646 | reg01 &= ~(LED | V_TX_EN); | ||
2647 | reg_w1(gspca_dev, 0x01, reg01); | ||
2648 | /* reg_w1(gspca_dev, 0x02, 0x??); * LED off ? */ | ||
2716 | break; | 2649 | break; |
2717 | case SENSOR_HV7131R: | 2650 | case SENSOR_HV7131R: |
2651 | reg01 &= ~V_TX_EN; | ||
2652 | reg_w1(gspca_dev, 0x01, reg01); | ||
2718 | i2c_w8(gspca_dev, stophv7131); | 2653 | i2c_w8(gspca_dev, stophv7131); |
2719 | data = 0x2b; | ||
2720 | break; | 2654 | break; |
2721 | case SENSOR_MI0360: | 2655 | case SENSOR_MI0360: |
2722 | case SENSOR_MI0360B: | 2656 | case SENSOR_MI0360B: |
2657 | reg01 &= ~V_TX_EN; | ||
2658 | reg_w1(gspca_dev, 0x01, reg01); | ||
2659 | /* reg_w1(gspca_dev, 0x02, 0x40); * LED off ? */ | ||
2723 | i2c_w8(gspca_dev, stopmi0360); | 2660 | i2c_w8(gspca_dev, stopmi0360); |
2724 | data = 0x29; | ||
2725 | break; | 2661 | break; |
2726 | case SENSOR_OV7648: | ||
2727 | i2c_w8(gspca_dev, stopov7648); | ||
2728 | /* fall thru */ | ||
2729 | case SENSOR_MT9V111: | 2662 | case SENSOR_MT9V111: |
2730 | case SENSOR_OV7630: | 2663 | case SENSOR_OM6802: |
2731 | case SENSOR_PO1030: | 2664 | case SENSOR_PO1030: |
2732 | data = 0x29; | 2665 | reg01 &= ~V_TX_EN; |
2666 | reg_w1(gspca_dev, 0x01, reg01); | ||
2667 | break; | ||
2668 | case SENSOR_OV7630: | ||
2669 | case SENSOR_OV7648: | ||
2670 | reg01 &= ~V_TX_EN; | ||
2671 | reg_w1(gspca_dev, 0x01, reg01); | ||
2672 | i2c_w8(gspca_dev, stopov7648); | ||
2673 | break; | ||
2674 | case SENSOR_OV7660: | ||
2675 | reg01 &= ~V_TX_EN; | ||
2676 | reg_w1(gspca_dev, 0x01, reg01); | ||
2733 | break; | 2677 | break; |
2734 | case SENSOR_SOI768: | 2678 | case SENSOR_SOI768: |
2735 | i2c_w8(gspca_dev, stopsoi768); | 2679 | i2c_w8(gspca_dev, stopsoi768); |
2736 | data = 0x29; | ||
2737 | break; | 2680 | break; |
2738 | } | 2681 | } |
2739 | sn9c1xx = sn_tb[sd->sensor]; | 2682 | |
2740 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | 2683 | reg01 |= SCL_SEL_OD; |
2741 | reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); | 2684 | reg_w1(gspca_dev, 0x01, reg01); |
2742 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | 2685 | reg01 |= S_PWR_DN; /* sensor power down */ |
2743 | reg_w1(gspca_dev, 0x01, data); | 2686 | reg_w1(gspca_dev, 0x01, reg01); |
2687 | reg_w1(gspca_dev, 0x17, reg17); | ||
2688 | reg01 &= ~SYS_SEL_48M; /* clock 24MHz */ | ||
2689 | reg_w1(gspca_dev, 0x01, reg01); | ||
2690 | reg01 |= LED; | ||
2691 | reg_w1(gspca_dev, 0x01, reg01); | ||
2744 | /* Don't disable sensor clock as that disables the button on the cam */ | 2692 | /* Don't disable sensor clock as that disables the button on the cam */ |
2745 | /* reg_w1(gspca_dev, 0xf1, 0x01); */ | 2693 | /* reg_w1(gspca_dev, 0xf1, 0x01); */ |
2746 | } | 2694 | } |
@@ -2954,14 +2902,18 @@ static const struct sd_desc sd_desc = { | |||
2954 | /* -- module initialisation -- */ | 2902 | /* -- module initialisation -- */ |
2955 | #define BS(bridge, sensor) \ | 2903 | #define BS(bridge, sensor) \ |
2956 | .driver_info = (BRIDGE_ ## bridge << 16) \ | 2904 | .driver_info = (BRIDGE_ ## bridge << 16) \ |
2957 | | SENSOR_ ## sensor | 2905 | | (SENSOR_ ## sensor << 8) |
2906 | #define BSF(bridge, sensor, flags) \ | ||
2907 | .driver_info = (BRIDGE_ ## bridge << 16) \ | ||
2908 | | (SENSOR_ ## sensor << 8) \ | ||
2909 | | (flags) | ||
2958 | static const __devinitdata struct usb_device_id device_table[] = { | 2910 | static const __devinitdata struct usb_device_id device_table[] = { |
2959 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | 2911 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
2960 | {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, | 2912 | {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, |
2961 | {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, | 2913 | {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, |
2962 | #endif | 2914 | #endif |
2963 | {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)}, | 2915 | {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)}, |
2964 | {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)}, | 2916 | {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)}, |
2965 | {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, | 2917 | {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, |
2966 | {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, | 2918 | {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, |
2967 | {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, | 2919 | {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, |