blob: 9e5ec080529dc3fac54b4143d316de94a38fc260 [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 */
134
135static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
136{
137 struct dvb_usb_device *d = i2c_get_adapdata(adap);
138 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++) {
148 u8 w_len;
149
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300150 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].addr, 0x80)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300151 goto unlock;
152
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300153 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[0], 0x0)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300154 goto unlock;
155
156 if (i + 1 < num && msg[i + 1].flags & I2C_M_RD) {
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300157 /* Possibly device dependant */
158 if (msg[i].addr == d->adapter[0].pll_addr)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300159 w_len = 0xc5;
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300160 else
161 w_len = 0x1f;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300162
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300163 if ((ret = m9206_write(d->udev, M9206_I2C, w_len, 0x80)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300164 goto unlock;
165
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300166 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 -0300167 goto unlock;
168
169 i++;
170 } else {
171 if (msg[i].len != 2)
172 return -EINVAL;
173
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300174 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[1], 0x40)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300175 goto unlock;
176 }
177 }
178 ret = i;
179 unlock:
180 mutex_unlock(&d->i2c_mutex);
181
182 return ret;
183}
184
185static u32 m9206_i2c_func(struct i2c_adapter *adapter)
186{
187 return I2C_FUNC_I2C;
188}
189
190static struct i2c_algorithm m9206_i2c_algo = {
191 .master_xfer = m9206_i2c_xfer,
192 .functionality = m9206_i2c_func,
193};
194
195/* Callbacks for DVB USB */
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300196static int megasky_identify_state(struct usb_device *udev,
197 struct dvb_usb_device_properties *props,
198 struct dvb_usb_device_description **desc,
199 int *cold)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300200{
201 struct usb_host_interface *alt;
202
203 alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
204 *cold = (alt == NULL) ? 1 : 0;
205
206 return 0;
207}
208
209static int megasky_mt352_demod_init(struct dvb_frontend *fe)
210{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300211 u8 config[] = { CONFIG, 0x3d };
212 u8 clock[] = { CLOCK_CTL, 0x30 };
213 u8 reset[] = { RESET, 0x80 };
214 u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
215 u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
216 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
217 u8 unk1[] = { 0x93, 0x1a };
218 u8 unk2[] = { 0xb5, 0x7a };
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300219
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300220 mt352_write(fe, config, ARRAY_SIZE(config));
221 mt352_write(fe, clock, ARRAY_SIZE(clock));
222 mt352_write(fe, reset, ARRAY_SIZE(reset));
223 mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
224 mt352_write(fe, agc, ARRAY_SIZE(agc));
225 mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
226 mt352_write(fe, unk1, ARRAY_SIZE(unk1));
227 mt352_write(fe, unk2, ARRAY_SIZE(unk2));
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300228
229 deb_rc("Demod init!\n");
230
231 return 0;
232}
233
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300234static struct mt352_config megasky_mt352_config = {
235 .demod_address = 0x1e,
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300236 .no_tuner = 1,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300237 .demod_init = megasky_mt352_demod_init,
238};
239
Michael Krufky01cb34d2006-09-23 20:01:29 -0300240static int megasky_frontend_attach(struct dvb_usb_adapter *adap)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300241{
242 deb_rc("megasky_frontend_attach!\n");
243
Patrick Boettcher94a47dc2006-09-28 13:48:03 -0300244 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) != NULL)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300245 return 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300246 return -EIO;
247}
248
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300249static int megasky_tuner_attach(struct dvb_usb_adapter *adap)
250{
251 adap->pll_addr = 0xc4;
252 adap->pll_desc = NULL;
253 adap->fe->ops.tuner_ops.set_params = qt1010_set_params;
254
255 return 0;
256}
257
Michael Krufky26f48ea2006-09-28 01:46:49 -0300258static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, int pid)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300259{
260 int ret = 0;
261
262 if (pid >= 0x8000)
263 return -EINVAL;
264
265 pid |= 0x8000;
266
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300267 if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300268 return ret;
269
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300270 if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
271 return ret;
272
273 return ret;
274}
275
276static int m9206_update_filters(struct dvb_usb_adapter *adap)
277{
278 struct m9206_state *m = adap->dev->priv;
279 int enabled = m->filtering_enabled;
280 int i, ret = 0, filter = 0;
281
282 for (i = 0; i < M9206_MAX_FILTERS; i++)
283 if (m->filters[i] == 8192)
284 enabled = 0;
285
286 /* Disable all filters */
Michael Krufky26f48ea2006-09-28 01:46:49 -0300287 if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300288 return ret;
289
290 for (i = 0; i < M9206_MAX_FILTERS; i++)
Michael Krufky26f48ea2006-09-28 01:46:49 -0300291 if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300292 return ret;
293
Michael Krufky26f48ea2006-09-28 01:46:49 -0300294 if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300295 return ret;
296
297 /* Set */
298 if (enabled) {
299 for (i = 0; i < M9206_MAX_FILTERS; i++) {
300 if (m->filters[i] == 0)
301 continue;
302
Michael Krufky26f48ea2006-09-28 01:46:49 -0300303 if ((ret = m9206_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0)
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300304 return ret;
305
306 filter++;
307 }
308 }
309
Michael Krufky26f48ea2006-09-28 01:46:49 -0300310 if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300311 return ret;
312
313 return ret;
314}
315
Michael Krufky01cb34d2006-09-23 20:01:29 -0300316static int m9206_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300317{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300318 struct m9206_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300319
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300320 m->filtering_enabled = onoff ? 1 : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300321
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300322 return m9206_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300323}
324
Michael Krufky01cb34d2006-09-23 20:01:29 -0300325static int m9206_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300326{
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300327 struct m9206_state *m = adap->dev->priv;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300328
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300329 m->filters[index] = onoff ? pid : 0;
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300330
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300331 return m9206_update_filters(adap);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300332}
333
334static int m9206_firmware_download(struct usb_device *udev, const struct firmware *fw)
335{
336 u16 value, index, size;
337 u8 read[4], *buff;
338 int i, pass, ret = 0;
339
340 buff = kmalloc(65536, GFP_KERNEL);
341
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300342 if ((ret = m9206_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300343 goto done;
344 deb_rc("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
345
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300346 if ((ret = m9206_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300347 goto done;
348 deb_rc("%x\n", read[0]);
349
350 for (pass = 0; pass < 2; pass++) {
351 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
352 value = le16_to_cpu(*(u16 *)(fw->data + i));
353 i += sizeof(u16);
354
355 index = le16_to_cpu(*(u16 *)(fw->data + i));
356 i += sizeof(u16);
357
358 size = le16_to_cpu(*(u16 *)(fw->data + i));
359 i += sizeof(u16);
360
361 if (pass == 1) {
362 /* Will stall if using fw->data ... */
363 memcpy(buff, fw->data + i, size);
364
365 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300366 M9206_FW,
367 USB_TYPE_VENDOR | USB_DIR_OUT,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300368 value, index, buff, size, 20);
369 if (ret != size) {
370 deb_rc("error while uploading fw!\n");
371 ret = -EIO;
372 goto done;
373 }
374 msleep(3);
375 }
376 i += size;
377 }
378 if (i != fw->size) {
379 ret = -EINVAL;
380 goto done;
381 }
382 }
383
384 msleep(36);
385
386 /* m9206 will disconnect itself from the bus after this. */
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300387 (void) m9206_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300388 deb_rc("firmware uploaded!\n");
389
390 done:
391 kfree(buff);
392
393 return ret;
394}
395
Michael Krufky26f48ea2006-09-28 01:46:49 -0300396/* DVB USB Driver stuff */
397static struct dvb_usb_device_properties megasky_properties;
398
399static int m920x_probe(struct usb_interface *intf, const struct usb_device_id *id)
400{
401 struct dvb_usb_device *d;
402 struct usb_host_interface *alt;
403 int ret;
404
405 if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) {
406 deb_rc("probed!\n");
407
408 alt = usb_altnum_to_altsetting(intf, 1);
409 if (alt == NULL) {
410 deb_rc("not alt found!\n");
411 return -ENODEV;
412 }
413
414 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, alt->desc.bAlternateSetting);
415 if (ret < 0)
416 return ret;
417
418 deb_rc("Changed to alternate setting!\n");
419
420 if ((ret = m9206_rc_init(d->udev)) != 0)
421 return ret;
422 }
423 return ret;
424}
425
426static struct usb_device_id m920x_table [] = {
427 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
428 { } /* Terminating entry */
429};
430MODULE_DEVICE_TABLE (usb, m920x_table);
431
Michael Krufky01cb34d2006-09-23 20:01:29 -0300432static struct dvb_usb_device_properties megasky_properties = {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300433 .usb_ctrl = DEVICE_SPECIFIC,
434 .firmware = "dvb-usb-megasky-02.fw",
435 .download_firmware = m9206_firmware_download,
436
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300437 .rc_interval = 100,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300438 .rc_key_map = megasky_rc_keys,
439 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys),
440 .rc_query = m9206_rc_query,
441
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300442 .size_of_priv = sizeof(struct m9206_state),
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300443
444 .identify_state = megasky_identify_state,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300445 .num_adapters = 1,
446 .adapter = {{
Michael Krufky26f48ea2006-09-28 01:46:49 -0300447 .caps = DVB_USB_IS_AN_I2C_ADAPTER | DVB_USB_ADAP_HAS_PID_FILTER |
448 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
449
Michael Krufky01cb34d2006-09-23 20:01:29 -0300450 .pid_filter_count = 8,
451 .pid_filter = m9206_pid_filter,
452 .pid_filter_ctrl = m9206_pid_filter_ctrl,
453
454 .frontend_attach = megasky_frontend_attach,
Aapo Tahkolae2adbecf72006-09-28 00:47:51 -0300455 .tuner_attach = megasky_tuner_attach,
Michael Krufky01cb34d2006-09-23 20:01:29 -0300456
457 .stream = {
458 .type = USB_BULK,
459 .count = 8,
460 .endpoint = 0x81,
461 .u = {
462 .bulk = {
463 .buffersize = 512,
464 }
465 }
466 },
467 }},
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300468 .i2c_algo = &m9206_i2c_algo,
469
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300470 .num_device_descs = 1,
471 .devices = {
472 { "MSI Mega Sky 580 DVB-T USB2.0",
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300473 { &m920x_table[0], NULL },
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300474 { NULL },
475 },
476 { NULL },
477 }
478};
479
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300480static struct usb_driver m920x_driver = {
481 .name = "dvb_usb_m920x",
Michael Krufky2a2bfa72006-09-23 20:13:12 -0300482 .probe = m920x_probe,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300483 .disconnect = dvb_usb_device_exit,
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300484 .id_table = m920x_table,
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300485};
486
487/* module stuff */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300488static int __init m920x_module_init(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300489{
490 int ret;
491
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300492 if ((ret = usb_register(&m920x_driver))) {
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300493 err("usb_register failed. Error number %d", ret);
494 return ret;
495 }
496
497 return 0;
498}
499
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300500static void __exit m920x_module_exit(void)
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300501{
502 /* deregister this driver from the USB subsystem */
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300503 usb_deregister(&m920x_driver);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300504}
505
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300506module_init (m920x_module_init);
507module_exit (m920x_module_exit);
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300508
509MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
Michael Krufkybaa2ed02006-09-23 20:01:29 -0300510MODULE_DESCRIPTION("Driver MSI Mega Sky 580 DVB-T USB2.0 / Uli m920x");
Aapo Tahkola5fecd9f2006-09-23 20:00:41 -0300511MODULE_VERSION("0.1");
512MODULE_LICENSE("GPL");