blob: 197bc29bcb8477ad4c7c50d1196178b0f3f246a0 [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 Krufkybaa2ed02006-09-23 20:01:29 -030019int dvb_usb_m920x_debug;
20module_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
88 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
89 return -EAGAIN;
90
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030091 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030092 goto unlock;
93
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -030094 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -030095 goto unlock;
96
97 for (i = 0; i < ARRAY_SIZE(megasky_rc_keys); i++)
98 if (megasky_rc_keys[i].data == rc_state[1]) {
99 *event = megasky_rc_keys[i].event;
100
101 switch(rc_state[0]) {
102 case 0x80:
103 *state = REMOTE_NO_KEY_PRESSED;
104 goto unlock;
105
106 case 0x93:
107 case 0x92:
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300108 m->rep_count = 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300109 *state = REMOTE_KEY_PRESSED;
110 goto unlock;
111
112 case 0x91:
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300113 /* For comfort. */
114 if (++m->rep_count > 2)
115 *state = REMOTE_KEY_REPEAT;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300116 goto unlock;
117
118 default:
119 deb_rc("Unexpected rc response %x\n", rc_state[0]);
120 *state = REMOTE_NO_KEY_PRESSED;
121 goto unlock;
122 }
123 }
124
125 if (rc_state[1] != 0)
126 deb_rc("Unknown rc key %x\n", rc_state[1]);
127
128 *state = REMOTE_NO_KEY_PRESSED;
129
130 unlock:
131 mutex_unlock(&d->i2c_mutex);
132
133 return ret;
134}
135
136/* I2C */
137
138static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
139{
140 struct dvb_usb_device *d = i2c_get_adapdata(adap);
141 int i;
142 int ret = 0;
143
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300144 /* Need to access d->adapter[0] */
145 if (d->num_adapters_initialized != 1) {
146 deb_rc("Impossible happened!\n");
147 return -EINVAL;
148 }
149
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300150 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
151 return -EAGAIN;
152
153 if (num > 2)
154 return -EINVAL;
155
156 for (i = 0; i < num; i++) {
157 u8 w_len;
158
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300159 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].addr, 0x80)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300160 goto unlock;
161
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300162 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[0], 0x0)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300163 goto unlock;
164
165 if (i + 1 < num && msg[i + 1].flags & I2C_M_RD) {
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300166 /* Possibly device dependant */
167 if (msg[i].addr == d->adapter[0].pll_addr)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300168 w_len = 0xc5;
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300169 else
170 w_len = 0x1f;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300171
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300172 if ((ret = m9206_write(d->udev, M9206_I2C, w_len, 0x80)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300173 goto unlock;
174
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300175 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 -0300176 goto unlock;
177
178 i++;
179 } else {
180 if (msg[i].len != 2)
181 return -EINVAL;
182
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300183 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[1], 0x40)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300184 goto unlock;
185 }
186 }
187 ret = i;
188 unlock:
189 mutex_unlock(&d->i2c_mutex);
190
191 return ret;
192}
193
194static u32 m9206_i2c_func(struct i2c_adapter *adapter)
195{
196 return I2C_FUNC_I2C;
197}
198
199static struct i2c_algorithm m9206_i2c_algo = {
200 .master_xfer = m9206_i2c_xfer,
201 .functionality = m9206_i2c_func,
202};
203
204/* Callbacks for DVB USB */
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300205static int megasky_identify_state(struct usb_device *udev,
206 struct dvb_usb_device_properties *props,
207 struct dvb_usb_device_description **desc,
208 int *cold)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300209{
210 struct usb_host_interface *alt;
211
212 alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
213 *cold = (alt == NULL) ? 1 : 0;
214
215 return 0;
216}
217
218static int megasky_mt352_demod_init(struct dvb_frontend *fe)
219{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300220 u8 config[] = { CONFIG, 0x3d };
221 u8 clock[] = { CLOCK_CTL, 0x30 };
222 u8 reset[] = { RESET, 0x80 };
223 u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
224 u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
225 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
226 u8 unk1[] = { 0x93, 0x1a };
227 u8 unk2[] = { 0xb5, 0x7a };
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300228
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300229 mt352_write(fe, config, ARRAY_SIZE(config));
230 mt352_write(fe, clock, ARRAY_SIZE(clock));
231 mt352_write(fe, reset, ARRAY_SIZE(reset));
232 mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
233 mt352_write(fe, agc, ARRAY_SIZE(agc));
234 mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
235 mt352_write(fe, unk1, ARRAY_SIZE(unk1));
236 mt352_write(fe, unk2, ARRAY_SIZE(unk2));
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300237
238 deb_rc("Demod init!\n");
239
240 return 0;
241}
242
243struct mt352_state;
244
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300245static struct mt352_config megasky_mt352_config = {
246 .demod_address = 0x1e,
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300247 .no_tuner = 1,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300248 .demod_init = megasky_mt352_demod_init,
249};
250
Michael Krufky01cb34d2006-09-23 20:01:29 -0300251static int megasky_frontend_attach(struct dvb_usb_adapter *adap)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300252{
253 deb_rc("megasky_frontend_attach!\n");
254
Michael Krufky01cb34d2006-09-23 20:01:29 -0300255 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) != NULL) {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300256 return 0;
257 }
258 return -EIO;
259}
260
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300261static int megasky_tuner_attach(struct dvb_usb_adapter *adap)
262{
263 adap->pll_addr = 0xc4;
264 adap->pll_desc = NULL;
265 adap->fe->ops.tuner_ops.set_params = qt1010_set_params;
266
267 return 0;
268}
269
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300270/* DVB USB Driver stuff */
Michael Krufky01cb34d2006-09-23 20:01:29 -0300271static struct dvb_usb_device_properties megasky_properties;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300272
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300273static int m920x_probe(struct usb_interface *intf, const struct usb_device_id *id)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300274{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300275 struct usb_device *udev = interface_to_usbdev(intf);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300276 struct dvb_usb_device *d;
277 struct usb_host_interface *alt;
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300278 struct dvb_usb_device_properties props;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300279 int ret;
280
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300281 memcpy(&props, &megasky_properties, sizeof(struct dvb_usb_device_properties));
282
283 /* Hardware pid filtering isn't quite perfect so dont use unless have to. */
284 if (udev->speed == USB_SPEED_FULL)
285 props.caps |= DVB_USB_ADAP_HAS_PID_FILTER |
286 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF;
287
288 if ((ret = dvb_usb_device_init(intf, &props, THIS_MODULE, &d)) == 0) {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300289 deb_rc("probed!\n");
290
291 alt = usb_altnum_to_altsetting(intf, 1);
292 if (alt == NULL) {
293 deb_rc("not alt found!\n");
294 return -ENODEV;
295 }
296
297 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, alt->desc.bAlternateSetting);
298 if (ret < 0)
299 return ret;
300
301 deb_rc("Changed to alternate setting!\n");
302
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300303 if ((ret = m9206_rc_init(d->udev)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300304 return ret;
305 }
306 return ret;
307}
308
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300309static struct usb_device_id m920x_table [] = {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300310 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
311 { } /* Terminating entry */
312};
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300313MODULE_DEVICE_TABLE (usb, m920x_table);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300314
Michael Krufky01cb34d2006-09-23 20:01:29 -0300315static int set_filter(struct dvb_usb_adapter *adap, int type, int idx, int pid)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300316{
317 int ret = 0;
318
319 if (pid >= 0x8000)
320 return -EINVAL;
321
322 pid |= 0x8000;
323
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300324 if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300325 return ret;
326
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300327 if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
328 return ret;
329
330 return ret;
331}
332
333static int m9206_update_filters(struct dvb_usb_adapter *adap)
334{
335 struct m9206_state *m = adap->dev->priv;
336 int enabled = m->filtering_enabled;
337 int i, ret = 0, filter = 0;
338
339 for (i = 0; i < M9206_MAX_FILTERS; i++)
340 if (m->filters[i] == 8192)
341 enabled = 0;
342
343 /* Disable all filters */
344 if ((ret = set_filter(adap, 0x81, 1, enabled)) != 0)
345 return ret;
346
347 for (i = 0; i < M9206_MAX_FILTERS; i++)
348 if ((ret = set_filter(adap, 0x81, i + 2, 0)) != 0)
349 return ret;
350
351 if ((ret = set_filter(adap, 0x82, 0, 0x0)) != 0)
352 return ret;
353
354 /* Set */
355 if (enabled) {
356 for (i = 0; i < M9206_MAX_FILTERS; i++) {
357 if (m->filters[i] == 0)
358 continue;
359
360 if ((ret = set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0)
361 return ret;
362
363 filter++;
364 }
365 }
366
367 if ((ret = set_filter(adap, 0x82, 0, 0x02f5)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300368 return ret;
369
370 return ret;
371}
372
Michael Krufky01cb34d2006-09-23 20:01:29 -0300373static int m9206_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300374{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300375 struct m9206_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300376
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300377 m->filtering_enabled = onoff ? 1 : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300378
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300379 return m9206_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300380}
381
Michael Krufky01cb34d2006-09-23 20:01:29 -0300382static int m9206_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300383{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300384 struct m9206_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300385
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300386 m->filters[index] = onoff ? pid : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300387
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300388 return m9206_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300389}
390
391static int m9206_firmware_download(struct usb_device *udev, const struct firmware *fw)
392{
393 u16 value, index, size;
394 u8 read[4], *buff;
395 int i, pass, ret = 0;
396
397 buff = kmalloc(65536, GFP_KERNEL);
398
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300399 if ((ret = m9206_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300400 goto done;
401 deb_rc("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
402
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300403 if ((ret = m9206_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300404 goto done;
405 deb_rc("%x\n", read[0]);
406
407 for (pass = 0; pass < 2; pass++) {
408 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
409 value = le16_to_cpu(*(u16 *)(fw->data + i));
410 i += sizeof(u16);
411
412 index = le16_to_cpu(*(u16 *)(fw->data + i));
413 i += sizeof(u16);
414
415 size = le16_to_cpu(*(u16 *)(fw->data + i));
416 i += sizeof(u16);
417
418 if (pass == 1) {
419 /* Will stall if using fw->data ... */
420 memcpy(buff, fw->data + i, size);
421
422 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300423 M9206_FW,
424 USB_TYPE_VENDOR | USB_DIR_OUT,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300425 value, index, buff, size, 20);
426 if (ret != size) {
427 deb_rc("error while uploading fw!\n");
428 ret = -EIO;
429 goto done;
430 }
431 msleep(3);
432 }
433 i += size;
434 }
435 if (i != fw->size) {
436 ret = -EINVAL;
437 goto done;
438 }
439 }
440
441 msleep(36);
442
443 /* m9206 will disconnect itself from the bus after this. */
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300444 (void) m9206_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300445 deb_rc("firmware uploaded!\n");
446
447 done:
448 kfree(buff);
449
450 return ret;
451}
452
Michael Krufky01cb34d2006-09-23 20:01:29 -0300453static struct dvb_usb_device_properties megasky_properties = {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300454 .usb_ctrl = DEVICE_SPECIFIC,
455 .firmware = "dvb-usb-megasky-02.fw",
456 .download_firmware = m9206_firmware_download,
457
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300458 .rc_interval = 100,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300459 .rc_key_map = megasky_rc_keys,
460 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys),
461 .rc_query = m9206_rc_query,
462
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300463 .size_of_priv = sizeof(struct m9206_state),
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300464
465 .identify_state = megasky_identify_state,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300466 .num_adapters = 1,
467 .adapter = {{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300468 .caps = DVB_USB_IS_AN_I2C_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,
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -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
489 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300490
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300491 .num_device_descs = 1,
492 .devices = {
493 { "MSI Mega Sky 580 DVB-T USB2.0",
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300494 { &m920x_table[0], NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300495 { NULL },
496 },
497 { NULL },
498 }
499};
500
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300501static struct usb_driver m920x_driver = {
502 .name = "dvb_usb_m920x",
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300503 .probe = m920x_probe,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300504 .disconnect = dvb_usb_device_exit,
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300505 .id_table = m920x_table,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300506};
507
508/* module stuff */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300509static int __init m920x_module_init(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300510{
511 int ret;
512
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300513 if ((ret = usb_register(&m920x_driver))) {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300514 err("usb_register failed. Error number %d", ret);
515 return ret;
516 }
517
518 return 0;
519}
520
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300521static void __exit m920x_module_exit(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300522{
523 /* deregister this driver from the USB subsystem */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300524 usb_deregister(&m920x_driver);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300525}
526
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300527module_init (m920x_module_init);
528module_exit (m920x_module_exit);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300529
530MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300531MODULE_DESCRIPTION("Driver MSI Mega Sky 580 DVB-T USB2.0 / Uli m920x");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300532MODULE_VERSION("0.1");
533MODULE_LICENSE("GPL");