1 /* DVB USB compliant linux driver for
3 * DM04/QQBOX DVB-S USB BOX LME2510C + SHARP:BS2F7HZ7395
4 * LME2510C + LG TDQY-P001F
5 * LME2510 + LG TDQY-P001F
7 * MVB7395 (LME2510C+SHARP:BS2F7HZ7395)
8 * SHARP:BS2F7HZ7395 = (STV0288+Sharp IX2505V)
10 * MV001F (LME2510+LGTDQY-P001F)
11 * LG TDQY - P001F =(TDA8263 + TDA10086H)
13 * MVB0001F (LME2510C+LGTDQT-P001F)
15 * For firmware see Documentation/dvb/lmedm04.txt
18 * 0xd0 - STV0288 - Demodulator
19 * 0xc0 - Sharp IX2505V - Tuner
21 * 0x1c - TDA10086 - Demodulator
22 * 0xc0 - TDA8263 - Tuner
25 * There are other variants of the DM04
27 * MV0194 (LME2510+SHARP0194)
28 * MVB0194 (LME2510C+SHARP0194)
31 * VID = 3344 PID LME2510=1122 LME2510C=1120
33 * Copyright (C) 2010 Malcolm Priestley (tvboxspy@gmail.com)
34 * LME2510(C)(C) Leaguerme (Shenzhen) MicroElectronics Co., Ltd.
36 * This program is free software; you can redistribute it and/or modify
37 * it under the terms of the GNU General Public License Version 2, as
38 * published by the Free Software Foundation.
40 * This program is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 * GNU General Public License for more details.
45 * You should have received a copy of the GNU General Public License
46 * along with this program; if not, write to the Free Software
47 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
50 * see Documentation/dvb/README.dvb-usb for more information
53 * LME2510: Non Intel USB chipsets fail to maintain High Speed on
56 * QQbox suffers from noise on LNB voltage.
58 * PID functions have been removed from this driver version due to
59 * problems with different firmware and application versions.
61 #define DVB_USB_LOG_PREFIX "LME2510(C)"
62 #include <linux/usb.h>
63 #include <linux/usb/input.h>
64 #include <media/rc-core.h>
76 static int dvb_usb_lme2510_debug
;
77 #define l_dprintk(var, level, args...) do { \
79 printk(KERN_DEBUG DVB_USB_LOG_PREFIX ": " args); \
82 #define deb_info(level, args...) l_dprintk(dvb_usb_lme2510_debug, level, args)
83 #define debug_data_snipet(level, name, p) \
84 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
85 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
86 *(p+5), *(p+6), *(p+7));
89 module_param_named(debug
, dvb_usb_lme2510_debug
, int, 0644);
90 MODULE_PARM_DESC(debug
, "set debugging level (1=info (or-able))."
91 DVB_USB_DEBUG_STATUS
);
93 static int dvb_usb_lme2510_firmware
;
94 module_param_named(firmware
, dvb_usb_lme2510_firmware
, int, 0644);
95 MODULE_PARM_DESC(firmware
, "set default firmware 0=Sharp7395 1=LG");
98 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
100 #define TUNER_S7395 0x2
102 struct lme2510_state
{
121 static int lme2510_bulk_write(struct usb_device
*dev
,
122 u8
*snd
, int len
, u8 pipe
)
126 ret
= usb_bulk_msg(dev
, usb_sndbulkpipe(dev
, pipe
),
127 snd
, len
, &actual_l
, 100);
131 static int lme2510_bulk_read(struct usb_device
*dev
,
132 u8
*rev
, int len
, u8 pipe
)
136 ret
= usb_bulk_msg(dev
, usb_rcvbulkpipe(dev
, pipe
),
137 rev
, len
, &actual_l
, 200);
141 static int lme2510_usb_talk(struct dvb_usb_device
*d
,
142 u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
144 struct lme2510_state
*st
= d
->priv
;
148 if (st
->usb_buffer
== NULL
) {
149 st
->usb_buffer
= kmalloc(512, GFP_KERNEL
);
150 if (st
->usb_buffer
== NULL
) {
151 info("MEM Error no memory");
155 buff
= st
->usb_buffer
;
157 /* the read/write capped at 512 */
158 memcpy(buff
, wbuf
, (wlen
> 512) ? 512 : wlen
);
160 ret
= mutex_lock_interruptible(&d
->usb_mutex
);
165 ret
|= usb_clear_halt(d
->udev
, usb_sndbulkpipe(d
->udev
, 0x01));
167 ret
|= lme2510_bulk_write(d
->udev
, buff
, wlen
, 0x01);
171 ret
|= usb_clear_halt(d
->udev
, usb_rcvbulkpipe(d
->udev
, 0x01));
173 ret
|= lme2510_bulk_read(d
->udev
, buff
, (rlen
> 512) ?
177 memcpy(rbuf
, buff
, rlen
);
179 mutex_unlock(&d
->usb_mutex
);
181 return (ret
< 0) ? -ENODEV
: 0;
184 static int lme2510_stream_restart(struct dvb_usb_device
*d
)
186 static u8 stream_on
[] = LME_ST_ON_W
;
189 /*Restart Stream Command*/
190 ret
= lme2510_usb_talk(d
, stream_on
, sizeof(stream_on
),
191 rbuff
, sizeof(rbuff
));
194 static int lme2510_remote_keypress(struct dvb_usb_adapter
*adap
, u16 keypress
)
196 struct dvb_usb_device
*d
= adap
->dev
;
198 deb_info(1, "INT Key Keypress =%04x", keypress
);
201 rc_keydown(d
->rc_dev
, keypress
, 0);
206 static void lme2510_int_response(struct urb
*lme_urb
)
208 struct dvb_usb_adapter
*adap
= lme_urb
->context
;
209 struct lme2510_state
*st
= adap
->dev
->priv
;
210 static u8
*ibuf
, *rbuf
;
213 switch (lme_urb
->status
) {
222 info("Error %x", lme_urb
->status
);
226 rbuf
= (u8
*) lme_urb
->transfer_buffer
;
228 offset
= ((lme_urb
->actual_length
/8) > 4)
229 ? 4 : (lme_urb
->actual_length
/8) ;
231 for (i
= 0; i
< offset
; ++i
) {
232 ibuf
= (u8
*)&rbuf
[i
*8];
233 deb_info(5, "INT O/S C =%02x C/O=%02x Type =%02x%02x",
234 offset
, i
, ibuf
[0], ibuf
[1]);
238 debug_data_snipet(1, "INT Remote data snipet in", ibuf
);
239 lme2510_remote_keypress(adap
,
240 (u16
)(ibuf
[4]<<8)+ibuf
[5]);
243 switch (st
->tuner_config
) {
246 st
->signal_lock
= ibuf
[2];
247 st
->signal_level
= ibuf
[4];
248 st
->signal_sn
= ibuf
[3];
249 st
->time_key
= ibuf
[7];
252 /* Tweak for earlier firmware*/
253 if (ibuf
[1] == 0x03) {
255 st
->signal_lock
= ibuf
[2];
256 st
->signal_level
= ibuf
[3];
257 st
->signal_sn
= ibuf
[4];
259 st
->signal_level
= ibuf
[4];
260 st
->signal_sn
= ibuf
[5];
262 (st
->signal_lock
& 0xf7) +
263 ((ibuf
[2] & 0x01) << 0x03);
269 debug_data_snipet(5, "INT Remote data snipet in", ibuf
);
272 debug_data_snipet(1, "INT Control data snipet", ibuf
);
275 debug_data_snipet(1, "INT Unknown data snipet", ibuf
);
279 usb_submit_urb(lme_urb
, GFP_ATOMIC
);
282 static int lme2510_int_read(struct dvb_usb_adapter
*adap
)
284 struct lme2510_state
*lme_int
= adap
->dev
->priv
;
286 lme_int
->lme_urb
= usb_alloc_urb(0, GFP_ATOMIC
);
288 if (lme_int
->lme_urb
== NULL
)
291 lme_int
->buffer
= usb_alloc_coherent(adap
->dev
->udev
, 5000, GFP_ATOMIC
,
292 &lme_int
->lme_urb
->transfer_dma
);
294 if (lme_int
->buffer
== NULL
)
297 usb_fill_int_urb(lme_int
->lme_urb
,
299 usb_rcvintpipe(adap
->dev
->udev
, 0xa),
302 lme2510_int_response
,
306 lme_int
->lme_urb
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
308 usb_submit_urb(lme_int
->lme_urb
, GFP_ATOMIC
);
309 info("INT Interupt Service Started");
314 static int lme2510_return_status(struct usb_device
*dev
)
319 ret
|= usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
320 0x06, 0x80, 0x0302, 0x00, data
, 0x0006, 200);
321 info("Firmware Status: %x (%x)", ret
, data
[2]);
323 return (ret
< 0) ? -ENODEV
: data
[2];
326 static int lme2510_msg(struct dvb_usb_device
*d
,
327 u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
)
330 struct lme2510_state
*st
= d
->priv
;
332 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
335 if (st
->i2c_talk_onoff
== 1) {
337 ret
= lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
339 switch (st
->tuner_config
) {
341 if (wbuf
[2] == 0x1c) {
342 if (wbuf
[3] == 0x0e) {
343 st
->signal_lock
= rbuf
[1];
344 if ((st
->stream_on
& 1) &&
345 (st
->signal_lock
& 0x10)) {
346 lme2510_stream_restart(d
);
347 st
->i2c_talk_onoff
= 0;
354 if (wbuf
[2] == 0xd0) {
355 if (wbuf
[3] == 0x24) {
356 st
->signal_lock
= rbuf
[1];
357 if ((st
->stream_on
& 1) &&
358 (st
->signal_lock
& 0x8)) {
359 lme2510_stream_restart(d
);
360 st
->i2c_talk_onoff
= 0;
363 if ((wbuf
[3] != 0x6) & (wbuf
[3] != 0x5))
371 switch (st
->tuner_config
) {
376 rbuf
[1] = st
->signal_lock
;
380 rbuf
[1] = st
->signal_level
;
384 rbuf
[1] = st
->signal_sn
;
394 lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
395 st
->i2c_talk_onoff
= 1;
403 rbuf
[1] = (st
->signal_level
& 0x80)
404 ? 0 : (st
->signal_level
* 2);
408 rbuf
[1] = st
->signal_sn
;
412 rbuf
[1] = st
->signal_lock
;
421 lme2510_usb_talk(d
, wbuf
, wlen
, rbuf
, rlen
);
422 st
->i2c_talk_onoff
= 1;
430 deb_info(4, "I2C From Interupt Message out(%02x) in(%02x)",
435 mutex_unlock(&d
->i2c_mutex
);
441 static int lme2510_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg msg
[],
444 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
445 struct lme2510_state
*st
= d
->priv
;
446 static u8 obuf
[64], ibuf
[512];
449 u8 gate
= st
->i2c_gate
;
455 warn("more than 2 i2c messages"
456 "at a time is not handled yet. TODO.");
458 for (i
= 0; i
< num
; i
++) {
459 read_o
= 1 & (msg
[i
].flags
& I2C_M_RD
);
460 read
= i
+1 < num
&& (msg
[i
+1].flags
& I2C_M_RD
);
462 gate
= (msg
[i
].addr
== st
->i2c_tuner_addr
)
463 ? (read
) ? st
->i2c_tuner_gate_r
464 : st
->i2c_tuner_gate_w
466 obuf
[0] = gate
| (read
<< 7);
469 obuf
[1] = (read
) ? 2 : msg
[i
].len
+ 1;
471 obuf
[1] = msg
[i
].len
+ read
+ 1;
473 obuf
[2] = msg
[i
].addr
;
478 memcpy(&obuf
[3], msg
[i
].buf
, msg
[i
].len
);
479 obuf
[msg
[i
].len
+3] = msg
[i
+1].len
;
483 memcpy(&obuf
[3], msg
[i
].buf
, msg
[i
].len
);
487 if (lme2510_msg(d
, obuf
, len
, ibuf
, 512) < 0) {
488 deb_info(1, "i2c transfer failed.");
494 memcpy(msg
[i
].buf
, &ibuf
[1], msg
[i
].len
);
496 memcpy(msg
[i
+1].buf
, &ibuf
[1], msg
[i
+1].len
);
504 static u32
lme2510_i2c_func(struct i2c_adapter
*adapter
)
509 static struct i2c_algorithm lme2510_i2c_algo
= {
510 .master_xfer
= lme2510_i2c_xfer
,
511 .functionality
= lme2510_i2c_func
,
514 /* Callbacks for DVB USB */
515 static int lme2510_identify_state(struct usb_device
*udev
,
516 struct dvb_usb_device_properties
*props
,
517 struct dvb_usb_device_description
**desc
,
520 if (lme2510_return_status(udev
) == 0x44)
527 static int lme2510_streaming_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
529 struct lme2510_state
*st
= adap
->dev
->priv
;
530 static u8 clear_reg_3
[] = LME_CLEAR_PID
;
532 int ret
= 0, rlen
= sizeof(rbuf
);
534 deb_info(1, "STM (%02x)", onoff
);
536 /* Streaming is started by FE_HAS_LOCK */
540 deb_info(1, "STM Steam Off");
541 /* mutex is here only to avoid collision with I2C */
542 ret
= mutex_lock_interruptible(&adap
->dev
->i2c_mutex
);
544 ret
|= lme2510_usb_talk(adap
->dev
, clear_reg_3
,
545 sizeof(clear_reg_3
), rbuf
, rlen
);
547 st
->i2c_talk_onoff
= 1;
549 mutex_unlock(&adap
->dev
->i2c_mutex
);
552 return (ret
< 0) ? -ENODEV
: 0;
555 static int lme2510_int_service(struct dvb_usb_adapter
*adap
)
557 struct dvb_usb_device
*d
= adap
->dev
;
561 info("STA Configuring Remote");
563 rc
= rc_allocate_device();
567 usb_make_path(d
->udev
, d
->rc_phys
, sizeof(d
->rc_phys
));
568 strlcat(d
->rc_phys
, "/ir0", sizeof(d
->rc_phys
));
570 rc
->input_name
= "LME2510 Remote Control";
571 rc
->input_phys
= d
->rc_phys
;
572 rc
->map_name
= RC_MAP_LME2510
;
573 rc
->driver_name
= "LME 2510";
574 usb_to_input_id(d
->udev
, &rc
->input_id
);
576 ret
= rc_register_device(rc
);
583 /* Start the Interupt */
584 ret
= lme2510_int_read(adap
);
586 rc_unregister_device(rc
);
587 info("INT Unable to start Interupt Service");
594 static u8
check_sum(u8
*p
, u8 len
)
602 static int lme2510_download_firmware(struct usb_device
*dev
,
603 const struct firmware
*fw
)
607 u16 j
, wlen
, len_in
, start
, end
;
608 u8 packet_size
, dlen
, i
;
615 info("FRM Starting Firmware Download");
617 for (i
= 1; i
< 3; i
++) {
618 start
= (i
== 1) ? 0 : 512;
619 end
= (i
== 1) ? 512 : fw
->size
;
620 for (j
= start
; j
< end
; j
+= (packet_size
+1)) {
621 fw_data
= (u8
*)(fw
->data
+ j
);
622 if ((end
- j
) > packet_size
) {
627 dlen
= (u8
)(end
- j
)-1;
630 memcpy(&data
[2], fw_data
, dlen
+1);
631 wlen
= (u8
) dlen
+ 4;
632 data
[wlen
-1] = check_sum(fw_data
, dlen
+1);
633 deb_info(1, "Data S=%02x:E=%02x CS= %02x", data
[3],
634 data
[dlen
+2], data
[dlen
+3]);
635 ret
|= lme2510_bulk_write(dev
, data
, wlen
, 1);
636 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
637 ret
|= (data
[0] == 0x88) ? 0 : -1;
641 usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
642 0x06, 0x80, 0x0200, 0x00, data
, 0x0109, 1000);
648 ret
|= lme2510_bulk_write(dev
, data
, len_in
, 1); /*Resetting*/
649 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
653 info("FRM Firmware Download Failed (%04x)" , ret
);
655 info("FRM Firmware Download Completed - Resetting Device");
658 return (ret
< 0) ? -ENODEV
: 0;
661 /* Default firmware for LME2510C */
662 const char lme_firmware
[50] = "dvb-usb-lme2510c-s7395.fw";
664 static void lme_coldreset(struct usb_device
*dev
)
671 info("FRM Firmware Cold Reset");
672 ret
|= lme2510_bulk_write(dev
, data
, len_in
, 1); /*Cold Resetting*/
673 ret
|= lme2510_bulk_read(dev
, data
, len_in
, 1);
678 static int lme_firmware_switch(struct usb_device
*udev
, int cold
)
680 const struct firmware
*fw
= NULL
;
681 char lme2510c_s7395
[] = "dvb-usb-lme2510c-s7395.fw";
682 char lme2510c_lg
[] = "dvb-usb-lme2510c-lg.fw";
683 char *firm_msg
[] = {"Loading", "Switching to"};
686 cold
= (cold
> 0) ? (cold
& 1) : 0;
688 if (udev
->descriptor
.idProduct
== 0x1122)
691 switch (dvb_usb_lme2510_firmware
) {
694 memcpy(&lme_firmware
, lme2510c_s7395
, sizeof(lme2510c_s7395
));
695 ret
= request_firmware(&fw
, lme_firmware
, &udev
->dev
);
697 info("FRM %s S7395 Firmware", firm_msg
[cold
]);
701 dvb_usb_lme2510_firmware
= 1;
705 memcpy(&lme_firmware
, lme2510c_lg
, sizeof(lme2510c_lg
));
706 ret
= request_firmware(&fw
, lme_firmware
, &udev
->dev
);
708 info("FRM %s LG Firmware", firm_msg
[cold
]);
711 info("FRM No Firmware Found - please install");
712 dvb_usb_lme2510_firmware
= 0;
717 release_firmware(fw
);
727 static int lme2510_kill_urb(struct usb_data_stream
*stream
)
731 for (i
= 0; i
< stream
->urbs_submitted
; i
++) {
732 deb_info(3, "killing URB no. %d.", i
);
734 usb_kill_urb(stream
->urb_list
[i
]);
736 stream
->urbs_submitted
= 0;
741 static struct tda10086_config tda10086_config
= {
742 .demod_address
= 0x1c,
745 .xtal_freq
= TDA10086_XTAL_16M
,
748 static struct stv0288_config lme_config
= {
749 .demod_address
= 0xd0,
751 .inittab
= s7395_inittab
,
754 static struct ix2505v_config lme_tuner
= {
755 .tuner_address
= 0xc0,
758 .tuner_chargepump
= 0x3,
761 static int dm04_lme2510_set_voltage(struct dvb_frontend
*fe
,
762 fe_sec_voltage_t voltage
)
764 struct dvb_usb_adapter
*adap
= fe
->dvb
->priv
;
765 static u8 voltage_low
[] = LME_VOLTAGE_L
;
766 static u8 voltage_high
[] = LME_VOLTAGE_H
;
768 int ret
= 0, len
= 3, rlen
= 1;
770 if (mutex_lock_interruptible(&adap
->dev
->i2c_mutex
) < 0)
775 ret
|= lme2510_usb_talk(adap
->dev
,
776 voltage_high
, len
, rbuf
, rlen
);
779 case SEC_VOLTAGE_OFF
:
782 ret
|= lme2510_usb_talk(adap
->dev
,
783 voltage_low
, len
, rbuf
, rlen
);
787 mutex_unlock(&adap
->dev
->i2c_mutex
);
789 return (ret
< 0) ? -ENODEV
: 0;
792 static int lme_name(struct dvb_usb_adapter
*adap
)
794 struct lme2510_state
*st
= adap
->dev
->priv
;
795 const char *desc
= adap
->dev
->desc
->name
;
796 char *fe_name
[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395"};
797 char *name
= adap
->fe
->ops
.info
.name
;
799 strlcpy(name
, desc
, 128);
800 strlcat(name
, fe_name
[st
->tuner_config
], 128);
805 static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter
*adap
)
807 struct lme2510_state
*st
= adap
->dev
->priv
;
811 st
->i2c_talk_onoff
= 1;
814 adap
->fe
= dvb_attach(tda10086_attach
, &tda10086_config
,
815 &adap
->dev
->i2c_adap
);
818 info("TUN Found Frontend TDA10086");
819 st
->i2c_tuner_gate_w
= 4;
820 st
->i2c_tuner_gate_r
= 4;
821 st
->i2c_tuner_addr
= 0xc0;
822 st
->tuner_config
= TUNER_LG
;
823 if (dvb_usb_lme2510_firmware
!= 1) {
824 dvb_usb_lme2510_firmware
= 1;
825 ret
= lme_firmware_switch(adap
->dev
->udev
, 1);
826 } else /*stops LG/Sharp multi tuner problems*/
827 dvb_usb_lme2510_firmware
= 0;
832 adap
->fe
= dvb_attach(stv0288_attach
, &lme_config
,
833 &adap
->dev
->i2c_adap
);
836 info("FE Found Stv0288");
837 st
->i2c_tuner_gate_w
= 4;
838 st
->i2c_tuner_gate_r
= 5;
839 st
->i2c_tuner_addr
= 0xc0;
840 st
->tuner_config
= TUNER_S7395
;
841 if (dvb_usb_lme2510_firmware
!= 0) {
842 dvb_usb_lme2510_firmware
= 0;
843 ret
= lme_firmware_switch(adap
->dev
->udev
, 1);
846 info("DM04 Not Supported");
856 adap
->fe
->ops
.set_voltage
= dm04_lme2510_set_voltage
;
857 ret
= lme_name(adap
);
862 static int dm04_lme2510_tuner(struct dvb_usb_adapter
*adap
)
864 struct lme2510_state
*st
= adap
->dev
->priv
;
865 char *tun_msg
[] = {"", "TDA8263", "IX2505V"};
868 switch (st
->tuner_config
) {
870 if (dvb_attach(tda826x_attach
, adap
->fe
, 0xc0,
871 &adap
->dev
->i2c_adap
, 1))
872 ret
= st
->tuner_config
;
875 if (dvb_attach(ix2505v_attach
, adap
->fe
, &lme_tuner
,
876 &adap
->dev
->i2c_adap
))
877 ret
= st
->tuner_config
;
884 info("TUN Found %s tuner", tun_msg
[ret
]);
886 info("TUN No tuner found --- reseting device");
887 lme_coldreset(adap
->dev
->udev
);
891 /* Start the Interupt & Remote*/
892 ret
= lme2510_int_service(adap
);
897 static int lme2510_powerup(struct dvb_usb_device
*d
, int onoff
)
899 struct lme2510_state
*st
= d
->priv
;
900 static u8 lnb_on
[] = LNB_ON
;
901 static u8 lnb_off
[] = LNB_OFF
;
903 int ret
, len
= 3, rlen
= 1;
905 ret
= mutex_lock_interruptible(&d
->i2c_mutex
);
908 ret
|= lme2510_usb_talk(d
, lnb_on
, len
, rbuf
, rlen
);
910 ret
|= lme2510_usb_talk(d
, lnb_off
, len
, rbuf
, rlen
);
912 st
->i2c_talk_onoff
= 1;
914 mutex_unlock(&d
->i2c_mutex
);
919 /* DVB USB Driver stuff */
920 static struct dvb_usb_device_properties lme2510_properties
;
921 static struct dvb_usb_device_properties lme2510c_properties
;
923 static int lme2510_probe(struct usb_interface
*intf
,
924 const struct usb_device_id
*id
)
926 struct usb_device
*udev
= interface_to_usbdev(intf
);
929 usb_reset_configuration(udev
);
931 usb_set_interface(udev
, intf
->cur_altsetting
->desc
.bInterfaceNumber
, 1);
933 if (udev
->speed
!= USB_SPEED_HIGH
) {
934 ret
= usb_reset_device(udev
);
935 info("DEV Failed to connect in HIGH SPEED mode");
939 lme_firmware_switch(udev
, 0);
941 if (0 == dvb_usb_device_init(intf
, &lme2510_properties
,
942 THIS_MODULE
, NULL
, adapter_nr
)) {
943 info("DEV registering device driver");
946 if (0 == dvb_usb_device_init(intf
, &lme2510c_properties
,
947 THIS_MODULE
, NULL
, adapter_nr
)) {
948 info("DEV registering device driver");
952 info("DEV lme2510 Error");
957 static struct usb_device_id lme2510_table
[] = {
958 { USB_DEVICE(0x3344, 0x1122) }, /* LME2510 */
959 { USB_DEVICE(0x3344, 0x1120) }, /* LME2510C */
960 {} /* Terminating entry */
963 MODULE_DEVICE_TABLE(usb
, lme2510_table
);
965 static struct dvb_usb_device_properties lme2510_properties
= {
966 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
967 .usb_ctrl
= DEVICE_SPECIFIC
,
968 .download_firmware
= lme2510_download_firmware
,
969 .firmware
= "dvb-usb-lme2510-lg.fw",
971 .size_of_priv
= sizeof(struct lme2510_state
),
975 .streaming_ctrl
= lme2510_streaming_ctrl
,
976 .frontend_attach
= dm04_lme2510_frontend_attach
,
977 .tuner_attach
= dm04_lme2510_tuner
,
978 /* parameter for the MPEG2-data transfer */
992 .power_ctrl
= lme2510_powerup
,
993 .identify_state
= lme2510_identify_state
,
994 .i2c_algo
= &lme2510_i2c_algo
,
995 .generic_bulk_ctrl_endpoint
= 0,
996 .num_device_descs
= 1,
998 { "DM04_LME2510_DVB-S",
999 { &lme2510_table
[0], NULL
},
1005 static struct dvb_usb_device_properties lme2510c_properties
= {
1006 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
1007 .usb_ctrl
= DEVICE_SPECIFIC
,
1008 .download_firmware
= lme2510_download_firmware
,
1009 .firmware
= lme_firmware
,
1010 .size_of_priv
= sizeof(struct lme2510_state
),
1014 .streaming_ctrl
= lme2510_streaming_ctrl
,
1015 .frontend_attach
= dm04_lme2510_frontend_attach
,
1016 .tuner_attach
= dm04_lme2510_tuner
,
1017 /* parameter for the MPEG2-data transfer */
1031 .power_ctrl
= lme2510_powerup
,
1032 .identify_state
= lme2510_identify_state
,
1033 .i2c_algo
= &lme2510_i2c_algo
,
1034 .generic_bulk_ctrl_endpoint
= 0,
1035 .num_device_descs
= 1,
1037 { "DM04_LME2510C_DVB-S",
1038 { &lme2510_table
[1], NULL
},
1043 void *lme2510_exit_int(struct dvb_usb_device
*d
)
1045 struct lme2510_state
*st
= d
->priv
;
1046 struct dvb_usb_adapter
*adap
= &d
->adapter
[0];
1047 void *buffer
= NULL
;
1050 lme2510_kill_urb(&adap
->stream
);
1051 adap
->feedcount
= 0;
1054 if (st
->lme_urb
!= NULL
) {
1055 st
->i2c_talk_onoff
= 1;
1056 st
->signal_lock
= 0;
1057 st
->signal_level
= 0;
1059 buffer
= st
->usb_buffer
;
1060 usb_kill_urb(st
->lme_urb
);
1061 usb_free_coherent(d
->udev
, 5000, st
->buffer
,
1062 st
->lme_urb
->transfer_dma
);
1063 info("Interupt Service Stopped");
1064 rc_unregister_device(d
->rc_dev
);
1065 info("Remote Stopped");
1070 void lme2510_exit(struct usb_interface
*intf
)
1072 struct dvb_usb_device
*d
= usb_get_intfdata(intf
);
1076 usb_buffer
= lme2510_exit_int(d
);
1077 dvb_usb_device_exit(intf
);
1082 static struct usb_driver lme2510_driver
= {
1083 .name
= "LME2510C_DVB-S",
1084 .probe
= lme2510_probe
,
1085 .disconnect
= lme2510_exit
,
1086 .id_table
= lme2510_table
,
1090 static int __init
lme2510_module_init(void)
1092 int result
= usb_register(&lme2510_driver
);
1094 err("usb_register failed. Error number %d", result
);
1101 static void __exit
lme2510_module_exit(void)
1103 /* deregister this driver from the USB subsystem */
1104 usb_deregister(&lme2510_driver
);
1107 module_init(lme2510_module_init
);
1108 module_exit(lme2510_module_exit
);
1110 MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1111 MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0");
1112 MODULE_VERSION("1.74");
1113 MODULE_LICENSE("GPL");