69 #define DVB_USB_LOG_PREFIX "LME2510(C)"
86 #define LME2510_C_S7395 "dvb-usb-lme2510c-s7395.fw";
87 #define LME2510_C_LG "dvb-usb-lme2510c-lg.fw";
88 #define LME2510_C_S0194 "dvb-usb-lme2510c-s0194.fw";
89 #define LME2510_C_RS2000 "dvb-usb-lme2510c-rs2000.fw";
90 #define LME2510_LG "dvb-usb-lme2510-lg.fw";
91 #define LME2510_S0194 "dvb-usb-lme2510-s0194.fw";
94 static int dvb_usb_lme2510_debug;
95 #define lme_debug(var, level, args...) do { \
97 pr_debug(DVB_USB_LOG_PREFIX": " args); \
99 #define deb_info(level, args...) lme_debug(dvb_usb_lme2510_debug, level, args)
100 #define debug_data_snipet(level, name, p) \
101 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
102 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
103 *(p+5), *(p+6), *(p+7));
104 #define info(args...) pr_info(DVB_USB_LOG_PREFIX": "args)
109 static int dvb_usb_lme2510_firmware;
113 static int pid_filter;
120 #define TUNER_DEFAULT 0x0
122 #define TUNER_S7395 0x2
123 #define TUNER_S0194 0x3
124 #define TUNER_RS2000 0x4
150 static int lme2510_bulk_write(
struct usb_device *
dev,
156 snd, len , &actual_l, 100);
160 static int lme2510_bulk_read(
struct usb_device *
dev,
166 rev, len , &actual_l, 200);
171 u8 *wbuf,
int wlen,
u8 *rbuf,
int rlen)
180 info(
"MEM Error no memory");
192 memcpy(buff, wbuf, (wlen < 64) ? wlen : 64);
194 ret |= lme2510_bulk_write(d->
udev, buff, wlen , 0x01);
196 ret |= lme2510_bulk_read(d->
udev, buff, (rlen < 64) ?
204 return (ret < 0) ? -
ENODEV : 0;
215 ret = lme2510_usb_talk(d, all_pids,
sizeof(all_pids),
216 rbuff,
sizeof(rbuff));
218 ret = lme2510_usb_talk(d, stream_on,
sizeof(stream_on),
219 rbuff,
sizeof(rbuff));
228 u8 pid_no = index * 2;
229 u8 pid_len = pid_no + 2;
231 deb_info(1,
"PID Setting Pid %04x", pid_out);
234 ret |= lme2510_stream_restart(d);
236 pid_buff[2] = pid_no;
237 pid_buff[3] = (
u8)pid_out & 0xff;
238 pid_buff[4] = pid_no + 1;
239 pid_buff[5] = (
u8)(pid_out >> 8);
245 ret |= lme2510_usb_talk(d, pid_buff ,
246 sizeof(pid_buff) , rbuf,
sizeof(rbuf));
249 ret |= lme2510_stream_restart(d);
254 static void lme2510_int_response(
struct urb *
lme_urb)
258 static u8 *ibuf, *rbuf;
262 switch (lme_urb->status) {
271 info(
"Error %x", lme_urb->status);
275 rbuf = (
u8 *) lme_urb->transfer_buffer;
277 offset = ((lme_urb->actual_length/8) > 4)
278 ? 4 : (lme_urb->actual_length/8) ;
281 ibuf = (
u8 *)&rbuf[i*8];
282 deb_info(5,
"INT O/S C =%02x C/O=%02x Type =%02x%02x",
283 offset, i, ibuf[0], ibuf[1]);
288 if ((ibuf[4] + ibuf[5]) == 0xff) {
291 ? (ibuf[3] ^ 0xff) << 8 : 0;
292 key += (ibuf[2] ^ 0xff) << 16;
311 if (ibuf[1] == 0x03) {
321 ((ibuf[2] & 0x01) << 0x03);
325 if (ibuf[1] == 0x3 && ibuf[6] == 0xff)
359 &lme_int->
lme_urb->transfer_dma);
364 usb_fill_int_urb(lme_int->
lme_urb,
366 usb_rcvintpipe(d->
udev, 0xa),
369 lme2510_int_response,
373 lme_int->
lme_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
376 info(
"INT Interrupt Service Started");
394 ret |= lme2510_usb_talk(d, clear_pid_reg,
395 sizeof(clear_pid_reg), rbuf,
sizeof(rbuf));
413 deb_info(3,
"%s PID=%04x Index=%04x onoff=%02x", __func__,
418 ret |= lme2510_enable_pid(d, index, pid);
437 0x06, 0x80, 0x0302, 0x00, data, 0x0006, 200);
438 info(
"Firmware Status: %x (%x)", ret , data[2]);
440 ret = (ret < 0) ? -
ENODEV : data[2];
446 u8 *wbuf,
int wlen,
u8 *rbuf,
int rlen)
453 ret = lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
457 if (wbuf[2] == 0x1c) {
458 if (wbuf[3] == 0x0e) {
462 lme2510_stream_restart(d);
470 if (wbuf[2] == 0xd0) {
471 if (wbuf[3] == 0x24) {
475 lme2510_stream_restart(d);
482 if (wbuf[2] == 0xd0) {
483 if (wbuf[3] == 0x1b) {
487 lme2510_stream_restart(d);
522 lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
549 lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
577 lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
596 lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
604 deb_info(4,
"I2C From Interrupt Message out(%02x) in(%02x)",
618 static u8 obuf[64], ibuf[64];
628 for (i = 0; i < num; i++) {
636 obuf[0] = gate | (read << 7);
639 obuf[1] = (
read) ? 2 : msg[i].len + 1;
641 obuf[1] = msg[
i].
len + read + 1;
643 obuf[2] = msg[
i].
addr;
648 memcpy(&obuf[3], msg[i].
buf, msg[i].len);
649 obuf[msg[
i].
len+3] = msg[i+1].len;
653 memcpy(&obuf[3], msg[i].
buf, msg[i].len);
657 if (lme2510_msg(d, obuf, len, ibuf, 64) < 0) {
658 deb_info(1,
"i2c transfer failed.");
665 memcpy(msg[i].
buf, &ibuf[1], msg[i].len);
667 memcpy(msg[i+1].
buf, &ibuf[1], msg[i+1].len);
683 .master_xfer = lme2510_i2c_xfer,
684 .functionality = lme2510_i2c_func,
687 static int lme2510_streaming_ctrl(
struct dvb_frontend *fe,
int onoff)
694 int ret = 0, rlen =
sizeof(rbuf);
706 ret = lme2510_usb_talk(d, clear_reg_3,
707 sizeof(clear_reg_3), rbuf, rlen);
714 return (ret < 0) ? -
ENODEV : 0;
717 static u8 check_sum(
u8 *
p,
u8 len)
739 info(
"FRM Could not start Firmware Download"\
740 "(Buffer allocation failed)");
744 info(
"FRM Starting Firmware Download");
746 for (i = 1; i < 3; i++) {
747 start = (i == 1) ? 0 : 512;
748 end = (i == 1) ? 512 : fw->
size;
749 for (j = start; j <
end; j += (packet_size+1)) {
750 fw_data = (
u8 *)(fw->
data + j);
751 if ((end - j) > packet_size) {
756 dlen = (
u8)(end - j)-1;
759 memcpy(&data[2], fw_data, dlen+1);
760 wlen = (
u8) dlen + 4;
761 data[wlen-1] = check_sum(fw_data, dlen+1);
762 deb_info(1,
"Data S=%02x:E=%02x CS= %02x", data[3],
763 data[dlen+2], data[dlen+3]);
764 lme2510_usb_talk(d, data, wlen, data, len_in);
765 ret |= (data[0] == 0x88) ? 0 : -1;
772 lme2510_usb_talk(d, data, len_in, data, len_in);
776 info(
"FRM Firmware Download Failed (%04x)" , ret);
778 info(
"FRM Firmware Download Completed - Resetting Device");
788 info(
"FRM Firmware Cold Reset");
790 lme2510_usb_talk(d, data,
sizeof(data), data,
sizeof(data));
810 cold = (cold > 0) ? (cold & 1) : 0;
863 fw_lme = fw_c_rs2000;
874 info(
"FRM Changing to %s firmware", fw_lme);
887 deb_info(3,
"killing URB no. %d.", i);
904 .demod_address = 0xd0,
906 .inittab = s7395_inittab,
910 .tuner_address = 0xc0,
913 .tuner_chargepump = 0x3,
917 .demod_address = 0xd0,
918 .inittab = sharp_z0194a_inittab,
925 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
928 static int dm04_rs2000_set_ts_param(
struct dvb_frontend *fe,
938 lme2510_stream_restart(d);
948 .set_ts_params = dm04_rs2000_set_ts_param,
951 static int dm04_lme2510_set_voltage(
struct dvb_frontend *fe,
959 int ret = 0, len = 3, rlen = 1;
965 ret |= lme2510_usb_talk(d,
966 voltage_high, len, rbuf, rlen);
972 ret |= lme2510_usb_talk(d,
973 voltage_low, len, rbuf, rlen);
984 return (ret < 0) ? -
ENODEV : 0;
987 static int dm04_rs2000_read_signal_strength(
struct dvb_frontend *fe,
1025 char *fe_name[] = {
"",
" LG TDQY-P001F",
" SHARP:BS2F7HZ7395",
1026 " SHARP:BS2F7HZ0194",
" RS2000"};
1027 char *
name = adap->
fe[0]->ops.info.name;
1049 info(
"TUN Found Frontend TDA10086");
1063 &sharp_z0194_config, &d->
i2c_adap);
1065 info(
"FE Found Stv0299");
1082 info(
"FE Found Stv0288");
1099 info(
"FE Found M88RS2000");
1105 adap->
fe[0]->ops.set_voltage;
1107 adap->
fe[0]->ops.read_signal_strength =
1108 dm04_rs2000_read_signal_strength;
1109 adap->
fe[0]->ops.read_snr =
1110 dm04_rs2000_read_snr;
1111 adap->
fe[0]->ops.read_ber =
1113 adap->
fe[0]->ops.read_ucblocks =
1119 if (adap->
fe[0] ==
NULL) {
1120 info(
"DM04/QQBOX Not Powered up or not Supported");
1133 adap->
fe[0]->ops.set_voltage = dm04_lme2510_set_voltage;
1134 ret = lme_name(adap);
1142 char *tun_msg[] = {
"",
"TDA8263",
"IX2505V",
"DVB_PLL_OPERA",
"RS2000"};
1169 info(
"TUN Found %s tuner", tun_msg[ret]);
1171 info(
"TUN No tuner found --- resetting device");
1177 ret = lme2510_int_read(adap);
1179 info(
"INT Unable to start Interrupt Service");
1192 int ret = 0, len = 3, rlen = 1;
1197 ret = lme2510_usb_talk(d, lnb_on, len, rbuf, rlen);
1199 ret = lme2510_usb_talk(d, lnb_off, len, rbuf, rlen);
1220 d->
intf->cur_altsetting->desc.bInterfaceNumber, 1);
1224 if (lme2510_return_status(d) == 0x44) {
1232 static int lme2510_get_stream_config(
struct dvb_frontend *fe,
u8 *ts_type,
1241 if (pid_filter == 2) {
1267 lme2510_kill_urb(&adap->
stream);
1282 info(
"Interrupt Service Stopped");
1293 usb_buffer = lme2510_exit_int(d);
1294 if (usb_buffer !=
NULL)
1300 .driver_name = KBUILD_MODNAME,
1302 .bInterfaceNumber = 0,
1306 .download_firmware = lme2510_download_firmware,
1308 .power_ctrl = lme2510_powerup,
1309 .identify_state = lme2510_identify_state,
1310 .i2c_algo = &lme2510_i2c_algo,
1312 .frontend_attach = dm04_lme2510_frontend_attach,
1313 .tuner_attach = dm04_lme2510_tuner,
1314 .get_stream_config = lme2510_get_stream_config,
1315 .get_adapter_count = lme2510_get_adapter_count,
1316 .streaming_ctrl = lme2510_streaming_ctrl,
1318 .get_rc_config = lme2510_get_rc_config,
1320 .exit = lme2510_exit,
1325 .pid_filter_count = 15,
1326 .pid_filter = lme2510_pid_filter,
1327 .pid_filter_ctrl = lme2510_pid_filter_ctrl,
1348 static struct usb_driver lme2510_driver = {
1349 .name = KBUILD_MODNAME,
1352 .id_table = lme2510_id_table,