1 /* DVB USB compliant linux driver for MSI Mega Sky 580 DVB-T USB2.0 receiver
3 * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org)
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.
9 * see Documentation/dvb/README.dvb-usb for more information
15 #include "mt352_priv.h"
21 #include <media/tuner.h>
22 #include "tuner-simple.h"
23 #include <asm/unaligned.h>
26 static int dvb_usb_m920x_debug
;
27 module_param_named(debug
,dvb_usb_m920x_debug
, int, 0644);
28 MODULE_PARM_DESC(debug
, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS
);
30 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
32 static int m920x_set_filter(struct dvb_usb_device
*d
, int type
, int idx
, int pid
);
34 static inline int m920x_read(struct usb_device
*udev
, u8 request
, u16 value
,
35 u16 index
, void *data
, int size
)
39 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
40 request
, USB_TYPE_VENDOR
| USB_DIR_IN
,
41 value
, index
, data
, size
, 2000);
43 printk(KERN_INFO
"m920x_read = error: %d\n", ret
);
48 deb("m920x_read = no data\n");
55 static inline int m920x_write(struct usb_device
*udev
, u8 request
,
60 ret
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
61 request
, USB_TYPE_VENDOR
| USB_DIR_OUT
,
62 value
, index
, NULL
, 0, 2000);
67 static inline int m920x_write_seq(struct usb_device
*udev
, u8 request
,
68 struct m920x_inits
*seq
)
72 ret
= m920x_write(udev
, request
, seq
->data
, seq
->address
);
77 } while (seq
->address
);
82 static int m920x_init(struct dvb_usb_device
*d
, struct m920x_inits
*rc_seq
)
84 int ret
, i
, epi
, flags
= 0;
85 int adap_enabled
[M9206_MAX_ADAPTERS
] = { 0 };
87 /* Remote controller init. */
88 if (d
->props
.rc
.legacy
.rc_query
|| d
->props
.rc
.core
.rc_query
) {
89 deb("Initialising remote control\n");
90 ret
= m920x_write_seq(d
->udev
, M9206_CORE
, rc_seq
);
92 deb("Initialising remote control failed\n");
96 deb("Initialising remote control success\n");
99 for (i
= 0; i
< d
->props
.num_adapters
; i
++)
100 flags
|= d
->adapter
[i
].props
.fe
[0].caps
;
102 /* Some devices(Dposh) might crash if we attempt touch at all. */
103 if (flags
& DVB_USB_ADAP_HAS_PID_FILTER
) {
104 for (i
= 0; i
< d
->props
.num_adapters
; i
++) {
105 epi
= d
->adapter
[i
].props
.fe
[0].stream
.endpoint
- 0x81;
107 if (epi
< 0 || epi
>= M9206_MAX_ADAPTERS
) {
108 printk(KERN_INFO
"m920x: Unexpected adapter endpoint!\n");
112 adap_enabled
[epi
] = 1;
115 for (i
= 0; i
< M9206_MAX_ADAPTERS
; i
++) {
119 if ((ret
= m920x_set_filter(d
, 0x81 + i
, 0, 0x0)) != 0)
122 if ((ret
= m920x_set_filter(d
, 0x81 + i
, 0, 0x02f5)) != 0)
130 static int m920x_init_ep(struct usb_interface
*intf
)
132 struct usb_device
*udev
= interface_to_usbdev(intf
);
133 struct usb_host_interface
*alt
;
135 if ((alt
= usb_altnum_to_altsetting(intf
, 1)) == NULL
) {
136 deb("No alt found!\n");
140 return usb_set_interface(udev
, alt
->desc
.bInterfaceNumber
,
141 alt
->desc
.bAlternateSetting
);
144 static inline void m920x_parse_rc_state(struct dvb_usb_device
*d
, u8 rc_state
,
147 struct m920x_state
*m
= d
->priv
;
151 *state
= REMOTE_NO_KEY_PRESSED
;
154 case 0x88: /* framing error or "invalid code" */
158 *state
= REMOTE_NO_KEY_PRESSED
;
164 case 0x83: /* pinnacle PCTV310e */
167 *state
= REMOTE_KEY_PRESSED
;
171 case 0x81: /* pinnacle PCTV310e */
172 /* prevent immediate auto-repeat */
173 if (++m
->rep_count
> 2)
174 *state
= REMOTE_KEY_REPEAT
;
176 *state
= REMOTE_NO_KEY_PRESSED
;
180 deb("Unexpected rc state %02x\n", rc_state
);
181 *state
= REMOTE_NO_KEY_PRESSED
;
186 static int m920x_rc_query(struct dvb_usb_device
*d
, u32
*event
, int *state
)
191 rc_state
= kmalloc(2, GFP_KERNEL
);
195 ret
= m920x_read(d
->udev
, M9206_CORE
, 0x0, M9206_RC_STATE
,
200 ret
= m920x_read(d
->udev
, M9206_CORE
, 0x0, M9206_RC_KEY
,
205 m920x_parse_rc_state(d
, rc_state
[0], state
);
207 for (i
= 0; i
< d
->props
.rc
.legacy
.rc_map_size
; i
++)
208 if (rc5_data(&d
->props
.rc
.legacy
.rc_map_table
[i
]) == rc_state
[1]) {
209 *event
= d
->props
.rc
.legacy
.rc_map_table
[i
].keycode
;
213 if (rc_state
[1] != 0)
214 deb("Unknown rc key %02x\n", rc_state
[1]);
216 *state
= REMOTE_NO_KEY_PRESSED
;
223 static int m920x_rc_core_query(struct dvb_usb_device
*d
)
229 rc_state
= kmalloc(2, GFP_KERNEL
);
233 if ((ret
= m920x_read(d
->udev
, M9206_CORE
, 0x0, M9206_RC_STATE
, &rc_state
[0], 1)) != 0)
236 if ((ret
= m920x_read(d
->udev
, M9206_CORE
, 0x0, M9206_RC_KEY
, &rc_state
[1], 1)) != 0)
239 deb("state=0x%02x keycode=0x%02x\n", rc_state
[0], rc_state
[1]);
241 m920x_parse_rc_state(d
, rc_state
[0], &state
);
243 if (state
== REMOTE_NO_KEY_PRESSED
)
245 else if (state
== REMOTE_KEY_REPEAT
)
246 rc_repeat(d
->rc_dev
);
248 rc_keydown(d
->rc_dev
, rc_state
[1], 0);
256 static int m920x_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
258 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
265 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
268 for (i
= 0; i
< num
; i
++) {
269 if (msg
[i
].flags
& (I2C_M_NO_RD_ACK
| I2C_M_IGNORE_NAK
| I2C_M_TEN
) || msg
[i
].len
== 0) {
270 /* For a 0 byte message, I think sending the address
271 * to index 0x80|0x40 would be the correct thing to
272 * do. However, zero byte messages are only used for
273 * probing, and since we don't know how to get the
274 * slave's ack, we can't probe. */
278 /* Send START & address/RW bit */
279 if (!(msg
[i
].flags
& I2C_M_NOSTART
)) {
280 if ((ret
= m920x_write(d
->udev
, M9206_I2C
,
282 (msg
[i
].flags
& I2C_M_RD
? 0x01 : 0), 0x80)) != 0)
284 /* Should check for ack here, if we knew how. */
286 if (msg
[i
].flags
& I2C_M_RD
) {
287 for (j
= 0; j
< msg
[i
].len
; j
++) {
288 /* Last byte of transaction?
289 * Send STOP, otherwise send ACK. */
290 int stop
= (i
+1 == num
&& j
+1 == msg
[i
].len
) ? 0x40 : 0x01;
292 if ((ret
= m920x_read(d
->udev
, M9206_I2C
, 0x0,
294 &msg
[i
].buf
[j
], 1)) != 0)
298 for (j
= 0; j
< msg
[i
].len
; j
++) {
299 /* Last byte of transaction? Then send STOP. */
300 int stop
= (i
+1 == num
&& j
+1 == msg
[i
].len
) ? 0x40 : 0x00;
302 if ((ret
= m920x_write(d
->udev
, M9206_I2C
, msg
[i
].buf
[j
], stop
)) != 0)
304 /* Should check for ack here too. */
311 mutex_unlock(&d
->i2c_mutex
);
316 static u32
m920x_i2c_func(struct i2c_adapter
*adapter
)
321 static struct i2c_algorithm m920x_i2c_algo
= {
322 .master_xfer
= m920x_i2c_xfer
,
323 .functionality
= m920x_i2c_func
,
327 static int m920x_set_filter(struct dvb_usb_device
*d
, int type
, int idx
, int pid
)
336 if ((ret
= m920x_write(d
->udev
, M9206_FILTER
, pid
, (type
<< 8) | (idx
* 4) )) != 0)
339 if ((ret
= m920x_write(d
->udev
, M9206_FILTER
, 0, (type
<< 8) | (idx
* 4) )) != 0)
345 static int m920x_update_filters(struct dvb_usb_adapter
*adap
)
347 struct m920x_state
*m
= adap
->dev
->priv
;
348 int enabled
= m
->filtering_enabled
[adap
->id
];
349 int i
, ret
= 0, filter
= 0;
350 int ep
= adap
->props
.fe
[0].stream
.endpoint
;
352 for (i
= 0; i
< M9206_MAX_FILTERS
; i
++)
353 if (m
->filters
[adap
->id
][i
] == 8192)
356 /* Disable all filters */
357 if ((ret
= m920x_set_filter(adap
->dev
, ep
, 1, enabled
)) != 0)
360 for (i
= 0; i
< M9206_MAX_FILTERS
; i
++)
361 if ((ret
= m920x_set_filter(adap
->dev
, ep
, i
+ 2, 0)) != 0)
366 for (i
= 0; i
< M9206_MAX_FILTERS
; i
++) {
367 if (m
->filters
[adap
->id
][i
] == 0)
370 if ((ret
= m920x_set_filter(adap
->dev
, ep
, filter
+ 2, m
->filters
[adap
->id
][i
])) != 0)
380 static int m920x_pid_filter_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
382 struct m920x_state
*m
= adap
->dev
->priv
;
384 m
->filtering_enabled
[adap
->id
] = onoff
? 1 : 0;
386 return m920x_update_filters(adap
);
389 static int m920x_pid_filter(struct dvb_usb_adapter
*adap
, int index
, u16 pid
, int onoff
)
391 struct m920x_state
*m
= adap
->dev
->priv
;
393 m
->filters
[adap
->id
][index
] = onoff
? pid
: 0;
395 return m920x_update_filters(adap
);
398 static int m920x_firmware_download(struct usb_device
*udev
, const struct firmware
*fw
)
400 u16 value
, index
, size
;
402 int i
, pass
, ret
= 0;
404 buff
= kmalloc(65536, GFP_KERNEL
);
408 read
= kmalloc(4, GFP_KERNEL
);
414 if ((ret
= m920x_read(udev
, M9206_FILTER
, 0x0, 0x8000, read
, 4)) != 0)
416 deb("%*ph\n", 4, read
);
418 if ((ret
= m920x_read(udev
, M9206_FW
, 0x0, 0x0, read
, 1)) != 0)
420 deb("%x\n", read
[0]);
422 for (pass
= 0; pass
< 2; pass
++) {
423 for (i
= 0; i
+ (sizeof(u16
) * 3) < fw
->size
;) {
424 value
= get_unaligned_le16(fw
->data
+ i
);
427 index
= get_unaligned_le16(fw
->data
+ i
);
430 size
= get_unaligned_le16(fw
->data
+ i
);
434 /* Will stall if using fw->data ... */
435 memcpy(buff
, fw
->data
+ i
, size
);
437 ret
= usb_control_msg(udev
, usb_sndctrlpipe(udev
,0),
439 USB_TYPE_VENDOR
| USB_DIR_OUT
,
440 value
, index
, buff
, size
, 20);
442 deb("error while uploading fw!\n");
451 deb("bad firmware file!\n");
459 /* m920x will disconnect itself from the bus after this. */
460 (void) m920x_write(udev
, M9206_CORE
, 0x01, M9206_FW_GO
);
461 deb("firmware uploaded!\n");
470 /* Callbacks for DVB USB */
471 static int m920x_identify_state(struct usb_device
*udev
,
472 struct dvb_usb_device_properties
*props
,
473 struct dvb_usb_device_description
**desc
,
476 struct usb_host_interface
*alt
;
478 alt
= usb_altnum_to_altsetting(usb_ifnum_to_if(udev
, 0), 1);
479 *cold
= (alt
== NULL
) ? 1 : 0;
484 /* demod configurations */
485 static int m920x_mt352_demod_init(struct dvb_frontend
*fe
)
488 u8 config
[] = { CONFIG
, 0x3d };
489 u8 clock
[] = { CLOCK_CTL
, 0x30 };
490 u8 reset
[] = { RESET
, 0x80 };
491 u8 adc_ctl
[] = { ADC_CTL_1
, 0x40 };
492 u8 agc
[] = { AGC_TARGET
, 0x1c, 0x20 };
493 u8 sec_agc
[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
494 u8 unk1
[] = { 0x93, 0x1a };
495 u8 unk2
[] = { 0xb5, 0x7a };
497 deb("Demod init!\n");
499 if ((ret
= mt352_write(fe
, config
, ARRAY_SIZE(config
))) != 0)
501 if ((ret
= mt352_write(fe
, clock
, ARRAY_SIZE(clock
))) != 0)
503 if ((ret
= mt352_write(fe
, reset
, ARRAY_SIZE(reset
))) != 0)
505 if ((ret
= mt352_write(fe
, adc_ctl
, ARRAY_SIZE(adc_ctl
))) != 0)
507 if ((ret
= mt352_write(fe
, agc
, ARRAY_SIZE(agc
))) != 0)
509 if ((ret
= mt352_write(fe
, sec_agc
, ARRAY_SIZE(sec_agc
))) != 0)
511 if ((ret
= mt352_write(fe
, unk1
, ARRAY_SIZE(unk1
))) != 0)
513 if ((ret
= mt352_write(fe
, unk2
, ARRAY_SIZE(unk2
))) != 0)
519 static struct mt352_config m920x_mt352_config
= {
520 .demod_address
= 0x0f,
522 .demod_init
= m920x_mt352_demod_init
,
525 static struct tda1004x_config m920x_tda10046_08_config
= {
526 .demod_address
= 0x08,
529 .ts_mode
= TDA10046_TS_SERIAL
,
530 .xtal_freq
= TDA10046_XTAL_16M
,
531 .if_freq
= TDA10046_FREQ_045
,
532 .agc_config
= TDA10046_AGC_TDA827X
,
533 .gpio_config
= TDA10046_GPTRI
,
534 .request_firmware
= NULL
,
537 static struct tda1004x_config m920x_tda10046_0b_config
= {
538 .demod_address
= 0x0b,
541 .ts_mode
= TDA10046_TS_SERIAL
,
542 .xtal_freq
= TDA10046_XTAL_16M
,
543 .if_freq
= TDA10046_FREQ_045
,
544 .agc_config
= TDA10046_AGC_TDA827X
,
545 .gpio_config
= TDA10046_GPTRI
,
546 .request_firmware
= NULL
, /* uses firmware EEPROM */
549 /* tuner configurations */
550 static struct qt1010_config m920x_qt1010_config
= {
554 static struct mt2060_config m920x_mt2060_config
= {
555 .i2c_address
= 0x60, /* 0xc0 */
560 /* Callbacks for DVB USB */
561 static int m920x_mt352_frontend_attach(struct dvb_usb_adapter
*adap
)
563 deb("%s\n",__func__
);
565 adap
->fe_adap
[0].fe
= dvb_attach(mt352_attach
,
567 &adap
->dev
->i2c_adap
);
568 if ((adap
->fe_adap
[0].fe
) == NULL
)
574 static int m920x_mt352_frontend_attach_vp7049(struct dvb_usb_adapter
*adap
)
576 struct m920x_inits vp7049_fe_init_seq
[] = {
577 /* XXX without these commands the frontend cannot be detected,
578 * they must be sent BEFORE the frontend is attached */
590 { } /* terminating entry */
594 deb("%s\n", __func__
);
596 ret
= m920x_write_seq(adap
->dev
->udev
, M9206_CORE
, vp7049_fe_init_seq
);
598 deb("Initialization of vp7049 frontend failed.");
602 return m920x_mt352_frontend_attach(adap
);
605 static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter
*adap
)
607 deb("%s\n",__func__
);
609 adap
->fe_adap
[0].fe
= dvb_attach(tda10046_attach
,
610 &m920x_tda10046_08_config
,
611 &adap
->dev
->i2c_adap
);
612 if ((adap
->fe_adap
[0].fe
) == NULL
)
618 static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter
*adap
)
620 deb("%s\n",__func__
);
622 adap
->fe_adap
[0].fe
= dvb_attach(tda10046_attach
,
623 &m920x_tda10046_0b_config
,
624 &adap
->dev
->i2c_adap
);
625 if ((adap
->fe_adap
[0].fe
) == NULL
)
631 static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter
*adap
)
633 deb("%s\n",__func__
);
635 if (dvb_attach(qt1010_attach
, adap
->fe_adap
[0].fe
, &adap
->dev
->i2c_adap
, &m920x_qt1010_config
) == NULL
)
641 static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter
*adap
)
643 deb("%s\n",__func__
);
645 if (dvb_attach(tda827x_attach
, adap
->fe_adap
[0].fe
, 0x60, &adap
->dev
->i2c_adap
, NULL
) == NULL
)
651 static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter
*adap
)
653 deb("%s\n",__func__
);
655 if (dvb_attach(tda827x_attach
, adap
->fe_adap
[0].fe
, 0x61, &adap
->dev
->i2c_adap
, NULL
) == NULL
)
661 static int m920x_fmd1216me_tuner_attach(struct dvb_usb_adapter
*adap
)
663 dvb_attach(simple_tuner_attach
, adap
->fe_adap
[0].fe
,
664 &adap
->dev
->i2c_adap
, 0x61,
665 TUNER_PHILIPS_FMD1216ME_MK3
);
669 static int m920x_mt2060_tuner_attach(struct dvb_usb_adapter
*adap
)
671 deb("%s\n", __func__
);
673 if (dvb_attach(mt2060_attach
, adap
->fe_adap
[0].fe
, &adap
->dev
->i2c_adap
,
674 &m920x_mt2060_config
, 1220) == NULL
)
681 /* device-specific initialization */
682 static struct m920x_inits megasky_rc_init
[] = {
683 { M9206_RC_INIT2
, 0xa8 },
684 { M9206_RC_INIT1
, 0x51 },
685 { } /* terminating entry */
688 static struct m920x_inits tvwalkertwin_rc_init
[] = {
689 { M9206_RC_INIT2
, 0x00 },
690 { M9206_RC_INIT1
, 0xef },
694 { } /* terminating entry */
697 static struct m920x_inits pinnacle310e_init
[] = {
698 /* without these the tuner doesn't work */
704 { M9206_RC_INIT1
, 0x00 },
705 { M9206_RC_INIT2
, 0xff },
706 { } /* terminating entry */
709 static struct m920x_inits vp7049_rc_init
[] = {
713 { M9206_RC_INIT2
, 0x00 },
714 { M9206_RC_INIT1
, 0xff },
715 { } /* terminating entry */
719 static struct rc_map_table rc_map_megasky_table
[] = {
720 { 0x0012, KEY_POWER
},
721 { 0x001e, KEY_CYCLEWINDOWS
}, /* min/max */
722 { 0x0002, KEY_CHANNELUP
},
723 { 0x0005, KEY_CHANNELDOWN
},
724 { 0x0003, KEY_VOLUMEUP
},
725 { 0x0006, KEY_VOLUMEDOWN
},
726 { 0x0004, KEY_MUTE
},
727 { 0x0007, KEY_OK
}, /* TS */
728 { 0x0008, KEY_STOP
},
729 { 0x0009, KEY_MENU
}, /* swap */
730 { 0x000a, KEY_REWIND
},
731 { 0x001b, KEY_PAUSE
},
732 { 0x001f, KEY_FASTFORWARD
},
733 { 0x000c, KEY_RECORD
},
734 { 0x000d, KEY_CAMERA
}, /* screenshot */
735 { 0x000e, KEY_COFFEE
}, /* "MTS" */
738 static struct rc_map_table rc_map_tvwalkertwin_table
[] = {
739 { 0x0001, KEY_ZOOM
}, /* Full Screen */
740 { 0x0002, KEY_CAMERA
}, /* snapshot */
741 { 0x0003, KEY_MUTE
},
742 { 0x0004, KEY_REWIND
},
743 { 0x0005, KEY_PLAYPAUSE
}, /* Play/Pause */
744 { 0x0006, KEY_FASTFORWARD
},
745 { 0x0007, KEY_RECORD
},
746 { 0x0008, KEY_STOP
},
747 { 0x0009, KEY_TIME
}, /* Timeshift */
748 { 0x000c, KEY_COFFEE
}, /* Recall */
749 { 0x000e, KEY_CHANNELUP
},
750 { 0x0012, KEY_POWER
},
751 { 0x0015, KEY_MENU
}, /* source */
752 { 0x0018, KEY_CYCLEWINDOWS
}, /* TWIN PIP */
753 { 0x001a, KEY_CHANNELDOWN
},
754 { 0x001b, KEY_VOLUMEDOWN
},
755 { 0x001e, KEY_VOLUMEUP
},
758 static struct rc_map_table rc_map_pinnacle310e_table
[] = {
760 { 0x17, KEY_FAVORITES
},
762 { 0x48, KEY_PROGRAM
}, /* preview */
764 { 0x04, KEY_LIST
}, /* record list */
775 { 0x0c, KEY_CANCEL
},
783 { 0x4f, KEY_ENTER
}, /* could also be KEY_OK */
784 { 0x1e, KEY_VOLUMEUP
},
785 { 0x0a, KEY_VOLUMEDOWN
},
786 { 0x05, KEY_CHANNELUP
},
787 { 0x02, KEY_CHANNELDOWN
},
788 { 0x11, KEY_RECORD
},
792 { 0x40, KEY_REWIND
},
793 { 0x12, KEY_FASTFORWARD
},
794 { 0x41, KEY_PREVIOUSSONG
}, /* Replay */
795 { 0x42, KEY_NEXTSONG
}, /* Skip */
796 { 0x54, KEY_CAMERA
}, /* Capture */
797 /* { 0x50, KEY_SAP }, */ /* Sap */
798 { 0x47, KEY_CYCLEWINDOWS
}, /* Pip */
799 { 0x4d, KEY_SCREEN
}, /* FullScreen */
800 { 0x08, KEY_SUBTITLE
},
802 /* { 0x49, KEY_LR }, */ /* L/R */
803 { 0x07, KEY_SLEEP
}, /* Hibernate */
804 { 0x08, KEY_VIDEO
}, /* A/V */
805 { 0x0e, KEY_MENU
}, /* Recall */
806 { 0x45, KEY_ZOOMIN
},
807 { 0x46, KEY_ZOOMOUT
},
808 { 0x18, KEY_RED
}, /* Red */
809 { 0x53, KEY_GREEN
}, /* Green */
810 { 0x5e, KEY_YELLOW
}, /* Yellow */
811 { 0x5f, KEY_BLUE
}, /* Blue */
814 /* DVB USB Driver stuff */
815 static struct dvb_usb_device_properties megasky_properties
;
816 static struct dvb_usb_device_properties digivox_mini_ii_properties
;
817 static struct dvb_usb_device_properties tvwalkertwin_properties
;
818 static struct dvb_usb_device_properties dposh_properties
;
819 static struct dvb_usb_device_properties pinnacle_pctv310e_properties
;
820 static struct dvb_usb_device_properties vp7049_properties
;
822 static int m920x_probe(struct usb_interface
*intf
,
823 const struct usb_device_id
*id
)
825 struct dvb_usb_device
*d
= NULL
;
827 struct m920x_inits
*rc_init_seq
= NULL
;
828 int bInterfaceNumber
= intf
->cur_altsetting
->desc
.bInterfaceNumber
;
830 deb("Probing for m920x device at interface %d\n", bInterfaceNumber
);
832 if (bInterfaceNumber
== 0) {
833 /* Single-tuner device, or first interface on
837 ret
= dvb_usb_device_init(intf
, &megasky_properties
,
838 THIS_MODULE
, &d
, adapter_nr
);
840 rc_init_seq
= megasky_rc_init
;
844 ret
= dvb_usb_device_init(intf
, &digivox_mini_ii_properties
,
845 THIS_MODULE
, &d
, adapter_nr
);
847 /* No remote control, so no rc_init_seq */
851 /* This configures both tuners on the TV Walker Twin */
852 ret
= dvb_usb_device_init(intf
, &tvwalkertwin_properties
,
853 THIS_MODULE
, &d
, adapter_nr
);
855 rc_init_seq
= tvwalkertwin_rc_init
;
859 ret
= dvb_usb_device_init(intf
, &dposh_properties
,
860 THIS_MODULE
, &d
, adapter_nr
);
862 /* Remote controller not supported yet. */
866 ret
= dvb_usb_device_init(intf
, &pinnacle_pctv310e_properties
,
867 THIS_MODULE
, &d
, adapter_nr
);
869 rc_init_seq
= pinnacle310e_init
;
873 ret
= dvb_usb_device_init(intf
, &vp7049_properties
,
874 THIS_MODULE
, &d
, adapter_nr
);
876 rc_init_seq
= vp7049_rc_init
;
882 /* Another interface on a multi-tuner device */
884 /* The LifeView TV Walker Twin gets here, but struct
885 * tvwalkertwin_properties already configured both
886 * tuners, so there is nothing for us to do here
891 if ((ret
= m920x_init_ep(intf
)) < 0)
894 if (d
&& (ret
= m920x_init(d
, rc_init_seq
)) != 0)
900 static struct usb_device_id m920x_table
[] = {
901 { USB_DEVICE(USB_VID_MSI
, USB_PID_MSI_MEGASKY580
) },
902 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC
,
903 USB_PID_MSI_DIGI_VOX_MINI_II
) },
904 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC
,
905 USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD
) },
906 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC
,
907 USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM
) },
908 { USB_DEVICE(USB_VID_DPOSH
, USB_PID_DPOSH_M9206_COLD
) },
909 { USB_DEVICE(USB_VID_DPOSH
, USB_PID_DPOSH_M9206_WARM
) },
910 { USB_DEVICE(USB_VID_VISIONPLUS
, USB_PID_PINNACLE_PCTV310E
) },
911 { USB_DEVICE(USB_VID_AZUREWAVE
, USB_PID_TWINHAN_VP7049
) },
912 { } /* Terminating entry */
914 MODULE_DEVICE_TABLE (usb
, m920x_table
);
916 static struct dvb_usb_device_properties megasky_properties
= {
917 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
919 .usb_ctrl
= DEVICE_SPECIFIC
,
920 .firmware
= "dvb-usb-megasky-02.fw",
921 .download_firmware
= m920x_firmware_download
,
925 .rc_map_table
= rc_map_megasky_table
,
926 .rc_map_size
= ARRAY_SIZE(rc_map_megasky_table
),
927 .rc_query
= m920x_rc_query
,
930 .size_of_priv
= sizeof(struct m920x_state
),
932 .identify_state
= m920x_identify_state
,
938 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
939 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
941 .pid_filter_count
= 8,
942 .pid_filter
= m920x_pid_filter
,
943 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
945 .frontend_attach
= m920x_mt352_frontend_attach
,
946 .tuner_attach
= m920x_qt1010_tuner_attach
,
960 .i2c_algo
= &m920x_i2c_algo
,
962 .num_device_descs
= 1,
964 { "MSI Mega Sky 580 DVB-T USB2.0",
965 { &m920x_table
[0], NULL
},
971 static struct dvb_usb_device_properties digivox_mini_ii_properties
= {
972 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
974 .usb_ctrl
= DEVICE_SPECIFIC
,
975 .firmware
= "dvb-usb-digivox-02.fw",
976 .download_firmware
= m920x_firmware_download
,
978 .size_of_priv
= sizeof(struct m920x_state
),
980 .identify_state
= m920x_identify_state
,
986 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
987 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
989 .pid_filter_count
= 8,
990 .pid_filter
= m920x_pid_filter
,
991 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
993 .frontend_attach
= m920x_tda10046_08_frontend_attach
,
994 .tuner_attach
= m920x_tda8275_60_tuner_attach
,
1002 .buffersize
= 0x4000,
1008 .i2c_algo
= &m920x_i2c_algo
,
1010 .num_device_descs
= 1,
1012 { "MSI DIGI VOX mini II DVB-T USB2.0",
1013 { &m920x_table
[1], NULL
},
1019 /* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
1021 * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
1022 * TDA10046 #0 is located at i2c address 0x08
1023 * TDA10046 #1 is located at i2c address 0x0b
1024 * TDA8275A #0 is located at i2c address 0x60
1025 * TDA8275A #1 is located at i2c address 0x61
1027 static struct dvb_usb_device_properties tvwalkertwin_properties
= {
1028 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1030 .usb_ctrl
= DEVICE_SPECIFIC
,
1031 .firmware
= "dvb-usb-tvwalkert.fw",
1032 .download_firmware
= m920x_firmware_download
,
1036 .rc_map_table
= rc_map_tvwalkertwin_table
,
1037 .rc_map_size
= ARRAY_SIZE(rc_map_tvwalkertwin_table
),
1038 .rc_query
= m920x_rc_query
,
1041 .size_of_priv
= sizeof(struct m920x_state
),
1043 .identify_state
= m920x_identify_state
,
1049 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1050 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1052 .pid_filter_count
= 8,
1053 .pid_filter
= m920x_pid_filter
,
1054 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
1056 .frontend_attach
= m920x_tda10046_08_frontend_attach
,
1057 .tuner_attach
= m920x_tda8275_60_tuner_attach
,
1073 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1074 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1076 .pid_filter_count
= 8,
1077 .pid_filter
= m920x_pid_filter
,
1078 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
1080 .frontend_attach
= m920x_tda10046_0b_frontend_attach
,
1081 .tuner_attach
= m920x_tda8275_61_tuner_attach
,
1095 .i2c_algo
= &m920x_i2c_algo
,
1097 .num_device_descs
= 1,
1099 { .name
= "LifeView TV Walker Twin DVB-T USB2.0",
1100 .cold_ids
= { &m920x_table
[2], NULL
},
1101 .warm_ids
= { &m920x_table
[3], NULL
},
1106 static struct dvb_usb_device_properties dposh_properties
= {
1107 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1109 .usb_ctrl
= DEVICE_SPECIFIC
,
1110 .firmware
= "dvb-usb-dposh-01.fw",
1111 .download_firmware
= m920x_firmware_download
,
1113 .size_of_priv
= sizeof(struct m920x_state
),
1115 .identify_state
= m920x_identify_state
,
1120 /* Hardware pid filters don't work with this device/firmware */
1122 .frontend_attach
= m920x_mt352_frontend_attach
,
1123 .tuner_attach
= m920x_qt1010_tuner_attach
,
1137 .i2c_algo
= &m920x_i2c_algo
,
1139 .num_device_descs
= 1,
1141 { .name
= "Dposh DVB-T USB2.0",
1142 .cold_ids
= { &m920x_table
[4], NULL
},
1143 .warm_ids
= { &m920x_table
[5], NULL
},
1148 static struct dvb_usb_device_properties pinnacle_pctv310e_properties
= {
1149 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1151 .usb_ctrl
= DEVICE_SPECIFIC
,
1152 .download_firmware
= NULL
,
1156 .rc_map_table
= rc_map_pinnacle310e_table
,
1157 .rc_map_size
= ARRAY_SIZE(rc_map_pinnacle310e_table
),
1158 .rc_query
= m920x_rc_query
,
1161 .size_of_priv
= sizeof(struct m920x_state
),
1163 .identify_state
= m920x_identify_state
,
1169 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1170 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1172 .pid_filter_count
= 8,
1173 .pid_filter
= m920x_pid_filter
,
1174 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
1176 .frontend_attach
= m920x_mt352_frontend_attach
,
1177 .tuner_attach
= m920x_fmd1216me_tuner_attach
,
1185 .framesperurb
= 128,
1193 .i2c_algo
= &m920x_i2c_algo
,
1195 .num_device_descs
= 1,
1197 { "Pinnacle PCTV 310e",
1198 { &m920x_table
[6], NULL
},
1204 static struct dvb_usb_device_properties vp7049_properties
= {
1205 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1207 .usb_ctrl
= DEVICE_SPECIFIC
,
1208 .firmware
= "dvb-usb-vp7049-0.95.fw",
1209 .download_firmware
= m920x_firmware_download
,
1213 .rc_codes
= RC_MAP_TWINHAN_VP1027_DVBS
,
1214 .rc_query
= m920x_rc_core_query
,
1215 .allowed_protos
= RC_TYPE_UNKNOWN
,
1218 .size_of_priv
= sizeof(struct m920x_state
),
1220 .identify_state
= m920x_identify_state
,
1226 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1227 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1229 .pid_filter_count
= 8,
1230 .pid_filter
= m920x_pid_filter
,
1231 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
1233 .frontend_attach
= m920x_mt352_frontend_attach_vp7049
,
1234 .tuner_attach
= m920x_mt2060_tuner_attach
,
1248 .i2c_algo
= &m920x_i2c_algo
,
1250 .num_device_descs
= 1,
1252 { "DTV-DVB UDTT7049",
1253 { &m920x_table
[7], NULL
},
1259 static struct usb_driver m920x_driver
= {
1260 .name
= "dvb_usb_m920x",
1261 .probe
= m920x_probe
,
1262 .disconnect
= dvb_usb_device_exit
,
1263 .id_table
= m920x_table
,
1266 module_usb_driver(m920x_driver
);
1268 MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
1269 MODULE_DESCRIPTION("DVB Driver for ULI M920x");
1270 MODULE_VERSION("0.1");
1271 MODULE_LICENSE("GPL");