blob: a12e6f784fdae92aade0f2b08040f93948206155 [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
Janne Grunau78e92002008-04-09 19:13:13 -030025DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
26
Aapo Tahkola47f8df02007-05-08 12:03:55 -030027static int m920x_set_filter(struct dvb_usb_device *d, int type, int idx, int pid);
28
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030029static inline int m920x_read(struct usb_device *udev, u8 request, u16 value,
Michael Krufkyfa948052007-01-21 15:57:48 -030030 u16 index, void *data, int size)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030031{
32 int ret;
33
34 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
35 request, USB_TYPE_VENDOR | USB_DIR_IN,
36 value, index, data, size, 2000);
Pierre Willenbrock59069e52007-03-15 13:24:29 -030037 if (ret < 0) {
38 printk(KERN_INFO "m920x_read = error: %d\n", ret);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030039 return ret;
Pierre Willenbrock59069e52007-03-15 13:24:29 -030040 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030041
Pierre Willenbrock59069e52007-03-15 13:24:29 -030042 if (ret != size) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -030043 deb("m920x_read = no data\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030044 return -EIO;
Pierre Willenbrock59069e52007-03-15 13:24:29 -030045 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030046
47 return 0;
48}
49
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030050static inline int m920x_write(struct usb_device *udev, u8 request,
Michael Krufkyfa948052007-01-21 15:57:48 -030051 u16 value, u16 index)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030052{
53 int ret;
54
55 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
56 request, USB_TYPE_VENDOR | USB_DIR_OUT,
57 value, index, NULL, 0, 2000);
Pierre Willenbrock59069e52007-03-15 13:24:29 -030058
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030059 return ret;
60}
61
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030062static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030063{
Aapo Tahkola3847b222007-05-08 18:21:47 -030064 int ret = 0, i, epi, flags = 0;
Aapo Tahkola47f8df02007-05-08 12:03:55 -030065 int adap_enabled[M9206_MAX_ADAPTERS] = { 0 };
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030066
67 /* Remote controller init. */
Aapo Tahkola480ac762007-03-05 18:54:27 -030068 if (d->props.rc_query) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -030069 deb("Initialising remote control\n");
Nick Andrewaa50ec22007-03-22 17:09:35 -030070 while (rc_seq->address) {
Aapo Tahkola4fd74a72007-03-26 17:05:59 -030071 if ((ret = m920x_write(d->udev, M9206_CORE,
Michael Krufkyd3911ea2007-03-22 19:03:37 -030072 rc_seq->data,
73 rc_seq->address)) != 0) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -030074 deb("Initialising remote control failed\n");
Nick Andrewaa50ec22007-03-22 17:09:35 -030075 return ret;
76 }
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030077
Nick Andrewaa50ec22007-03-22 17:09:35 -030078 rc_seq++;
79 }
80
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -030081 deb("Initialising remote control success\n");
Aapo Tahkola480ac762007-03-05 18:54:27 -030082 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030083
Aapo Tahkola3847b222007-05-08 18:21:47 -030084 for (i = 0; i < d->props.num_adapters; i++)
85 flags |= d->adapter[i].props.caps;
Aapo Tahkola47f8df02007-05-08 12:03:55 -030086
Aapo Tahkola3847b222007-05-08 18:21:47 -030087 /* Some devices(Dposh) might crash if we attempt touch at all. */
88 if (flags & DVB_USB_ADAP_HAS_PID_FILTER) {
89 for (i = 0; i < d->props.num_adapters; i++) {
90 epi = d->adapter[i].props.stream.endpoint - 0x81;
91
92 if (epi < 0 || epi >= M9206_MAX_ADAPTERS) {
93 printk(KERN_INFO "m920x: Unexpected adapter endpoint!\n");
94 return -EINVAL;
95 }
96
97 adap_enabled[epi] = 1;
Aapo Tahkola47f8df02007-05-08 12:03:55 -030098 }
99
Aapo Tahkola3847b222007-05-08 18:21:47 -0300100 for (i = 0; i < M9206_MAX_ADAPTERS; i++) {
101 if (adap_enabled[i])
102 continue;
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300103
Aapo Tahkola3847b222007-05-08 18:21:47 -0300104 if ((ret = m920x_set_filter(d, 0x81 + i, 0, 0x0)) != 0)
105 return ret;
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300106
Aapo Tahkola3847b222007-05-08 18:21:47 -0300107 if ((ret = m920x_set_filter(d, 0x81 + i, 0, 0x02f5)) != 0)
108 return ret;
109 }
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300110 }
111
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300112 return ret;
113}
114
Aapo Tahkola55bbe5e2007-05-08 12:56:54 -0300115static int m920x_init_ep(struct usb_interface *intf)
116{
117 struct usb_device *udev = interface_to_usbdev(intf);
118 struct usb_host_interface *alt;
119
120 if ((alt = usb_altnum_to_altsetting(intf, 1)) == NULL) {
121 deb("No alt found!\n");
122 return -ENODEV;
123 }
124
125 return usb_set_interface(udev, alt->desc.bInterfaceNumber,
126 alt->desc.bAlternateSetting);
127}
128
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300129static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300130{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300131 struct m920x_state *m = d->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300132 int i, ret = 0;
133 u8 rc_state[2];
134
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300135 if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300136 goto unlock;
137
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300138 if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300139 goto unlock;
140
Aapo Tahkola480ac762007-03-05 18:54:27 -0300141 for (i = 0; i < d->props.rc_key_map_size; i++)
142 if (d->props.rc_key_map[i].data == rc_state[1]) {
143 *event = d->props.rc_key_map[i].event;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300144
145 switch(rc_state[0]) {
146 case 0x80:
147 *state = REMOTE_NO_KEY_PRESSED;
148 goto unlock;
149
Nick Andrewaa50ec22007-03-22 17:09:35 -0300150 case 0x88: /* framing error or "invalid code" */
151 case 0x99:
152 case 0xc0:
153 case 0xd8:
154 *state = REMOTE_NO_KEY_PRESSED;
155 m->rep_count = 0;
156 goto unlock;
157
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300158 case 0x93:
159 case 0x92:
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300160 m->rep_count = 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300161 *state = REMOTE_KEY_PRESSED;
162 goto unlock;
163
164 case 0x91:
Nick Andrewaa50ec22007-03-22 17:09:35 -0300165 /* prevent immediate auto-repeat */
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300166 if (++m->rep_count > 2)
167 *state = REMOTE_KEY_REPEAT;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300168 else
169 *state = REMOTE_NO_KEY_PRESSED;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300170 goto unlock;
171
172 default:
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300173 deb("Unexpected rc state %02x\n", rc_state[0]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300174 *state = REMOTE_NO_KEY_PRESSED;
175 goto unlock;
176 }
177 }
178
179 if (rc_state[1] != 0)
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300180 deb("Unknown rc key %02x\n", rc_state[1]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300181
182 *state = REMOTE_NO_KEY_PRESSED;
183
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300184 unlock:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300185
186 return ret;
187}
188
189/* I2C */
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300190static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300191{
192 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Aapo Tahkola26247012007-03-05 18:23:19 -0300193 int i, j;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300194 int ret = 0;
195
Trent Piephod40860f2007-03-05 23:55:00 -0300196 if (!num)
197 return -EINVAL;
198
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300199 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
200 return -EAGAIN;
201
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300202 for (i = 0; i < num; i++) {
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300203 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 -0300204 /* For a 0 byte message, I think sending the address
205 * to index 0x80|0x40 would be the correct thing to
206 * do. However, zero byte messages are only used for
207 * probing, and since we don't know how to get the
208 * slave's ack, we can't probe. */
Trent Piephod40860f2007-03-05 23:55:00 -0300209 ret = -ENOTSUPP;
210 goto unlock;
211 }
212 /* Send START & address/RW bit */
213 if (!(msg[i].flags & I2C_M_NOSTART)) {
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300214 if ((ret = m920x_write(d->udev, M9206_I2C,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300215 (msg[i].addr << 1) |
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300216 (msg[i].flags & I2C_M_RD ? 0x01 : 0), 0x80)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300217 goto unlock;
218 /* Should check for ack here, if we knew how. */
219 }
Aapo Tahkola26247012007-03-05 18:23:19 -0300220 if (msg[i].flags & I2C_M_RD) {
Trent Piephod40860f2007-03-05 23:55:00 -0300221 for (j = 0; j < msg[i].len; j++) {
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300222 /* Last byte of transaction?
223 * Send STOP, otherwise send ACK. */
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300224 int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x01;
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300225
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300226 if ((ret = m920x_read(d->udev, M9206_I2C, 0x0,
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300227 0x20 | stop,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300228 &msg[i].buf[j], 1)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300229 goto unlock;
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300230 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300231 } else {
Trent Piephod40860f2007-03-05 23:55:00 -0300232 for (j = 0; j < msg[i].len; j++) {
233 /* Last byte of transaction? Then send STOP. */
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300234 int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x00;
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300235
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300236 if ((ret = m920x_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0)
Trent Piephod40860f2007-03-05 23:55:00 -0300237 goto unlock;
238 /* Should check for ack here too. */
Aapo Tahkola26247012007-03-05 18:23:19 -0300239 }
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300240 }
241 }
Aapo Tahkola26247012007-03-05 18:23:19 -0300242 ret = num;
Trent Piephod40860f2007-03-05 23:55:00 -0300243
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300244 unlock:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300245 mutex_unlock(&d->i2c_mutex);
246
247 return ret;
248}
249
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300250static u32 m920x_i2c_func(struct i2c_adapter *adapter)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300251{
252 return I2C_FUNC_I2C;
253}
254
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300255static struct i2c_algorithm m920x_i2c_algo = {
256 .master_xfer = m920x_i2c_xfer,
257 .functionality = m920x_i2c_func,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300258};
259
Michael Krufky5afb7072007-03-26 16:35:29 -0300260/* pid filter */
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300261static int m920x_set_filter(struct dvb_usb_device *d, int type, int idx, int pid)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300262{
263 int ret = 0;
264
265 if (pid >= 0x8000)
266 return -EINVAL;
267
268 pid |= 0x8000;
269
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300270 if ((ret = m920x_write(d->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300271 return ret;
272
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300273 if ((ret = m920x_write(d->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300274 return ret;
275
276 return ret;
277}
278
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300279static int m920x_update_filters(struct dvb_usb_adapter *adap)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300280{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300281 struct m920x_state *m = adap->dev->priv;
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300282 int enabled = m->filtering_enabled[adap->id];
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300283 int i, ret = 0, filter = 0;
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300284 int ep = adap->props.stream.endpoint;
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300285
286 for (i = 0; i < M9206_MAX_FILTERS; i++)
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300287 if (m->filters[adap->id][i] == 8192)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300288 enabled = 0;
289
290 /* Disable all filters */
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300291 if ((ret = m920x_set_filter(adap->dev, ep, 1, enabled)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300292 return ret;
293
294 for (i = 0; i < M9206_MAX_FILTERS; i++)
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300295 if ((ret = m920x_set_filter(adap->dev, ep, i + 2, 0)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300296 return ret;
297
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300298 /* Set */
299 if (enabled) {
300 for (i = 0; i < M9206_MAX_FILTERS; i++) {
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300301 if (m->filters[adap->id][i] == 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300302 continue;
303
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300304 if ((ret = m920x_set_filter(adap->dev, ep, filter + 2, m->filters[adap->id][i])) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300305 return ret;
306
307 filter++;
308 }
309 }
310
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300311 return ret;
312}
313
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300314static int m920x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300315{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300316 struct m920x_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300317
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300318 m->filtering_enabled[adap->id] = onoff ? 1 : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300319
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300320 return m920x_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300321}
322
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300323static int m920x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300324{
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300325 struct m920x_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300326
Aapo Tahkola47f8df02007-05-08 12:03:55 -0300327 m->filters[adap->id][index] = onoff ? pid : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300328
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300329 return m920x_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300330}
331
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300332static int m920x_firmware_download(struct usb_device *udev, const struct firmware *fw)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300333{
334 u16 value, index, size;
335 u8 read[4], *buff;
336 int i, pass, ret = 0;
337
338 buff = kmalloc(65536, GFP_KERNEL);
339
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300340 if ((ret = m920x_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300341 goto done;
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300342 deb("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300343
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300344 if ((ret = m920x_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300345 goto done;
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300346 deb("%x\n", read[0]);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300347
348 for (pass = 0; pass < 2; pass++) {
349 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
350 value = le16_to_cpu(*(u16 *)(fw->data + i));
351 i += sizeof(u16);
352
353 index = le16_to_cpu(*(u16 *)(fw->data + i));
354 i += sizeof(u16);
355
356 size = le16_to_cpu(*(u16 *)(fw->data + i));
357 i += sizeof(u16);
358
359 if (pass == 1) {
360 /* Will stall if using fw->data ... */
361 memcpy(buff, fw->data + i, size);
362
363 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300364 M9206_FW,
365 USB_TYPE_VENDOR | USB_DIR_OUT,
366 value, index, buff, size, 20);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300367 if (ret != size) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300368 deb("error while uploading fw!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300369 ret = -EIO;
370 goto done;
371 }
372 msleep(3);
373 }
374 i += size;
375 }
376 if (i != fw->size) {
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300377 deb("bad firmware file!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300378 ret = -EINVAL;
379 goto done;
380 }
381 }
382
383 msleep(36);
384
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300385 /* m920x will disconnect itself from the bus after this. */
386 (void) m920x_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300387 deb("firmware uploaded!\n");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300388
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300389 done:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300390 kfree(buff);
391
392 return ret;
393}
394
Michael Krufkye16c1f52007-01-23 15:00:42 -0300395/* Callbacks for DVB USB */
Aapo Tahkola7d1d4e62007-03-15 13:01:46 -0300396static int m920x_identify_state(struct usb_device *udev,
397 struct dvb_usb_device_properties *props,
398 struct dvb_usb_device_description **desc,
399 int *cold)
Michael Krufkye16c1f52007-01-23 15:00:42 -0300400{
401 struct usb_host_interface *alt;
402
403 alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
404 *cold = (alt == NULL) ? 1 : 0;
405
406 return 0;
407}
408
Michael Krufky5afb7072007-03-26 16:35:29 -0300409/* demod configurations */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300410static int m920x_mt352_demod_init(struct dvb_frontend *fe)
Michael Krufkye16c1f52007-01-23 15:00:42 -0300411{
Aapo Tahkolad577ee02007-05-08 18:33:52 -0300412 int ret;
Michael Krufkye16c1f52007-01-23 15:00:42 -0300413 u8 config[] = { CONFIG, 0x3d };
414 u8 clock[] = { CLOCK_CTL, 0x30 };
415 u8 reset[] = { RESET, 0x80 };
416 u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
417 u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
418 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
419 u8 unk1[] = { 0x93, 0x1a };
420 u8 unk2[] = { 0xb5, 0x7a };
421
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300422 deb("Demod init!\n");
Michael Krufkye16c1f52007-01-23 15:00:42 -0300423
Aapo Tahkolad577ee02007-05-08 18:33:52 -0300424 if ((ret = mt352_write(fe, config, ARRAY_SIZE(config))) != 0)
425 return ret;
426 if ((ret = mt352_write(fe, clock, ARRAY_SIZE(clock))) != 0)
427 return ret;
428 if ((ret = mt352_write(fe, reset, ARRAY_SIZE(reset))) != 0)
429 return ret;
430 if ((ret = mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl))) != 0)
431 return ret;
432 if ((ret = mt352_write(fe, agc, ARRAY_SIZE(agc))) != 0)
433 return ret;
434 if ((ret = mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc))) != 0)
435 return ret;
436 if ((ret = mt352_write(fe, unk1, ARRAY_SIZE(unk1))) != 0)
437 return ret;
438 if ((ret = mt352_write(fe, unk2, ARRAY_SIZE(unk2))) != 0)
439 return ret;
440
Michael Krufkye16c1f52007-01-23 15:00:42 -0300441 return 0;
442}
443
Michael Krufkye7b419b2007-03-26 16:39:20 -0300444static struct mt352_config m920x_mt352_config = {
Aapo Tahkola26247012007-03-05 18:23:19 -0300445 .demod_address = 0x0f,
Michael Krufkye16c1f52007-01-23 15:00:42 -0300446 .no_tuner = 1,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300447 .demod_init = m920x_mt352_demod_init,
Michael Krufkye16c1f52007-01-23 15:00:42 -0300448};
449
Michael Krufkye7b419b2007-03-26 16:39:20 -0300450static struct tda1004x_config m920x_tda10046_08_config = {
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300451 .demod_address = 0x08,
452 .invert = 0,
453 .invert_oclk = 0,
454 .ts_mode = TDA10046_TS_SERIAL,
455 .xtal_freq = TDA10046_XTAL_16M,
456 .if_freq = TDA10046_FREQ_045,
457 .agc_config = TDA10046_AGC_TDA827X,
458 .gpio_config = TDA10046_GPTRI,
459 .request_firmware = NULL,
460};
461
Michael Krufkye7b419b2007-03-26 16:39:20 -0300462static struct tda1004x_config m920x_tda10046_0b_config = {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300463 .demod_address = 0x0b,
464 .invert = 0,
465 .invert_oclk = 0,
466 .ts_mode = TDA10046_TS_SERIAL,
467 .xtal_freq = TDA10046_XTAL_16M,
468 .if_freq = TDA10046_FREQ_045,
469 .agc_config = TDA10046_AGC_TDA827X,
470 .gpio_config = TDA10046_GPTRI,
471 .request_firmware = NULL, /* uses firmware EEPROM */
472};
473
Michael Krufky5afb7072007-03-26 16:35:29 -0300474/* tuner configurations */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300475static struct qt1010_config m920x_qt1010_config = {
Michael Krufky5afb7072007-03-26 16:35:29 -0300476 .i2c_address = 0x62
477};
478
479/* Callbacks for DVB USB */
Michael Krufkye7b419b2007-03-26 16:39:20 -0300480static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300481{
Harvey Harrison708bebd2008-04-08 23:20:00 -0300482 deb("%s\n",__func__);
Michael Krufky5afb7072007-03-26 16:35:29 -0300483
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300484 if ((adap->fe = dvb_attach(mt352_attach,
485 &m920x_mt352_config,
Michael Krufky5afb7072007-03-26 16:35:29 -0300486 &adap->dev->i2c_adap)) == NULL)
487 return -EIO;
488
489 return 0;
490}
491
Michael Krufkye7b419b2007-03-26 16:39:20 -0300492static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300493{
Harvey Harrison708bebd2008-04-08 23:20:00 -0300494 deb("%s\n",__func__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300495
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300496 if ((adap->fe = dvb_attach(tda10046_attach,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300497 &m920x_tda10046_08_config,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300498 &adap->dev->i2c_adap)) == NULL)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300499 return -EIO;
500
Nick Andrewaa50ec22007-03-22 17:09:35 -0300501 return 0;
502}
503
Michael Krufkye7b419b2007-03-26 16:39:20 -0300504static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300505{
Harvey Harrison708bebd2008-04-08 23:20:00 -0300506 deb("%s\n",__func__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300507
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300508 if ((adap->fe = dvb_attach(tda10046_attach,
Michael Krufkye7b419b2007-03-26 16:39:20 -0300509 &m920x_tda10046_0b_config,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300510 &adap->dev->i2c_adap)) == NULL)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300511 return -EIO;
512
Nick Andrewaa50ec22007-03-22 17:09:35 -0300513 return 0;
514}
515
Michael Krufkye7b419b2007-03-26 16:39:20 -0300516static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300517{
Harvey Harrison708bebd2008-04-08 23:20:00 -0300518 deb("%s\n",__func__);
Michael Krufkye7b419b2007-03-26 16:39:20 -0300519
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300520 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL)
Michael Krufky5afb7072007-03-26 16:35:29 -0300521 return -ENODEV;
522
523 return 0;
524}
525
Michael Krufkye7b419b2007-03-26 16:39:20 -0300526static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky5afb7072007-03-26 16:35:29 -0300527{
Harvey Harrison708bebd2008-04-08 23:20:00 -0300528 deb("%s\n",__func__);
Michael Krufkye7b419b2007-03-26 16:39:20 -0300529
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300530 if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL)
Michael Krufky5afb7072007-03-26 16:35:29 -0300531 return -ENODEV;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300532
533 return 0;
534}
535
Michael Krufkye7b419b2007-03-26 16:39:20 -0300536static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300537{
Harvey Harrison708bebd2008-04-08 23:20:00 -0300538 deb("%s\n",__func__);
Nick Andrewaa50ec22007-03-22 17:09:35 -0300539
Aapo Tahkola9ad4eef2007-04-20 13:34:25 -0300540 if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL)
Nick Andrewaa50ec22007-03-22 17:09:35 -0300541 return -ENODEV;
542
Nick Andrewaa50ec22007-03-22 17:09:35 -0300543 return 0;
544}
545
Michael Krufky5afb7072007-03-26 16:35:29 -0300546/* device-specific initialization */
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300547static struct m920x_inits megasky_rc_init [] = {
Michael Krufky5afb7072007-03-26 16:35:29 -0300548 { M9206_RC_INIT2, 0xa8 },
549 { M9206_RC_INIT1, 0x51 },
550 { } /* terminating entry */
551};
552
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300553static struct m920x_inits tvwalkertwin_rc_init [] = {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300554 { M9206_RC_INIT2, 0x00 },
555 { M9206_RC_INIT1, 0xef },
556 { 0xff28, 0x00 },
557 { 0xff23, 0x00 },
558 { 0xff21, 0x30 },
559 { } /* terminating entry */
560};
561
Michael Krufky5afb7072007-03-26 16:35:29 -0300562/* ir keymaps */
563static struct dvb_usb_rc_key megasky_rc_keys [] = {
564 { 0x0, 0x12, KEY_POWER },
565 { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */
566 { 0x0, 0x02, KEY_CHANNELUP },
567 { 0x0, 0x05, KEY_CHANNELDOWN },
568 { 0x0, 0x03, KEY_VOLUMEUP },
569 { 0x0, 0x06, KEY_VOLUMEDOWN },
570 { 0x0, 0x04, KEY_MUTE },
571 { 0x0, 0x07, KEY_OK }, /* TS */
572 { 0x0, 0x08, KEY_STOP },
573 { 0x0, 0x09, KEY_MENU }, /* swap */
574 { 0x0, 0x0a, KEY_REWIND },
575 { 0x0, 0x1b, KEY_PAUSE },
576 { 0x0, 0x1f, KEY_FASTFORWARD },
577 { 0x0, 0x0c, KEY_RECORD },
578 { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */
579 { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
580};
581
582static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
583 { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */
584 { 0x0, 0x02, KEY_CAMERA }, /* snapshot */
585 { 0x0, 0x03, KEY_MUTE },
586 { 0x0, 0x04, KEY_REWIND },
587 { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */
588 { 0x0, 0x06, KEY_FASTFORWARD },
589 { 0x0, 0x07, KEY_RECORD },
590 { 0x0, 0x08, KEY_STOP },
591 { 0x0, 0x09, KEY_TIME }, /* Timeshift */
592 { 0x0, 0x0c, KEY_COFFEE }, /* Recall */
593 { 0x0, 0x0e, KEY_CHANNELUP },
594 { 0x0, 0x12, KEY_POWER },
595 { 0x0, 0x15, KEY_MENU }, /* source */
596 { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */
597 { 0x0, 0x1a, KEY_CHANNELDOWN },
598 { 0x0, 0x1b, KEY_VOLUMEDOWN },
599 { 0x0, 0x1e, KEY_VOLUMEUP },
600};
601
Michael Krufky26f48ea2006-09-28 01:46:49 -0300602/* DVB USB Driver stuff */
603static struct dvb_usb_device_properties megasky_properties;
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300604static struct dvb_usb_device_properties digivox_mini_ii_properties;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300605static struct dvb_usb_device_properties tvwalkertwin_properties;
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300606static struct dvb_usb_device_properties dposh_properties;
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300607
Michael Krufkyfa948052007-01-21 15:57:48 -0300608static int m920x_probe(struct usb_interface *intf,
609 const struct usb_device_id *id)
Michael Krufky26f48ea2006-09-28 01:46:49 -0300610{
Aapo Tahkola55bbe5e2007-05-08 12:56:54 -0300611 struct dvb_usb_device *d = NULL;
Michael Krufky26f48ea2006-09-28 01:46:49 -0300612 int ret;
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300613 struct m920x_inits *rc_init_seq = NULL;
Nick Andrewaa50ec22007-03-22 17:09:35 -0300614 int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber;
Michael Krufky26f48ea2006-09-28 01:46:49 -0300615
Aapo Tahkolabf2b4f62007-03-26 16:59:16 -0300616 deb("Probing for m920x device at interface %d\n", bInterfaceNumber);
Michael Krufky26f48ea2006-09-28 01:46:49 -0300617
Nick Andrewaa50ec22007-03-22 17:09:35 -0300618 if (bInterfaceNumber == 0) {
619 /* Single-tuner device, or first interface on
620 * multi-tuner device
621 */
Michael Krufky26f48ea2006-09-28 01:46:49 -0300622
Janne Grunau78e92002008-04-09 19:13:13 -0300623 ret = dvb_usb_device_init(intf, &megasky_properties,
624 THIS_MODULE, &d, adapter_nr);
625 if (ret == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300626 rc_init_seq = megasky_rc_init;
627 goto found;
628 }
629
Janne Grunau78e92002008-04-09 19:13:13 -0300630 ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties,
631 THIS_MODULE, &d, adapter_nr);
632 if (ret == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300633 /* No remote control, so no rc_init_seq */
634 goto found;
635 }
636
637 /* This configures both tuners on the TV Walker Twin */
Janne Grunau78e92002008-04-09 19:13:13 -0300638 ret = dvb_usb_device_init(intf, &tvwalkertwin_properties,
639 THIS_MODULE, &d, adapter_nr);
640 if (ret == 0) {
Nick Andrewaa50ec22007-03-22 17:09:35 -0300641 rc_init_seq = tvwalkertwin_rc_init;
642 goto found;
643 }
644
Janne Grunau78e92002008-04-09 19:13:13 -0300645 ret = dvb_usb_device_init(intf, &dposh_properties,
646 THIS_MODULE, &d, adapter_nr);
647 if (ret == 0) {
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300648 /* Remote controller not supported yet. */
649 goto found;
650 }
651
Nick Andrewaa50ec22007-03-22 17:09:35 -0300652 return ret;
653 } else {
654 /* Another interface on a multi-tuner device */
655
656 /* The LifeView TV Walker Twin gets here, but struct
657 * tvwalkertwin_properties already configured both
658 * tuners, so there is nothing for us to do here
659 */
Nick Andrewaa50ec22007-03-22 17:09:35 -0300660 }
Michael Krufky26f48ea2006-09-28 01:46:49 -0300661
Michael Krufkye7b419b2007-03-26 16:39:20 -0300662 found:
Aapo Tahkola55bbe5e2007-05-08 12:56:54 -0300663 if ((ret = m920x_init_ep(intf)) < 0)
Aapo Tahkola480ac762007-03-05 18:54:27 -0300664 return ret;
665
Aapo Tahkola55bbe5e2007-05-08 12:56:54 -0300666 if (d && (ret = m920x_init(d, rc_init_seq)) != 0)
Aapo Tahkola480ac762007-03-05 18:54:27 -0300667 return ret;
668
Michael Krufky26f48ea2006-09-28 01:46:49 -0300669 return ret;
670}
671
672static struct usb_device_id m920x_table [] = {
673 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300674 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
675 USB_PID_MSI_DIGI_VOX_MINI_II) },
Nick Andrewaa50ec22007-03-22 17:09:35 -0300676 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
677 USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) },
678 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
679 USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) },
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300680 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) },
681 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) },
Michael Krufky26f48ea2006-09-28 01:46:49 -0300682 { } /* Terminating entry */
683};
684MODULE_DEVICE_TABLE (usb, m920x_table);
685
Michael Krufky01cb34d2006-09-23 20:01:29 -0300686static struct dvb_usb_device_properties megasky_properties = {
Michael Krufky758117c2007-01-23 15:34:10 -0300687 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
Michael Krufky1f61f3b2006-10-07 15:03:04 -0300688
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300689 .usb_ctrl = DEVICE_SPECIFIC,
690 .firmware = "dvb-usb-megasky-02.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300691 .download_firmware = m920x_firmware_download,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300692
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300693 .rc_interval = 100,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300694 .rc_key_map = megasky_rc_keys,
695 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys),
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300696 .rc_query = m920x_rc_query,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300697
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300698 .size_of_priv = sizeof(struct m920x_state),
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300699
Aapo Tahkola7d1d4e62007-03-15 13:01:46 -0300700 .identify_state = m920x_identify_state,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300701 .num_adapters = 1,
702 .adapter = {{
Michael Krufky758117c2007-01-23 15:34:10 -0300703 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
704 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
705
Michael Krufky01cb34d2006-09-23 20:01:29 -0300706 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300707 .pid_filter = m920x_pid_filter,
708 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300709
Michael Krufkye7b419b2007-03-26 16:39:20 -0300710 .frontend_attach = m920x_mt352_frontend_attach,
711 .tuner_attach = m920x_qt1010_tuner_attach,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300712
713 .stream = {
714 .type = USB_BULK,
715 .count = 8,
716 .endpoint = 0x81,
717 .u = {
718 .bulk = {
719 .buffersize = 512,
720 }
721 }
722 },
723 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300724 .i2c_algo = &m920x_i2c_algo,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300725
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300726 .num_device_descs = 1,
727 .devices = {
728 { "MSI Mega Sky 580 DVB-T USB2.0",
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300729 { &m920x_table[0], NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300730 { NULL },
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300731 }
732 }
733};
734
735static struct dvb_usb_device_properties digivox_mini_ii_properties = {
736 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
737
738 .usb_ctrl = DEVICE_SPECIFIC,
739 .firmware = "dvb-usb-digivox-02.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300740 .download_firmware = m920x_firmware_download,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300741
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300742 .size_of_priv = sizeof(struct m920x_state),
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300743
744 .identify_state = m920x_identify_state,
745 .num_adapters = 1,
746 .adapter = {{
747 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300748 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300749
750 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300751 .pid_filter = m920x_pid_filter,
752 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300753
Michael Krufkye7b419b2007-03-26 16:39:20 -0300754 .frontend_attach = m920x_tda10046_08_frontend_attach,
755 .tuner_attach = m920x_tda8275_60_tuner_attach,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300756
757 .stream = {
758 .type = USB_BULK,
759 .count = 8,
760 .endpoint = 0x81,
761 .u = {
762 .bulk = {
763 .buffersize = 0x4000,
764 }
765 }
766 },
767 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300768 .i2c_algo = &m920x_i2c_algo,
Pierre Willenbrockd4ca23b2007-03-18 19:54:07 -0300769
770 .num_device_descs = 1,
771 .devices = {
772 { "MSI DIGI VOX mini II DVB-T USB2.0",
773 { &m920x_table[1], NULL },
774 { NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300775 },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300776 }
777};
778
Michael Krufkye7b419b2007-03-26 16:39:20 -0300779/* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
780 *
781 * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
782 * TDA10046 #0 is located at i2c address 0x08
Aapo Tahkola3ab3b692007-05-08 18:23:38 -0300783 * TDA10046 #1 is located at i2c address 0x0b
Michael Krufkye7b419b2007-03-26 16:39:20 -0300784 * TDA8275A #0 is located at i2c address 0x60
Aapo Tahkola3ab3b692007-05-08 18:23:38 -0300785 * TDA8275A #1 is located at i2c address 0x61
Michael Krufkye7b419b2007-03-26 16:39:20 -0300786 */
Nick Andrewaa50ec22007-03-22 17:09:35 -0300787static struct dvb_usb_device_properties tvwalkertwin_properties = {
788 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
789
790 .usb_ctrl = DEVICE_SPECIFIC,
791 .firmware = "dvb-usb-tvwalkert.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300792 .download_firmware = m920x_firmware_download,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300793
794 .rc_interval = 100,
795 .rc_key_map = tvwalkertwin_rc_keys,
796 .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys),
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300797 .rc_query = m920x_rc_query,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300798
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300799 .size_of_priv = sizeof(struct m920x_state),
Nick Andrewaa50ec22007-03-22 17:09:35 -0300800
801 .identify_state = m920x_identify_state,
Aapo Tahkola3ab3b692007-05-08 18:23:38 -0300802 .num_adapters = 2,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300803 .adapter = {{
804 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
805 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300806
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300807 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300808 .pid_filter = m920x_pid_filter,
809 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300810
Michael Krufkye7b419b2007-03-26 16:39:20 -0300811 .frontend_attach = m920x_tda10046_08_frontend_attach,
812 .tuner_attach = m920x_tda8275_60_tuner_attach,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300813
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300814 .stream = {
815 .type = USB_BULK,
816 .count = 8,
817 .endpoint = 0x81,
818 .u = {
819 .bulk = {
820 .buffersize = 512,
821 }
822 }
823 }},{
824 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
825 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
826
827 .pid_filter_count = 8,
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300828 .pid_filter = m920x_pid_filter,
829 .pid_filter_ctrl = m920x_pid_filter_ctrl,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300830
Michael Krufkye7b419b2007-03-26 16:39:20 -0300831 .frontend_attach = m920x_tda10046_0b_frontend_attach,
832 .tuner_attach = m920x_tda8275_61_tuner_attach,
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300833
834 .stream = {
835 .type = USB_BULK,
836 .count = 8,
837 .endpoint = 0x82,
838 .u = {
839 .bulk = {
840 .buffersize = 512,
841 }
842 }
Nick Andrewaa50ec22007-03-22 17:09:35 -0300843 },
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300844 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300845 .i2c_algo = &m920x_i2c_algo,
Nick Andrewaa50ec22007-03-22 17:09:35 -0300846
847 .num_device_descs = 1,
848 .devices = {
849 { .name = "LifeView TV Walker Twin DVB-T USB2.0",
850 .cold_ids = { &m920x_table[2], NULL },
851 .warm_ids = { &m920x_table[3], NULL },
852 },
853 }
854};
855
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300856static struct dvb_usb_device_properties dposh_properties = {
857 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
858
859 .usb_ctrl = DEVICE_SPECIFIC,
860 .firmware = "dvb-usb-dposh-01.fw",
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300861 .download_firmware = m920x_firmware_download,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300862
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300863 .size_of_priv = sizeof(struct m920x_state),
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300864
865 .identify_state = m920x_identify_state,
866 .num_adapters = 1,
867 .adapter = {{
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300868 /* Hardware pid filters don't work with this device/firmware */
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300869
Michael Krufkye7b419b2007-03-26 16:39:20 -0300870 .frontend_attach = m920x_mt352_frontend_attach,
871 .tuner_attach = m920x_qt1010_tuner_attach,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300872
Michael Krufkyd3911ea2007-03-22 19:03:37 -0300873 .stream = {
874 .type = USB_BULK,
875 .count = 8,
876 .endpoint = 0x81,
877 .u = {
878 .bulk = {
879 .buffersize = 512,
880 }
881 }
882 },
883 }},
Aapo Tahkola4fd74a72007-03-26 17:05:59 -0300884 .i2c_algo = &m920x_i2c_algo,
Aapo Tahkolaf8e0bd52007-03-22 17:37:58 -0300885
886 .num_device_descs = 1,
887 .devices = {
888 { .name = "Dposh DVB-T USB2.0",
889 .cold_ids = { &m920x_table[4], NULL },
890 .warm_ids = { &m920x_table[5], NULL },
891 },
892 }
893};
894
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300895static struct usb_driver m920x_driver = {
896 .name = "dvb_usb_m920x",
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300897 .probe = m920x_probe,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300898 .disconnect = dvb_usb_device_exit,
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300899 .id_table = m920x_table,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300900};
901
902/* module stuff */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300903static int __init m920x_module_init(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300904{
905 int ret;
906
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300907 if ((ret = usb_register(&m920x_driver))) {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300908 err("usb_register failed. Error number %d", ret);
909 return ret;
910 }
911
912 return 0;
913}
914
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300915static void __exit m920x_module_exit(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300916{
917 /* deregister this driver from the USB subsystem */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300918 usb_deregister(&m920x_driver);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300919}
920
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300921module_init (m920x_module_init);
922module_exit (m920x_module_exit);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300923
924MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
Nick Andrewaa50ec22007-03-22 17:09:35 -0300925MODULE_DESCRIPTION("DVB Driver for ULI M920x");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300926MODULE_VERSION("0.1");
927MODULE_LICENSE("GPL");
Michael Krufkyce9c2752007-03-22 17:18:26 -0300928
929/*
930 * Local variables:
931 * c-basic-offset: 8
932 */