aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb
diff options
context:
space:
mode:
authorTimothy Lee <timothy.lee@siriushk.com>2008-08-09 12:36:51 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:36:49 -0400
commitdfbdce04905d3196c828ca36f01ef06e6fdb2428 (patch)
treef3665bc518d6365b6e0533d49eee47c33b43c069 /drivers/media/dvb/dvb-usb
parent2e06d2ff548fc6333f5b34d188646ded327187c3 (diff)
V4L/DVB (8657): cxusb: add lgs8gl5 and support for Magic-Pro DMB-TH usb stick
Add support for Magic-Pro DMB-TH usb stick. DMB-TH is the HDTV broadcast standard used in Hong Kong and China. [...] I've also attached a second patch against the dvb-apps repository which adds a DMB-TH scan file for Hong Kong. Since the ProHDTV stick contains a DMB-TH decoder (lgs8gl5) onboard, it outputs MPEG-TS to the PC. Signed-off-by: Timothy Lee <timothy.lee@siriushk.com> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c286
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h2
2 files changed, 288 insertions, 0 deletions
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index 338c819ca739..bffb44380389 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -38,6 +38,7 @@
38#include "mxl5005s.h" 38#include "mxl5005s.h"
39#include "dib7000p.h" 39#include "dib7000p.h"
40#include "dib0070.h" 40#include "dib0070.h"
41#include "lgs8gl5.h"
41 42
42/* debug */ 43/* debug */
43static int dvb_usb_cxusb_debug; 44static int dvb_usb_cxusb_debug;
@@ -111,6 +112,25 @@ static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
111 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40); 112 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
112} 113}
113 114
115static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
116 u8 addr, int onoff)
117{
118 u8 o[2] = {addr, onoff};
119 u8 i;
120 int rc;
121
122 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
123
124 if (rc < 0)
125 return rc;
126 if (i == 0x01)
127 return 0;
128 else {
129 deb_info("gpio_write failed.\n");
130 return -EIO;
131 }
132}
133
114/* I2C */ 134/* I2C */
115static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], 135static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
116 int num) 136 int num)
@@ -264,6 +284,20 @@ static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
264 return rc; 284 return rc;
265} 285}
266 286
287static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)
288{
289 int ret;
290 u8 b;
291 ret = cxusb_power_ctrl(d, onoff);
292 if (!onoff)
293 return ret;
294
295 msleep(128);
296 cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1);
297 msleep(100);
298 return ret;
299}
300
267static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 301static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
268{ 302{
269 u8 buf[2] = { 0x03, 0x00 }; 303 u8 buf[2] = { 0x03, 0x00 };
@@ -285,6 +319,67 @@ static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
285 return 0; 319 return 0;
286} 320}
287 321
322static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
323{
324 int ep = d->props.generic_bulk_ctrl_endpoint;
325 const int timeout = 100;
326 const int junk_len = 32;
327 u8 *junk;
328 int rd_count;
329
330 /* Discard remaining data in video pipe */
331 junk = kmalloc(junk_len, GFP_KERNEL);
332 if (!junk)
333 return;
334 while (1) {
335 if (usb_bulk_msg(d->udev,
336 usb_rcvbulkpipe(d->udev, ep),
337 junk, junk_len, &rd_count, timeout) < 0)
338 break;
339 if (!rd_count)
340 break;
341 }
342 kfree(junk);
343}
344
345static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
346{
347 struct usb_data_stream_properties *p = &d->props.adapter[0].stream;
348 const int timeout = 100;
349 const int junk_len = p->u.bulk.buffersize;
350 u8 *junk;
351 int rd_count;
352
353 /* Discard remaining data in video pipe */
354 junk = kmalloc(junk_len, GFP_KERNEL);
355 if (!junk)
356 return;
357 while (1) {
358 if (usb_bulk_msg(d->udev,
359 usb_rcvbulkpipe(d->udev, p->endpoint),
360 junk, junk_len, &rd_count, timeout) < 0)
361 break;
362 if (!rd_count)
363 break;
364 }
365 kfree(junk);
366}
367
368static int cxusb_d680_dmb_streaming_ctrl(
369 struct dvb_usb_adapter *adap, int onoff)
370{
371 if (onoff) {
372 u8 buf[2] = { 0x03, 0x00 };
373 cxusb_d680_dmb_drain_video(adap->dev);
374 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
375 buf, sizeof(buf), NULL, 0);
376 } else {
377 int ret = cxusb_ctrl_msg(adap->dev,
378 CMD_STREAMING_OFF, NULL, 0, NULL, 0);
379 return ret;
380 }
381}
382
288static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 383static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
289{ 384{
290 struct dvb_usb_rc_key *keymap = d->props.rc_key_map; 385 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
@@ -337,6 +432,32 @@ static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
337 return 0; 432 return 0;
338} 433}
339 434
435static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
436 int *state)
437{
438 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
439 u8 ircode[2];
440 int i;
441
442 *event = 0;
443 *state = REMOTE_NO_KEY_PRESSED;
444
445 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
446 return 0;
447
448 for (i = 0; i < d->props.rc_key_map_size; i++) {
449 if (keymap[i].custom == ircode[0] &&
450 keymap[i].data == ircode[1]) {
451 *event = keymap[i].event;
452 *state = REMOTE_KEY_PRESSED;
453
454 return 0;
455 }
456 }
457
458 return 0;
459}
460
340static struct dvb_usb_rc_key dvico_mce_rc_keys[] = { 461static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
341 { 0xfe, 0x02, KEY_TV }, 462 { 0xfe, 0x02, KEY_TV },
342 { 0xfe, 0x0e, KEY_MP3 }, 463 { 0xfe, 0x0e, KEY_MP3 },
@@ -424,6 +545,44 @@ static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
424 { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */ 545 { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
425}; 546};
426 547
548static struct dvb_usb_rc_key d680_dmb_rc_keys[] = {
549 { 0x00, 0x38, KEY_UNKNOWN }, /* TV/AV */
550 { 0x08, 0x0c, KEY_ZOOM },
551 { 0x08, 0x00, KEY_0 },
552 { 0x00, 0x01, KEY_1 },
553 { 0x08, 0x02, KEY_2 },
554 { 0x00, 0x03, KEY_3 },
555 { 0x08, 0x04, KEY_4 },
556 { 0x00, 0x05, KEY_5 },
557 { 0x08, 0x06, KEY_6 },
558 { 0x00, 0x07, KEY_7 },
559 { 0x08, 0x08, KEY_8 },
560 { 0x00, 0x09, KEY_9 },
561 { 0x00, 0x0a, KEY_MUTE },
562 { 0x08, 0x29, KEY_BACK },
563 { 0x00, 0x12, KEY_CHANNELUP },
564 { 0x08, 0x13, KEY_CHANNELDOWN },
565 { 0x00, 0x2b, KEY_VOLUMEUP },
566 { 0x08, 0x2c, KEY_VOLUMEDOWN },
567 { 0x00, 0x20, KEY_UP },
568 { 0x08, 0x21, KEY_DOWN },
569 { 0x00, 0x11, KEY_LEFT },
570 { 0x08, 0x10, KEY_RIGHT },
571 { 0x00, 0x0d, KEY_OK },
572 { 0x08, 0x1f, KEY_RECORD },
573 { 0x00, 0x17, KEY_PLAYPAUSE },
574 { 0x08, 0x16, KEY_PLAYPAUSE },
575 { 0x00, 0x0b, KEY_STOP },
576 { 0x08, 0x27, KEY_FASTFORWARD },
577 { 0x00, 0x26, KEY_REWIND },
578 { 0x08, 0x1e, KEY_UNKNOWN }, /* Time Shift */
579 { 0x00, 0x0e, KEY_UNKNOWN }, /* Snapshot */
580 { 0x08, 0x2d, KEY_UNKNOWN }, /* Mouse Cursor */
581 { 0x00, 0x0f, KEY_UNKNOWN }, /* Minimize/Maximize */
582 { 0x08, 0x14, KEY_UNKNOWN }, /* Shuffle */
583 { 0x00, 0x25, KEY_POWER },
584};
585
427static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) 586static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
428{ 587{
429 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 }; 588 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
@@ -529,6 +688,24 @@ static struct mxl5005s_config aver_a868r_tuner = {
529 .AgcMasterByte = 0x00, 688 .AgcMasterByte = 0x00,
530}; 689};
531 690
691/* FIXME: needs tweaking */
692static struct mxl5005s_config d680_dmb_tuner = {
693 .i2c_address = 0x63,
694 .if_freq = 36125000UL,
695 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
696 .agc_mode = MXL_SINGLE_AGC,
697 .tracking_filter = MXL_TF_C,
698 .rssi_enable = MXL_RSSI_ENABLE,
699 .cap_select = MXL_CAP_SEL_ENABLE,
700 .div_out = MXL_DIV_OUT_4,
701 .clock_out = MXL_CLOCK_OUT_DISABLE,
702 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
703 .top = MXL5005S_TOP_25P2,
704 .mod_mode = MXL_DIGITAL_MODE,
705 .if_mode = MXL_ZERO_IF,
706 .AgcMasterByte = 0x00,
707};
708
532/* Callbacks for DVB USB */ 709/* Callbacks for DVB USB */
533static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) 710static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
534{ 711{
@@ -617,6 +794,14 @@ static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
617 return 0; 794 return 0;
618} 795}
619 796
797static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
798{
799 struct dvb_frontend *fe;
800 fe = dvb_attach(mxl5005s_attach, adap->fe,
801 &adap->dev->i2c_adap, &d680_dmb_tuner);
802 return (fe == NULL) ? -EIO : 0;
803}
804
620static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap) 805static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
621{ 806{
622 u8 b; 807 u8 b;
@@ -906,6 +1091,54 @@ static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
906 return -EIO; 1091 return -EIO;
907} 1092}
908 1093
1094static struct lgs8gl5_config lgs8gl5_cfg = {
1095 .demod_address = 0x19,
1096};
1097
1098static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1099{
1100 struct dvb_usb_device *d = adap->dev;
1101 int n;
1102
1103 /* Select required USB configuration */
1104 if (usb_set_interface(d->udev, 0, 0) < 0)
1105 err("set interface failed");
1106
1107 /* Unblock all USB pipes */
1108 usb_clear_halt(d->udev,
1109 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1110 usb_clear_halt(d->udev,
1111 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1112 usb_clear_halt(d->udev,
1113 usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));
1114
1115 /* Drain USB pipes to avoid hang after reboot */
1116 for (n = 0; n < 5; n++) {
1117 cxusb_d680_dmb_drain_message(d);
1118 cxusb_d680_dmb_drain_video(d);
1119 msleep(200);
1120 }
1121
1122 /* Reset the tuner */
1123 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1124 err("clear tuner gpio failed");
1125 return -EIO;
1126 }
1127 msleep(100);
1128 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1129 err("set tuner gpio failed");
1130 return -EIO;
1131 }
1132 msleep(100);
1133
1134 /* Attach frontend */
1135 adap->fe = dvb_attach(lgs8gl5_attach, &lgs8gl5_cfg, &d->i2c_adap);
1136 if (adap->fe == NULL)
1137 return -EIO;
1138
1139 return 0;
1140}
1141
909/* 1142/*
910 * DViCO has shipped two devices with the same USB ID, but only one of them 1143 * DViCO has shipped two devices with the same USB ID, but only one of them
911 * needs a firmware download. Check the device class details to see if they 1144 * needs a firmware download. Check the device class details to see if they
@@ -985,6 +1218,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
985static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties; 1218static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
986static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties; 1219static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
987static struct dvb_usb_device_properties cxusb_aver_a868r_properties; 1220static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
1221static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
988 1222
989static int cxusb_probe(struct usb_interface *intf, 1223static int cxusb_probe(struct usb_interface *intf,
990 const struct usb_device_id *id) 1224 const struct usb_device_id *id)
@@ -1011,6 +1245,8 @@ static int cxusb_probe(struct usb_interface *intf,
1011 0 == dvb_usb_device_init(intf, 1245 0 == dvb_usb_device_init(intf,
1012 &cxusb_bluebird_dualdig4_rev2_properties, 1246 &cxusb_bluebird_dualdig4_rev2_properties,
1013 THIS_MODULE, NULL, adapter_nr) || 1247 THIS_MODULE, NULL, adapter_nr) ||
1248 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1249 THIS_MODULE, NULL, adapter_nr) ||
1014 0) 1250 0)
1015 return 0; 1251 return 0;
1016 1252
@@ -1036,6 +1272,7 @@ static struct usb_device_id cxusb_table [] = {
1036 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) }, 1272 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
1037 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) }, 1273 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
1038 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) }, 1274 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
1275 { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
1039 {} /* Terminating entry */ 1276 {} /* Terminating entry */
1040}; 1277};
1041MODULE_DEVICE_TABLE (usb, cxusb_table); 1278MODULE_DEVICE_TABLE (usb, cxusb_table);
@@ -1530,6 +1767,55 @@ struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
1530 } 1767 }
1531}; 1768};
1532 1769
1770static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
1771 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1772
1773 .usb_ctrl = CYPRESS_FX2,
1774
1775 .size_of_priv = sizeof(struct cxusb_state),
1776
1777 .num_adapters = 1,
1778 .adapter = {
1779 {
1780 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
1781 .frontend_attach = cxusb_d680_dmb_frontend_attach,
1782 .tuner_attach = cxusb_d680_dmb_tuner_attach,
1783
1784 /* parameter for the MPEG2-data transfer */
1785 .stream = {
1786 .type = USB_BULK,
1787 .count = 5,
1788 .endpoint = 0x02,
1789 .u = {
1790 .bulk = {
1791 .buffersize = 8192,
1792 }
1793 }
1794 },
1795 },
1796 },
1797
1798 .power_ctrl = cxusb_d680_dmb_power_ctrl,
1799
1800 .i2c_algo = &cxusb_i2c_algo,
1801
1802 .generic_bulk_ctrl_endpoint = 0x01,
1803
1804 .rc_interval = 100,
1805 .rc_key_map = d680_dmb_rc_keys,
1806 .rc_key_map_size = ARRAY_SIZE(d680_dmb_rc_keys),
1807 .rc_query = cxusb_d680_dmb_rc_query,
1808
1809 .num_device_descs = 1,
1810 .devices = {
1811 {
1812 "Conexant DMB-TH Stick",
1813 { NULL },
1814 { &cxusb_table[18], NULL },
1815 },
1816 }
1817};
1818
1533static struct usb_driver cxusb_driver = { 1819static struct usb_driver cxusb_driver = {
1534 .name = "dvb_usb_cxusb", 1820 .name = "dvb_usb_cxusb",
1535 .probe = cxusb_probe, 1821 .probe = cxusb_probe,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index f327a154b6c6..81369b79e75a 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -22,6 +22,7 @@
22#define USB_VID_AVERMEDIA 0x07ca 22#define USB_VID_AVERMEDIA 0x07ca
23#define USB_VID_COMPRO 0x185b 23#define USB_VID_COMPRO 0x185b
24#define USB_VID_COMPRO_UNK 0x145f 24#define USB_VID_COMPRO_UNK 0x145f
25#define USB_VID_CONEXANT 0x0572
25#define USB_VID_CYPRESS 0x04b4 26#define USB_VID_CYPRESS 0x04b4
26#define USB_VID_DIBCOM 0x10b8 27#define USB_VID_DIBCOM 0x10b8
27#define USB_VID_DPOSH 0x1498 28#define USB_VID_DPOSH 0x1498
@@ -69,6 +70,7 @@
69#define USB_PID_COMPRO_DVBU2000_UNK_WARM 0x010d 70#define USB_PID_COMPRO_DVBU2000_UNK_WARM 0x010d
70#define USB_PID_COMPRO_VIDEOMATE_U500 0x1e78 71#define USB_PID_COMPRO_VIDEOMATE_U500 0x1e78
71#define USB_PID_COMPRO_VIDEOMATE_U500_PC 0x1e80 72#define USB_PID_COMPRO_VIDEOMATE_U500_PC 0x1e80
73#define USB_PID_CONEXANT_D680_DMB 0x86d6
72#define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064 74#define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064
73#define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065 75#define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065
74#define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8 76#define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8