Lines Matching +full:1 +full:- +full:d

1 // SPDX-License-Identifier: GPL-2.0-or-later
39 static int dvbsky_usb_generic_rw(struct dvb_usb_device *d, in dvbsky_usb_generic_rw() argument
43 struct dvbsky_state *state = d_to_priv(d); in dvbsky_usb_generic_rw()
45 mutex_lock(&d->usb_mutex); in dvbsky_usb_generic_rw()
47 memcpy(state->obuf, wbuf, wlen); in dvbsky_usb_generic_rw()
49 ret = dvb_usbv2_generic_rw_locked(d, state->obuf, wlen, in dvbsky_usb_generic_rw()
50 state->ibuf, rlen); in dvbsky_usb_generic_rw()
53 memcpy(rbuf, state->ibuf, rlen); in dvbsky_usb_generic_rw()
55 mutex_unlock(&d->usb_mutex); in dvbsky_usb_generic_rw()
59 static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff) in dvbsky_stream_ctrl() argument
61 struct dvbsky_state *state = d_to_priv(d); in dvbsky_stream_ctrl()
66 mutex_lock(&d->usb_mutex); in dvbsky_stream_ctrl()
67 memcpy(state->obuf, obuf_pre, 3); in dvbsky_stream_ctrl()
68 ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3); in dvbsky_stream_ctrl()
71 memcpy(state->obuf, obuf_post, 3); in dvbsky_stream_ctrl()
72 ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3); in dvbsky_stream_ctrl()
74 mutex_unlock(&d->usb_mutex); in dvbsky_stream_ctrl()
80 struct dvb_usb_device *d = fe_to_d(fe); in dvbsky_streaming_ctrl() local
82 return dvbsky_stream_ctrl(d, (onoff == 0) ? 0 : 1); in dvbsky_streaming_ctrl()
86 static int dvbsky_gpio_ctrl(struct dvb_usb_device *d, u8 gport, u8 value) in dvbsky_gpio_ctrl() argument
92 obuf[1] = gport; in dvbsky_gpio_ctrl()
94 ret = dvbsky_usb_generic_rw(d, obuf, 3, ibuf, 1); in dvbsky_gpio_ctrl()
102 struct dvb_usb_device *d = i2c_get_adapdata(adap); in dvbsky_i2c_xfer() local
106 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) in dvbsky_i2c_xfer()
107 return -EAGAIN; in dvbsky_i2c_xfer()
110 dev_err(&d->udev->dev, in dvbsky_i2c_xfer()
111 "too many i2c messages[%d], max 2.", num); in dvbsky_i2c_xfer()
112 ret = -EOPNOTSUPP; in dvbsky_i2c_xfer()
116 if (num == 1) { in dvbsky_i2c_xfer()
118 dev_err(&d->udev->dev, in dvbsky_i2c_xfer()
119 "too many i2c bytes[%d], max 60.", in dvbsky_i2c_xfer()
121 ret = -EOPNOTSUPP; in dvbsky_i2c_xfer()
127 obuf[1] = 0; in dvbsky_i2c_xfer()
130 ret = dvbsky_usb_generic_rw(d, obuf, 4, in dvbsky_i2c_xfer()
131 ibuf, msg[0].len + 1); in dvbsky_i2c_xfer()
133 memcpy(msg[0].buf, &ibuf[1], msg[0].len); in dvbsky_i2c_xfer()
137 obuf[1] = msg[0].addr; in dvbsky_i2c_xfer()
140 ret = dvbsky_usb_generic_rw(d, obuf, in dvbsky_i2c_xfer()
141 msg[0].len + 3, ibuf, 1); in dvbsky_i2c_xfer()
144 if ((msg[0].len > 60) || (msg[1].len > 60)) { in dvbsky_i2c_xfer()
145 dev_err(&d->udev->dev, in dvbsky_i2c_xfer()
146 "too many i2c bytes[w-%d][r-%d], max 60.", in dvbsky_i2c_xfer()
147 msg[0].len, msg[1].len); in dvbsky_i2c_xfer()
148 ret = -EOPNOTSUPP; in dvbsky_i2c_xfer()
153 obuf[1] = msg[0].len; in dvbsky_i2c_xfer()
154 obuf[2] = msg[1].len; in dvbsky_i2c_xfer()
157 ret = dvbsky_usb_generic_rw(d, obuf, in dvbsky_i2c_xfer()
158 msg[0].len + 4, ibuf, msg[1].len + 1); in dvbsky_i2c_xfer()
160 memcpy(msg[1].buf, &ibuf[1], msg[1].len); in dvbsky_i2c_xfer()
163 mutex_unlock(&d->i2c_mutex); in dvbsky_i2c_xfer()
178 static int dvbsky_rc_query(struct dvb_usb_device *d) in dvbsky_rc_query() argument
186 ret = dvbsky_usb_generic_rw(d, obuf, 1, ibuf, 2); in dvbsky_rc_query()
188 code = (ibuf[0] << 8) | ibuf[1]; in dvbsky_rc_query()
190 dev_dbg(&d->udev->dev, "rc code: %x\n", code); in dvbsky_rc_query()
193 toggle = (code & 0x800) ? 1 : 0; in dvbsky_rc_query()
195 rc_keydown(d->rc_dev, RC_PROTO_RC5, scancode, toggle); in dvbsky_rc_query()
200 static int dvbsky_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) in dvbsky_get_rc_config() argument
203 rc->map_name = NULL; in dvbsky_get_rc_config()
207 rc->allowed_protos = RC_PROTO_BIT_RC5; in dvbsky_get_rc_config()
208 rc->query = dvbsky_rc_query; in dvbsky_get_rc_config()
209 rc->interval = 300; in dvbsky_get_rc_config()
219 struct dvb_usb_device *d = fe_to_d(fe); in dvbsky_usb_set_voltage() local
220 struct dvbsky_state *state = d_to_priv(d); in dvbsky_usb_set_voltage()
226 value = 1; in dvbsky_usb_set_voltage()
227 dvbsky_gpio_ctrl(d, 0x80, value); in dvbsky_usb_set_voltage()
229 return state->fe_set_voltage(fe, voltage); in dvbsky_usb_set_voltage()
234 struct dvb_usb_device *d = adap_to_d(adap); in dvbsky_read_mac_addr() local
251 if (i2c_transfer(&d->i2c_adap, msg, 2) == 2) in dvbsky_read_mac_addr()
260 struct dvb_usb_device *d = fe_to_d(fe); in dvbsky_usb_read_status() local
261 struct dvbsky_state *state = d_to_priv(d); in dvbsky_usb_read_status()
264 ret = state->fe_read_status(fe, status); in dvbsky_usb_read_status()
267 if ((*status & FE_HAS_LOCK) && (!state->last_lock)) in dvbsky_usb_read_status()
268 dvbsky_stream_ctrl(d, 1); in dvbsky_usb_read_status()
270 state->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0; in dvbsky_usb_read_status()
277 struct dvb_usb_device *d = adap_to_d(adap); in dvbsky_s960_attach() local
290 m88ds3103_pdata.lnb_hv_pol = 1; in dvbsky_s960_attach()
291 m88ds3103_pdata.lnb_en_pol = 1; in dvbsky_s960_attach()
293 state->i2c_client_demod = dvb_module_probe("m88ds3103", NULL, in dvbsky_s960_attach()
294 &d->i2c_adap, in dvbsky_s960_attach()
296 if (!state->i2c_client_demod) in dvbsky_s960_attach()
297 return -ENODEV; in dvbsky_s960_attach()
299 adap->fe[0] = m88ds3103_pdata.get_dvb_frontend(state->i2c_client_demod); in dvbsky_s960_attach()
300 i2c_adapter = m88ds3103_pdata.get_i2c_adapter(state->i2c_client_demod); in dvbsky_s960_attach()
303 ts2020_config.fe = adap->fe[0]; in dvbsky_s960_attach()
306 state->i2c_client_tuner = dvb_module_probe("ts2020", NULL, in dvbsky_s960_attach()
309 if (!state->i2c_client_tuner) { in dvbsky_s960_attach()
310 dvb_module_release(state->i2c_client_demod); in dvbsky_s960_attach()
311 return -ENODEV; in dvbsky_s960_attach()
315 adap->fe[0]->ops.read_signal_strength = in dvbsky_s960_attach()
316 adap->fe[0]->ops.tuner_ops.get_rf_strength; in dvbsky_s960_attach()
319 state->fe_read_status = adap->fe[0]->ops.read_status; in dvbsky_s960_attach()
320 adap->fe[0]->ops.read_status = dvbsky_usb_read_status; in dvbsky_s960_attach()
323 state->fe_set_voltage = adap->fe[0]->ops.set_voltage; in dvbsky_s960_attach()
324 adap->fe[0]->ops.set_voltage = dvbsky_usb_set_voltage; in dvbsky_s960_attach()
332 struct dvb_usb_device *d = fe_to_d(fe); in dvbsky_usb_ci_set_voltage() local
333 struct dvbsky_state *state = d_to_priv(d); in dvbsky_usb_ci_set_voltage()
339 value = 1; in dvbsky_usb_ci_set_voltage()
340 dvbsky_gpio_ctrl(d, 0x00, value); in dvbsky_usb_ci_set_voltage()
342 return state->fe_set_voltage(fe, voltage); in dvbsky_usb_ci_set_voltage()
348 struct dvb_usb_device *d = priv; in dvbsky_ci_ctrl() local
352 command[1] = (u8)((addr >> 8) & 0xff); /*high part of address*/ in dvbsky_ci_ctrl()
362 respond_size = 1; in dvbsky_ci_ctrl()
364 ret = dvbsky_usb_generic_rw(d, command, command_size, in dvbsky_ci_ctrl()
369 *mem = respond[1]; in dvbsky_ci_ctrl()
372 dev_err(&d->udev->dev, "ci control failed=%d\n", ret); in dvbsky_ci_ctrl()
379 struct dvb_usb_device *d = adap_to_d(adap); in dvbsky_s960c_attach() local
391 m88ds3103_pdata.ts_clk_pol = 1; in dvbsky_s960c_attach()
394 m88ds3103_pdata.lnb_en_pol = 1; in dvbsky_s960c_attach()
396 state->i2c_client_demod = dvb_module_probe("m88ds3103", NULL, in dvbsky_s960c_attach()
397 &d->i2c_adap, in dvbsky_s960c_attach()
399 if (!state->i2c_client_demod) in dvbsky_s960c_attach()
400 return -ENODEV; in dvbsky_s960c_attach()
402 adap->fe[0] = m88ds3103_pdata.get_dvb_frontend(state->i2c_client_demod); in dvbsky_s960c_attach()
403 i2c_adapter = m88ds3103_pdata.get_i2c_adapter(state->i2c_client_demod); in dvbsky_s960c_attach()
406 ts2020_config.fe = adap->fe[0]; in dvbsky_s960c_attach()
409 state->i2c_client_tuner = dvb_module_probe("ts2020", NULL, in dvbsky_s960c_attach()
412 if (!state->i2c_client_tuner) { in dvbsky_s960c_attach()
413 dvb_module_release(state->i2c_client_demod); in dvbsky_s960c_attach()
414 return -ENODEV; in dvbsky_s960c_attach()
418 sp2_config.dvb_adap = &adap->dvb_adap; in dvbsky_s960c_attach()
419 sp2_config.priv = d; in dvbsky_s960c_attach()
422 state->i2c_client_ci = dvb_module_probe("sp2", NULL, in dvbsky_s960c_attach()
423 &d->i2c_adap, in dvbsky_s960c_attach()
426 if (!state->i2c_client_ci) { in dvbsky_s960c_attach()
427 dvb_module_release(state->i2c_client_tuner); in dvbsky_s960c_attach()
428 dvb_module_release(state->i2c_client_demod); in dvbsky_s960c_attach()
429 return -ENODEV; in dvbsky_s960c_attach()
433 adap->fe[0]->ops.read_signal_strength = in dvbsky_s960c_attach()
434 adap->fe[0]->ops.tuner_ops.get_rf_strength; in dvbsky_s960c_attach()
437 state->fe_read_status = adap->fe[0]->ops.read_status; in dvbsky_s960c_attach()
438 adap->fe[0]->ops.read_status = dvbsky_usb_read_status; in dvbsky_s960c_attach()
441 state->fe_set_voltage = adap->fe[0]->ops.set_voltage; in dvbsky_s960c_attach()
442 adap->fe[0]->ops.set_voltage = dvbsky_usb_ci_set_voltage; in dvbsky_s960c_attach()
450 struct dvb_usb_device *d = adap_to_d(adap); in dvbsky_t680c_attach() local
458 si2168_config.fe = &adap->fe[0]; in dvbsky_t680c_attach()
461 state->i2c_client_demod = dvb_module_probe("si2168", NULL, in dvbsky_t680c_attach()
462 &d->i2c_adap, in dvbsky_t680c_attach()
464 if (!state->i2c_client_demod) in dvbsky_t680c_attach()
465 return -ENODEV; in dvbsky_t680c_attach()
468 si2157_config.fe = adap->fe[0]; in dvbsky_t680c_attach()
469 si2157_config.if_port = 1; in dvbsky_t680c_attach()
471 state->i2c_client_tuner = dvb_module_probe("si2157", NULL, in dvbsky_t680c_attach()
474 if (!state->i2c_client_tuner) { in dvbsky_t680c_attach()
475 dvb_module_release(state->i2c_client_demod); in dvbsky_t680c_attach()
476 return -ENODEV; in dvbsky_t680c_attach()
480 sp2_config.dvb_adap = &adap->dvb_adap; in dvbsky_t680c_attach()
481 sp2_config.priv = d; in dvbsky_t680c_attach()
484 state->i2c_client_ci = dvb_module_probe("sp2", NULL, in dvbsky_t680c_attach()
485 &d->i2c_adap, in dvbsky_t680c_attach()
488 if (!state->i2c_client_ci) { in dvbsky_t680c_attach()
489 dvb_module_release(state->i2c_client_tuner); in dvbsky_t680c_attach()
490 dvb_module_release(state->i2c_client_demod); in dvbsky_t680c_attach()
491 return -ENODEV; in dvbsky_t680c_attach()
500 struct dvb_usb_device *d = adap_to_d(adap); in dvbsky_t330_attach() local
507 si2168_config.fe = &adap->fe[0]; in dvbsky_t330_attach()
511 state->i2c_client_demod = dvb_module_probe("si2168", NULL, in dvbsky_t330_attach()
512 &d->i2c_adap, in dvbsky_t330_attach()
514 if (!state->i2c_client_demod) in dvbsky_t330_attach()
515 return -ENODEV; in dvbsky_t330_attach()
518 si2157_config.fe = adap->fe[0]; in dvbsky_t330_attach()
519 si2157_config.if_port = 1; in dvbsky_t330_attach()
521 state->i2c_client_tuner = dvb_module_probe("si2157", NULL, in dvbsky_t330_attach()
524 if (!state->i2c_client_tuner) { in dvbsky_t330_attach()
525 dvb_module_release(state->i2c_client_demod); in dvbsky_t330_attach()
526 return -ENODEV; in dvbsky_t330_attach()
535 struct dvb_usb_device *d = adap_to_d(adap); in dvbsky_mygica_t230c_attach() local
542 si2168_config.fe = &adap->fe[0]; in dvbsky_mygica_t230c_attach()
544 if (le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_MYGICA_T230C2 || in dvbsky_mygica_t230c_attach()
545 le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_MYGICA_T230C2_LITE || in dvbsky_mygica_t230c_attach()
546 le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_MYGICA_T230A) in dvbsky_mygica_t230c_attach()
548 si2168_config.ts_clock_inv = 1; in dvbsky_mygica_t230c_attach()
550 state->i2c_client_demod = dvb_module_probe("si2168", NULL, in dvbsky_mygica_t230c_attach()
551 &d->i2c_adap, in dvbsky_mygica_t230c_attach()
553 if (!state->i2c_client_demod) in dvbsky_mygica_t230c_attach()
554 return -ENODEV; in dvbsky_mygica_t230c_attach()
557 si2157_config.fe = adap->fe[0]; in dvbsky_mygica_t230c_attach()
558 if (le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_MYGICA_T230) { in dvbsky_mygica_t230c_attach()
559 si2157_config.if_port = 1; in dvbsky_mygica_t230c_attach()
560 state->i2c_client_tuner = dvb_module_probe("si2157", NULL, in dvbsky_mygica_t230c_attach()
566 state->i2c_client_tuner = dvb_module_probe("si2157", "si2141", in dvbsky_mygica_t230c_attach()
571 if (!state->i2c_client_tuner) { in dvbsky_mygica_t230c_attach()
572 dvb_module_release(state->i2c_client_demod); in dvbsky_mygica_t230c_attach()
573 return -ENODEV; in dvbsky_mygica_t230c_attach()
580 static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name) in dvbsky_identify_state() argument
582 if (le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_MYGICA_T230A) { in dvbsky_identify_state()
583 dvbsky_gpio_ctrl(d, 0x87, 0); in dvbsky_identify_state()
585 dvbsky_gpio_ctrl(d, 0x86, 1); in dvbsky_identify_state()
586 dvbsky_gpio_ctrl(d, 0x80, 0); in dvbsky_identify_state()
588 dvbsky_gpio_ctrl(d, 0x80, 1); in dvbsky_identify_state()
591 dvbsky_gpio_ctrl(d, 0x04, 1); in dvbsky_identify_state()
593 dvbsky_gpio_ctrl(d, 0x83, 0); in dvbsky_identify_state()
594 dvbsky_gpio_ctrl(d, 0xc0, 1); in dvbsky_identify_state()
596 dvbsky_gpio_ctrl(d, 0x83, 1); in dvbsky_identify_state()
597 dvbsky_gpio_ctrl(d, 0xc0, 0); in dvbsky_identify_state()
603 static int dvbsky_init(struct dvb_usb_device *d) in dvbsky_init() argument
605 struct dvbsky_state *state = d_to_priv(d); in dvbsky_init()
606 state->last_lock = 0; in dvbsky_init()
612 struct dvb_usb_device *d = adap_to_d(adap); in dvbsky_frontend_detach() local
613 struct dvbsky_state *state = d_to_priv(d); in dvbsky_frontend_detach()
615 dev_dbg(&d->udev->dev, "%s: adap=%d\n", __func__, adap->id); in dvbsky_frontend_detach()
617 dvb_module_release(state->i2c_client_tuner); in dvbsky_frontend_detach()
618 dvb_module_release(state->i2c_client_demod); in dvbsky_frontend_detach()
619 dvb_module_release(state->i2c_client_ci); in dvbsky_frontend_detach()
644 .num_adapters = 1,
671 .num_adapters = 1,
698 .num_adapters = 1,
725 .num_adapters = 1,
751 .num_adapters = 1,
770 &dvbsky_t330_props, "TechnoTrend TVStick CT2-4400",
774 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI",
778 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI v1.1",
782 &dvbsky_s960c_props, "TechnoTrend TT-connect S2-4650 CI",
792 &mygica_t230c_props, "MyGica Mini DVB-(T/T2/C) USB Stick T230",
795 &mygica_t230c_props, "MyGica Mini DVB-(T/T2/C) USB Stick T230C",
798 &mygica_t230c_props, "MyGica Mini DVB-(T/T2/C) USB Stick T230C Lite",
801 &mygica_t230c_props, "MyGica Mini DVB-(T/T2/C) USB Stick T230C v2",
804 &mygica_t230c_props, "MyGica Mini DVB-(T/T2/C) USB Stick T230C v2 Lite",
807 &mygica_t230c_props, "MyGica Mini DVB-(T/T2/C) USB Stick T230A",
821 .no_dynamic_id = 1,
822 .soft_unbind = 1,