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.
65 * PID functions have been removed from this driver version due to
66 * problems with different firmware and application versions.
68 #define DVB_USB_LOG_PREFIX "LME2510(C)"
69 #include <linux/usb.h>
70 #include <linux/usb/input.h>
71 #include <media/rc-core.h>
86 static int dvb_usb_lme2510_debug
;
87 #define l_dprintk(var, level, args...) do { \
89 printk(KERN_DEBUG DVB_USB_LOG_PREFIX ": " args); \
92 #define deb_info(level, args...) l_dprintk(dvb_usb_lme2510_debug, level, args)
93 #define debug_data_snipet(level, name, p) \
94 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
95 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
96 *(p+5), *(p+6), *(p+7));
99 module_param_named(debug
, dvb_usb_lme2510_debug
, int, 0644);
100 MODULE_PARM_DESC(debug
, "set debugging level (1=info (or-able))."
101 DVB_USB_DEBUG_STATUS
);
103 static int dvb_usb_lme2510_firmware
;
104 module_param_named(firmware
, dvb_usb_lme2510_firmware
, int, 0644);
105 MODULE_PARM_DESC(firmware
, "set default firmware 0=Sharp7395 1=LG");
108 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
110 #define TUNER_DEFAULT 0x0
112 #define TUNER_S7395 0x2
113 #define TUNER_S0194 0x3
115 struct lme2510_state
{
134 static int lme2510_bulk_write(struct usb_device
*dev
,
135 u8
*snd
, int len
, u8 pipe
)
139 ret
= usb_bulk_msg(dev
, usb_sndbulkpipe(dev
, pipe
),
140 snd
, len
, &actual_l
, 100);
144 static int lme2510_bulk_read(struct usb_device
*dev
,
145 u8
*rev
, int len
, u8 pipe
)
149 ret
= usb_bulk_msg(dev
, usb_rcvbulkpipe(dev
, pipe
),
150 rev
, len
, &actual_l
, 200);
154 static int lme2510_usb_talk(struct dvb_usb_device
*d
,
155 u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
157 struct lme2510_state
*st
= d
->priv
;
161 if (st
->usb_buffer
== NULL
) {
162 st
->usb_buffer
= kmalloc(512, GFP_KERNEL
);
163 if (st
->usb_buffer
== NULL
) {
164 info("MEM Error no memory");
168 buff
= st
->usb_buffer
;
170 /* the read/write capped at 512 */
171 memcpy(buff
, wbuf
, (wlen
> 512) ? 512 : wlen
);
173 ret
= mutex_lock_interruptible(&d
->usb_mutex
);
178 ret
|= usb_clear_halt(d
->udev
, usb_sndbulkpipe(d
->udev
, 0x01));
180 ret
|= lme2510_bulk_write(d
->udev
, buff
, wlen
, 0x01);
184 ret
|= usb_clear_halt(d
->udev
, usb_rcvbulkpipe(d
->udev
, 0x01));
186 ret
|= lme2510_bulk_read(d
->udev
, buff
, (rlen
> 512) ?
190 memcpy(rbuf
, buff
, rlen
);
192 mutex_unlock(&d
->usb_mutex
);
194 return (ret
< 0) ? -ENODEV
: 0;
197 static int lme2510_stream_restart(struct dvb_usb_device
*d
)
199 static u8 stream_on
[] = LME_ST_ON_W
;
202 /*Restart Stream Command*/
203 ret
= lme2510_usb_talk(d
, stream_on
, sizeof(stream_on
),
204 rbuff
, sizeof(rbuff
));
207 static int lme2510_remote_keypress(struct dvb_usb_adapter
*adap
, u32 keypress
)
209 struct dvb_usb_device
*d
= adap
->dev
;
211 deb_info(1, "INT Key Keypress =%04x", keypress
);
214 rc_keydown(d
->rc_dev
, keypress
, 0);
219 static void lme2510_int_response(struct urb
*lme_urb
)
221 struct dvb_usb_adapter
*adap
= lme_urb
->context
;
222 struct lme2510_state
*st
= adap
->dev
->priv
;
223 static u8
*ibuf
, *rbuf
;
226 switch (lme_urb
->status
) {
235 info("Error %x", lme_urb
->status
);
239 rbuf
= (u8
*) lme_urb
->transfer_buffer
;
241 offset
= ((lme_urb
->actual_length
/8) > 4)
242 ? 4 : (lme_urb
->actual_length
/8) ;
244 for (i
= 0; i
< offset
; ++i
) {
245 ibuf
= (u8
*)&rbuf
[i
*8];
246 deb_info(5, "INT O/S C =%02x C/O=%02x Type =%02x%02x",
247 offset
, i
, ibuf
[0], ibuf
[1]);
251 debug_data_snipet(1, "INT Remote data snipet in", ibuf
);
252 lme2510_remote_keypress(adap
,
253 (u32
)(ibuf
[2] << 24) + (ibuf
[3] << 16) +
254 (ibuf
[4] << 8) + ibuf
[5]);
257 switch (st
->tuner_config
) {
260 st
->signal_lock
= ibuf
[2];
261 st
->signal_level
= ibuf
[4];
262 st
->signal_sn
= ibuf
[3];
263 st
->time_key
= ibuf
[7];
267 /* Tweak for earlier firmware*/
268 if (ibuf
[1] == 0x03) {
270 st
->signal_lock
= ibuf
[2];
271 st
->signal_level
= ibuf
[3];
272 st
->signal_sn
= ibuf
[4];
274 st
->signal_level
= ibuf
[4];
275 st
->signal_sn
= ibuf
[5];
277 (st
->signal_lock
& 0xf7) +
278 ((ibuf
[2] & 0x01) << 0x03);
284 debug_data_snipet(5, "INT Remote data snipet in", ibuf
);
287 debug_data_snipet(1, "INT Control data snipet", ibuf
);
290 debug_data_snipet(1, "INT Unknown data snipet", ibuf
);
294 usb_submit_urb(lme_urb
, GFP_ATOMIC
);
297 static int lme2510_int_read(struct dvb_usb_adapter
*adap
)
299 struct lme2510_state
*lme_int
= adap
->dev
->priv
;
301 lme_int
->lme_urb
= usb_alloc_urb(0, GFP_ATOMIC
);
303 if (lme_int
->lme_urb
== NULL
)
306 lme_int
->buffer
= usb_alloc_coherent(adap
->dev
->udev
, 5000, GFP_ATOMIC
,
307 &lme_int
->lme_urb
->transfer_dma
);
309 if (lme_int
->buffer
== NULL
)
312 usb_fill_int_urb(lme_int
->lme_urb
,
314 usb_rcvintpipe(adap
->dev
->udev
, 0xa),
317 lme2510_int_response
,
321 lme_int
->lme_urb
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
323 usb_submit_urb(lme_int
->lme_urb
, GFP_ATOMIC
);
324 info("INT Interupt Service Started");
329 static int lme2510_return_status(struct usb_device
*dev
)
334 ret
|= usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
335 0x06, 0x80, 0x0302, 0x00, data
, 0x0006, 200);
336 info("Firmware Status: %x (%x)", ret
, data
[2]);
338 return (ret
< 0) ? -ENODEV
: data
[2];
341 static int lme2510_msg(struct dvb_usb_device
*d
,
342 u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
345 struct lme2510_state
*st
= d
->priv
;
347 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
350 if (st
->i2c_talk_onoff
== 1) {
352 ret
= lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
354 switch (st
->tuner_config
) {
356 if (wbuf
[2] == 0x1c) {
357 if (wbuf
[3] == 0x0e) {
358 st
->signal_lock
= rbuf
[1];
359 if ((st
->stream_on
& 1) &&
360 (st
->signal_lock
& 0x10)) {
361 lme2510_stream_restart(d
);
362 st
->i2c_talk_onoff
= 0;
369 if (wbuf
[2] == 0xd0) {
370 if (wbuf
[3] == 0x24) {
371 st
->signal_lock
= rbuf
[1];
372 if ((st
->stream_on
& 1) &&
373 (st
->signal_lock
& 0x8)) {
374 lme2510_stream_restart(d
);
375 st
->i2c_talk_onoff
= 0;
378 if ((wbuf
[3] != 0x6) & (wbuf
[3] != 0x5))
383 if (wbuf
[2] == 0xd0) {
384 if (wbuf
[3] == 0x1b) {
385 st
->signal_lock
= rbuf
[1];
386 if ((st
->stream_on
& 1) &&
387 (st
->signal_lock
& 0x8)) {
388 lme2510_stream_restart(d
);
389 st
->i2c_talk_onoff
= 0;
398 switch (st
->tuner_config
) {
403 rbuf
[1] = st
->signal_lock
;
407 rbuf
[1] = st
->signal_level
;
411 rbuf
[1] = st
->signal_sn
;
421 lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
422 st
->i2c_talk_onoff
= 1;
430 rbuf
[1] = (st
->signal_level
& 0x80)
431 ? 0 : (st
->signal_level
* 2);
435 rbuf
[1] = st
->signal_sn
;
439 rbuf
[1] = st
->signal_lock
;
448 lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
449 st
->i2c_talk_onoff
= 1;
457 rbuf
[1] = (st
->signal_level
& 0x80)
458 ? 0 : (st
->signal_level
* 2);
462 rbuf
[1] = st
->signal_sn
;
466 rbuf
[1] = st
->signal_lock
;
476 lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
477 st
->i2c_talk_onoff
= 1;
485 deb_info(4, "I2C From Interupt Message out(%02x) in(%02x)",
490 mutex_unlock(&d
->i2c_mutex
);
496 static int lme2510_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
499 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
500 struct lme2510_state
*st
= d
->priv
;
501 static u8 obuf
[64], ibuf
[512];
504 u8 gate
= st
->i2c_gate
;
510 warn("more than 2 i2c messages"
511 "at a time is not handled yet. TODO.");
513 for (i
= 0; i
< num
; i
++) {
514 read_o
= 1 & (msg
[i
].flags
& I2C_M_RD
);
515 read
= i
+1 < num
&& (msg
[i
+1].flags
& I2C_M_RD
);
517 gate
= (msg
[i
].addr
== st
->i2c_tuner_addr
)
518 ? (read
) ? st
->i2c_tuner_gate_r
519 : st
->i2c_tuner_gate_w
521 obuf
[0] = gate
| (read
<< 7);
524 obuf
[1] = (read
) ? 2 : msg
[i
].len
+ 1;
526 obuf
[1] = msg
[i
].len
+ read
+ 1;
528 obuf
[2] = msg
[i
].addr
;
533 memcpy(&obuf
[3], msg
[i
].buf
, msg
[i
].len
);
534 obuf
[msg
[i
].len
+3] = msg
[i
+1].len
;
538 memcpy(&obuf
[3], msg
[i
].buf
, msg
[i
].len
);
542 if (lme2510_msg(d
, obuf
, len
, ibuf
, 512) < 0) {
543 deb_info(1, "i2c transfer failed.");
549 memcpy(msg
[i
].buf
, &ibuf
[1], msg
[i
].len
);
551 memcpy(msg
[i
+1].buf
, &ibuf
[1], msg
[i
+1].len
);
559 static u32
lme2510_i2c_func(struct i2c_adapter
*adapter
)
564 static struct i2c_algorithm lme2510_i2c_algo
= {
565 .master_xfer
= lme2510_i2c_xfer
,
566 .functionality
= lme2510_i2c_func
,
569 /* Callbacks for DVB USB */
570 static int lme2510_identify_state(struct usb_device
*udev
,
571 struct dvb_usb_device_properties
*props
,
572 struct dvb_usb_device_description
**desc
,
579 static int lme2510_streaming_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
581 struct lme2510_state
*st
= adap
->dev
->priv
;
582 static u8 clear_reg_3
[] = LME_CLEAR_PID
;
584 int ret
= 0, rlen
= sizeof(rbuf
);
586 deb_info(1, "STM (%02x)", onoff
);
588 /* Streaming is started by FE_HAS_LOCK */
592 deb_info(1, "STM Steam Off");
593 /* mutex is here only to avoid collision with I2C */
594 ret
= mutex_lock_interruptible(&adap
->dev
->i2c_mutex
);
596 ret
|= lme2510_usb_talk(adap
->dev
, clear_reg_3
,
597 sizeof(clear_reg_3
), rbuf
, rlen
);
599 st
->i2c_talk_onoff
= 1;
601 mutex_unlock(&adap
->dev
->i2c_mutex
);
604 return (ret
< 0) ? -ENODEV
: 0;
607 static int lme2510_int_service(struct dvb_usb_adapter
*adap
)
609 struct dvb_usb_device
*d
= adap
->dev
;
613 info("STA Configuring Remote");
615 rc
= rc_allocate_device();
619 usb_make_path(d
->udev
, d
->rc_phys
, sizeof(d
->rc_phys
));
620 strlcat(d
->rc_phys
, "/ir0", sizeof(d
->rc_phys
));
622 rc
->input_name
= "LME2510 Remote Control";
623 rc
->input_phys
= d
->rc_phys
;
624 rc
->map_name
= RC_MAP_LME2510
;
625 rc
->driver_name
= "LME 2510";
626 usb_to_input_id(d
->udev
, &rc
->input_id
);
628 ret
= rc_register_device(rc
);
635 /* Start the Interupt */
636 ret
= lme2510_int_read(adap
);
638 rc_unregister_device(rc
);
639 info("INT Unable to start Interupt Service");
646 static u8
check_sum(u8
*p
, u8 len
)
654 static int lme2510_download_firmware(struct usb_device
*dev
,
655 const struct firmware
*fw
)
659 u16 j
, wlen
, len_in
, start
, end
;
660 u8 packet_size
, dlen
, i
;
667 info("FRM Starting Firmware Download");
669 for (i
= 1; i
< 3; i
++) {
670 start
= (i
== 1) ? 0 : 512;
671 end
= (i
== 1) ? 512 : fw
->size
;
672 for (j
= start
; j
< end
; j
+= (packet_size
+1)) {
673 fw_data
= (u8
*)(fw
->data
+ j
);
674 if ((end
- j
) > packet_size
) {
679 dlen
= (u8
)(end
- j
)-1;
682 memcpy(&data
[2], fw_data
, dlen
+1);
683 wlen
= (u8
) dlen
+ 4;
684 data
[wlen
-1] = check_sum(fw_data
, dlen
+1);
685 deb_info(1, "Data S=%02x:E=%02x CS= %02x", data
[3],
686 data
[dlen
+2], data
[dlen
+3]);
687 ret
|= lme2510_bulk_write(dev
, data
, wlen
, 1);
688 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
689 ret
|= (data
[0] == 0x88) ? 0 : -1;
693 usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
694 0x06, 0x80, 0x0200, 0x00, data
, 0x0109, 1000);
700 ret
|= lme2510_bulk_write(dev
, data
, len_in
, 1); /*Resetting*/
701 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
705 info("FRM Firmware Download Failed (%04x)" , ret
);
707 info("FRM Firmware Download Completed - Resetting Device");
710 return (ret
< 0) ? -ENODEV
: 0;
713 static void lme_coldreset(struct usb_device
*dev
)
720 info("FRM Firmware Cold Reset");
721 ret
|= lme2510_bulk_write(dev
, data
, len_in
, 1); /*Cold Resetting*/
722 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
727 static int lme_firmware_switch(struct usb_device
*udev
, int cold
)
729 const struct firmware
*fw
= NULL
;
730 const char fw_c_s7395
[] = "dvb-usb-lme2510c-s7395.fw";
731 const char fw_c_lg
[] = "dvb-usb-lme2510c-lg.fw";
732 const char fw_c_s0194
[] = "dvb-usb-lme2510c-s0194.fw";
733 const char fw_lg
[] = "dvb-usb-lme2510-lg.fw";
734 const char fw_s0194
[] = "dvb-usb-lme2510-s0194.fw";
738 cold
= (cold
> 0) ? (cold
& 1) : 0;
742 if (udev
->descriptor
.idProduct
== 0x1122) {
743 switch (dvb_usb_lme2510_firmware
) {
745 dvb_usb_lme2510_firmware
= TUNER_S0194
;
748 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
750 cold
= 0;/*lme2510-s0194 cannot cold reset*/
753 dvb_usb_lme2510_firmware
= TUNER_LG
;
756 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
759 info("FRM No Firmware Found - please install");
760 dvb_usb_lme2510_firmware
= TUNER_DEFAULT
;
766 switch (dvb_usb_lme2510_firmware
) {
768 dvb_usb_lme2510_firmware
= TUNER_S7395
;
771 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
774 dvb_usb_lme2510_firmware
= TUNER_LG
;
777 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
780 dvb_usb_lme2510_firmware
= TUNER_S0194
;
783 ret
= request_firmware(&fw
, fw_lme
, &udev
->dev
);
786 info("FRM No Firmware Found - please install");
787 dvb_usb_lme2510_firmware
= TUNER_DEFAULT
;
795 info("FRM Loading %s file", fw_lme
);
796 ret
= lme2510_download_firmware(udev
, fw
);
800 info("FRM Changing to %s firmware", fw_lme
);
805 release_firmware(fw
);
810 static int lme2510_kill_urb(struct usb_data_stream
*stream
)
814 for (i
= 0; i
< stream
->urbs_submitted
; i
++) {
815 deb_info(3, "killing URB no. %d.", i
);
817 usb_kill_urb(stream
->urb_list
[i
]);
819 stream
->urbs_submitted
= 0;
824 static struct tda10086_config tda10086_config
= {
825 .demod_address
= 0x1c,
828 .xtal_freq
= TDA10086_XTAL_16M
,
831 static struct stv0288_config lme_config
= {
832 .demod_address
= 0xd0,
834 .inittab
= s7395_inittab
,
837 static struct ix2505v_config lme_tuner
= {
838 .tuner_address
= 0xc0,
841 .tuner_chargepump
= 0x3,
844 static struct stv0299_config sharp_z0194_config
= {
845 .demod_address
= 0xd0,
846 .inittab
= sharp_z0194a_inittab
,
850 .lock_output
= STV0299_LOCKOUTPUT_1
,
851 .volt13_op0_op1
= STV0299_VOLT13_OP1
,
853 .set_symbol_rate
= sharp_z0194a_set_symbol_rate
,
856 static int dm04_lme2510_set_voltage(struct dvb_frontend
*fe
,
857 fe_sec_voltage_t voltage
)
859 struct dvb_usb_adapter
*adap
= fe
->dvb
->priv
;
860 static u8 voltage_low
[] = LME_VOLTAGE_L
;
861 static u8 voltage_high
[] = LME_VOLTAGE_H
;
863 int ret
= 0, len
= 3, rlen
= 1;
865 if (mutex_lock_interruptible(&adap
->dev
->i2c_mutex
) < 0)
870 ret
|= lme2510_usb_talk(adap
->dev
,
871 voltage_high
, len
, rbuf
, rlen
);
874 case SEC_VOLTAGE_OFF
:
877 ret
|= lme2510_usb_talk(adap
->dev
,
878 voltage_low
, len
, rbuf
, rlen
);
882 mutex_unlock(&adap
->dev
->i2c_mutex
);
884 return (ret
< 0) ? -ENODEV
: 0;
887 static int lme_name(struct dvb_usb_adapter
*adap
)
889 struct lme2510_state
*st
= adap
->dev
->priv
;
890 const char *desc
= adap
->dev
->desc
->name
;
891 char *fe_name
[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395",
892 " SHARP:BS2F7HZ0194"};
893 char *name
= adap
->fe
->ops
.info
.name
;
895 strlcpy(name
, desc
, 128);
896 strlcat(name
, fe_name
[st
->tuner_config
], 128);
901 static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter
*adap
)
903 struct lme2510_state
*st
= adap
->dev
->priv
;
907 st
->i2c_talk_onoff
= 1;
910 adap
->fe
= dvb_attach(tda10086_attach
, &tda10086_config
,
911 &adap
->dev
->i2c_adap
);
914 info("TUN Found Frontend TDA10086");
915 st
->i2c_tuner_gate_w
= 4;
916 st
->i2c_tuner_gate_r
= 4;
917 st
->i2c_tuner_addr
= 0xc0;
918 st
->tuner_config
= TUNER_LG
;
919 if (dvb_usb_lme2510_firmware
!= TUNER_LG
) {
920 dvb_usb_lme2510_firmware
= TUNER_LG
;
921 ret
= lme_firmware_switch(adap
->dev
->udev
, 1);
927 adap
->fe
= dvb_attach(stv0299_attach
, &sharp_z0194_config
,
928 &adap
->dev
->i2c_adap
);
930 info("FE Found Stv0299");
931 st
->i2c_tuner_gate_w
= 4;
932 st
->i2c_tuner_gate_r
= 5;
933 st
->i2c_tuner_addr
= 0xc0;
934 st
->tuner_config
= TUNER_S0194
;
935 if (dvb_usb_lme2510_firmware
!= TUNER_S0194
) {
936 dvb_usb_lme2510_firmware
= TUNER_S0194
;
937 ret
= lme_firmware_switch(adap
->dev
->udev
, 1);
943 adap
->fe
= dvb_attach(stv0288_attach
, &lme_config
,
944 &adap
->dev
->i2c_adap
);
946 info("FE Found Stv0288");
947 st
->i2c_tuner_gate_w
= 4;
948 st
->i2c_tuner_gate_r
= 5;
949 st
->i2c_tuner_addr
= 0xc0;
950 st
->tuner_config
= TUNER_S7395
;
951 if (dvb_usb_lme2510_firmware
!= TUNER_S7395
) {
952 dvb_usb_lme2510_firmware
= TUNER_S7395
;
953 ret
= lme_firmware_switch(adap
->dev
->udev
, 1);
956 info("DM04 Not Supported");
967 adap
->fe
->ops
.set_voltage
= dm04_lme2510_set_voltage
;
968 ret
= lme_name(adap
);
972 static int dm04_lme2510_tuner(struct dvb_usb_adapter
*adap
)
974 struct lme2510_state
*st
= adap
->dev
->priv
;
975 char *tun_msg
[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA"};
978 switch (st
->tuner_config
) {
980 if (dvb_attach(tda826x_attach
, adap
->fe
, 0xc0,
981 &adap
->dev
->i2c_adap
, 1))
982 ret
= st
->tuner_config
;
985 if (dvb_attach(ix2505v_attach
, adap
->fe
, &lme_tuner
,
986 &adap
->dev
->i2c_adap
))
987 ret
= st
->tuner_config
;
990 if (dvb_attach(dvb_pll_attach
, adap
->fe
, 0xc0,
991 &adap
->dev
->i2c_adap
, DVB_PLL_OPERA1
))
992 ret
= st
->tuner_config
;
999 info("TUN Found %s tuner", tun_msg
[ret
]);
1001 info("TUN No tuner found --- reseting device");
1002 lme_coldreset(adap
->dev
->udev
);
1006 /* Start the Interupt & Remote*/
1007 ret
= lme2510_int_service(adap
);
1012 static int lme2510_powerup(struct dvb_usb_device
*d
, int onoff
)
1014 struct lme2510_state
*st
= d
->priv
;
1015 static u8 lnb_on
[] = LNB_ON
;
1016 static u8 lnb_off
[] = LNB_OFF
;
1018 int ret
, len
= 3, rlen
= 1;
1020 ret
= mutex_lock_interruptible(&d
->i2c_mutex
);
1023 ret
|= lme2510_usb_talk(d
, lnb_on
, len
, rbuf
, rlen
);
1025 ret
|= lme2510_usb_talk(d
, lnb_off
, len
, rbuf
, rlen
);
1027 st
->i2c_talk_onoff
= 1;
1029 mutex_unlock(&d
->i2c_mutex
);
1034 /* DVB USB Driver stuff */
1035 static struct dvb_usb_device_properties lme2510_properties
;
1036 static struct dvb_usb_device_properties lme2510c_properties
;
1038 static int lme2510_probe(struct usb_interface
*intf
,
1039 const struct usb_device_id
*id
)
1041 struct usb_device
*udev
= interface_to_usbdev(intf
);
1044 usb_reset_configuration(udev
);
1046 usb_set_interface(udev
, intf
->cur_altsetting
->desc
.bInterfaceNumber
, 1);
1048 if (udev
->speed
!= USB_SPEED_HIGH
) {
1049 ret
= usb_reset_device(udev
);
1050 info("DEV Failed to connect in HIGH SPEED mode");
1054 if (lme2510_return_status(udev
) == 0x44) {
1055 lme_firmware_switch(udev
, 0);
1059 if (0 == dvb_usb_device_init(intf
, &lme2510_properties
,
1060 THIS_MODULE
, NULL
, adapter_nr
)) {
1061 info("DEV registering device driver");
1064 if (0 == dvb_usb_device_init(intf
, &lme2510c_properties
,
1065 THIS_MODULE
, NULL
, adapter_nr
)) {
1066 info("DEV registering device driver");
1070 info("DEV lme2510 Error");
1075 static struct usb_device_id lme2510_table
[] = {
1076 { USB_DEVICE(0x3344, 0x1122) }, /* LME2510 */
1077 { USB_DEVICE(0x3344, 0x1120) }, /* LME2510C */
1078 {} /* Terminating entry */
1081 MODULE_DEVICE_TABLE(usb
, lme2510_table
);
1083 static struct dvb_usb_device_properties lme2510_properties
= {
1084 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1085 .size_of_priv
= sizeof(struct lme2510_state
),
1089 .streaming_ctrl
= lme2510_streaming_ctrl
,
1090 .frontend_attach
= dm04_lme2510_frontend_attach
,
1091 .tuner_attach
= dm04_lme2510_tuner
,
1092 /* parameter for the MPEG2-data transfer */
1106 .power_ctrl
= lme2510_powerup
,
1107 .identify_state
= lme2510_identify_state
,
1108 .i2c_algo
= &lme2510_i2c_algo
,
1109 .generic_bulk_ctrl_endpoint
= 0,
1110 .num_device_descs
= 1,
1112 { "DM04_LME2510_DVB-S",
1113 { &lme2510_table
[0], NULL
},
1119 static struct dvb_usb_device_properties lme2510c_properties
= {
1120 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1121 .size_of_priv
= sizeof(struct lme2510_state
),
1125 .streaming_ctrl
= lme2510_streaming_ctrl
,
1126 .frontend_attach
= dm04_lme2510_frontend_attach
,
1127 .tuner_attach
= dm04_lme2510_tuner
,
1128 /* parameter for the MPEG2-data transfer */
1142 .power_ctrl
= lme2510_powerup
,
1143 .identify_state
= lme2510_identify_state
,
1144 .i2c_algo
= &lme2510_i2c_algo
,
1145 .generic_bulk_ctrl_endpoint
= 0,
1146 .num_device_descs
= 1,
1148 { "DM04_LME2510C_DVB-S",
1149 { &lme2510_table
[1], NULL
},
1154 void *lme2510_exit_int(struct dvb_usb_device
*d
)
1156 struct lme2510_state
*st
= d
->priv
;
1157 struct dvb_usb_adapter
*adap
= &d
->adapter
[0];
1158 void *buffer
= NULL
;
1161 lme2510_kill_urb(&adap
->stream
);
1162 adap
->feedcount
= 0;
1165 if (st
->lme_urb
!= NULL
) {
1166 st
->i2c_talk_onoff
= 1;
1167 st
->signal_lock
= 0;
1168 st
->signal_level
= 0;
1170 buffer
= st
->usb_buffer
;
1171 usb_kill_urb(st
->lme_urb
);
1172 usb_free_coherent(d
->udev
, 5000, st
->buffer
,
1173 st
->lme_urb
->transfer_dma
);
1174 info("Interupt Service Stopped");
1175 rc_unregister_device(d
->rc_dev
);
1176 info("Remote Stopped");
1181 void lme2510_exit(struct usb_interface
*intf
)
1183 struct dvb_usb_device
*d
= usb_get_intfdata(intf
);
1187 usb_buffer
= lme2510_exit_int(d
);
1188 dvb_usb_device_exit(intf
);
1193 static struct usb_driver lme2510_driver
= {
1194 .name
= "LME2510C_DVB-S",
1195 .probe
= lme2510_probe
,
1196 .disconnect
= lme2510_exit
,
1197 .id_table
= lme2510_table
,
1201 static int __init
lme2510_module_init(void)
1203 int result
= usb_register(&lme2510_driver
);
1205 err("usb_register failed. Error number %d", result
);
1212 static void __exit
lme2510_module_exit(void)
1214 /* deregister this driver from the USB subsystem */
1215 usb_deregister(&lme2510_driver
);
1218 module_init(lme2510_module_init
);
1219 module_exit(lme2510_module_exit
);
1221 MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1222 MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0");
1223 MODULE_VERSION("1.80");
1224 MODULE_LICENSE("GPL");