blob: 49e57f85f99b7cf01c1afd672eff67465b33e0af [file] [log] [blame]
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -03001/* DVB USB compliant linux driver for MSI Mega Sky 580 DVB-T USB2.0 receiver
2 *
3 * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org)
4 *
5 * This program is free software; you can redistribute it and/or modify it
Michael Krufkyd3911ea2007-03-22 19:03:37 -03006 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation, version 2.
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -03008 *
9 * see Documentation/dvb/README.dvb-usb for more information
10 */
Michael Krufkybaa2ed02006-09-23 20:01:29 -030011
Michael Krufky2aef7d02006-09-23 20:00:42 -030012#include "m920x.h"
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030013
14#include "mt352.h"
15#include "mt352_priv.h"
Michael Krufky017cf012006-09-23 20:40:20 -030016#include "qt1010.h"
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -030017#include "tda1004x.h"
18#include "tda827x.h"
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030019
20/* debug */
Michael Krufky26f48ea2006-09-28 01:46:49 -030021static int dvb_usb_m920x_debug;
Michael Krufkybaa2ed02006-09-23 20:01:29 -030022module_param_named(debug,dvb_usb_m920x_debug, int, 0644);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030023MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
24
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030025static inline int m920x_read(struct usb_device *udev, u8 request, u16 value,
Michael Krufkyfa948052007-01-21 15:57:48 -030026 u16 index, void *data, int size)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030027{
28 int ret;
29
30 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
31 request, USB_TYPE_VENDOR | USB_DIR_IN,
32 value, index, data, size, 2000);
Pierre Willenbrock59069e52007-03-15 13:24:29 -030033 if (ret < 0) {
34 printk(KERN_INFO "m920x_read = error: %d\n", ret);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030035 return ret;
Pierre Willenbrock59069e52007-03-15 13:24:29 -030036 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030037
Pierre Willenbrock59069e52007-03-15 13:24:29 -030038 if (ret != size) {
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -030039 deb("m920x_read = no data\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030040 return -EIO;
Pierre Willenbrock59069e52007-03-15 13:24:29 -030041 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030042
43 return 0;
44}
45
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030046static inline int m920x_write(struct usb_device *udev, u8 request,
Michael Krufkyfa948052007-01-21 15:57:48 -030047 u16 value, u16 index)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030048{
49 int ret;
50
51 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
52 request, USB_TYPE_VENDOR | USB_DIR_OUT,
53 value, index, NULL, 0, 2000);
Pierre Willenbrock59069e52007-03-15 13:24:29 -030054
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030055 return ret;
56}
57
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030058static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030059{
60 int ret = 0;
61
62 /* Remote controller init. */
Aapo Tahkola480ac762007-03-05 18:54:27 -030063 if (d->props.rc_query) {
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -030064 deb("Initialising remote control\n");
Nick Andrewaa50ec22007-03-22 17:09:35 -030065 while (rc_seq->address) {
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030066 if ((ret = m920x_write(d->udev, M9206_CORE,
Michael Krufkyd3911ea2007-03-22 19:03:37 -030067 rc_seq->data,
68 rc_seq->address)) != 0) {
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -030069 deb("Initialising remote control failed\n");
Nick Andrewaa50ec22007-03-22 17:09:35 -030070 return ret;
71 }
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030072
Nick Andrewaa50ec22007-03-22 17:09:35 -030073 rc_seq++;
74 }
75
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -030076 deb("Initialising remote control success\n");
Aapo Tahkola480ac762007-03-05 18:54:27 -030077 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030078
79 return ret;
80}
81
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030082static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030083{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030084 struct m920x_state *m = d->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030085 int i, ret = 0;
86 u8 rc_state[2];
87
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030088 if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE,
Michael Krufkyd3911ea2007-03-22 19:03:37 -030089 rc_state, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030090 goto unlock;
91
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030092 if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY,
Michael Krufkyd3911ea2007-03-22 19:03:37 -030093 rc_state + 1, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030094 goto unlock;
95
Aapo Tahkola480ac762007-03-05 18:54:27 -030096 for (i = 0; i < d->props.rc_key_map_size; i++)
97 if (d->props.rc_key_map[i].data == rc_state[1]) {
98 *event = d->props.rc_key_map[i].event;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030099
100 switch(rc_state[0]) {
101 case 0x80:
102 *state = REMOTE_NO_KEY_PRESSED;
103 goto unlock;
104
Nick Andrewaa50ec22007-03-22 17:09:35 -0300105 case 0x88: /* framing error or "invalid code" */
106 case 0x99:
107 case 0xc0:
108 case 0xd8:
109 *state = REMOTE_NO_KEY_PRESSED;
110 m->rep_count = 0;
111 goto unlock;
112
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300113 case 0x93:
114 case 0x92:
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300115 m->rep_count = 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300116 *state = REMOTE_KEY_PRESSED;
117 goto unlock;
118
119 case 0x91:
Nick Andrewaa50ec22007-03-22 17:09:35 -0300120 /* prevent immediate auto-repeat */
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300121 if (++m->rep_count > 2)
122 *state = REMOTE_KEY_REPEAT;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300123 else
124 *state = REMOTE_NO_KEY_PRESSED;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300125 goto unlock;
126
127 default:
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300128 deb("Unexpected rc state %02x\n", rc_state[0]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300129 *state = REMOTE_NO_KEY_PRESSED;
130 goto unlock;
131 }
132 }
133
134 if (rc_state[1] != 0)
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300135 deb("Unknown rc key %02x\n", rc_state[1]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300136
137 *state = REMOTE_NO_KEY_PRESSED;
138
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300139 unlock:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300140
141 return ret;
142}
143
144/* I2C */
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300145static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
Michael Krufkyfa948052007-01-21 15:57:48 -0300146 int num)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300147{
148 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Aapo Tahkola26247012007-03-05 18:23:19 -0300149 int i, j;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300150 int ret = 0;
151
Trent Piephod40860f2007-03-05 23:55:00 -0300152 if (!num)
153 return -EINVAL;
154
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300155 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
156 return -EAGAIN;
157
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300158 for (i = 0; i < num; i++) {
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300159 if (msg[i].flags & (I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK |
160 I2C_M_TEN) || msg[i].len == 0) {
161 /* For a 0 byte message, I think sending the address
162 * to index 0x80|0x40 would be the correct thing to
163 * do. However, zero byte messages are only used for
164 * probing, and since we don't know how to get the
165 * slave's ack, we can't probe. */
Trent Piephod40860f2007-03-05 23:55:00 -0300166 ret = -ENOTSUPP;
167 goto unlock;
168 }
169 /* Send START & address/RW bit */
170 if (!(msg[i].flags & I2C_M_NOSTART)) {
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300171 if ((ret = m920x_write(d->udev, M9206_I2C,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300172 (msg[i].addr << 1) |
173 (msg[i].flags & I2C_M_RD ? 0x01 : 0),
174 0x80)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300175 goto unlock;
176 /* Should check for ack here, if we knew how. */
177 }
Aapo Tahkola26247012007-03-05 18:23:19 -0300178 if (msg[i].flags & I2C_M_RD) {
Trent Piephod40860f2007-03-05 23:55:00 -0300179 for (j = 0; j < msg[i].len; j++) {
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300180 /* Last byte of transaction?
181 * Send STOP, otherwise send ACK. */
182 int stop = (i+1 == num && j+1 == msg[i].len)
183 ? 0x40 : 0x01;
184
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300185 if ((ret = m920x_read(d->udev, M9206_I2C, 0x0,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300186 0x20|stop,
187 &msg[i].buf[j], 1)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300188 goto unlock;
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300189 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300190 } else {
Trent Piephod40860f2007-03-05 23:55:00 -0300191 for (j = 0; j < msg[i].len; j++) {
192 /* Last byte of transaction? Then send STOP. */
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300193 int stop = (i+1 == num && j+1 == msg[i].len)
194 ? 0x40 : 0x00;
195
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300196 if ((ret = m920x_write(d->udev, M9206_I2C,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300197 msg[i].buf[j],
198 stop)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300199 goto unlock;
200 /* Should check for ack here too. */
Aapo Tahkola26247012007-03-05 18:23:19 -0300201 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300202 }
203 }
Aapo Tahkola26247012007-03-05 18:23:19 -0300204 ret = num;
Trent Piephod40860f2007-03-05 23:55:00 -0300205
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300206 unlock:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300207 mutex_unlock(&d->i2c_mutex);
208
209 return ret;
210}
211
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300212static u32 m920x_i2c_func(struct i2c_adapter *adapter)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300213{
214 return I2C_FUNC_I2C;
215}
216
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300217static struct i2c_algorithm m920x_i2c_algo = {
218 .master_xfer = m920x_i2c_xfer,
219 .functionality = m920x_i2c_func,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300220};
221
Michael Krufky5afb7072007-03-26 16:35:29 -0300222/* pid filter */
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300223static int m920x_set_filter(struct dvb_usb_adapter *adap,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300224 int type, int idx, int pid)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300225{
226 int ret = 0;
227
228 if (pid >= 0x8000)
229 return -EINVAL;
230
231 pid |= 0x8000;
232
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300233 if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, pid,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300234 (type << 8) | (idx * 4) )) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300235 return ret;
236
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300237 if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, 0,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300238 (type << 8) | (idx * 4) )) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300239 return ret;
240
241 return ret;
242}
243
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300244static int m920x_update_filters(struct dvb_usb_adapter *adap)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300245{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300246 struct m920x_state *m = adap->dev->priv;
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300247 int enabled = m->filtering_enabled;
248 int i, ret = 0, filter = 0;
249
250 for (i = 0; i < M9206_MAX_FILTERS; i++)
251 if (m->filters[i] == 8192)
252 enabled = 0;
253
254 /* Disable all filters */
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300255 if ((ret = m920x_set_filter(adap, 0x81, 1, enabled)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300256 return ret;
257
258 for (i = 0; i < M9206_MAX_FILTERS; i++)
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300259 if ((ret = m920x_set_filter(adap, 0x81, i + 2, 0)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300260 return ret;
261
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300262 if ((ret = m920x_set_filter(adap, 0x82, 0, 0x0)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300263 return ret;
264
265 /* Set */
266 if (enabled) {
267 for (i = 0; i < M9206_MAX_FILTERS; i++) {
268 if (m->filters[i] == 0)
269 continue;
270
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300271 if ((ret = m920x_set_filter(adap, 0x81, filter + 2,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300272 m->filters[i])) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300273 return ret;
274
275 filter++;
276 }
277 }
278
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300279 if ((ret = m920x_set_filter(adap, 0x82, 0, 0x02f5)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300280 return ret;
281
282 return ret;
283}
284
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300285static int m920x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300286{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300287 struct m920x_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300288
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300289 m->filtering_enabled = onoff ? 1 : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300290
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300291 return m920x_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300292}
293
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300294static int m920x_pid_filter(struct dvb_usb_adapter *adap,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300295 int index, u16 pid, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300296{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300297 struct m920x_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300298
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300299 m->filters[index] = onoff ? pid : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300300
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300301 return m920x_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300302}
303
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300304static int m920x_firmware_download(struct usb_device *udev,
Michael Krufkyfa948052007-01-21 15:57:48 -0300305 const struct firmware *fw)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300306{
307 u16 value, index, size;
308 u8 read[4], *buff;
309 int i, pass, ret = 0;
310
311 buff = kmalloc(65536, GFP_KERNEL);
312
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300313 if ((ret = m920x_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300314 goto done;
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300315 deb("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300316
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300317 if ((ret = m920x_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300318 goto done;
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300319 deb("%x\n", read[0]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300320
321 for (pass = 0; pass < 2; pass++) {
322 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
323 value = le16_to_cpu(*(u16 *)(fw->data + i));
324 i += sizeof(u16);
325
326 index = le16_to_cpu(*(u16 *)(fw->data + i));
327 i += sizeof(u16);
328
329 size = le16_to_cpu(*(u16 *)(fw->data + i));
330 i += sizeof(u16);
331
332 if (pass == 1) {
333 /* Will stall if using fw->data ... */
334 memcpy(buff, fw->data + i, size);
335
336 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300337 M9206_FW,
338 USB_TYPE_VENDOR | USB_DIR_OUT,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300339 value, index, buff, size, 20);
340 if (ret != size) {
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300341 deb("error while uploading fw!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300342 ret = -EIO;
343 goto done;
344 }
345 msleep(3);
346 }
347 i += size;
348 }
349 if (i != fw->size) {
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300350 deb("bad firmware file!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300351 ret = -EINVAL;
352 goto done;
353 }
354 }
355
356 msleep(36);
357
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300358 /* m920x will disconnect itself from the bus after this. */
359 (void) m920x_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300360 deb("firmware uploaded!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300361
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300362 done:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300363 kfree(buff);
364
365 return ret;
366}
367
Michael Krufkye16c1f52007-01-23 15:00:42 -0300368/* Callbacks for DVB USB */
Aapo Tahkola7d1d4e62007-03-15 13:01:46 -0300369static int m920x_identify_state(struct usb_device *udev,
370 struct dvb_usb_device_properties *props,
371 struct dvb_usb_device_description **desc,
372 int *cold)
Michael Krufkye16c1f52007-01-23 15:00:42 -0300373{
374 struct usb_host_interface *alt;
375
376 alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
377 *cold = (alt == NULL) ? 1 : 0;
378
379 return 0;
380}
381
Michael Krufky5afb7072007-03-26 16:35:29 -0300382/* demod configurations */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300383static int m920x_mt352_demod_init(struct dvb_frontend *fe)
Michael Krufkye16c1f52007-01-23 15:00:42 -0300384{
385 u8 config[] = { CONFIG, 0x3d };
386 u8 clock[] = { CLOCK_CTL, 0x30 };
387 u8 reset[] = { RESET, 0x80 };
388 u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
389 u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
390 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
391 u8 unk1[] = { 0x93, 0x1a };
392 u8 unk2[] = { 0xb5, 0x7a };
393
394 mt352_write(fe, config, ARRAY_SIZE(config));
395 mt352_write(fe, clock, ARRAY_SIZE(clock));
396 mt352_write(fe, reset, ARRAY_SIZE(reset));
397 mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
398 mt352_write(fe, agc, ARRAY_SIZE(agc));
399 mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
400 mt352_write(fe, unk1, ARRAY_SIZE(unk1));
401 mt352_write(fe, unk2, ARRAY_SIZE(unk2));
402
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300403 deb("Demod init!\n");
Michael Krufkye16c1f52007-01-23 15:00:42 -0300404
405 return 0;
406}
407
Michael Krufkye7b419b2007-03-26 16:39:20 -0300408static struct mt352_config m920x_mt352_config = {
Aapo Tahkola26247012007-03-05 18:23:19 -0300409 .demod_address = 0x0f,
Michael Krufkye16c1f52007-01-23 15:00:42 -0300410 .no_tuner = 1,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300411 .demod_init = m920x_mt352_demod_init,
Michael Krufkye16c1f52007-01-23 15:00:42 -0300412};
413
Michael Krufkye7b419b2007-03-26 16:39:20 -0300414static struct tda1004x_config m920x_tda10046_08_config = {
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300415 .demod_address = 0x08,
416 .invert = 0,
417 .invert_oclk = 0,
418 .ts_mode = TDA10046_TS_SERIAL,
419 .xtal_freq = TDA10046_XTAL_16M,
420 .if_freq = TDA10046_FREQ_045,
421 .agc_config = TDA10046_AGC_TDA827X,
422 .gpio_config = TDA10046_GPTRI,
423 .request_firmware = NULL,
424};
425
Michael Krufkye7b419b2007-03-26 16:39:20 -0300426static struct tda1004x_config m920x_tda10046_0b_config = {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300427 .demod_address = 0x0b,
428 .invert = 0,
429 .invert_oclk = 0,
430 .ts_mode = TDA10046_TS_SERIAL,
431 .xtal_freq = TDA10046_XTAL_16M,
432 .if_freq = TDA10046_FREQ_045,
433 .agc_config = TDA10046_AGC_TDA827X,
434 .gpio_config = TDA10046_GPTRI,
435 .request_firmware = NULL, /* uses firmware EEPROM */
436};
437
Michael Krufky5afb7072007-03-26 16:35:29 -0300438/* tuner configurations */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300439static struct qt1010_config m920x_qt1010_config = {
Michael Krufky5afb7072007-03-26 16:35:29 -0300440 .i2c_address = 0x62
441};
442
443/* Callbacks for DVB USB */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300444static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300445{
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300446 deb("%s\n",__FUNCTION__);
Michael Krufky5afb7072007-03-26 16:35:29 -0300447
Michael Krufkye7b419b2007-03-26 16:39:20 -0300448 if ((adap->fe = dvb_attach(mt352_attach, &m920x_mt352_config,
Michael Krufky5afb7072007-03-26 16:35:29 -0300449 &adap->dev->i2c_adap)) == NULL)
450 return -EIO;
451
452 return 0;
453}
454
Michael Krufkye7b419b2007-03-26 16:39:20 -0300455static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300456{
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300457 deb("%s\n",__FUNCTION__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300458
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300459 if ((adap->fe = dvb_attach(tda10046_attach,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300460 &m920x_tda10046_08_config,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300461 &adap->dev->i2c_adap)) == NULL)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300462 return -EIO;
463
Nick Andrewaa50ec22007-03-22 17:09:35 -0300464 return 0;
465}
466
Michael Krufkye7b419b2007-03-26 16:39:20 -0300467static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300468{
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300469 deb("%s\n",__FUNCTION__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300470
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300471 if ((adap->fe = dvb_attach(tda10046_attach,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300472 &m920x_tda10046_0b_config,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300473 &adap->dev->i2c_adap)) == NULL)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300474 return -EIO;
475
Nick Andrewaa50ec22007-03-22 17:09:35 -0300476 return 0;
477}
478
Michael Krufkye7b419b2007-03-26 16:39:20 -0300479static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300480{
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300481 deb("%s\n",__FUNCTION__);
Michael Krufkye7b419b2007-03-26 16:39:20 -0300482
Michael Krufky5afb7072007-03-26 16:35:29 -0300483 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300484 &m920x_qt1010_config) == NULL)
Michael Krufky5afb7072007-03-26 16:35:29 -0300485 return -ENODEV;
486
487 return 0;
488}
489
Michael Krufkye7b419b2007-03-26 16:39:20 -0300490static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300491{
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300492 deb("%s\n",__FUNCTION__);
Michael Krufkye7b419b2007-03-26 16:39:20 -0300493
Michael Krufky5afb7072007-03-26 16:35:29 -0300494 if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap,
495 NULL) == NULL)
496 return -ENODEV;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300497
498 return 0;
499}
500
Michael Krufkye7b419b2007-03-26 16:39:20 -0300501static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300502{
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300503 deb("%s\n",__FUNCTION__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300504
Michael Krufkye7b419b2007-03-26 16:39:20 -0300505 if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300506 NULL) == NULL)
507 return -ENODEV;
508
Nick Andrewaa50ec22007-03-22 17:09:35 -0300509 return 0;
510}
511
Michael Krufky5afb7072007-03-26 16:35:29 -0300512/* device-specific initialization */
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300513static struct m920x_inits megasky_rc_init [] = {
Michael Krufky5afb7072007-03-26 16:35:29 -0300514 { M9206_RC_INIT2, 0xa8 },
515 { M9206_RC_INIT1, 0x51 },
516 { } /* terminating entry */
517};
518
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300519static struct m920x_inits tvwalkertwin_rc_init [] = {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300520 { M9206_RC_INIT2, 0x00 },
521 { M9206_RC_INIT1, 0xef },
522 { 0xff28, 0x00 },
523 { 0xff23, 0x00 },
524 { 0xff21, 0x30 },
525 { } /* terminating entry */
526};
527
Michael Krufky5afb7072007-03-26 16:35:29 -0300528/* ir keymaps */
529static struct dvb_usb_rc_key megasky_rc_keys [] = {
530 { 0x0, 0x12, KEY_POWER },
531 { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */
532 { 0x0, 0x02, KEY_CHANNELUP },
533 { 0x0, 0x05, KEY_CHANNELDOWN },
534 { 0x0, 0x03, KEY_VOLUMEUP },
535 { 0x0, 0x06, KEY_VOLUMEDOWN },
536 { 0x0, 0x04, KEY_MUTE },
537 { 0x0, 0x07, KEY_OK }, /* TS */
538 { 0x0, 0x08, KEY_STOP },
539 { 0x0, 0x09, KEY_MENU }, /* swap */
540 { 0x0, 0x0a, KEY_REWIND },
541 { 0x0, 0x1b, KEY_PAUSE },
542 { 0x0, 0x1f, KEY_FASTFORWARD },
543 { 0x0, 0x0c, KEY_RECORD },
544 { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */
545 { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
546};
547
548static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
549 { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */
550 { 0x0, 0x02, KEY_CAMERA }, /* snapshot */
551 { 0x0, 0x03, KEY_MUTE },
552 { 0x0, 0x04, KEY_REWIND },
553 { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */
554 { 0x0, 0x06, KEY_FASTFORWARD },
555 { 0x0, 0x07, KEY_RECORD },
556 { 0x0, 0x08, KEY_STOP },
557 { 0x0, 0x09, KEY_TIME }, /* Timeshift */
558 { 0x0, 0x0c, KEY_COFFEE }, /* Recall */
559 { 0x0, 0x0e, KEY_CHANNELUP },
560 { 0x0, 0x12, KEY_POWER },
561 { 0x0, 0x15, KEY_MENU }, /* source */
562 { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */
563 { 0x0, 0x1a, KEY_CHANNELDOWN },
564 { 0x0, 0x1b, KEY_VOLUMEDOWN },
565 { 0x0, 0x1e, KEY_VOLUMEUP },
566};
567
Michael Krufky26f48ea2006-09-28 01:46:49 -0300568/* DVB USB Driver stuff */
569static struct dvb_usb_device_properties megasky_properties;
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300570static struct dvb_usb_device_properties digivox_mini_ii_properties;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300571static struct dvb_usb_device_properties tvwalkertwin_properties;
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300572static struct dvb_usb_device_properties dposh_properties;
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300573
Michael Krufkyfa948052007-01-21 15:57:48 -0300574static int m920x_probe(struct usb_interface *intf,
575 const struct usb_device_id *id)
Michael Krufky26f48ea2006-09-28 01:46:49 -0300576{
577 struct dvb_usb_device *d;
578 struct usb_host_interface *alt;
579 int ret;
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300580 struct m920x_inits *rc_init_seq = NULL;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300581 int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber;
Michael Krufky26f48ea2006-09-28 01:46:49 -0300582
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300583 deb("Probing for m920x device at interface %d\n", bInterfaceNumber);
Michael Krufky26f48ea2006-09-28 01:46:49 -0300584
Nick Andrewaa50ec22007-03-22 17:09:35 -0300585 if (bInterfaceNumber == 0) {
586 /* Single-tuner device, or first interface on
587 * multi-tuner device
588 */
Michael Krufky26f48ea2006-09-28 01:46:49 -0300589
Nick Andrewaa50ec22007-03-22 17:09:35 -0300590 if ((ret = dvb_usb_device_init(intf, &megasky_properties,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300591 THIS_MODULE, &d)) == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300592 rc_init_seq = megasky_rc_init;
593 goto found;
594 }
595
596 if ((ret = dvb_usb_device_init(intf,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300597 &digivox_mini_ii_properties,
598 THIS_MODULE, &d)) == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300599 /* No remote control, so no rc_init_seq */
600 goto found;
601 }
602
603 /* This configures both tuners on the TV Walker Twin */
604 if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300605 THIS_MODULE, &d)) == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300606 rc_init_seq = tvwalkertwin_rc_init;
607 goto found;
608 }
609
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300610 if ((ret = dvb_usb_device_init(intf, &dposh_properties,
611 THIS_MODULE, &d)) == 0) {
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300612 /* Remote controller not supported yet. */
613 goto found;
614 }
615
Nick Andrewaa50ec22007-03-22 17:09:35 -0300616 return ret;
617 } else {
618 /* Another interface on a multi-tuner device */
619
620 /* The LifeView TV Walker Twin gets here, but struct
621 * tvwalkertwin_properties already configured both
622 * tuners, so there is nothing for us to do here
623 */
624
625 return -ENODEV;
626 }
Michael Krufky26f48ea2006-09-28 01:46:49 -0300627
Michael Krufkye7b419b2007-03-26 16:39:20 -0300628 found:
Aapo Tahkola480ac762007-03-05 18:54:27 -0300629 alt = usb_altnum_to_altsetting(intf, 1);
630 if (alt == NULL) {
Aapo Tahkolabf2b4f672007-03-26 16:59:16 -0300631 deb("No alt found!\n");
Aapo Tahkola480ac762007-03-05 18:54:27 -0300632 return -ENODEV;
Michael Krufky26f48ea2006-09-28 01:46:49 -0300633 }
Aapo Tahkola480ac762007-03-05 18:54:27 -0300634
635 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
636 alt->desc.bAlternateSetting);
637 if (ret < 0)
638 return ret;
639
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300640 if ((ret = m920x_init(d, rc_init_seq)) != 0)
Aapo Tahkola480ac762007-03-05 18:54:27 -0300641 return ret;
642
Michael Krufky26f48ea2006-09-28 01:46:49 -0300643 return ret;
644}
645
646static struct usb_device_id m920x_table [] = {
647 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300648 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
649 USB_PID_MSI_DIGI_VOX_MINI_II) },
Nick Andrewaa50ec22007-03-22 17:09:35 -0300650 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
651 USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) },
652 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
653 USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) },
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300654 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) },
655 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) },
Michael Krufky26f48ea2006-09-28 01:46:49 -0300656 { } /* Terminating entry */
657};
658MODULE_DEVICE_TABLE (usb, m920x_table);
659
Michael Krufky01cb34d2006-09-23 20:01:29 -0300660static struct dvb_usb_device_properties megasky_properties = {
Michael Krufky758117c2007-01-23 15:34:10 -0300661 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
Michael Krufky1f61f3b2006-10-07 15:03:04 -0300662
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300663 .usb_ctrl = DEVICE_SPECIFIC,
664 .firmware = "dvb-usb-megasky-02.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300665 .download_firmware = m920x_firmware_download,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300666
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300667 .rc_interval = 100,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300668 .rc_key_map = megasky_rc_keys,
669 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys),
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300670 .rc_query = m920x_rc_query,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300671
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300672 .size_of_priv = sizeof(struct m920x_state),
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300673
Aapo Tahkola7d1d4e62007-03-15 13:01:46 -0300674 .identify_state = m920x_identify_state,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300675 .num_adapters = 1,
676 .adapter = {{
Michael Krufky758117c2007-01-23 15:34:10 -0300677 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
678 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
679
Michael Krufky01cb34d2006-09-23 20:01:29 -0300680 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300681 .pid_filter = m920x_pid_filter,
682 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300683
Michael Krufkye7b419b2007-03-26 16:39:20 -0300684 .frontend_attach = m920x_mt352_frontend_attach,
685 .tuner_attach = m920x_qt1010_tuner_attach,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300686
687 .stream = {
688 .type = USB_BULK,
689 .count = 8,
690 .endpoint = 0x81,
691 .u = {
692 .bulk = {
693 .buffersize = 512,
694 }
695 }
696 },
697 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300698 .i2c_algo = &m920x_i2c_algo,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300699
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300700 .num_device_descs = 1,
701 .devices = {
702 { "MSI Mega Sky 580 DVB-T USB2.0",
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300703 { &m920x_table[0], NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300704 { NULL },
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300705 }
706 }
707};
708
709static struct dvb_usb_device_properties digivox_mini_ii_properties = {
710 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
711
712 .usb_ctrl = DEVICE_SPECIFIC,
713 .firmware = "dvb-usb-digivox-02.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300714 .download_firmware = m920x_firmware_download,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300715
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300716 .size_of_priv = sizeof(struct m920x_state),
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300717
718 .identify_state = m920x_identify_state,
719 .num_adapters = 1,
720 .adapter = {{
721 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300722 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300723
724 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300725 .pid_filter = m920x_pid_filter,
726 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300727
Michael Krufkye7b419b2007-03-26 16:39:20 -0300728 .frontend_attach = m920x_tda10046_08_frontend_attach,
729 .tuner_attach = m920x_tda8275_60_tuner_attach,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300730
731 .stream = {
732 .type = USB_BULK,
733 .count = 8,
734 .endpoint = 0x81,
735 .u = {
736 .bulk = {
737 .buffersize = 0x4000,
738 }
739 }
740 },
741 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300742 .i2c_algo = &m920x_i2c_algo,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300743
744 .num_device_descs = 1,
745 .devices = {
746 { "MSI DIGI VOX mini II DVB-T USB2.0",
747 { &m920x_table[1], NULL },
748 { NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300749 },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300750 }
751};
752
Michael Krufkye7b419b2007-03-26 16:39:20 -0300753/* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
754 *
755 * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
756 * TDA10046 #0 is located at i2c address 0x08
757 * TDA10046 #1 is located at i2c address 0x0b
758 * TDA8275A #0 is located at i2c address 0x60
759 * TDA8275A #1 is located at i2c address 0x61
760 */
Nick Andrewaa50ec22007-03-22 17:09:35 -0300761static struct dvb_usb_device_properties tvwalkertwin_properties = {
762 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
763
764 .usb_ctrl = DEVICE_SPECIFIC,
765 .firmware = "dvb-usb-tvwalkert.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300766 .download_firmware = m920x_firmware_download,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300767
768 .rc_interval = 100,
769 .rc_key_map = tvwalkertwin_rc_keys,
770 .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys),
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300771 .rc_query = m920x_rc_query,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300772
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300773 .size_of_priv = sizeof(struct m920x_state),
Nick Andrewaa50ec22007-03-22 17:09:35 -0300774
775 .identify_state = m920x_identify_state,
776 .num_adapters = 2,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300777 .adapter = {{
778 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
779 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300780
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300781 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300782 .pid_filter = m920x_pid_filter,
783 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300784
Michael Krufkye7b419b2007-03-26 16:39:20 -0300785 .frontend_attach = m920x_tda10046_08_frontend_attach,
786 .tuner_attach = m920x_tda8275_60_tuner_attach,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300787
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300788 .stream = {
789 .type = USB_BULK,
790 .count = 8,
791 .endpoint = 0x81,
792 .u = {
793 .bulk = {
794 .buffersize = 512,
795 }
796 }
797 }},{
798 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
799 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
800
801 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300802 .pid_filter = m920x_pid_filter,
803 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300804
Michael Krufkye7b419b2007-03-26 16:39:20 -0300805 .frontend_attach = m920x_tda10046_0b_frontend_attach,
806 .tuner_attach = m920x_tda8275_61_tuner_attach,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300807
808 .stream = {
809 .type = USB_BULK,
810 .count = 8,
811 .endpoint = 0x82,
812 .u = {
813 .bulk = {
814 .buffersize = 512,
815 }
816 }
Nick Andrewaa50ec22007-03-22 17:09:35 -0300817 },
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300818 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300819 .i2c_algo = &m920x_i2c_algo,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300820
821 .num_device_descs = 1,
822 .devices = {
823 { .name = "LifeView TV Walker Twin DVB-T USB2.0",
824 .cold_ids = { &m920x_table[2], NULL },
825 .warm_ids = { &m920x_table[3], NULL },
826 },
827 }
828};
829
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300830static struct dvb_usb_device_properties dposh_properties = {
831 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
832
833 .usb_ctrl = DEVICE_SPECIFIC,
834 .firmware = "dvb-usb-dposh-01.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300835 .download_firmware = m920x_firmware_download,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300836
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300837 .size_of_priv = sizeof(struct m920x_state),
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300838
839 .identify_state = m920x_identify_state,
840 .num_adapters = 1,
841 .adapter = {{
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300842 /* Hardware pid filters don't work with this device/firmware */
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300843
Michael Krufkye7b419b2007-03-26 16:39:20 -0300844 .frontend_attach = m920x_mt352_frontend_attach,
845 .tuner_attach = m920x_qt1010_tuner_attach,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300846
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300847 .stream = {
848 .type = USB_BULK,
849 .count = 8,
850 .endpoint = 0x81,
851 .u = {
852 .bulk = {
853 .buffersize = 512,
854 }
855 }
856 },
857 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300858 .i2c_algo = &m920x_i2c_algo,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300859
860 .num_device_descs = 1,
861 .devices = {
862 { .name = "Dposh DVB-T USB2.0",
863 .cold_ids = { &m920x_table[4], NULL },
864 .warm_ids = { &m920x_table[5], NULL },
865 },
866 }
867};
868
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300869static struct usb_driver m920x_driver = {
870 .name = "dvb_usb_m920x",
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300871 .probe = m920x_probe,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300872 .disconnect = dvb_usb_device_exit,
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300873 .id_table = m920x_table,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300874};
875
876/* module stuff */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300877static int __init m920x_module_init(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300878{
879 int ret;
880
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300881 if ((ret = usb_register(&m920x_driver))) {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300882 err("usb_register failed. Error number %d", ret);
883 return ret;
884 }
885
886 return 0;
887}
888
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300889static void __exit m920x_module_exit(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300890{
891 /* deregister this driver from the USB subsystem */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300892 usb_deregister(&m920x_driver);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300893}
894
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300895module_init (m920x_module_init);
896module_exit (m920x_module_exit);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300897
898MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
Nick Andrewaa50ec22007-03-22 17:09:35 -0300899MODULE_DESCRIPTION("DVB Driver for ULI M920x");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300900MODULE_VERSION("0.1");
901MODULE_LICENSE("GPL");
Michael Krufkyce9c2752007-03-22 17:18:26 -0300902
903/*
904 * Local variables:
905 * c-basic-offset: 8
906 */