22 #include <asm/unaligned.h>
25 static int dvb_usb_m920x_debug;
40 value, index, data, size, 2000);
47 deb(
"m920x_read = no data\n");
54 static inline int m920x_write(
struct usb_device *udev,
u8 request,
61 value, index,
NULL, 0, 2000);
68 int ret = 0,
i, epi,
flags = 0;
72 if (d->
props.rc.legacy.rc_query) {
73 deb(
"Initialising remote control\n");
78 deb(
"Initialising remote control failed\n");
85 deb(
"Initialising remote control success\n");
88 for (
i = 0;
i < d->
props.num_adapters;
i++)
89 flags |= d->
adapter[
i].props.fe[0].caps;
93 for (
i = 0;
i < d->
props.num_adapters;
i++) {
94 epi = d->
adapter[
i].props.fe[0].stream.endpoint - 0x81;
101 adap_enabled[epi] = 1;
108 if ((ret = m920x_set_filter(d, 0x81 + i, 0, 0x0)) != 0)
111 if ((ret = m920x_set_filter(d, 0x81 + i, 0, 0x02f5)) != 0)
121 struct usb_device *udev = interface_to_usbdev(intf);
122 struct usb_host_interface *alt;
125 deb(
"No alt found!\n");
130 alt->desc.bAlternateSetting);
149 for (i = 0; i < d->
props.rc.legacy.rc_map_size; i++)
150 if (rc5_data(&d->
props.rc.legacy.rc_map_table[i]) == rc_state[1]) {
151 *
event = d->
props.rc.legacy.rc_map_table[
i].keycode;
153 switch(rc_state[0]) {
184 deb(
"Unexpected rc state %02x\n", rc_state[0]);
190 if (rc_state[1] != 0)
191 deb(
"Unknown rc key %02x\n", rc_state[1]);
213 for (i = 0; i < num; i++) {
232 for (j = 0; j < msg[
i].
len; j++) {
235 int stop = (i+1 == num && j+1 == msg[
i].
len) ? 0x40 : 0x01;
239 &msg[i].
buf[j], 1)) != 0)
243 for (j = 0; j < msg[
i].
len; j++) {
245 int stop = (i+1 == num && j+1 == msg[
i].
len) ? 0x40 : 0x00;
267 .master_xfer = m920x_i2c_xfer,
268 .functionality = m920x_i2c_func,
281 if ((ret = m920x_write(d->
udev,
M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
284 if ((ret = m920x_write(d->
udev,
M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
295 int ep = adap->
props.fe[0].stream.endpoint;
302 if ((ret = m920x_set_filter(adap->
dev, ep, 1, enabled)) != 0)
306 if ((ret = m920x_set_filter(adap->
dev, ep, i + 2, 0)) != 0)
315 if ((ret = m920x_set_filter(adap->
dev, ep,
filter + 2, m->
filters[adap->
id][i])) != 0)
331 return m920x_update_filters(adap);
340 return m920x_update_filters(adap);
343 static int m920x_firmware_download(
struct usb_device *udev,
const struct firmware *
fw)
347 int i, pass, ret = 0;
359 if ((ret = m920x_read(udev,
M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
361 deb(
"%*ph\n", 4, read);
363 if ((ret = m920x_read(udev,
M9206_FW, 0x0, 0x0, read, 1)) != 0)
365 deb(
"%x\n", read[0]);
367 for (pass = 0; pass < 2; pass++) {
368 for (i = 0; i + (
sizeof(
u16) * 3) < fw->
size;) {
369 value = get_unaligned_le16(fw->
data + i);
372 index = get_unaligned_le16(fw->
data + i);
375 size = get_unaligned_le16(fw->
data + i);
385 value, index, buff, size, 20);
387 deb(
"error while uploading fw!\n");
396 deb(
"bad firmware file!\n");
406 deb(
"firmware uploaded!\n");
416 static int m920x_identify_state(
struct usb_device *udev,
421 struct usb_host_interface *alt;
424 *cold = (alt ==
NULL) ? 1 : 0;
430 static int m920x_mt352_demod_init(
struct dvb_frontend *fe)
438 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
439 u8 unk1[] = { 0x93, 0x1a };
440 u8 unk2[] = { 0xb5, 0x7a };
442 deb(
"Demod init!\n");
444 if ((ret = mt352_write(fe, config,
ARRAY_SIZE(config))) != 0)
446 if ((ret = mt352_write(fe, clock,
ARRAY_SIZE(clock))) != 0)
448 if ((ret = mt352_write(fe, reset,
ARRAY_SIZE(reset))) != 0)
450 if ((ret = mt352_write(fe, adc_ctl,
ARRAY_SIZE(adc_ctl))) != 0)
452 if ((ret = mt352_write(fe, agc,
ARRAY_SIZE(agc))) != 0)
454 if ((ret = mt352_write(fe, sec_agc,
ARRAY_SIZE(sec_agc))) != 0)
456 if ((ret = mt352_write(fe, unk1,
ARRAY_SIZE(unk1))) != 0)
458 if ((ret = mt352_write(fe, unk2,
ARRAY_SIZE(unk2))) != 0)
465 .demod_address = 0x0f,
467 .demod_init = m920x_mt352_demod_init,
471 .demod_address = 0x08,
479 .request_firmware =
NULL,
483 .demod_address = 0x0b,
491 .request_firmware =
NULL,
502 deb(
"%s\n",__func__);
506 &adap->
dev->i2c_adap);
513 static int m920x_tda10046_08_frontend_attach(
struct dvb_usb_adapter *adap)
515 deb(
"%s\n",__func__);
518 &m920x_tda10046_08_config,
519 &adap->
dev->i2c_adap);
526 static int m920x_tda10046_0b_frontend_attach(
struct dvb_usb_adapter *adap)
528 deb(
"%s\n",__func__);
531 &m920x_tda10046_0b_config,
532 &adap->
dev->i2c_adap);
541 deb(
"%s\n",__func__);
551 deb(
"%s\n",__func__);
561 deb(
"%s\n",__func__);
572 &adap->
dev->i2c_adap, 0x61,
573 TUNER_PHILIPS_FMD1216ME_MK3);
584 static struct m920x_inits tvwalkertwin_rc_init [] = {
625 static struct rc_map_table rc_map_tvwalkertwin_table[] = {
645 static struct rc_map_table rc_map_pinnacle310e_table[] = {
716 deb(
"Probing for m920x device at interface %d\n", bInterfaceNumber);
718 if (bInterfaceNumber == 0) {
726 rc_init_seq = megasky_rc_init;
741 rc_init_seq = tvwalkertwin_rc_init;
755 rc_init_seq = pinnacle310e_init;
770 if ((ret = m920x_init_ep(intf)) < 0)
773 if (d && (ret = m920x_init(d, rc_init_seq)) != 0)
798 .firmware =
"dvb-usb-megasky-02.fw",
799 .download_firmware = m920x_firmware_download,
803 .rc_map_table = rc_map_megasky_table,
804 .rc_map_size =
ARRAY_SIZE(rc_map_megasky_table),
805 .rc_query = m920x_rc_query,
810 .identify_state = m920x_identify_state,
816 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
819 .pid_filter_count = 8,
820 .pid_filter = m920x_pid_filter,
821 .pid_filter_ctrl = m920x_pid_filter_ctrl,
823 .frontend_attach = m920x_mt352_frontend_attach,
824 .tuner_attach = m920x_qt1010_tuner_attach,
838 .i2c_algo = &m920x_i2c_algo,
840 .num_device_descs = 1,
842 {
"MSI Mega Sky 580 DVB-T USB2.0",
843 { &m920x_table[0],
NULL },
853 .firmware =
"dvb-usb-digivox-02.fw",
854 .download_firmware = m920x_firmware_download,
858 .identify_state = m920x_identify_state,
864 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
867 .pid_filter_count = 8,
868 .pid_filter = m920x_pid_filter,
869 .pid_filter_ctrl = m920x_pid_filter_ctrl,
871 .frontend_attach = m920x_tda10046_08_frontend_attach,
872 .tuner_attach = m920x_tda8275_60_tuner_attach,
880 .buffersize = 0x4000,
886 .i2c_algo = &m920x_i2c_algo,
888 .num_device_descs = 1,
890 {
"MSI DIGI VOX mini II DVB-T USB2.0",
891 { &m920x_table[1],
NULL },
909 .firmware =
"dvb-usb-tvwalkert.fw",
910 .download_firmware = m920x_firmware_download,
914 .rc_map_table = rc_map_tvwalkertwin_table,
915 .rc_map_size =
ARRAY_SIZE(rc_map_tvwalkertwin_table),
916 .rc_query = m920x_rc_query,
921 .identify_state = m920x_identify_state,
927 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
930 .pid_filter_count = 8,
931 .pid_filter = m920x_pid_filter,
932 .pid_filter_ctrl = m920x_pid_filter_ctrl,
934 .frontend_attach = m920x_tda10046_08_frontend_attach,
935 .tuner_attach = m920x_tda8275_60_tuner_attach,
951 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
954 .pid_filter_count = 8,
955 .pid_filter = m920x_pid_filter,
956 .pid_filter_ctrl = m920x_pid_filter_ctrl,
958 .frontend_attach = m920x_tda10046_0b_frontend_attach,
959 .tuner_attach = m920x_tda8275_61_tuner_attach,
973 .i2c_algo = &m920x_i2c_algo,
975 .num_device_descs = 1,
977 { .name =
"LifeView TV Walker Twin DVB-T USB2.0",
978 .cold_ids = { &m920x_table[2],
NULL },
979 .warm_ids = { &m920x_table[3],
NULL },
988 .firmware =
"dvb-usb-dposh-01.fw",
989 .download_firmware = m920x_firmware_download,
993 .identify_state = m920x_identify_state,
1000 .frontend_attach = m920x_mt352_frontend_attach,
1001 .tuner_attach = m920x_qt1010_tuner_attach,
1015 .i2c_algo = &m920x_i2c_algo,
1017 .num_device_descs = 1,
1019 { .name =
"Dposh DVB-T USB2.0",
1020 .cold_ids = { &m920x_table[4],
NULL },
1021 .warm_ids = { &m920x_table[5],
NULL },
1030 .download_firmware =
NULL,
1034 .rc_map_table = rc_map_pinnacle310e_table,
1035 .rc_map_size =
ARRAY_SIZE(rc_map_pinnacle310e_table),
1036 .rc_query = m920x_rc_query,
1041 .identify_state = m920x_identify_state,
1047 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
1050 .pid_filter_count = 8,
1051 .pid_filter = m920x_pid_filter,
1052 .pid_filter_ctrl = m920x_pid_filter_ctrl,
1054 .frontend_attach = m920x_mt352_frontend_attach,
1055 .tuner_attach = m920x_fmd1216me_tuner_attach,
1063 .framesperurb = 128,
1071 .i2c_algo = &m920x_i2c_algo,
1073 .num_device_descs = 1,
1075 {
"Pinnacle PCTV 310e",
1076 { &m920x_table[6],
NULL },
1082 static struct usb_driver m920x_driver = {
1083 .name =
"dvb_usb_m920x",
1084 .probe = m920x_probe,
1086 .id_table = m920x_table,