Merge git://git.infradead.org/mtd-2.6
[linux-2.6] / drivers / media / dvb / dvb-usb / m920x.c
1 /* 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
7  *      Free Software Foundation, version 2.
8  *
9  * see Documentation/dvb/README.dvb-usb for more information
10  */
11
12 #include "m920x.h"
13
14 #include "mt352.h"
15 #include "mt352_priv.h"
16 #include "qt1010.h"
17 #include "tda1004x.h"
18 #include "tda827x.h"
19
20 /* debug */
21 static int dvb_usb_m920x_debug;
22 module_param_named(debug,dvb_usb_m920x_debug, int, 0644);
23 MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
24
25 static inline int m920x_read(struct usb_device *udev, u8 request, u16 value,
26                              u16 index, void *data, int size)
27 {
28         int ret;
29
30         ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
31                               request, USB_TYPE_VENDOR | USB_DIR_IN,
32                               value, index, data, size, 2000);
33         if (ret < 0) {
34                 printk(KERN_INFO "m920x_read = error: %d\n", ret);
35                 return ret;
36         }
37
38         if (ret != size) {
39                 deb("m920x_read = no data\n");
40                 return -EIO;
41         }
42
43         return 0;
44 }
45
46 static inline int m920x_write(struct usb_device *udev, u8 request,
47                               u16 value, u16 index)
48 {
49         int ret;
50
51         ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
52                               request, USB_TYPE_VENDOR | USB_DIR_OUT,
53                               value, index, NULL, 0, 2000);
54
55         return ret;
56 }
57
58 static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq)
59 {
60         int ret = 0;
61
62         /* Remote controller init. */
63         if (d->props.rc_query) {
64                 deb("Initialising remote control\n");
65                 while (rc_seq->address) {
66                         if ((ret = m920x_write(d->udev, M9206_CORE,
67                                                rc_seq->data,
68                                                rc_seq->address)) != 0) {
69                                 deb("Initialising remote control failed\n");
70                                 return ret;
71                         }
72
73                         rc_seq++;
74                 }
75
76                 deb("Initialising remote control success\n");
77         }
78
79         return ret;
80 }
81
82 static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
83 {
84         struct m920x_state *m = d->priv;
85         int i, ret = 0;
86         u8 rc_state[2];
87
88         if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
89                 goto unlock;
90
91         if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
92                 goto unlock;
93
94         for (i = 0; i < d->props.rc_key_map_size; i++)
95                 if (d->props.rc_key_map[i].data == rc_state[1]) {
96                         *event = d->props.rc_key_map[i].event;
97
98                         switch(rc_state[0]) {
99                         case 0x80:
100                                 *state = REMOTE_NO_KEY_PRESSED;
101                                 goto unlock;
102
103                         case 0x88: /* framing error or "invalid code" */
104                         case 0x99:
105                         case 0xc0:
106                         case 0xd8:
107                                 *state = REMOTE_NO_KEY_PRESSED;
108                                 m->rep_count = 0;
109                                 goto unlock;
110
111                         case 0x93:
112                         case 0x92:
113                                 m->rep_count = 0;
114                                 *state = REMOTE_KEY_PRESSED;
115                                 goto unlock;
116
117                         case 0x91:
118                                 /* prevent immediate auto-repeat */
119                                 if (++m->rep_count > 2)
120                                         *state = REMOTE_KEY_REPEAT;
121                                 else
122                                         *state = REMOTE_NO_KEY_PRESSED;
123                                 goto unlock;
124
125                         default:
126                                 deb("Unexpected rc state %02x\n", rc_state[0]);
127                                 *state = REMOTE_NO_KEY_PRESSED;
128                                 goto unlock;
129                         }
130                 }
131
132         if (rc_state[1] != 0)
133                 deb("Unknown rc key %02x\n", rc_state[1]);
134
135         *state = REMOTE_NO_KEY_PRESSED;
136
137  unlock:
138
139         return ret;
140 }
141
142 /* I2C */
143 static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
144 {
145         struct dvb_usb_device *d = i2c_get_adapdata(adap);
146         int i, j;
147         int ret = 0;
148
149         if (!num)
150                 return -EINVAL;
151
152         if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
153                 return -EAGAIN;
154
155         for (i = 0; i < num; i++) {
156                 if (msg[i].flags & (I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK | I2C_M_TEN) || msg[i].len == 0) {
157                         /* For a 0 byte message, I think sending the address
158                          * to index 0x80|0x40 would be the correct thing to
159                          * do.  However, zero byte messages are only used for
160                          * probing, and since we don't know how to get the
161                          * slave's ack, we can't probe. */
162                         ret = -ENOTSUPP;
163                         goto unlock;
164                 }
165                 /* Send START & address/RW bit */
166                 if (!(msg[i].flags & I2C_M_NOSTART)) {
167                         if ((ret = m920x_write(d->udev, M9206_I2C,
168                                         (msg[i].addr << 1) |
169                                         (msg[i].flags & I2C_M_RD ? 0x01 : 0), 0x80)) != 0)
170                                 goto unlock;
171                         /* Should check for ack here, if we knew how. */
172                 }
173                 if (msg[i].flags & I2C_M_RD) {
174                         for (j = 0; j < msg[i].len; j++) {
175                                 /* Last byte of transaction?
176                                  * Send STOP, otherwise send ACK. */
177                                 int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x01;
178
179                                 if ((ret = m920x_read(d->udev, M9206_I2C, 0x0,
180                                                       0x20 | stop,
181                                                       &msg[i].buf[j], 1)) != 0)
182                                         goto unlock;
183                         }
184                 } else {
185                         for (j = 0; j < msg[i].len; j++) {
186                                 /* Last byte of transaction? Then send STOP. */
187                                 int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x00;
188
189                                 if ((ret = m920x_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0)
190                                         goto unlock;
191                                 /* Should check for ack here too. */
192                         }
193                 }
194         }
195         ret = num;
196
197  unlock:
198         mutex_unlock(&d->i2c_mutex);
199
200         return ret;
201 }
202
203 static u32 m920x_i2c_func(struct i2c_adapter *adapter)
204 {
205         return I2C_FUNC_I2C;
206 }
207
208 static struct i2c_algorithm m920x_i2c_algo = {
209         .master_xfer   = m920x_i2c_xfer,
210         .functionality = m920x_i2c_func,
211 };
212
213 /* pid filter */
214 static int m920x_set_filter(struct dvb_usb_adapter *adap,
215                             int type, int idx, int pid)
216 {
217         int ret = 0;
218
219         if (pid >= 0x8000)
220                 return -EINVAL;
221
222         pid |= 0x8000;
223
224         if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
225                 return ret;
226
227         if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
228                 return ret;
229
230         return ret;
231 }
232
233 static int m920x_update_filters(struct dvb_usb_adapter *adap)
234 {
235         struct m920x_state *m = adap->dev->priv;
236         int enabled = m->filtering_enabled;
237         int i, ret = 0, filter = 0;
238
239         for (i = 0; i < M9206_MAX_FILTERS; i++)
240                 if (m->filters[i] == 8192)
241                         enabled = 0;
242
243         /* Disable all filters */
244         if ((ret = m920x_set_filter(adap, 0x81, 1, enabled)) != 0)
245                 return ret;
246
247         for (i = 0; i < M9206_MAX_FILTERS; i++)
248                 if ((ret = m920x_set_filter(adap, 0x81, i + 2, 0)) != 0)
249                         return ret;
250
251         if ((ret = m920x_set_filter(adap, 0x82, 0, 0x0)) != 0)
252                 return ret;
253
254         /* Set */
255         if (enabled) {
256                 for (i = 0; i < M9206_MAX_FILTERS; i++) {
257                         if (m->filters[i] == 0)
258                                 continue;
259
260                         if ((ret = m920x_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0)
261                                 return ret;
262
263                         filter++;
264                 }
265         }
266
267         if ((ret = m920x_set_filter(adap, 0x82, 0, 0x02f5)) != 0)
268                 return ret;
269
270         return ret;
271 }
272
273 static int m920x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
274 {
275         struct m920x_state *m = adap->dev->priv;
276
277         m->filtering_enabled = onoff ? 1 : 0;
278
279         return m920x_update_filters(adap);
280 }
281
282 static int m920x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
283 {
284         struct m920x_state *m = adap->dev->priv;
285
286         m->filters[index] = onoff ? pid : 0;
287
288         return m920x_update_filters(adap);
289 }
290
291 static int m920x_firmware_download(struct usb_device *udev, const struct firmware *fw)
292 {
293         u16 value, index, size;
294         u8 read[4], *buff;
295         int i, pass, ret = 0;
296
297         buff = kmalloc(65536, GFP_KERNEL);
298
299         if ((ret = m920x_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
300                 goto done;
301         deb("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
302
303         if ((ret = m920x_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
304                 goto done;
305         deb("%x\n", read[0]);
306
307         for (pass = 0; pass < 2; pass++) {
308                 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
309                         value = le16_to_cpu(*(u16 *)(fw->data + i));
310                         i += sizeof(u16);
311
312                         index = le16_to_cpu(*(u16 *)(fw->data + i));
313                         i += sizeof(u16);
314
315                         size = le16_to_cpu(*(u16 *)(fw->data + i));
316                         i += sizeof(u16);
317
318                         if (pass == 1) {
319                                 /* Will stall if using fw->data ... */
320                                 memcpy(buff, fw->data + i, size);
321
322                                 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
323                                                       M9206_FW,
324                                                       USB_TYPE_VENDOR | USB_DIR_OUT,
325                                                       value, index, buff, size, 20);
326                                 if (ret != size) {
327                                         deb("error while uploading fw!\n");
328                                         ret = -EIO;
329                                         goto done;
330                                 }
331                                 msleep(3);
332                         }
333                         i += size;
334                 }
335                 if (i != fw->size) {
336                         deb("bad firmware file!\n");
337                         ret = -EINVAL;
338                         goto done;
339                 }
340         }
341
342         msleep(36);
343
344         /* m920x will disconnect itself from the bus after this. */
345         (void) m920x_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
346         deb("firmware uploaded!\n");
347
348  done:
349         kfree(buff);
350
351         return ret;
352 }
353
354 /* Callbacks for DVB USB */
355 static int m920x_identify_state(struct usb_device *udev,
356                                 struct dvb_usb_device_properties *props,
357                                 struct dvb_usb_device_description **desc,
358                                 int *cold)
359 {
360         struct usb_host_interface *alt;
361
362         alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
363         *cold = (alt == NULL) ? 1 : 0;
364
365         return 0;
366 }
367
368 /* demod configurations */
369 static int m920x_mt352_demod_init(struct dvb_frontend *fe)
370 {
371         u8 config[] = { CONFIG, 0x3d };
372         u8 clock[] = { CLOCK_CTL, 0x30 };
373         u8 reset[] = { RESET, 0x80 };
374         u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
375         u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
376         u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
377         u8 unk1[] = { 0x93, 0x1a };
378         u8 unk2[] = { 0xb5, 0x7a };
379
380         mt352_write(fe, config, ARRAY_SIZE(config));
381         mt352_write(fe, clock, ARRAY_SIZE(clock));
382         mt352_write(fe, reset, ARRAY_SIZE(reset));
383         mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
384         mt352_write(fe, agc, ARRAY_SIZE(agc));
385         mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
386         mt352_write(fe, unk1, ARRAY_SIZE(unk1));
387         mt352_write(fe, unk2, ARRAY_SIZE(unk2));
388
389         deb("Demod init!\n");
390
391         return 0;
392 }
393
394 static struct mt352_config m920x_mt352_config = {
395         .demod_address = 0x0f,
396         .no_tuner = 1,
397         .demod_init = m920x_mt352_demod_init,
398 };
399
400 static struct tda1004x_config m920x_tda10046_08_config = {
401         .demod_address = 0x08,
402         .invert = 0,
403         .invert_oclk = 0,
404         .ts_mode = TDA10046_TS_SERIAL,
405         .xtal_freq = TDA10046_XTAL_16M,
406         .if_freq = TDA10046_FREQ_045,
407         .agc_config = TDA10046_AGC_TDA827X,
408         .gpio_config = TDA10046_GPTRI,
409         .request_firmware = NULL,
410 };
411
412 static struct tda1004x_config m920x_tda10046_0b_config = {
413         .demod_address = 0x0b,
414         .invert = 0,
415         .invert_oclk = 0,
416         .ts_mode = TDA10046_TS_SERIAL,
417         .xtal_freq = TDA10046_XTAL_16M,
418         .if_freq = TDA10046_FREQ_045,
419         .agc_config = TDA10046_AGC_TDA827X,
420         .gpio_config = TDA10046_GPTRI,
421         .request_firmware = NULL, /* uses firmware EEPROM */
422 };
423
424 /* tuner configurations */
425 static struct qt1010_config m920x_qt1010_config = {
426         .i2c_address = 0x62
427 };
428
429 /* Callbacks for DVB USB */
430 static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap)
431 {
432         deb("%s\n",__FUNCTION__);
433
434         if ((adap->fe = dvb_attach(mt352_attach,
435                                    &m920x_mt352_config,
436                                    &adap->dev->i2c_adap)) == NULL)
437                 return -EIO;
438
439         return 0;
440 }
441
442 static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap)
443 {
444         deb("%s\n",__FUNCTION__);
445
446         if ((adap->fe = dvb_attach(tda10046_attach,
447                                    &m920x_tda10046_08_config,
448                                    &adap->dev->i2c_adap)) == NULL)
449                 return -EIO;
450
451         return 0;
452 }
453
454 static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap)
455 {
456         deb("%s\n",__FUNCTION__);
457
458         if ((adap->fe = dvb_attach(tda10046_attach,
459                                    &m920x_tda10046_0b_config,
460                                    &adap->dev->i2c_adap)) == NULL)
461                 return -EIO;
462
463         return 0;
464 }
465
466 static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
467 {
468         deb("%s\n",__FUNCTION__);
469
470         if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL)
471                 return -ENODEV;
472
473         return 0;
474 }
475
476 static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap)
477 {
478         deb("%s\n",__FUNCTION__);
479
480         if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL)
481                 return -ENODEV;
482
483         return 0;
484 }
485
486 static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap)
487 {
488         deb("%s\n",__FUNCTION__);
489
490         if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL)
491                 return -ENODEV;
492
493         return 0;
494 }
495
496 /* device-specific initialization */
497 static struct m920x_inits megasky_rc_init [] = {
498         { M9206_RC_INIT2, 0xa8 },
499         { M9206_RC_INIT1, 0x51 },
500         { } /* terminating entry */
501 };
502
503 static struct m920x_inits tvwalkertwin_rc_init [] = {
504         { M9206_RC_INIT2, 0x00 },
505         { M9206_RC_INIT1, 0xef },
506         { 0xff28,         0x00 },
507         { 0xff23,         0x00 },
508         { 0xff21,         0x30 },
509         { } /* terminating entry */
510 };
511
512 /* ir keymaps */
513 static struct dvb_usb_rc_key megasky_rc_keys [] = {
514         { 0x0, 0x12, KEY_POWER },
515         { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */
516         { 0x0, 0x02, KEY_CHANNELUP },
517         { 0x0, 0x05, KEY_CHANNELDOWN },
518         { 0x0, 0x03, KEY_VOLUMEUP },
519         { 0x0, 0x06, KEY_VOLUMEDOWN },
520         { 0x0, 0x04, KEY_MUTE },
521         { 0x0, 0x07, KEY_OK }, /* TS */
522         { 0x0, 0x08, KEY_STOP },
523         { 0x0, 0x09, KEY_MENU }, /* swap */
524         { 0x0, 0x0a, KEY_REWIND },
525         { 0x0, 0x1b, KEY_PAUSE },
526         { 0x0, 0x1f, KEY_FASTFORWARD },
527         { 0x0, 0x0c, KEY_RECORD },
528         { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */
529         { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
530 };
531
532 static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
533         { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */
534         { 0x0, 0x02, KEY_CAMERA }, /* snapshot */
535         { 0x0, 0x03, KEY_MUTE },
536         { 0x0, 0x04, KEY_REWIND },
537         { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */
538         { 0x0, 0x06, KEY_FASTFORWARD },
539         { 0x0, 0x07, KEY_RECORD },
540         { 0x0, 0x08, KEY_STOP },
541         { 0x0, 0x09, KEY_TIME }, /* Timeshift */
542         { 0x0, 0x0c, KEY_COFFEE }, /* Recall */
543         { 0x0, 0x0e, KEY_CHANNELUP },
544         { 0x0, 0x12, KEY_POWER },
545         { 0x0, 0x15, KEY_MENU }, /* source */
546         { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */
547         { 0x0, 0x1a, KEY_CHANNELDOWN },
548         { 0x0, 0x1b, KEY_VOLUMEDOWN },
549         { 0x0, 0x1e, KEY_VOLUMEUP },
550 };
551
552 /* DVB USB Driver stuff */
553 static struct dvb_usb_device_properties megasky_properties;
554 static struct dvb_usb_device_properties digivox_mini_ii_properties;
555 static struct dvb_usb_device_properties tvwalkertwin_properties;
556 static struct dvb_usb_device_properties dposh_properties;
557
558 static int m920x_probe(struct usb_interface *intf,
559                        const struct usb_device_id *id)
560 {
561         struct dvb_usb_device *d;
562         struct usb_host_interface *alt;
563         int ret;
564         struct m920x_inits *rc_init_seq = NULL;
565         int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber;
566
567         deb("Probing for m920x device at interface %d\n", bInterfaceNumber);
568
569         if (bInterfaceNumber == 0) {
570                 /* Single-tuner device, or first interface on
571                  * multi-tuner device
572                  */
573
574                 if ((ret = dvb_usb_device_init(intf, &megasky_properties,
575                                                THIS_MODULE, &d)) == 0) {
576                         rc_init_seq = megasky_rc_init;
577                         goto found;
578                 }
579
580                 if ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties,
581                                                THIS_MODULE, &d)) == 0) {
582                         /* No remote control, so no rc_init_seq */
583                         goto found;
584                 }
585
586                 /* This configures both tuners on the TV Walker Twin */
587                 if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties,
588                                                THIS_MODULE, &d)) == 0) {
589                         rc_init_seq = tvwalkertwin_rc_init;
590                         goto found;
591                 }
592
593                 if ((ret = dvb_usb_device_init(intf, &dposh_properties,
594                                                THIS_MODULE, &d)) == 0) {
595                         /* Remote controller not supported yet. */
596                         goto found;
597                 }
598
599                 return ret;
600         } else {
601                 /* Another interface on a multi-tuner device */
602
603                 /* The LifeView TV Walker Twin gets here, but struct
604                  * tvwalkertwin_properties already configured both
605                  * tuners, so there is nothing for us to do here
606                  */
607
608                 return -ENODEV;
609         }
610
611  found:
612         alt = usb_altnum_to_altsetting(intf, 1);
613         if (alt == NULL) {
614                 deb("No alt found!\n");
615                 return -ENODEV;
616         }
617
618         ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
619                                 alt->desc.bAlternateSetting);
620         if (ret < 0)
621                 return ret;
622
623         if ((ret = m920x_init(d, rc_init_seq)) != 0)
624                 return ret;
625
626         return ret;
627 }
628
629 static struct usb_device_id m920x_table [] = {
630                 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
631                 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
632                              USB_PID_MSI_DIGI_VOX_MINI_II) },
633                 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
634                              USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) },
635                 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
636                              USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) },
637                 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) },
638                 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) },
639                 { }             /* Terminating entry */
640 };
641 MODULE_DEVICE_TABLE (usb, m920x_table);
642
643 static struct dvb_usb_device_properties megasky_properties = {
644         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
645
646         .usb_ctrl = DEVICE_SPECIFIC,
647         .firmware = "dvb-usb-megasky-02.fw",
648         .download_firmware = m920x_firmware_download,
649
650         .rc_interval      = 100,
651         .rc_key_map       = megasky_rc_keys,
652         .rc_key_map_size  = ARRAY_SIZE(megasky_rc_keys),
653         .rc_query         = m920x_rc_query,
654
655         .size_of_priv     = sizeof(struct m920x_state),
656
657         .identify_state   = m920x_identify_state,
658         .num_adapters = 1,
659         .adapter = {{
660                 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
661                         DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
662
663                 .pid_filter_count = 8,
664                 .pid_filter       = m920x_pid_filter,
665                 .pid_filter_ctrl  = m920x_pid_filter_ctrl,
666
667                 .frontend_attach  = m920x_mt352_frontend_attach,
668                 .tuner_attach     = m920x_qt1010_tuner_attach,
669
670                 .stream = {
671                         .type = USB_BULK,
672                         .count = 8,
673                         .endpoint = 0x81,
674                         .u = {
675                                 .bulk = {
676                                         .buffersize = 512,
677                                 }
678                         }
679                 },
680         }},
681         .i2c_algo         = &m920x_i2c_algo,
682
683         .num_device_descs = 1,
684         .devices = {
685                 {   "MSI Mega Sky 580 DVB-T USB2.0",
686                         { &m920x_table[0], NULL },
687                         { NULL },
688                 }
689         }
690 };
691
692 static struct dvb_usb_device_properties digivox_mini_ii_properties = {
693         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
694
695         .usb_ctrl = DEVICE_SPECIFIC,
696         .firmware = "dvb-usb-digivox-02.fw",
697         .download_firmware = m920x_firmware_download,
698
699         .size_of_priv     = sizeof(struct m920x_state),
700
701         .identify_state   = m920x_identify_state,
702         .num_adapters = 1,
703         .adapter = {{
704                 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
705                         DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
706
707                 .pid_filter_count = 8,
708                 .pid_filter       = m920x_pid_filter,
709                 .pid_filter_ctrl  = m920x_pid_filter_ctrl,
710
711                 .frontend_attach  = m920x_tda10046_08_frontend_attach,
712                 .tuner_attach     = m920x_tda8275_60_tuner_attach,
713
714                 .stream = {
715                         .type = USB_BULK,
716                         .count = 8,
717                         .endpoint = 0x81,
718                         .u = {
719                                 .bulk = {
720                                         .buffersize = 0x4000,
721                                 }
722                         }
723                 },
724         }},
725         .i2c_algo         = &m920x_i2c_algo,
726
727         .num_device_descs = 1,
728         .devices = {
729                 {   "MSI DIGI VOX mini II DVB-T USB2.0",
730                         { &m920x_table[1], NULL },
731                         { NULL },
732                 },
733         }
734 };
735
736 /* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
737  *
738  * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
739  * TDA10046 #0 is located at i2c address 0x08
740  * TDA10046 #1 is located at i2c address 0x0b (presently disabled - not yet working)
741  * TDA8275A #0 is located at i2c address 0x60
742  * TDA8275A #1 is located at i2c address 0x61 (presently disabled - not yet working)
743  */
744 static struct dvb_usb_device_properties tvwalkertwin_properties = {
745         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
746
747         .usb_ctrl = DEVICE_SPECIFIC,
748         .firmware = "dvb-usb-tvwalkert.fw",
749         .download_firmware = m920x_firmware_download,
750
751         .rc_interval      = 100,
752         .rc_key_map       = tvwalkertwin_rc_keys,
753         .rc_key_map_size  = ARRAY_SIZE(tvwalkertwin_rc_keys),
754         .rc_query         = m920x_rc_query,
755
756         .size_of_priv     = sizeof(struct m920x_state),
757
758         .identify_state   = m920x_identify_state,
759         .num_adapters = 1,
760         .adapter = {{
761                 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
762                         DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
763
764                 .pid_filter_count = 8,
765                 .pid_filter       = m920x_pid_filter,
766                 .pid_filter_ctrl  = m920x_pid_filter_ctrl,
767
768                 .frontend_attach  = m920x_tda10046_08_frontend_attach,
769                 .tuner_attach     = m920x_tda8275_60_tuner_attach,
770
771                 .stream = {
772                         .type = USB_BULK,
773                         .count = 8,
774                         .endpoint = 0x81,
775                         .u = {
776                                  .bulk = {
777                                          .buffersize = 512,
778                                  }
779                         }
780                 }},{
781                 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
782                         DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
783
784                 .pid_filter_count = 8,
785                 .pid_filter       = m920x_pid_filter,
786                 .pid_filter_ctrl  = m920x_pid_filter_ctrl,
787
788                 .frontend_attach  = m920x_tda10046_0b_frontend_attach,
789                 .tuner_attach     = m920x_tda8275_61_tuner_attach,
790
791                 .stream = {
792                         .type = USB_BULK,
793                         .count = 8,
794                         .endpoint = 0x82,
795                         .u = {
796                                  .bulk = {
797                                          .buffersize = 512,
798                                  }
799                         }
800                 },
801         }},
802         .i2c_algo         = &m920x_i2c_algo,
803
804         .num_device_descs = 1,
805         .devices = {
806                 {   .name = "LifeView TV Walker Twin DVB-T USB2.0",
807                     .cold_ids = { &m920x_table[2], NULL },
808                     .warm_ids = { &m920x_table[3], NULL },
809                 },
810         }
811 };
812
813 static struct dvb_usb_device_properties dposh_properties = {
814         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
815
816         .usb_ctrl = DEVICE_SPECIFIC,
817         .firmware = "dvb-usb-dposh-01.fw",
818         .download_firmware = m920x_firmware_download,
819
820         .size_of_priv     = sizeof(struct m920x_state),
821
822         .identify_state   = m920x_identify_state,
823         .num_adapters = 1,
824         .adapter = {{
825                 /* Hardware pid filters don't work with this device/firmware */
826
827                 .frontend_attach  = m920x_mt352_frontend_attach,
828                 .tuner_attach     = m920x_qt1010_tuner_attach,
829
830                 .stream = {
831                         .type = USB_BULK,
832                         .count = 8,
833                         .endpoint = 0x81,
834                         .u = {
835                                  .bulk = {
836                                          .buffersize = 512,
837                                  }
838                         }
839                 },
840         }},
841         .i2c_algo         = &m920x_i2c_algo,
842
843         .num_device_descs = 1,
844         .devices = {
845                  {   .name = "Dposh DVB-T USB2.0",
846                      .cold_ids = { &m920x_table[4], NULL },
847                      .warm_ids = { &m920x_table[5], NULL },
848                  },
849          }
850 };
851
852 static struct usb_driver m920x_driver = {
853         .name           = "dvb_usb_m920x",
854         .probe          = m920x_probe,
855         .disconnect     = dvb_usb_device_exit,
856         .id_table       = m920x_table,
857 };
858
859 /* module stuff */
860 static int __init m920x_module_init(void)
861 {
862         int ret;
863
864         if ((ret = usb_register(&m920x_driver))) {
865                 err("usb_register failed. Error number %d", ret);
866                 return ret;
867         }
868
869         return 0;
870 }
871
872 static void __exit m920x_module_exit(void)
873 {
874         /* deregister this driver from the USB subsystem */
875         usb_deregister(&m920x_driver);
876 }
877
878 module_init (m920x_module_init);
879 module_exit (m920x_module_exit);
880
881 MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
882 MODULE_DESCRIPTION("DVB Driver for ULI M920x");
883 MODULE_VERSION("0.1");
884 MODULE_LICENSE("GPL");
885
886 /*
887  * Local variables:
888  * c-basic-offset: 8
889  */