1 /* DVB USB compliant linux driver for
3 * DM04/QQBOX DVB-S USB BOX LME2510C + SHARP:BS2F7HZ7395
4 * LME2510C + LG TDQY-P001F
5 * LME2510C + BS2F7HZ0194
6 * LME2510 + LG TDQY-P001F
7 * LME2510 + BS2F7HZ0194
9 * MVB7395 (LME2510C+SHARP:BS2F7HZ7395)
10 * SHARP:BS2F7HZ7395 = (STV0288+Sharp IX2505V)
12 * MV001F (LME2510+LGTDQY-P001F)
13 * LG TDQY - P001F =(TDA8263 + TDA10086H)
15 * MVB0001F (LME2510C+LGTDQT-P001F)
17 * MV0194 (LME2510+SHARP:BS2F7HZ0194)
18 * SHARP:BS2F7HZ0194 = (STV0299+IX2410)
20 * MVB0194 (LME2510C+SHARP0194)
22 * For firmware see Documentation/dvb/lmedm04.txt
25 * 0xd0 - STV0288 - Demodulator
26 * 0xc0 - Sharp IX2505V - Tuner
28 * 0x1c - TDA10086 - Demodulator
29 * 0xc0 - TDA8263 - Tuner
31 * 0xd0 - STV0299 - Demodulator
32 * 0xc0 - IX2410 - Tuner
35 * VID = 3344 PID LME2510=1122 LME2510C=1120
37 * Copyright (C) 2010 Malcolm Priestley (tvboxspy@gmail.com)
38 * LME2510(C)(C) Leaguerme (Shenzhen) MicroElectronics Co., Ltd.
40 * This program is free software; you can redistribute it and/or modify
41 * it under the terms of the GNU General Public License Version 2, as
42 * published by the Free Software Foundation.
44 * This program is distributed in the hope that it will be useful,
45 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 * GNU General Public License for more details.
49 * You should have received a copy of the GNU General Public License
50 * along with this program; if not, write to the Free Software
51 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
54 * see Documentation/dvb/README.dvb-usb for more information
57 * LME2510: Non Intel USB chipsets fail to maintain High Speed on
60 * QQbox suffers from noise on LNB voltage.
62 * LME2510: SHARP:BS2F7HZ0194(MV0194) cannot cold reset and share system
63 * with other tuners. After a cold reset streaming will not start.
66 #define DVB_USB_LOG_PREFIX "LME2510(C)"
67 #include <linux/usb.h>
68 #include <linux/usb/input.h>
69 #include <media/rc-core.h>
84 static int dvb_usb_lme2510_debug
;
85 #define l_dprintk(var, level, args...) do { \
87 printk(KERN_DEBUG DVB_USB_LOG_PREFIX ": " args); \
90 #define deb_info(level, args...) l_dprintk(dvb_usb_lme2510_debug, level, args)
91 #define debug_data_snipet(level, name, p) \
92 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
93 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
94 *(p+5), *(p+6), *(p+7));
97 module_param_named(debug
, dvb_usb_lme2510_debug
, int, 0644);
98 MODULE_PARM_DESC(debug
, "set debugging level (1=info (or-able))."
99 DVB_USB_DEBUG_STATUS
);
101 static int dvb_usb_lme2510_firmware
;
102 module_param_named(firmware
, dvb_usb_lme2510_firmware
, int, 0644);
103 MODULE_PARM_DESC(firmware
, "set default firmware 0=Sharp7395 1=LG");
105 static int pid_filter
;
106 module_param_named(pid
, pid_filter
, int, 0644);
107 MODULE_PARM_DESC(pid
, "set default 0=on 1=off");
110 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
112 #define TUNER_DEFAULT 0x0
114 #define TUNER_S7395 0x2
115 #define TUNER_S0194 0x3
117 struct lme2510_state
{
137 static int lme2510_bulk_write(struct usb_device
*dev
,
138 u8
*snd
, int len
, u8 pipe
)
142 ret
= usb_bulk_msg(dev
, usb_sndbulkpipe(dev
, pipe
),
143 snd
, len
, &actual_l
, 100);
147 static int lme2510_bulk_read(struct usb_device
*dev
,
148 u8
*rev
, int len
, u8 pipe
)
152 ret
= usb_bulk_msg(dev
, usb_rcvbulkpipe(dev
, pipe
),
153 rev
, len
, &actual_l
, 200);
157 static int lme2510_usb_talk(struct dvb_usb_device
*d
,
158 u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
160 struct lme2510_state
*st
= d
->priv
;
164 if (st
->usb_buffer
== NULL
) {
165 st
->usb_buffer
= kmalloc(64, GFP_KERNEL
);
166 if (st
->usb_buffer
== NULL
) {
167 info("MEM Error no memory");
171 buff
= st
->usb_buffer
;
173 ret
= mutex_lock_interruptible(&d
->usb_mutex
);
178 /* the read/write capped at 64 */
179 memcpy(buff
, wbuf
, (wlen
< 64) ? wlen
: 64);
181 ret
|= usb_clear_halt(d
->udev
, usb_sndbulkpipe(d
->udev
, 0x01));
183 ret
|= lme2510_bulk_write(d
->udev
, buff
, wlen
, 0x01);
187 ret
|= usb_clear_halt(d
->udev
, usb_rcvbulkpipe(d
->udev
, 0x01));
189 ret
|= lme2510_bulk_read(d
->udev
, buff
, (rlen
< 64) ?
193 memcpy(rbuf
, buff
, rlen
);
195 mutex_unlock(&d
->usb_mutex
);
197 return (ret
< 0) ? -ENODEV
: 0;
200 static int lme2510_stream_restart(struct dvb_usb_device
*d
)
202 static u8 stream_on
[] = LME_ST_ON_W
;
205 /*Restart Stream Command*/
206 ret
= lme2510_usb_talk(d
, stream_on
, sizeof(stream_on
),
207 rbuff
, sizeof(rbuff
));
211 static int lme2510_enable_pid(struct dvb_usb_device
*d
, u8 index
, u16 pid_out
)
213 struct lme2510_state
*st
= d
->priv
;
214 static u8 pid_buff
[] = LME_ZERO_PID
;
216 u8 pid_no
= index
* 2;
217 u8 pid_len
= pid_no
+ 2;
219 deb_info(1, "PID Setting Pid %04x", pid_out
);
221 if (st
->pid_size
== 0)
222 ret
|= lme2510_stream_restart(d
);
224 pid_buff
[2] = pid_no
;
225 pid_buff
[3] = (u8
)pid_out
& 0xff;
226 pid_buff
[4] = pid_no
+ 1;
227 pid_buff
[5] = (u8
)(pid_out
>> 8);
229 if (pid_len
> st
->pid_size
)
230 st
->pid_size
= pid_len
;
231 pid_buff
[7] = 0x80 + st
->pid_size
;
233 ret
|= lme2510_usb_talk(d
, pid_buff
,
234 sizeof(pid_buff
) , rbuf
, sizeof(rbuf
));
237 ret
|= lme2510_stream_restart(d
);
242 static void lme2510_int_response(struct urb
*lme_urb
)
244 struct dvb_usb_adapter
*adap
= lme_urb
->context
;
245 struct lme2510_state
*st
= adap
->dev
->priv
;
246 static u8
*ibuf
, *rbuf
;
250 switch (lme_urb
->status
) {
259 info("Error %x", lme_urb
->status
);
263 rbuf
= (u8
*) lme_urb
->transfer_buffer
;
265 offset
= ((lme_urb
->actual_length
/8) > 4)
266 ? 4 : (lme_urb
->actual_length
/8) ;
268 for (i
= 0; i
< offset
; ++i
) {
269 ibuf
= (u8
*)&rbuf
[i
*8];
270 deb_info(5, "INT O/S C =%02x C/O=%02x Type =%02x%02x",
271 offset
, i
, ibuf
[0], ibuf
[1]);
275 debug_data_snipet(1, "INT Remote data snipet", ibuf
);
276 if ((ibuf
[4] + ibuf
[5]) == 0xff) {
279 ? (ibuf
[3] ^ 0xff) << 8 : 0;
280 key
+= (ibuf
[2] ^ 0xff) << 16;
281 deb_info(1, "INT Key =%08x", key
);
282 if (adap
->dev
->rc_dev
!= NULL
)
283 rc_keydown(adap
->dev
->rc_dev
, key
, 0);
287 switch (st
->tuner_config
) {
290 st
->signal_lock
= ibuf
[2];
291 st
->signal_level
= ibuf
[4];
292 st
->signal_sn
= ibuf
[3];
293 st
->time_key
= ibuf
[7];
297 /* Tweak for earlier firmware*/
298 if (ibuf
[1] == 0x03) {
300 st
->signal_lock
= ibuf
[2];
301 st
->signal_level
= ibuf
[3];
302 st
->signal_sn
= ibuf
[4];
304 st
->signal_level
= ibuf
[4];
305 st
->signal_sn
= ibuf
[5];
307 (st
->signal_lock
& 0xf7) +
308 ((ibuf
[2] & 0x01) << 0x03);
314 debug_data_snipet(5, "INT Remote data snipet in", ibuf
);
317 debug_data_snipet(1, "INT Control data snipet", ibuf
);
320 debug_data_snipet(1, "INT Unknown data snipet", ibuf
);
324 usb_submit_urb(lme_urb
, GFP_ATOMIC
);
327 static int lme2510_int_read(struct dvb_usb_adapter
*adap
)
329 struct lme2510_state
*lme_int
= adap
->dev
->priv
;
331 lme_int
->lme_urb
= usb_alloc_urb(0, GFP_ATOMIC
);
333 if (lme_int
->lme_urb
== NULL
)
336 lme_int
->buffer
= usb_alloc_coherent(adap
->dev
->udev
, 128, GFP_ATOMIC
,
337 &lme_int
->lme_urb
->transfer_dma
);
339 if (lme_int
->buffer
== NULL
)
342 usb_fill_int_urb(lme_int
->lme_urb
,
344 usb_rcvintpipe(adap
->dev
->udev
, 0xa),
347 lme2510_int_response
,
351 lme_int
->lme_urb
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
353 usb_submit_urb(lme_int
->lme_urb
, GFP_ATOMIC
);
354 info("INT Interrupt Service Started");
359 static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
361 struct lme2510_state
*st
= adap
->dev
->priv
;
362 static u8 clear_pid_reg
[] = LME_CLEAR_PID
;
366 deb_info(1, "PID Clearing Filter");
368 ret
= mutex_lock_interruptible(&adap
->dev
->i2c_mutex
);
373 ret
|= lme2510_usb_talk(adap
->dev
, clear_pid_reg
,
374 sizeof(clear_pid_reg
), rbuf
, sizeof(rbuf
));
378 mutex_unlock(&adap
->dev
->i2c_mutex
);
383 static int lme2510_pid_filter(struct dvb_usb_adapter
*adap
, int index
, u16 pid
,
388 deb_info(3, "%s PID=%04x Index=%04x onoff=%02x", __func__
,
392 ret
= mutex_lock_interruptible(&adap
->dev
->i2c_mutex
);
395 ret
|= lme2510_enable_pid(adap
->dev
, index
, pid
);
396 mutex_unlock(&adap
->dev
->i2c_mutex
);
404 static int lme2510_return_status(struct usb_device
*dev
)
409 data
= kzalloc(10, GFP_KERNEL
);
413 ret
|= usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
414 0x06, 0x80, 0x0302, 0x00, data
, 0x0006, 200);
415 info("Firmware Status: %x (%x)", ret
, data
[2]);
417 ret
= (ret
< 0) ? -ENODEV
: data
[2];
422 static int lme2510_msg(struct dvb_usb_device
*d
,
423 u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
426 struct lme2510_state
*st
= d
->priv
;
428 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
431 if (st
->i2c_talk_onoff
== 1) {
433 ret
= lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
435 switch (st
->tuner_config
) {
437 if (wbuf
[2] == 0x1c) {
438 if (wbuf
[3] == 0x0e) {
439 st
->signal_lock
= rbuf
[1];
440 if ((st
->stream_on
& 1) &&
441 (st
->signal_lock
& 0x10)) {
442 lme2510_stream_restart(d
);
443 st
->i2c_talk_onoff
= 0;
450 if (wbuf
[2] == 0xd0) {
451 if (wbuf
[3] == 0x24) {
452 st
->signal_lock
= rbuf
[1];
453 if ((st
->stream_on
& 1) &&
454 (st
->signal_lock
& 0x8)) {
455 lme2510_stream_restart(d
);
456 st
->i2c_talk_onoff
= 0;
459 if ((wbuf
[3] != 0x6) & (wbuf
[3] != 0x5))
464 if (wbuf
[2] == 0xd0) {
465 if (wbuf
[3] == 0x1b) {
466 st
->signal_lock
= rbuf
[1];
467 if ((st
->stream_on
& 1) &&
468 (st
->signal_lock
& 0x8)) {
469 lme2510_stream_restart(d
);
470 st
->i2c_talk_onoff
= 0;
479 switch (st
->tuner_config
) {
484 rbuf
[1] = st
->signal_lock
;
488 rbuf
[1] = st
->signal_level
;
492 rbuf
[1] = st
->signal_sn
;
502 lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
503 st
->i2c_talk_onoff
= 1;
511 rbuf
[1] = (st
->signal_level
& 0x80)
512 ? 0 : (st
->signal_level
* 2);
516 rbuf
[1] = st
->signal_sn
;
520 rbuf
[1] = st
->signal_lock
;
529 lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
530 st
->i2c_talk_onoff
= 1;
538 rbuf
[1] = (st
->signal_level
& 0x80)
539 ? 0 : (st
->signal_level
* 2);
543 rbuf
[1] = st
->signal_sn
;
547 rbuf
[1] = st
->signal_lock
;
557 lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
558 st
->i2c_talk_onoff
= 1;
566 deb_info(4, "I2C From Interrupt Message out(%02x) in(%02x)",
571 mutex_unlock(&d
->i2c_mutex
);
577 static int lme2510_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
580 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
581 struct lme2510_state
*st
= d
->priv
;
582 static u8 obuf
[64], ibuf
[64];
585 u8 gate
= st
->i2c_gate
;
591 warn("more than 2 i2c messages"
592 "at a time is not handled yet. TODO.");
594 for (i
= 0; i
< num
; i
++) {
595 read_o
= 1 & (msg
[i
].flags
& I2C_M_RD
);
596 read
= i
+1 < num
&& (msg
[i
+1].flags
& I2C_M_RD
);
598 gate
= (msg
[i
].addr
== st
->i2c_tuner_addr
)
599 ? (read
) ? st
->i2c_tuner_gate_r
600 : st
->i2c_tuner_gate_w
602 obuf
[0] = gate
| (read
<< 7);
605 obuf
[1] = (read
) ? 2 : msg
[i
].len
+ 1;
607 obuf
[1] = msg
[i
].len
+ read
+ 1;
609 obuf
[2] = msg
[i
].addr
;
614 memcpy(&obuf
[3], msg
[i
].buf
, msg
[i
].len
);
615 obuf
[msg
[i
].len
+3] = msg
[i
+1].len
;
619 memcpy(&obuf
[3], msg
[i
].buf
, msg
[i
].len
);
623 if (lme2510_msg(d
, obuf
, len
, ibuf
, 64) < 0) {
624 deb_info(1, "i2c transfer failed.");
630 memcpy(msg
[i
].buf
, &ibuf
[1], msg
[i
].len
);
632 memcpy(msg
[i
+1].buf
, &ibuf
[1], msg
[i
+1].len
);
640 static u32
lme2510_i2c_func(struct i2c_adapter
*adapter
)
645 static struct i2c_algorithm lme2510_i2c_algo
= {
646 .master_xfer
= lme2510_i2c_xfer
,
647 .functionality
= lme2510_i2c_func
,
650 /* Callbacks for DVB USB */
651 static int lme2510_identify_state(struct usb_device
*udev
,
652 struct dvb_usb_device_properties
*props
,
653 struct dvb_usb_device_description
**desc
,
657 props
->adapter
[0].fe
[0].caps
&=
658 ~DVB_USB_ADAP_NEED_PID_FILTERING
;
663 static int lme2510_streaming_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
665 struct lme2510_state
*st
= adap
->dev
->priv
;
666 static u8 clear_reg_3
[] = LME_CLEAR_PID
;
668 int ret
= 0, rlen
= sizeof(rbuf
);
670 deb_info(1, "STM (%02x)", onoff
);
672 /* Streaming is started by FE_HAS_LOCK */
676 deb_info(1, "STM Steam Off");
677 /* mutex is here only to avoid collision with I2C */
678 if (mutex_lock_interruptible(&adap
->dev
->i2c_mutex
) < 0)
681 ret
= lme2510_usb_talk(adap
->dev
, clear_reg_3
,
682 sizeof(clear_reg_3
), rbuf
, rlen
);
684 st
->i2c_talk_onoff
= 1;
686 mutex_unlock(&adap
->dev
->i2c_mutex
);
689 return (ret
< 0) ? -ENODEV
: 0;
692 static u8
check_sum(u8
*p
, u8 len
)
700 static int lme2510_download_firmware(struct usb_device
*dev
,
701 const struct firmware
*fw
)
705 u16 j
, wlen
, len_in
, start
, end
;
706 u8 packet_size
, dlen
, i
;
712 data
= kzalloc(512, GFP_KERNEL
);
714 info("FRM Could not start Firmware Download (Buffer allocation failed)");
718 info("FRM Starting Firmware Download");
720 for (i
= 1; i
< 3; i
++) {
721 start
= (i
== 1) ? 0 : 512;
722 end
= (i
== 1) ? 512 : fw
->size
;
723 for (j
= start
; j
< end
; j
+= (packet_size
+1)) {
724 fw_data
= (u8
*)(fw
->data
+ j
);
725 if ((end
- j
) > packet_size
) {
730 dlen
= (u8
)(end
- j
)-1;
733 memcpy(&data
[2], fw_data
, dlen
+1);
734 wlen
= (u8
) dlen
+ 4;
735 data
[wlen
-1] = check_sum(fw_data
, dlen
+1);
736 deb_info(1, "Data S=%02x:E=%02x CS= %02x", data
[3],
737 data
[dlen
+2], data
[dlen
+3]);
738 ret
|= lme2510_bulk_write(dev
, data
, wlen
, 1);
739 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
740 ret
|= (data
[0] == 0x88) ? 0 : -1;
744 usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
745 0x06, 0x80, 0x0200, 0x00, data
, 0x0109, 1000);
751 ret
|= lme2510_bulk_write(dev
, data
, len_in
, 1); /*Resetting*/
752 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
756 info("FRM Firmware Download Failed (%04x)" , ret
);
758 info("FRM Firmware Download Completed - Resetting Device");
761 return (ret
< 0) ? -ENODEV
: 0;
764 static void lme_coldreset(struct usb_device
*dev
)
771 info("FRM Firmware Cold Reset");
772 ret
|= lme2510_bulk_write(dev
, data
, len_in
, 1); /*Cold Resetting*/
773 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
778 static int lme_firmware_switch(struct usb_device
*udev
, int cold
)
780 const struct firmware
*fw
= NULL
;
781 const char fw_c_s7395
[] = "dvb-usb-lme2510c-s7395.fw";
782 const char fw_c_lg
[] = "dvb-usb-lme2510c-lg.fw";
783 const char fw_c_s0194
[] = "dvb-usb-lme2510c-s0194.fw";
784 const char fw_lg
[] = "dvb-usb-lme2510-lg.fw";
785 const char fw_s0194
[] = "dvb-usb-lme2510-s0194.fw";
789 cold
= (cold
> 0) ? (cold
& 1) : 0;
793 if (le16_to_cpu(udev
->descriptor
.idProduct
) == 0x1122) {
794 switch (dvb_usb_lme2510_firmware
) {
796 dvb_usb_lme2510_firmware
= TUNER_S0194
;
799 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
804 dvb_usb_lme2510_firmware
= TUNER_LG
;
807 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
810 info("FRM No Firmware Found - please install");
811 dvb_usb_lme2510_firmware
= TUNER_DEFAULT
;
817 switch (dvb_usb_lme2510_firmware
) {
819 dvb_usb_lme2510_firmware
= TUNER_S7395
;
822 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
827 dvb_usb_lme2510_firmware
= TUNER_LG
;
830 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
833 dvb_usb_lme2510_firmware
= TUNER_S0194
;
836 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
839 info("FRM No Firmware Found - please install");
840 dvb_usb_lme2510_firmware
= TUNER_DEFAULT
;
848 info("FRM Loading %s file", fw_lme
);
849 ret
= lme2510_download_firmware(udev
, fw
);
852 release_firmware(fw
);
855 info("FRM Changing to %s firmware", fw_lme
);
863 static int lme2510_kill_urb(struct usb_data_stream
*stream
)
867 for (i
= 0; i
< stream
->urbs_submitted
; i
++) {
868 deb_info(3, "killing URB no. %d.", i
);
870 usb_kill_urb(stream
->urb_list
[i
]);
872 stream
->urbs_submitted
= 0;
877 static struct tda10086_config tda10086_config
= {
878 .demod_address
= 0x1c,
881 .xtal_freq
= TDA10086_XTAL_16M
,
884 static struct stv0288_config lme_config
= {
885 .demod_address
= 0xd0,
887 .inittab
= s7395_inittab
,
890 static struct ix2505v_config lme_tuner
= {
891 .tuner_address
= 0xc0,
894 .tuner_chargepump
= 0x3,
897 static struct stv0299_config sharp_z0194_config
= {
898 .demod_address
= 0xd0,
899 .inittab
= sharp_z0194a_inittab
,
903 .lock_output
= STV0299_LOCKOUTPUT_1
,
904 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
906 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
909 static int dm04_lme2510_set_voltage(struct dvb_frontend
*fe
,
910 fe_sec_voltage_t voltage
)
912 struct dvb_usb_adapter
*adap
= fe
->dvb
->priv
;
913 static u8 voltage_low
[] = LME_VOLTAGE_L
;
914 static u8 voltage_high
[] = LME_VOLTAGE_H
;
916 int ret
= 0, len
= 3, rlen
= 1;
918 if (mutex_lock_interruptible(&adap
->dev
->i2c_mutex
) < 0)
923 ret
|= lme2510_usb_talk(adap
->dev
,
924 voltage_high
, len
, rbuf
, rlen
);
927 case SEC_VOLTAGE_OFF
:
930 ret
|= lme2510_usb_talk(adap
->dev
,
931 voltage_low
, len
, rbuf
, rlen
);
935 mutex_unlock(&adap
->dev
->i2c_mutex
);
937 return (ret
< 0) ? -ENODEV
: 0;
940 static int lme_name(struct dvb_usb_adapter
*adap
)
942 struct lme2510_state
*st
= adap
->dev
->priv
;
943 const char *desc
= adap
->dev
->desc
->name
;
944 char *fe_name
[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395",
945 " SHARP:BS2F7HZ0194"};
946 char *name
= adap
->fe_adap
[0].fe
->ops
.info
.name
;
948 strlcpy(name
, desc
, 128);
949 strlcat(name
, fe_name
[st
->tuner_config
], 128);
954 static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter
*adap
)
956 struct lme2510_state
*st
= adap
->dev
->priv
;
960 st
->i2c_talk_onoff
= 1;
963 adap
->fe_adap
[0].fe
= dvb_attach(tda10086_attach
, &tda10086_config
,
964 &adap
->dev
->i2c_adap
);
966 if (adap
->fe_adap
[0].fe
) {
967 info("TUN Found Frontend TDA10086");
968 st
->i2c_tuner_gate_w
= 4;
969 st
->i2c_tuner_gate_r
= 4;
970 st
->i2c_tuner_addr
= 0xc0;
971 st
->tuner_config
= TUNER_LG
;
972 if (dvb_usb_lme2510_firmware
!= TUNER_LG
) {
973 dvb_usb_lme2510_firmware
= TUNER_LG
;
974 ret
= lme_firmware_switch(adap
->dev
->udev
, 1);
980 adap
->fe_adap
[0].fe
= dvb_attach(stv0299_attach
, &sharp_z0194_config
,
981 &adap
->dev
->i2c_adap
);
982 if (adap
->fe_adap
[0].fe
) {
983 info("FE Found Stv0299");
984 st
->i2c_tuner_gate_w
= 4;
985 st
->i2c_tuner_gate_r
= 5;
986 st
->i2c_tuner_addr
= 0xc0;
987 st
->tuner_config
= TUNER_S0194
;
988 if (dvb_usb_lme2510_firmware
!= TUNER_S0194
) {
989 dvb_usb_lme2510_firmware
= TUNER_S0194
;
990 ret
= lme_firmware_switch(adap
->dev
->udev
, 1);
996 adap
->fe_adap
[0].fe
= dvb_attach(stv0288_attach
, &lme_config
,
997 &adap
->dev
->i2c_adap
);
998 if (adap
->fe_adap
[0].fe
) {
999 info("FE Found Stv0288");
1000 st
->i2c_tuner_gate_w
= 4;
1001 st
->i2c_tuner_gate_r
= 5;
1002 st
->i2c_tuner_addr
= 0xc0;
1003 st
->tuner_config
= TUNER_S7395
;
1004 if (dvb_usb_lme2510_firmware
!= TUNER_S7395
) {
1005 dvb_usb_lme2510_firmware
= TUNER_S7395
;
1006 ret
= lme_firmware_switch(adap
->dev
->udev
, 1);
1009 info("DM04 Not Supported");
1015 if (adap
->fe_adap
[0].fe
) {
1016 dvb_frontend_detach(adap
->fe_adap
[0].fe
);
1017 adap
->fe_adap
[0].fe
= NULL
;
1019 adap
->dev
->props
.rc
.core
.rc_codes
= NULL
;
1023 adap
->fe_adap
[0].fe
->ops
.set_voltage
= dm04_lme2510_set_voltage
;
1024 ret
= lme_name(adap
);
1028 static int dm04_lme2510_tuner(struct dvb_usb_adapter
*adap
)
1030 struct lme2510_state
*st
= adap
->dev
->priv
;
1031 char *tun_msg
[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA"};
1034 switch (st
->tuner_config
) {
1036 if (dvb_attach(tda826x_attach
, adap
->fe_adap
[0].fe
, 0xc0,
1037 &adap
->dev
->i2c_adap
, 1))
1038 ret
= st
->tuner_config
;
1041 if (dvb_attach(ix2505v_attach
, adap
->fe_adap
[0].fe
, &lme_tuner
,
1042 &adap
->dev
->i2c_adap
))
1043 ret
= st
->tuner_config
;
1046 if (dvb_attach(dvb_pll_attach
, adap
->fe_adap
[0].fe
, 0xc0,
1047 &adap
->dev
->i2c_adap
, DVB_PLL_OPERA1
))
1048 ret
= st
->tuner_config
;
1055 info("TUN Found %s tuner", tun_msg
[ret
]);
1057 info("TUN No tuner found --- reseting device");
1058 lme_coldreset(adap
->dev
->udev
);
1062 /* Start the Interrupt*/
1063 ret
= lme2510_int_read(adap
);
1065 info("INT Unable to start Interrupt Service");
1072 static int lme2510_powerup(struct dvb_usb_device
*d
, int onoff
)
1074 struct lme2510_state
*st
= d
->priv
;
1075 static u8 lnb_on
[] = LNB_ON
;
1076 static u8 lnb_off
[] = LNB_OFF
;
1078 int ret
, len
= 3, rlen
= 1;
1080 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
1084 ret
= lme2510_usb_talk(d
, lnb_on
, len
, rbuf
, rlen
);
1086 ret
= lme2510_usb_talk(d
, lnb_off
, len
, rbuf
, rlen
);
1088 st
->i2c_talk_onoff
= 1;
1090 mutex_unlock(&d
->i2c_mutex
);
1095 /* DVB USB Driver stuff */
1096 static struct dvb_usb_device_properties lme2510_properties
;
1097 static struct dvb_usb_device_properties lme2510c_properties
;
1099 static int lme2510_probe(struct usb_interface
*intf
,
1100 const struct usb_device_id
*id
)
1102 struct usb_device
*udev
= interface_to_usbdev(intf
);
1105 usb_reset_configuration(udev
);
1107 usb_set_interface(udev
, intf
->cur_altsetting
->desc
.bInterfaceNumber
, 1);
1109 if (udev
->speed
!= USB_SPEED_HIGH
) {
1110 ret
= usb_reset_device(udev
);
1111 info("DEV Failed to connect in HIGH SPEED mode");
1115 if (lme2510_return_status(udev
) == 0x44) {
1116 lme_firmware_switch(udev
, 0);
1120 if (0 == dvb_usb_device_init(intf
, &lme2510_properties
,
1121 THIS_MODULE
, NULL
, adapter_nr
)) {
1122 info("DEV registering device driver");
1125 if (0 == dvb_usb_device_init(intf
, &lme2510c_properties
,
1126 THIS_MODULE
, NULL
, adapter_nr
)) {
1127 info("DEV registering device driver");
1131 info("DEV lme2510 Error");
1136 static struct usb_device_id lme2510_table
[] = {
1137 { USB_DEVICE(0x3344, 0x1122) }, /* LME2510 */
1138 { USB_DEVICE(0x3344, 0x1120) }, /* LME2510C */
1139 {} /* Terminating entry */
1142 MODULE_DEVICE_TABLE(usb
, lme2510_table
);
1144 static struct dvb_usb_device_properties lme2510_properties
= {
1145 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1146 .size_of_priv
= sizeof(struct lme2510_state
),
1152 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1153 DVB_USB_ADAP_NEED_PID_FILTERING
|
1154 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1155 .streaming_ctrl
= lme2510_streaming_ctrl
,
1156 .pid_filter_count
= 15,
1157 .pid_filter
= lme2510_pid_filter
,
1158 .pid_filter_ctrl
= lme2510_pid_filter_ctrl
,
1159 .frontend_attach
= dm04_lme2510_frontend_attach
,
1160 .tuner_attach
= dm04_lme2510_tuner
,
1161 /* parameter for the MPEG2-data transfer */
1177 .protocol
= RC_TYPE_NEC
,
1178 .module_name
= "LME2510 Remote Control",
1179 .allowed_protos
= RC_TYPE_NEC
,
1180 .rc_codes
= RC_MAP_LME2510
,
1182 .power_ctrl
= lme2510_powerup
,
1183 .identify_state
= lme2510_identify_state
,
1184 .i2c_algo
= &lme2510_i2c_algo
,
1185 .generic_bulk_ctrl_endpoint
= 0,
1186 .num_device_descs
= 1,
1188 { "DM04_LME2510_DVB-S",
1189 { &lme2510_table
[0], NULL
},
1195 static struct dvb_usb_device_properties lme2510c_properties
= {
1196 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1197 .size_of_priv
= sizeof(struct lme2510_state
),
1203 .caps
= DVB_USB_ADAP_HAS_PID_FILTER
|
1204 DVB_USB_ADAP_NEED_PID_FILTERING
|
1205 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF
,
1206 .streaming_ctrl
= lme2510_streaming_ctrl
,
1207 .pid_filter_count
= 15,
1208 .pid_filter
= lme2510_pid_filter
,
1209 .pid_filter_ctrl
= lme2510_pid_filter_ctrl
,
1210 .frontend_attach
= dm04_lme2510_frontend_attach
,
1211 .tuner_attach
= dm04_lme2510_tuner
,
1212 /* parameter for the MPEG2-data transfer */
1228 .protocol
= RC_TYPE_NEC
,
1229 .module_name
= "LME2510 Remote Control",
1230 .allowed_protos
= RC_TYPE_NEC
,
1231 .rc_codes
= RC_MAP_LME2510
,
1233 .power_ctrl
= lme2510_powerup
,
1234 .identify_state
= lme2510_identify_state
,
1235 .i2c_algo
= &lme2510_i2c_algo
,
1236 .generic_bulk_ctrl_endpoint
= 0,
1237 .num_device_descs
= 1,
1239 { "DM04_LME2510C_DVB-S",
1240 { &lme2510_table
[1], NULL
},
1245 static void *lme2510_exit_int(struct dvb_usb_device
*d
)
1247 struct lme2510_state
*st
= d
->priv
;
1248 struct dvb_usb_adapter
*adap
= &d
->adapter
[0];
1249 void *buffer
= NULL
;
1252 lme2510_kill_urb(&adap
->fe_adap
[0].stream
);
1253 adap
->feedcount
= 0;
1256 if (st
->usb_buffer
!= NULL
) {
1257 st
->i2c_talk_onoff
= 1;
1258 st
->signal_lock
= 0;
1259 st
->signal_level
= 0;
1261 buffer
= st
->usb_buffer
;
1264 if (st
->lme_urb
!= NULL
) {
1265 usb_kill_urb(st
->lme_urb
);
1266 usb_free_coherent(d
->udev
, 128, st
->buffer
,
1267 st
->lme_urb
->transfer_dma
);
1268 info("Interrupt Service Stopped");
1274 static void lme2510_exit(struct usb_interface
*intf
)
1276 struct dvb_usb_device
*d
= usb_get_intfdata(intf
);
1280 usb_buffer
= lme2510_exit_int(d
);
1281 dvb_usb_device_exit(intf
);
1282 if (usb_buffer
!= NULL
)
1287 static struct usb_driver lme2510_driver
= {
1288 .name
= "LME2510C_DVB-S",
1289 .probe
= lme2510_probe
,
1290 .disconnect
= lme2510_exit
,
1291 .id_table
= lme2510_table
,
1294 module_usb_driver(lme2510_driver
);
1296 MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1297 MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0");
1298 MODULE_VERSION("1.91");
1299 MODULE_LICENSE("GPL");