treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / media / usb / dvb-usb-v2 / dvbsky.c
blob356fd8e66834ea5883aec2b567615b888b2916fe
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Driver for DVBSky USB2.0 receiver
5 * Copyright (C) 2013 Max nibble <nibble.max@gmail.com>
6 */
8 #include "dvb_usb.h"
9 #include "m88ds3103.h"
10 #include "ts2020.h"
11 #include "sp2.h"
12 #include "si2168.h"
13 #include "si2157.h"
15 #define DVBSKY_MSG_DELAY 0/*2000*/
16 #define DVBSKY_BUF_LEN 64
18 static int dvb_usb_dvbsky_disable_rc;
19 module_param_named(disable_rc, dvb_usb_dvbsky_disable_rc, int, 0644);
20 MODULE_PARM_DESC(disable_rc, "Disable inbuilt IR receiver.");
22 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
24 struct dvbsky_state {
25 u8 ibuf[DVBSKY_BUF_LEN];
26 u8 obuf[DVBSKY_BUF_LEN];
27 u8 last_lock;
28 struct i2c_client *i2c_client_demod;
29 struct i2c_client *i2c_client_tuner;
30 struct i2c_client *i2c_client_ci;
32 /* fe hook functions*/
33 int (*fe_set_voltage)(struct dvb_frontend *fe,
34 enum fe_sec_voltage voltage);
35 int (*fe_read_status)(struct dvb_frontend *fe,
36 enum fe_status *status);
39 static int dvbsky_usb_generic_rw(struct dvb_usb_device *d,
40 u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
42 int ret;
43 struct dvbsky_state *state = d_to_priv(d);
45 mutex_lock(&d->usb_mutex);
46 if (wlen != 0)
47 memcpy(state->obuf, wbuf, wlen);
49 ret = dvb_usbv2_generic_rw_locked(d, state->obuf, wlen,
50 state->ibuf, rlen);
52 if (!ret && (rlen != 0))
53 memcpy(rbuf, state->ibuf, rlen);
55 mutex_unlock(&d->usb_mutex);
56 return ret;
59 static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
61 struct dvbsky_state *state = d_to_priv(d);
62 static const u8 obuf_pre[3] = { 0x37, 0, 0 };
63 static const u8 obuf_post[3] = { 0x36, 3, 0 };
64 int ret;
66 mutex_lock(&d->usb_mutex);
67 memcpy(state->obuf, obuf_pre, 3);
68 ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
69 if (!ret && onoff) {
70 msleep(20);
71 memcpy(state->obuf, obuf_post, 3);
72 ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
74 mutex_unlock(&d->usb_mutex);
75 return ret;
78 static int dvbsky_streaming_ctrl(struct dvb_frontend *fe, int onoff)
80 struct dvb_usb_device *d = fe_to_d(fe);
82 return dvbsky_stream_ctrl(d, (onoff == 0) ? 0 : 1);
85 /* GPIO */
86 static int dvbsky_gpio_ctrl(struct dvb_usb_device *d, u8 gport, u8 value)
88 int ret;
89 u8 obuf[3], ibuf[2];
91 obuf[0] = 0x0e;
92 obuf[1] = gport;
93 obuf[2] = value;
94 ret = dvbsky_usb_generic_rw(d, obuf, 3, ibuf, 1);
95 return ret;
98 /* I2C */
99 static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
100 int num)
102 struct dvb_usb_device *d = i2c_get_adapdata(adap);
103 int ret = 0;
104 u8 ibuf[64], obuf[64];
106 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
107 return -EAGAIN;
109 if (num > 2) {
110 dev_err(&d->udev->dev,
111 "too many i2c messages[%d], max 2.", num);
112 ret = -EOPNOTSUPP;
113 goto i2c_error;
116 if (num == 1) {
117 if (msg[0].len > 60) {
118 dev_err(&d->udev->dev,
119 "too many i2c bytes[%d], max 60.",
120 msg[0].len);
121 ret = -EOPNOTSUPP;
122 goto i2c_error;
124 if (msg[0].flags & I2C_M_RD) {
125 /* single read */
126 obuf[0] = 0x09;
127 obuf[1] = 0;
128 obuf[2] = msg[0].len;
129 obuf[3] = msg[0].addr;
130 ret = dvbsky_usb_generic_rw(d, obuf, 4,
131 ibuf, msg[0].len + 1);
132 if (!ret)
133 memcpy(msg[0].buf, &ibuf[1], msg[0].len);
134 } else {
135 /* write */
136 obuf[0] = 0x08;
137 obuf[1] = msg[0].addr;
138 obuf[2] = msg[0].len;
139 memcpy(&obuf[3], msg[0].buf, msg[0].len);
140 ret = dvbsky_usb_generic_rw(d, obuf,
141 msg[0].len + 3, ibuf, 1);
143 } else {
144 if ((msg[0].len > 60) || (msg[1].len > 60)) {
145 dev_err(&d->udev->dev,
146 "too many i2c bytes[w-%d][r-%d], max 60.",
147 msg[0].len, msg[1].len);
148 ret = -EOPNOTSUPP;
149 goto i2c_error;
151 /* write then read */
152 obuf[0] = 0x09;
153 obuf[1] = msg[0].len;
154 obuf[2] = msg[1].len;
155 obuf[3] = msg[0].addr;
156 memcpy(&obuf[4], msg[0].buf, msg[0].len);
157 ret = dvbsky_usb_generic_rw(d, obuf,
158 msg[0].len + 4, ibuf, msg[1].len + 1);
159 if (!ret)
160 memcpy(msg[1].buf, &ibuf[1], msg[1].len);
162 i2c_error:
163 mutex_unlock(&d->i2c_mutex);
164 return (ret) ? ret : num;
167 static u32 dvbsky_i2c_func(struct i2c_adapter *adapter)
169 return I2C_FUNC_I2C;
172 static struct i2c_algorithm dvbsky_i2c_algo = {
173 .master_xfer = dvbsky_i2c_xfer,
174 .functionality = dvbsky_i2c_func,
177 #if IS_ENABLED(CONFIG_RC_CORE)
178 static int dvbsky_rc_query(struct dvb_usb_device *d)
180 u32 code = 0xffff, scancode;
181 u8 rc5_command, rc5_system;
182 u8 obuf[2], ibuf[2], toggle;
183 int ret;
185 obuf[0] = 0x10;
186 ret = dvbsky_usb_generic_rw(d, obuf, 1, ibuf, 2);
187 if (ret == 0)
188 code = (ibuf[0] << 8) | ibuf[1];
189 if (code != 0xffff) {
190 dev_dbg(&d->udev->dev, "rc code: %x\n", code);
191 rc5_command = code & 0x3F;
192 rc5_system = (code & 0x7C0) >> 6;
193 toggle = (code & 0x800) ? 1 : 0;
194 scancode = rc5_system << 8 | rc5_command;
195 rc_keydown(d->rc_dev, RC_PROTO_RC5, scancode, toggle);
197 return 0;
200 static int dvbsky_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
202 if (dvb_usb_dvbsky_disable_rc) {
203 rc->map_name = NULL;
204 return 0;
207 rc->allowed_protos = RC_PROTO_BIT_RC5;
208 rc->query = dvbsky_rc_query;
209 rc->interval = 300;
210 return 0;
212 #else
213 #define dvbsky_get_rc_config NULL
214 #endif
216 static int dvbsky_usb_set_voltage(struct dvb_frontend *fe,
217 enum fe_sec_voltage voltage)
219 struct dvb_usb_device *d = fe_to_d(fe);
220 struct dvbsky_state *state = d_to_priv(d);
221 u8 value;
223 if (voltage == SEC_VOLTAGE_OFF)
224 value = 0;
225 else
226 value = 1;
227 dvbsky_gpio_ctrl(d, 0x80, value);
229 return state->fe_set_voltage(fe, voltage);
232 static int dvbsky_read_mac_addr(struct dvb_usb_adapter *adap, u8 mac[6])
234 struct dvb_usb_device *d = adap_to_d(adap);
235 u8 obuf[] = { 0x1e, 0x00 };
236 u8 ibuf[6] = { 0 };
237 struct i2c_msg msg[] = {
239 .addr = 0x51,
240 .flags = 0,
241 .buf = obuf,
242 .len = 2,
243 }, {
244 .addr = 0x51,
245 .flags = I2C_M_RD,
246 .buf = ibuf,
247 .len = 6,
251 if (i2c_transfer(&d->i2c_adap, msg, 2) == 2)
252 memcpy(mac, ibuf, 6);
254 return 0;
257 static int dvbsky_usb_read_status(struct dvb_frontend *fe,
258 enum fe_status *status)
260 struct dvb_usb_device *d = fe_to_d(fe);
261 struct dvbsky_state *state = d_to_priv(d);
262 int ret;
264 ret = state->fe_read_status(fe, status);
266 /* it need resync slave fifo when signal change from unlock to lock.*/
267 if ((*status & FE_HAS_LOCK) && (!state->last_lock))
268 dvbsky_stream_ctrl(d, 1);
270 state->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0;
271 return ret;
274 static int dvbsky_s960_attach(struct dvb_usb_adapter *adap)
276 struct dvbsky_state *state = adap_to_priv(adap);
277 struct dvb_usb_device *d = adap_to_d(adap);
278 struct i2c_adapter *i2c_adapter;
279 struct m88ds3103_platform_data m88ds3103_pdata = {};
280 struct ts2020_config ts2020_config = {};
282 /* attach demod */
283 m88ds3103_pdata.clk = 27000000;
284 m88ds3103_pdata.i2c_wr_max = 33;
285 m88ds3103_pdata.clk_out = 0;
286 m88ds3103_pdata.ts_mode = M88DS3103_TS_CI;
287 m88ds3103_pdata.ts_clk = 16000;
288 m88ds3103_pdata.ts_clk_pol = 0;
289 m88ds3103_pdata.agc = 0x99;
290 m88ds3103_pdata.lnb_hv_pol = 1,
291 m88ds3103_pdata.lnb_en_pol = 1,
293 state->i2c_client_demod = dvb_module_probe("m88ds3103", NULL,
294 &d->i2c_adap,
295 0x68, &m88ds3103_pdata);
296 if (!state->i2c_client_demod)
297 return -ENODEV;
299 adap->fe[0] = m88ds3103_pdata.get_dvb_frontend(state->i2c_client_demod);
300 i2c_adapter = m88ds3103_pdata.get_i2c_adapter(state->i2c_client_demod);
302 /* attach tuner */
303 ts2020_config.fe = adap->fe[0];
304 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
306 state->i2c_client_tuner = dvb_module_probe("ts2020", NULL,
307 i2c_adapter,
308 0x60, &ts2020_config);
309 if (!state->i2c_client_tuner) {
310 dvb_module_release(state->i2c_client_demod);
311 return -ENODEV;
314 /* delegate signal strength measurement to tuner */
315 adap->fe[0]->ops.read_signal_strength =
316 adap->fe[0]->ops.tuner_ops.get_rf_strength;
318 /* hook fe: need to resync the slave fifo when signal locks. */
319 state->fe_read_status = adap->fe[0]->ops.read_status;
320 adap->fe[0]->ops.read_status = dvbsky_usb_read_status;
322 /* hook fe: LNB off/on is control by Cypress usb chip. */
323 state->fe_set_voltage = adap->fe[0]->ops.set_voltage;
324 adap->fe[0]->ops.set_voltage = dvbsky_usb_set_voltage;
326 return 0;
329 static int dvbsky_usb_ci_set_voltage(struct dvb_frontend *fe,
330 enum fe_sec_voltage voltage)
332 struct dvb_usb_device *d = fe_to_d(fe);
333 struct dvbsky_state *state = d_to_priv(d);
334 u8 value;
336 if (voltage == SEC_VOLTAGE_OFF)
337 value = 0;
338 else
339 value = 1;
340 dvbsky_gpio_ctrl(d, 0x00, value);
342 return state->fe_set_voltage(fe, voltage);
345 static int dvbsky_ci_ctrl(void *priv, u8 read, int addr,
346 u8 data, int *mem)
348 struct dvb_usb_device *d = priv;
349 int ret = 0;
350 u8 command[4], respond[2], command_size, respond_size;
352 command[1] = (u8)((addr >> 8) & 0xff); /*high part of address*/
353 command[2] = (u8)(addr & 0xff); /*low part of address*/
354 if (read) {
355 command[0] = 0x71;
356 command_size = 3;
357 respond_size = 2;
358 } else {
359 command[0] = 0x70;
360 command[3] = data;
361 command_size = 4;
362 respond_size = 1;
364 ret = dvbsky_usb_generic_rw(d, command, command_size,
365 respond, respond_size);
366 if (ret)
367 goto err;
368 if (read)
369 *mem = respond[1];
370 return ret;
371 err:
372 dev_err(&d->udev->dev, "ci control failed=%d\n", ret);
373 return ret;
376 static int dvbsky_s960c_attach(struct dvb_usb_adapter *adap)
378 struct dvbsky_state *state = adap_to_priv(adap);
379 struct dvb_usb_device *d = adap_to_d(adap);
380 struct i2c_adapter *i2c_adapter;
381 struct m88ds3103_platform_data m88ds3103_pdata = {};
382 struct ts2020_config ts2020_config = {};
383 struct sp2_config sp2_config = {};
385 /* attach demod */
386 m88ds3103_pdata.clk = 27000000,
387 m88ds3103_pdata.i2c_wr_max = 33,
388 m88ds3103_pdata.clk_out = 0,
389 m88ds3103_pdata.ts_mode = M88DS3103_TS_CI,
390 m88ds3103_pdata.ts_clk = 10000,
391 m88ds3103_pdata.ts_clk_pol = 1,
392 m88ds3103_pdata.agc = 0x99,
393 m88ds3103_pdata.lnb_hv_pol = 0,
394 m88ds3103_pdata.lnb_en_pol = 1,
396 state->i2c_client_demod = dvb_module_probe("m88ds3103", NULL,
397 &d->i2c_adap,
398 0x68, &m88ds3103_pdata);
399 if (!state->i2c_client_demod)
400 return -ENODEV;
402 adap->fe[0] = m88ds3103_pdata.get_dvb_frontend(state->i2c_client_demod);
403 i2c_adapter = m88ds3103_pdata.get_i2c_adapter(state->i2c_client_demod);
405 /* attach tuner */
406 ts2020_config.fe = adap->fe[0];
407 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
409 state->i2c_client_tuner = dvb_module_probe("ts2020", NULL,
410 i2c_adapter,
411 0x60, &ts2020_config);
412 if (!state->i2c_client_tuner) {
413 dvb_module_release(state->i2c_client_demod);
414 return -ENODEV;
417 /* attach ci controller */
418 sp2_config.dvb_adap = &adap->dvb_adap;
419 sp2_config.priv = d;
420 sp2_config.ci_control = dvbsky_ci_ctrl;
422 state->i2c_client_ci = dvb_module_probe("sp2", NULL,
423 &d->i2c_adap,
424 0x40, &sp2_config);
426 if (!state->i2c_client_ci) {
427 dvb_module_release(state->i2c_client_tuner);
428 dvb_module_release(state->i2c_client_demod);
429 return -ENODEV;
432 /* delegate signal strength measurement to tuner */
433 adap->fe[0]->ops.read_signal_strength =
434 adap->fe[0]->ops.tuner_ops.get_rf_strength;
436 /* hook fe: need to resync the slave fifo when signal locks. */
437 state->fe_read_status = adap->fe[0]->ops.read_status;
438 adap->fe[0]->ops.read_status = dvbsky_usb_read_status;
440 /* hook fe: LNB off/on is control by Cypress usb chip. */
441 state->fe_set_voltage = adap->fe[0]->ops.set_voltage;
442 adap->fe[0]->ops.set_voltage = dvbsky_usb_ci_set_voltage;
444 return 0;
447 static int dvbsky_t680c_attach(struct dvb_usb_adapter *adap)
449 struct dvbsky_state *state = adap_to_priv(adap);
450 struct dvb_usb_device *d = adap_to_d(adap);
451 struct i2c_adapter *i2c_adapter;
452 struct si2168_config si2168_config = {};
453 struct si2157_config si2157_config = {};
454 struct sp2_config sp2_config = {};
456 /* attach demod */
457 si2168_config.i2c_adapter = &i2c_adapter;
458 si2168_config.fe = &adap->fe[0];
459 si2168_config.ts_mode = SI2168_TS_PARALLEL;
461 state->i2c_client_demod = dvb_module_probe("si2168", NULL,
462 &d->i2c_adap,
463 0x64, &si2168_config);
464 if (!state->i2c_client_demod)
465 return -ENODEV;
467 /* attach tuner */
468 si2157_config.fe = adap->fe[0];
469 si2157_config.if_port = 1;
471 state->i2c_client_tuner = dvb_module_probe("si2157", NULL,
472 i2c_adapter,
473 0x60, &si2157_config);
474 if (!state->i2c_client_tuner) {
475 dvb_module_release(state->i2c_client_demod);
476 return -ENODEV;
479 /* attach ci controller */
480 sp2_config.dvb_adap = &adap->dvb_adap;
481 sp2_config.priv = d;
482 sp2_config.ci_control = dvbsky_ci_ctrl;
484 state->i2c_client_ci = dvb_module_probe("sp2", NULL,
485 &d->i2c_adap,
486 0x40, &sp2_config);
488 if (!state->i2c_client_ci) {
489 dvb_module_release(state->i2c_client_tuner);
490 dvb_module_release(state->i2c_client_demod);
491 return -ENODEV;
494 return 0;
497 static int dvbsky_t330_attach(struct dvb_usb_adapter *adap)
499 struct dvbsky_state *state = adap_to_priv(adap);
500 struct dvb_usb_device *d = adap_to_d(adap);
501 struct i2c_adapter *i2c_adapter;
502 struct si2168_config si2168_config = {};
503 struct si2157_config si2157_config = {};
505 /* attach demod */
506 si2168_config.i2c_adapter = &i2c_adapter;
507 si2168_config.fe = &adap->fe[0];
508 si2168_config.ts_mode = SI2168_TS_PARALLEL;
509 si2168_config.ts_clock_gapped = true;
511 state->i2c_client_demod = dvb_module_probe("si2168", NULL,
512 &d->i2c_adap,
513 0x64, &si2168_config);
514 if (!state->i2c_client_demod)
515 return -ENODEV;
517 /* attach tuner */
518 si2157_config.fe = adap->fe[0];
519 si2157_config.if_port = 1;
521 state->i2c_client_tuner = dvb_module_probe("si2157", NULL,
522 i2c_adapter,
523 0x60, &si2157_config);
524 if (!state->i2c_client_tuner) {
525 dvb_module_release(state->i2c_client_demod);
526 return -ENODEV;
529 return 0;
532 static int dvbsky_mygica_t230c_attach(struct dvb_usb_adapter *adap)
534 struct dvbsky_state *state = adap_to_priv(adap);
535 struct dvb_usb_device *d = adap_to_d(adap);
536 struct i2c_adapter *i2c_adapter;
537 struct si2168_config si2168_config = {};
538 struct si2157_config si2157_config = {};
540 /* attach demod */
541 si2168_config.i2c_adapter = &i2c_adapter;
542 si2168_config.fe = &adap->fe[0];
543 si2168_config.ts_mode = SI2168_TS_PARALLEL;
544 if (le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_MYGICA_T230C2)
545 si2168_config.ts_mode |= SI2168_TS_CLK_MANUAL;
546 si2168_config.ts_clock_inv = 1;
548 state->i2c_client_demod = dvb_module_probe("si2168", NULL,
549 &d->i2c_adap,
550 0x64, &si2168_config);
551 if (!state->i2c_client_demod)
552 return -ENODEV;
554 /* attach tuner */
555 si2157_config.fe = adap->fe[0];
556 if (le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_MYGICA_T230) {
557 si2157_config.if_port = 1;
558 state->i2c_client_tuner = dvb_module_probe("si2157", NULL,
559 i2c_adapter,
560 0x60,
561 &si2157_config);
562 } else {
563 si2157_config.if_port = 0;
564 state->i2c_client_tuner = dvb_module_probe("si2157", "si2141",
565 i2c_adapter,
566 0x60,
567 &si2157_config);
569 if (!state->i2c_client_tuner) {
570 dvb_module_release(state->i2c_client_demod);
571 return -ENODEV;
574 return 0;
578 static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name)
580 dvbsky_gpio_ctrl(d, 0x04, 1);
581 msleep(20);
582 dvbsky_gpio_ctrl(d, 0x83, 0);
583 dvbsky_gpio_ctrl(d, 0xc0, 1);
584 msleep(100);
585 dvbsky_gpio_ctrl(d, 0x83, 1);
586 dvbsky_gpio_ctrl(d, 0xc0, 0);
587 msleep(50);
589 return WARM;
592 static int dvbsky_init(struct dvb_usb_device *d)
594 struct dvbsky_state *state = d_to_priv(d);
595 state->last_lock = 0;
596 return 0;
599 static int dvbsky_frontend_detach(struct dvb_usb_adapter *adap)
601 struct dvb_usb_device *d = adap_to_d(adap);
602 struct dvbsky_state *state = d_to_priv(d);
604 dev_dbg(&d->udev->dev, "%s: adap=%d\n", __func__, adap->id);
606 dvb_module_release(state->i2c_client_tuner);
607 dvb_module_release(state->i2c_client_demod);
608 dvb_module_release(state->i2c_client_ci);
610 return 0;
613 /* DVB USB Driver stuff */
614 static struct dvb_usb_device_properties dvbsky_s960_props = {
615 .driver_name = KBUILD_MODNAME,
616 .owner = THIS_MODULE,
617 .adapter_nr = adapter_nr,
618 .size_of_priv = sizeof(struct dvbsky_state),
620 .generic_bulk_ctrl_endpoint = 0x01,
621 .generic_bulk_ctrl_endpoint_response = 0x81,
622 .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY,
624 .i2c_algo = &dvbsky_i2c_algo,
625 .frontend_attach = dvbsky_s960_attach,
626 .frontend_detach = dvbsky_frontend_detach,
627 .init = dvbsky_init,
628 .get_rc_config = dvbsky_get_rc_config,
629 .streaming_ctrl = dvbsky_streaming_ctrl,
630 .identify_state = dvbsky_identify_state,
631 .read_mac_address = dvbsky_read_mac_addr,
633 .num_adapters = 1,
634 .adapter = {
636 .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096),
641 static struct dvb_usb_device_properties dvbsky_s960c_props = {
642 .driver_name = KBUILD_MODNAME,
643 .owner = THIS_MODULE,
644 .adapter_nr = adapter_nr,
645 .size_of_priv = sizeof(struct dvbsky_state),
647 .generic_bulk_ctrl_endpoint = 0x01,
648 .generic_bulk_ctrl_endpoint_response = 0x81,
649 .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY,
651 .i2c_algo = &dvbsky_i2c_algo,
652 .frontend_attach = dvbsky_s960c_attach,
653 .frontend_detach = dvbsky_frontend_detach,
654 .init = dvbsky_init,
655 .get_rc_config = dvbsky_get_rc_config,
656 .streaming_ctrl = dvbsky_streaming_ctrl,
657 .identify_state = dvbsky_identify_state,
658 .read_mac_address = dvbsky_read_mac_addr,
660 .num_adapters = 1,
661 .adapter = {
663 .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096),
668 static struct dvb_usb_device_properties dvbsky_t680c_props = {
669 .driver_name = KBUILD_MODNAME,
670 .owner = THIS_MODULE,
671 .adapter_nr = adapter_nr,
672 .size_of_priv = sizeof(struct dvbsky_state),
674 .generic_bulk_ctrl_endpoint = 0x01,
675 .generic_bulk_ctrl_endpoint_response = 0x81,
676 .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY,
678 .i2c_algo = &dvbsky_i2c_algo,
679 .frontend_attach = dvbsky_t680c_attach,
680 .frontend_detach = dvbsky_frontend_detach,
681 .init = dvbsky_init,
682 .get_rc_config = dvbsky_get_rc_config,
683 .streaming_ctrl = dvbsky_streaming_ctrl,
684 .identify_state = dvbsky_identify_state,
685 .read_mac_address = dvbsky_read_mac_addr,
687 .num_adapters = 1,
688 .adapter = {
690 .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096),
695 static struct dvb_usb_device_properties dvbsky_t330_props = {
696 .driver_name = KBUILD_MODNAME,
697 .owner = THIS_MODULE,
698 .adapter_nr = adapter_nr,
699 .size_of_priv = sizeof(struct dvbsky_state),
701 .generic_bulk_ctrl_endpoint = 0x01,
702 .generic_bulk_ctrl_endpoint_response = 0x81,
703 .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY,
705 .i2c_algo = &dvbsky_i2c_algo,
706 .frontend_attach = dvbsky_t330_attach,
707 .frontend_detach = dvbsky_frontend_detach,
708 .init = dvbsky_init,
709 .get_rc_config = dvbsky_get_rc_config,
710 .streaming_ctrl = dvbsky_streaming_ctrl,
711 .identify_state = dvbsky_identify_state,
712 .read_mac_address = dvbsky_read_mac_addr,
714 .num_adapters = 1,
715 .adapter = {
717 .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096),
722 static struct dvb_usb_device_properties mygica_t230c_props = {
723 .driver_name = KBUILD_MODNAME,
724 .owner = THIS_MODULE,
725 .adapter_nr = adapter_nr,
726 .size_of_priv = sizeof(struct dvbsky_state),
728 .generic_bulk_ctrl_endpoint = 0x01,
729 .generic_bulk_ctrl_endpoint_response = 0x81,
730 .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY,
732 .i2c_algo = &dvbsky_i2c_algo,
733 .frontend_attach = dvbsky_mygica_t230c_attach,
734 .frontend_detach = dvbsky_frontend_detach,
735 .init = dvbsky_init,
736 .get_rc_config = dvbsky_get_rc_config,
737 .streaming_ctrl = dvbsky_streaming_ctrl,
738 .identify_state = dvbsky_identify_state,
740 .num_adapters = 1,
741 .adapter = {
743 .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096),
748 static const struct usb_device_id dvbsky_id_table[] = {
749 { DVB_USB_DEVICE(0x0572, 0x6831,
750 &dvbsky_s960_props, "DVBSky S960/S860", RC_MAP_DVBSKY) },
751 { DVB_USB_DEVICE(0x0572, 0x960c,
752 &dvbsky_s960c_props, "DVBSky S960CI", RC_MAP_DVBSKY) },
753 { DVB_USB_DEVICE(0x0572, 0x680c,
754 &dvbsky_t680c_props, "DVBSky T680CI", RC_MAP_DVBSKY) },
755 { DVB_USB_DEVICE(0x0572, 0x0320,
756 &dvbsky_t330_props, "DVBSky T330", RC_MAP_DVBSKY) },
757 { DVB_USB_DEVICE(USB_VID_TECHNOTREND,
758 USB_PID_TECHNOTREND_TVSTICK_CT2_4400,
759 &dvbsky_t330_props, "TechnoTrend TVStick CT2-4400",
760 RC_MAP_TT_1500) },
761 { DVB_USB_DEVICE(USB_VID_TECHNOTREND,
762 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI,
763 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI",
764 RC_MAP_TT_1500) },
765 { DVB_USB_DEVICE(USB_VID_TECHNOTREND,
766 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2,
767 &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI v1.1",
768 RC_MAP_TT_1500) },
769 { DVB_USB_DEVICE(USB_VID_TECHNOTREND,
770 USB_PID_TECHNOTREND_CONNECT_S2_4650_CI,
771 &dvbsky_s960c_props, "TechnoTrend TT-connect S2-4650 CI",
772 RC_MAP_TT_1500) },
773 { DVB_USB_DEVICE(USB_VID_TERRATEC,
774 USB_PID_TERRATEC_H7_3,
775 &dvbsky_t680c_props, "Terratec H7 Rev.4",
776 RC_MAP_TT_1500) },
777 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4,
778 &dvbsky_s960_props, "Terratec Cinergy S2 Rev.4",
779 RC_MAP_DVBSKY) },
780 { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230,
781 &mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230",
782 RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
783 { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C,
784 &mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230C",
785 RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
786 { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C_LITE,
787 &mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230C Lite",
788 NULL) },
789 { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C2,
790 &mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230C v2",
791 RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
794 MODULE_DEVICE_TABLE(usb, dvbsky_id_table);
796 static struct usb_driver dvbsky_usb_driver = {
797 .name = KBUILD_MODNAME,
798 .id_table = dvbsky_id_table,
799 .probe = dvb_usbv2_probe,
800 .disconnect = dvb_usbv2_disconnect,
801 .suspend = dvb_usbv2_suspend,
802 .resume = dvb_usbv2_resume,
803 .reset_resume = dvb_usbv2_reset_resume,
804 .no_dynamic_id = 1,
805 .soft_unbind = 1,
808 module_usb_driver(dvbsky_usb_driver);
810 MODULE_AUTHOR("Max nibble <nibble.max@gmail.com>");
811 MODULE_DESCRIPTION("Driver for DVBSky USB");
812 MODULE_LICENSE("GPL");