diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2010-12-14 14:14:10 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-17 15:47:53 -0500 |
commit | 5e68f400aad4e2c29e2531cc4413c459fa88cb62 (patch) | |
tree | 3b34b4b183f9d35ed892ec36be71f40c7c39687e /drivers/media/video | |
parent | 692e42df12e8427219958468301f3d03ca5f0f0d (diff) |
[media] gspca - sonixj: Move bridge init to sd start
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')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 265 |
1 files changed, 129 insertions, 136 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 330dadc00106..5d5698959b10 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -1755,141 +1755,6 @@ static void po2030n_probe(struct gspca_dev *gspca_dev) | |||
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | 1757 | ||
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 */ | 1758 | /* this function is called at probe time */ |
1894 | static int sd_config(struct gspca_dev *gspca_dev, | 1759 | static int sd_config(struct gspca_dev *gspca_dev, |
1895 | const struct usb_device_id *id) | 1760 | const struct usb_device_id *id) |
@@ -2423,10 +2288,17 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2423 | { | 2288 | { |
2424 | struct sd *sd = (struct sd *) gspca_dev; | 2289 | struct sd *sd = (struct sd *) gspca_dev; |
2425 | int i; | 2290 | int i; |
2291 | u8 reg0102[2]; | ||
2292 | const u8 *reg9a; | ||
2426 | u8 reg1, reg17; | 2293 | u8 reg1, reg17; |
2427 | const u8 *sn9c1xx; | 2294 | const u8 *sn9c1xx; |
2428 | const u8 (*init)[8]; | 2295 | const u8 (*init)[8]; |
2429 | int mode; | 2296 | int mode; |
2297 | static const u8 reg9a_def[] = | ||
2298 | {0x00, 0x40, 0x20, 0x00, 0x00, 0x00}; | ||
2299 | static const u8 reg9a_spec[] = | ||
2300 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; | ||
2301 | static const u8 regd4[] = {0x60, 0x00, 0x00}; | ||
2430 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; | 2302 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
2431 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; | 2303 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
2432 | static const u8 CA_adcm1700[] = | 2304 | static const u8 CA_adcm1700[] = |
@@ -2448,7 +2320,128 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2448 | 2320 | ||
2449 | /* initialize the bridge */ | 2321 | /* initialize the bridge */ |
2450 | sn9c1xx = sn_tb[sd->sensor]; | 2322 | sn9c1xx = sn_tb[sd->sensor]; |
2451 | bridge_init(gspca_dev, sn9c1xx); | 2323 | |
2324 | /* sensor clock already enabled in sd_init */ | ||
2325 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ | ||
2326 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | ||
2327 | |||
2328 | /* configure gpio */ | ||
2329 | reg0102[0] = sn9c1xx[1]; | ||
2330 | reg0102[1] = sn9c1xx[2]; | ||
2331 | if (gspca_dev->audio) | ||
2332 | reg0102[1] |= 0x04; /* keep the audio connection */ | ||
2333 | reg_w(gspca_dev, 0x01, reg0102, 2); | ||
2334 | reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); | ||
2335 | reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); | ||
2336 | switch (sd->sensor) { | ||
2337 | case SENSOR_GC0307: | ||
2338 | case SENSOR_OV7660: | ||
2339 | case SENSOR_PO1030: | ||
2340 | case SENSOR_PO2030N: | ||
2341 | case SENSOR_SOI768: | ||
2342 | case SENSOR_SP80708: | ||
2343 | reg9a = reg9a_spec; | ||
2344 | break; | ||
2345 | default: | ||
2346 | reg9a = reg9a_def; | ||
2347 | break; | ||
2348 | } | ||
2349 | reg_w(gspca_dev, 0x9a, reg9a, 6); | ||
2350 | |||
2351 | reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); | ||
2352 | |||
2353 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); | ||
2354 | |||
2355 | switch (sd->sensor) { | ||
2356 | case SENSOR_ADCM1700: | ||
2357 | reg_w1(gspca_dev, 0x01, 0x43); | ||
2358 | reg_w1(gspca_dev, 0x17, 0x62); | ||
2359 | reg_w1(gspca_dev, 0x01, 0x42); | ||
2360 | reg_w1(gspca_dev, 0x01, 0x42); | ||
2361 | break; | ||
2362 | case SENSOR_GC0307: | ||
2363 | msleep(50); | ||
2364 | reg_w1(gspca_dev, 0x01, 0x61); | ||
2365 | reg_w1(gspca_dev, 0x17, 0x22); | ||
2366 | reg_w1(gspca_dev, 0x01, 0x60); | ||
2367 | reg_w1(gspca_dev, 0x01, 0x40); | ||
2368 | msleep(50); | ||
2369 | break; | ||
2370 | case SENSOR_MI0360B: | ||
2371 | reg_w1(gspca_dev, 0x01, 0x61); | ||
2372 | reg_w1(gspca_dev, 0x17, 0x60); | ||
2373 | reg_w1(gspca_dev, 0x01, 0x60); | ||
2374 | reg_w1(gspca_dev, 0x01, 0x40); | ||
2375 | break; | ||
2376 | case SENSOR_MT9V111: | ||
2377 | reg_w1(gspca_dev, 0x01, 0x61); | ||
2378 | reg_w1(gspca_dev, 0x17, 0x61); | ||
2379 | reg_w1(gspca_dev, 0x01, 0x60); | ||
2380 | reg_w1(gspca_dev, 0x01, 0x40); | ||
2381 | break; | ||
2382 | case SENSOR_OM6802: | ||
2383 | msleep(10); | ||
2384 | reg_w1(gspca_dev, 0x02, 0x73); | ||
2385 | reg_w1(gspca_dev, 0x17, 0x60); | ||
2386 | reg_w1(gspca_dev, 0x01, 0x22); | ||
2387 | msleep(100); | ||
2388 | reg_w1(gspca_dev, 0x01, 0x62); | ||
2389 | reg_w1(gspca_dev, 0x17, 0x64); | ||
2390 | reg_w1(gspca_dev, 0x17, 0x64); | ||
2391 | reg_w1(gspca_dev, 0x01, 0x42); | ||
2392 | msleep(10); | ||
2393 | reg_w1(gspca_dev, 0x01, 0x42); | ||
2394 | i2c_w8(gspca_dev, om6802_init0[0]); | ||
2395 | i2c_w8(gspca_dev, om6802_init0[1]); | ||
2396 | msleep(15); | ||
2397 | reg_w1(gspca_dev, 0x02, 0x71); | ||
2398 | msleep(150); | ||
2399 | break; | ||
2400 | case SENSOR_OV7630: | ||
2401 | reg_w1(gspca_dev, 0x01, 0x61); | ||
2402 | reg_w1(gspca_dev, 0x17, 0xe2); | ||
2403 | reg_w1(gspca_dev, 0x01, 0x60); | ||
2404 | reg_w1(gspca_dev, 0x01, 0x40); | ||
2405 | break; | ||
2406 | case SENSOR_OV7648: | ||
2407 | reg_w1(gspca_dev, 0x01, 0x63); | ||
2408 | reg_w1(gspca_dev, 0x17, 0x20); | ||
2409 | reg_w1(gspca_dev, 0x01, 0x62); | ||
2410 | reg_w1(gspca_dev, 0x01, 0x42); | ||
2411 | break; | ||
2412 | case SENSOR_PO1030: | ||
2413 | case SENSOR_SOI768: | ||
2414 | reg_w1(gspca_dev, 0x01, 0x61); | ||
2415 | reg_w1(gspca_dev, 0x17, 0x20); | ||
2416 | reg_w1(gspca_dev, 0x01, 0x60); | ||
2417 | reg_w1(gspca_dev, 0x01, 0x40); | ||
2418 | break; | ||
2419 | case SENSOR_PO2030N: | ||
2420 | case SENSOR_OV7660: | ||
2421 | reg_w1(gspca_dev, 0x01, 0x63); | ||
2422 | reg_w1(gspca_dev, 0x17, 0x20); | ||
2423 | reg_w1(gspca_dev, 0x01, 0x62); | ||
2424 | reg_w1(gspca_dev, 0x01, 0x42); | ||
2425 | break; | ||
2426 | case SENSOR_SP80708: | ||
2427 | reg_w1(gspca_dev, 0x01, 0x63); | ||
2428 | reg_w1(gspca_dev, 0x17, 0x20); | ||
2429 | reg_w1(gspca_dev, 0x01, 0x62); | ||
2430 | reg_w1(gspca_dev, 0x01, 0x42); | ||
2431 | msleep(100); | ||
2432 | reg_w1(gspca_dev, 0x02, 0x62); | ||
2433 | break; | ||
2434 | default: | ||
2435 | /* case SENSOR_HV7131R: */ | ||
2436 | /* case SENSOR_MI0360: */ | ||
2437 | /* case SENSOR_MO4000: */ | ||
2438 | reg_w1(gspca_dev, 0x01, 0x43); | ||
2439 | reg_w1(gspca_dev, 0x17, 0x61); | ||
2440 | reg_w1(gspca_dev, 0x01, 0x42); | ||
2441 | if (sd->sensor == SENSOR_HV7131R) | ||
2442 | hv7131r_probe(gspca_dev); | ||
2443 | break; | ||
2444 | } | ||
2452 | 2445 | ||
2453 | /* initialize the sensor */ | 2446 | /* initialize the sensor */ |
2454 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); | 2447 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); |