Lines Matching +full:usb +full:- +full:attach

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * DVB USB Linux driver for Anysee E30 DVB-C & DVB-T USB2.0 receiver
8 * - add smart card reader support for Conditional Access (CA)
22 #include "dvb-pll.h"
42 mutex_lock(&d->usb_mutex); in anysee_ctrl_msg()
44 memcpy(&state->buf[0], sbuf, slen); in anysee_ctrl_msg()
45 state->buf[60] = state->seq++; in anysee_ctrl_msg()
47 dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, slen, state->buf); in anysee_ctrl_msg()
53 ret = dvb_usbv2_generic_rw_locked(d, state->buf, sizeof(state->buf), in anysee_ctrl_msg()
54 state->buf, sizeof(state->buf)); in anysee_ctrl_msg()
61 ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, in anysee_ctrl_msg()
62 d->props->generic_bulk_ctrl_endpoint), in anysee_ctrl_msg()
63 state->buf, sizeof(state->buf), &act_len, 2000); in anysee_ctrl_msg()
65 dev_dbg(&d->udev->dev, in anysee_ctrl_msg()
69 dev_dbg(&d->udev->dev, "%s: <<< %*ph\n", __func__, in anysee_ctrl_msg()
70 rlen, state->buf); in anysee_ctrl_msg()
72 if (state->buf[63] != 0x4f) in anysee_ctrl_msg()
73 dev_dbg(&d->udev->dev, in anysee_ctrl_msg()
81 dev_err(&d->udev->dev, "%s: recv bulk message failed=%d\n", in anysee_ctrl_msg()
88 memcpy(rbuf, state->buf, rlen); in anysee_ctrl_msg()
91 mutex_unlock(&d->usb_mutex); in anysee_ctrl_msg()
100 dev_dbg(&d->udev->dev, "%s: reg=%04x val=%02x\n", __func__, reg, *val); in anysee_read_reg()
107 dev_dbg(&d->udev->dev, "%s: reg=%04x val=%02x\n", __func__, reg, val); in anysee_write_reg()
164 dev_dbg(&fe_to_d(fe)->udev->dev, "%s: onoff=%d\n", __func__, onoff); in anysee_streaming_ctrl()
171 dev_dbg(&d->udev->dev, "%s: state=%d interval=%d\n", __func__, in anysee_led_ctrl()
179 dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff); in anysee_ir_ctrl()
189 u8 buf[52]; /* 4 + 48 (I2C WR USB command header + I2C WR max) */ in anysee_master_xfer()
191 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) in anysee_master_xfer()
192 return -EAGAIN; in anysee_master_xfer()
197 ret = -EOPNOTSUPP; in anysee_master_xfer()
204 buf[4] = msg[i].len-1; in anysee_master_xfer()
211 ret = -EOPNOTSUPP; in anysee_master_xfer()
228 mutex_unlock(&d->i2c_mutex); in anysee_master_xfer()
264 /* Callbacks for DVB USB */
365 * New USB device strings: Mfr=1, Product=2, SerialNumber=0
372 * E30 VID=04b4 PID=861f HW=2 FW=2.1 "anysee-T(LP)"
385 * tuner is not behind ZL10353 I2C-gate (no care if gate disabled or not)
387 * E30 C Plus VID=04b4 PID=861f HW=10 FW=1.0 "anysee-DC(LP)"
394 * E30 S2 Plus VID=04b4 PID=861f HW=11 FW=0.1 "anysee-S2(LP)"
401 * E30 C Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
409 * E30 Combo Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
414 * DVB-C:
417 * DVB-T:
420 * tuner is behind ZL10353 I2C-gate
421 * tuner is behind TDA10023 I2C-gate
423 * E7 TC VID=1c73 PID=861f HW=18 FW=0.7 AMTCI=0.5 "anysee-E7TC(LP)"
430 * DVB-C:
434 * DVB-T:
439 * E7 S2 VID=1c73 PID=861f HW=19 FW=0.4 AMTCI=0.5 "anysee-E7S2(LP)"
447 * E7 T2C VID=1c73 PID=861f HW=20 FW=0.1 AMTCI=0.5 "anysee-E7T2C(LP)"
455 * E7 PTC VID=1c73 PID=861f HW=21 FW=0.1 AMTCI=?? "anysee-E7PTC(LP)"
462 * DVB-C:
466 * DVB-T:
471 * E7 PS2 VID=1c73 PID=861f HW=22 FW=0.1 AMTCI=?? "anysee-E7PS2(LP)"
501 dev_info(&d->udev->dev, "%s: firmware version %d.%d hardware id %d\n", in anysee_read_config()
504 state->hw = hw_info[0]; in anysee_read_config()
521 dev_dbg(&d->udev->dev, "%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); in anysee_frontend_ctrl()
527 switch (state->hw) { in anysee_frontend_ctrl()
532 if (fe->id == 0) { in anysee_frontend_ctrl()
533 /* disable DVB-T demod on IOD[0] */ in anysee_frontend_ctrl()
538 /* enable DVB-C demod on IOD[5] */ in anysee_frontend_ctrl()
543 /* enable DVB-C tuner on IOE[0] */ in anysee_frontend_ctrl()
548 /* disable DVB-C demod on IOD[5] */ in anysee_frontend_ctrl()
553 /* enable DVB-T demod on IOD[0] */ in anysee_frontend_ctrl()
558 /* enable DVB-T tuner on IOE[0] */ in anysee_frontend_ctrl()
570 if (fe->id == 0) { in anysee_frontend_ctrl()
571 /* disable DVB-T demod on IOD[6] */ in anysee_frontend_ctrl()
576 /* enable DVB-C demod on IOD[5] */ in anysee_frontend_ctrl()
586 /* disable DVB-C demod on IOD[5] */ in anysee_frontend_ctrl()
591 /* enable DVB-T demod on IOD[6] */ in anysee_frontend_ctrl()
617 struct i2c_adapter *adapter = &d->i2c_adap; in anysee_add_i2c_dev()
627 if (state->i2c_client[num] == NULL) in anysee_add_i2c_dev()
631 dev_dbg(&d->udev->dev, "%s: num=%d\n", __func__, num); in anysee_add_i2c_dev()
634 dev_err(&d->udev->dev, "%s: I2C client out of index\n", in anysee_add_i2c_dev()
636 ret = -ENODEV; in anysee_add_i2c_dev()
645 ret = -ENODEV; in anysee_add_i2c_dev()
650 if (!try_module_get(client->dev.driver->owner)) { in anysee_add_i2c_dev()
652 ret = -ENODEV; in anysee_add_i2c_dev()
656 state->i2c_client[num] = client; in anysee_add_i2c_dev()
659 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); in anysee_add_i2c_dev()
671 while (num--) { in anysee_del_i2c_dev()
672 if (state->i2c_client[num] != NULL) in anysee_del_i2c_dev()
676 dev_dbg(&d->udev->dev, "%s: num=%d\n", __func__, num); in anysee_del_i2c_dev()
678 if (num == -1) { in anysee_del_i2c_dev()
679 dev_err(&d->udev->dev, "%s: I2C client out of index\n", in anysee_del_i2c_dev()
684 client = state->i2c_client[num]; in anysee_del_i2c_dev()
687 module_put(client->dev.driver->owner); in anysee_del_i2c_dev()
692 state->i2c_client[num] = NULL; in anysee_del_i2c_dev()
694 dev_dbg(&d->udev->dev, "%s: failed\n", __func__); in anysee_del_i2c_dev()
717 switch (state->hw) { in anysee_frontend_attach()
721 /* attach demod */ in anysee_frontend_attach()
722 adap->fe[0] = dvb_attach(mt352_attach, &anysee_mt352_config, in anysee_frontend_attach()
723 &d->i2c_adap); in anysee_frontend_attach()
724 if (adap->fe[0]) in anysee_frontend_attach()
727 /* attach demod */ in anysee_frontend_attach()
728 adap->fe[0] = dvb_attach(zl10353_attach, &anysee_zl10353_config, in anysee_frontend_attach()
729 &d->i2c_adap); in anysee_frontend_attach()
735 /* enable DVB-T demod on IOD[0] */ in anysee_frontend_attach()
745 /* attach demod */ in anysee_frontend_attach()
746 adap->fe[0] = dvb_attach(zl10353_attach, &anysee_zl10353_config, in anysee_frontend_attach()
747 &d->i2c_adap); in anysee_frontend_attach()
753 /* enable DVB-C demod on IOD[0] */ in anysee_frontend_attach()
758 /* attach demod */ in anysee_frontend_attach()
759 adap->fe[0] = dvb_attach(tda10023_attach, in anysee_frontend_attach()
760 &anysee_tda10023_config, &d->i2c_adap, 0x48); in anysee_frontend_attach()
766 /* enable DVB-S/S2 demod on IOD[0] */ in anysee_frontend_attach()
771 /* attach demod */ in anysee_frontend_attach()
772 adap->fe[0] = dvb_attach(cx24116_attach, &anysee_cx24116_config, in anysee_frontend_attach()
773 &d->i2c_adap); in anysee_frontend_attach()
787 ret = i2c_transfer(&d->i2c_adap, msg, 2); in anysee_frontend_attach()
789 dev_dbg(&d->udev->dev, "%s: TDA18212 found\n", in anysee_frontend_attach()
791 state->has_tda18212 = true; in anysee_frontend_attach()
801 /* disable DVB-T demod on IOD[0] */ in anysee_frontend_attach()
806 /* enable DVB-C demod on IOD[5] */ in anysee_frontend_attach()
811 /* attach demod */ in anysee_frontend_attach()
814 adap->fe[0] = dvb_attach(tda10023_attach, in anysee_frontend_attach()
816 &d->i2c_adap, 0x48); in anysee_frontend_attach()
819 if (adap->fe[0]) in anysee_frontend_attach()
820 adap->fe[0]->ops.i2c_gate_ctrl = in anysee_frontend_attach()
824 adap->fe[0] = dvb_attach(tda10023_attach, in anysee_frontend_attach()
826 &d->i2c_adap, 0x48); in anysee_frontend_attach()
830 if (!adap->fe[0]) in anysee_frontend_attach()
833 /* disable DVB-C demod on IOD[5] */ in anysee_frontend_attach()
838 /* enable DVB-T demod on IOD[0] */ in anysee_frontend_attach()
843 /* attach demod */ in anysee_frontend_attach()
846 adap->fe[1] = dvb_attach(zl10353_attach, in anysee_frontend_attach()
848 &d->i2c_adap); in anysee_frontend_attach()
851 if (adap->fe[1]) in anysee_frontend_attach()
852 adap->fe[1]->ops.i2c_gate_ctrl = in anysee_frontend_attach()
856 adap->fe[1] = dvb_attach(zl10353_attach, in anysee_frontend_attach()
858 &d->i2c_adap); in anysee_frontend_attach()
867 /* disable DVB-T demod on IOD[6] */ in anysee_frontend_attach()
872 /* enable DVB-C demod on IOD[5] */ in anysee_frontend_attach()
877 /* attach demod */ in anysee_frontend_attach()
878 adap->fe[0] = dvb_attach(tda10023_attach, in anysee_frontend_attach()
880 &d->i2c_adap, 0x48); in anysee_frontend_attach()
883 if (adap->fe[0]) in anysee_frontend_attach()
884 adap->fe[0]->ops.i2c_gate_ctrl = anysee_i2c_gate_ctrl; in anysee_frontend_attach()
887 if (!adap->fe[0]) in anysee_frontend_attach()
890 /* disable DVB-C demod on IOD[5] */ in anysee_frontend_attach()
895 /* enable DVB-T demod on IOD[6] */ in anysee_frontend_attach()
900 /* attach demod */ in anysee_frontend_attach()
901 adap->fe[1] = dvb_attach(zl10353_attach, in anysee_frontend_attach()
903 &d->i2c_adap); in anysee_frontend_attach()
906 if (adap->fe[1]) in anysee_frontend_attach()
907 adap->fe[1]->ops.i2c_gate_ctrl = anysee_i2c_gate_ctrl; in anysee_frontend_attach()
909 state->has_ci = true; in anysee_frontend_attach()
917 /* enable DVB-S/S2 demod on IOE[5] */ in anysee_frontend_attach()
922 /* attach demod */ in anysee_frontend_attach()
923 adap->fe[0] = dvb_attach(stv0900_attach, in anysee_frontend_attach()
924 &anysee_stv0900_config, &d->i2c_adap, 0); in anysee_frontend_attach()
926 state->has_ci = true; in anysee_frontend_attach()
932 /* enable DVB-T/T2/C demod on IOE[5] */ in anysee_frontend_attach()
937 /* attach demod */ in anysee_frontend_attach()
938 adap->fe[0] = dvb_attach(cxd2820r_attach, in anysee_frontend_attach()
939 &anysee_cxd2820r_config, &d->i2c_adap, NULL); in anysee_frontend_attach()
941 state->has_ci = true; in anysee_frontend_attach()
946 if (!adap->fe[0]) { in anysee_frontend_attach()
947 /* we have no frontend :-( */ in anysee_frontend_attach()
948 ret = -ENODEV; in anysee_frontend_attach()
949 dev_err(&d->udev->dev, in anysee_frontend_attach()
950 "%s: Unsupported Anysee version. Please report to <linux-[email protected]>.\n", in anysee_frontend_attach()
963 dev_dbg(&d->udev->dev, "%s:\n", __func__); in anysee_tuner_attach()
965 switch (state->hw) { in anysee_tuner_attach()
969 /* attach tuner */ in anysee_tuner_attach()
970 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc2 >> 1), NULL, in anysee_tuner_attach()
977 /* attach tuner */ in anysee_tuner_attach()
978 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc2 >> 1), in anysee_tuner_attach()
979 &d->i2c_adap, DVB_PLL_THOMSON_DTT7579); in anysee_tuner_attach()
985 /* attach tuner */ in anysee_tuner_attach()
986 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc0 >> 1), in anysee_tuner_attach()
987 &d->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); in anysee_tuner_attach()
993 /* attach LNB controller */ in anysee_tuner_attach()
994 fe = dvb_attach(isl6423_attach, adap->fe[0], &d->i2c_adap, in anysee_tuner_attach()
1002 /* Try first attach TDA18212 silicon tuner on IOE[4], if that in anysee_tuner_attach()
1003 * fails attach old simple PLL. */ in anysee_tuner_attach()
1005 /* attach tuner */ in anysee_tuner_attach()
1006 if (state->has_tda18212) { in anysee_tuner_attach()
1010 tda18212_config.fe = adap->fe[0]; in anysee_tuner_attach()
1017 if (adap->fe[1]) { in anysee_tuner_attach()
1018 adap->fe[1]->tuner_priv = in anysee_tuner_attach()
1019 adap->fe[0]->tuner_priv; in anysee_tuner_attach()
1020 memcpy(&adap->fe[1]->ops.tuner_ops, in anysee_tuner_attach()
1021 &adap->fe[0]->ops.tuner_ops, in anysee_tuner_attach()
1027 /* attach tuner */ in anysee_tuner_attach()
1028 fe = dvb_attach(dvb_pll_attach, adap->fe[0], in anysee_tuner_attach()
1029 (0xc0 >> 1), &d->i2c_adap, in anysee_tuner_attach()
1032 if (fe && adap->fe[1]) { in anysee_tuner_attach()
1033 /* attach tuner for 2nd FE */ in anysee_tuner_attach()
1034 fe = dvb_attach(dvb_pll_attach, adap->fe[1], in anysee_tuner_attach()
1035 (0xc0 >> 1), &d->i2c_adap, in anysee_tuner_attach()
1048 tda18212_config.fe = adap->fe[0]; in anysee_tuner_attach()
1054 if (adap->fe[1]) { in anysee_tuner_attach()
1055 adap->fe[1]->tuner_priv = adap->fe[0]->tuner_priv; in anysee_tuner_attach()
1056 memcpy(&adap->fe[1]->ops.tuner_ops, in anysee_tuner_attach()
1057 &adap->fe[0]->ops.tuner_ops, in anysee_tuner_attach()
1068 /* attach tuner */ in anysee_tuner_attach()
1069 fe = dvb_attach(stv6110_attach, adap->fe[0], in anysee_tuner_attach()
1070 &anysee_stv6110_config, &d->i2c_adap); in anysee_tuner_attach()
1073 /* attach LNB controller */ in anysee_tuner_attach()
1074 fe = dvb_attach(isl6423_attach, adap->fe[0], in anysee_tuner_attach()
1075 &d->i2c_adap, &anysee_isl6423_config); in anysee_tuner_attach()
1086 tda18212_config.fe = adap->fe[0]; in anysee_tuner_attach()
1100 ret = -ENODEV; in anysee_tuner_attach()
1125 dev_dbg(&d->udev->dev, "%s: key pressed %02x\n", __func__, in anysee_rc_query()
1127 rc_keydown(d->rc_dev, RC_PROTO_NEC, in anysee_rc_query()
1136 rc->allowed_protos = RC_PROTO_BIT_NEC; in anysee_get_rc_config()
1137 rc->query = anysee_rc_query; in anysee_get_rc_config()
1138 rc->interval = 250; /* windows driver uses 500ms */ in anysee_get_rc_config()
1149 struct dvb_usb_device *d = ci->data; in anysee_ci_read_attribute_mem()
1164 struct dvb_usb_device *d = ci->data; in anysee_ci_write_attribute_mem()
1173 struct dvb_usb_device *d = ci->data; in anysee_ci_read_cam_control()
1188 struct dvb_usb_device *d = ci->data; in anysee_ci_write_cam_control()
1196 struct dvb_usb_device *d = ci->data; in anysee_ci_slot_reset()
1200 state->ci_cam_ready = jiffies + msecs_to_jiffies(1000); in anysee_ci_slot_reset()
1217 struct dvb_usb_device *d = ci->data; in anysee_ci_slot_shutdown()
1235 struct dvb_usb_device *d = ci->data; in anysee_ci_slot_ts_enable()
1243 struct dvb_usb_device *d = ci->data; in anysee_ci_poll_slot_status()
1254 if (time_after(jiffies, state->ci_cam_ready)) in anysee_ci_poll_slot_status()
1266 state->ci.owner = THIS_MODULE; in anysee_ci_init()
1267 state->ci.read_attribute_mem = anysee_ci_read_attribute_mem; in anysee_ci_init()
1268 state->ci.write_attribute_mem = anysee_ci_write_attribute_mem; in anysee_ci_init()
1269 state->ci.read_cam_control = anysee_ci_read_cam_control; in anysee_ci_init()
1270 state->ci.write_cam_control = anysee_ci_write_cam_control; in anysee_ci_init()
1271 state->ci.slot_reset = anysee_ci_slot_reset; in anysee_ci_init()
1272 state->ci.slot_shutdown = anysee_ci_slot_shutdown; in anysee_ci_init()
1273 state->ci.slot_ts_enable = anysee_ci_slot_ts_enable; in anysee_ci_init()
1274 state->ci.poll_slot_status = anysee_ci_poll_slot_status; in anysee_ci_init()
1275 state->ci.data = d; in anysee_ci_init()
1289 ret = dvb_ca_en50221_init(&d->adapter[0].dvb_adap, &state->ci, 0, 1); in anysee_ci_init()
1293 state->ci_attached = true; in anysee_ci_init()
1303 if (state->ci_attached) in anysee_ci_release()
1304 dvb_ca_en50221_release(&state->ci); in anysee_ci_release()
1318 ret = usb_set_interface(d->udev, 0, 0); in anysee_init()
1332 /* attach CI */ in anysee_init()
1333 if (state->has_ci) { in anysee_init()
1346 if (state->i2c_client[0]) in anysee_exit()
1352 /* DVB USB Driver stuff */
1387 MODULE_DEVICE_TABLE(usb, anysee_id_table);
1404 MODULE_DESCRIPTION("Driver Anysee E30 DVB-C & DVB-T USB2.0");