aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 17:39:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 17:39:09 -0400
commite317234975cb7463b8ca21a93bb6862d9dcf113f (patch)
tree4446fa3a21364f3cba23a22aa2a94027f169d8df /drivers/media/video/em28xx
parentf37ab0fba271e43edab0e3ae9fe644fcda455402 (diff)
parent7483d45f0aee3afc0646d185cabd4af9f6cab58c (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - V4L2 API additions to better support JPEG compression control - media API additions to properly support MPEG decoders - V4L2 API additions for image crop/scaling - a few other V4L2 API DocBook fixes/improvements - two new DVB frontend drivers: m88rs2000 and rtl2830 - two new DVB drivers: az6007 and rtl28xxu - a framework for ISA drivers, that removed lots of common code found at the ISA radio drivers - a new FM transmitter driver (radio-keene) - a GPIO-based IR receiver driver - a new sensor driver: mt9m032 - some new video drivers: adv7183, blackfin, mx2_emmaprp, sii9234_drv, vs6624 - several new board additions, driver fixes, improvements and cleanups. * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (295 commits) [media] update CARDLIST.em28xx [media] partially reverts changeset fa5527c [media] stb0899: fix the limits for signal strength values [media] em28xx: support for 2304:0242 PCTV QuatroStick (510e) [media] em28xx: support for 2013:0251 PCTV QuatroStick nano (520e) [media] -EINVAL -> -ENOTTY [media] gspca - sn9c20x: Cleanup source [media] gspca - sn9c20x: Simplify register write for capture start/stop [media] gspca - sn9c20x: Add automatic JPEG compression mechanism [media] gspca - sn9c20x: Greater delay in case of sensor no response [media] gspca - sn9c20x: Optimize the code of write sequences [media] gspca - sn9c20x: Add the JPEG compression quality control [media] gspca - sn9c20x: Add a delay after Omnivision sensor reset [media] gspca - sn9c20x: Propagate USB errors to higher level [media] gspca - sn9c20x: Use the new video control mechanism [media] gspca - sn9c20x: Fix loss of frame start [media] gspca - zc3xx: Lack of register 08 value for sensor cs2102k [media] gspca - ov534_9: Add brightness to OmniVision 5621 sensor [media] gspca - zc3xx: Add V4L2_CID_JPEG_COMPRESSION_QUALITY control support [media] pvrusb2: fix 7MHz & 8MHz DVB-T tuner support for HVR1900 rev D1F5 ...
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c114
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c145
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c96
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c8
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c10
-rw-r--r--drivers/media/video/em28xx/em28xx.h29
6 files changed, 310 insertions, 92 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 4561cd89938d..9fd8cc7dbb23 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -353,6 +353,44 @@ static struct em28xx_reg_seq hauppauge_930c_digital[] = {
353}; 353};
354#endif 354#endif
355 355
356/* 1b80:e425 MaxMedia UB425-TC
357 * GPIO_6 - demod reset, 0=active
358 * GPIO_7 - LED, 0=active
359 */
360static struct em28xx_reg_seq maxmedia_ub425_tc[] = {
361 {EM2874_R80_GPIO, 0x83, 0xff, 100},
362 {EM2874_R80_GPIO, 0xc3, 0xff, 100}, /* GPIO_6 = 1 */
363 {EM2874_R80_GPIO, 0x43, 0xff, 000}, /* GPIO_7 = 0 */
364 {-1, -1, -1, -1},
365};
366
367/* 2304:0242 PCTV QuatroStick (510e)
368 * GPIO_2: decoder reset, 0=active
369 * GPIO_4: decoder suspend, 0=active
370 * GPIO_6: demod reset, 0=active
371 * GPIO_7: LED, 1=active
372 */
373static struct em28xx_reg_seq pctv_510e[] = {
374 {EM2874_R80_GPIO, 0x10, 0xff, 100},
375 {EM2874_R80_GPIO, 0x14, 0xff, 100}, /* GPIO_2 = 1 */
376 {EM2874_R80_GPIO, 0x54, 0xff, 050}, /* GPIO_6 = 1 */
377 { -1, -1, -1, -1},
378};
379
380/* 2013:0251 PCTV QuatroStick nano (520e)
381 * GPIO_2: decoder reset, 0=active
382 * GPIO_4: decoder suspend, 0=active
383 * GPIO_6: demod reset, 0=active
384 * GPIO_7: LED, 1=active
385 */
386static struct em28xx_reg_seq pctv_520e[] = {
387 {EM2874_R80_GPIO, 0x10, 0xff, 100},
388 {EM2874_R80_GPIO, 0x14, 0xff, 100}, /* GPIO_2 = 1 */
389 {EM2874_R80_GPIO, 0x54, 0xff, 050}, /* GPIO_6 = 1 */
390 {EM2874_R80_GPIO, 0xd4, 0xff, 000}, /* GPIO_7 = 1 */
391 { -1, -1, -1, -1},
392};
393
356/* 394/*
357 * Board definitions 395 * Board definitions
358 */ 396 */
@@ -1908,6 +1946,41 @@ struct em28xx_board em28xx_boards[] = {
1908 .amux = EM28XX_AMUX_LINE_IN, 1946 .amux = EM28XX_AMUX_LINE_IN,
1909 } }, 1947 } },
1910 }, 1948 },
1949 /* 1b80:e425 MaxMedia UB425-TC
1950 * Empia EM2874B + Micronas DRX 3913KA2 + NXP TDA18271HDC2 */
1951 [EM2874_BOARD_MAXMEDIA_UB425_TC] = {
1952 .name = "MaxMedia UB425-TC",
1953 .tuner_type = TUNER_ABSENT,
1954 .tuner_gpio = maxmedia_ub425_tc,
1955 .has_dvb = 1,
1956 .i2c_speed = EM2874_I2C_SECONDARY_BUS_SELECT |
1957 EM28XX_I2C_CLK_WAIT_ENABLE |
1958 EM28XX_I2C_FREQ_400_KHZ,
1959 },
1960 /* 2304:0242 PCTV QuatroStick (510e)
1961 * Empia EM2884 + Micronas DRX 3926K + NXP TDA18271HDC2 */
1962 [EM2884_BOARD_PCTV_510E] = {
1963 .name = "PCTV QuatroStick (510e)",
1964 .tuner_type = TUNER_ABSENT,
1965 .tuner_gpio = pctv_510e,
1966 .has_dvb = 1,
1967 .ir_codes = RC_MAP_PINNACLE_PCTV_HD,
1968 .i2c_speed = EM2874_I2C_SECONDARY_BUS_SELECT |
1969 EM28XX_I2C_CLK_WAIT_ENABLE |
1970 EM28XX_I2C_FREQ_400_KHZ,
1971 },
1972 /* 2013:0251 PCTV QuatroStick nano (520e)
1973 * Empia EM2884 + Micronas DRX 3926K + NXP TDA18271HDC2 */
1974 [EM2884_BOARD_PCTV_520E] = {
1975 .name = "PCTV QuatroStick nano (520e)",
1976 .tuner_type = TUNER_ABSENT,
1977 .tuner_gpio = pctv_520e,
1978 .has_dvb = 1,
1979 .ir_codes = RC_MAP_PINNACLE_PCTV_HD,
1980 .i2c_speed = EM2874_I2C_SECONDARY_BUS_SELECT |
1981 EM28XX_I2C_CLK_WAIT_ENABLE |
1982 EM28XX_I2C_FREQ_400_KHZ,
1983 },
1911}; 1984};
1912const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); 1985const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
1913 1986
@@ -2059,6 +2132,12 @@ struct usb_device_id em28xx_id_table[] = {
2059 .driver_info = EM2860_BOARD_HT_VIDBOX_NW03 }, 2132 .driver_info = EM2860_BOARD_HT_VIDBOX_NW03 },
2060 { USB_DEVICE(0x1b80, 0xe309), /* Sveon STV40 */ 2133 { USB_DEVICE(0x1b80, 0xe309), /* Sveon STV40 */
2061 .driver_info = EM2860_BOARD_EASYCAP }, 2134 .driver_info = EM2860_BOARD_EASYCAP },
2135 { USB_DEVICE(0x1b80, 0xe425),
2136 .driver_info = EM2874_BOARD_MAXMEDIA_UB425_TC },
2137 { USB_DEVICE(0x2304, 0x0242),
2138 .driver_info = EM2884_BOARD_PCTV_510E },
2139 { USB_DEVICE(0x2013, 0x0251),
2140 .driver_info = EM2884_BOARD_PCTV_520E },
2062 { }, 2141 { },
2063}; 2142};
2064MODULE_DEVICE_TABLE(usb, em28xx_id_table); 2143MODULE_DEVICE_TABLE(usb, em28xx_id_table);
@@ -3122,7 +3201,6 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3122 int i, nr; 3201 int i, nr;
3123 const int ifnum = interface->altsetting[0].desc.bInterfaceNumber; 3202 const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
3124 char *speed; 3203 char *speed;
3125 char descr[255] = "";
3126 3204
3127 udev = usb_get_dev(interface_to_usbdev(interface)); 3205 udev = usb_get_dev(interface_to_usbdev(interface));
3128 3206
@@ -3227,21 +3305,11 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3227 speed = "unknown"; 3305 speed = "unknown";
3228 } 3306 }
3229 3307
3230 if (udev->manufacturer)
3231 strlcpy(descr, udev->manufacturer, sizeof(descr));
3232
3233 if (udev->product) {
3234 if (*descr)
3235 strlcat(descr, " ", sizeof(descr));
3236 strlcat(descr, udev->product, sizeof(descr));
3237 }
3238
3239 if (*descr)
3240 strlcat(descr, " ", sizeof(descr));
3241
3242 printk(KERN_INFO DRIVER_NAME 3308 printk(KERN_INFO DRIVER_NAME
3243 ": New device %s@ %s Mbps (%04x:%04x, interface %d, class %d)\n", 3309 ": New device %s %s @ %s Mbps "
3244 descr, 3310 "(%04x:%04x, interface %d, class %d)\n",
3311 udev->manufacturer ? udev->manufacturer : "",
3312 udev->product ? udev->product : "",
3245 speed, 3313 speed,
3246 le16_to_cpu(udev->descriptor.idVendor), 3314 le16_to_cpu(udev->descriptor.idVendor),
3247 le16_to_cpu(udev->descriptor.idProduct), 3315 le16_to_cpu(udev->descriptor.idProduct),
@@ -3307,6 +3375,17 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3307 goto unlock_and_free; 3375 goto unlock_and_free;
3308 } 3376 }
3309 3377
3378 if (has_dvb) {
3379 /* pre-allocate DVB isoc transfer buffers */
3380 retval = em28xx_alloc_isoc(dev, EM28XX_DIGITAL_MODE,
3381 EM28XX_DVB_MAX_PACKETS,
3382 EM28XX_DVB_NUM_BUFS,
3383 dev->dvb_max_pkt_size);
3384 if (retval) {
3385 goto unlock_and_free;
3386 }
3387 }
3388
3310 request_modules(dev); 3389 request_modules(dev);
3311 3390
3312 /* Should be the last thing to do, to avoid newer udev's to 3391 /* Should be the last thing to do, to avoid newer udev's to
@@ -3379,7 +3458,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
3379 video_device_node_name(dev->vdev)); 3458 video_device_node_name(dev->vdev));
3380 3459
3381 dev->state |= DEV_MISCONFIGURED; 3460 dev->state |= DEV_MISCONFIGURED;
3382 em28xx_uninit_isoc(dev); 3461 em28xx_uninit_isoc(dev, dev->mode);
3383 dev->state |= DEV_DISCONNECTED; 3462 dev->state |= DEV_DISCONNECTED;
3384 wake_up_interruptible(&dev->wait_frame); 3463 wake_up_interruptible(&dev->wait_frame);
3385 wake_up_interruptible(&dev->wait_stream); 3464 wake_up_interruptible(&dev->wait_stream);
@@ -3388,6 +3467,9 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
3388 em28xx_release_resources(dev); 3467 em28xx_release_resources(dev);
3389 } 3468 }
3390 3469
3470 /* free DVB isoc buffers */
3471 em28xx_uninit_isoc(dev, EM28XX_DIGITAL_MODE);
3472
3391 mutex_unlock(&dev->lock); 3473 mutex_unlock(&dev->lock);
3392 3474
3393 em28xx_close_extension(dev); 3475 em28xx_close_extension(dev);
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 0aacc96f9a23..53a9fb91e97e 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -666,6 +666,7 @@ int em28xx_capture_start(struct em28xx *dev, int start)
666 666
667 return rc; 667 return rc;
668} 668}
669EXPORT_SYMBOL_GPL(em28xx_capture_start);
669 670
670int em28xx_vbi_supported(struct em28xx *dev) 671int em28xx_vbi_supported(struct em28xx *dev)
671{ 672{
@@ -961,146 +962,192 @@ static void em28xx_irq_callback(struct urb *urb)
961/* 962/*
962 * Stop and Deallocate URBs 963 * Stop and Deallocate URBs
963 */ 964 */
964void em28xx_uninit_isoc(struct em28xx *dev) 965void em28xx_uninit_isoc(struct em28xx *dev, enum em28xx_mode mode)
965{ 966{
966 struct urb *urb; 967 struct urb *urb;
968 struct em28xx_usb_isoc_bufs *isoc_bufs;
967 int i; 969 int i;
968 970
969 em28xx_isocdbg("em28xx: called em28xx_uninit_isoc\n"); 971 em28xx_isocdbg("em28xx: called em28xx_uninit_isoc in mode %d\n", mode);
972
973 if (mode == EM28XX_DIGITAL_MODE)
974 isoc_bufs = &dev->isoc_ctl.digital_bufs;
975 else
976 isoc_bufs = &dev->isoc_ctl.analog_bufs;
970 977
971 dev->isoc_ctl.nfields = -1; 978 dev->isoc_ctl.nfields = -1;
972 for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { 979 for (i = 0; i < isoc_bufs->num_bufs; i++) {
973 urb = dev->isoc_ctl.urb[i]; 980 urb = isoc_bufs->urb[i];
974 if (urb) { 981 if (urb) {
975 if (!irqs_disabled()) 982 if (!irqs_disabled())
976 usb_kill_urb(urb); 983 usb_kill_urb(urb);
977 else 984 else
978 usb_unlink_urb(urb); 985 usb_unlink_urb(urb);
979 986
980 if (dev->isoc_ctl.transfer_buffer[i]) { 987 if (isoc_bufs->transfer_buffer[i]) {
981 usb_free_coherent(dev->udev, 988 usb_free_coherent(dev->udev,
982 urb->transfer_buffer_length, 989 urb->transfer_buffer_length,
983 dev->isoc_ctl.transfer_buffer[i], 990 isoc_bufs->transfer_buffer[i],
984 urb->transfer_dma); 991 urb->transfer_dma);
985 } 992 }
986 usb_free_urb(urb); 993 usb_free_urb(urb);
987 dev->isoc_ctl.urb[i] = NULL; 994 isoc_bufs->urb[i] = NULL;
988 } 995 }
989 dev->isoc_ctl.transfer_buffer[i] = NULL; 996 isoc_bufs->transfer_buffer[i] = NULL;
990 } 997 }
991 998
992 kfree(dev->isoc_ctl.urb); 999 kfree(isoc_bufs->urb);
993 kfree(dev->isoc_ctl.transfer_buffer); 1000 kfree(isoc_bufs->transfer_buffer);
994 1001
995 dev->isoc_ctl.urb = NULL; 1002 isoc_bufs->urb = NULL;
996 dev->isoc_ctl.transfer_buffer = NULL; 1003 isoc_bufs->transfer_buffer = NULL;
997 dev->isoc_ctl.num_bufs = 0; 1004 isoc_bufs->num_bufs = 0;
998 1005
999 em28xx_capture_start(dev, 0); 1006 em28xx_capture_start(dev, 0);
1000} 1007}
1001EXPORT_SYMBOL_GPL(em28xx_uninit_isoc); 1008EXPORT_SYMBOL_GPL(em28xx_uninit_isoc);
1002 1009
1003/* 1010/*
1004 * Allocate URBs and start IRQ 1011 * Allocate URBs
1005 */ 1012 */
1006int em28xx_init_isoc(struct em28xx *dev, int max_packets, 1013int em28xx_alloc_isoc(struct em28xx *dev, enum em28xx_mode mode,
1007 int num_bufs, int max_pkt_size, 1014 int max_packets, int num_bufs, int max_pkt_size)
1008 int (*isoc_copy) (struct em28xx *dev, struct urb *urb))
1009{ 1015{
1010 struct em28xx_dmaqueue *dma_q = &dev->vidq; 1016 struct em28xx_usb_isoc_bufs *isoc_bufs;
1011 struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq;
1012 int i; 1017 int i;
1013 int sb_size, pipe; 1018 int sb_size, pipe;
1014 struct urb *urb; 1019 struct urb *urb;
1015 int j, k; 1020 int j, k;
1016 int rc;
1017 1021
1018 em28xx_isocdbg("em28xx: called em28xx_prepare_isoc\n"); 1022 em28xx_isocdbg("em28xx: called em28xx_alloc_isoc in mode %d\n", mode);
1023
1024 if (mode == EM28XX_DIGITAL_MODE)
1025 isoc_bufs = &dev->isoc_ctl.digital_bufs;
1026 else
1027 isoc_bufs = &dev->isoc_ctl.analog_bufs;
1019 1028
1020 /* De-allocates all pending stuff */ 1029 /* De-allocates all pending stuff */
1021 em28xx_uninit_isoc(dev); 1030 em28xx_uninit_isoc(dev, mode);
1022 1031
1023 dev->isoc_ctl.isoc_copy = isoc_copy; 1032 isoc_bufs->num_bufs = num_bufs;
1024 dev->isoc_ctl.num_bufs = num_bufs;
1025 1033
1026 dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); 1034 isoc_bufs->urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
1027 if (!dev->isoc_ctl.urb) { 1035 if (!isoc_bufs->urb) {
1028 em28xx_errdev("cannot alloc memory for usb buffers\n"); 1036 em28xx_errdev("cannot alloc memory for usb buffers\n");
1029 return -ENOMEM; 1037 return -ENOMEM;
1030 } 1038 }
1031 1039
1032 dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, 1040 isoc_bufs->transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
1033 GFP_KERNEL); 1041 GFP_KERNEL);
1034 if (!dev->isoc_ctl.transfer_buffer) { 1042 if (!isoc_bufs->transfer_buffer) {
1035 em28xx_errdev("cannot allocate memory for usb transfer\n"); 1043 em28xx_errdev("cannot allocate memory for usb transfer\n");
1036 kfree(dev->isoc_ctl.urb); 1044 kfree(isoc_bufs->urb);
1037 return -ENOMEM; 1045 return -ENOMEM;
1038 } 1046 }
1039 1047
1040 dev->isoc_ctl.max_pkt_size = max_pkt_size; 1048 isoc_bufs->max_pkt_size = max_pkt_size;
1049 isoc_bufs->num_packets = max_packets;
1041 dev->isoc_ctl.vid_buf = NULL; 1050 dev->isoc_ctl.vid_buf = NULL;
1042 dev->isoc_ctl.vbi_buf = NULL; 1051 dev->isoc_ctl.vbi_buf = NULL;
1043 1052
1044 sb_size = max_packets * dev->isoc_ctl.max_pkt_size; 1053 sb_size = isoc_bufs->num_packets * isoc_bufs->max_pkt_size;
1045 1054
1046 /* allocate urbs and transfer buffers */ 1055 /* allocate urbs and transfer buffers */
1047 for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { 1056 for (i = 0; i < isoc_bufs->num_bufs; i++) {
1048 urb = usb_alloc_urb(max_packets, GFP_KERNEL); 1057 urb = usb_alloc_urb(isoc_bufs->num_packets, GFP_KERNEL);
1049 if (!urb) { 1058 if (!urb) {
1050 em28xx_err("cannot alloc isoc_ctl.urb %i\n", i); 1059 em28xx_err("cannot alloc isoc_ctl.urb %i\n", i);
1051 em28xx_uninit_isoc(dev); 1060 em28xx_uninit_isoc(dev, mode);
1052 return -ENOMEM; 1061 return -ENOMEM;
1053 } 1062 }
1054 dev->isoc_ctl.urb[i] = urb; 1063 isoc_bufs->urb[i] = urb;
1055 1064
1056 dev->isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->udev, 1065 isoc_bufs->transfer_buffer[i] = usb_alloc_coherent(dev->udev,
1057 sb_size, GFP_KERNEL, &urb->transfer_dma); 1066 sb_size, GFP_KERNEL, &urb->transfer_dma);
1058 if (!dev->isoc_ctl.transfer_buffer[i]) { 1067 if (!isoc_bufs->transfer_buffer[i]) {
1059 em28xx_err("unable to allocate %i bytes for transfer" 1068 em28xx_err("unable to allocate %i bytes for transfer"
1060 " buffer %i%s\n", 1069 " buffer %i%s\n",
1061 sb_size, i, 1070 sb_size, i,
1062 in_interrupt() ? " while in int" : ""); 1071 in_interrupt() ? " while in int" : "");
1063 em28xx_uninit_isoc(dev); 1072 em28xx_uninit_isoc(dev, mode);
1064 return -ENOMEM; 1073 return -ENOMEM;
1065 } 1074 }
1066 memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size); 1075 memset(isoc_bufs->transfer_buffer[i], 0, sb_size);
1067 1076
1068 /* FIXME: this is a hack - should be 1077 /* FIXME: this is a hack - should be
1069 'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK' 1078 'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK'
1070 should also be using 'desc.bInterval' 1079 should also be using 'desc.bInterval'
1071 */ 1080 */
1072 pipe = usb_rcvisocpipe(dev->udev, 1081 pipe = usb_rcvisocpipe(dev->udev,
1073 dev->mode == EM28XX_ANALOG_MODE ? 1082 mode == EM28XX_ANALOG_MODE ?
1074 EM28XX_EP_ANALOG : EM28XX_EP_DIGITAL); 1083 EM28XX_EP_ANALOG : EM28XX_EP_DIGITAL);
1075 1084
1076 usb_fill_int_urb(urb, dev->udev, pipe, 1085 usb_fill_int_urb(urb, dev->udev, pipe,
1077 dev->isoc_ctl.transfer_buffer[i], sb_size, 1086 isoc_bufs->transfer_buffer[i], sb_size,
1078 em28xx_irq_callback, dev, 1); 1087 em28xx_irq_callback, dev, 1);
1079 1088
1080 urb->number_of_packets = max_packets; 1089 urb->number_of_packets = isoc_bufs->num_packets;
1081 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; 1090 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
1082 1091
1083 k = 0; 1092 k = 0;
1084 for (j = 0; j < max_packets; j++) { 1093 for (j = 0; j < isoc_bufs->num_packets; j++) {
1085 urb->iso_frame_desc[j].offset = k; 1094 urb->iso_frame_desc[j].offset = k;
1086 urb->iso_frame_desc[j].length = 1095 urb->iso_frame_desc[j].length =
1087 dev->isoc_ctl.max_pkt_size; 1096 isoc_bufs->max_pkt_size;
1088 k += dev->isoc_ctl.max_pkt_size; 1097 k += isoc_bufs->max_pkt_size;
1089 } 1098 }
1090 } 1099 }
1091 1100
1101 return 0;
1102}
1103EXPORT_SYMBOL_GPL(em28xx_alloc_isoc);
1104
1105/*
1106 * Allocate URBs and start IRQ
1107 */
1108int em28xx_init_isoc(struct em28xx *dev, enum em28xx_mode mode,
1109 int max_packets, int num_bufs, int max_pkt_size,
1110 int (*isoc_copy) (struct em28xx *dev, struct urb *urb))
1111{
1112 struct em28xx_dmaqueue *dma_q = &dev->vidq;
1113 struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq;
1114 struct em28xx_usb_isoc_bufs *isoc_bufs;
1115 int i;
1116 int rc;
1117 int alloc;
1118
1119 em28xx_isocdbg("em28xx: called em28xx_init_isoc in mode %d\n", mode);
1120
1121 dev->isoc_ctl.isoc_copy = isoc_copy;
1122
1123 if (mode == EM28XX_DIGITAL_MODE) {
1124 isoc_bufs = &dev->isoc_ctl.digital_bufs;
1125 /* no need to free/alloc isoc buffers in digital mode */
1126 alloc = 0;
1127 } else {
1128 isoc_bufs = &dev->isoc_ctl.analog_bufs;
1129 alloc = 1;
1130 }
1131
1132 if (alloc) {
1133 rc = em28xx_alloc_isoc(dev, mode, max_packets,
1134 num_bufs, max_pkt_size);
1135 if (rc)
1136 return rc;
1137 }
1138
1092 init_waitqueue_head(&dma_q->wq); 1139 init_waitqueue_head(&dma_q->wq);
1093 init_waitqueue_head(&vbi_dma_q->wq); 1140 init_waitqueue_head(&vbi_dma_q->wq);
1094 1141
1095 em28xx_capture_start(dev, 1); 1142 em28xx_capture_start(dev, 1);
1096 1143
1097 /* submit urbs and enables IRQ */ 1144 /* submit urbs and enables IRQ */
1098 for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { 1145 for (i = 0; i < isoc_bufs->num_bufs; i++) {
1099 rc = usb_submit_urb(dev->isoc_ctl.urb[i], GFP_ATOMIC); 1146 rc = usb_submit_urb(isoc_bufs->urb[i], GFP_ATOMIC);
1100 if (rc) { 1147 if (rc) {
1101 em28xx_err("submit of urb %i failed (error=%i)\n", i, 1148 em28xx_err("submit of urb %i failed (error=%i)\n", i,
1102 rc); 1149 rc);
1103 em28xx_uninit_isoc(dev); 1150 em28xx_uninit_isoc(dev, mode);
1104 return rc; 1151 return rc;
1105 } 1152 }
1106 } 1153 }
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index aabbf4854f66..503a8d5b5382 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -61,9 +61,6 @@ if (debug >= level) \
61 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ 61 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \
62} while (0) 62} while (0)
63 63
64#define EM28XX_DVB_NUM_BUFS 5
65#define EM28XX_DVB_MAX_PACKETS 64
66
67struct em28xx_dvb { 64struct em28xx_dvb {
68 struct dvb_frontend *fe[2]; 65 struct dvb_frontend *fe[2];
69 66
@@ -172,20 +169,21 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
172 max_dvb_packet_size = dev->dvb_max_pkt_size; 169 max_dvb_packet_size = dev->dvb_max_pkt_size;
173 if (max_dvb_packet_size < 0) 170 if (max_dvb_packet_size < 0)
174 return max_dvb_packet_size; 171 return max_dvb_packet_size;
175 dprintk(1, "Using %d buffers each with %d bytes\n", 172 dprintk(1, "Using %d buffers each with %d x %d bytes\n",
176 EM28XX_DVB_NUM_BUFS, 173 EM28XX_DVB_NUM_BUFS,
174 EM28XX_DVB_MAX_PACKETS,
177 max_dvb_packet_size); 175 max_dvb_packet_size);
178 176
179 return em28xx_init_isoc(dev, EM28XX_DVB_MAX_PACKETS, 177 return em28xx_init_isoc(dev, EM28XX_DIGITAL_MODE,
180 EM28XX_DVB_NUM_BUFS, max_dvb_packet_size, 178 EM28XX_DVB_MAX_PACKETS, EM28XX_DVB_NUM_BUFS,
181 em28xx_dvb_isoc_copy); 179 max_dvb_packet_size, em28xx_dvb_isoc_copy);
182} 180}
183 181
184static int em28xx_stop_streaming(struct em28xx_dvb *dvb) 182static int em28xx_stop_streaming(struct em28xx_dvb *dvb)
185{ 183{
186 struct em28xx *dev = dvb->adapter.priv; 184 struct em28xx *dev = dvb->adapter.priv;
187 185
188 em28xx_uninit_isoc(dev); 186 em28xx_capture_start(dev, 0);
189 187
190 em28xx_set_mode(dev, EM28XX_SUSPEND); 188 em28xx_set_mode(dev, EM28XX_SUSPEND);
191 189
@@ -327,6 +325,19 @@ struct drxk_config hauppauge_930c_drxk = {
327 .chunk_size = 56, 325 .chunk_size = 56,
328}; 326};
329 327
328struct drxk_config maxmedia_ub425_tc_drxk = {
329 .adr = 0x29,
330 .single_master = 1,
331 .no_i2c_bridge = 1,
332};
333
334struct drxk_config pctv_520e_drxk = {
335 .adr = 0x29,
336 .single_master = 1,
337 .microcode_name = "dvb-demod-drxk-pctv.fw",
338 .chunk_size = 58,
339};
340
330static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) 341static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
331{ 342{
332 struct em28xx_dvb *dvb = fe->sec_priv; 343 struct em28xx_dvb *dvb = fe->sec_priv;
@@ -460,6 +471,33 @@ static void terratec_h5_init(struct em28xx *dev)
460 em28xx_gpio_set(dev, terratec_h5_end); 471 em28xx_gpio_set(dev, terratec_h5_end);
461}; 472};
462 473
474static void pctv_520e_init(struct em28xx *dev)
475{
476 /*
477 * Init TDA8295(?) analog demodulator. Looks like I2C traffic to
478 * digital demodulator and tuner are routed via TDA8295.
479 */
480 int i;
481 struct {
482 unsigned char r[4];
483 int len;
484 } regs[] = {
485 {{ 0x06, 0x02, 0x00, 0x31 }, 4},
486 {{ 0x01, 0x02 }, 2},
487 {{ 0x01, 0x02, 0x00, 0xc6 }, 4},
488 {{ 0x01, 0x00 }, 2},
489 {{ 0x01, 0x00, 0xff, 0xaf }, 4},
490 {{ 0x01, 0x00, 0x03, 0xa0 }, 4},
491 {{ 0x01, 0x00 }, 2},
492 {{ 0x01, 0x00, 0x73, 0xaf }, 4},
493 };
494
495 dev->i2c_client.addr = 0x82 >> 1; /* 0x41 */
496
497 for (i = 0; i < ARRAY_SIZE(regs); i++)
498 i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len);
499};
500
463static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe) 501static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe)
464{ 502{
465 /* Values extracted from a USB trace of the Terratec Windows driver */ 503 /* Values extracted from a USB trace of the Terratec Windows driver */
@@ -938,6 +976,48 @@ static int em28xx_dvb_init(struct em28xx *dev)
938 dvb_attach(a8293_attach, dvb->fe[0], &dev->i2c_adap, 976 dvb_attach(a8293_attach, dvb->fe[0], &dev->i2c_adap,
939 &em28xx_a8293_config); 977 &em28xx_a8293_config);
940 break; 978 break;
979 case EM2874_BOARD_MAXMEDIA_UB425_TC:
980 /* attach demodulator */
981 dvb->fe[0] = dvb_attach(drxk_attach, &maxmedia_ub425_tc_drxk,
982 &dev->i2c_adap);
983
984 if (dvb->fe[0]) {
985 /* disable I2C-gate */
986 dvb->fe[0]->ops.i2c_gate_ctrl = NULL;
987
988 /* attach tuner */
989 if (!dvb_attach(tda18271c2dd_attach, dvb->fe[0],
990 &dev->i2c_adap, 0x60)) {
991 dvb_frontend_detach(dvb->fe[0]);
992 result = -EINVAL;
993 goto out_free;
994 }
995 }
996
997 /* TODO: we need drx-3913k firmware in order to support DVB-T */
998 em28xx_info("MaxMedia UB425-TC: only DVB-C supported by that " \
999 "driver version\n");
1000
1001 break;
1002 case EM2884_BOARD_PCTV_510E:
1003 case EM2884_BOARD_PCTV_520E:
1004 pctv_520e_init(dev);
1005
1006 /* attach demodulator */
1007 dvb->fe[0] = dvb_attach(drxk_attach, &pctv_520e_drxk,
1008 &dev->i2c_adap);
1009
1010 if (dvb->fe[0]) {
1011 /* attach tuner */
1012 if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
1013 &dev->i2c_adap,
1014 &em28xx_cxd2820r_tda18271_config)) {
1015 dvb_frontend_detach(dvb->fe[0]);
1016 result = -EINVAL;
1017 goto out_free;
1018 }
1019 }
1020 break;
941 default: 1021 default:
942 em28xx_errdev("/2: The frontend of your DVB/ATSC card" 1022 em28xx_errdev("/2: The frontend of your DVB/ATSC card"
943 " isn't supported yet\n"); 1023 " isn't supported yet\n");
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index 36f5a9bc8b76..a88e169dba23 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -41,14 +41,6 @@ static unsigned int i2c_debug;
41module_param(i2c_debug, int, 0644); 41module_param(i2c_debug, int, 0644);
42MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); 42MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
43 43
44
45#define dprintk1(lvl, fmt, args...) \
46do { \
47 if (i2c_debug >= lvl) { \
48 printk(fmt, ##args); \
49 } \
50} while (0)
51
52#define dprintk2(lvl, fmt, args...) \ 44#define dprintk2(lvl, fmt, args...) \
53do { \ 45do { \
54 if (i2c_debug >= lvl) { \ 46 if (i2c_debug >= lvl) { \
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 613300b51a9e..324b695c0724 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -760,17 +760,19 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
760 goto fail; 760 goto fail;
761 } 761 }
762 762
763 if (!dev->isoc_ctl.num_bufs) 763 if (!dev->isoc_ctl.analog_bufs.num_bufs)
764 urb_init = 1; 764 urb_init = 1;
765 765
766 if (urb_init) { 766 if (urb_init) {
767 if (em28xx_vbi_supported(dev) == 1) 767 if (em28xx_vbi_supported(dev) == 1)
768 rc = em28xx_init_isoc(dev, EM28XX_NUM_PACKETS, 768 rc = em28xx_init_isoc(dev, EM28XX_ANALOG_MODE,
769 EM28XX_NUM_PACKETS,
769 EM28XX_NUM_BUFS, 770 EM28XX_NUM_BUFS,
770 dev->max_pkt_size, 771 dev->max_pkt_size,
771 em28xx_isoc_copy_vbi); 772 em28xx_isoc_copy_vbi);
772 else 773 else
773 rc = em28xx_init_isoc(dev, EM28XX_NUM_PACKETS, 774 rc = em28xx_init_isoc(dev, EM28XX_ANALOG_MODE,
775 EM28XX_NUM_PACKETS,
774 EM28XX_NUM_BUFS, 776 EM28XX_NUM_BUFS,
775 dev->max_pkt_size, 777 dev->max_pkt_size,
776 em28xx_isoc_copy); 778 em28xx_isoc_copy);
@@ -2267,7 +2269,7 @@ static int em28xx_v4l2_close(struct file *filp)
2267 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0); 2269 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0);
2268 2270
2269 /* do this before setting alternate! */ 2271 /* do this before setting alternate! */
2270 em28xx_uninit_isoc(dev); 2272 em28xx_uninit_isoc(dev, EM28XX_ANALOG_MODE);
2271 em28xx_set_mode(dev, EM28XX_SUSPEND); 2273 em28xx_set_mode(dev, EM28XX_SUSPEND);
2272 2274
2273 /* set alternate 0 */ 2275 /* set alternate 0 */
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 22e252bcc41e..2868b19f8b54 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -125,6 +125,9 @@
125#define EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C 81 125#define EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C 81
126#define EM2884_BOARD_CINERGY_HTC_STICK 82 126#define EM2884_BOARD_CINERGY_HTC_STICK 82
127#define EM2860_BOARD_HT_VIDBOX_NW03 83 127#define EM2860_BOARD_HT_VIDBOX_NW03 83
128#define EM2874_BOARD_MAXMEDIA_UB425_TC 84
129#define EM2884_BOARD_PCTV_510E 85
130#define EM2884_BOARD_PCTV_520E 86
128 131
129/* Limits minimum and default number of buffers */ 132/* Limits minimum and default number of buffers */
130#define EM28XX_MIN_BUF 4 133#define EM28XX_MIN_BUF 4
@@ -151,12 +154,14 @@
151 154
152/* number of buffers for isoc transfers */ 155/* number of buffers for isoc transfers */
153#define EM28XX_NUM_BUFS 5 156#define EM28XX_NUM_BUFS 5
157#define EM28XX_DVB_NUM_BUFS 5
154 158
155/* number of packets for each buffer 159/* number of packets for each buffer
156 windows requests only 64 packets .. so we better do the same 160 windows requests only 64 packets .. so we better do the same
157 this is what I found out for all alternate numbers there! 161 this is what I found out for all alternate numbers there!
158 */ 162 */
159#define EM28XX_NUM_PACKETS 64 163#define EM28XX_NUM_PACKETS 64
164#define EM28XX_DVB_MAX_PACKETS 64
160 165
161#define EM28XX_INTERLACED_DEFAULT 1 166#define EM28XX_INTERLACED_DEFAULT 1
162 167
@@ -197,10 +202,13 @@ enum em28xx_mode {
197 202
198struct em28xx; 203struct em28xx;
199 204
200struct em28xx_usb_isoc_ctl { 205struct em28xx_usb_isoc_bufs {
201 /* max packet size of isoc transaction */ 206 /* max packet size of isoc transaction */
202 int max_pkt_size; 207 int max_pkt_size;
203 208
209 /* number of packets in each buffer */
210 int num_packets;
211
204 /* number of allocated urbs */ 212 /* number of allocated urbs */
205 int num_bufs; 213 int num_bufs;
206 214
@@ -209,6 +217,14 @@ struct em28xx_usb_isoc_ctl {
209 217
210 /* transfer buffers for isoc transfer */ 218 /* transfer buffers for isoc transfer */
211 char **transfer_buffer; 219 char **transfer_buffer;
220};
221
222struct em28xx_usb_isoc_ctl {
223 /* isoc transfer buffers for analog mode */
224 struct em28xx_usb_isoc_bufs analog_bufs;
225
226 /* isoc transfer buffers for digital mode */
227 struct em28xx_usb_isoc_bufs digital_bufs;
212 228
213 /* Last buffer command and region */ 229 /* Last buffer command and region */
214 u8 cmd; 230 u8 cmd;
@@ -600,9 +616,6 @@ struct em28xx {
600 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ 616 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
601 int dvb_alt; /* alternate for DVB */ 617 int dvb_alt; /* alternate for DVB */
602 unsigned int dvb_max_pkt_size; /* wMaxPacketSize for DVB */ 618 unsigned int dvb_max_pkt_size; /* wMaxPacketSize for DVB */
603 struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */
604 char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc
605 transfer */
606 char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ 619 char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */
607 620
608 /* helper funcs that call usb_control_msg */ 621 /* helper funcs that call usb_control_msg */
@@ -676,10 +689,12 @@ int em28xx_vbi_supported(struct em28xx *dev);
676int em28xx_set_outfmt(struct em28xx *dev); 689int em28xx_set_outfmt(struct em28xx *dev);
677int em28xx_resolution_set(struct em28xx *dev); 690int em28xx_resolution_set(struct em28xx *dev);
678int em28xx_set_alternate(struct em28xx *dev); 691int em28xx_set_alternate(struct em28xx *dev);
679int em28xx_init_isoc(struct em28xx *dev, int max_packets, 692int em28xx_alloc_isoc(struct em28xx *dev, enum em28xx_mode mode,
680 int num_bufs, int max_pkt_size, 693 int max_packets, int num_bufs, int max_pkt_size);
694int em28xx_init_isoc(struct em28xx *dev, enum em28xx_mode mode,
695 int max_packets, int num_bufs, int max_pkt_size,
681 int (*isoc_copy) (struct em28xx *dev, struct urb *urb)); 696 int (*isoc_copy) (struct em28xx *dev, struct urb *urb));
682void em28xx_uninit_isoc(struct em28xx *dev); 697void em28xx_uninit_isoc(struct em28xx *dev, enum em28xx_mode mode);
683int em28xx_isoc_dvb_max_packetsize(struct em28xx *dev); 698int em28xx_isoc_dvb_max_packetsize(struct em28xx *dev);
684int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); 699int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode);
685int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); 700int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio);