diff options
author | Douglas Schilling Landgraf <dougsland@redhat.com> | 2009-03-31 16:10:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 20:43:50 -0400 |
commit | f2cf250af156bef127433efd255abfae6aab02f6 (patch) | |
tree | 806656ca13f3a6278224f92b3ee1adc77dcbf148 /drivers/media/video/em28xx/em28xx-cards.c | |
parent | 9fc4d219b93ca0222f342fb3ca75bb62cc8be05c (diff) |
V4L/DVB (11331): em28xx: convert to v4l2_subdev
Converted em28xx driver to v4l2_subdev.
Thanks to Hans Verkuil <hverkuil@xs4all.nl> for helping this conversion.
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-cards.c')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-cards.c | 145 |
1 files changed, 119 insertions, 26 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 0f48c0ff5ac3..fe96da0d54ef 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <media/msp3400.h> | 31 | #include <media/msp3400.h> |
32 | #include <media/saa7115.h> | 32 | #include <media/saa7115.h> |
33 | #include <media/tvp5150.h> | 33 | #include <media/tvp5150.h> |
34 | #include <media/tvaudio.h> | ||
35 | #include <media/i2c-addr.h> | ||
34 | #include <media/tveeprom.h> | 36 | #include <media/tveeprom.h> |
35 | #include <media/v4l2-common.h> | 37 | #include <media/v4l2-common.h> |
36 | #include <media/v4l2-chip-ident.h> | 38 | #include <media/v4l2-chip-ident.h> |
@@ -1240,6 +1242,7 @@ struct em28xx_board em28xx_boards[] = { | |||
1240 | [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = { | 1242 | [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = { |
1241 | .name = "Compro VideoMate ForYou/Stereo", | 1243 | .name = "Compro VideoMate ForYou/Stereo", |
1242 | .tuner_type = TUNER_LG_PAL_NEW_TAPC, | 1244 | .tuner_type = TUNER_LG_PAL_NEW_TAPC, |
1245 | .tvaudio_addr = 0xb0, | ||
1243 | .tda9887_conf = TDA9887_PRESENT, | 1246 | .tda9887_conf = TDA9887_PRESENT, |
1244 | .decoder = EM28XX_TVP5150, | 1247 | .decoder = EM28XX_TVP5150, |
1245 | .adecoder = EM28XX_TVAUDIO, | 1248 | .adecoder = EM28XX_TVAUDIO, |
@@ -1444,6 +1447,24 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = { | |||
1444 | {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC}, | 1447 | {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC}, |
1445 | }; | 1448 | }; |
1446 | 1449 | ||
1450 | /* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */ | ||
1451 | static unsigned short saa711x_addrs[] = { | ||
1452 | 0x4a >> 1, 0x48 >> 1, /* SAA7111, SAA7111A and SAA7113 */ | ||
1453 | 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */ | ||
1454 | I2C_CLIENT_END }; | ||
1455 | |||
1456 | static unsigned short tvp5150_addrs[] = { | ||
1457 | 0xb8 >> 1, | ||
1458 | 0xba >> 1, | ||
1459 | I2C_CLIENT_END | ||
1460 | }; | ||
1461 | |||
1462 | static unsigned short msp3400_addrs[] = { | ||
1463 | 0x80 >> 1, | ||
1464 | 0x88 >> 1, | ||
1465 | I2C_CLIENT_END | ||
1466 | }; | ||
1467 | |||
1447 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg) | 1468 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg) |
1448 | { | 1469 | { |
1449 | int rc = 0; | 1470 | int rc = 0; |
@@ -1672,31 +1693,55 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl) | |||
1672 | } | 1693 | } |
1673 | } | 1694 | } |
1674 | 1695 | ||
1675 | static void em28xx_config_tuner(struct em28xx *dev) | 1696 | static void em28xx_tuner_setup(struct em28xx *dev) |
1676 | { | 1697 | { |
1677 | struct v4l2_priv_tun_config xc2028_cfg; | ||
1678 | struct tuner_setup tun_setup; | 1698 | struct tuner_setup tun_setup; |
1679 | struct v4l2_frequency f; | 1699 | struct v4l2_frequency f; |
1680 | 1700 | ||
1681 | if (dev->tuner_type == TUNER_ABSENT) | 1701 | if (dev->tuner_type == TUNER_ABSENT) |
1682 | return; | 1702 | return; |
1683 | 1703 | ||
1704 | memset(&tun_setup, 0, sizeof(tun_setup)); | ||
1705 | |||
1684 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; | 1706 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; |
1685 | tun_setup.type = dev->tuner_type; | ||
1686 | tun_setup.addr = dev->tuner_addr; | ||
1687 | tun_setup.tuner_callback = em28xx_tuner_callback; | 1707 | tun_setup.tuner_callback = em28xx_tuner_callback; |
1688 | 1708 | ||
1689 | em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); | 1709 | if (dev->board.radio.type) { |
1710 | tun_setup.type = dev->board.radio.type; | ||
1711 | tun_setup.addr = dev->board.radio_addr; | ||
1712 | |||
1713 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup); | ||
1714 | } | ||
1715 | |||
1716 | if ((dev->tuner_type != TUNER_ABSENT) && (dev->tuner_type)) { | ||
1717 | tun_setup.type = dev->tuner_type; | ||
1718 | tun_setup.addr = dev->tuner_addr; | ||
1719 | |||
1720 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup); | ||
1721 | } | ||
1722 | |||
1723 | if (dev->tda9887_conf) { | ||
1724 | struct v4l2_priv_tun_config tda9887_cfg; | ||
1725 | |||
1726 | tda9887_cfg.tuner = TUNER_TDA9887; | ||
1727 | tda9887_cfg.priv = &dev->tda9887_conf; | ||
1728 | |||
1729 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &tda9887_cfg); | ||
1730 | } | ||
1690 | 1731 | ||
1691 | if (dev->tuner_type == TUNER_XC2028) { | 1732 | if (dev->tuner_type == TUNER_XC2028) { |
1733 | struct v4l2_priv_tun_config xc2028_cfg; | ||
1692 | struct xc2028_ctrl ctl; | 1734 | struct xc2028_ctrl ctl; |
1693 | 1735 | ||
1736 | memset(&xc2028_cfg, 0, sizeof(xc2028_cfg)); | ||
1737 | memset(&ctl, 0, sizeof(ctl)); | ||
1738 | |||
1694 | em28xx_setup_xc3028(dev, &ctl); | 1739 | em28xx_setup_xc3028(dev, &ctl); |
1695 | 1740 | ||
1696 | xc2028_cfg.tuner = TUNER_XC2028; | 1741 | xc2028_cfg.tuner = TUNER_XC2028; |
1697 | xc2028_cfg.priv = &ctl; | 1742 | xc2028_cfg.priv = &ctl; |
1698 | 1743 | ||
1699 | em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg); | 1744 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &xc2028_cfg); |
1700 | } | 1745 | } |
1701 | 1746 | ||
1702 | /* configure tuner */ | 1747 | /* configure tuner */ |
@@ -1704,7 +1749,7 @@ static void em28xx_config_tuner(struct em28xx *dev) | |||
1704 | f.type = V4L2_TUNER_ANALOG_TV; | 1749 | f.type = V4L2_TUNER_ANALOG_TV; |
1705 | f.frequency = 9076; /* just a magic number */ | 1750 | f.frequency = 9076; /* just a magic number */ |
1706 | dev->ctl_freq = f.frequency; | 1751 | dev->ctl_freq = f.frequency; |
1707 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); | 1752 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f); |
1708 | } | 1753 | } |
1709 | 1754 | ||
1710 | static int em28xx_hint_board(struct em28xx *dev) | 1755 | static int em28xx_hint_board(struct em28xx *dev) |
@@ -1911,22 +1956,50 @@ void em28xx_card_setup(struct em28xx *dev) | |||
1911 | if (tuner >= 0) | 1956 | if (tuner >= 0) |
1912 | dev->tuner_type = tuner; | 1957 | dev->tuner_type = tuner; |
1913 | 1958 | ||
1914 | #ifdef CONFIG_MODULES | ||
1915 | /* request some modules */ | 1959 | /* request some modules */ |
1916 | if (dev->board.has_msp34xx) | 1960 | if (dev->board.has_msp34xx) |
1917 | request_module("msp3400"); | 1961 | v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "msp3400", |
1962 | "msp3400", msp3400_addrs); | ||
1963 | |||
1918 | if (dev->board.decoder == EM28XX_SAA711X) | 1964 | if (dev->board.decoder == EM28XX_SAA711X) |
1919 | request_module("saa7115"); | 1965 | v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "saa7115", |
1966 | "saa7115_auto", saa711x_addrs); | ||
1967 | |||
1920 | if (dev->board.decoder == EM28XX_TVP5150) | 1968 | if (dev->board.decoder == EM28XX_TVP5150) |
1921 | request_module("tvp5150"); | 1969 | v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tvp5150", |
1922 | if (dev->board.tuner_type != TUNER_ABSENT) | 1970 | "tvp5150", tvp5150_addrs); |
1923 | request_module("tuner"); | ||
1924 | if (dev->board.adecoder == EM28XX_TVAUDIO) | ||
1925 | request_module("tvaudio"); | ||
1926 | #endif | ||
1927 | 1971 | ||
1928 | em28xx_config_tuner(dev); | 1972 | if (dev->board.adecoder == EM28XX_TVAUDIO) |
1973 | v4l2_i2c_new_subdev(&dev->i2c_adap, "tvaudio", | ||
1974 | "tvaudio", dev->board.tvaudio_addr); | ||
1975 | |||
1976 | if (dev->board.tuner_type != TUNER_ABSENT) { | ||
1977 | int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); | ||
1978 | |||
1979 | if (dev->board.radio.type) | ||
1980 | v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner", | ||
1981 | dev->board.radio_addr); | ||
1982 | |||
1983 | if (has_demod) | ||
1984 | v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner", | ||
1985 | "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | ||
1986 | if (dev->tuner_addr == 0) { | ||
1987 | enum v4l2_i2c_tuner_type type = | ||
1988 | has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; | ||
1989 | struct v4l2_subdev *sd; | ||
1990 | |||
1991 | sd = v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner", | ||
1992 | "tuner", v4l2_i2c_tuner_addrs(type)); | ||
1993 | |||
1994 | if (sd) | ||
1995 | dev->tuner_addr = v4l2_i2c_subdev_addr(sd); | ||
1996 | } else { | ||
1997 | v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", | ||
1998 | "tuner", dev->tuner_addr); | ||
1999 | } | ||
2000 | } | ||
1929 | 2001 | ||
2002 | em28xx_tuner_setup(dev); | ||
1930 | em28xx_ir_init(dev); | 2003 | em28xx_ir_init(dev); |
1931 | } | 2004 | } |
1932 | 2005 | ||
@@ -1975,6 +2048,9 @@ void em28xx_release_resources(struct em28xx *dev) | |||
1975 | em28xx_remove_from_devlist(dev); | 2048 | em28xx_remove_from_devlist(dev); |
1976 | 2049 | ||
1977 | em28xx_i2c_unregister(dev); | 2050 | em28xx_i2c_unregister(dev); |
2051 | |||
2052 | v4l2_device_unregister(&dev->v4l2_dev); | ||
2053 | |||
1978 | usb_put_dev(dev->udev); | 2054 | usb_put_dev(dev->udev); |
1979 | 2055 | ||
1980 | /* Mark device as unused */ | 2056 | /* Mark device as unused */ |
@@ -2019,9 +2095,16 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2019 | } | 2095 | } |
2020 | } | 2096 | } |
2021 | 2097 | ||
2098 | retval = v4l2_device_register(&dev->udev->dev, &dev->v4l2_dev); | ||
2099 | if (retval < 0) { | ||
2100 | em28xx_errdev("Call to v4l2_device_register() failed!\n"); | ||
2101 | return retval; | ||
2102 | } | ||
2103 | |||
2022 | /* register i2c bus */ | 2104 | /* register i2c bus */ |
2023 | errCode = em28xx_i2c_register(dev); | 2105 | errCode = em28xx_i2c_register(dev); |
2024 | if (errCode < 0) { | 2106 | if (errCode < 0) { |
2107 | v4l2_device_unregister(&dev->v4l2_dev); | ||
2025 | em28xx_errdev("%s: em28xx_i2c_register - errCode [%d]!\n", | 2108 | em28xx_errdev("%s: em28xx_i2c_register - errCode [%d]!\n", |
2026 | __func__, errCode); | 2109 | __func__, errCode); |
2027 | return errCode; | 2110 | return errCode; |
@@ -2033,6 +2116,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2033 | /* Configure audio */ | 2116 | /* Configure audio */ |
2034 | errCode = em28xx_audio_setup(dev); | 2117 | errCode = em28xx_audio_setup(dev); |
2035 | if (errCode < 0) { | 2118 | if (errCode < 0) { |
2119 | v4l2_device_unregister(&dev->v4l2_dev); | ||
2036 | em28xx_errdev("%s: Error while setting audio - errCode [%d]!\n", | 2120 | em28xx_errdev("%s: Error while setting audio - errCode [%d]!\n", |
2037 | __func__, errCode); | 2121 | __func__, errCode); |
2038 | } | 2122 | } |
@@ -2077,7 +2161,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2077 | em28xx_init_extension(dev); | 2161 | em28xx_init_extension(dev); |
2078 | 2162 | ||
2079 | /* Save some power by putting tuner to sleep */ | 2163 | /* Save some power by putting tuner to sleep */ |
2080 | em28xx_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); | 2164 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_standby, 0); |
2081 | 2165 | ||
2082 | return 0; | 2166 | return 0; |
2083 | 2167 | ||
@@ -2096,7 +2180,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2096 | struct usb_device *udev; | 2180 | struct usb_device *udev; |
2097 | struct usb_interface *uif; | 2181 | struct usb_interface *uif; |
2098 | struct em28xx *dev = NULL; | 2182 | struct em28xx *dev = NULL; |
2099 | int retval = -ENODEV; | 2183 | int retval; |
2100 | int i, nr, ifnum, isoc_pipe; | 2184 | int i, nr, ifnum, isoc_pipe; |
2101 | char *speed; | 2185 | char *speed; |
2102 | char descr[255] = ""; | 2186 | char descr[255] = ""; |
@@ -2118,7 +2202,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2118 | interface->altsetting[0].desc.bInterfaceClass); | 2202 | interface->altsetting[0].desc.bInterfaceClass); |
2119 | 2203 | ||
2120 | em28xx_devused &= ~(1<<nr); | 2204 | em28xx_devused &= ~(1<<nr); |
2121 | return -ENODEV; | 2205 | retval = -ENODEV; |
2206 | goto err; | ||
2122 | } | 2207 | } |
2123 | 2208 | ||
2124 | endpoint = &interface->cur_altsetting->endpoint[0].desc; | 2209 | endpoint = &interface->cur_altsetting->endpoint[0].desc; |
@@ -2151,7 +2236,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2151 | "interface not used by the driver\n"); | 2236 | "interface not used by the driver\n"); |
2152 | 2237 | ||
2153 | em28xx_devused &= ~(1<<nr); | 2238 | em28xx_devused &= ~(1<<nr); |
2154 | return -ENODEV; | 2239 | retval = -ENODEV; |
2240 | goto err; | ||
2155 | } | 2241 | } |
2156 | } | 2242 | } |
2157 | 2243 | ||
@@ -2194,7 +2280,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2194 | printk(DRIVER_NAME ": Supports only %i em28xx boards.\n", | 2280 | printk(DRIVER_NAME ": Supports only %i em28xx boards.\n", |
2195 | EM28XX_MAXBOARDS); | 2281 | EM28XX_MAXBOARDS); |
2196 | em28xx_devused &= ~(1<<nr); | 2282 | em28xx_devused &= ~(1<<nr); |
2197 | return -ENOMEM; | 2283 | retval = -ENOMEM; |
2284 | goto err; | ||
2198 | } | 2285 | } |
2199 | 2286 | ||
2200 | /* allocate memory for our device state and initialize it */ | 2287 | /* allocate memory for our device state and initialize it */ |
@@ -2202,7 +2289,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2202 | if (dev == NULL) { | 2289 | if (dev == NULL) { |
2203 | em28xx_err(DRIVER_NAME ": out of memory!\n"); | 2290 | em28xx_err(DRIVER_NAME ": out of memory!\n"); |
2204 | em28xx_devused &= ~(1<<nr); | 2291 | em28xx_devused &= ~(1<<nr); |
2205 | return -ENOMEM; | 2292 | retval = -ENOMEM; |
2293 | goto err; | ||
2206 | } | 2294 | } |
2207 | 2295 | ||
2208 | snprintf(dev->name, 29, "em28xx #%d", nr); | 2296 | snprintf(dev->name, 29, "em28xx #%d", nr); |
@@ -2229,7 +2317,8 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2229 | em28xx_errdev("out of memory!\n"); | 2317 | em28xx_errdev("out of memory!\n"); |
2230 | em28xx_devused &= ~(1<<nr); | 2318 | em28xx_devused &= ~(1<<nr); |
2231 | kfree(dev); | 2319 | kfree(dev); |
2232 | return -ENOMEM; | 2320 | retval = -ENOMEM; |
2321 | goto err; | ||
2233 | } | 2322 | } |
2234 | 2323 | ||
2235 | for (i = 0; i < dev->num_alt ; i++) { | 2324 | for (i = 0; i < dev->num_alt ; i++) { |
@@ -2248,8 +2337,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2248 | if (retval) { | 2337 | if (retval) { |
2249 | em28xx_devused &= ~(1<<dev->devno); | 2338 | em28xx_devused &= ~(1<<dev->devno); |
2250 | kfree(dev); | 2339 | kfree(dev); |
2251 | 2340 | goto err; | |
2252 | return retval; | ||
2253 | } | 2341 | } |
2254 | 2342 | ||
2255 | /* save our data pointer in this interface device */ | 2343 | /* save our data pointer in this interface device */ |
@@ -2263,6 +2351,9 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2263 | mutex_unlock(&dev->lock); | 2351 | mutex_unlock(&dev->lock); |
2264 | 2352 | ||
2265 | return 0; | 2353 | return 0; |
2354 | |||
2355 | err: | ||
2356 | return retval; | ||
2266 | } | 2357 | } |
2267 | 2358 | ||
2268 | /* | 2359 | /* |
@@ -2288,6 +2379,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
2288 | 2379 | ||
2289 | wake_up_interruptible_all(&dev->open); | 2380 | wake_up_interruptible_all(&dev->open); |
2290 | 2381 | ||
2382 | v4l2_device_disconnect(&dev->v4l2_dev); | ||
2383 | |||
2291 | if (dev->users) { | 2384 | if (dev->users) { |
2292 | em28xx_warn | 2385 | em28xx_warn |
2293 | ("device /dev/video%d is open! Deregistration and memory " | 2386 | ("device /dev/video%d is open! Deregistration and memory " |