em28xx-cards.c (1f0ee65a3b6a3c78c4f6b10f8df5700a44ed3c36) | em28xx-cards.c (01c2819330b1e0ec6b53dcfac76ad75ff2c8ba4f) |
---|---|
1/* 2 em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB 3 video capture devices 4 5 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it> 6 Markus Rechberger <mrechberger@gmail.com> 7 Mauro Carvalho Chehab <mchehab@infradead.org> 8 Sascha Sommer <saschasommer@freenet.de> --- 2145 unchanged lines hidden (view full) --- 2154 .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ, 2155 .name = "PCTV DVB-S2 Stick (461e)", 2156 .tuner_type = TUNER_ABSENT, 2157 .tuner_gpio = pctv_461e, 2158 .has_dvb = 1, 2159 .ir_codes = RC_MAP_PINNACLE_PCTV_HD, 2160 }, 2161}; | 1/* 2 em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB 3 video capture devices 4 5 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it> 6 Markus Rechberger <mrechberger@gmail.com> 7 Mauro Carvalho Chehab <mchehab@infradead.org> 8 Sascha Sommer <saschasommer@freenet.de> --- 2145 unchanged lines hidden (view full) --- 2154 .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ, 2155 .name = "PCTV DVB-S2 Stick (461e)", 2156 .tuner_type = TUNER_ABSENT, 2157 .tuner_gpio = pctv_461e, 2158 .has_dvb = 1, 2159 .ir_codes = RC_MAP_PINNACLE_PCTV_HD, 2160 }, 2161}; |
2162EXPORT_SYMBOL_GPL(em28xx_boards); 2163 |
|
2162const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); 2163 2164/* table of devices that work with this driver */ 2165struct usb_device_id em28xx_id_table[] = { 2166 { USB_DEVICE(0xeb1a, 0x2750), 2167 .driver_info = EM2750_BOARD_UNKNOWN }, 2168 { USB_DEVICE(0xeb1a, 0x2751), 2169 .driver_info = EM2750_BOARD_UNKNOWN }, --- 605 unchanged lines hidden (view full) --- 2775 * The em28xx extensions can be modules or builtin. If the 2776 * modules are already loaded or are built in, those extensions 2777 * can be initialised right now. Otherwise, the module init 2778 * code will do it. 2779 */ 2780 em28xx_init_extension(dev); 2781 2782#if defined(CONFIG_MODULES) && defined(MODULE) | 2164const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); 2165 2166/* table of devices that work with this driver */ 2167struct usb_device_id em28xx_id_table[] = { 2168 { USB_DEVICE(0xeb1a, 0x2750), 2169 .driver_info = EM2750_BOARD_UNKNOWN }, 2170 { USB_DEVICE(0xeb1a, 0x2751), 2171 .driver_info = EM2750_BOARD_UNKNOWN }, --- 605 unchanged lines hidden (view full) --- 2777 * The em28xx extensions can be modules or builtin. If the 2778 * modules are already loaded or are built in, those extensions 2779 * can be initialised right now. Otherwise, the module init 2780 * code will do it. 2781 */ 2782 em28xx_init_extension(dev); 2783 2784#if defined(CONFIG_MODULES) && defined(MODULE) |
2785 if (dev->has_video) 2786 request_module("em28xx-v4l"); |
|
2783 if (dev->has_audio_class) 2784 request_module("snd-usb-audio"); 2785 else if (dev->has_alsa_audio) 2786 request_module("em28xx-alsa"); | 2787 if (dev->has_audio_class) 2788 request_module("snd-usb-audio"); 2789 else if (dev->has_alsa_audio) 2790 request_module("em28xx-alsa"); |
2787 | |
2788 if (dev->board.has_dvb) 2789 request_module("em28xx-dvb"); 2790 if (dev->board.buttons || 2791 ((dev->board.ir_codes || dev->board.has_ir_i2c) && !disable_ir)) 2792 request_module("em28xx-rc"); 2793#endif /* CONFIG_MODULES */ 2794} 2795 --- 12 unchanged lines hidden (view full) --- 2808 * em28xx_release_resources() 2809 * unregisters the v4l2,i2c and usb devices 2810 * called when the device gets disconnected or at module unload 2811*/ 2812void em28xx_release_resources(struct em28xx *dev) 2813{ 2814 /*FIXME: I2C IR should be disconnected */ 2815 | 2791 if (dev->board.has_dvb) 2792 request_module("em28xx-dvb"); 2793 if (dev->board.buttons || 2794 ((dev->board.ir_codes || dev->board.has_ir_i2c) && !disable_ir)) 2795 request_module("em28xx-rc"); 2796#endif /* CONFIG_MODULES */ 2797} 2798 --- 12 unchanged lines hidden (view full) --- 2811 * em28xx_release_resources() 2812 * unregisters the v4l2,i2c and usb devices 2813 * called when the device gets disconnected or at module unload 2814*/ 2815void em28xx_release_resources(struct em28xx *dev) 2816{ 2817 /*FIXME: I2C IR should be disconnected */ 2818 |
2816 em28xx_release_analog_resources(dev); 2817 | |
2818 if (dev->def_i2c_bus) 2819 em28xx_i2c_unregister(dev, 1); 2820 em28xx_i2c_unregister(dev, 0); 2821 if (dev->clk) 2822 v4l2_clk_unregister_fixed(dev->clk); 2823 | 2819 if (dev->def_i2c_bus) 2820 em28xx_i2c_unregister(dev, 1); 2821 em28xx_i2c_unregister(dev, 0); 2822 if (dev->clk) 2823 v4l2_clk_unregister_fixed(dev->clk); 2824 |
2824 v4l2_ctrl_handler_free(&dev->ctrl_handler); 2825 2826 v4l2_device_unregister(&dev->v4l2_dev); 2827 | |
2828 usb_put_dev(dev->udev); 2829 2830 /* Mark device as unused */ 2831 clear_bit(dev->devno, &em28xx_devused); 2832}; 2833 2834/* 2835 * em28xx_init_dev() --- 158 unchanged lines hidden (view full) --- 2994 2995 return retval; 2996 } 2997 } 2998 2999 /* Do board specific init and eeprom reading */ 3000 em28xx_card_setup(dev); 3001 | 2825 usb_put_dev(dev->udev); 2826 2827 /* Mark device as unused */ 2828 clear_bit(dev->devno, &em28xx_devused); 2829}; 2830 2831/* 2832 * em28xx_init_dev() --- 158 unchanged lines hidden (view full) --- 2991 2992 return retval; 2993 } 2994 } 2995 2996 /* Do board specific init and eeprom reading */ 2997 em28xx_card_setup(dev); 2998 |
3002 retval = em28xx_register_analog_devices(dev); 3003 if (retval < 0) 3004 goto fail; 3005 | |
3006 return 0; | 2999 return 0; |
3007 3008fail: 3009 if (dev->def_i2c_bus) 3010 em28xx_i2c_unregister(dev, 1); 3011 em28xx_i2c_unregister(dev, 0); 3012 3013 return retval; | |
3014} 3015 3016/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */ 3017#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03)) 3018 3019/* 3020 * em28xx_usb_probe() 3021 * checks for supported devices --- 186 unchanged lines hidden (view full) --- 3208 goto err_free; 3209 } 3210 3211 dev->devno = nr; 3212 dev->model = id->driver_info; 3213 dev->alt = -1; 3214 dev->is_audio_only = has_audio && !(has_video || has_dvb); 3215 dev->has_alsa_audio = has_audio; | 3000} 3001 3002/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */ 3003#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03)) 3004 3005/* 3006 * em28xx_usb_probe() 3007 * checks for supported devices --- 186 unchanged lines hidden (view full) --- 3194 goto err_free; 3195 } 3196 3197 dev->devno = nr; 3198 dev->model = id->driver_info; 3199 dev->alt = -1; 3200 dev->is_audio_only = has_audio && !(has_video || has_dvb); 3201 dev->has_alsa_audio = has_audio; |
3202 dev->has_video = has_video; |
|
3216 dev->audio_ifnum = ifnum; 3217 3218 /* Checks if audio is provided by some interface */ 3219 for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { 3220 struct usb_interface *uif = udev->config->interface[i]; 3221 if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 3222 dev->has_audio_class = 1; 3223 break; --- 23 unchanged lines hidden (view full) --- 3247 if ((unsigned)card[nr] < em28xx_bcount) 3248 dev->model = card[nr]; 3249 3250 /* save our data pointer in this interface device */ 3251 usb_set_intfdata(interface, dev); 3252 3253 /* allocate device struct */ 3254 mutex_init(&dev->lock); | 3203 dev->audio_ifnum = ifnum; 3204 3205 /* Checks if audio is provided by some interface */ 3206 for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { 3207 struct usb_interface *uif = udev->config->interface[i]; 3208 if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 3209 dev->has_audio_class = 1; 3210 break; --- 23 unchanged lines hidden (view full) --- 3234 if ((unsigned)card[nr] < em28xx_bcount) 3235 dev->model = card[nr]; 3236 3237 /* save our data pointer in this interface device */ 3238 usb_set_intfdata(interface, dev); 3239 3240 /* allocate device struct */ 3241 mutex_init(&dev->lock); |
3255 mutex_lock(&dev->lock); | |
3256 retval = em28xx_init_dev(dev, udev, interface, nr); 3257 if (retval) { | 3242 retval = em28xx_init_dev(dev, udev, interface, nr); 3243 if (retval) { |
3258 goto unlock_and_free; | 3244 goto err_free; |
3259 } 3260 3261 if (usb_xfer_mode < 0) { 3262 if (dev->board.is_webcam) 3263 try_bulk = 1; 3264 else 3265 try_bulk = 0; 3266 } else { --- 26 unchanged lines hidden (view full) --- 3293 dev->dvb_xfer_bulk, 3294 EM28XX_DVB_NUM_BUFS, 3295 dev->dvb_max_pkt_size_isoc, 3296 EM28XX_DVB_NUM_ISOC_PACKETS); 3297 } 3298 if (retval) { 3299 printk(DRIVER_NAME 3300 ": Failed to pre-allocate USB transfer buffers for DVB.\n"); | 3245 } 3246 3247 if (usb_xfer_mode < 0) { 3248 if (dev->board.is_webcam) 3249 try_bulk = 1; 3250 else 3251 try_bulk = 0; 3252 } else { --- 26 unchanged lines hidden (view full) --- 3279 dev->dvb_xfer_bulk, 3280 EM28XX_DVB_NUM_BUFS, 3281 dev->dvb_max_pkt_size_isoc, 3282 EM28XX_DVB_NUM_ISOC_PACKETS); 3283 } 3284 if (retval) { 3285 printk(DRIVER_NAME 3286 ": Failed to pre-allocate USB transfer buffers for DVB.\n"); |
3301 goto unlock_and_free; | 3287 goto err_free; |
3302 } 3303 } 3304 3305 request_modules(dev); 3306 3307 /* Should be the last thing to do, to avoid newer udev's to 3308 open the device before fully initializing it 3309 */ | 3288 } 3289 } 3290 3291 request_modules(dev); 3292 3293 /* Should be the last thing to do, to avoid newer udev's to 3294 open the device before fully initializing it 3295 */ |
3310 mutex_unlock(&dev->lock); | |
3311 3312 return 0; 3313 | 3296 3297 return 0; 3298 |
3314unlock_and_free: 3315 mutex_unlock(&dev->lock); 3316 | |
3317err_free: 3318 kfree(dev->alt_max_pkt_size_isoc); 3319 kfree(dev); 3320 3321err: 3322 clear_bit(nr, &em28xx_devused); 3323 3324err_no_slot: --- 67 unchanged lines hidden --- | 3299err_free: 3300 kfree(dev->alt_max_pkt_size_isoc); 3301 kfree(dev); 3302 3303err: 3304 clear_bit(nr, &em28xx_devused); 3305 3306err_no_slot: --- 67 unchanged lines hidden --- |