blob: f06fee3af9e626f7ad881da34b3ce6f0594e07e8 [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
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation, version 2.
8 *
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"
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030017
18/* debug */
Michael Krufky26f48ea2006-09-28 01:46:49 -030019static int dvb_usb_m920x_debug;
Michael Krufkybaa2ed02006-09-23 20:01:29 -030020module_param_named(debug,dvb_usb_m920x_debug, int, 0644);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030021MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
22
23static struct dvb_usb_rc_key megasky_rc_keys [] = {
24 { 0x0, 0x12, KEY_POWER },
25 { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */
26 { 0x0, 0x02, KEY_CHANNELUP },
27 { 0x0, 0x05, KEY_CHANNELDOWN },
28 { 0x0, 0x03, KEY_VOLUMEUP },
29 { 0x0, 0x06, KEY_VOLUMEDOWN },
30 { 0x0, 0x04, KEY_MUTE },
31 { 0x0, 0x07, KEY_OK }, /* TS */
32 { 0x0, 0x08, KEY_STOP },
33 { 0x0, 0x09, KEY_MENU }, /* swap */
34 { 0x0, 0x0a, KEY_REWIND },
35 { 0x0, 0x1b, KEY_PAUSE },
36 { 0x0, 0x1f, KEY_FASTFORWARD },
37 { 0x0, 0x0c, KEY_RECORD },
38 { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */
39 { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
40};
41
42static inline int m9206_read(struct usb_device *udev, u8 request, u16 value, u16 index, void *data, int size)
43{
44 int ret;
45
46 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
47 request, USB_TYPE_VENDOR | USB_DIR_IN,
48 value, index, data, size, 2000);
49 if (ret < 0)
50 return ret;
51
52 if (ret != size)
53 return -EIO;
54
55 return 0;
56}
57
58static inline int m9206_write(struct usb_device *udev, u8 request, u16 value, u16 index)
59{
60 int ret;
61
62 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
63 request, USB_TYPE_VENDOR | USB_DIR_OUT,
64 value, index, NULL, 0, 2000);
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030065 return ret;
66}
67
68static int m9206_rc_init(struct usb_device *udev)
69{
70 int ret = 0;
71
72 /* Remote controller init. */
73 if ((ret = m9206_write(udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0)
74 return ret;
75
76 if ((ret = m9206_write(udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0)
77 return ret;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030078
79 return ret;
80}
81
82static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
83{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030084 struct m9206_state *m = d->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030085 int i, ret = 0;
86 u8 rc_state[2];
87
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030088
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030089 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030090 goto unlock;
91
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030092 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030093 goto unlock;
94
95 for (i = 0; i < ARRAY_SIZE(megasky_rc_keys); i++)
96 if (megasky_rc_keys[i].data == rc_state[1]) {
97 *event = megasky_rc_keys[i].event;
98
99 switch(rc_state[0]) {
100 case 0x80:
101 *state = REMOTE_NO_KEY_PRESSED;
102 goto unlock;
103
104 case 0x93:
105 case 0x92:
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300106 m->rep_count = 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300107 *state = REMOTE_KEY_PRESSED;
108 goto unlock;
109
110 case 0x91:
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300111 /* For comfort. */
112 if (++m->rep_count > 2)
113 *state = REMOTE_KEY_REPEAT;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300114 goto unlock;
115
116 default:
117 deb_rc("Unexpected rc response %x\n", rc_state[0]);
118 *state = REMOTE_NO_KEY_PRESSED;
119 goto unlock;
120 }
121 }
122
123 if (rc_state[1] != 0)
124 deb_rc("Unknown rc key %x\n", rc_state[1]);
125
126 *state = REMOTE_NO_KEY_PRESSED;
127
128 unlock:
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300129
130 return ret;
131}
132
133/* I2C */
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300134static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
135{
136 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300137 struct m9206_state *m = d->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300138 int i;
139 int ret = 0;
140
141 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
142 return -EAGAIN;
143
144 if (num > 2)
145 return -EINVAL;
146
147 for (i = 0; i < num; i++) {
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300148 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].addr, 0x80)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300149 goto unlock;
150
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300151 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[0], 0x0)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300152 goto unlock;
153
154 if (i + 1 < num && msg[i + 1].flags & I2C_M_RD) {
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300155 int i2c_i;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300156
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300157 for (i2c_i = 0; i2c_i < M9206_I2C_MAX; i2c_i++)
158 if (msg[i].addr == m->i2c_r[i2c_i].addr)
159 break;
160
161 if (i2c_i >= M9206_I2C_MAX) {
162 deb_rc("No magic for i2c addr!\n");
163 ret = -EINVAL;
164 goto unlock;
165 }
166
167 if ((ret = m9206_write(d->udev, M9206_I2C, m->i2c_r[i2c_i].magic, 0x80)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300168 goto unlock;
169
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300170 if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x60, msg[i + 1].buf, msg[i + 1].len)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300171 goto unlock;
172
173 i++;
174 } else {
175 if (msg[i].len != 2)
176 return -EINVAL;
177
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300178 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[1], 0x40)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300179 goto unlock;
180 }
181 }
182 ret = i;
183 unlock:
184 mutex_unlock(&d->i2c_mutex);
185
186 return ret;
187}
188
189static u32 m9206_i2c_func(struct i2c_adapter *adapter)
190{
191 return I2C_FUNC_I2C;
192}
193
194static struct i2c_algorithm m9206_i2c_algo = {
195 .master_xfer = m9206_i2c_xfer,
196 .functionality = m9206_i2c_func,
197};
198
199/* Callbacks for DVB USB */
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300200static int megasky_identify_state(struct usb_device *udev,
201 struct dvb_usb_device_properties *props,
202 struct dvb_usb_device_description **desc,
203 int *cold)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300204{
205 struct usb_host_interface *alt;
206
207 alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
208 *cold = (alt == NULL) ? 1 : 0;
209
210 return 0;
211}
212
213static int megasky_mt352_demod_init(struct dvb_frontend *fe)
214{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300215 u8 config[] = { CONFIG, 0x3d };
216 u8 clock[] = { CLOCK_CTL, 0x30 };
217 u8 reset[] = { RESET, 0x80 };
218 u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
219 u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
220 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
221 u8 unk1[] = { 0x93, 0x1a };
222 u8 unk2[] = { 0xb5, 0x7a };
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300223
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300224 mt352_write(fe, config, ARRAY_SIZE(config));
225 mt352_write(fe, clock, ARRAY_SIZE(clock));
226 mt352_write(fe, reset, ARRAY_SIZE(reset));
227 mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
228 mt352_write(fe, agc, ARRAY_SIZE(agc));
229 mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
230 mt352_write(fe, unk1, ARRAY_SIZE(unk1));
231 mt352_write(fe, unk2, ARRAY_SIZE(unk2));
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300232
233 deb_rc("Demod init!\n");
234
235 return 0;
236}
237
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300238static struct mt352_config megasky_mt352_config = {
239 .demod_address = 0x1e,
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300240 .no_tuner = 1,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300241 .demod_init = megasky_mt352_demod_init,
242};
243
Michael Krufky01cb34d2006-09-23 20:01:29 -0300244static int megasky_frontend_attach(struct dvb_usb_adapter *adap)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300245{
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300246 struct m9206_state *m = adap->dev->priv;
247
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300248 deb_rc("megasky_frontend_attach!\n");
249
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300250 m->i2c_r[M9206_I2C_DEMOD].addr = megasky_mt352_config.demod_address;
251 m->i2c_r[M9206_I2C_DEMOD].magic = 0x1f;
252
253 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL)
254 return -EIO;
255
256 return 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300257}
258
Michael Krufky26f48ea2006-09-28 01:46:49 -0300259static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, int pid)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300260{
261 int ret = 0;
262
263 if (pid >= 0x8000)
264 return -EINVAL;
265
266 pid |= 0x8000;
267
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300268 if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300269 return ret;
270
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300271 if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
272 return ret;
273
274 return ret;
275}
276
277static int m9206_update_filters(struct dvb_usb_adapter *adap)
278{
279 struct m9206_state *m = adap->dev->priv;
280 int enabled = m->filtering_enabled;
281 int i, ret = 0, filter = 0;
282
283 for (i = 0; i < M9206_MAX_FILTERS; i++)
284 if (m->filters[i] == 8192)
285 enabled = 0;
286
287 /* Disable all filters */
Michael Krufky26f48ea2006-09-28 01:46:49 -0300288 if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300289 return ret;
290
291 for (i = 0; i < M9206_MAX_FILTERS; i++)
Michael Krufky26f48ea2006-09-28 01:46:49 -0300292 if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300293 return ret;
294
Michael Krufky26f48ea2006-09-28 01:46:49 -0300295 if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300296 return ret;
297
298 /* Set */
299 if (enabled) {
300 for (i = 0; i < M9206_MAX_FILTERS; i++) {
301 if (m->filters[i] == 0)
302 continue;
303
Michael Krufky26f48ea2006-09-28 01:46:49 -0300304 if ((ret = m9206_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300305 return ret;
306
307 filter++;
308 }
309 }
310
Michael Krufky26f48ea2006-09-28 01:46:49 -0300311 if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300312 return ret;
313
314 return ret;
315}
316
Michael Krufky01cb34d2006-09-23 20:01:29 -0300317static int m9206_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300318{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300319 struct m9206_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300320
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300321 m->filtering_enabled = onoff ? 1 : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300322
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300323 return m9206_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300324}
325
Michael Krufky01cb34d2006-09-23 20:01:29 -0300326static int m9206_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300327{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300328 struct m9206_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300329
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300330 m->filters[index] = onoff ? pid : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300331
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300332 return m9206_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300333}
334
335static int m9206_firmware_download(struct usb_device *udev, const struct firmware *fw)
336{
337 u16 value, index, size;
338 u8 read[4], *buff;
339 int i, pass, ret = 0;
340
341 buff = kmalloc(65536, GFP_KERNEL);
342
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300343 if ((ret = m9206_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300344 goto done;
345 deb_rc("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
346
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300347 if ((ret = m9206_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300348 goto done;
349 deb_rc("%x\n", read[0]);
350
351 for (pass = 0; pass < 2; pass++) {
352 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
353 value = le16_to_cpu(*(u16 *)(fw->data + i));
354 i += sizeof(u16);
355
356 index = le16_to_cpu(*(u16 *)(fw->data + i));
357 i += sizeof(u16);
358
359 size = le16_to_cpu(*(u16 *)(fw->data + i));
360 i += sizeof(u16);
361
362 if (pass == 1) {
363 /* Will stall if using fw->data ... */
364 memcpy(buff, fw->data + i, size);
365
366 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300367 M9206_FW,
368 USB_TYPE_VENDOR | USB_DIR_OUT,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300369 value, index, buff, size, 20);
370 if (ret != size) {
371 deb_rc("error while uploading fw!\n");
372 ret = -EIO;
373 goto done;
374 }
375 msleep(3);
376 }
377 i += size;
378 }
379 if (i != fw->size) {
380 ret = -EINVAL;
381 goto done;
382 }
383 }
384
385 msleep(36);
386
387 /* m9206 will disconnect itself from the bus after this. */
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300388 (void) m9206_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300389 deb_rc("firmware uploaded!\n");
390
391 done:
392 kfree(buff);
393
394 return ret;
395}
396
Antti Palosaaricbdc80e2007-01-21 15:56:10 -0300397static struct qt1010_config megasky_qt1010_config = {
398 .i2c_address = 0xc4
399};
400
401static int megasky_tuner_attach(struct dvb_usb_adapter *adap)
402{
Aapo Tahkola84ad7572007-01-21 15:57:20 -0300403 struct m9206_state *m = adap->dev->priv;
404
405 m->i2c_r[M9206_I2C_TUNER].addr = megasky_qt1010_config.i2c_address;
406 m->i2c_r[M9206_I2C_TUNER].magic = 0xc5;
407
408 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap,
409 &megasky_qt1010_config) == NULL)
410 return -ENODEV;
411
412 return 0;
Antti Palosaaricbdc80e2007-01-21 15:56:10 -0300413}
414
Michael Krufky26f48ea2006-09-28 01:46:49 -0300415/* DVB USB Driver stuff */
416static struct dvb_usb_device_properties megasky_properties;
417
418static int m920x_probe(struct usb_interface *intf, const struct usb_device_id *id)
419{
420 struct dvb_usb_device *d;
421 struct usb_host_interface *alt;
422 int ret;
423
424 if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) {
425 deb_rc("probed!\n");
426
427 alt = usb_altnum_to_altsetting(intf, 1);
428 if (alt == NULL) {
429 deb_rc("not alt found!\n");
430 return -ENODEV;
431 }
432
433 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, alt->desc.bAlternateSetting);
434 if (ret < 0)
435 return ret;
436
437 deb_rc("Changed to alternate setting!\n");
438
439 if ((ret = m9206_rc_init(d->udev)) != 0)
440 return ret;
441 }
442 return ret;
443}
444
445static struct usb_device_id m920x_table [] = {
446 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
447 { } /* Terminating entry */
448};
449MODULE_DEVICE_TABLE (usb, m920x_table);
450
Michael Krufky01cb34d2006-09-23 20:01:29 -0300451static struct dvb_usb_device_properties megasky_properties = {
Michael Krufky1f61f3b2006-10-07 15:03:04 -0300452 .caps = DVB_USB_IS_AN_I2C_ADAPTER | DVB_USB_ADAP_HAS_PID_FILTER |
453 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
454
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300455 .usb_ctrl = DEVICE_SPECIFIC,
456 .firmware = "dvb-usb-megasky-02.fw",
457 .download_firmware = m9206_firmware_download,
458
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300459 .rc_interval = 100,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300460 .rc_key_map = megasky_rc_keys,
461 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys),
462 .rc_query = m9206_rc_query,
463
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300464 .size_of_priv = sizeof(struct m9206_state),
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300465
466 .identify_state = megasky_identify_state,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300467 .num_adapters = 1,
468 .adapter = {{
Michael Krufky01cb34d2006-09-23 20:01:29 -0300469 .pid_filter_count = 8,
470 .pid_filter = m9206_pid_filter,
471 .pid_filter_ctrl = m9206_pid_filter_ctrl,
472
473 .frontend_attach = megasky_frontend_attach,
Antti Palosaaricbdc80e2007-01-21 15:56:10 -0300474 .tuner_attach = megasky_tuner_attach,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300475
476 .stream = {
477 .type = USB_BULK,
478 .count = 8,
479 .endpoint = 0x81,
480 .u = {
481 .bulk = {
482 .buffersize = 512,
483 }
484 }
485 },
486 }},
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300487 .i2c_algo = &m9206_i2c_algo,
488
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300489 .num_device_descs = 1,
490 .devices = {
491 { "MSI Mega Sky 580 DVB-T USB2.0",
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300492 { &m920x_table[0], NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300493 { NULL },
494 },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300495 }
496};
497
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300498static struct usb_driver m920x_driver = {
499 .name = "dvb_usb_m920x",
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300500 .probe = m920x_probe,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300501 .disconnect = dvb_usb_device_exit,
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300502 .id_table = m920x_table,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300503};
504
505/* module stuff */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300506static int __init m920x_module_init(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300507{
508 int ret;
509
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300510 if ((ret = usb_register(&m920x_driver))) {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300511 err("usb_register failed. Error number %d", ret);
512 return ret;
513 }
514
515 return 0;
516}
517
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300518static void __exit m920x_module_exit(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300519{
520 /* deregister this driver from the USB subsystem */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300521 usb_deregister(&m920x_driver);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300522}
523
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300524module_init (m920x_module_init);
525module_exit (m920x_module_exit);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300526
527MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300528MODULE_DESCRIPTION("Driver MSI Mega Sky 580 DVB-T USB2.0 / Uli m920x");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300529MODULE_VERSION("0.1");
530MODULE_LICENSE("GPL");