2 * Driver for DVBSky USB2.0 receiver
4 * Copyright (C) 2013 Max nibble <nibble.max@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #include "m88ds3103.h"
24 #define DVBSKY_MSG_DELAY 0/*2000*/
25 #define DVBSKY_BUF_LEN 64
27 static int dvb_usb_dvbsky_disable_rc
;
28 module_param_named(disable_rc
, dvb_usb_dvbsky_disable_rc
, int, 0644);
29 MODULE_PARM_DESC(disable_rc
, "Disable inbuilt IR receiver.");
31 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
34 struct mutex stream_mutex
;
35 u8 ibuf
[DVBSKY_BUF_LEN
];
36 u8 obuf
[DVBSKY_BUF_LEN
];
38 struct i2c_client
*i2c_client_demod
;
39 struct i2c_client
*i2c_client_tuner
;
40 struct i2c_client
*i2c_client_ci
;
42 /* fe hook functions*/
43 int (*fe_set_voltage
)(struct dvb_frontend
*fe
,
44 enum fe_sec_voltage voltage
);
45 int (*fe_read_status
)(struct dvb_frontend
*fe
,
46 enum fe_status
*status
);
49 static int dvbsky_usb_generic_rw(struct dvb_usb_device
*d
,
50 u8
*wbuf
, u16 wlen
, u8
*rbuf
, u16 rlen
)
53 struct dvbsky_state
*state
= d_to_priv(d
);
55 mutex_lock(&d
->usb_mutex
);
57 memcpy(state
->obuf
, wbuf
, wlen
);
59 ret
= dvb_usbv2_generic_rw_locked(d
, state
->obuf
, wlen
,
62 if (!ret
&& (rlen
!= 0))
63 memcpy(rbuf
, state
->ibuf
, rlen
);
65 mutex_unlock(&d
->usb_mutex
);
69 static int dvbsky_stream_ctrl(struct dvb_usb_device
*d
, u8 onoff
)
71 struct dvbsky_state
*state
= d_to_priv(d
);
73 u8 obuf_pre
[3] = { 0x37, 0, 0 };
74 u8 obuf_post
[3] = { 0x36, 3, 0 };
76 mutex_lock(&state
->stream_mutex
);
77 ret
= dvbsky_usb_generic_rw(d
, obuf_pre
, 3, NULL
, 0);
80 ret
= dvbsky_usb_generic_rw(d
, obuf_post
, 3, NULL
, 0);
82 mutex_unlock(&state
->stream_mutex
);
86 static int dvbsky_streaming_ctrl(struct dvb_frontend
*fe
, int onoff
)
88 struct dvb_usb_device
*d
= fe_to_d(fe
);
90 return dvbsky_stream_ctrl(d
, (onoff
== 0) ? 0 : 1);
94 static int dvbsky_gpio_ctrl(struct dvb_usb_device
*d
, u8 gport
, u8 value
)
102 ret
= dvbsky_usb_generic_rw(d
, obuf
, 3, ibuf
, 1);
104 dev_err(&d
->udev
->dev
, "failed=%d\n", ret
);
109 static int dvbsky_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
112 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
114 u8 ibuf
[64], obuf
[64];
116 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
120 dev_err(&d
->udev
->dev
,
121 "too many i2c messages[%d], max 2.", num
);
127 if (msg
[0].len
> 60) {
128 dev_err(&d
->udev
->dev
,
129 "too many i2c bytes[%d], max 60.",
134 if (msg
[0].flags
& I2C_M_RD
) {
138 obuf
[2] = msg
[0].len
;
139 obuf
[3] = msg
[0].addr
;
140 ret
= dvbsky_usb_generic_rw(d
, obuf
, 4,
141 ibuf
, msg
[0].len
+ 1);
143 dev_err(&d
->udev
->dev
, "failed=%d\n", ret
);
145 memcpy(msg
[0].buf
, &ibuf
[1], msg
[0].len
);
149 obuf
[1] = msg
[0].addr
;
150 obuf
[2] = msg
[0].len
;
151 memcpy(&obuf
[3], msg
[0].buf
, msg
[0].len
);
152 ret
= dvbsky_usb_generic_rw(d
, obuf
,
153 msg
[0].len
+ 3, ibuf
, 1);
155 dev_err(&d
->udev
->dev
, "failed=%d\n", ret
);
158 if ((msg
[0].len
> 60) || (msg
[1].len
> 60)) {
159 dev_err(&d
->udev
->dev
,
160 "too many i2c bytes[w-%d][r-%d], max 60.",
161 msg
[0].len
, msg
[1].len
);
165 /* write then read */
167 obuf
[1] = msg
[0].len
;
168 obuf
[2] = msg
[1].len
;
169 obuf
[3] = msg
[0].addr
;
170 memcpy(&obuf
[4], msg
[0].buf
, msg
[0].len
);
171 ret
= dvbsky_usb_generic_rw(d
, obuf
,
172 msg
[0].len
+ 4, ibuf
, msg
[1].len
+ 1);
174 dev_err(&d
->udev
->dev
, "failed=%d\n", ret
);
177 memcpy(msg
[1].buf
, &ibuf
[1], msg
[1].len
);
180 mutex_unlock(&d
->i2c_mutex
);
181 return (ret
) ? ret
: num
;
184 static u32
dvbsky_i2c_func(struct i2c_adapter
*adapter
)
189 static struct i2c_algorithm dvbsky_i2c_algo
= {
190 .master_xfer
= dvbsky_i2c_xfer
,
191 .functionality
= dvbsky_i2c_func
,
194 #if IS_ENABLED(CONFIG_RC_CORE)
195 static int dvbsky_rc_query(struct dvb_usb_device
*d
)
197 u32 code
= 0xffff, scancode
;
198 u8 rc5_command
, rc5_system
;
199 u8 obuf
[2], ibuf
[2], toggle
;
203 ret
= dvbsky_usb_generic_rw(d
, obuf
, 1, ibuf
, 2);
205 dev_err(&d
->udev
->dev
, "failed=%d\n", ret
);
207 code
= (ibuf
[0] << 8) | ibuf
[1];
208 if (code
!= 0xffff) {
209 dev_dbg(&d
->udev
->dev
, "rc code: %x\n", code
);
210 rc5_command
= code
& 0x3F;
211 rc5_system
= (code
& 0x7C0) >> 6;
212 toggle
= (code
& 0x800) ? 1 : 0;
213 scancode
= rc5_system
<< 8 | rc5_command
;
214 rc_keydown(d
->rc_dev
, RC_PROTO_RC5
, scancode
, toggle
);
219 static int dvbsky_get_rc_config(struct dvb_usb_device
*d
, struct dvb_usb_rc
*rc
)
221 if (dvb_usb_dvbsky_disable_rc
) {
226 rc
->allowed_protos
= RC_PROTO_BIT_RC5
;
227 rc
->query
= dvbsky_rc_query
;
232 #define dvbsky_get_rc_config NULL
235 static int dvbsky_usb_set_voltage(struct dvb_frontend
*fe
,
236 enum fe_sec_voltage voltage
)
238 struct dvb_usb_device
*d
= fe_to_d(fe
);
239 struct dvbsky_state
*state
= d_to_priv(d
);
242 if (voltage
== SEC_VOLTAGE_OFF
)
246 dvbsky_gpio_ctrl(d
, 0x80, value
);
248 return state
->fe_set_voltage(fe
, voltage
);
251 static int dvbsky_read_mac_addr(struct dvb_usb_adapter
*adap
, u8 mac
[6])
253 struct dvb_usb_device
*d
= adap_to_d(adap
);
254 u8 obuf
[] = { 0x1e, 0x00 };
256 struct i2c_msg msg
[] = {
270 if (i2c_transfer(&d
->i2c_adap
, msg
, 2) == 2)
271 memcpy(mac
, ibuf
, 6);
276 static int dvbsky_usb_read_status(struct dvb_frontend
*fe
,
277 enum fe_status
*status
)
279 struct dvb_usb_device
*d
= fe_to_d(fe
);
280 struct dvbsky_state
*state
= d_to_priv(d
);
283 ret
= state
->fe_read_status(fe
, status
);
285 /* it need resync slave fifo when signal change from unlock to lock.*/
286 if ((*status
& FE_HAS_LOCK
) && (!state
->last_lock
))
287 dvbsky_stream_ctrl(d
, 1);
289 state
->last_lock
= (*status
& FE_HAS_LOCK
) ? 1 : 0;
293 static const struct m88ds3103_config dvbsky_s960_m88ds3103_config
= {
298 .ts_mode
= M88DS3103_TS_CI
,
306 static int dvbsky_s960_attach(struct dvb_usb_adapter
*adap
)
308 struct dvbsky_state
*state
= adap_to_priv(adap
);
309 struct dvb_usb_device
*d
= adap_to_d(adap
);
311 /* demod I2C adapter */
312 struct i2c_adapter
*i2c_adapter
= NULL
;
313 struct i2c_client
*client
;
314 struct i2c_board_info info
;
315 struct ts2020_config ts2020_config
= {};
316 memset(&info
, 0, sizeof(struct i2c_board_info
));
319 adap
->fe
[0] = dvb_attach(m88ds3103_attach
,
320 &dvbsky_s960_m88ds3103_config
,
324 dev_err(&d
->udev
->dev
, "dvbsky_s960_attach fail.\n");
330 ts2020_config
.fe
= adap
->fe
[0];
331 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
332 strlcpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
334 info
.platform_data
= &ts2020_config
;
335 request_module("ts2020");
336 client
= i2c_new_device(i2c_adapter
, &info
);
337 if (client
== NULL
|| client
->dev
.driver
== NULL
) {
338 dvb_frontend_detach(adap
->fe
[0]);
343 if (!try_module_get(client
->dev
.driver
->owner
)) {
344 i2c_unregister_device(client
);
345 dvb_frontend_detach(adap
->fe
[0]);
350 /* delegate signal strength measurement to tuner */
351 adap
->fe
[0]->ops
.read_signal_strength
=
352 adap
->fe
[0]->ops
.tuner_ops
.get_rf_strength
;
354 /* hook fe: need to resync the slave fifo when signal locks. */
355 state
->fe_read_status
= adap
->fe
[0]->ops
.read_status
;
356 adap
->fe
[0]->ops
.read_status
= dvbsky_usb_read_status
;
358 /* hook fe: LNB off/on is control by Cypress usb chip. */
359 state
->fe_set_voltage
= adap
->fe
[0]->ops
.set_voltage
;
360 adap
->fe
[0]->ops
.set_voltage
= dvbsky_usb_set_voltage
;
362 state
->i2c_client_tuner
= client
;
368 static int dvbsky_usb_ci_set_voltage(struct dvb_frontend
*fe
,
369 enum fe_sec_voltage voltage
)
371 struct dvb_usb_device
*d
= fe_to_d(fe
);
372 struct dvbsky_state
*state
= d_to_priv(d
);
375 if (voltage
== SEC_VOLTAGE_OFF
)
379 dvbsky_gpio_ctrl(d
, 0x00, value
);
381 return state
->fe_set_voltage(fe
, voltage
);
384 static int dvbsky_ci_ctrl(void *priv
, u8 read
, int addr
,
387 struct dvb_usb_device
*d
= priv
;
389 u8 command
[4], respond
[2], command_size
, respond_size
;
391 command
[1] = (u8
)((addr
>> 8) & 0xff); /*high part of address*/
392 command
[2] = (u8
)(addr
& 0xff); /*low part of address*/
403 ret
= dvbsky_usb_generic_rw(d
, command
, command_size
,
404 respond
, respond_size
);
411 dev_err(&d
->udev
->dev
, "ci control failed=%d\n", ret
);
415 static const struct m88ds3103_config dvbsky_s960c_m88ds3103_config
= {
420 .ts_mode
= M88DS3103_TS_CI
,
428 static int dvbsky_s960c_attach(struct dvb_usb_adapter
*adap
)
430 struct dvbsky_state
*state
= adap_to_priv(adap
);
431 struct dvb_usb_device
*d
= adap_to_d(adap
);
433 /* demod I2C adapter */
434 struct i2c_adapter
*i2c_adapter
= NULL
;
435 struct i2c_client
*client_tuner
, *client_ci
;
436 struct i2c_board_info info
;
437 struct sp2_config sp2_config
;
438 struct ts2020_config ts2020_config
= {};
439 memset(&info
, 0, sizeof(struct i2c_board_info
));
442 adap
->fe
[0] = dvb_attach(m88ds3103_attach
,
443 &dvbsky_s960c_m88ds3103_config
,
447 dev_err(&d
->udev
->dev
, "dvbsky_s960ci_attach fail.\n");
453 ts2020_config
.fe
= adap
->fe
[0];
454 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
455 strlcpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
457 info
.platform_data
= &ts2020_config
;
458 request_module("ts2020");
459 client_tuner
= i2c_new_device(i2c_adapter
, &info
);
460 if (client_tuner
== NULL
|| client_tuner
->dev
.driver
== NULL
) {
462 goto fail_tuner_device
;
465 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
467 goto fail_tuner_module
;
470 /* attach ci controller */
471 memset(&sp2_config
, 0, sizeof(sp2_config
));
472 sp2_config
.dvb_adap
= &adap
->dvb_adap
;
474 sp2_config
.ci_control
= dvbsky_ci_ctrl
;
475 memset(&info
, 0, sizeof(struct i2c_board_info
));
476 strlcpy(info
.type
, "sp2", I2C_NAME_SIZE
);
478 info
.platform_data
= &sp2_config
;
479 request_module("sp2");
480 client_ci
= i2c_new_device(&d
->i2c_adap
, &info
);
481 if (client_ci
== NULL
|| client_ci
->dev
.driver
== NULL
) {
486 if (!try_module_get(client_ci
->dev
.driver
->owner
)) {
491 /* delegate signal strength measurement to tuner */
492 adap
->fe
[0]->ops
.read_signal_strength
=
493 adap
->fe
[0]->ops
.tuner_ops
.get_rf_strength
;
495 /* hook fe: need to resync the slave fifo when signal locks. */
496 state
->fe_read_status
= adap
->fe
[0]->ops
.read_status
;
497 adap
->fe
[0]->ops
.read_status
= dvbsky_usb_read_status
;
499 /* hook fe: LNB off/on is control by Cypress usb chip. */
500 state
->fe_set_voltage
= adap
->fe
[0]->ops
.set_voltage
;
501 adap
->fe
[0]->ops
.set_voltage
= dvbsky_usb_ci_set_voltage
;
503 state
->i2c_client_tuner
= client_tuner
;
504 state
->i2c_client_ci
= client_ci
;
507 i2c_unregister_device(client_ci
);
509 module_put(client_tuner
->dev
.driver
->owner
);
511 i2c_unregister_device(client_tuner
);
513 dvb_frontend_detach(adap
->fe
[0]);
518 static int dvbsky_t680c_attach(struct dvb_usb_adapter
*adap
)
520 struct dvbsky_state
*state
= adap_to_priv(adap
);
521 struct dvb_usb_device
*d
= adap_to_d(adap
);
523 struct i2c_adapter
*i2c_adapter
;
524 struct i2c_client
*client_demod
, *client_tuner
, *client_ci
;
525 struct i2c_board_info info
;
526 struct si2168_config si2168_config
;
527 struct si2157_config si2157_config
;
528 struct sp2_config sp2_config
;
531 memset(&si2168_config
, 0, sizeof(si2168_config
));
532 si2168_config
.i2c_adapter
= &i2c_adapter
;
533 si2168_config
.fe
= &adap
->fe
[0];
534 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
535 memset(&info
, 0, sizeof(struct i2c_board_info
));
536 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
538 info
.platform_data
= &si2168_config
;
540 request_module(info
.type
);
541 client_demod
= i2c_new_device(&d
->i2c_adap
, &info
);
542 if (client_demod
== NULL
||
543 client_demod
->dev
.driver
== NULL
)
544 goto fail_demod_device
;
545 if (!try_module_get(client_demod
->dev
.driver
->owner
))
546 goto fail_demod_module
;
549 memset(&si2157_config
, 0, sizeof(si2157_config
));
550 si2157_config
.fe
= adap
->fe
[0];
551 si2157_config
.if_port
= 1;
552 memset(&info
, 0, sizeof(struct i2c_board_info
));
553 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
555 info
.platform_data
= &si2157_config
;
557 request_module(info
.type
);
558 client_tuner
= i2c_new_device(i2c_adapter
, &info
);
559 if (client_tuner
== NULL
||
560 client_tuner
->dev
.driver
== NULL
)
561 goto fail_tuner_device
;
562 if (!try_module_get(client_tuner
->dev
.driver
->owner
))
563 goto fail_tuner_module
;
565 /* attach ci controller */
566 memset(&sp2_config
, 0, sizeof(sp2_config
));
567 sp2_config
.dvb_adap
= &adap
->dvb_adap
;
569 sp2_config
.ci_control
= dvbsky_ci_ctrl
;
570 memset(&info
, 0, sizeof(struct i2c_board_info
));
571 strlcpy(info
.type
, "sp2", I2C_NAME_SIZE
);
573 info
.platform_data
= &sp2_config
;
575 request_module(info
.type
);
576 client_ci
= i2c_new_device(&d
->i2c_adap
, &info
);
578 if (client_ci
== NULL
|| client_ci
->dev
.driver
== NULL
)
581 if (!try_module_get(client_ci
->dev
.driver
->owner
))
584 state
->i2c_client_demod
= client_demod
;
585 state
->i2c_client_tuner
= client_tuner
;
586 state
->i2c_client_ci
= client_ci
;
589 i2c_unregister_device(client_ci
);
591 module_put(client_tuner
->dev
.driver
->owner
);
593 i2c_unregister_device(client_tuner
);
595 module_put(client_demod
->dev
.driver
->owner
);
597 i2c_unregister_device(client_demod
);
603 static int dvbsky_t330_attach(struct dvb_usb_adapter
*adap
)
605 struct dvbsky_state
*state
= adap_to_priv(adap
);
606 struct dvb_usb_device
*d
= adap_to_d(adap
);
608 struct i2c_adapter
*i2c_adapter
;
609 struct i2c_client
*client_demod
, *client_tuner
;
610 struct i2c_board_info info
;
611 struct si2168_config si2168_config
;
612 struct si2157_config si2157_config
;
615 memset(&si2168_config
, 0, sizeof(si2168_config
));
616 si2168_config
.i2c_adapter
= &i2c_adapter
;
617 si2168_config
.fe
= &adap
->fe
[0];
618 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
619 si2168_config
.ts_clock_gapped
= true;
620 memset(&info
, 0, sizeof(struct i2c_board_info
));
621 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
623 info
.platform_data
= &si2168_config
;
625 request_module(info
.type
);
626 client_demod
= i2c_new_device(&d
->i2c_adap
, &info
);
627 if (client_demod
== NULL
||
628 client_demod
->dev
.driver
== NULL
)
629 goto fail_demod_device
;
630 if (!try_module_get(client_demod
->dev
.driver
->owner
))
631 goto fail_demod_module
;
634 memset(&si2157_config
, 0, sizeof(si2157_config
));
635 si2157_config
.fe
= adap
->fe
[0];
636 si2157_config
.if_port
= 1;
637 memset(&info
, 0, sizeof(struct i2c_board_info
));
638 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
640 info
.platform_data
= &si2157_config
;
642 request_module(info
.type
);
643 client_tuner
= i2c_new_device(i2c_adapter
, &info
);
644 if (client_tuner
== NULL
||
645 client_tuner
->dev
.driver
== NULL
)
646 goto fail_tuner_device
;
647 if (!try_module_get(client_tuner
->dev
.driver
->owner
))
648 goto fail_tuner_module
;
650 state
->i2c_client_demod
= client_demod
;
651 state
->i2c_client_tuner
= client_tuner
;
654 i2c_unregister_device(client_tuner
);
656 module_put(client_demod
->dev
.driver
->owner
);
658 i2c_unregister_device(client_demod
);
664 static int dvbsky_mygica_t230c_attach(struct dvb_usb_adapter
*adap
)
666 struct dvbsky_state
*state
= adap_to_priv(adap
);
667 struct dvb_usb_device
*d
= adap_to_d(adap
);
668 struct i2c_adapter
*i2c_adapter
;
669 struct i2c_client
*client_demod
, *client_tuner
;
670 struct i2c_board_info info
;
671 struct si2168_config si2168_config
;
672 struct si2157_config si2157_config
;
675 memset(&si2168_config
, 0, sizeof(si2168_config
));
676 si2168_config
.i2c_adapter
= &i2c_adapter
;
677 si2168_config
.fe
= &adap
->fe
[0];
678 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
679 si2168_config
.ts_clock_inv
= 1;
680 memset(&info
, 0, sizeof(struct i2c_board_info
));
681 strlcpy(info
.type
, "si2168", sizeof(info
.type
));
683 info
.platform_data
= &si2168_config
;
685 request_module("si2168");
686 client_demod
= i2c_new_device(&d
->i2c_adap
, &info
);
687 if (!client_demod
|| !client_demod
->dev
.driver
)
688 goto fail_demod_device
;
689 if (!try_module_get(client_demod
->dev
.driver
->owner
))
690 goto fail_demod_module
;
693 memset(&si2157_config
, 0, sizeof(si2157_config
));
694 si2157_config
.fe
= adap
->fe
[0];
695 si2157_config
.if_port
= 0;
696 memset(&info
, 0, sizeof(struct i2c_board_info
));
697 strlcpy(info
.type
, "si2141", sizeof(info
.type
));
699 info
.platform_data
= &si2157_config
;
701 request_module("si2157");
702 client_tuner
= i2c_new_device(i2c_adapter
, &info
);
703 if (!client_tuner
|| !client_tuner
->dev
.driver
)
704 goto fail_tuner_device
;
705 if (!try_module_get(client_tuner
->dev
.driver
->owner
))
706 goto fail_tuner_module
;
708 state
->i2c_client_demod
= client_demod
;
709 state
->i2c_client_tuner
= client_tuner
;
713 i2c_unregister_device(client_tuner
);
715 module_put(client_demod
->dev
.driver
->owner
);
717 i2c_unregister_device(client_demod
);
723 static int dvbsky_identify_state(struct dvb_usb_device
*d
, const char **name
)
725 dvbsky_gpio_ctrl(d
, 0x04, 1);
727 dvbsky_gpio_ctrl(d
, 0x83, 0);
728 dvbsky_gpio_ctrl(d
, 0xc0, 1);
730 dvbsky_gpio_ctrl(d
, 0x83, 1);
731 dvbsky_gpio_ctrl(d
, 0xc0, 0);
737 static int dvbsky_init(struct dvb_usb_device
*d
)
739 struct dvbsky_state
*state
= d_to_priv(d
);
741 /* use default interface */
743 ret = usb_set_interface(d->udev, 0, 0);
747 mutex_init(&state
->stream_mutex
);
749 state
->last_lock
= 0;
754 static void dvbsky_exit(struct dvb_usb_device
*d
)
756 struct dvbsky_state
*state
= d_to_priv(d
);
757 struct i2c_client
*client
;
759 client
= state
->i2c_client_tuner
;
760 /* remove I2C tuner */
762 module_put(client
->dev
.driver
->owner
);
763 i2c_unregister_device(client
);
765 client
= state
->i2c_client_demod
;
766 /* remove I2C demod */
768 module_put(client
->dev
.driver
->owner
);
769 i2c_unregister_device(client
);
771 client
= state
->i2c_client_ci
;
774 module_put(client
->dev
.driver
->owner
);
775 i2c_unregister_device(client
);
779 /* DVB USB Driver stuff */
780 static struct dvb_usb_device_properties dvbsky_s960_props
= {
781 .driver_name
= KBUILD_MODNAME
,
782 .owner
= THIS_MODULE
,
783 .adapter_nr
= adapter_nr
,
784 .size_of_priv
= sizeof(struct dvbsky_state
),
786 .generic_bulk_ctrl_endpoint
= 0x01,
787 .generic_bulk_ctrl_endpoint_response
= 0x81,
788 .generic_bulk_ctrl_delay
= DVBSKY_MSG_DELAY
,
790 .i2c_algo
= &dvbsky_i2c_algo
,
791 .frontend_attach
= dvbsky_s960_attach
,
793 .get_rc_config
= dvbsky_get_rc_config
,
794 .streaming_ctrl
= dvbsky_streaming_ctrl
,
795 .identify_state
= dvbsky_identify_state
,
797 .read_mac_address
= dvbsky_read_mac_addr
,
802 .stream
= DVB_USB_STREAM_BULK(0x82, 8, 4096),
807 static struct dvb_usb_device_properties dvbsky_s960c_props
= {
808 .driver_name
= KBUILD_MODNAME
,
809 .owner
= THIS_MODULE
,
810 .adapter_nr
= adapter_nr
,
811 .size_of_priv
= sizeof(struct dvbsky_state
),
813 .generic_bulk_ctrl_endpoint
= 0x01,
814 .generic_bulk_ctrl_endpoint_response
= 0x81,
815 .generic_bulk_ctrl_delay
= DVBSKY_MSG_DELAY
,
817 .i2c_algo
= &dvbsky_i2c_algo
,
818 .frontend_attach
= dvbsky_s960c_attach
,
820 .get_rc_config
= dvbsky_get_rc_config
,
821 .streaming_ctrl
= dvbsky_streaming_ctrl
,
822 .identify_state
= dvbsky_identify_state
,
824 .read_mac_address
= dvbsky_read_mac_addr
,
829 .stream
= DVB_USB_STREAM_BULK(0x82, 8, 4096),
834 static struct dvb_usb_device_properties dvbsky_t680c_props
= {
835 .driver_name
= KBUILD_MODNAME
,
836 .owner
= THIS_MODULE
,
837 .adapter_nr
= adapter_nr
,
838 .size_of_priv
= sizeof(struct dvbsky_state
),
840 .generic_bulk_ctrl_endpoint
= 0x01,
841 .generic_bulk_ctrl_endpoint_response
= 0x81,
842 .generic_bulk_ctrl_delay
= DVBSKY_MSG_DELAY
,
844 .i2c_algo
= &dvbsky_i2c_algo
,
845 .frontend_attach
= dvbsky_t680c_attach
,
847 .get_rc_config
= dvbsky_get_rc_config
,
848 .streaming_ctrl
= dvbsky_streaming_ctrl
,
849 .identify_state
= dvbsky_identify_state
,
851 .read_mac_address
= dvbsky_read_mac_addr
,
856 .stream
= DVB_USB_STREAM_BULK(0x82, 8, 4096),
861 static struct dvb_usb_device_properties dvbsky_t330_props
= {
862 .driver_name
= KBUILD_MODNAME
,
863 .owner
= THIS_MODULE
,
864 .adapter_nr
= adapter_nr
,
865 .size_of_priv
= sizeof(struct dvbsky_state
),
867 .generic_bulk_ctrl_endpoint
= 0x01,
868 .generic_bulk_ctrl_endpoint_response
= 0x81,
869 .generic_bulk_ctrl_delay
= DVBSKY_MSG_DELAY
,
871 .i2c_algo
= &dvbsky_i2c_algo
,
872 .frontend_attach
= dvbsky_t330_attach
,
874 .get_rc_config
= dvbsky_get_rc_config
,
875 .streaming_ctrl
= dvbsky_streaming_ctrl
,
876 .identify_state
= dvbsky_identify_state
,
878 .read_mac_address
= dvbsky_read_mac_addr
,
883 .stream
= DVB_USB_STREAM_BULK(0x82, 8, 4096),
888 static struct dvb_usb_device_properties mygica_t230c_props
= {
889 .driver_name
= KBUILD_MODNAME
,
890 .owner
= THIS_MODULE
,
891 .adapter_nr
= adapter_nr
,
892 .size_of_priv
= sizeof(struct dvbsky_state
),
894 .generic_bulk_ctrl_endpoint
= 0x01,
895 .generic_bulk_ctrl_endpoint_response
= 0x81,
896 .generic_bulk_ctrl_delay
= DVBSKY_MSG_DELAY
,
898 .i2c_algo
= &dvbsky_i2c_algo
,
899 .frontend_attach
= dvbsky_mygica_t230c_attach
,
901 .get_rc_config
= dvbsky_get_rc_config
,
902 .streaming_ctrl
= dvbsky_streaming_ctrl
,
903 .identify_state
= dvbsky_identify_state
,
909 .stream
= DVB_USB_STREAM_BULK(0x82, 8, 4096),
914 static const struct usb_device_id dvbsky_id_table
[] = {
915 { DVB_USB_DEVICE(0x0572, 0x6831,
916 &dvbsky_s960_props
, "DVBSky S960/S860", RC_MAP_DVBSKY
) },
917 { DVB_USB_DEVICE(0x0572, 0x960c,
918 &dvbsky_s960c_props
, "DVBSky S960CI", RC_MAP_DVBSKY
) },
919 { DVB_USB_DEVICE(0x0572, 0x680c,
920 &dvbsky_t680c_props
, "DVBSky T680CI", RC_MAP_DVBSKY
) },
921 { DVB_USB_DEVICE(0x0572, 0x0320,
922 &dvbsky_t330_props
, "DVBSky T330", RC_MAP_DVBSKY
) },
923 { DVB_USB_DEVICE(USB_VID_TECHNOTREND
,
924 USB_PID_TECHNOTREND_TVSTICK_CT2_4400
,
925 &dvbsky_t330_props
, "TechnoTrend TVStick CT2-4400",
927 { DVB_USB_DEVICE(USB_VID_TECHNOTREND
,
928 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI
,
929 &dvbsky_t680c_props
, "TechnoTrend TT-connect CT2-4650 CI",
931 { DVB_USB_DEVICE(USB_VID_TECHNOTREND
,
932 USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2
,
933 &dvbsky_t680c_props
, "TechnoTrend TT-connect CT2-4650 CI v1.1",
935 { DVB_USB_DEVICE(USB_VID_TECHNOTREND
,
936 USB_PID_TECHNOTREND_CONNECT_S2_4650_CI
,
937 &dvbsky_s960c_props
, "TechnoTrend TT-connect S2-4650 CI",
939 { DVB_USB_DEVICE(USB_VID_TERRATEC
,
940 USB_PID_TERRATEC_H7_3
,
941 &dvbsky_t680c_props
, "Terratec H7 Rev.4",
943 { DVB_USB_DEVICE(USB_VID_TERRATEC
, USB_PID_TERRATEC_CINERGY_S2_R4
,
944 &dvbsky_s960_props
, "Terratec Cinergy S2 Rev.4",
946 { DVB_USB_DEVICE(USB_VID_CONEXANT
, USB_PID_MYGICA_T230C
,
947 &mygica_t230c_props
, "MyGica Mini DVB-T2 USB Stick T230C",
948 RC_MAP_TOTAL_MEDIA_IN_HAND_02
) },
951 MODULE_DEVICE_TABLE(usb
, dvbsky_id_table
);
953 static struct usb_driver dvbsky_usb_driver
= {
954 .name
= KBUILD_MODNAME
,
955 .id_table
= dvbsky_id_table
,
956 .probe
= dvb_usbv2_probe
,
957 .disconnect
= dvb_usbv2_disconnect
,
958 .suspend
= dvb_usbv2_suspend
,
959 .resume
= dvb_usbv2_resume
,
960 .reset_resume
= dvb_usbv2_reset_resume
,
965 module_usb_driver(dvbsky_usb_driver
);
967 MODULE_AUTHOR("Max nibble <nibble.max@gmail.com>");
968 MODULE_DESCRIPTION("Driver for DVBSky USB");
969 MODULE_LICENSE("GPL");