aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-08-10 01:57:57 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-08-13 19:39:10 -0400
commitfcd20e3c369caf7a3fec300c9c183b25a06e21b2 (patch)
tree159d432b53f2cfd34a7752bc3abf49ac2d21a3a7
parent970cff36c0850e8193ac1162e42c7c11001b872d (diff)
V4L/DVB (12410): em28xx: Move the non-board dependent part to be outside em28xx_pre_card_setup()
em28xx_pre_card_setup() is meant to contain board-specific initialization. Also, as autodetection sometimes occur only after having i2c bus enabled, this function may need to be called later. Moving those setups to happen outside the function avoids calling it twice without need and without duplicating output lines at dmesg. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c111
1 files changed, 53 insertions, 58 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index fc46032bfe27..6b2b5d3e2fad 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -1821,63 +1821,6 @@ static int em28xx_hint_sensor(struct em28xx *dev)
1821 */ 1821 */
1822void em28xx_pre_card_setup(struct em28xx *dev) 1822void em28xx_pre_card_setup(struct em28xx *dev)
1823{ 1823{
1824 int rc;
1825
1826 em28xx_set_model(dev);
1827
1828 em28xx_info("Identified as %s (card=%d)\n",
1829 dev->board.name, dev->model);
1830
1831 /* Set the default GPO/GPIO for legacy devices */
1832 dev->reg_gpo_num = EM2880_R04_GPO;
1833 dev->reg_gpio_num = EM28XX_R08_GPIO;
1834
1835 dev->wait_after_write = 5;
1836
1837 /* Based on the Chip ID, set the device configuration */
1838 rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
1839 if (rc > 0) {
1840 dev->chip_id = rc;
1841
1842 switch (dev->chip_id) {
1843 case CHIP_ID_EM2710:
1844 em28xx_info("chip ID is em2710\n");
1845 break;
1846 case CHIP_ID_EM2750:
1847 em28xx_info("chip ID is em2750\n");
1848 break;
1849 case CHIP_ID_EM2820:
1850 em28xx_info("chip ID is em2820 (or em2710)\n");
1851 break;
1852 case CHIP_ID_EM2840:
1853 em28xx_info("chip ID is em2840\n");
1854 break;
1855 case CHIP_ID_EM2860:
1856 em28xx_info("chip ID is em2860\n");
1857 break;
1858 case CHIP_ID_EM2870:
1859 em28xx_info("chip ID is em2870\n");
1860 dev->wait_after_write = 0;
1861 break;
1862 case CHIP_ID_EM2874:
1863 em28xx_info("chip ID is em2874\n");
1864 dev->reg_gpio_num = EM2874_R80_GPIO;
1865 dev->wait_after_write = 0;
1866 break;
1867 case CHIP_ID_EM2883:
1868 em28xx_info("chip ID is em2882/em2883\n");
1869 dev->wait_after_write = 0;
1870 break;
1871 default:
1872 em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
1873 }
1874 }
1875
1876 /* Prepopulate cached GPO register content */
1877 rc = em28xx_read_reg(dev, dev->reg_gpo_num);
1878 if (rc >= 0)
1879 dev->reg_gpo = rc;
1880
1881 /* Set the initial XCLK and I2C clock values based on the board 1824 /* Set the initial XCLK and I2C clock values based on the board
1882 definition */ 1825 definition */
1883 em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f); 1826 em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
@@ -2443,7 +2386,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2443 int minor) 2386 int minor)
2444{ 2387{
2445 struct em28xx *dev = *devhandle; 2388 struct em28xx *dev = *devhandle;
2446 int retval = -ENOMEM; 2389 int retval;
2447 int errCode; 2390 int errCode;
2448 2391
2449 dev->udev = udev; 2392 dev->udev = udev;
@@ -2460,6 +2403,58 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2460 dev->em28xx_read_reg_req = em28xx_read_reg_req; 2403 dev->em28xx_read_reg_req = em28xx_read_reg_req;
2461 dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800; 2404 dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
2462 2405
2406 em28xx_set_model(dev);
2407
2408 /* Set the default GPO/GPIO for legacy devices */
2409 dev->reg_gpo_num = EM2880_R04_GPO;
2410 dev->reg_gpio_num = EM28XX_R08_GPIO;
2411
2412 dev->wait_after_write = 5;
2413
2414 /* Based on the Chip ID, set the device configuration */
2415 retval = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
2416 if (retval > 0) {
2417 dev->chip_id = retval;
2418
2419 switch (dev->chip_id) {
2420 case CHIP_ID_EM2710:
2421 em28xx_info("chip ID is em2710\n");
2422 break;
2423 case CHIP_ID_EM2750:
2424 em28xx_info("chip ID is em2750\n");
2425 break;
2426 case CHIP_ID_EM2820:
2427 em28xx_info("chip ID is em2820 (or em2710)\n");
2428 break;
2429 case CHIP_ID_EM2840:
2430 em28xx_info("chip ID is em2840\n");
2431 break;
2432 case CHIP_ID_EM2860:
2433 em28xx_info("chip ID is em2860\n");
2434 break;
2435 case CHIP_ID_EM2870:
2436 em28xx_info("chip ID is em2870\n");
2437 dev->wait_after_write = 0;
2438 break;
2439 case CHIP_ID_EM2874:
2440 em28xx_info("chip ID is em2874\n");
2441 dev->reg_gpio_num = EM2874_R80_GPIO;
2442 dev->wait_after_write = 0;
2443 break;
2444 case CHIP_ID_EM2883:
2445 em28xx_info("chip ID is em2882/em2883\n");
2446 dev->wait_after_write = 0;
2447 break;
2448 default:
2449 em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
2450 }
2451 }
2452
2453 /* Prepopulate cached GPO register content */
2454 retval = em28xx_read_reg(dev, dev->reg_gpo_num);
2455 if (retval >= 0)
2456 dev->reg_gpo = retval;
2457
2463 em28xx_pre_card_setup(dev); 2458 em28xx_pre_card_setup(dev);
2464 2459
2465 if (!dev->board.is_em2800) { 2460 if (!dev->board.is_em2800) {