GNU Linux-libre 4.9.292-gnu1
[releases.git] / drivers / media / usb / dvb-usb-v2 / lmedm04.c
1 /* DVB USB compliant linux driver for
2  *
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
8  *
9  * MVB7395 (LME2510C+SHARP:BS2F7HZ7395)
10  * SHARP:BS2F7HZ7395 = (STV0288+Sharp IX2505V)
11  *
12  * MV001F (LME2510+LGTDQY-P001F)
13  * LG TDQY - P001F =(TDA8263 + TDA10086H)
14  *
15  * MVB0001F (LME2510C+LGTDQT-P001F)
16  *
17  * MV0194 (LME2510+SHARP:BS2F7HZ0194)
18  * SHARP:BS2F7HZ0194 = (STV0299+IX2410)
19  *
20  * MVB0194 (LME2510C+SHARP0194)
21  *
22  * LME2510C + M88RS2000
23  *
24  * For firmware see Documentation/dvb/lmedm04.txt
25  *
26  * I2C addresses:
27  * 0xd0 - STV0288       - Demodulator
28  * 0xc0 - Sharp IX2505V - Tuner
29  * --
30  * 0x1c - TDA10086   - Demodulator
31  * 0xc0 - TDA8263    - Tuner
32  * --
33  * 0xd0 - STV0299       - Demodulator
34  * 0xc0 - IX2410        - Tuner
35  *
36  *
37  * VID = 3344  PID LME2510=1122 LME2510C=1120
38  *
39  * Copyright (C) 2010 Malcolm Priestley (tvboxspy@gmail.com)
40  * LME2510(C)(C) Leaguerme (Shenzhen) MicroElectronics Co., Ltd.
41  *
42  * This program is free software; you can redistribute it and/or modify
43  * it under the terms of the GNU General Public License Version 2, as
44  * published by the Free Software Foundation.
45  *
46  * This program is distributed in the hope that it will be useful,
47  * but WITHOUT ANY WARRANTY; without even the implied warranty of
48  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
49  * GNU General Public License for more details.
50  *
51  * You should have received a copy of the GNU General Public License
52  * along with this program; if not, write to the Free Software
53  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
54  *
55  *
56  * see Documentation/dvb/README.dvb-usb for more information
57  *
58  * Known Issues :
59  *      LME2510: Non Intel USB chipsets fail to maintain High Speed on
60  * Boot or Hot Plug.
61  *
62  * QQbox suffers from noise on LNB voltage.
63  *
64  *      LME2510: SHARP:BS2F7HZ0194(MV0194) cannot cold reset and share system
65  * with other tuners. After a cold reset streaming will not start.
66  *
67  * M88RS2000 suffers from loss of lock.
68  */
69 #define DVB_USB_LOG_PREFIX "LME2510(C)"
70 #include <linux/usb.h>
71 #include <linux/usb/input.h>
72 #include <media/rc-core.h>
73
74 #include "dvb_usb.h"
75 #include "lmedm04.h"
76 #include "tda826x.h"
77 #include "tda10086.h"
78 #include "stv0288.h"
79 #include "ix2505v.h"
80 #include "stv0299.h"
81 #include "dvb-pll.h"
82 #include "z0194a.h"
83 #include "m88rs2000.h"
84 #include "ts2020.h"
85
86
87 #define LME2510_C_S7395 "/*(DEBLOBBED)*/";
88 #define LME2510_C_LG    "/*(DEBLOBBED)*/";
89 #define LME2510_C_S0194 "/*(DEBLOBBED)*/";
90 #define LME2510_C_RS2000 "/*(DEBLOBBED)*/";
91 #define LME2510_LG      "/*(DEBLOBBED)*/";
92 #define LME2510_S0194   "/*(DEBLOBBED)*/";
93
94 /* debug */
95 static int dvb_usb_lme2510_debug;
96 #define lme_debug(var, level, args...) do { \
97         if ((var >= level)) \
98                 pr_debug(DVB_USB_LOG_PREFIX": " args); \
99 } while (0)
100 #define deb_info(level, args...) lme_debug(dvb_usb_lme2510_debug, level, args)
101 #define debug_data_snipet(level, name, p) \
102          deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
103                 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
104                         *(p+5), *(p+6), *(p+7));
105 #define info(args...) pr_info(DVB_USB_LOG_PREFIX": "args)
106
107 module_param_named(debug, dvb_usb_lme2510_debug, int, 0644);
108 MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able)).");
109
110 static int dvb_usb_lme2510_firmware;
111 module_param_named(firmware, dvb_usb_lme2510_firmware, int, 0644);
112 MODULE_PARM_DESC(firmware, "set default firmware 0=Sharp7395 1=LG");
113
114 static int pid_filter;
115 module_param_named(pid, pid_filter, int, 0644);
116 MODULE_PARM_DESC(pid, "set default 0=default 1=off 2=on");
117
118
119 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
120
121 #define TUNER_DEFAULT   0x0
122 #define TUNER_LG        0x1
123 #define TUNER_S7395     0x2
124 #define TUNER_S0194     0x3
125 #define TUNER_RS2000    0x4
126
127 struct lme2510_state {
128         unsigned long int_urb_due;
129         enum fe_status lock_status;
130         u8 id;
131         u8 tuner_config;
132         u8 signal_level;
133         u8 signal_sn;
134         u8 time_key;
135         u8 i2c_talk_onoff;
136         u8 i2c_gate;
137         u8 i2c_tuner_gate_w;
138         u8 i2c_tuner_gate_r;
139         u8 i2c_tuner_addr;
140         u8 stream_on;
141         u8 pid_size;
142         u8 pid_off;
143         void *buffer;
144         struct urb *lme_urb;
145         void *usb_buffer;
146         /* Frontend original calls */
147         int (*fe_read_status)(struct dvb_frontend *, enum fe_status *);
148         int (*fe_read_signal_strength)(struct dvb_frontend *, u16 *);
149         int (*fe_read_snr)(struct dvb_frontend *, u16 *);
150         int (*fe_read_ber)(struct dvb_frontend *, u32 *);
151         int (*fe_read_ucblocks)(struct dvb_frontend *, u32 *);
152         int (*fe_set_voltage)(struct dvb_frontend *, enum fe_sec_voltage);
153         u8 dvb_usb_lme2510_firmware;
154 };
155
156 static int lme2510_bulk_write(struct usb_device *dev,
157                                 u8 *snd, int len, u8 pipe)
158 {
159         int ret, actual_l;
160
161         ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe),
162                                 snd, len , &actual_l, 100);
163         return ret;
164 }
165
166 static int lme2510_bulk_read(struct usb_device *dev,
167                                 u8 *rev, int len, u8 pipe)
168 {
169         int ret, actual_l;
170
171         ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe),
172                                  rev, len , &actual_l, 200);
173         return ret;
174 }
175
176 static int lme2510_usb_talk(struct dvb_usb_device *d,
177                 u8 *wbuf, int wlen, u8 *rbuf, int rlen)
178 {
179         struct lme2510_state *st = d->priv;
180         u8 *buff;
181         int ret = 0;
182
183         if (st->usb_buffer == NULL) {
184                 st->usb_buffer = kmalloc(64, GFP_KERNEL);
185                 if (st->usb_buffer == NULL) {
186                         info("MEM Error no memory");
187                         return -ENOMEM;
188                 }
189         }
190         buff = st->usb_buffer;
191
192         ret = mutex_lock_interruptible(&d->usb_mutex);
193
194         if (ret < 0)
195                 return -EAGAIN;
196
197         /* the read/write capped at 64 */
198         memcpy(buff, wbuf, (wlen < 64) ? wlen : 64);
199
200         ret |= lme2510_bulk_write(d->udev, buff, wlen , 0x01);
201
202         ret |= lme2510_bulk_read(d->udev, buff, (rlen < 64) ?
203                         rlen : 64 , 0x01);
204
205         if (rlen > 0)
206                 memcpy(rbuf, buff, rlen);
207
208         mutex_unlock(&d->usb_mutex);
209
210         return (ret < 0) ? -ENODEV : 0;
211 }
212
213 static int lme2510_stream_restart(struct dvb_usb_device *d)
214 {
215         struct lme2510_state *st = d->priv;
216         u8 all_pids[] = LME_ALL_PIDS;
217         u8 stream_on[] = LME_ST_ON_W;
218         int ret;
219         u8 rbuff[1];
220         if (st->pid_off)
221                 ret = lme2510_usb_talk(d, all_pids, sizeof(all_pids),
222                         rbuff, sizeof(rbuff));
223         /*Restart Stream Command*/
224         ret = lme2510_usb_talk(d, stream_on, sizeof(stream_on),
225                         rbuff, sizeof(rbuff));
226         return ret;
227 }
228
229 static int lme2510_enable_pid(struct dvb_usb_device *d, u8 index, u16 pid_out)
230 {
231         struct lme2510_state *st = d->priv;
232         static u8 pid_buff[] = LME_ZERO_PID;
233         static u8 rbuf[1];
234         u8 pid_no = index * 2;
235         u8 pid_len = pid_no + 2;
236         int ret = 0;
237         deb_info(1, "PID Setting Pid %04x", pid_out);
238
239         if (st->pid_size == 0)
240                 ret |= lme2510_stream_restart(d);
241
242         pid_buff[2] = pid_no;
243         pid_buff[3] = (u8)pid_out & 0xff;
244         pid_buff[4] = pid_no + 1;
245         pid_buff[5] = (u8)(pid_out >> 8);
246
247         if (pid_len > st->pid_size)
248                 st->pid_size = pid_len;
249         pid_buff[7] = 0x80 + st->pid_size;
250
251         ret |= lme2510_usb_talk(d, pid_buff ,
252                 sizeof(pid_buff) , rbuf, sizeof(rbuf));
253
254         if (st->stream_on)
255                 ret |= lme2510_stream_restart(d);
256
257         return ret;
258 }
259
260 /* Convert range from 0x00-0xff to 0x0000-0xffff */
261 #define reg_to_16bits(x)        ((x) | ((x) << 8))
262
263 static void lme2510_update_stats(struct dvb_usb_adapter *adap)
264 {
265         struct lme2510_state *st = adap_to_priv(adap);
266         struct dvb_frontend *fe = adap->fe[0];
267         struct dtv_frontend_properties *c;
268         u32 s_tmp = 0, c_tmp = 0;
269
270         if (!fe)
271                 return;
272
273         c = &fe->dtv_property_cache;
274
275         c->block_count.len = 1;
276         c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
277         c->block_error.len = 1;
278         c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
279         c->post_bit_count.len = 1;
280         c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
281         c->post_bit_error.len = 1;
282         c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
283
284         if (st->i2c_talk_onoff) {
285                 c->strength.len = 1;
286                 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
287                 c->cnr.len = 1;
288                 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
289                 return;
290         }
291
292         switch (st->tuner_config) {
293         case TUNER_LG:
294                 s_tmp = reg_to_16bits(0xff - st->signal_level);
295                 c_tmp = reg_to_16bits(0xff - st->signal_sn);
296                 break;
297         case TUNER_S7395:
298         case TUNER_S0194:
299                 s_tmp = 0xffff - (((st->signal_level * 2) << 8) * 5 / 4);
300                 c_tmp = reg_to_16bits((0xff - st->signal_sn - 0xa1) * 3);
301                 break;
302         case TUNER_RS2000:
303                 s_tmp = reg_to_16bits(st->signal_level);
304                 c_tmp = reg_to_16bits(st->signal_sn);
305         }
306
307         c->strength.len = 1;
308         c->strength.stat[0].scale = FE_SCALE_RELATIVE;
309         c->strength.stat[0].uvalue = (u64)s_tmp;
310
311         c->cnr.len = 1;
312         c->cnr.stat[0].scale = FE_SCALE_RELATIVE;
313         c->cnr.stat[0].uvalue = (u64)c_tmp;
314 }
315
316 static void lme2510_int_response(struct urb *lme_urb)
317 {
318         struct dvb_usb_adapter *adap = lme_urb->context;
319         struct lme2510_state *st = adap_to_priv(adap);
320         static u8 *ibuf, *rbuf;
321         int i = 0, offset;
322         u32 key;
323         u8 signal_lock = 0;
324
325         switch (lme_urb->status) {
326         case 0:
327         case -ETIMEDOUT:
328                 break;
329         case -ECONNRESET:
330         case -ENOENT:
331         case -ESHUTDOWN:
332                 return;
333         default:
334                 info("Error %x", lme_urb->status);
335                 break;
336         }
337
338         rbuf = (u8 *) lme_urb->transfer_buffer;
339
340         offset = ((lme_urb->actual_length/8) > 4)
341                         ? 4 : (lme_urb->actual_length/8) ;
342
343         for (i = 0; i < offset; ++i) {
344                 ibuf = (u8 *)&rbuf[i*8];
345                 deb_info(5, "INT O/S C =%02x C/O=%02x Type =%02x%02x",
346                 offset, i, ibuf[0], ibuf[1]);
347
348                 switch (ibuf[0]) {
349                 case 0xaa:
350                         debug_data_snipet(1, "INT Remote data snipet", ibuf);
351                         if (!adap_to_d(adap)->rc_dev)
352                                 break;
353
354                         key = RC_SCANCODE_NEC32(ibuf[2] << 24 |
355                                                 ibuf[3] << 16 |
356                                                 ibuf[4] << 8  |
357                                                 ibuf[5]);
358
359                         deb_info(1, "INT Key = 0x%08x", key);
360                         rc_keydown(adap_to_d(adap)->rc_dev, RC_TYPE_NEC32, key,
361                                                                         0);
362                         break;
363                 case 0xbb:
364                         switch (st->tuner_config) {
365                         case TUNER_LG:
366                                 signal_lock = ibuf[2] & BIT(5);
367                                 st->signal_level = ibuf[4];
368                                 st->signal_sn = ibuf[3];
369                                 st->time_key = ibuf[7];
370                                 break;
371                         case TUNER_S7395:
372                         case TUNER_S0194:
373                                 /* Tweak for earlier firmware*/
374                                 if (ibuf[1] == 0x03) {
375                                         signal_lock = ibuf[2] & BIT(4);
376                                         st->signal_level = ibuf[3];
377                                         st->signal_sn = ibuf[4];
378                                 } else {
379                                         st->signal_level = ibuf[4];
380                                         st->signal_sn = ibuf[5];
381                                 }
382                                 break;
383                         case TUNER_RS2000:
384                                 signal_lock = ibuf[2] & 0xee;
385                                 st->signal_level = ibuf[5];
386                                 st->signal_sn = ibuf[4];
387                                 st->time_key = ibuf[7];
388                         default:
389                                 break;
390                         }
391
392                         /* Interrupt will also throw just BIT 0 as lock */
393                         signal_lock |= ibuf[2] & BIT(0);
394
395                         if (!signal_lock)
396                                 st->lock_status &= ~FE_HAS_LOCK;
397
398                         lme2510_update_stats(adap);
399
400                         debug_data_snipet(5, "INT Remote data snipet in", ibuf);
401                 break;
402                 case 0xcc:
403                         debug_data_snipet(1, "INT Control data snipet", ibuf);
404                         break;
405                 default:
406                         debug_data_snipet(1, "INT Unknown data snipet", ibuf);
407                 break;
408                 }
409         }
410
411         usb_submit_urb(lme_urb, GFP_ATOMIC);
412
413         /* Interrupt urb is due every 48 msecs while streaming the buffer
414          * stores up to 4 periods if missed. Allow 200 msec for next interrupt.
415          */
416         st->int_urb_due = jiffies + msecs_to_jiffies(200);
417 }
418
419 static int lme2510_int_read(struct dvb_usb_adapter *adap)
420 {
421         struct dvb_usb_device *d = adap_to_d(adap);
422         struct lme2510_state *lme_int = adap_to_priv(adap);
423         struct usb_host_endpoint *ep;
424
425         lme_int->lme_urb = usb_alloc_urb(0, GFP_ATOMIC);
426
427         if (lme_int->lme_urb == NULL)
428                         return -ENOMEM;
429
430         lme_int->buffer = usb_alloc_coherent(d->udev, 128, GFP_ATOMIC,
431                                         &lme_int->lme_urb->transfer_dma);
432
433         if (lme_int->buffer == NULL)
434                         return -ENOMEM;
435
436         usb_fill_int_urb(lme_int->lme_urb,
437                                 d->udev,
438                                 usb_rcvintpipe(d->udev, 0xa),
439                                 lme_int->buffer,
440                                 128,
441                                 lme2510_int_response,
442                                 adap,
443                                 8);
444
445         /* Quirk of pipe reporting PIPE_BULK but behaves as interrupt */
446         ep = usb_pipe_endpoint(d->udev, lme_int->lme_urb->pipe);
447
448         if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK)
449                 lme_int->lme_urb->pipe = usb_rcvbulkpipe(d->udev, 0xa);
450
451         lme_int->lme_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
452
453         usb_submit_urb(lme_int->lme_urb, GFP_ATOMIC);
454         info("INT Interrupt Service Started");
455
456         return 0;
457 }
458
459 static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
460 {
461         struct dvb_usb_device *d = adap_to_d(adap);
462         struct lme2510_state *st = adap_to_priv(adap);
463         static u8 clear_pid_reg[] = LME_ALL_PIDS;
464         static u8 rbuf[1];
465         int ret = 0;
466
467         deb_info(1, "PID Clearing Filter");
468
469         mutex_lock(&d->i2c_mutex);
470
471         if (!onoff) {
472                 ret |= lme2510_usb_talk(d, clear_pid_reg,
473                         sizeof(clear_pid_reg), rbuf, sizeof(rbuf));
474                 st->pid_off = true;
475         } else
476                 st->pid_off = false;
477
478         st->pid_size = 0;
479
480         mutex_unlock(&d->i2c_mutex);
481
482         return 0;
483 }
484
485 static int lme2510_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
486         int onoff)
487 {
488         struct dvb_usb_device *d = adap_to_d(adap);
489         int ret = 0;
490
491         deb_info(3, "%s PID=%04x Index=%04x onoff=%02x", __func__,
492                 pid, index, onoff);
493
494         if (onoff) {
495                 mutex_lock(&d->i2c_mutex);
496                 ret |= lme2510_enable_pid(d, index, pid);
497                 mutex_unlock(&d->i2c_mutex);
498         }
499
500
501         return ret;
502 }
503
504
505 static int lme2510_return_status(struct dvb_usb_device *d)
506 {
507         int ret;
508         u8 *data;
509
510         data = kzalloc(6, GFP_KERNEL);
511         if (!data)
512                 return -ENOMEM;
513
514         ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
515                               0x06, 0x80, 0x0302, 0x00,
516                               data, 0x6, 200);
517         if (ret != 6)
518                 ret = -EINVAL;
519         else
520                 ret = data[2];
521
522         info("Firmware Status: %6ph", data);
523
524         kfree(data);
525         return ret;
526 }
527
528 static int lme2510_msg(struct dvb_usb_device *d,
529                 u8 *wbuf, int wlen, u8 *rbuf, int rlen)
530 {
531         struct lme2510_state *st = d->priv;
532
533         st->i2c_talk_onoff = 1;
534
535         return lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
536 }
537
538 static int lme2510_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
539                                  int num)
540 {
541         struct dvb_usb_device *d = i2c_get_adapdata(adap);
542         struct lme2510_state *st = d->priv;
543         static u8 obuf[64], ibuf[64];
544         int i, read, read_o;
545         u16 len;
546         u8 gate = st->i2c_gate;
547
548         mutex_lock(&d->i2c_mutex);
549
550         if (gate == 0)
551                 gate = 5;
552
553         for (i = 0; i < num; i++) {
554                 read_o = msg[i].flags & I2C_M_RD;
555                 read = i + 1 < num && msg[i + 1].flags & I2C_M_RD;
556                 read |= read_o;
557                 gate = (msg[i].addr == st->i2c_tuner_addr)
558                         ? (read)        ? st->i2c_tuner_gate_r
559                                         : st->i2c_tuner_gate_w
560                         : st->i2c_gate;
561                 obuf[0] = gate | (read << 7);
562
563                 if (gate == 5)
564                         obuf[1] = (read) ? 2 : msg[i].len + 1;
565                 else
566                         obuf[1] = msg[i].len + read + 1;
567
568                 obuf[2] = msg[i].addr << 1;
569
570                 if (read) {
571                         if (read_o)
572                                 len = 3;
573                         else {
574                                 memcpy(&obuf[3], msg[i].buf, msg[i].len);
575                                 obuf[msg[i].len+3] = msg[i+1].len;
576                                 len = msg[i].len+4;
577                         }
578                 } else {
579                         memcpy(&obuf[3], msg[i].buf, msg[i].len);
580                         len = msg[i].len+3;
581                 }
582
583                 if (lme2510_msg(d, obuf, len, ibuf, 64) < 0) {
584                         deb_info(1, "i2c transfer failed.");
585                         mutex_unlock(&d->i2c_mutex);
586                         return -EAGAIN;
587                 }
588
589                 if (read) {
590                         if (read_o)
591                                 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
592                         else {
593                                 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
594                                 i++;
595                         }
596                 }
597         }
598
599         mutex_unlock(&d->i2c_mutex);
600         return i;
601 }
602
603 static u32 lme2510_i2c_func(struct i2c_adapter *adapter)
604 {
605         return I2C_FUNC_I2C;
606 }
607
608 static struct i2c_algorithm lme2510_i2c_algo = {
609         .master_xfer   = lme2510_i2c_xfer,
610         .functionality = lme2510_i2c_func,
611 };
612
613 static int lme2510_streaming_ctrl(struct dvb_frontend *fe, int onoff)
614 {
615         struct dvb_usb_adapter *adap = fe_to_adap(fe);
616         struct dvb_usb_device *d = adap_to_d(adap);
617         struct lme2510_state *st = adap_to_priv(adap);
618         static u8 clear_reg_3[] = LME_ALL_PIDS;
619         static u8 rbuf[1];
620         int ret = 0, rlen = sizeof(rbuf);
621
622         deb_info(1, "STM  (%02x)", onoff);
623
624         /* Streaming is started by FE_HAS_LOCK */
625         if (onoff == 1)
626                 st->stream_on = 1;
627         else {
628                 deb_info(1, "STM Steam Off");
629                 /* mutex is here only to avoid collision with I2C */
630                 mutex_lock(&d->i2c_mutex);
631
632                 ret = lme2510_usb_talk(d, clear_reg_3,
633                                 sizeof(clear_reg_3), rbuf, rlen);
634                 st->stream_on = 0;
635                 st->i2c_talk_onoff = 1;
636
637                 mutex_unlock(&d->i2c_mutex);
638         }
639
640         return (ret < 0) ? -ENODEV : 0;
641 }
642
643 static u8 check_sum(u8 *p, u8 len)
644 {
645         u8 sum = 0;
646         while (len--)
647                 sum += *p++;
648         return sum;
649 }
650
651 static int lme2510_download_firmware(struct dvb_usb_device *d,
652                                         const struct firmware *fw)
653 {
654         int ret = 0;
655         u8 *data;
656         u16 j, wlen, len_in, start, end;
657         u8 packet_size, dlen, i;
658         u8 *fw_data;
659
660         packet_size = 0x31;
661         len_in = 1;
662
663         data = kzalloc(128, GFP_KERNEL);
664         if (!data) {
665                 info("FRM Could not start Firmware Download"\
666                         "(Buffer allocation failed)");
667                 return -ENOMEM;
668         }
669
670         info("FRM Starting Firmware Download");
671
672         for (i = 1; i < 3; i++) {
673                 start = (i == 1) ? 0 : 512;
674                 end = (i == 1) ? 512 : fw->size;
675                 for (j = start; j < end; j += (packet_size+1)) {
676                         fw_data = (u8 *)(fw->data + j);
677                         if ((end - j) > packet_size) {
678                                 data[0] = i;
679                                 dlen = packet_size;
680                         } else {
681                                 data[0] = i | 0x80;
682                                 dlen = (u8)(end - j)-1;
683                         }
684                         data[1] = dlen;
685                         memcpy(&data[2], fw_data, dlen+1);
686                         wlen = (u8) dlen + 4;
687                         data[wlen-1] = check_sum(fw_data, dlen+1);
688                         deb_info(1, "Data S=%02x:E=%02x CS= %02x", data[3],
689                                 data[dlen+2], data[dlen+3]);
690                         lme2510_usb_talk(d, data, wlen, data, len_in);
691                         ret |= (data[0] == 0x88) ? 0 : -1;
692                 }
693         }
694
695         data[0] = 0x8a;
696         len_in = 1;
697         msleep(2000);
698         lme2510_usb_talk(d, data, len_in, data, len_in);
699         msleep(400);
700
701         if (ret < 0)
702                 info("FRM Firmware Download Failed (%04x)" , ret);
703         else
704                 info("FRM Firmware Download Completed - Resetting Device");
705
706         kfree(data);
707         return RECONNECTS_USB;
708 }
709
710 static void lme_coldreset(struct dvb_usb_device *d)
711 {
712         u8 data[1] = {0};
713         data[0] = 0x0a;
714         info("FRM Firmware Cold Reset");
715
716         lme2510_usb_talk(d, data, sizeof(data), data, sizeof(data));
717
718         return;
719 }
720
721 static const char fw_c_s7395[] = LME2510_C_S7395;
722 static const char fw_c_lg[] = LME2510_C_LG;
723 static const char fw_c_s0194[] = LME2510_C_S0194;
724 static const char fw_c_rs2000[] = LME2510_C_RS2000;
725 static const char fw_lg[] = LME2510_LG;
726 static const char fw_s0194[] = LME2510_S0194;
727
728 static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
729 {
730         struct lme2510_state *st = d->priv;
731         struct usb_device *udev = d->udev;
732         const struct firmware *fw = NULL;
733         const char *fw_lme;
734         int ret = 0;
735
736         cold = (cold > 0) ? (cold & 1) : 0;
737
738         switch (le16_to_cpu(udev->descriptor.idProduct)) {
739         case 0x1122:
740                 switch (st->dvb_usb_lme2510_firmware) {
741                 default:
742                 case TUNER_S0194:
743                         fw_lme = fw_s0194;
744                         ret = reject_firmware(&fw, fw_lme, &udev->dev);
745                         if (ret == 0) {
746                                 st->dvb_usb_lme2510_firmware = TUNER_S0194;
747                                 cold = 0;
748                                 break;
749                         }
750                         /* fall through */
751                 case TUNER_LG:
752                         fw_lme = fw_lg;
753                         ret = reject_firmware(&fw, fw_lme, &udev->dev);
754                         if (ret == 0) {
755                                 st->dvb_usb_lme2510_firmware = TUNER_LG;
756                                 break;
757                         }
758                         st->dvb_usb_lme2510_firmware = TUNER_DEFAULT;
759                         break;
760                 }
761                 break;
762         case 0x1120:
763                 switch (st->dvb_usb_lme2510_firmware) {
764                 default:
765                 case TUNER_S7395:
766                         fw_lme = fw_c_s7395;
767                         ret = reject_firmware(&fw, fw_lme, &udev->dev);
768                         if (ret == 0) {
769                                 st->dvb_usb_lme2510_firmware = TUNER_S7395;
770                                 cold = 0;
771                                 break;
772                         }
773                         /* fall through */
774                 case TUNER_LG:
775                         fw_lme = fw_c_lg;
776                         ret = reject_firmware(&fw, fw_lme, &udev->dev);
777                         if (ret == 0) {
778                                 st->dvb_usb_lme2510_firmware = TUNER_LG;
779                                 break;
780                         }
781                         /* fall through */
782                 case TUNER_S0194:
783                         fw_lme = fw_c_s0194;
784                         ret = reject_firmware(&fw, fw_lme, &udev->dev);
785                         if (ret == 0) {
786                                 st->dvb_usb_lme2510_firmware = TUNER_S0194;
787                                 break;
788                         }
789                         st->dvb_usb_lme2510_firmware = TUNER_DEFAULT;
790                         cold = 0;
791                         break;
792                 }
793                 break;
794         case 0x22f0:
795                 fw_lme = fw_c_rs2000;
796                 st->dvb_usb_lme2510_firmware = TUNER_RS2000;
797                 break;
798         default:
799                 fw_lme = fw_c_s7395;
800         }
801
802         release_firmware(fw);
803
804         if (cold) {
805                 dvb_usb_lme2510_firmware = st->dvb_usb_lme2510_firmware;
806                 info("FRM Changing to %s firmware", fw_lme);
807                 lme_coldreset(d);
808                 return NULL;
809         }
810
811         return fw_lme;
812 }
813
814 static int lme2510_kill_urb(struct usb_data_stream *stream)
815 {
816         int i;
817
818         for (i = 0; i < stream->urbs_submitted; i++) {
819                 deb_info(3, "killing URB no. %d.", i);
820                 /* stop the URB */
821                 usb_kill_urb(stream->urb_list[i]);
822         }
823         stream->urbs_submitted = 0;
824
825         return 0;
826 }
827
828 static struct tda10086_config tda10086_config = {
829         .demod_address = 0x0e,
830         .invert = 0,
831         .diseqc_tone = 1,
832         .xtal_freq = TDA10086_XTAL_16M,
833 };
834
835 static struct stv0288_config lme_config = {
836         .demod_address = 0x68,
837         .min_delay_ms = 15,
838         .inittab = s7395_inittab,
839 };
840
841 static struct ix2505v_config lme_tuner = {
842         .tuner_address = 0x60,
843         .min_delay_ms = 100,
844         .tuner_gain = 0x0,
845         .tuner_chargepump = 0x3,
846 };
847
848 static struct stv0299_config sharp_z0194_config = {
849         .demod_address = 0x68,
850         .inittab = sharp_z0194a_inittab,
851         .mclk = 88000000UL,
852         .invert = 0,
853         .skip_reinit = 0,
854         .lock_output = STV0299_LOCKOUTPUT_1,
855         .volt13_op0_op1 = STV0299_VOLT13_OP1,
856         .min_delay_ms = 100,
857         .set_symbol_rate = sharp_z0194a_set_symbol_rate,
858 };
859
860 static struct m88rs2000_config m88rs2000_config = {
861         .demod_addr = 0x68
862 };
863
864 static struct ts2020_config ts2020_config = {
865         .tuner_address = 0x60,
866         .clk_out_div = 7,
867         .dont_poll = true
868 };
869
870 static int dm04_lme2510_set_voltage(struct dvb_frontend *fe,
871                                     enum fe_sec_voltage voltage)
872 {
873         struct dvb_usb_device *d = fe_to_d(fe);
874         struct lme2510_state *st = fe_to_priv(fe);
875         static u8 voltage_low[] = LME_VOLTAGE_L;
876         static u8 voltage_high[] = LME_VOLTAGE_H;
877         static u8 rbuf[1];
878         int ret = 0, len = 3, rlen = 1;
879
880         mutex_lock(&d->i2c_mutex);
881
882         switch (voltage) {
883         case SEC_VOLTAGE_18:
884                 ret |= lme2510_usb_talk(d,
885                         voltage_high, len, rbuf, rlen);
886                 break;
887
888         case SEC_VOLTAGE_OFF:
889         case SEC_VOLTAGE_13:
890         default:
891                 ret |= lme2510_usb_talk(d,
892                                 voltage_low, len, rbuf, rlen);
893                 break;
894         }
895
896         mutex_unlock(&d->i2c_mutex);
897
898         if (st->tuner_config == TUNER_RS2000)
899                 if (st->fe_set_voltage)
900                         st->fe_set_voltage(fe, voltage);
901
902
903         return (ret < 0) ? -ENODEV : 0;
904 }
905
906 static int dm04_read_status(struct dvb_frontend *fe, enum fe_status *status)
907 {
908         struct dvb_usb_device *d = fe_to_d(fe);
909         struct lme2510_state *st = d->priv;
910         int ret = 0;
911
912         if (st->i2c_talk_onoff) {
913                 if (st->fe_read_status) {
914                         ret = st->fe_read_status(fe, status);
915                         if (ret < 0)
916                                 return ret;
917                 }
918
919                 st->lock_status = *status;
920
921                 if (*status & FE_HAS_LOCK && st->stream_on) {
922                         mutex_lock(&d->i2c_mutex);
923
924                         st->i2c_talk_onoff = 0;
925                         ret = lme2510_stream_restart(d);
926
927                         mutex_unlock(&d->i2c_mutex);
928                 }
929
930                 return ret;
931         }
932
933         /* Timeout of interrupt reached on RS2000 */
934         if (st->tuner_config == TUNER_RS2000 &&
935             time_after(jiffies, st->int_urb_due))
936                 st->lock_status &= ~FE_HAS_LOCK;
937
938         *status = st->lock_status;
939
940         if (!(*status & FE_HAS_LOCK)) {
941                 struct dvb_usb_adapter *adap = fe_to_adap(fe);
942
943                 st->i2c_talk_onoff = 1;
944
945                 lme2510_update_stats(adap);
946         }
947
948         return ret;
949 }
950
951 static int dm04_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
952 {
953         struct dtv_frontend_properties *c = &fe->dtv_property_cache;
954         struct lme2510_state *st = fe_to_priv(fe);
955
956         if (st->fe_read_signal_strength && !st->stream_on)
957                 return st->fe_read_signal_strength(fe, strength);
958
959         if (c->strength.stat[0].scale == FE_SCALE_RELATIVE)
960                 *strength = (u16)c->strength.stat[0].uvalue;
961         else
962                 *strength = 0;
963
964         return 0;
965 }
966
967 static int dm04_read_snr(struct dvb_frontend *fe, u16 *snr)
968 {
969         struct dtv_frontend_properties *c = &fe->dtv_property_cache;
970         struct lme2510_state *st = fe_to_priv(fe);
971
972         if (st->fe_read_snr && !st->stream_on)
973                 return st->fe_read_snr(fe, snr);
974
975         if (c->cnr.stat[0].scale == FE_SCALE_RELATIVE)
976                 *snr = (u16)c->cnr.stat[0].uvalue;
977         else
978                 *snr = 0;
979
980         return 0;
981 }
982
983 static int dm04_read_ber(struct dvb_frontend *fe, u32 *ber)
984 {
985         struct lme2510_state *st = fe_to_priv(fe);
986
987         if (st->fe_read_ber && !st->stream_on)
988                 return st->fe_read_ber(fe, ber);
989
990         *ber = 0;
991
992         return 0;
993 }
994
995 static int dm04_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
996 {
997         struct lme2510_state *st = fe_to_priv(fe);
998
999         if (st->fe_read_ucblocks && !st->stream_on)
1000                 return st->fe_read_ucblocks(fe, ucblocks);
1001
1002         *ucblocks = 0;
1003
1004         return 0;
1005 }
1006
1007 static int lme_name(struct dvb_usb_adapter *adap)
1008 {
1009         struct dvb_usb_device *d = adap_to_d(adap);
1010         struct lme2510_state *st = adap_to_priv(adap);
1011         const char *desc = d->name;
1012         char *fe_name[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395",
1013                                 " SHARP:BS2F7HZ0194", " RS2000"};
1014         char *name = adap->fe[0]->ops.info.name;
1015
1016         strlcpy(name, desc, 128);
1017         strlcat(name, fe_name[st->tuner_config], 128);
1018
1019         return 0;
1020 }
1021
1022 static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap)
1023 {
1024         struct dvb_usb_device *d = adap_to_d(adap);
1025         struct lme2510_state *st = d->priv;
1026         int ret = 0;
1027
1028         st->i2c_talk_onoff = 1;
1029         switch (le16_to_cpu(d->udev->descriptor.idProduct)) {
1030         case 0x1122:
1031         case 0x1120:
1032                 st->i2c_gate = 4;
1033                 adap->fe[0] = dvb_attach(tda10086_attach,
1034                         &tda10086_config, &d->i2c_adap);
1035                 if (adap->fe[0]) {
1036                         info("TUN Found Frontend TDA10086");
1037                         st->i2c_tuner_gate_w = 4;
1038                         st->i2c_tuner_gate_r = 4;
1039                         st->i2c_tuner_addr = 0x60;
1040                         st->tuner_config = TUNER_LG;
1041                         if (st->dvb_usb_lme2510_firmware != TUNER_LG) {
1042                                 st->dvb_usb_lme2510_firmware = TUNER_LG;
1043                                 ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1044                         }
1045                         break;
1046                 }
1047
1048                 st->i2c_gate = 4;
1049                 adap->fe[0] = dvb_attach(stv0299_attach,
1050                                 &sharp_z0194_config, &d->i2c_adap);
1051                 if (adap->fe[0]) {
1052                         info("FE Found Stv0299");
1053                         st->i2c_tuner_gate_w = 4;
1054                         st->i2c_tuner_gate_r = 5;
1055                         st->i2c_tuner_addr = 0x60;
1056                         st->tuner_config = TUNER_S0194;
1057                         if (st->dvb_usb_lme2510_firmware != TUNER_S0194) {
1058                                 st->dvb_usb_lme2510_firmware = TUNER_S0194;
1059                                 ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1060                         }
1061                         break;
1062                 }
1063
1064                 st->i2c_gate = 5;
1065                 adap->fe[0] = dvb_attach(stv0288_attach, &lme_config,
1066                         &d->i2c_adap);
1067
1068                 if (adap->fe[0]) {
1069                         info("FE Found Stv0288");
1070                         st->i2c_tuner_gate_w = 4;
1071                         st->i2c_tuner_gate_r = 5;
1072                         st->i2c_tuner_addr = 0x60;
1073                         st->tuner_config = TUNER_S7395;
1074                         if (st->dvb_usb_lme2510_firmware != TUNER_S7395) {
1075                                 st->dvb_usb_lme2510_firmware = TUNER_S7395;
1076                                 ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1077                         }
1078                         break;
1079                 }
1080         case 0x22f0:
1081                 st->i2c_gate = 5;
1082                 adap->fe[0] = dvb_attach(m88rs2000_attach,
1083                         &m88rs2000_config, &d->i2c_adap);
1084
1085                 if (adap->fe[0]) {
1086                         info("FE Found M88RS2000");
1087                         st->i2c_tuner_gate_w = 5;
1088                         st->i2c_tuner_gate_r = 5;
1089                         st->i2c_tuner_addr = 0x60;
1090                         st->tuner_config = TUNER_RS2000;
1091                         st->fe_set_voltage =
1092                                 adap->fe[0]->ops.set_voltage;
1093                 }
1094                 break;
1095         }
1096
1097         if (adap->fe[0] == NULL) {
1098                 info("DM04/QQBOX Not Powered up or not Supported");
1099                 return -ENODEV;
1100         }
1101
1102         if (ret) {
1103                 if (adap->fe[0]) {
1104                         dvb_frontend_detach(adap->fe[0]);
1105                         adap->fe[0] = NULL;
1106                 }
1107                 d->rc_map = NULL;
1108                 return -ENODEV;
1109         }
1110
1111         st->fe_read_status = adap->fe[0]->ops.read_status;
1112         st->fe_read_signal_strength = adap->fe[0]->ops.read_signal_strength;
1113         st->fe_read_snr = adap->fe[0]->ops.read_snr;
1114         st->fe_read_ber = adap->fe[0]->ops.read_ber;
1115         st->fe_read_ucblocks = adap->fe[0]->ops.read_ucblocks;
1116
1117         adap->fe[0]->ops.read_status = dm04_read_status;
1118         adap->fe[0]->ops.read_signal_strength = dm04_read_signal_strength;
1119         adap->fe[0]->ops.read_snr = dm04_read_snr;
1120         adap->fe[0]->ops.read_ber = dm04_read_ber;
1121         adap->fe[0]->ops.read_ucblocks = dm04_read_ucblocks;
1122         adap->fe[0]->ops.set_voltage = dm04_lme2510_set_voltage;
1123
1124         ret = lme_name(adap);
1125         return ret;
1126 }
1127
1128 static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap)
1129 {
1130         struct dvb_usb_device *d = adap_to_d(adap);
1131         struct lme2510_state *st = adap_to_priv(adap);
1132         char *tun_msg[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA", "RS2000"};
1133         int ret = 0;
1134
1135         switch (st->tuner_config) {
1136         case TUNER_LG:
1137                 if (dvb_attach(tda826x_attach, adap->fe[0], 0x60,
1138                         &d->i2c_adap, 1))
1139                         ret = st->tuner_config;
1140                 break;
1141         case TUNER_S7395:
1142                 if (dvb_attach(ix2505v_attach , adap->fe[0], &lme_tuner,
1143                         &d->i2c_adap))
1144                         ret = st->tuner_config;
1145                 break;
1146         case TUNER_S0194:
1147                 if (dvb_attach(dvb_pll_attach , adap->fe[0], 0x60,
1148                         &d->i2c_adap, DVB_PLL_OPERA1))
1149                         ret = st->tuner_config;
1150                 break;
1151         case TUNER_RS2000:
1152                 if (dvb_attach(ts2020_attach, adap->fe[0],
1153                                &ts2020_config, &d->i2c_adap))
1154                         ret = st->tuner_config;
1155                 break;
1156         default:
1157                 break;
1158         }
1159
1160         if (ret) {
1161                 info("TUN Found %s tuner", tun_msg[ret]);
1162         } else {
1163                 info("TUN No tuner found");
1164                 return -ENODEV;
1165         }
1166
1167         /* Start the Interrupt*/
1168         ret = lme2510_int_read(adap);
1169         if (ret < 0) {
1170                 info("INT Unable to start Interrupt Service");
1171                 return -ENODEV;
1172         }
1173
1174         return ret;
1175 }
1176
1177 static int lme2510_powerup(struct dvb_usb_device *d, int onoff)
1178 {
1179         struct lme2510_state *st = d->priv;
1180         static u8 lnb_on[] = LNB_ON;
1181         static u8 lnb_off[] = LNB_OFF;
1182         static u8 rbuf[1];
1183         int ret = 0, len = 3, rlen = 1;
1184
1185         mutex_lock(&d->i2c_mutex);
1186
1187         if (onoff)
1188                 ret = lme2510_usb_talk(d, lnb_on, len, rbuf, rlen);
1189         else
1190                 ret = lme2510_usb_talk(d, lnb_off, len, rbuf, rlen);
1191
1192         st->i2c_talk_onoff = 1;
1193
1194         mutex_unlock(&d->i2c_mutex);
1195
1196         return ret;
1197 }
1198
1199 static int lme2510_get_adapter_count(struct dvb_usb_device *d)
1200 {
1201         return 1;
1202 }
1203
1204 static int lme2510_identify_state(struct dvb_usb_device *d, const char **name)
1205 {
1206         struct lme2510_state *st = d->priv;
1207         int status;
1208
1209         usb_reset_configuration(d->udev);
1210
1211         usb_set_interface(d->udev,
1212                 d->props->bInterfaceNumber, 1);
1213
1214         st->dvb_usb_lme2510_firmware = dvb_usb_lme2510_firmware;
1215
1216         status = lme2510_return_status(d);
1217         if (status == 0x44) {
1218                 *name = lme_firmware_switch(d, 0);
1219                 return COLD;
1220         }
1221
1222         if (status != 0x47)
1223                 return -EINVAL;
1224
1225         return WARM;
1226 }
1227
1228 static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
1229                 struct usb_data_stream_properties *stream)
1230 {
1231         struct dvb_usb_adapter *adap = fe_to_adap(fe);
1232         struct dvb_usb_device *d;
1233
1234         if (adap == NULL)
1235                 return 0;
1236
1237         d = adap_to_d(adap);
1238
1239         /* Turn PID filter on the fly by module option */
1240         if (pid_filter == 2) {
1241                 adap->pid_filtering  = true;
1242                 adap->max_feed_count = 15;
1243         }
1244
1245         if (!(le16_to_cpu(d->udev->descriptor.idProduct)
1246                 == 0x1122))
1247                 stream->endpoint = 0x8;
1248
1249         return 0;
1250 }
1251
1252 static int lme2510_get_rc_config(struct dvb_usb_device *d,
1253         struct dvb_usb_rc *rc)
1254 {
1255         rc->allowed_protos = RC_BIT_NEC32;
1256         return 0;
1257 }
1258
1259 static void *lme2510_exit_int(struct dvb_usb_device *d)
1260 {
1261         struct lme2510_state *st = d->priv;
1262         struct dvb_usb_adapter *adap = &d->adapter[0];
1263         void *buffer = NULL;
1264
1265         if (adap != NULL) {
1266                 lme2510_kill_urb(&adap->stream);
1267         }
1268
1269         if (st->usb_buffer != NULL) {
1270                 st->i2c_talk_onoff = 1;
1271                 st->signal_level = 0;
1272                 st->signal_sn = 0;
1273                 buffer = st->usb_buffer;
1274         }
1275
1276         if (st->lme_urb != NULL) {
1277                 usb_kill_urb(st->lme_urb);
1278                 usb_free_coherent(d->udev, 128, st->buffer,
1279                                   st->lme_urb->transfer_dma);
1280                 info("Interrupt Service Stopped");
1281         }
1282
1283         return buffer;
1284 }
1285
1286 static void lme2510_exit(struct dvb_usb_device *d)
1287 {
1288         void *usb_buffer;
1289
1290         if (d != NULL) {
1291                 usb_buffer = lme2510_exit_int(d);
1292                 kfree(usb_buffer);
1293         }
1294 }
1295
1296 static struct dvb_usb_device_properties lme2510_props = {
1297         .driver_name = KBUILD_MODNAME,
1298         .owner = THIS_MODULE,
1299         .bInterfaceNumber = 0,
1300         .adapter_nr = adapter_nr,
1301         .size_of_priv = sizeof(struct lme2510_state),
1302
1303         .download_firmware = lme2510_download_firmware,
1304
1305         .power_ctrl       = lme2510_powerup,
1306         .identify_state   = lme2510_identify_state,
1307         .i2c_algo         = &lme2510_i2c_algo,
1308
1309         .frontend_attach  = dm04_lme2510_frontend_attach,
1310         .tuner_attach = dm04_lme2510_tuner,
1311         .get_stream_config = lme2510_get_stream_config,
1312         .get_adapter_count = lme2510_get_adapter_count,
1313         .streaming_ctrl   = lme2510_streaming_ctrl,
1314
1315         .get_rc_config = lme2510_get_rc_config,
1316
1317         .exit = lme2510_exit,
1318         .adapter = {
1319                 {
1320                         .caps = DVB_USB_ADAP_HAS_PID_FILTER|
1321                                 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1322                         .pid_filter_count = 15,
1323                         .pid_filter = lme2510_pid_filter,
1324                         .pid_filter_ctrl  = lme2510_pid_filter_ctrl,
1325                         .stream =
1326                         DVB_USB_STREAM_BULK(0x86, 10, 4096),
1327                 },
1328                 {
1329                 }
1330         },
1331 };
1332
1333 static const struct usb_device_id lme2510_id_table[] = {
1334         {       DVB_USB_DEVICE(0x3344, 0x1122, &lme2510_props,
1335                 "DM04_LME2510_DVB-S", RC_MAP_LME2510)   },
1336         {       DVB_USB_DEVICE(0x3344, 0x1120, &lme2510_props,
1337                 "DM04_LME2510C_DVB-S", RC_MAP_LME2510)  },
1338         {       DVB_USB_DEVICE(0x3344, 0x22f0, &lme2510_props,
1339                 "DM04_LME2510C_DVB-S RS2000", RC_MAP_LME2510)   },
1340         {}              /* Terminating entry */
1341 };
1342
1343 MODULE_DEVICE_TABLE(usb, lme2510_id_table);
1344
1345 static struct usb_driver lme2510_driver = {
1346         .name           = KBUILD_MODNAME,
1347         .probe          = dvb_usbv2_probe,
1348         .disconnect     = dvb_usbv2_disconnect,
1349         .id_table       = lme2510_id_table,
1350         .no_dynamic_id = 1,
1351         .soft_unbind = 1,
1352 };
1353
1354 module_usb_driver(lme2510_driver);
1355
1356 MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1357 MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0");
1358 MODULE_VERSION("2.07");
1359 MODULE_LICENSE("GPL");
1360 /*(DEBLOBBED)*/
1361