1 // SPDX-License-Identifier: GPL-2.0-only
2 /* DVB USB compliant linux driver for MSI Mega Sky 580 DVB-T USB2.0 receiver
4 * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org)
6 * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
12 #include "mt352_priv.h"
18 #include <media/tuner.h>
19 #include "tuner-simple.h"
20 #include <asm/unaligned.h>
23 static int dvb_usb_m920x_debug
;
24 module_param_named(debug
,dvb_usb_m920x_debug
, int, 0644);
25 MODULE_PARM_DESC(debug
, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS
);
27 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
29 static int m920x_set_filter(struct dvb_usb_device
*d
, int type
, int idx
, int pid
);
31 static inline int m920x_read(struct usb_device
*udev
, u8 request
, u16 value
,
32 u16 index
, void *data
, int size
)
36 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
37 request
, USB_TYPE_VENDOR
| USB_DIR_IN
,
38 value
, index
, data
, size
, 2000);
40 printk(KERN_INFO
"m920x_read = error: %d\n", ret
);
45 deb("m920x_read = no data\n");
52 static inline int m920x_write(struct usb_device
*udev
, u8 request
,
55 return usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0), request
,
56 USB_TYPE_VENDOR
| USB_DIR_OUT
, value
, index
,
60 static inline int m920x_write_seq(struct usb_device
*udev
, u8 request
,
61 struct m920x_inits
*seq
)
65 ret
= m920x_write(udev
, request
, seq
->data
, seq
->address
);
70 } while (seq
->address
);
75 static int m920x_init(struct dvb_usb_device
*d
, struct m920x_inits
*rc_seq
)
77 int ret
, i
, epi
, flags
= 0;
78 int adap_enabled
[M9206_MAX_ADAPTERS
] = { 0 };
80 /* Remote controller init. */
81 if (d
->props
.rc
.legacy
.rc_query
|| d
->props
.rc
.core
.rc_query
) {
82 deb("Initialising remote control\n");
83 ret
= m920x_write_seq(d
->udev
, M9206_CORE
, rc_seq
);
85 deb("Initialising remote control failed\n");
89 deb("Initialising remote control success\n");
92 for (i
= 0; i
< d
->props
.num_adapters
; i
++)
93 flags
|= d
->adapter
[i
].props
.fe
[0].caps
;
95 /* Some devices(Dposh) might crash if we attempt touch at all. */
96 if (flags
& DVB_USB_ADAP_HAS_PID_FILTER
) {
97 for (i
= 0; i
< d
->props
.num_adapters
; i
++) {
98 epi
= d
->adapter
[i
].props
.fe
[0].stream
.endpoint
- 0x81;
100 if (epi
< 0 || epi
>= M9206_MAX_ADAPTERS
) {
101 printk(KERN_INFO
"m920x: Unexpected adapter endpoint!\n");
105 adap_enabled
[epi
] = 1;
108 for (i
= 0; i
< M9206_MAX_ADAPTERS
; i
++) {
112 if ((ret
= m920x_set_filter(d
, 0x81 + i
, 0, 0x0)) != 0)
115 if ((ret
= m920x_set_filter(d
, 0x81 + i
, 0, 0x02f5)) != 0)
123 static int m920x_init_ep(struct usb_interface
*intf
)
125 struct usb_device
*udev
= interface_to_usbdev(intf
);
126 struct usb_host_interface
*alt
;
128 if ((alt
= usb_altnum_to_altsetting(intf
, 1)) == NULL
) {
129 deb("No alt found!\n");
133 return usb_set_interface(udev
, alt
->desc
.bInterfaceNumber
,
134 alt
->desc
.bAlternateSetting
);
137 static inline void m920x_parse_rc_state(struct dvb_usb_device
*d
, u8 rc_state
,
140 struct m920x_state
*m
= d
->priv
;
144 *state
= REMOTE_NO_KEY_PRESSED
;
147 case 0x88: /* framing error or "invalid code" */
151 *state
= REMOTE_NO_KEY_PRESSED
;
157 case 0x83: /* pinnacle PCTV310e */
160 *state
= REMOTE_KEY_PRESSED
;
164 case 0x81: /* pinnacle PCTV310e */
165 /* prevent immediate auto-repeat */
166 if (++m
->rep_count
> 2)
167 *state
= REMOTE_KEY_REPEAT
;
169 *state
= REMOTE_NO_KEY_PRESSED
;
173 deb("Unexpected rc state %02x\n", rc_state
);
174 *state
= REMOTE_NO_KEY_PRESSED
;
179 static int m920x_rc_query(struct dvb_usb_device
*d
, u32
*event
, int *state
)
184 rc_state
= kmalloc(2, GFP_KERNEL
);
188 ret
= m920x_read(d
->udev
, M9206_CORE
, 0x0, M9206_RC_STATE
,
193 ret
= m920x_read(d
->udev
, M9206_CORE
, 0x0, M9206_RC_KEY
,
198 m920x_parse_rc_state(d
, rc_state
[0], state
);
200 for (i
= 0; i
< d
->props
.rc
.legacy
.rc_map_size
; i
++)
201 if (rc5_data(&d
->props
.rc
.legacy
.rc_map_table
[i
]) == rc_state
[1]) {
202 *event
= d
->props
.rc
.legacy
.rc_map_table
[i
].keycode
;
206 if (rc_state
[1] != 0)
207 deb("Unknown rc key %02x\n", rc_state
[1]);
209 *state
= REMOTE_NO_KEY_PRESSED
;
216 static int m920x_rc_core_query(struct dvb_usb_device
*d
)
222 rc_state
= kmalloc(2, GFP_KERNEL
);
226 if ((ret
= m920x_read(d
->udev
, M9206_CORE
, 0x0, M9206_RC_STATE
, &rc_state
[0], 1)) != 0)
229 if ((ret
= m920x_read(d
->udev
, M9206_CORE
, 0x0, M9206_RC_KEY
, &rc_state
[1], 1)) != 0)
232 deb("state=0x%02x keycode=0x%02x\n", rc_state
[0], rc_state
[1]);
234 m920x_parse_rc_state(d
, rc_state
[0], &state
);
236 if (state
== REMOTE_NO_KEY_PRESSED
)
238 else if (state
== REMOTE_KEY_REPEAT
)
239 rc_repeat(d
->rc_dev
);
241 rc_keydown(d
->rc_dev
, RC_PROTO_UNKNOWN
, rc_state
[1], 0);
249 static int m920x_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[], int num
)
251 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
255 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
258 for (i
= 0; i
< num
; i
++) {
259 if (msg
[i
].flags
& (I2C_M_NO_RD_ACK
| I2C_M_IGNORE_NAK
| I2C_M_TEN
) || msg
[i
].len
== 0) {
260 /* For a 0 byte message, I think sending the address
261 * to index 0x80|0x40 would be the correct thing to
262 * do. However, zero byte messages are only used for
263 * probing, and since we don't know how to get the
264 * slave's ack, we can't probe. */
268 /* Send START & address/RW bit */
269 if (!(msg
[i
].flags
& I2C_M_NOSTART
)) {
270 if ((ret
= m920x_write(d
->udev
, M9206_I2C
,
272 (msg
[i
].flags
& I2C_M_RD
? 0x01 : 0), 0x80)) != 0)
274 /* Should check for ack here, if we knew how. */
276 if (msg
[i
].flags
& I2C_M_RD
) {
277 for (j
= 0; j
< msg
[i
].len
; j
++) {
278 /* Last byte of transaction?
279 * Send STOP, otherwise send ACK. */
280 int stop
= (i
+1 == num
&& j
+1 == msg
[i
].len
) ? 0x40 : 0x01;
282 if ((ret
= m920x_read(d
->udev
, M9206_I2C
, 0x0,
284 &msg
[i
].buf
[j
], 1)) != 0)
288 for (j
= 0; j
< msg
[i
].len
; j
++) {
289 /* Last byte of transaction? Then send STOP. */
290 int stop
= (i
+1 == num
&& j
+1 == msg
[i
].len
) ? 0x40 : 0x00;
292 if ((ret
= m920x_write(d
->udev
, M9206_I2C
, msg
[i
].buf
[j
], stop
)) != 0)
294 /* Should check for ack here too. */
301 mutex_unlock(&d
->i2c_mutex
);
306 static u32
m920x_i2c_func(struct i2c_adapter
*adapter
)
311 static struct i2c_algorithm m920x_i2c_algo
= {
312 .master_xfer
= m920x_i2c_xfer
,
313 .functionality
= m920x_i2c_func
,
317 static int m920x_set_filter(struct dvb_usb_device
*d
, int type
, int idx
, int pid
)
326 if ((ret
= m920x_write(d
->udev
, M9206_FILTER
, pid
, (type
<< 8) | (idx
* 4) )) != 0)
329 if ((ret
= m920x_write(d
->udev
, M9206_FILTER
, 0, (type
<< 8) | (idx
* 4) )) != 0)
335 static int m920x_update_filters(struct dvb_usb_adapter
*adap
)
337 struct m920x_state
*m
= adap
->dev
->priv
;
338 int enabled
= m
->filtering_enabled
[adap
->id
];
339 int i
, ret
= 0, filter
= 0;
340 int ep
= adap
->props
.fe
[0].stream
.endpoint
;
342 for (i
= 0; i
< M9206_MAX_FILTERS
; i
++)
343 if (m
->filters
[adap
->id
][i
] == 8192)
346 /* Disable all filters */
347 if ((ret
= m920x_set_filter(adap
->dev
, ep
, 1, enabled
)) != 0)
350 for (i
= 0; i
< M9206_MAX_FILTERS
; i
++)
351 if ((ret
= m920x_set_filter(adap
->dev
, ep
, i
+ 2, 0)) != 0)
356 for (i
= 0; i
< M9206_MAX_FILTERS
; i
++) {
357 if (m
->filters
[adap
->id
][i
] == 0)
360 if ((ret
= m920x_set_filter(adap
->dev
, ep
, filter
+ 2, m
->filters
[adap
->id
][i
])) != 0)
370 static int m920x_pid_filter_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
372 struct m920x_state
*m
= adap
->dev
->priv
;
374 m
->filtering_enabled
[adap
->id
] = onoff
? 1 : 0;
376 return m920x_update_filters(adap
);
379 static int m920x_pid_filter(struct dvb_usb_adapter
*adap
, int index
, u16 pid
, int onoff
)
381 struct m920x_state
*m
= adap
->dev
->priv
;
383 m
->filters
[adap
->id
][index
] = onoff
? pid
: 0;
385 return m920x_update_filters(adap
);
388 static int m920x_firmware_download(struct usb_device
*udev
, const struct firmware
*fw
)
390 u16 value
, index
, size
;
392 int i
, pass
, ret
= 0;
394 buff
= kmalloc(65536, GFP_KERNEL
);
398 read
= kmalloc(4, GFP_KERNEL
);
404 if ((ret
= m920x_read(udev
, M9206_FILTER
, 0x0, 0x8000, read
, 4)) != 0)
406 deb("%*ph\n", 4, read
);
408 if ((ret
= m920x_read(udev
, M9206_FW
, 0x0, 0x0, read
, 1)) != 0)
410 deb("%x\n", read
[0]);
412 for (pass
= 0; pass
< 2; pass
++) {
413 for (i
= 0; i
+ (sizeof(u16
) * 3) < fw
->size
;) {
414 value
= get_unaligned_le16(fw
->data
+ i
);
417 index
= get_unaligned_le16(fw
->data
+ i
);
420 size
= get_unaligned_le16(fw
->data
+ i
);
424 /* Will stall if using fw->data ... */
425 memcpy(buff
, fw
->data
+ i
, size
);
427 ret
= usb_control_msg(udev
, usb_sndctrlpipe(udev
,0),
429 USB_TYPE_VENDOR
| USB_DIR_OUT
,
430 value
, index
, buff
, size
, 20);
432 deb("error while uploading fw!\n");
441 deb("bad firmware file!\n");
449 /* m920x will disconnect itself from the bus after this. */
450 (void) m920x_write(udev
, M9206_CORE
, 0x01, M9206_FW_GO
);
451 deb("firmware uploaded!\n");
460 /* Callbacks for DVB USB */
461 static int m920x_identify_state(struct usb_device
*udev
,
462 const struct dvb_usb_device_properties
*props
,
463 const struct dvb_usb_device_description
**desc
,
466 struct usb_host_interface
*alt
;
468 alt
= usb_altnum_to_altsetting(usb_ifnum_to_if(udev
, 0), 1);
469 *cold
= (alt
== NULL
) ? 1 : 0;
474 /* demod configurations */
475 static int m920x_mt352_demod_init(struct dvb_frontend
*fe
)
478 u8 config
[] = { CONFIG
, 0x3d };
479 u8 clock
[] = { CLOCK_CTL
, 0x30 };
480 u8 reset
[] = { RESET
, 0x80 };
481 u8 adc_ctl
[] = { ADC_CTL_1
, 0x40 };
482 u8 agc
[] = { AGC_TARGET
, 0x1c, 0x20 };
483 u8 sec_agc
[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
484 u8 unk1
[] = { 0x93, 0x1a };
485 u8 unk2
[] = { 0xb5, 0x7a };
487 deb("Demod init!\n");
489 if ((ret
= mt352_write(fe
, config
, ARRAY_SIZE(config
))) != 0)
491 if ((ret
= mt352_write(fe
, clock
, ARRAY_SIZE(clock
))) != 0)
493 if ((ret
= mt352_write(fe
, reset
, ARRAY_SIZE(reset
))) != 0)
495 if ((ret
= mt352_write(fe
, adc_ctl
, ARRAY_SIZE(adc_ctl
))) != 0)
497 if ((ret
= mt352_write(fe
, agc
, ARRAY_SIZE(agc
))) != 0)
499 if ((ret
= mt352_write(fe
, sec_agc
, ARRAY_SIZE(sec_agc
))) != 0)
501 if ((ret
= mt352_write(fe
, unk1
, ARRAY_SIZE(unk1
))) != 0)
503 if ((ret
= mt352_write(fe
, unk2
, ARRAY_SIZE(unk2
))) != 0)
509 static struct mt352_config m920x_mt352_config
= {
510 .demod_address
= 0x0f,
512 .demod_init
= m920x_mt352_demod_init
,
515 static struct tda1004x_config m920x_tda10046_08_config
= {
516 .demod_address
= 0x08,
519 .ts_mode
= TDA10046_TS_SERIAL
,
520 .xtal_freq
= TDA10046_XTAL_16M
,
521 .if_freq
= TDA10046_FREQ_045
,
522 .agc_config
= TDA10046_AGC_TDA827X
,
523 .gpio_config
= TDA10046_GPTRI
,
524 .request_firmware
= NULL
,
527 static struct tda1004x_config m920x_tda10046_0b_config
= {
528 .demod_address
= 0x0b,
531 .ts_mode
= TDA10046_TS_SERIAL
,
532 .xtal_freq
= TDA10046_XTAL_16M
,
533 .if_freq
= TDA10046_FREQ_045
,
534 .agc_config
= TDA10046_AGC_TDA827X
,
535 .gpio_config
= TDA10046_GPTRI
,
536 .request_firmware
= NULL
, /* uses firmware EEPROM */
539 /* tuner configurations */
540 static struct qt1010_config m920x_qt1010_config
= {
544 static struct mt2060_config m920x_mt2060_config
= {
545 .i2c_address
= 0x60, /* 0xc0 */
550 /* Callbacks for DVB USB */
551 static int m920x_mt352_frontend_attach(struct dvb_usb_adapter
*adap
)
553 deb("%s\n",__func__
);
555 adap
->fe_adap
[0].fe
= dvb_attach(mt352_attach
,
557 &adap
->dev
->i2c_adap
);
558 if ((adap
->fe_adap
[0].fe
) == NULL
)
564 static int m920x_mt352_frontend_attach_vp7049(struct dvb_usb_adapter
*adap
)
566 struct m920x_inits vp7049_fe_init_seq
[] = {
567 /* XXX without these commands the frontend cannot be detected,
568 * they must be sent BEFORE the frontend is attached */
580 { } /* terminating entry */
584 deb("%s\n", __func__
);
586 ret
= m920x_write_seq(adap
->dev
->udev
, M9206_CORE
, vp7049_fe_init_seq
);
588 deb("Initialization of vp7049 frontend failed.");
592 return m920x_mt352_frontend_attach(adap
);
595 static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter
*adap
)
597 deb("%s\n",__func__
);
599 adap
->fe_adap
[0].fe
= dvb_attach(tda10046_attach
,
600 &m920x_tda10046_08_config
,
601 &adap
->dev
->i2c_adap
);
602 if ((adap
->fe_adap
[0].fe
) == NULL
)
608 static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter
*adap
)
610 deb("%s\n",__func__
);
612 adap
->fe_adap
[0].fe
= dvb_attach(tda10046_attach
,
613 &m920x_tda10046_0b_config
,
614 &adap
->dev
->i2c_adap
);
615 if ((adap
->fe_adap
[0].fe
) == NULL
)
621 static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter
*adap
)
623 deb("%s\n",__func__
);
625 if (dvb_attach(qt1010_attach
, adap
->fe_adap
[0].fe
, &adap
->dev
->i2c_adap
, &m920x_qt1010_config
) == NULL
)
631 static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter
*adap
)
633 deb("%s\n",__func__
);
635 if (dvb_attach(tda827x_attach
, adap
->fe_adap
[0].fe
, 0x60, &adap
->dev
->i2c_adap
, NULL
) == NULL
)
641 static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter
*adap
)
643 deb("%s\n",__func__
);
645 if (dvb_attach(tda827x_attach
, adap
->fe_adap
[0].fe
, 0x61, &adap
->dev
->i2c_adap
, NULL
) == NULL
)
651 static int m920x_fmd1216me_tuner_attach(struct dvb_usb_adapter
*adap
)
653 dvb_attach(simple_tuner_attach
, adap
->fe_adap
[0].fe
,
654 &adap
->dev
->i2c_adap
, 0x61,
655 TUNER_PHILIPS_FMD1216ME_MK3
);
659 static int m920x_mt2060_tuner_attach(struct dvb_usb_adapter
*adap
)
661 deb("%s\n", __func__
);
663 if (dvb_attach(mt2060_attach
, adap
->fe_adap
[0].fe
, &adap
->dev
->i2c_adap
,
664 &m920x_mt2060_config
, 1220) == NULL
)
671 /* device-specific initialization */
672 static struct m920x_inits megasky_rc_init
[] = {
673 { M9206_RC_INIT2
, 0xa8 },
674 { M9206_RC_INIT1
, 0x51 },
675 { } /* terminating entry */
678 static struct m920x_inits tvwalkertwin_rc_init
[] = {
679 { M9206_RC_INIT2
, 0x00 },
680 { M9206_RC_INIT1
, 0xef },
684 { } /* terminating entry */
687 static struct m920x_inits pinnacle310e_init
[] = {
688 /* without these the tuner doesn't work */
694 { M9206_RC_INIT1
, 0x00 },
695 { M9206_RC_INIT2
, 0xff },
696 { } /* terminating entry */
699 static struct m920x_inits vp7049_rc_init
[] = {
703 { M9206_RC_INIT2
, 0x00 },
704 { M9206_RC_INIT1
, 0xff },
705 { } /* terminating entry */
709 static struct rc_map_table rc_map_megasky_table
[] = {
710 { 0x0012, KEY_POWER
},
711 { 0x001e, KEY_CYCLEWINDOWS
}, /* min/max */
712 { 0x0002, KEY_CHANNELUP
},
713 { 0x0005, KEY_CHANNELDOWN
},
714 { 0x0003, KEY_VOLUMEUP
},
715 { 0x0006, KEY_VOLUMEDOWN
},
716 { 0x0004, KEY_MUTE
},
717 { 0x0007, KEY_OK
}, /* TS */
718 { 0x0008, KEY_STOP
},
719 { 0x0009, KEY_MENU
}, /* swap */
720 { 0x000a, KEY_REWIND
},
721 { 0x001b, KEY_PAUSE
},
722 { 0x001f, KEY_FASTFORWARD
},
723 { 0x000c, KEY_RECORD
},
724 { 0x000d, KEY_CAMERA
}, /* screenshot */
725 { 0x000e, KEY_COFFEE
}, /* "MTS" */
728 static struct rc_map_table rc_map_tvwalkertwin_table
[] = {
729 { 0x0001, KEY_ZOOM
}, /* Full Screen */
730 { 0x0002, KEY_CAMERA
}, /* snapshot */
731 { 0x0003, KEY_MUTE
},
732 { 0x0004, KEY_REWIND
},
733 { 0x0005, KEY_PLAYPAUSE
}, /* Play/Pause */
734 { 0x0006, KEY_FASTFORWARD
},
735 { 0x0007, KEY_RECORD
},
736 { 0x0008, KEY_STOP
},
737 { 0x0009, KEY_TIME
}, /* Timeshift */
738 { 0x000c, KEY_COFFEE
}, /* Recall */
739 { 0x000e, KEY_CHANNELUP
},
740 { 0x0012, KEY_POWER
},
741 { 0x0015, KEY_MENU
}, /* source */
742 { 0x0018, KEY_CYCLEWINDOWS
}, /* TWIN PIP */
743 { 0x001a, KEY_CHANNELDOWN
},
744 { 0x001b, KEY_VOLUMEDOWN
},
745 { 0x001e, KEY_VOLUMEUP
},
748 static struct rc_map_table rc_map_pinnacle310e_table
[] = {
750 { 0x17, KEY_FAVORITES
},
752 { 0x48, KEY_PROGRAM
}, /* preview */
754 { 0x04, KEY_LIST
}, /* record list */
765 { 0x0c, KEY_CANCEL
},
773 { 0x4f, KEY_ENTER
}, /* could also be KEY_OK */
774 { 0x1e, KEY_VOLUMEUP
},
775 { 0x0a, KEY_VOLUMEDOWN
},
776 { 0x05, KEY_CHANNELUP
},
777 { 0x02, KEY_CHANNELDOWN
},
778 { 0x11, KEY_RECORD
},
782 { 0x40, KEY_REWIND
},
783 { 0x12, KEY_FASTFORWARD
},
784 { 0x41, KEY_PREVIOUSSONG
}, /* Replay */
785 { 0x42, KEY_NEXTSONG
}, /* Skip */
786 { 0x54, KEY_CAMERA
}, /* Capture */
787 /* { 0x50, KEY_SAP }, */ /* Sap */
788 { 0x47, KEY_CYCLEWINDOWS
}, /* Pip */
789 { 0x4d, KEY_SCREEN
}, /* FullScreen */
790 { 0x08, KEY_SUBTITLE
},
792 /* { 0x49, KEY_LR }, */ /* L/R */
793 { 0x07, KEY_SLEEP
}, /* Hibernate */
794 { 0x08, KEY_VIDEO
}, /* A/V */
795 { 0x0e, KEY_MENU
}, /* Recall */
796 { 0x45, KEY_ZOOMIN
},
797 { 0x46, KEY_ZOOMOUT
},
798 { 0x18, KEY_RED
}, /* Red */
799 { 0x53, KEY_GREEN
}, /* Green */
800 { 0x5e, KEY_YELLOW
}, /* Yellow */
801 { 0x5f, KEY_BLUE
}, /* Blue */
804 /* DVB USB Driver stuff */
805 static struct dvb_usb_device_properties megasky_properties
;
806 static struct dvb_usb_device_properties digivox_mini_ii_properties
;
807 static struct dvb_usb_device_properties tvwalkertwin_properties
;
808 static struct dvb_usb_device_properties dposh_properties
;
809 static struct dvb_usb_device_properties pinnacle_pctv310e_properties
;
810 static struct dvb_usb_device_properties vp7049_properties
;
812 static int m920x_probe(struct usb_interface
*intf
,
813 const struct usb_device_id
*id
)
815 struct dvb_usb_device
*d
= NULL
;
817 struct m920x_inits
*rc_init_seq
= NULL
;
818 int bInterfaceNumber
= intf
->cur_altsetting
->desc
.bInterfaceNumber
;
820 deb("Probing for m920x device at interface %d\n", bInterfaceNumber
);
822 if (bInterfaceNumber
== 0) {
823 /* Single-tuner device, or first interface on
827 ret
= dvb_usb_device_init(intf
, &megasky_properties
,
828 THIS_MODULE
, &d
, adapter_nr
);
830 rc_init_seq
= megasky_rc_init
;
834 ret
= dvb_usb_device_init(intf
, &digivox_mini_ii_properties
,
835 THIS_MODULE
, &d
, adapter_nr
);
837 /* No remote control, so no rc_init_seq */
841 /* This configures both tuners on the TV Walker Twin */
842 ret
= dvb_usb_device_init(intf
, &tvwalkertwin_properties
,
843 THIS_MODULE
, &d
, adapter_nr
);
845 rc_init_seq
= tvwalkertwin_rc_init
;
849 ret
= dvb_usb_device_init(intf
, &dposh_properties
,
850 THIS_MODULE
, &d
, adapter_nr
);
852 /* Remote controller not supported yet. */
856 ret
= dvb_usb_device_init(intf
, &pinnacle_pctv310e_properties
,
857 THIS_MODULE
, &d
, adapter_nr
);
859 rc_init_seq
= pinnacle310e_init
;
863 ret
= dvb_usb_device_init(intf
, &vp7049_properties
,
864 THIS_MODULE
, &d
, adapter_nr
);
866 rc_init_seq
= vp7049_rc_init
;
872 /* Another interface on a multi-tuner device */
874 /* The LifeView TV Walker Twin gets here, but struct
875 * tvwalkertwin_properties already configured both
876 * tuners, so there is nothing for us to do here
881 if ((ret
= m920x_init_ep(intf
)) < 0)
884 if (d
&& (ret
= m920x_init(d
, rc_init_seq
)) != 0)
890 static struct usb_device_id m920x_table
[] = {
891 { USB_DEVICE(USB_VID_MSI
, USB_PID_MSI_MEGASKY580
) },
892 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC
,
893 USB_PID_MSI_DIGI_VOX_MINI_II
) },
894 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC
,
895 USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD
) },
896 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC
,
897 USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM
) },
898 { USB_DEVICE(USB_VID_DPOSH
, USB_PID_DPOSH_M9206_COLD
) },
899 { USB_DEVICE(USB_VID_DPOSH
, USB_PID_DPOSH_M9206_WARM
) },
900 { USB_DEVICE(USB_VID_VISIONPLUS
, USB_PID_PINNACLE_PCTV310E
) },
901 { USB_DEVICE(USB_VID_AZUREWAVE
, USB_PID_TWINHAN_VP7049
) },
902 { } /* Terminating entry */
904 MODULE_DEVICE_TABLE (usb
, m920x_table
);
906 static struct dvb_usb_device_properties megasky_properties
= {
907 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
909 .usb_ctrl
= DEVICE_SPECIFIC
,
910 .firmware
= "dvb-usb-megasky-02.fw",
911 .download_firmware
= m920x_firmware_download
,
915 .rc_map_table
= rc_map_megasky_table
,
916 .rc_map_size
= ARRAY_SIZE(rc_map_megasky_table
),
917 .rc_query
= m920x_rc_query
,
920 .size_of_priv
= sizeof(struct m920x_state
),
922 .identify_state
= m920x_identify_state
,
928 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
929 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
931 .pid_filter_count
= 8,
932 .pid_filter
= m920x_pid_filter
,
933 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
935 .frontend_attach
= m920x_mt352_frontend_attach
,
936 .tuner_attach
= m920x_qt1010_tuner_attach
,
950 .i2c_algo
= &m920x_i2c_algo
,
952 .num_device_descs
= 1,
954 { "MSI Mega Sky 580 DVB-T USB2.0",
955 { &m920x_table
[0], NULL
},
961 static struct dvb_usb_device_properties digivox_mini_ii_properties
= {
962 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
964 .usb_ctrl
= DEVICE_SPECIFIC
,
965 .firmware
= "dvb-usb-digivox-02.fw",
966 .download_firmware
= m920x_firmware_download
,
968 .size_of_priv
= sizeof(struct m920x_state
),
970 .identify_state
= m920x_identify_state
,
976 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
977 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
979 .pid_filter_count
= 8,
980 .pid_filter
= m920x_pid_filter
,
981 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
983 .frontend_attach
= m920x_tda10046_08_frontend_attach
,
984 .tuner_attach
= m920x_tda8275_60_tuner_attach
,
992 .buffersize
= 0x4000,
998 .i2c_algo
= &m920x_i2c_algo
,
1000 .num_device_descs
= 1,
1002 { "MSI DIGI VOX mini II DVB-T USB2.0",
1003 { &m920x_table
[1], NULL
},
1009 /* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
1011 * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
1012 * TDA10046 #0 is located at i2c address 0x08
1013 * TDA10046 #1 is located at i2c address 0x0b
1014 * TDA8275A #0 is located at i2c address 0x60
1015 * TDA8275A #1 is located at i2c address 0x61
1017 static struct dvb_usb_device_properties tvwalkertwin_properties
= {
1018 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1020 .usb_ctrl
= DEVICE_SPECIFIC
,
1021 .firmware
= "dvb-usb-tvwalkert.fw",
1022 .download_firmware
= m920x_firmware_download
,
1026 .rc_map_table
= rc_map_tvwalkertwin_table
,
1027 .rc_map_size
= ARRAY_SIZE(rc_map_tvwalkertwin_table
),
1028 .rc_query
= m920x_rc_query
,
1031 .size_of_priv
= sizeof(struct m920x_state
),
1033 .identify_state
= m920x_identify_state
,
1039 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1040 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1042 .pid_filter_count
= 8,
1043 .pid_filter
= m920x_pid_filter
,
1044 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
1046 .frontend_attach
= m920x_tda10046_08_frontend_attach
,
1047 .tuner_attach
= m920x_tda8275_60_tuner_attach
,
1063 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1064 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1066 .pid_filter_count
= 8,
1067 .pid_filter
= m920x_pid_filter
,
1068 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
1070 .frontend_attach
= m920x_tda10046_0b_frontend_attach
,
1071 .tuner_attach
= m920x_tda8275_61_tuner_attach
,
1085 .i2c_algo
= &m920x_i2c_algo
,
1087 .num_device_descs
= 1,
1089 { .name
= "LifeView TV Walker Twin DVB-T USB2.0",
1090 .cold_ids
= { &m920x_table
[2], NULL
},
1091 .warm_ids
= { &m920x_table
[3], NULL
},
1096 static struct dvb_usb_device_properties dposh_properties
= {
1097 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1099 .usb_ctrl
= DEVICE_SPECIFIC
,
1100 .firmware
= "dvb-usb-dposh-01.fw",
1101 .download_firmware
= m920x_firmware_download
,
1103 .size_of_priv
= sizeof(struct m920x_state
),
1105 .identify_state
= m920x_identify_state
,
1110 /* Hardware pid filters don't work with this device/firmware */
1112 .frontend_attach
= m920x_mt352_frontend_attach
,
1113 .tuner_attach
= m920x_qt1010_tuner_attach
,
1127 .i2c_algo
= &m920x_i2c_algo
,
1129 .num_device_descs
= 1,
1131 { .name
= "Dposh DVB-T USB2.0",
1132 .cold_ids
= { &m920x_table
[4], NULL
},
1133 .warm_ids
= { &m920x_table
[5], NULL
},
1138 static struct dvb_usb_device_properties pinnacle_pctv310e_properties
= {
1139 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1141 .usb_ctrl
= DEVICE_SPECIFIC
,
1142 .download_firmware
= NULL
,
1146 .rc_map_table
= rc_map_pinnacle310e_table
,
1147 .rc_map_size
= ARRAY_SIZE(rc_map_pinnacle310e_table
),
1148 .rc_query
= m920x_rc_query
,
1151 .size_of_priv
= sizeof(struct m920x_state
),
1153 .identify_state
= m920x_identify_state
,
1159 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1160 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1162 .pid_filter_count
= 8,
1163 .pid_filter
= m920x_pid_filter
,
1164 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
1166 .frontend_attach
= m920x_mt352_frontend_attach
,
1167 .tuner_attach
= m920x_fmd1216me_tuner_attach
,
1175 .framesperurb
= 128,
1183 .i2c_algo
= &m920x_i2c_algo
,
1185 .num_device_descs
= 1,
1187 { "Pinnacle PCTV 310e",
1188 { &m920x_table
[6], NULL
},
1194 static struct dvb_usb_device_properties vp7049_properties
= {
1195 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1197 .usb_ctrl
= DEVICE_SPECIFIC
,
1198 .firmware
= "dvb-usb-vp7049-0.95.fw",
1199 .download_firmware
= m920x_firmware_download
,
1203 .rc_codes
= RC_MAP_TWINHAN_VP1027_DVBS
,
1204 .rc_query
= m920x_rc_core_query
,
1205 .allowed_protos
= RC_PROTO_BIT_UNKNOWN
,
1208 .size_of_priv
= sizeof(struct m920x_state
),
1210 .identify_state
= m920x_identify_state
,
1216 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1217 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1219 .pid_filter_count
= 8,
1220 .pid_filter
= m920x_pid_filter
,
1221 .pid_filter_ctrl
= m920x_pid_filter_ctrl
,
1223 .frontend_attach
= m920x_mt352_frontend_attach_vp7049
,
1224 .tuner_attach
= m920x_mt2060_tuner_attach
,
1238 .i2c_algo
= &m920x_i2c_algo
,
1240 .num_device_descs
= 1,
1242 { "DTV-DVB UDTT7049",
1243 { &m920x_table
[7], NULL
},
1249 static struct usb_driver m920x_driver
= {
1250 .name
= "dvb_usb_m920x",
1251 .probe
= m920x_probe
,
1252 .disconnect
= dvb_usb_device_exit
,
1253 .id_table
= m920x_table
,
1256 module_usb_driver(m920x_driver
);
1258 MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
1259 MODULE_DESCRIPTION("DVB Driver for ULI M920x");
1260 MODULE_VERSION("0.1");
1261 MODULE_LICENSE("GPL");