aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig12
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile4
-rw-r--r--drivers/media/dvb/dvb-usb/au6610.c6
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h6
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c2
-rw-r--r--drivers/media/dvb/dvb-usb/gl861.c8
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c235
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.h46
-rw-r--r--drivers/media/dvb/dvb-usb/opera1.c581
-rw-r--r--drivers/media/dvb/dvb-usb/opera1.h9
-rw-r--r--drivers/media/dvb/dvb-usb/ttusb2.c7
13 files changed, 822 insertions, 102 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 80f67a51b908..54488737a08f 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -33,6 +33,7 @@ config DVB_USB_A800
33config DVB_USB_DIBUSB_MB 33config DVB_USB_DIBUSB_MB
34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)" 34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)"
35 depends on DVB_USB 35 depends on DVB_USB
36 select DVB_PLL
36 select DVB_DIB3000MB 37 select DVB_DIB3000MB
37 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE 38 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
38 help 39 help
@@ -88,6 +89,7 @@ config DVB_USB_DIB0700
88config DVB_USB_UMT_010 89config DVB_USB_UMT_010
89 tristate "HanfTek UMT-010 DVB-T USB2.0 support" 90 tristate "HanfTek UMT-010 DVB-T USB2.0 support"
90 depends on DVB_USB 91 depends on DVB_USB
92 select DVB_PLL
91 select DVB_DIB3000MC 93 select DVB_DIB3000MC
92 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE 94 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
93 help 95 help
@@ -96,9 +98,9 @@ config DVB_USB_UMT_010
96config DVB_USB_CXUSB 98config DVB_USB_CXUSB
97 tristate "Conexant USB2.0 hybrid reference design support" 99 tristate "Conexant USB2.0 hybrid reference design support"
98 depends on DVB_USB 100 depends on DVB_USB
101 select DVB_PLL
99 select DVB_CX22702 if !DVB_FE_CUSTOMISE 102 select DVB_CX22702 if !DVB_FE_CUSTOMISE
100 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 103 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
101 select DVB_TUNER_LGH06XF if !DVB_FE_CUSTOMISE
102 select DVB_MT352 if !DVB_FE_CUSTOMISE 104 select DVB_MT352 if !DVB_FE_CUSTOMISE
103 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 105 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
104 help 106 help
@@ -140,6 +142,7 @@ config DVB_USB_AU6610
140config DVB_USB_DIGITV 142config DVB_USB_DIGITV
141 tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support" 143 tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support"
142 depends on DVB_USB 144 depends on DVB_USB
145 select DVB_PLL
143 select DVB_NXT6000 if !DVB_FE_CUSTOMISE 146 select DVB_NXT6000 if !DVB_FE_CUSTOMISE
144 select DVB_MT352 if !DVB_FE_CUSTOMISE 147 select DVB_MT352 if !DVB_FE_CUSTOMISE
145 help 148 help
@@ -208,3 +211,10 @@ config DVB_USB_DTT200U
208 The receivers are also known as DTT200U (Yakumo) and UB300 (Yuan). 211 The receivers are also known as DTT200U (Yakumo) and UB300 (Yuan).
209 212
210 The WT-220U and its clones are pen-sized. 213 The WT-220U and its clones are pen-sized.
214
215config DVB_USB_OPERA1
216 tristate "Opera1 DVB-S USB2.0 receiver"
217 depends on DVB_USB
218 select DVB_STV0299 if !DVB_FE_CUSTOMISE
219 help
220 Say Y here to support the Opera DVB-S USB2.0 receiver.
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 40f28f559b54..976f840cc904 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -51,4 +51,8 @@ obj-$(CONFIG_DVB_USB_TTUSB2) += dvb-usb-ttusb2.o
51dvb-usb-dib0700-objs = dib0700_core.o dib0700_devices.o 51dvb-usb-dib0700-objs = dib0700_core.o dib0700_devices.o
52obj-$(CONFIG_DVB_USB_DIB0700) += dvb-usb-dib0700.o 52obj-$(CONFIG_DVB_USB_DIB0700) += dvb-usb-dib0700.o
53 53
54dvb-usb-opera-objs = opera1.o
55obj-$(CONFIG_DVB_USB_OPERA1) += dvb-usb-opera.o
56
57
54EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 58EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/dvb-usb/au6610.c b/drivers/media/dvb/dvb-usb/au6610.c
index 0dc66a8d2baf..18e0b16fb2a9 100644
--- a/drivers/media/dvb/dvb-usb/au6610.c
+++ b/drivers/media/dvb/dvb-usb/au6610.c
@@ -40,7 +40,7 @@ static int au6610_usb_msg(struct dvb_usb_device *d, u8 operation, u8 addr,
40 } 40 }
41 41
42 ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), operation, 42 ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), operation,
43 USB_TYPE_VENDOR|USB_DIR_IN, addr, index, usb_buf, 43 USB_TYPE_VENDOR|USB_DIR_IN, addr << 1, index, usb_buf,
44 sizeof(usb_buf), AU6610_USB_TIMEOUT); 44 sizeof(usb_buf), AU6610_USB_TIMEOUT);
45 45
46 if (ret < 0) 46 if (ret < 0)
@@ -124,7 +124,7 @@ static int au6610_identify_state(struct usb_device *udev,
124} 124}
125 125
126static struct zl10353_config au6610_zl10353_config = { 126static struct zl10353_config au6610_zl10353_config = {
127 .demod_address = 0x1e, 127 .demod_address = 0x0f,
128 .no_tuner = 1, 128 .no_tuner = 1,
129 .parallel_ts = 1, 129 .parallel_ts = 1,
130}; 130};
@@ -140,7 +140,7 @@ static int au6610_zl10353_frontend_attach(struct dvb_usb_adapter *adap)
140} 140}
141 141
142static struct qt1010_config au6610_qt1010_config = { 142static struct qt1010_config au6610_qt1010_config = {
143 .i2c_address = 0xc4 143 .i2c_address = 0x62
144}; 144};
145 145
146static int au6610_qt1010_tuner_attach(struct dvb_usb_adapter *adap) 146static int au6610_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index 127a94b9a1b5..bac2ae3b4a1f 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -27,7 +27,6 @@
27 27
28#include "cx22702.h" 28#include "cx22702.h"
29#include "lgdt330x.h" 29#include "lgdt330x.h"
30#include "lgh06xf.h"
31#include "mt352.h" 30#include "mt352.h"
32#include "mt352_priv.h" 31#include "mt352_priv.h"
33#include "zl10353.h" 32#include "zl10353.h"
@@ -388,7 +387,8 @@ static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
388 387
389static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap) 388static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
390{ 389{
391 dvb_attach(lgh06xf_attach, adap->fe, &adap->dev->i2c_adap); 390 dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
391 &dvb_pll_lg_tdvs_h06xf);
392 return 0; 392 return 0;
393} 393}
394 394
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 6a4d150784a6..dddf164f269a 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -56,10 +56,6 @@ static int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u
56 if (txlen > 3) 56 if (txlen > 3)
57 index |= tx[3]; 57 index |= tx[3];
58 58
59 /* think about swapping here */
60 value = le16_to_cpu(value);
61 index = le16_to_cpu(index);
62
63 status = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev,0), tx[0], 59 status = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev,0), tx[0],
64 USB_TYPE_VENDOR | USB_DIR_IN, value, index, rx, rxlen, 60 USB_TYPE_VENDOR | USB_DIR_IN, value, index, rx, rxlen,
65 USB_CTRL_GET_TIMEOUT); 61 USB_CTRL_GET_TIMEOUT);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 148386aba275..97715f7514d6 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -13,6 +13,7 @@
13#define USB_VID_ADSTECH 0x06e1 13#define USB_VID_ADSTECH 0x06e1
14#define USB_VID_ALCOR_MICRO 0x058f 14#define USB_VID_ALCOR_MICRO 0x058f
15#define USB_VID_ANCHOR 0x0547 15#define USB_VID_ANCHOR 0x0547
16#define USB_VID_ANUBIS_ELECTRONIC 0x10fd
16#define USB_VID_AVERMEDIA 0x07ca 17#define USB_VID_AVERMEDIA 0x07ca
17#define USB_VID_COMPRO 0x185b 18#define USB_VID_COMPRO 0x185b
18#define USB_VID_COMPRO_UNK 0x145f 19#define USB_VID_COMPRO_UNK 0x145f
@@ -31,6 +32,7 @@
31#define USB_VID_LITEON 0x04ca 32#define USB_VID_LITEON 0x04ca
32#define USB_VID_MEDION 0x1660 33#define USB_VID_MEDION 0x1660
33#define USB_VID_MSI 0x0db0 34#define USB_VID_MSI 0x0db0
35#define USB_VID_OPERA1 0x695c
34#define USB_VID_PINNACLE 0x2304 36#define USB_VID_PINNACLE 0x2304
35#define USB_VID_VISIONPLUS 0x13d3 37#define USB_VID_VISIONPLUS 0x13d3
36#define USB_VID_TWINHAN 0x1822 38#define USB_VID_TWINHAN 0x1822
@@ -127,6 +129,7 @@
127#define USB_PID_KYE_DVB_T_WARM 0x701f 129#define USB_PID_KYE_DVB_T_WARM 0x701f
128#define USB_PID_PCTV_200E 0x020e 130#define USB_PID_PCTV_200E 0x020e
129#define USB_PID_PCTV_400E 0x020f 131#define USB_PID_PCTV_400E 0x020f
132#define USB_PID_PCTV_450E 0x0222
130#define USB_PID_LITEON_DVB_T_COLD 0xf000 133#define USB_PID_LITEON_DVB_T_COLD 0xf000
131#define USB_PID_LITEON_DVB_T_WARM 0xf001 134#define USB_PID_LITEON_DVB_T_WARM 0xf001
132#define USB_PID_DIGIVOX_MINI_SL_COLD 0xe360 135#define USB_PID_DIGIVOX_MINI_SL_COLD 0xe360
@@ -139,6 +142,9 @@
139#define USB_PID_GENPIX_8PSK_COLD 0x0200 142#define USB_PID_GENPIX_8PSK_COLD 0x0200
140#define USB_PID_GENPIX_8PSK_WARM 0x0201 143#define USB_PID_GENPIX_8PSK_WARM 0x0201
141#define USB_PID_SIGMATEK_DVB_110 0x6610 144#define USB_PID_SIGMATEK_DVB_110 0x6610
145#define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513
146#define USB_PID_OPERA1_COLD 0x2830
147#define USB_PID_OPERA1_WARM 0x3829
142 148
143 149
144#endif 150#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index 9511a31c8f50..68ed3a788083 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -107,8 +107,6 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
107 return -ENOMEM; 107 return -ENOMEM;
108 108
109 input_dev->evbit[0] = BIT(EV_KEY); 109 input_dev->evbit[0] = BIT(EV_KEY);
110 input_dev->keycodesize = sizeof(unsigned char);
111 input_dev->keycodemax = KEY_MAX;
112 input_dev->name = "IR-receiver inside an USB DVB receiver"; 110 input_dev->name = "IR-receiver inside an USB DVB receiver";
113 input_dev->phys = d->rc_phys; 111 input_dev->phys = d->rc_phys;
114 usb_to_input_id(d->udev, &input_dev->id); 112 usb_to_input_id(d->udev, &input_dev->id);
diff --git a/drivers/media/dvb/dvb-usb/gl861.c b/drivers/media/dvb/dvb-usb/gl861.c
index c9f38a5e70d3..e0587e663591 100644
--- a/drivers/media/dvb/dvb-usb/gl861.c
+++ b/drivers/media/dvb/dvb-usb/gl861.c
@@ -12,7 +12,7 @@
12#include "qt1010.h" 12#include "qt1010.h"
13 13
14/* debug */ 14/* debug */
15int dvb_usb_gl861_debug; 15static int dvb_usb_gl861_debug;
16module_param_named(debug,dvb_usb_gl861_debug, int, 0644); 16module_param_named(debug,dvb_usb_gl861_debug, int, 0644);
17MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); 17MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
18 18
@@ -20,7 +20,7 @@ static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr,
20 u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) 20 u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
21{ 21{
22 u16 index; 22 u16 index;
23 u16 value = addr << 8; 23 u16 value = addr << (8 + 1);
24 int wo = (rbuf == NULL || rlen == 0); /* write-only */ 24 int wo = (rbuf == NULL || rlen == 0); /* write-only */
25 u8 req, type; 25 u8 req, type;
26 26
@@ -101,7 +101,7 @@ static int gl861_identify_state(struct usb_device *udev,
101} 101}
102 102
103static struct zl10353_config gl861_zl10353_config = { 103static struct zl10353_config gl861_zl10353_config = {
104 .demod_address = 0x1e, 104 .demod_address = 0x0f,
105 .no_tuner = 1, 105 .no_tuner = 1,
106 .parallel_ts = 1, 106 .parallel_ts = 1,
107}; 107};
@@ -117,7 +117,7 @@ static int gl861_frontend_attach(struct dvb_usb_adapter *adap)
117} 117}
118 118
119static struct qt1010_config gl861_qt1010_config = { 119static struct qt1010_config gl861_qt1010_config = {
120 .i2c_address = 0xc4 120 .i2c_address = 0x62
121}; 121};
122 122
123static int gl861_tuner_attach(struct dvb_usb_adapter *adap) 123static int gl861_tuner_attach(struct dvb_usb_adapter *adap)
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index d48b24d9abf4..45d7bc214c18 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -14,6 +14,8 @@
14#include "mt352.h" 14#include "mt352.h"
15#include "mt352_priv.h" 15#include "mt352_priv.h"
16#include "qt1010.h" 16#include "qt1010.h"
17#include "tda1004x.h"
18#include "tda827x.h"
17 19
18/* debug */ 20/* debug */
19static int dvb_usb_m920x_debug; 21static int dvb_usb_m920x_debug;
@@ -47,11 +49,15 @@ static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\
47 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 49 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
48 request, USB_TYPE_VENDOR | USB_DIR_IN, 50 request, USB_TYPE_VENDOR | USB_DIR_IN,
49 value, index, data, size, 2000); 51 value, index, data, size, 2000);
50 if (ret < 0) 52 if (ret < 0) {
53 printk(KERN_INFO "m920x_read = error: %d\n", ret);
51 return ret; 54 return ret;
55 }
52 56
53 if (ret != size) 57 if (ret != size) {
58 deb_rc("m920x_read = no data\n");
54 return -EIO; 59 return -EIO;
60 }
55 61
56 return 0; 62 return 0;
57} 63}
@@ -64,19 +70,22 @@ static inline int m9206_write(struct usb_device *udev, u8 request,
64 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 70 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
65 request, USB_TYPE_VENDOR | USB_DIR_OUT, 71 request, USB_TYPE_VENDOR | USB_DIR_OUT,
66 value, index, NULL, 0, 2000); 72 value, index, NULL, 0, 2000);
73
67 return ret; 74 return ret;
68} 75}
69 76
70static int m9206_rc_init(struct usb_device *udev) 77static int m9206_init(struct dvb_usb_device *d)
71{ 78{
72 int ret = 0; 79 int ret = 0;
73 80
74 /* Remote controller init. */ 81 /* Remote controller init. */
75 if ((ret = m9206_write(udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0) 82 if (d->props.rc_query) {
76 return ret; 83 if ((ret = m9206_write(d->udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0)
84 return ret;
77 85
78 if ((ret = m9206_write(udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0) 86 if ((ret = m9206_write(d->udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0)
79 return ret; 87 return ret;
88 }
80 89
81 return ret; 90 return ret;
82} 91}
@@ -87,16 +96,15 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
87 int i, ret = 0; 96 int i, ret = 0;
88 u8 rc_state[2]; 97 u8 rc_state[2];
89 98
90
91 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) 99 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
92 goto unlock; 100 goto unlock;
93 101
94 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) 102 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
95 goto unlock; 103 goto unlock;
96 104
97 for (i = 0; i < ARRAY_SIZE(megasky_rc_keys); i++) 105 for (i = 0; i < d->props.rc_key_map_size; i++)
98 if (megasky_rc_keys[i].data == rc_state[1]) { 106 if (d->props.rc_key_map[i].data == rc_state[1]) {
99 *event = megasky_rc_keys[i].event; 107 *event = d->props.rc_key_map[i].event;
100 108
101 switch(rc_state[0]) { 109 switch(rc_state[0]) {
102 case 0x80: 110 case 0x80:
@@ -137,53 +145,51 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
137 int num) 145 int num)
138{ 146{
139 struct dvb_usb_device *d = i2c_get_adapdata(adap); 147 struct dvb_usb_device *d = i2c_get_adapdata(adap);
140 struct m9206_state *m = d->priv; 148 int i, j;
141 int i;
142 int ret = 0; 149 int ret = 0;
143 150
151 if (!num)
152 return -EINVAL;
153
144 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 154 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
145 return -EAGAIN; 155 return -EAGAIN;
146 156
147 if (num > 2)
148 return -EINVAL;
149
150 for (i = 0; i < num; i++) { 157 for (i = 0; i < num; i++) {
151 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].addr, 0x80)) != 0) 158 if (msg[i].flags & (I2C_M_NO_RD_ACK|I2C_M_IGNORE_NAK|I2C_M_TEN) ||
152 goto unlock; 159 msg[i].len == 0) {
153 160 /* For a 0 byte message, I think sending the address to index 0x80|0x40
154 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[0], 0x0)) != 0) 161 * would be the correct thing to do. However, zero byte messages are
162 * only used for probing, and since we don't know how to get the slave's
163 * ack, we can't probe. */
164 ret = -ENOTSUPP;
155 goto unlock; 165 goto unlock;
156 166 }
157 if (i + 1 < num && msg[i + 1].flags & I2C_M_RD) { 167 /* Send START & address/RW bit */
158 int i2c_i; 168 if (!(msg[i].flags & I2C_M_NOSTART)) {
159 169 if ((ret = m9206_write(d->udev, M9206_I2C, (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0), 0x80)) != 0)
160 for (i2c_i = 0; i2c_i < M9206_I2C_MAX; i2c_i++)
161 if (msg[i].addr == m->i2c_r[i2c_i].addr)
162 break;
163
164 if (i2c_i >= M9206_I2C_MAX) {
165 deb_rc("No magic for i2c addr!\n");
166 ret = -EINVAL;
167 goto unlock; 170 goto unlock;
171 /* Should check for ack here, if we knew how. */
172 }
173 if (msg[i].flags & I2C_M_RD) {
174 for (j = 0; j < msg[i].len; j++) {
175 /* Last byte of transaction? Send STOP, otherwise send ACK. */
176 int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x01;
177 if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x20|stop, &msg[i].buf[j], 1)) != 0)
178 goto unlock;
168 } 179 }
169
170 if ((ret = m9206_write(d->udev, M9206_I2C, m->i2c_r[i2c_i].magic, 0x80)) != 0)
171 goto unlock;
172
173 if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x60, msg[i + 1].buf, msg[i + 1].len)) != 0)
174 goto unlock;
175
176 i++;
177 } else { 180 } else {
178 if (msg[i].len != 2) 181 for (j = 0; j < msg[i].len; j++) {
179 return -EINVAL; 182 /* Last byte of transaction? Then send STOP. */
180 183 int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x00;
181 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[1], 0x40)) != 0) 184 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0)
182 goto unlock; 185 goto unlock;
186 /* Should check for ack here too. */
187 }
183 } 188 }
184 } 189 }
185 ret = i; 190 ret = num;
186 unlock: 191
192unlock:
187 mutex_unlock(&d->i2c_mutex); 193 mutex_unlock(&d->i2c_mutex);
188 194
189 return ret; 195 return ret;
@@ -324,6 +330,7 @@ static int m9206_firmware_download(struct usb_device *udev,
324 i += size; 330 i += size;
325 } 331 }
326 if (i != fw->size) { 332 if (i != fw->size) {
333 deb_rc("bad firmware file!\n");
327 ret = -EINVAL; 334 ret = -EINVAL;
328 goto done; 335 goto done;
329 } 336 }
@@ -342,10 +349,10 @@ static int m9206_firmware_download(struct usb_device *udev,
342} 349}
343 350
344/* Callbacks for DVB USB */ 351/* Callbacks for DVB USB */
345static int megasky_identify_state(struct usb_device *udev, 352static int m920x_identify_state(struct usb_device *udev,
346 struct dvb_usb_device_properties *props, 353 struct dvb_usb_device_properties *props,
347 struct dvb_usb_device_description **desc, 354 struct dvb_usb_device_description **desc,
348 int *cold) 355 int *cold)
349{ 356{
350 struct usb_host_interface *alt; 357 struct usb_host_interface *alt;
351 358
@@ -381,20 +388,15 @@ static int megasky_mt352_demod_init(struct dvb_frontend *fe)
381} 388}
382 389
383static struct mt352_config megasky_mt352_config = { 390static struct mt352_config megasky_mt352_config = {
384 .demod_address = 0x1e, 391 .demod_address = 0x0f,
385 .no_tuner = 1, 392 .no_tuner = 1,
386 .demod_init = megasky_mt352_demod_init, 393 .demod_init = megasky_mt352_demod_init,
387}; 394};
388 395
389static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap) 396static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap)
390{ 397{
391 struct m9206_state *m = adap->dev->priv;
392
393 deb_rc("megasky_frontend_attach!\n"); 398 deb_rc("megasky_frontend_attach!\n");
394 399
395 m->i2c_r[M9206_I2C_DEMOD].addr = megasky_mt352_config.demod_address;
396 m->i2c_r[M9206_I2C_DEMOD].magic = 0x1f;
397
398 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL) 400 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL)
399 return -EIO; 401 return -EIO;
400 402
@@ -402,16 +404,11 @@ static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap)
402} 404}
403 405
404static struct qt1010_config megasky_qt1010_config = { 406static struct qt1010_config megasky_qt1010_config = {
405 .i2c_address = 0xc4 407 .i2c_address = 0x62
406}; 408};
407 409
408static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap) 410static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
409{ 411{
410 struct m9206_state *m = adap->dev->priv;
411
412 m->i2c_r[M9206_I2C_TUNER].addr = megasky_qt1010_config.i2c_address;
413 m->i2c_r[M9206_I2C_TUNER].magic = 0xc5;
414
415 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, 412 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap,
416 &megasky_qt1010_config) == NULL) 413 &megasky_qt1010_config) == NULL)
417 return -ENODEV; 414 return -ENODEV;
@@ -419,8 +416,40 @@ static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
419 return 0; 416 return 0;
420} 417}
421 418
419static struct tda1004x_config digivox_tda10046_config = {
420 .demod_address = 0x08,
421 .invert = 0,
422 .invert_oclk = 0,
423 .ts_mode = TDA10046_TS_SERIAL,
424 .xtal_freq = TDA10046_XTAL_16M,
425 .if_freq = TDA10046_FREQ_045,
426 .agc_config = TDA10046_AGC_TDA827X,
427 .gpio_config = TDA10046_GPTRI,
428 .request_firmware = NULL,
429};
430
431static int digivox_tda10046_frontend_attach(struct dvb_usb_adapter *adap)
432{
433 deb_rc("digivox_tda10046_frontend_attach!\n");
434
435 if ((adap->fe = dvb_attach(tda10046_attach, &digivox_tda10046_config,
436 &adap->dev->i2c_adap)) == NULL)
437 return -EIO;
438
439 return 0;
440}
441
442static int digivox_tda8275_tuner_attach(struct dvb_usb_adapter *adap)
443{
444 if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap,
445 NULL) == NULL)
446 return -ENODEV;
447 return 0;
448}
449
422/* DVB USB Driver stuff */ 450/* DVB USB Driver stuff */
423static struct dvb_usb_device_properties megasky_properties; 451static struct dvb_usb_device_properties megasky_properties;
452static struct dvb_usb_device_properties digivox_mini_ii_properties;
424 453
425static int m920x_probe(struct usb_interface *intf, 454static int m920x_probe(struct usb_interface *intf,
426 const struct usb_device_id *id) 455 const struct usb_device_id *id)
@@ -429,30 +458,36 @@ static int m920x_probe(struct usb_interface *intf,
429 struct usb_host_interface *alt; 458 struct usb_host_interface *alt;
430 int ret; 459 int ret;
431 460
432 if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) { 461 deb_rc("Probed!\n");
433 deb_rc("probed!\n");
434 462
435 alt = usb_altnum_to_altsetting(intf, 1); 463 if (((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) ||
436 if (alt == NULL) { 464 ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, THIS_MODULE, &d)) == 0))
437 deb_rc("not alt found!\n"); 465 goto found;
438 return -ENODEV;
439 }
440 466
441 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, 467 return ret;
442 alt->desc.bAlternateSetting);
443 if (ret < 0)
444 return ret;
445
446 deb_rc("Changed to alternate setting!\n");
447 468
448 if ((ret = m9206_rc_init(d->udev)) != 0) 469found:
449 return ret; 470 alt = usb_altnum_to_altsetting(intf, 1);
471 if (alt == NULL) {
472 deb_rc("No alt found!\n");
473 return -ENODEV;
450 } 474 }
475
476 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
477 alt->desc.bAlternateSetting);
478 if (ret < 0)
479 return ret;
480
481 if ((ret = m9206_init(d)) != 0)
482 return ret;
483
451 return ret; 484 return ret;
452} 485}
453 486
454static struct usb_device_id m920x_table [] = { 487static struct usb_device_id m920x_table [] = {
455 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, 488 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
489 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
490 USB_PID_MSI_DIGI_VOX_MINI_II) },
456 { } /* Terminating entry */ 491 { } /* Terminating entry */
457}; 492};
458MODULE_DEVICE_TABLE (usb, m920x_table); 493MODULE_DEVICE_TABLE (usb, m920x_table);
@@ -471,7 +506,7 @@ static struct dvb_usb_device_properties megasky_properties = {
471 506
472 .size_of_priv = sizeof(struct m9206_state), 507 .size_of_priv = sizeof(struct m9206_state),
473 508
474 .identify_state = megasky_identify_state, 509 .identify_state = m920x_identify_state,
475 .num_adapters = 1, 510 .num_adapters = 1,
476 .adapter = {{ 511 .adapter = {{
477 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 512 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
@@ -502,6 +537,50 @@ static struct dvb_usb_device_properties megasky_properties = {
502 { "MSI Mega Sky 580 DVB-T USB2.0", 537 { "MSI Mega Sky 580 DVB-T USB2.0",
503 { &m920x_table[0], NULL }, 538 { &m920x_table[0], NULL },
504 { NULL }, 539 { NULL },
540 }
541 }
542};
543
544static struct dvb_usb_device_properties digivox_mini_ii_properties = {
545 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
546
547 .usb_ctrl = DEVICE_SPECIFIC,
548 .firmware = "dvb-usb-digivox-02.fw",
549 .download_firmware = m9206_firmware_download,
550
551 .size_of_priv = sizeof(struct m9206_state),
552
553 .identify_state = m920x_identify_state,
554 .num_adapters = 1,
555 .adapter = {{
556 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
557 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
558
559 .pid_filter_count = 8,
560 .pid_filter = m9206_pid_filter,
561 .pid_filter_ctrl = m9206_pid_filter_ctrl,
562
563 .frontend_attach = digivox_tda10046_frontend_attach,
564 .tuner_attach = digivox_tda8275_tuner_attach,
565
566 .stream = {
567 .type = USB_BULK,
568 .count = 8,
569 .endpoint = 0x81,
570 .u = {
571 .bulk = {
572 .buffersize = 0x4000,
573 }
574 }
575 },
576 }},
577 .i2c_algo = &m9206_i2c_algo,
578
579 .num_device_descs = 1,
580 .devices = {
581 { "MSI DIGI VOX mini II DVB-T USB2.0",
582 { &m920x_table[1], NULL },
583 { NULL },
505 }, 584 },
506 } 585 }
507}; 586};
diff --git a/drivers/media/dvb/dvb-usb/m920x.h b/drivers/media/dvb/dvb-usb/m920x.h
index c354196ffe5d..7dd3db65c80e 100644
--- a/drivers/media/dvb/dvb-usb/m920x.h
+++ b/drivers/media/dvb/dvb-usb/m920x.h
@@ -19,17 +19,49 @@
19 19
20#define M9206_MAX_FILTERS 8 20#define M9206_MAX_FILTERS 8
21 21
22#define M9206_I2C_TUNER 0 22/*
23#define M9206_I2C_DEMOD 1 23sequences found in logs:
24#define M9206_I2C_MAX 2 24[index value]
250x80 write addr
26(0x00 out byte)*
270x40 out byte
28
290x80 write addr
30(0x00 out byte)*
310x80 read addr
32(0x21 in byte)*
330x60 in byte
34
35this sequence works:
360x80 read addr
37(0x21 in byte)*
380x60 in byte
39
40Guess at API of the I2C function:
41I2C operation is done one byte at a time with USB control messages. The
42index the messages is sent to is made up of a set of flags that control
43the I2C bus state:
440x80: Send START condition. After a START condition, one would normally
45 always send the 7-bit slave I2C address as the 7 MSB, followed by
46 the read/write bit as the LSB.
470x40: Send STOP condition. This should be set on the last byte of an
48 I2C transaction.
490x20: Read a byte from the slave. As opposed to writing a byte to the
50 slave. The slave will normally not produce any data unless you
51 set the R/W bit to 1 when sending the slave's address after the
52 START condition.
530x01: Respond with ACK, as opposed to a NACK. For a multi-byte read,
54 the master should send an ACK, that is pull SDA low during the 9th
55 clock cycle, after every byte but the last. This flags only makes
56 sense when bit 0x20 is set, indicating a read.
57
58What any other bits might mean, or how to get the slave's ACK/NACK
59response to a write, is unknown.
60*/
25 61
26struct m9206_state { 62struct m9206_state {
27 u16 filters[M9206_MAX_FILTERS]; 63 u16 filters[M9206_MAX_FILTERS];
28 int filtering_enabled; 64 int filtering_enabled;
29 int rep_count; 65 int rep_count;
30 struct {
31 unsigned char addr;
32 unsigned char magic;
33 }i2c_r[M9206_I2C_MAX];
34}; 66};
35#endif 67#endif
diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c
new file mode 100644
index 000000000000..518d7ad217df
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/opera1.c
@@ -0,0 +1,581 @@
1/* DVB USB framework compliant Linux driver for the Opera1 DVB-S Card
2*
3* Copyright (C) 2006 Mario Hlawitschka (dh1pa@amsat.org)
4* Copyright (C) 2006 Marco Gittler (g.marco@freenet.de)
5*
6* This program is free software; you can redistribute it and/or modify it
7* under the terms of the GNU General Public License as published by the Free
8* Software Foundation, version 2.
9*
10* see Documentation/dvb/README.dvb-usb for more information
11*/
12
13#include "opera1.h"
14#include "stv0299.h"
15
16#define OPERA_READ_MSG 0
17#define OPERA_WRITE_MSG 1
18#define OPERA_I2C_TUNER 0xd1
19
20#define READ_FX2_REG_REQ 0xba
21#define READ_MAC_ADDR 0x08
22#define OPERA_WRITE_FX2 0xbb
23#define OPERA_TUNER_REQ 0xb1
24#define REG_1F_SYMBOLRATE_BYTE0 0x1f
25#define REG_20_SYMBOLRATE_BYTE1 0x20
26#define REG_21_SYMBOLRATE_BYTE2 0x21
27
28#define ADDR_B600_VOLTAGE_13V (0x02)
29#define ADDR_B601_VOLTAGE_18V (0x03)
30#define ADDR_B1A6_STREAM_CTRL (0x04)
31#define ADDR_B880_READ_REMOTE (0x05)
32
33struct opera1_state {
34 u32 last_key_pressed;
35};
36struct opera_rc_keys {
37 u32 keycode;
38 u32 event;
39};
40
41int dvb_usb_opera1_debug;
42module_param_named(debug, dvb_usb_opera1_debug, int, 0644);
43MODULE_PARM_DESC(debug,
44 "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))."
45 DVB_USB_DEBUG_STATUS);
46
47static int opera1_xilinx_rw(struct usb_device *dev, u8 request, u16 value,
48 u8 * data, u16 len, int flags)
49{
50 int ret;
51 u8 r;
52 u8 u8buf[len];
53
54 unsigned int pipe = (flags == OPERA_READ_MSG) ?
55 usb_rcvctrlpipe(dev,0) : usb_sndctrlpipe(dev, 0);
56 u8 request_type = (flags == OPERA_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
57
58 if (flags == OPERA_WRITE_MSG)
59 memcpy(u8buf, data, len);
60 ret =
61 usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
62 value, 0x0, u8buf, len, 2000);
63
64 if (request == OPERA_TUNER_REQ) {
65 if (usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
66 OPERA_TUNER_REQ, USB_DIR_IN | USB_TYPE_VENDOR,
67 0x01, 0x0, &r, 1, 2000)<1 || r!=0x08)
68 return 0;
69 }
70 if (flags == OPERA_READ_MSG)
71 memcpy(data, u8buf, len);
72 return ret;
73}
74
75/* I2C */
76
77static int opera1_usb_i2c_msgxfer(struct dvb_usb_device *dev, u16 addr,
78 u8 * buf, u16 len)
79{
80 int ret = 0;
81 u8 request;
82 u16 value;
83
84 if (!dev) {
85 info("no usb_device");
86 return -EINVAL;
87 }
88 if (mutex_lock_interruptible(&dev->usb_mutex) < 0)
89 return -EAGAIN;
90
91 switch (addr>>1){
92 case ADDR_B600_VOLTAGE_13V:
93 request=0xb6;
94 value=0x00;
95 break;
96 case ADDR_B601_VOLTAGE_18V:
97 request=0xb6;
98 value=0x01;
99 break;
100 case ADDR_B1A6_STREAM_CTRL:
101 request=0xb1;
102 value=0xa6;
103 break;
104 case ADDR_B880_READ_REMOTE:
105 request=0xb8;
106 value=0x80;
107 break;
108 default:
109 request=0xb1;
110 value=addr;
111 }
112 ret = opera1_xilinx_rw(dev->udev, request,
113 value, buf, len,
114 addr&0x01?OPERA_READ_MSG:OPERA_WRITE_MSG);
115
116 mutex_unlock(&dev->usb_mutex);
117 return ret;
118}
119
120static int opera1_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
121 int num)
122{
123 struct dvb_usb_device *d = i2c_get_adapdata(adap);
124 int i = 0, tmp = 0;
125
126 if (!d)
127 return -ENODEV;
128 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
129 return -EAGAIN;
130
131 for (i = 0; i < num; i++) {
132 if ((tmp = opera1_usb_i2c_msgxfer(d,
133 (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0),
134 msg[i].buf,
135 msg[i].len
136 )!= msg[i].len)) {
137 break;
138 }
139 if (dvb_usb_opera1_debug & 0x10)
140 info("sending i2c mesage %d %d", tmp, msg[i].len);
141 }
142 mutex_unlock(&d->i2c_mutex);
143 return num;
144}
145
146static u32 opera1_i2c_func(struct i2c_adapter *adapter)
147{
148 return I2C_FUNC_I2C;
149}
150
151static struct i2c_algorithm opera1_i2c_algo = {
152 .master_xfer = opera1_i2c_xfer,
153 .functionality = opera1_i2c_func,
154};
155
156static int opera1_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
157{
158 static u8 command_13v[1]={0x00};
159 static u8 command_18v[1]={0x01};
160 struct i2c_msg msg[] = {
161 {.addr = ADDR_B600_VOLTAGE_13V,.flags = 0,.buf = command_13v,.len = 1},
162 };
163 struct dvb_usb_adapter *udev_adap =
164 (struct dvb_usb_adapter *)(fe->dvb->priv);
165 if (voltage == SEC_VOLTAGE_18) {
166 msg[0].addr = ADDR_B601_VOLTAGE_18V;
167 msg[0].buf = command_18v;
168 }
169 i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1);
170 return 0;
171}
172
173static int opera1_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate,
174 u32 ratio)
175{
176 stv0299_writereg(fe, 0x13, 0x98);
177 stv0299_writereg(fe, 0x14, 0x95);
178 stv0299_writereg(fe, REG_1F_SYMBOLRATE_BYTE0, (ratio >> 16) & 0xff);
179 stv0299_writereg(fe, REG_20_SYMBOLRATE_BYTE1, (ratio >> 8) & 0xff);
180 stv0299_writereg(fe, REG_21_SYMBOLRATE_BYTE2, (ratio) & 0xf0);
181 return 0;
182
183}
184static u8 opera1_inittab[] = {
185 0x00, 0xa1,
186 0x01, 0x15,
187 0x02, 0x00,
188 0x03, 0x00,
189 0x04, 0x7d,
190 0x05, 0x05,
191 0x06, 0x02,
192 0x07, 0x00,
193 0x0b, 0x00,
194 0x0c, 0x01,
195 0x0d, 0x81,
196 0x0e, 0x44,
197 0x0f, 0x19,
198 0x10, 0x3f,
199 0x11, 0x84,
200 0x12, 0xda,
201 0x13, 0x98,
202 0x14, 0x95,
203 0x15, 0xc9,
204 0x16, 0xeb,
205 0x17, 0x00,
206 0x18, 0x19,
207 0x19, 0x8b,
208 0x1a, 0x00,
209 0x1b, 0x82,
210 0x1c, 0x7f,
211 0x1d, 0x00,
212 0x1e, 0x00,
213 REG_1F_SYMBOLRATE_BYTE0, 0x06,
214 REG_20_SYMBOLRATE_BYTE1, 0x50,
215 REG_21_SYMBOLRATE_BYTE2, 0x10,
216 0x22, 0x00,
217 0x23, 0x00,
218 0x24, 0x37,
219 0x25, 0xbc,
220 0x26, 0x00,
221 0x27, 0x00,
222 0x28, 0x00,
223 0x29, 0x1e,
224 0x2a, 0x14,
225 0x2b, 0x1f,
226 0x2c, 0x09,
227 0x2d, 0x0a,
228 0x2e, 0x00,
229 0x2f, 0x00,
230 0x30, 0x00,
231 0x31, 0x1f,
232 0x32, 0x19,
233 0x33, 0xfc,
234 0x34, 0x13,
235 0xff, 0xff,
236};
237
238static struct stv0299_config opera1_stv0299_config = {
239 .demod_address = 0xd0>>1,
240 .min_delay_ms = 100,
241 .mclk = 88000000UL,
242 .invert = 1,
243 .skip_reinit = 0,
244 .lock_output = STV0229_LOCKOUTPUT_0,
245 .volt13_op0_op1 = STV0299_VOLT13_OP0,
246 .inittab = opera1_inittab,
247 .set_symbol_rate = opera1_stv0299_set_symbol_rate,
248};
249
250static int opera1_frontend_attach(struct dvb_usb_adapter *d)
251{
252 if ((d->fe =
253 dvb_attach(stv0299_attach, &opera1_stv0299_config,
254 &d->dev->i2c_adap)) != NULL) {
255 d->fe->ops.set_voltage = opera1_set_voltage;
256 return 0;
257 }
258 info("not attached stv0299");
259 return -EIO;
260}
261
262static int opera1_tuner_attach(struct dvb_usb_adapter *adap)
263{
264 dvb_attach(
265 dvb_pll_attach, adap->fe, 0xc0>>1,
266 &adap->dev->i2c_adap, &dvb_pll_opera1
267 );
268 return 0;
269}
270
271static int opera1_power_ctrl(struct dvb_usb_device *d, int onoff)
272{
273 u8 val = onoff ? 0x01 : 0x00;
274
275 if (dvb_usb_opera1_debug)
276 info("power %s", onoff ? "on" : "off");
277 return opera1_xilinx_rw(d->udev, 0xb7, val,
278 &val, 1, OPERA_WRITE_MSG);
279}
280
281static int opera1_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
282{
283 static u8 buf_start[2] = { 0xff, 0x03 };
284 static u8 buf_stop[2] = { 0xff, 0x00 };
285 struct i2c_msg start_tuner[] = {
286 {.addr = ADDR_B1A6_STREAM_CTRL,.buf = onoff ? buf_start : buf_stop,.len = 2},
287 };
288 if (dvb_usb_opera1_debug)
289 info("streaming %s", onoff ? "on" : "off");
290 i2c_transfer(&adap->dev->i2c_adap, start_tuner, 1);
291 return 0;
292}
293
294static int opera1_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
295 int onoff)
296{
297 u8 b_pid[3];
298 struct i2c_msg msg[] = {
299 {.addr = ADDR_B1A6_STREAM_CTRL,.buf = b_pid,.len = 3},
300 };
301 if (dvb_usb_opera1_debug)
302 info("pidfilter index: %d pid: %d %s", index, pid,
303 onoff ? "on" : "off");
304 b_pid[0] = (2 * index) + 4;
305 b_pid[1] = onoff ? (pid & 0xff) : (0x00);
306 b_pid[2] = onoff ? ((pid >> 8) & 0xff) : (0x00);
307 i2c_transfer(&adap->dev->i2c_adap, msg, 1);
308 return 0;
309}
310
311static int opera1_pid_filter_control(struct dvb_usb_adapter *adap, int onoff)
312{
313 int u = 0x04;
314 u8 b_pid[3];
315 struct i2c_msg msg[] = {
316 {.addr = ADDR_B1A6_STREAM_CTRL,.buf = b_pid,.len = 3},
317 };
318 if (dvb_usb_opera1_debug)
319 info("%s hw-pidfilter", onoff ? "enable" : "disable");
320 for (; u < 0x7e; u += 2) {
321 b_pid[0] = u;
322 b_pid[1] = 0;
323 b_pid[2] = 0x80;
324 i2c_transfer(&adap->dev->i2c_adap, msg, 1);
325 }
326 return 0;
327}
328
329static struct dvb_usb_rc_key opera1_rc_keys[] = {
330 {0x5f, 0xa0, KEY_1},
331 {0x51, 0xaf, KEY_2},
332 {0x5d, 0xa2, KEY_3},
333 {0x41, 0xbe, KEY_4},
334 {0x0b, 0xf5, KEY_5},
335 {0x43, 0xbd, KEY_6},
336 {0x47, 0xb8, KEY_7},
337 {0x49, 0xb6, KEY_8},
338 {0x05, 0xfa, KEY_9},
339 {0x45, 0xba, KEY_0},
340 {0x09, 0xf6, KEY_UP}, /*chanup */
341 {0x1b, 0xe5, KEY_DOWN}, /*chandown */
342 {0x5d, 0xa3, KEY_LEFT}, /*voldown */
343 {0x5f, 0xa1, KEY_RIGHT}, /*volup */
344 {0x07, 0xf8, KEY_SPACE}, /*tab */
345 {0x1f, 0xe1, KEY_ENTER}, /*play ok */
346 {0x1b, 0xe4, KEY_Z}, /*zoom */
347 {0x59, 0xa6, KEY_M}, /*mute */
348 {0x5b, 0xa5, KEY_F}, /*tv/f */
349 {0x19, 0xe7, KEY_R}, /*rec */
350 {0x01, 0xfe, KEY_S}, /*Stop */
351 {0x03, 0xfd, KEY_P}, /*pause */
352 {0x03, 0xfc, KEY_W}, /*<- -> */
353 {0x07, 0xf9, KEY_C}, /*capture */
354 {0x47, 0xb9, KEY_Q}, /*exit */
355 {0x43, 0xbc, KEY_O}, /*power */
356
357};
358
359static int opera1_rc_query(struct dvb_usb_device *dev, u32 * event, int *state)
360{
361 struct opera1_state *opst = dev->priv;
362 u8 rcbuffer[32];
363 const u16 startmarker1 = 0x10ed;
364 const u16 startmarker2 = 0x11ec;
365 struct i2c_msg read_remote[] = {
366 {.addr = ADDR_B880_READ_REMOTE,.buf = rcbuffer,.flags = I2C_M_RD,.len = 32},
367 };
368 int i = 0;
369 u32 send_key = 0;
370
371 if (i2c_transfer(&dev->i2c_adap, read_remote, 1) == 1) {
372 for (i = 0; i < 32; i++) {
373 if (rcbuffer[i])
374 send_key |= 1;
375 if (i < 31)
376 send_key = send_key << 1;
377 }
378 if (send_key & 0x8000)
379 send_key = (send_key << 1) | (send_key >> 15 & 0x01);
380
381 if (send_key == 0xffff && opst->last_key_pressed != 0) {
382 *state = REMOTE_KEY_REPEAT;
383 *event = opst->last_key_pressed;
384 return 0;
385 }
386 for (; send_key != 0;) {
387 if (send_key >> 16 == startmarker2) {
388 break;
389 } else if (send_key >> 16 == startmarker1) {
390 send_key =
391 (send_key & 0xfffeffff) | (startmarker1 << 16);
392 break;
393 } else
394 send_key >>= 1;
395 }
396
397 if (send_key == 0)
398 return 0;
399
400 send_key = (send_key & 0xffff) | 0x0100;
401
402 for (i = 0; i < ARRAY_SIZE(opera1_rc_keys); i++) {
403 if ((opera1_rc_keys[i].custom * 256 +
404 opera1_rc_keys[i].data) == (send_key & 0xffff)) {
405 *state = REMOTE_KEY_PRESSED;
406 *event = opera1_rc_keys[i].event;
407 opst->last_key_pressed =
408 opera1_rc_keys[i].event;
409 break;
410 }
411 opst->last_key_pressed = 0;
412 }
413 } else
414 *state = REMOTE_NO_KEY_PRESSED;
415 return 0;
416}
417
418static struct usb_device_id opera1_table[] = {
419 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_OPERA1_COLD)},
420 {USB_DEVICE(USB_VID_OPERA1, USB_PID_OPERA1_WARM)},
421 {}
422};
423
424MODULE_DEVICE_TABLE(usb, opera1_table);
425
426static int opera1_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
427{
428 u8 command[] = { READ_MAC_ADDR };
429 opera1_xilinx_rw(d->udev, 0xb1, 0xa0, command, 1, OPERA_WRITE_MSG);
430 opera1_xilinx_rw(d->udev, 0xb1, 0xa1, mac, 6, OPERA_READ_MSG);
431 return 0;
432}
433static int opera1_xilinx_load_firmware(struct usb_device *dev,
434 const char *filename)
435{
436 const struct firmware *fw = NULL;
437 u8 *b, *p;
438 int ret = 0, i;
439 u8 testval;
440 info("start downloading fpga firmware");
441
442 if ((ret = request_firmware(&fw, filename, &dev->dev)) != 0) {
443 err("did not find the firmware file. (%s) "
444 "Please see linux/Documentation/dvb/ for more details on firmware-problems.",
445 filename);
446 return ret;
447 } else {
448 p = kmalloc(fw->size, GFP_KERNEL);
449 opera1_xilinx_rw(dev, 0xbc, 0x00, &testval, 1, OPERA_READ_MSG);
450 if (p != NULL && testval != 0x67) {
451
452 u8 reset = 0, fpga_command = 0;
453 memcpy(p, fw->data, fw->size);
454 /* clear fpga ? */
455 opera1_xilinx_rw(dev, 0xbc, 0xaa, &fpga_command, 1,
456 OPERA_WRITE_MSG);
457 for (i = 0; p[i] != 0 && i < fw->size;) {
458 b = (u8 *) p + i;
459 if (opera1_xilinx_rw
460 (dev, OPERA_WRITE_FX2, 0x0, b + 1, b[0],
461 OPERA_WRITE_MSG) != b[0]
462 ) {
463 err("error while transferring firmware");
464 ret = -EINVAL;
465 break;
466 }
467 i = i + 1 + b[0];
468 }
469 /* restart the CPU */
470 if (ret || opera1_xilinx_rw
471 (dev, 0xa0, 0xe600, &reset, 1,
472 OPERA_WRITE_MSG) != 1) {
473 err("could not restart the USB controller CPU.");
474 ret = -EINVAL;
475 }
476 kfree(p);
477 }
478 }
479 if (fw) {
480 release_firmware(fw);
481 }
482 return ret;
483}
484
485static struct dvb_usb_device_properties opera1_properties = {
486 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
487 .usb_ctrl = CYPRESS_FX2,
488 .firmware = "dvb-usb-opera-01.fw",
489 .size_of_priv = sizeof(struct opera1_state),
490
491 .power_ctrl = opera1_power_ctrl,
492 .i2c_algo = &opera1_i2c_algo,
493
494 .rc_key_map = opera1_rc_keys,
495 .rc_key_map_size = ARRAY_SIZE(opera1_rc_keys),
496 .rc_interval = 200,
497 .rc_query = opera1_rc_query,
498 .read_mac_address = opera1_read_mac_address,
499 .generic_bulk_ctrl_endpoint = 0x00,
500 /* parameter for the MPEG2-data transfer */
501 .num_adapters = 1,
502 .adapter = {
503 {
504 .frontend_attach = opera1_frontend_attach,
505 .streaming_ctrl = opera1_streaming_ctrl,
506 .tuner_attach = opera1_tuner_attach,
507 .caps =
508 DVB_USB_ADAP_HAS_PID_FILTER |
509 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
510 .pid_filter = opera1_pid_filter,
511 .pid_filter_ctrl = opera1_pid_filter_control,
512 .pid_filter_count = 252,
513 .stream = {
514 .type = USB_BULK,
515 .count = 10,
516 .endpoint = 0x82,
517 .u = {
518 .bulk = {
519 .buffersize = 4096,
520 }
521 }
522 },
523 }
524 },
525 .num_device_descs = 1,
526 .devices = {
527 {"Opera1 DVB-S USB2.0",
528 {&opera1_table[0], NULL},
529 {&opera1_table[1], NULL},
530 },
531 }
532};
533
534static int opera1_probe(struct usb_interface *intf,
535 const struct usb_device_id *id)
536{
537 struct dvb_usb_device *d;
538 struct usb_device *udev = interface_to_usbdev(intf);
539
540 if (udev->descriptor.idProduct == USB_PID_OPERA1_WARM &&
541 udev->descriptor.idVendor == USB_VID_OPERA1 &&
542 (d == NULL
543 || opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga.fw") != 0)
544 ) {
545 return -EINVAL;
546 }
547
548 if (dvb_usb_device_init(intf, &opera1_properties, THIS_MODULE, &d) != 0)
549 return -EINVAL;
550 return 0;
551}
552
553static struct usb_driver opera1_driver = {
554 .name = "opera1",
555 .probe = opera1_probe,
556 .disconnect = dvb_usb_device_exit,
557 .id_table = opera1_table,
558};
559
560static int __init opera1_module_init(void)
561{
562 int result = 0;
563 if ((result = usb_register(&opera1_driver))) {
564 err("usb_register failed. Error number %d", result);
565 }
566 return result;
567}
568
569static void __exit opera1_module_exit(void)
570{
571 usb_deregister(&opera1_driver);
572}
573
574module_init(opera1_module_init);
575module_exit(opera1_module_exit);
576
577MODULE_AUTHOR("Mario Hlawitschka (c) dh1pa@amsat.org");
578MODULE_AUTHOR("Marco Gittler (c) g.marco@freenet.de");
579MODULE_DESCRIPTION("Driver for Opera1 DVB-S device");
580MODULE_VERSION("0.1");
581MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/opera1.h b/drivers/media/dvb/dvb-usb/opera1.h
new file mode 100644
index 000000000000..53174427902d
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/opera1.h
@@ -0,0 +1,9 @@
1#ifndef _OPERA1_H_
2#define _OPERA1_H_
3
4#define DVB_USB_LOG_PREFIX "opera"
5#include "dvb-usb.h"
6
7extern int dvb_usb_opera1_debug;
8#define deb_xfer(args...) dprintk(dvb_usb_opera1_debug,0x02,args)
9#endif
diff --git a/drivers/media/dvb/dvb-usb/ttusb2.c b/drivers/media/dvb/dvb-usb/ttusb2.c
index 95d29976ed78..88dc4367a2e3 100644
--- a/drivers/media/dvb/dvb-usb/ttusb2.c
+++ b/drivers/media/dvb/dvb-usb/ttusb2.c
@@ -184,6 +184,7 @@ static int ttusb2_probe(struct usb_interface *intf,
184 184
185static struct usb_device_id ttusb2_table [] = { 185static struct usb_device_id ttusb2_table [] = {
186 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_400E) }, 186 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_400E) },
187 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_450E) },
187 {} /* Terminating entry */ 188 {} /* Terminating entry */
188}; 189};
189MODULE_DEVICE_TABLE (usb, ttusb2_table); 190MODULE_DEVICE_TABLE (usb, ttusb2_table);
@@ -227,12 +228,16 @@ static struct dvb_usb_device_properties ttusb2_properties = {
227 228
228 .generic_bulk_ctrl_endpoint = 0x01, 229 .generic_bulk_ctrl_endpoint = 0x01,
229 230
230 .num_device_descs = 1, 231 .num_device_descs = 2,
231 .devices = { 232 .devices = {
232 { "Pinnacle 400e DVB-S USB2.0", 233 { "Pinnacle 400e DVB-S USB2.0",
233 { &ttusb2_table[0], NULL }, 234 { &ttusb2_table[0], NULL },
234 { NULL }, 235 { NULL },
235 }, 236 },
237 { "Pinnacle 450e DVB-S USB2.0",
238 { &ttusb2_table[1], NULL },
239 { NULL },
240 },
236 } 241 }
237}; 242};
238 243