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()
51 ret = dvb_usbv2_generic_rw_locked(d, state->buf, sizeof(state->buf), in anysee_ctrl_msg()
52 state->buf, sizeof(state->buf)); in anysee_ctrl_msg()
56 /* TODO FIXME: dvb_usb_generic_rw() fails rarely with error code -32 in anysee_ctrl_msg()
59 * Documentation/timers/timers-howto.rst it should not be used such in anysee_ctrl_msg()
70 ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, in anysee_ctrl_msg()
71 d->props->generic_bulk_ctrl_endpoint), in anysee_ctrl_msg()
72 state->buf, sizeof(state->buf), &act_len, 2000); in anysee_ctrl_msg()
74 dev_dbg(&d->udev->dev, in anysee_ctrl_msg()
78 dev_dbg(&d->udev->dev, "%s: <<< %*ph\n", __func__, in anysee_ctrl_msg()
79 rlen, state->buf); in anysee_ctrl_msg()
81 if (state->buf[63] != 0x4f) in anysee_ctrl_msg()
82 dev_dbg(&d->udev->dev, in anysee_ctrl_msg()
90 dev_err(&d->udev->dev, "%s: recv bulk message failed=%d\n", in anysee_ctrl_msg()
97 memcpy(rbuf, state->buf, rlen); in anysee_ctrl_msg()
100 mutex_unlock(&d->usb_mutex); in anysee_ctrl_msg()
109 dev_dbg(&d->udev->dev, "%s: reg=%04x val=%02x\n", __func__, reg, *val); in anysee_read_reg()
116 dev_dbg(&d->udev->dev, "%s: reg=%04x val=%02x\n", __func__, reg, val); in anysee_write_reg()
173 dev_dbg(&fe_to_d(fe)->udev->dev, "%s: onoff=%d\n", __func__, onoff); in anysee_streaming_ctrl()
180 dev_dbg(&d->udev->dev, "%s: state=%d interval=%d\n", __func__, in anysee_led_ctrl()
188 dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff); in anysee_ir_ctrl()
198 u8 buf[52]; /* 4 + 48 (I2C WR USB command header + I2C WR max) */ in anysee_master_xfer()
200 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) in anysee_master_xfer()
201 return -EAGAIN; in anysee_master_xfer()
206 ret = -EOPNOTSUPP; in anysee_master_xfer()
213 buf[4] = msg[i].len-1; in anysee_master_xfer()
220 ret = -EOPNOTSUPP; in anysee_master_xfer()
237 mutex_unlock(&d->i2c_mutex); in anysee_master_xfer()
273 /* Callbacks for DVB USB */
374 * New USB device strings: Mfr=1, Product=2, SerialNumber=0
381 * E30 VID=04b4 PID=861f HW=2 FW=2.1 "anysee-T(LP)"
394 * tuner is not behind ZL10353 I2C-gate (no care if gate disabled or not)
396 * E30 C Plus VID=04b4 PID=861f HW=10 FW=1.0 "anysee-DC(LP)"
403 * E30 S2 Plus VID=04b4 PID=861f HW=11 FW=0.1 "anysee-S2(LP)"
410 * E30 C Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
418 * E30 Combo Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
423 * DVB-C:
426 * DVB-T:
429 * tuner is behind ZL10353 I2C-gate
430 * tuner is behind TDA10023 I2C-gate
432 * E7 TC VID=1c73 PID=861f HW=18 FW=0.7 AMTCI=0.5 "anysee-E7TC(LP)"
439 * DVB-C:
443 * DVB-T:
448 * E7 S2 VID=1c73 PID=861f HW=19 FW=0.4 AMTCI=0.5 "anysee-E7S2(LP)"
456 * E7 T2C VID=1c73 PID=861f HW=20 FW=0.1 AMTCI=0.5 "anysee-E7T2C(LP)"
464 * E7 PTC VID=1c73 PID=861f HW=21 FW=0.1 AMTCI=?? "anysee-E7PTC(LP)"
471 * DVB-C:
475 * DVB-T:
480 * E7 PS2 VID=1c73 PID=861f HW=22 FW=0.1 AMTCI=?? "anysee-E7PS2(LP)"
510 dev_info(&d->udev->dev, "%s: firmware version %d.%d hardware id %d\n", in anysee_read_config()
513 state->hw = hw_info[0]; in anysee_read_config()
530 dev_dbg(&d->udev->dev, "%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); in anysee_frontend_ctrl()
536 switch (state->hw) { in anysee_frontend_ctrl()
541 if (fe->id == 0) { in anysee_frontend_ctrl()
542 /* disable DVB-T demod on IOD[0] */ in anysee_frontend_ctrl()
547 /* enable DVB-C demod on IOD[5] */ in anysee_frontend_ctrl()
552 /* enable DVB-C tuner on IOE[0] */ in anysee_frontend_ctrl()
557 /* disable DVB-C demod on IOD[5] */ in anysee_frontend_ctrl()
562 /* enable DVB-T demod on IOD[0] */ in anysee_frontend_ctrl()
567 /* enable DVB-T tuner on IOE[0] */ in anysee_frontend_ctrl()
579 if (fe->id == 0) { in anysee_frontend_ctrl()
580 /* disable DVB-T demod on IOD[6] */ in anysee_frontend_ctrl()
585 /* enable DVB-C demod on IOD[5] */ in anysee_frontend_ctrl()
595 /* disable DVB-C demod on IOD[5] */ in anysee_frontend_ctrl()
600 /* enable DVB-T demod on IOD[6] */ in anysee_frontend_ctrl()
626 struct i2c_adapter *adapter = &d->i2c_adap; in anysee_add_i2c_dev()
636 if (state->i2c_client[num] == NULL) in anysee_add_i2c_dev()
640 dev_dbg(&d->udev->dev, "%s: num=%d\n", __func__, num); in anysee_add_i2c_dev()
643 dev_err(&d->udev->dev, "%s: I2C client out of index\n", in anysee_add_i2c_dev()
645 ret = -ENODEV; in anysee_add_i2c_dev()
654 ret = -ENODEV; in anysee_add_i2c_dev()
659 if (!try_module_get(client->dev.driver->owner)) { in anysee_add_i2c_dev()
661 ret = -ENODEV; in anysee_add_i2c_dev()
665 state->i2c_client[num] = client; in anysee_add_i2c_dev()
668 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); in anysee_add_i2c_dev()
680 while (num--) { in anysee_del_i2c_dev()
681 if (state->i2c_client[num] != NULL) in anysee_del_i2c_dev()
685 dev_dbg(&d->udev->dev, "%s: num=%d\n", __func__, num); in anysee_del_i2c_dev()
687 if (num == -1) { in anysee_del_i2c_dev()
688 dev_err(&d->udev->dev, "%s: I2C client out of index\n", in anysee_del_i2c_dev()
693 client = state->i2c_client[num]; in anysee_del_i2c_dev()
696 module_put(client->dev.driver->owner); in anysee_del_i2c_dev()
701 state->i2c_client[num] = NULL; in anysee_del_i2c_dev()
703 dev_dbg(&d->udev->dev, "%s: failed\n", __func__); in anysee_del_i2c_dev()
726 switch (state->hw) { in anysee_frontend_attach()
730 /* attach demod */ in anysee_frontend_attach()
731 adap->fe[0] = dvb_attach(mt352_attach, &anysee_mt352_config, in anysee_frontend_attach()
732 &d->i2c_adap); in anysee_frontend_attach()
733 if (adap->fe[0]) in anysee_frontend_attach()
736 /* attach demod */ in anysee_frontend_attach()
737 adap->fe[0] = dvb_attach(zl10353_attach, &anysee_zl10353_config, in anysee_frontend_attach()
738 &d->i2c_adap); in anysee_frontend_attach()
744 /* enable DVB-T demod on IOD[0] */ in anysee_frontend_attach()
754 /* attach demod */ in anysee_frontend_attach()
755 adap->fe[0] = dvb_attach(zl10353_attach, &anysee_zl10353_config, in anysee_frontend_attach()
756 &d->i2c_adap); in anysee_frontend_attach()
762 /* enable DVB-C demod on IOD[0] */ in anysee_frontend_attach()
767 /* attach demod */ in anysee_frontend_attach()
768 adap->fe[0] = dvb_attach(tda10023_attach, in anysee_frontend_attach()
769 &anysee_tda10023_config, &d->i2c_adap, 0x48); in anysee_frontend_attach()
775 /* enable DVB-S/S2 demod on IOD[0] */ in anysee_frontend_attach()
780 /* attach demod */ in anysee_frontend_attach()
781 adap->fe[0] = dvb_attach(cx24116_attach, &anysee_cx24116_config, in anysee_frontend_attach()
782 &d->i2c_adap); in anysee_frontend_attach()
796 ret = i2c_transfer(&d->i2c_adap, msg, 2); in anysee_frontend_attach()
798 dev_dbg(&d->udev->dev, "%s: TDA18212 found\n", in anysee_frontend_attach()
800 state->has_tda18212 = true; in anysee_frontend_attach()
810 /* disable DVB-T demod on IOD[0] */ in anysee_frontend_attach()
815 /* enable DVB-C demod on IOD[5] */ in anysee_frontend_attach()
820 /* attach demod */ in anysee_frontend_attach()
823 adap->fe[0] = dvb_attach(tda10023_attach, in anysee_frontend_attach()
825 &d->i2c_adap, 0x48); in anysee_frontend_attach()
828 if (adap->fe[0]) in anysee_frontend_attach()
829 adap->fe[0]->ops.i2c_gate_ctrl = in anysee_frontend_attach()
833 adap->fe[0] = dvb_attach(tda10023_attach, in anysee_frontend_attach()
835 &d->i2c_adap, 0x48); in anysee_frontend_attach()
839 if (!adap->fe[0]) in anysee_frontend_attach()
842 /* disable DVB-C demod on IOD[5] */ in anysee_frontend_attach()
847 /* enable DVB-T demod on IOD[0] */ in anysee_frontend_attach()
852 /* attach demod */ in anysee_frontend_attach()
855 adap->fe[1] = dvb_attach(zl10353_attach, in anysee_frontend_attach()
857 &d->i2c_adap); in anysee_frontend_attach()
860 if (adap->fe[1]) in anysee_frontend_attach()
861 adap->fe[1]->ops.i2c_gate_ctrl = in anysee_frontend_attach()
865 adap->fe[1] = dvb_attach(zl10353_attach, in anysee_frontend_attach()
867 &d->i2c_adap); in anysee_frontend_attach()
876 /* disable DVB-T demod on IOD[6] */ in anysee_frontend_attach()
881 /* enable DVB-C demod on IOD[5] */ in anysee_frontend_attach()
886 /* attach demod */ in anysee_frontend_attach()
887 adap->fe[0] = dvb_attach(tda10023_attach, in anysee_frontend_attach()
889 &d->i2c_adap, 0x48); in anysee_frontend_attach()
892 if (adap->fe[0]) in anysee_frontend_attach()
893 adap->fe[0]->ops.i2c_gate_ctrl = anysee_i2c_gate_ctrl; in anysee_frontend_attach()
896 if (!adap->fe[0]) in anysee_frontend_attach()
899 /* disable DVB-C demod on IOD[5] */ in anysee_frontend_attach()
904 /* enable DVB-T demod on IOD[6] */ in anysee_frontend_attach()
909 /* attach demod */ in anysee_frontend_attach()
910 adap->fe[1] = dvb_attach(zl10353_attach, in anysee_frontend_attach()
912 &d->i2c_adap); in anysee_frontend_attach()
915 if (adap->fe[1]) in anysee_frontend_attach()
916 adap->fe[1]->ops.i2c_gate_ctrl = anysee_i2c_gate_ctrl; in anysee_frontend_attach()
918 state->has_ci = true; in anysee_frontend_attach()
926 /* enable DVB-S/S2 demod on IOE[5] */ in anysee_frontend_attach()
931 /* attach demod */ in anysee_frontend_attach()
932 adap->fe[0] = dvb_attach(stv0900_attach, in anysee_frontend_attach()
933 &anysee_stv0900_config, &d->i2c_adap, 0); in anysee_frontend_attach()
935 state->has_ci = true; in anysee_frontend_attach()
941 /* enable DVB-T/T2/C demod on IOE[5] */ in anysee_frontend_attach()
946 /* attach demod */ in anysee_frontend_attach()
947 adap->fe[0] = dvb_attach(cxd2820r_attach, in anysee_frontend_attach()
948 &anysee_cxd2820r_config, &d->i2c_adap, NULL); in anysee_frontend_attach()
950 state->has_ci = true; in anysee_frontend_attach()
955 if (!adap->fe[0]) { in anysee_frontend_attach()
956 /* we have no frontend :-( */ in anysee_frontend_attach()
957 ret = -ENODEV; in anysee_frontend_attach()
958 dev_err(&d->udev->dev, in anysee_frontend_attach()
959 "%s: Unsupported Anysee version. Please report to <linux-media@vger.kernel.org>.\n", in anysee_frontend_attach()
972 dev_dbg(&d->udev->dev, "%s:\n", __func__); in anysee_tuner_attach()
974 switch (state->hw) { in anysee_tuner_attach()
978 /* attach tuner */ in anysee_tuner_attach()
979 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc2 >> 1), NULL, in anysee_tuner_attach()
986 /* attach tuner */ in anysee_tuner_attach()
987 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc2 >> 1), in anysee_tuner_attach()
988 &d->i2c_adap, DVB_PLL_THOMSON_DTT7579); in anysee_tuner_attach()
994 /* attach tuner */ in anysee_tuner_attach()
995 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc0 >> 1), in anysee_tuner_attach()
996 &d->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); in anysee_tuner_attach()
1002 /* attach LNB controller */ in anysee_tuner_attach()
1003 fe = dvb_attach(isl6423_attach, adap->fe[0], &d->i2c_adap, in anysee_tuner_attach()
1011 /* Try first attach TDA18212 silicon tuner on IOE[4], if that in anysee_tuner_attach()
1012 * fails attach old simple PLL. */ in anysee_tuner_attach()
1014 /* attach tuner */ in anysee_tuner_attach()
1015 if (state->has_tda18212) { in anysee_tuner_attach()
1019 tda18212_config.fe = adap->fe[0]; in anysee_tuner_attach()
1026 if (adap->fe[1]) { in anysee_tuner_attach()
1027 adap->fe[1]->tuner_priv = in anysee_tuner_attach()
1028 adap->fe[0]->tuner_priv; in anysee_tuner_attach()
1029 memcpy(&adap->fe[1]->ops.tuner_ops, in anysee_tuner_attach()
1030 &adap->fe[0]->ops.tuner_ops, in anysee_tuner_attach()
1036 /* attach tuner */ in anysee_tuner_attach()
1037 fe = dvb_attach(dvb_pll_attach, adap->fe[0], in anysee_tuner_attach()
1038 (0xc0 >> 1), &d->i2c_adap, in anysee_tuner_attach()
1041 if (fe && adap->fe[1]) { in anysee_tuner_attach()
1042 /* attach tuner for 2nd FE */ in anysee_tuner_attach()
1043 fe = dvb_attach(dvb_pll_attach, adap->fe[1], in anysee_tuner_attach()
1044 (0xc0 >> 1), &d->i2c_adap, in anysee_tuner_attach()
1057 tda18212_config.fe = adap->fe[0]; in anysee_tuner_attach()
1063 if (adap->fe[1]) { in anysee_tuner_attach()
1064 adap->fe[1]->tuner_priv = adap->fe[0]->tuner_priv; in anysee_tuner_attach()
1065 memcpy(&adap->fe[1]->ops.tuner_ops, in anysee_tuner_attach()
1066 &adap->fe[0]->ops.tuner_ops, in anysee_tuner_attach()
1077 /* attach tuner */ in anysee_tuner_attach()
1078 fe = dvb_attach(stv6110_attach, adap->fe[0], in anysee_tuner_attach()
1079 &anysee_stv6110_config, &d->i2c_adap); in anysee_tuner_attach()
1082 /* attach LNB controller */ in anysee_tuner_attach()
1083 fe = dvb_attach(isl6423_attach, adap->fe[0], in anysee_tuner_attach()
1084 &d->i2c_adap, &anysee_isl6423_config); in anysee_tuner_attach()
1095 tda18212_config.fe = adap->fe[0]; in anysee_tuner_attach()
1109 ret = -ENODEV; in anysee_tuner_attach()
1134 dev_dbg(&d->udev->dev, "%s: key pressed %02x\n", __func__, in anysee_rc_query()
1136 rc_keydown(d->rc_dev, RC_PROTO_NEC, in anysee_rc_query()
1145 rc->allowed_protos = RC_PROTO_BIT_NEC; in anysee_get_rc_config()
1146 rc->query = anysee_rc_query; in anysee_get_rc_config()
1147 rc->interval = 250; /* windows driver uses 500ms */ in anysee_get_rc_config()
1158 struct dvb_usb_device *d = ci->data; in anysee_ci_read_attribute_mem()
1173 struct dvb_usb_device *d = ci->data; in anysee_ci_write_attribute_mem()
1182 struct dvb_usb_device *d = ci->data; in anysee_ci_read_cam_control()
1197 struct dvb_usb_device *d = ci->data; in anysee_ci_write_cam_control()
1205 struct dvb_usb_device *d = ci->data; in anysee_ci_slot_reset()
1209 state->ci_cam_ready = jiffies + msecs_to_jiffies(1000); in anysee_ci_slot_reset()
1226 struct dvb_usb_device *d = ci->data; in anysee_ci_slot_shutdown()
1244 struct dvb_usb_device *d = ci->data; in anysee_ci_slot_ts_enable()
1252 struct dvb_usb_device *d = ci->data; in anysee_ci_poll_slot_status()
1263 if (time_after(jiffies, state->ci_cam_ready)) in anysee_ci_poll_slot_status()
1275 state->ci.owner = THIS_MODULE; in anysee_ci_init()
1276 state->ci.read_attribute_mem = anysee_ci_read_attribute_mem; in anysee_ci_init()
1277 state->ci.write_attribute_mem = anysee_ci_write_attribute_mem; in anysee_ci_init()
1278 state->ci.read_cam_control = anysee_ci_read_cam_control; in anysee_ci_init()
1279 state->ci.write_cam_control = anysee_ci_write_cam_control; in anysee_ci_init()
1280 state->ci.slot_reset = anysee_ci_slot_reset; in anysee_ci_init()
1281 state->ci.slot_shutdown = anysee_ci_slot_shutdown; in anysee_ci_init()
1282 state->ci.slot_ts_enable = anysee_ci_slot_ts_enable; in anysee_ci_init()
1283 state->ci.poll_slot_status = anysee_ci_poll_slot_status; in anysee_ci_init()
1284 state->ci.data = d; in anysee_ci_init()
1298 ret = dvb_ca_en50221_init(&d->adapter[0].dvb_adap, &state->ci, 0, 1); in anysee_ci_init()
1302 state->ci_attached = true; in anysee_ci_init()
1312 if (state->ci_attached) in anysee_ci_release()
1313 dvb_ca_en50221_release(&state->ci); in anysee_ci_release()
1327 ret = usb_set_interface(d->udev, 0, 0); in anysee_init()
1341 /* attach CI */ in anysee_init()
1342 if (state->has_ci) { in anysee_init()
1355 if (state->i2c_client[0]) in anysee_exit()
1361 /* DVB USB Driver stuff */
1396 MODULE_DEVICE_TABLE(usb, anysee_id_table);
1413 MODULE_DESCRIPTION("Driver Anysee E30 DVB-C & DVB-T USB2.0");