blob: 37e7f5881a82822f0f876f5aada8d73a37cbde5f [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 Tahkola47f8df02007-05-08 12:03:55 -030025static int m920x_set_filter(struct dvb_usb_device *d, int type, int idx, int pid);
26
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030027static inline int m920x_read(struct usb_device *udev, u8 request, u16 value,
Michael Krufkyfa948052007-01-21 15:57:48 -030028 u16 index, void *data, int size)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030029{
30 int ret;
31
32 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
33 request, USB_TYPE_VENDOR | USB_DIR_IN,
34 value, index, data, size, 2000);
Pierre Willenbrock59069e52007-03-15 13:24:29 -030035 if (ret < 0) {
36 printk(KERN_INFO "m920x_read = error: %d\n", ret);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030037 return ret;
Pierre Willenbrock59069e52007-03-15 13:24:29 -030038 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030039
Pierre Willenbrock59069e52007-03-15 13:24:29 -030040 if (ret != size) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -030041 deb("m920x_read = no data\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030042 return -EIO;
Pierre Willenbrock59069e52007-03-15 13:24:29 -030043 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030044
45 return 0;
46}
47
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030048static inline int m920x_write(struct usb_device *udev, u8 request,
Michael Krufkyfa948052007-01-21 15:57:48 -030049 u16 value, u16 index)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030050{
51 int ret;
52
53 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
54 request, USB_TYPE_VENDOR | USB_DIR_OUT,
55 value, index, NULL, 0, 2000);
Pierre Willenbrock59069e52007-03-15 13:24:29 -030056
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030057 return ret;
58}
59
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030060static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030061{
Aapo Tahkola47f8df02007-05-08 12:03:55 -030062 int ret = 0, i, epi;
63 int adap_enabled[M9206_MAX_ADAPTERS] = { 0 };
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030064
65 /* Remote controller init. */
Aapo Tahkola480ac762007-03-05 18:54:27 -030066 if (d->props.rc_query) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -030067 deb("Initialising remote control\n");
Nick Andrewaa50ec22007-03-22 17:09:35 -030068 while (rc_seq->address) {
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030069 if ((ret = m920x_write(d->udev, M9206_CORE,
Michael Krufkyd3911ea2007-03-22 19:03:37 -030070 rc_seq->data,
71 rc_seq->address)) != 0) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -030072 deb("Initialising remote control failed\n");
Nick Andrewaa50ec22007-03-22 17:09:35 -030073 return ret;
74 }
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030075
Nick Andrewaa50ec22007-03-22 17:09:35 -030076 rc_seq++;
77 }
78
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -030079 deb("Initialising remote control success\n");
Aapo Tahkola480ac762007-03-05 18:54:27 -030080 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030081
Aapo Tahkola47f8df02007-05-08 12:03:55 -030082 for (i = 0; i < d->props.num_adapters; i++) {
83 epi = d->adapter[i].props.stream.endpoint - 0x81;
84
85 if (epi < 0 || epi >= M9206_MAX_ADAPTERS) {
86 printk(KERN_INFO "m920x: Unexpected adapter endpoint!\n");
87 return -EINVAL;
88 }
89
90 adap_enabled[epi] = 1;
91 }
92
93 for (i = 0; i < M9206_MAX_ADAPTERS; i++) {
94 if (adap_enabled[i])
95 continue;
96
97 if ((ret = m920x_set_filter(d, 0x81 + i, 0, 0x0)) != 0)
98 return ret;
99
100 if ((ret = m920x_set_filter(d, 0x81 + i, 0, 0x02f5)) != 0)
101 return ret;
102 }
103
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300104 return ret;
105}
106
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300107static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300108{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300109 struct m920x_state *m = d->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300110 int i, ret = 0;
111 u8 rc_state[2];
112
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300113 if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300114 goto unlock;
115
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300116 if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300117 goto unlock;
118
Aapo Tahkola480ac762007-03-05 18:54:27 -0300119 for (i = 0; i < d->props.rc_key_map_size; i++)
120 if (d->props.rc_key_map[i].data == rc_state[1]) {
121 *event = d->props.rc_key_map[i].event;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300122
123 switch(rc_state[0]) {
124 case 0x80:
125 *state = REMOTE_NO_KEY_PRESSED;
126 goto unlock;
127
Nick Andrewaa50ec22007-03-22 17:09:35 -0300128 case 0x88: /* framing error or "invalid code" */
129 case 0x99:
130 case 0xc0:
131 case 0xd8:
132 *state = REMOTE_NO_KEY_PRESSED;
133 m->rep_count = 0;
134 goto unlock;
135
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300136 case 0x93:
137 case 0x92:
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300138 m->rep_count = 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300139 *state = REMOTE_KEY_PRESSED;
140 goto unlock;
141
142 case 0x91:
Nick Andrewaa50ec22007-03-22 17:09:35 -0300143 /* prevent immediate auto-repeat */
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300144 if (++m->rep_count > 2)
145 *state = REMOTE_KEY_REPEAT;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300146 else
147 *state = REMOTE_NO_KEY_PRESSED;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300148 goto unlock;
149
150 default:
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300151 deb("Unexpected rc state %02x\n", rc_state[0]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300152 *state = REMOTE_NO_KEY_PRESSED;
153 goto unlock;
154 }
155 }
156
157 if (rc_state[1] != 0)
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300158 deb("Unknown rc key %02x\n", rc_state[1]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300159
160 *state = REMOTE_NO_KEY_PRESSED;
161
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300162 unlock:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300163
164 return ret;
165}
166
167/* I2C */
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300168static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300169{
170 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Aapo Tahkola26247012007-03-05 18:23:19 -0300171 int i, j;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300172 int ret = 0;
173
Trent Piephod40860f2007-03-05 23:55:00 -0300174 if (!num)
175 return -EINVAL;
176
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300177 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
178 return -EAGAIN;
179
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300180 for (i = 0; i < num; i++) {
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300181 if (msg[i].flags & (I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK | I2C_M_TEN) || msg[i].len == 0) {
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300182 /* For a 0 byte message, I think sending the address
183 * to index 0x80|0x40 would be the correct thing to
184 * do. However, zero byte messages are only used for
185 * probing, and since we don't know how to get the
186 * slave's ack, we can't probe. */
Trent Piephod40860f2007-03-05 23:55:00 -0300187 ret = -ENOTSUPP;
188 goto unlock;
189 }
190 /* Send START & address/RW bit */
191 if (!(msg[i].flags & I2C_M_NOSTART)) {
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300192 if ((ret = m920x_write(d->udev, M9206_I2C,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300193 (msg[i].addr << 1) |
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300194 (msg[i].flags & I2C_M_RD ? 0x01 : 0), 0x80)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300195 goto unlock;
196 /* Should check for ack here, if we knew how. */
197 }
Aapo Tahkola26247012007-03-05 18:23:19 -0300198 if (msg[i].flags & I2C_M_RD) {
Trent Piephod40860f2007-03-05 23:55:00 -0300199 for (j = 0; j < msg[i].len; j++) {
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300200 /* Last byte of transaction?
201 * Send STOP, otherwise send ACK. */
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300202 int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x01;
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300203
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300204 if ((ret = m920x_read(d->udev, M9206_I2C, 0x0,
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300205 0x20 | stop,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300206 &msg[i].buf[j], 1)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300207 goto unlock;
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300208 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300209 } else {
Trent Piephod40860f2007-03-05 23:55:00 -0300210 for (j = 0; j < msg[i].len; j++) {
211 /* Last byte of transaction? Then send STOP. */
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300212 int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x00;
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300213
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300214 if ((ret = m920x_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300215 goto unlock;
216 /* Should check for ack here too. */
Aapo Tahkola26247012007-03-05 18:23:19 -0300217 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300218 }
219 }
Aapo Tahkola26247012007-03-05 18:23:19 -0300220 ret = num;
Trent Piephod40860f2007-03-05 23:55:00 -0300221
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300222 unlock:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300223 mutex_unlock(&d->i2c_mutex);
224
225 return ret;
226}
227
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300228static u32 m920x_i2c_func(struct i2c_adapter *adapter)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300229{
230 return I2C_FUNC_I2C;
231}
232
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300233static struct i2c_algorithm m920x_i2c_algo = {
234 .master_xfer = m920x_i2c_xfer,
235 .functionality = m920x_i2c_func,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300236};
237
Michael Krufky5afb7072007-03-26 16:35:29 -0300238/* pid filter */
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300239static int m920x_set_filter(struct dvb_usb_device *d, int type, int idx, int pid)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300240{
241 int ret = 0;
242
243 if (pid >= 0x8000)
244 return -EINVAL;
245
246 pid |= 0x8000;
247
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300248 if ((ret = m920x_write(d->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300249 return ret;
250
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300251 if ((ret = m920x_write(d->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300252 return ret;
253
254 return ret;
255}
256
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300257static int m920x_update_filters(struct dvb_usb_adapter *adap)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300258{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300259 struct m920x_state *m = adap->dev->priv;
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300260 int enabled = m->filtering_enabled[adap->id];
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300261 int i, ret = 0, filter = 0;
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300262 int ep = adap->props.stream.endpoint;
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300263
264 for (i = 0; i < M9206_MAX_FILTERS; i++)
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300265 if (m->filters[adap->id][i] == 8192)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300266 enabled = 0;
267
268 /* Disable all filters */
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300269 if ((ret = m920x_set_filter(adap->dev, ep, 1, enabled)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300270 return ret;
271
272 for (i = 0; i < M9206_MAX_FILTERS; i++)
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300273 if ((ret = m920x_set_filter(adap->dev, ep, i + 2, 0)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300274 return ret;
275
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300276 /* Set */
277 if (enabled) {
278 for (i = 0; i < M9206_MAX_FILTERS; i++) {
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300279 if (m->filters[adap->id][i] == 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300280 continue;
281
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300282 if ((ret = m920x_set_filter(adap->dev, ep, filter + 2, m->filters[adap->id][i])) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300283 return ret;
284
285 filter++;
286 }
287 }
288
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300289 return ret;
290}
291
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300292static int m920x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300293{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300294 struct m920x_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300295
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300296 m->filtering_enabled[adap->id] = onoff ? 1 : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300297
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300298 return m920x_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300299}
300
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300301static int m920x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300302{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300303 struct m920x_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300304
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300305 m->filters[adap->id][index] = onoff ? pid : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300306
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300307 return m920x_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300308}
309
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300310static int m920x_firmware_download(struct usb_device *udev, const struct firmware *fw)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300311{
312 u16 value, index, size;
313 u8 read[4], *buff;
314 int i, pass, ret = 0;
315
316 buff = kmalloc(65536, GFP_KERNEL);
317
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300318 if ((ret = m920x_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300319 goto done;
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300320 deb("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300321
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300322 if ((ret = m920x_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300323 goto done;
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300324 deb("%x\n", read[0]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300325
326 for (pass = 0; pass < 2; pass++) {
327 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
328 value = le16_to_cpu(*(u16 *)(fw->data + i));
329 i += sizeof(u16);
330
331 index = le16_to_cpu(*(u16 *)(fw->data + i));
332 i += sizeof(u16);
333
334 size = le16_to_cpu(*(u16 *)(fw->data + i));
335 i += sizeof(u16);
336
337 if (pass == 1) {
338 /* Will stall if using fw->data ... */
339 memcpy(buff, fw->data + i, size);
340
341 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300342 M9206_FW,
343 USB_TYPE_VENDOR | USB_DIR_OUT,
344 value, index, buff, size, 20);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300345 if (ret != size) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300346 deb("error while uploading fw!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300347 ret = -EIO;
348 goto done;
349 }
350 msleep(3);
351 }
352 i += size;
353 }
354 if (i != fw->size) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300355 deb("bad firmware file!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300356 ret = -EINVAL;
357 goto done;
358 }
359 }
360
361 msleep(36);
362
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300363 /* m920x will disconnect itself from the bus after this. */
364 (void) m920x_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300365 deb("firmware uploaded!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300366
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300367 done:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300368 kfree(buff);
369
370 return ret;
371}
372
Michael Krufkye16c1f52007-01-23 15:00:42 -0300373/* Callbacks for DVB USB */
Aapo Tahkola7d1d4e62007-03-15 13:01:46 -0300374static int m920x_identify_state(struct usb_device *udev,
375 struct dvb_usb_device_properties *props,
376 struct dvb_usb_device_description **desc,
377 int *cold)
Michael Krufkye16c1f52007-01-23 15:00:42 -0300378{
379 struct usb_host_interface *alt;
380
381 alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
382 *cold = (alt == NULL) ? 1 : 0;
383
384 return 0;
385}
386
Michael Krufky5afb7072007-03-26 16:35:29 -0300387/* demod configurations */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300388static int m920x_mt352_demod_init(struct dvb_frontend *fe)
Michael Krufkye16c1f52007-01-23 15:00:42 -0300389{
390 u8 config[] = { CONFIG, 0x3d };
391 u8 clock[] = { CLOCK_CTL, 0x30 };
392 u8 reset[] = { RESET, 0x80 };
393 u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
394 u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
395 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
396 u8 unk1[] = { 0x93, 0x1a };
397 u8 unk2[] = { 0xb5, 0x7a };
398
399 mt352_write(fe, config, ARRAY_SIZE(config));
400 mt352_write(fe, clock, ARRAY_SIZE(clock));
401 mt352_write(fe, reset, ARRAY_SIZE(reset));
402 mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
403 mt352_write(fe, agc, ARRAY_SIZE(agc));
404 mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
405 mt352_write(fe, unk1, ARRAY_SIZE(unk1));
406 mt352_write(fe, unk2, ARRAY_SIZE(unk2));
407
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300408 deb("Demod init!\n");
Michael Krufkye16c1f52007-01-23 15:00:42 -0300409
410 return 0;
411}
412
Michael Krufkye7b419b2007-03-26 16:39:20 -0300413static struct mt352_config m920x_mt352_config = {
Aapo Tahkola26247012007-03-05 18:23:19 -0300414 .demod_address = 0x0f,
Michael Krufkye16c1f52007-01-23 15:00:42 -0300415 .no_tuner = 1,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300416 .demod_init = m920x_mt352_demod_init,
Michael Krufkye16c1f52007-01-23 15:00:42 -0300417};
418
Michael Krufkye7b419b2007-03-26 16:39:20 -0300419static struct tda1004x_config m920x_tda10046_08_config = {
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300420 .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
Michael Krufkye7b419b2007-03-26 16:39:20 -0300431static struct tda1004x_config m920x_tda10046_0b_config = {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300432 .demod_address = 0x0b,
433 .invert = 0,
434 .invert_oclk = 0,
435 .ts_mode = TDA10046_TS_SERIAL,
436 .xtal_freq = TDA10046_XTAL_16M,
437 .if_freq = TDA10046_FREQ_045,
438 .agc_config = TDA10046_AGC_TDA827X,
439 .gpio_config = TDA10046_GPTRI,
440 .request_firmware = NULL, /* uses firmware EEPROM */
441};
442
Michael Krufky5afb7072007-03-26 16:35:29 -0300443/* tuner configurations */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300444static struct qt1010_config m920x_qt1010_config = {
Michael Krufky5afb7072007-03-26 16:35:29 -0300445 .i2c_address = 0x62
446};
447
448/* Callbacks for DVB USB */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300449static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300450{
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300451 deb("%s\n",__FUNCTION__);
Michael Krufky5afb7072007-03-26 16:35:29 -0300452
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300453 if ((adap->fe = dvb_attach(mt352_attach,
454 &m920x_mt352_config,
Michael Krufky5afb7072007-03-26 16:35:29 -0300455 &adap->dev->i2c_adap)) == NULL)
456 return -EIO;
457
458 return 0;
459}
460
Michael Krufkye7b419b2007-03-26 16:39:20 -0300461static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300462{
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300463 deb("%s\n",__FUNCTION__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300464
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300465 if ((adap->fe = dvb_attach(tda10046_attach,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300466 &m920x_tda10046_08_config,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300467 &adap->dev->i2c_adap)) == NULL)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300468 return -EIO;
469
Nick Andrewaa50ec22007-03-22 17:09:35 -0300470 return 0;
471}
472
Michael Krufkye7b419b2007-03-26 16:39:20 -0300473static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300474{
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300475 deb("%s\n",__FUNCTION__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300476
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300477 if ((adap->fe = dvb_attach(tda10046_attach,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300478 &m920x_tda10046_0b_config,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300479 &adap->dev->i2c_adap)) == NULL)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300480 return -EIO;
481
Nick Andrewaa50ec22007-03-22 17:09:35 -0300482 return 0;
483}
484
Michael Krufkye7b419b2007-03-26 16:39:20 -0300485static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300486{
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300487 deb("%s\n",__FUNCTION__);
Michael Krufkye7b419b2007-03-26 16:39:20 -0300488
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300489 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL)
Michael Krufky5afb7072007-03-26 16:35:29 -0300490 return -ENODEV;
491
492 return 0;
493}
494
Michael Krufkye7b419b2007-03-26 16:39:20 -0300495static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300496{
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300497 deb("%s\n",__FUNCTION__);
Michael Krufkye7b419b2007-03-26 16:39:20 -0300498
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300499 if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL)
Michael Krufky5afb7072007-03-26 16:35:29 -0300500 return -ENODEV;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300501
502 return 0;
503}
504
Michael Krufkye7b419b2007-03-26 16:39:20 -0300505static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300506{
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300507 deb("%s\n",__FUNCTION__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300508
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300509 if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300510 return -ENODEV;
511
Nick Andrewaa50ec22007-03-22 17:09:35 -0300512 return 0;
513}
514
Michael Krufky5afb7072007-03-26 16:35:29 -0300515/* device-specific initialization */
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300516static struct m920x_inits megasky_rc_init [] = {
Michael Krufky5afb7072007-03-26 16:35:29 -0300517 { M9206_RC_INIT2, 0xa8 },
518 { M9206_RC_INIT1, 0x51 },
519 { } /* terminating entry */
520};
521
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300522static struct m920x_inits tvwalkertwin_rc_init [] = {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300523 { M9206_RC_INIT2, 0x00 },
524 { M9206_RC_INIT1, 0xef },
525 { 0xff28, 0x00 },
526 { 0xff23, 0x00 },
527 { 0xff21, 0x30 },
528 { } /* terminating entry */
529};
530
Michael Krufky5afb7072007-03-26 16:35:29 -0300531/* ir keymaps */
532static struct dvb_usb_rc_key megasky_rc_keys [] = {
533 { 0x0, 0x12, KEY_POWER },
534 { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */
535 { 0x0, 0x02, KEY_CHANNELUP },
536 { 0x0, 0x05, KEY_CHANNELDOWN },
537 { 0x0, 0x03, KEY_VOLUMEUP },
538 { 0x0, 0x06, KEY_VOLUMEDOWN },
539 { 0x0, 0x04, KEY_MUTE },
540 { 0x0, 0x07, KEY_OK }, /* TS */
541 { 0x0, 0x08, KEY_STOP },
542 { 0x0, 0x09, KEY_MENU }, /* swap */
543 { 0x0, 0x0a, KEY_REWIND },
544 { 0x0, 0x1b, KEY_PAUSE },
545 { 0x0, 0x1f, KEY_FASTFORWARD },
546 { 0x0, 0x0c, KEY_RECORD },
547 { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */
548 { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
549};
550
551static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
552 { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */
553 { 0x0, 0x02, KEY_CAMERA }, /* snapshot */
554 { 0x0, 0x03, KEY_MUTE },
555 { 0x0, 0x04, KEY_REWIND },
556 { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */
557 { 0x0, 0x06, KEY_FASTFORWARD },
558 { 0x0, 0x07, KEY_RECORD },
559 { 0x0, 0x08, KEY_STOP },
560 { 0x0, 0x09, KEY_TIME }, /* Timeshift */
561 { 0x0, 0x0c, KEY_COFFEE }, /* Recall */
562 { 0x0, 0x0e, KEY_CHANNELUP },
563 { 0x0, 0x12, KEY_POWER },
564 { 0x0, 0x15, KEY_MENU }, /* source */
565 { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */
566 { 0x0, 0x1a, KEY_CHANNELDOWN },
567 { 0x0, 0x1b, KEY_VOLUMEDOWN },
568 { 0x0, 0x1e, KEY_VOLUMEUP },
569};
570
Michael Krufky26f48ea2006-09-28 01:46:49 -0300571/* DVB USB Driver stuff */
572static struct dvb_usb_device_properties megasky_properties;
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300573static struct dvb_usb_device_properties digivox_mini_ii_properties;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300574static struct dvb_usb_device_properties tvwalkertwin_properties;
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300575static struct dvb_usb_device_properties dposh_properties;
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300576
Michael Krufkyfa948052007-01-21 15:57:48 -0300577static int m920x_probe(struct usb_interface *intf,
578 const struct usb_device_id *id)
Michael Krufky26f48ea2006-09-28 01:46:49 -0300579{
580 struct dvb_usb_device *d;
581 struct usb_host_interface *alt;
582 int ret;
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300583 struct m920x_inits *rc_init_seq = NULL;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300584 int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber;
Michael Krufky26f48ea2006-09-28 01:46:49 -0300585
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300586 deb("Probing for m920x device at interface %d\n", bInterfaceNumber);
Michael Krufky26f48ea2006-09-28 01:46:49 -0300587
Nick Andrewaa50ec22007-03-22 17:09:35 -0300588 if (bInterfaceNumber == 0) {
589 /* Single-tuner device, or first interface on
590 * multi-tuner device
591 */
Michael Krufky26f48ea2006-09-28 01:46:49 -0300592
Nick Andrewaa50ec22007-03-22 17:09:35 -0300593 if ((ret = dvb_usb_device_init(intf, &megasky_properties,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300594 THIS_MODULE, &d)) == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300595 rc_init_seq = megasky_rc_init;
596 goto found;
597 }
598
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300599 if ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300600 THIS_MODULE, &d)) == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300601 /* No remote control, so no rc_init_seq */
602 goto found;
603 }
604
605 /* This configures both tuners on the TV Walker Twin */
606 if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300607 THIS_MODULE, &d)) == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300608 rc_init_seq = tvwalkertwin_rc_init;
609 goto found;
610 }
611
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300612 if ((ret = dvb_usb_device_init(intf, &dposh_properties,
613 THIS_MODULE, &d)) == 0) {
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300614 /* Remote controller not supported yet. */
615 goto found;
616 }
617
Nick Andrewaa50ec22007-03-22 17:09:35 -0300618 return ret;
619 } else {
620 /* Another interface on a multi-tuner device */
621
622 /* The LifeView TV Walker Twin gets here, but struct
623 * tvwalkertwin_properties already configured both
624 * tuners, so there is nothing for us to do here
625 */
626
627 return -ENODEV;
628 }
Michael Krufky26f48ea2006-09-28 01:46:49 -0300629
Michael Krufkye7b419b2007-03-26 16:39:20 -0300630 found:
Aapo Tahkola480ac762007-03-05 18:54:27 -0300631 alt = usb_altnum_to_altsetting(intf, 1);
632 if (alt == NULL) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300633 deb("No alt found!\n");
Aapo Tahkola480ac762007-03-05 18:54:27 -0300634 return -ENODEV;
Michael Krufky26f48ea2006-09-28 01:46:49 -0300635 }
Aapo Tahkola480ac762007-03-05 18:54:27 -0300636
637 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
638 alt->desc.bAlternateSetting);
639 if (ret < 0)
640 return ret;
641
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300642 if ((ret = m920x_init(d, rc_init_seq)) != 0)
Aapo Tahkola480ac762007-03-05 18:54:27 -0300643 return ret;
644
Michael Krufky26f48ea2006-09-28 01:46:49 -0300645 return ret;
646}
647
648static struct usb_device_id m920x_table [] = {
649 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300650 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
651 USB_PID_MSI_DIGI_VOX_MINI_II) },
Nick Andrewaa50ec22007-03-22 17:09:35 -0300652 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
653 USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) },
654 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
655 USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) },
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300656 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) },
657 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) },
Michael Krufky26f48ea2006-09-28 01:46:49 -0300658 { } /* Terminating entry */
659};
660MODULE_DEVICE_TABLE (usb, m920x_table);
661
Michael Krufky01cb34d2006-09-23 20:01:29 -0300662static struct dvb_usb_device_properties megasky_properties = {
Michael Krufky758117c2007-01-23 15:34:10 -0300663 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
Michael Krufky1f61f3b2006-10-07 15:03:04 -0300664
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300665 .usb_ctrl = DEVICE_SPECIFIC,
666 .firmware = "dvb-usb-megasky-02.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300667 .download_firmware = m920x_firmware_download,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300668
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300669 .rc_interval = 100,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300670 .rc_key_map = megasky_rc_keys,
671 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys),
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300672 .rc_query = m920x_rc_query,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300673
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300674 .size_of_priv = sizeof(struct m920x_state),
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300675
Aapo Tahkola7d1d4e62007-03-15 13:01:46 -0300676 .identify_state = m920x_identify_state,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300677 .num_adapters = 1,
678 .adapter = {{
Michael Krufky758117c2007-01-23 15:34:10 -0300679 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
680 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
681
Michael Krufky01cb34d2006-09-23 20:01:29 -0300682 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300683 .pid_filter = m920x_pid_filter,
684 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300685
Michael Krufkye7b419b2007-03-26 16:39:20 -0300686 .frontend_attach = m920x_mt352_frontend_attach,
687 .tuner_attach = m920x_qt1010_tuner_attach,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300688
689 .stream = {
690 .type = USB_BULK,
691 .count = 8,
692 .endpoint = 0x81,
693 .u = {
694 .bulk = {
695 .buffersize = 512,
696 }
697 }
698 },
699 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300700 .i2c_algo = &m920x_i2c_algo,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300701
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300702 .num_device_descs = 1,
703 .devices = {
704 { "MSI Mega Sky 580 DVB-T USB2.0",
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300705 { &m920x_table[0], NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300706 { NULL },
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300707 }
708 }
709};
710
711static struct dvb_usb_device_properties digivox_mini_ii_properties = {
712 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
713
714 .usb_ctrl = DEVICE_SPECIFIC,
715 .firmware = "dvb-usb-digivox-02.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300716 .download_firmware = m920x_firmware_download,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300717
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300718 .size_of_priv = sizeof(struct m920x_state),
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300719
720 .identify_state = m920x_identify_state,
721 .num_adapters = 1,
722 .adapter = {{
723 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300724 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300725
726 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300727 .pid_filter = m920x_pid_filter,
728 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300729
Michael Krufkye7b419b2007-03-26 16:39:20 -0300730 .frontend_attach = m920x_tda10046_08_frontend_attach,
731 .tuner_attach = m920x_tda8275_60_tuner_attach,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300732
733 .stream = {
734 .type = USB_BULK,
735 .count = 8,
736 .endpoint = 0x81,
737 .u = {
738 .bulk = {
739 .buffersize = 0x4000,
740 }
741 }
742 },
743 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300744 .i2c_algo = &m920x_i2c_algo,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300745
746 .num_device_descs = 1,
747 .devices = {
748 { "MSI DIGI VOX mini II DVB-T USB2.0",
749 { &m920x_table[1], NULL },
750 { NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300751 },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300752 }
753};
754
Michael Krufkye7b419b2007-03-26 16:39:20 -0300755/* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
756 *
757 * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
758 * TDA10046 #0 is located at i2c address 0x08
Nick Andrew14c4ffb2007-05-05 09:24:27 -0300759 * TDA10046 #1 is located at i2c address 0x0b (presently disabled - not yet working)
Michael Krufkye7b419b2007-03-26 16:39:20 -0300760 * TDA8275A #0 is located at i2c address 0x60
Nick Andrew14c4ffb2007-05-05 09:24:27 -0300761 * TDA8275A #1 is located at i2c address 0x61 (presently disabled - not yet working)
Michael Krufkye7b419b2007-03-26 16:39:20 -0300762 */
Nick Andrewaa50ec22007-03-22 17:09:35 -0300763static struct dvb_usb_device_properties tvwalkertwin_properties = {
764 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
765
766 .usb_ctrl = DEVICE_SPECIFIC,
767 .firmware = "dvb-usb-tvwalkert.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300768 .download_firmware = m920x_firmware_download,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300769
770 .rc_interval = 100,
771 .rc_key_map = tvwalkertwin_rc_keys,
772 .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys),
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300773 .rc_query = m920x_rc_query,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300774
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300775 .size_of_priv = sizeof(struct m920x_state),
Nick Andrewaa50ec22007-03-22 17:09:35 -0300776
777 .identify_state = m920x_identify_state,
Nick Andrew14c4ffb2007-05-05 09:24:27 -0300778 .num_adapters = 1,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300779 .adapter = {{
780 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
781 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300782
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300783 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300784 .pid_filter = m920x_pid_filter,
785 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300786
Michael Krufkye7b419b2007-03-26 16:39:20 -0300787 .frontend_attach = m920x_tda10046_08_frontend_attach,
788 .tuner_attach = m920x_tda8275_60_tuner_attach,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300789
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300790 .stream = {
791 .type = USB_BULK,
792 .count = 8,
793 .endpoint = 0x81,
794 .u = {
795 .bulk = {
796 .buffersize = 512,
797 }
798 }
799 }},{
800 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
801 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
802
803 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300804 .pid_filter = m920x_pid_filter,
805 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300806
Michael Krufkye7b419b2007-03-26 16:39:20 -0300807 .frontend_attach = m920x_tda10046_0b_frontend_attach,
808 .tuner_attach = m920x_tda8275_61_tuner_attach,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300809
810 .stream = {
811 .type = USB_BULK,
812 .count = 8,
813 .endpoint = 0x82,
814 .u = {
815 .bulk = {
816 .buffersize = 512,
817 }
818 }
Nick Andrewaa50ec22007-03-22 17:09:35 -0300819 },
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300820 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300821 .i2c_algo = &m920x_i2c_algo,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300822
823 .num_device_descs = 1,
824 .devices = {
825 { .name = "LifeView TV Walker Twin DVB-T USB2.0",
826 .cold_ids = { &m920x_table[2], NULL },
827 .warm_ids = { &m920x_table[3], NULL },
828 },
829 }
830};
831
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300832static struct dvb_usb_device_properties dposh_properties = {
833 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
834
835 .usb_ctrl = DEVICE_SPECIFIC,
836 .firmware = "dvb-usb-dposh-01.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300837 .download_firmware = m920x_firmware_download,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300838
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300839 .size_of_priv = sizeof(struct m920x_state),
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300840
841 .identify_state = m920x_identify_state,
842 .num_adapters = 1,
843 .adapter = {{
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300844 /* Hardware pid filters don't work with this device/firmware */
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300845
Michael Krufkye7b419b2007-03-26 16:39:20 -0300846 .frontend_attach = m920x_mt352_frontend_attach,
847 .tuner_attach = m920x_qt1010_tuner_attach,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300848
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300849 .stream = {
850 .type = USB_BULK,
851 .count = 8,
852 .endpoint = 0x81,
853 .u = {
854 .bulk = {
855 .buffersize = 512,
856 }
857 }
858 },
859 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300860 .i2c_algo = &m920x_i2c_algo,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300861
862 .num_device_descs = 1,
863 .devices = {
864 { .name = "Dposh DVB-T USB2.0",
865 .cold_ids = { &m920x_table[4], NULL },
866 .warm_ids = { &m920x_table[5], NULL },
867 },
868 }
869};
870
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300871static struct usb_driver m920x_driver = {
872 .name = "dvb_usb_m920x",
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300873 .probe = m920x_probe,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300874 .disconnect = dvb_usb_device_exit,
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300875 .id_table = m920x_table,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300876};
877
878/* module stuff */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300879static int __init m920x_module_init(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300880{
881 int ret;
882
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300883 if ((ret = usb_register(&m920x_driver))) {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300884 err("usb_register failed. Error number %d", ret);
885 return ret;
886 }
887
888 return 0;
889}
890
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300891static void __exit m920x_module_exit(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300892{
893 /* deregister this driver from the USB subsystem */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300894 usb_deregister(&m920x_driver);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300895}
896
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300897module_init (m920x_module_init);
898module_exit (m920x_module_exit);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300899
900MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
Nick Andrewaa50ec22007-03-22 17:09:35 -0300901MODULE_DESCRIPTION("DVB Driver for ULI M920x");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300902MODULE_VERSION("0.1");
903MODULE_LICENSE("GPL");
Michael Krufkyce9c2752007-03-22 17:18:26 -0300904
905/*
906 * Local variables:
907 * c-basic-offset: 8
908 */