aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorMalcolm Priestley <tvboxspy@gmail.com>2012-08-06 15:21:40 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-12 06:48:09 -0400
commite41543a2a9f91fcebd7f450a712c08ddbb1d563e (patch)
tree47daf49de6f3c69619f22fdcaa8a45917a44e174 /drivers/media/dvb
parent9468542bf29ba6cdc9d052a7b9aa384279b0f845 (diff)
[media] lmedm04 2.06 conversion to dvb-usb-v2 version 2
Conversion of lmedm04 to dvb-usb-v2 Functional changes m88rs2000 tuner now uses all callbacks. TODO migrate other tuners to the callbacks. This patch is applied on top of [BUG] Re: dvb_usb_lmedm04 crash Kernel (rs2000) http://patchwork.linuxtv.org/patch/13584/ Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com> Acked-by: Antti Palosaari <crope@iki.fi> Tested-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-usb-v2/Kconfig13
-rw-r--r--drivers/media/dvb/dvb-usb-v2/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig13
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/lmedm04.c588
5 files changed, 291 insertions, 329 deletions
diff --git a/drivers/media/dvb/dvb-usb-v2/Kconfig b/drivers/media/dvb/dvb-usb-v2/Kconfig
index e7ff148e4a29..14a635b97b0b 100644
--- a/drivers/media/dvb/dvb-usb-v2/Kconfig
+++ b/drivers/media/dvb/dvb-usb-v2/Kconfig
@@ -102,6 +102,19 @@ config DVB_USB_GL861
102 Say Y here to support the MSI Megasky 580 (55801) DVB-T USB2.0 102 Say Y here to support the MSI Megasky 580 (55801) DVB-T USB2.0
103 receiver with USB ID 0db0:5581. 103 receiver with USB ID 0db0:5581.
104 104
105config DVB_USB_LME2510
106 tristate "LME DM04/QQBOX DVB-S USB2.0 support"
107 depends on DVB_USB_V2
108 select DVB_TDA10086 if !DVB_FE_CUSTOMISE
109 select DVB_TDA826X if !DVB_FE_CUSTOMISE
110 select DVB_STV0288 if !DVB_FE_CUSTOMISE
111 select DVB_IX2505V if !DVB_FE_CUSTOMISE
112 select DVB_STV0299 if !DVB_FE_CUSTOMISE
113 select DVB_PLL if !DVB_FE_CUSTOMISE
114 select DVB_M88RS2000 if !DVB_FE_CUSTOMISE
115 help
116 Say Y here to support the LME DM04/QQBOX DVB-S USB2.0
117
105config DVB_USB_MXL111SF 118config DVB_USB_MXL111SF
106 tristate "MxL111SF DTV USB2.0 support" 119 tristate "MxL111SF DTV USB2.0 support"
107 depends on DVB_USB_V2 120 depends on DVB_USB_V2
diff --git a/drivers/media/dvb/dvb-usb-v2/Makefile b/drivers/media/dvb/dvb-usb-v2/Makefile
index a784bf4af4e4..26659bc7fa60 100644
--- a/drivers/media/dvb/dvb-usb-v2/Makefile
+++ b/drivers/media/dvb/dvb-usb-v2/Makefile
@@ -25,6 +25,9 @@ obj-$(CONFIG_DVB_USB_CE6230) += dvb-usb-ce6230.o
25dvb-usb-ec168-objs = ec168.o 25dvb-usb-ec168-objs = ec168.o
26obj-$(CONFIG_DVB_USB_EC168) += dvb-usb-ec168.o 26obj-$(CONFIG_DVB_USB_EC168) += dvb-usb-ec168.o
27 27
28dvb-usb-lmedm04-objs = lmedm04.o
29obj-$(CONFIG_DVB_USB_LME2510) += dvb-usb-lmedm04.o
30
28dvb-usb-gl861-objs = gl861.o 31dvb-usb-gl861-objs = gl861.o
29obj-$(CONFIG_DVB_USB_GL861) += dvb-usb-gl861.o 32obj-$(CONFIG_DVB_USB_GL861) += dvb-usb-gl861.o
30 33
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 29bba9a24875..8e13877a5c2c 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -304,19 +304,6 @@ config DVB_USB_AZ6027
304 help 304 help
305 Say Y here to support the AZ6027 device 305 Say Y here to support the AZ6027 device
306 306
307config DVB_USB_LME2510
308 tristate "LME DM04/QQBOX DVB-S USB2.0 support"
309 depends on DVB_USB
310 select DVB_TDA10086 if !DVB_FE_CUSTOMISE
311 select DVB_TDA826X if !DVB_FE_CUSTOMISE
312 select DVB_STV0288 if !DVB_FE_CUSTOMISE
313 select DVB_IX2505V if !DVB_FE_CUSTOMISE
314 select DVB_STV0299 if !DVB_FE_CUSTOMISE
315 select DVB_PLL if !DVB_FE_CUSTOMISE
316 select DVB_M88RS2000 if !DVB_FE_CUSTOMISE
317 help
318 Say Y here to support the LME DM04/QQBOX DVB-S USB2.0 .
319
320config DVB_USB_TECHNISAT_USB2 307config DVB_USB_TECHNISAT_USB2
321 tristate "Technisat DVB-S/S2 USB2.0 support" 308 tristate "Technisat DVB-S/S2 USB2.0 support"
322 depends on DVB_USB 309 depends on DVB_USB
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 5261c7dae982..859baf9c8e0c 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -72,9 +72,6 @@ obj-$(CONFIG_DVB_USB_FRIIO) += dvb-usb-friio.o
72dvb-usb-az6027-objs = az6027.o 72dvb-usb-az6027-objs = az6027.o
73obj-$(CONFIG_DVB_USB_AZ6027) += dvb-usb-az6027.o 73obj-$(CONFIG_DVB_USB_AZ6027) += dvb-usb-az6027.o
74 74
75dvb-usb-lmedm04-objs = lmedm04.o
76obj-$(CONFIG_DVB_USB_LME2510) += dvb-usb-lmedm04.o
77
78dvb-usb-technisat-usb2-objs = technisat-usb2.o 75dvb-usb-technisat-usb2-objs = technisat-usb2.o
79obj-$(CONFIG_DVB_USB_TECHNISAT_USB2) += dvb-usb-technisat-usb2.o 76obj-$(CONFIG_DVB_USB_TECHNISAT_USB2) += dvb-usb-technisat-usb2.o
80 77
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c b/drivers/media/dvb/dvb-usb/lmedm04.c
index 26ba5bc92c61..c6bc1b8b58b8 100644
--- a/drivers/media/dvb/dvb-usb/lmedm04.c
+++ b/drivers/media/dvb/dvb-usb/lmedm04.c
@@ -19,6 +19,8 @@
19 * 19 *
20 * MVB0194 (LME2510C+SHARP0194) 20 * MVB0194 (LME2510C+SHARP0194)
21 * 21 *
22 * LME2510C + M88RS2000
23 *
22 * For firmware see Documentation/dvb/lmedm04.txt 24 * For firmware see Documentation/dvb/lmedm04.txt
23 * 25 *
24 * I2C addresses: 26 * I2C addresses:
@@ -62,13 +64,14 @@
62 * LME2510: SHARP:BS2F7HZ0194(MV0194) cannot cold reset and share system 64 * LME2510: SHARP:BS2F7HZ0194(MV0194) cannot cold reset and share system
63 * with other tuners. After a cold reset streaming will not start. 65 * with other tuners. After a cold reset streaming will not start.
64 * 66 *
67 * M88RS2000 suffers from loss of lock.
65 */ 68 */
66#define DVB_USB_LOG_PREFIX "LME2510(C)" 69#define DVB_USB_LOG_PREFIX "LME2510(C)"
67#include <linux/usb.h> 70#include <linux/usb.h>
68#include <linux/usb/input.h> 71#include <linux/usb/input.h>
69#include <media/rc-core.h> 72#include <media/rc-core.h>
70 73
71#include "dvb-usb.h" 74#include "dvb_usb.h"
72#include "lmedm04.h" 75#include "lmedm04.h"
73#include "tda826x.h" 76#include "tda826x.h"
74#include "tda10086.h" 77#include "tda10086.h"
@@ -80,24 +83,28 @@
80#include "m88rs2000.h" 83#include "m88rs2000.h"
81 84
82 85
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";
83 92
84/* debug */ 93/* debug */
85static int dvb_usb_lme2510_debug; 94static int dvb_usb_lme2510_debug;
86#define l_dprintk(var, level, args...) do { \ 95#define lme_debug(var, level, args...) do { \
87 if ((var >= level)) \ 96 if ((var >= level)) \
88 printk(KERN_DEBUG DVB_USB_LOG_PREFIX ": " args); \ 97 pr_debug(DVB_USB_LOG_PREFIX": " args); \
89} while (0) 98} while (0)
90 99#define deb_info(level, args...) lme_debug(dvb_usb_lme2510_debug, level, args)
91#define deb_info(level, args...) l_dprintk(dvb_usb_lme2510_debug, level, args)
92#define debug_data_snipet(level, name, p) \ 100#define debug_data_snipet(level, name, p) \
93 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \ 101 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
94 *p, *(p+1), *(p+2), *(p+3), *(p+4), \ 102 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
95 *(p+5), *(p+6), *(p+7)); 103 *(p+5), *(p+6), *(p+7));
96 104#define info(args...) pr_info(DVB_USB_LOG_PREFIX": "args)
97 105
98module_param_named(debug, dvb_usb_lme2510_debug, int, 0644); 106module_param_named(debug, dvb_usb_lme2510_debug, int, 0644);
99MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))." 107MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able)).");
100 DVB_USB_DEBUG_STATUS);
101 108
102static int dvb_usb_lme2510_firmware; 109static int dvb_usb_lme2510_firmware;
103module_param_named(firmware, dvb_usb_lme2510_firmware, int, 0644); 110module_param_named(firmware, dvb_usb_lme2510_firmware, int, 0644);
@@ -136,7 +143,8 @@ struct lme2510_state {
136 void *buffer; 143 void *buffer;
137 struct urb *lme_urb; 144 struct urb *lme_urb;
138 void *usb_buffer; 145 void *usb_buffer;
139 146 int (*fe_set_voltage)(struct dvb_frontend *, fe_sec_voltage_t);
147 u8 dvb_usb_lme2510_firmware;
140}; 148};
141 149
142static int lme2510_bulk_write(struct usb_device *dev, 150static int lme2510_bulk_write(struct usb_device *dev,
@@ -246,7 +254,7 @@ static int lme2510_enable_pid(struct dvb_usb_device *d, u8 index, u16 pid_out)
246static void lme2510_int_response(struct urb *lme_urb) 254static void lme2510_int_response(struct urb *lme_urb)
247{ 255{
248 struct dvb_usb_adapter *adap = lme_urb->context; 256 struct dvb_usb_adapter *adap = lme_urb->context;
249 struct lme2510_state *st = adap->dev->priv; 257 struct lme2510_state *st = adap_to_priv(adap);
250 static u8 *ibuf, *rbuf; 258 static u8 *ibuf, *rbuf;
251 int i = 0, offset; 259 int i = 0, offset;
252 u32 key; 260 u32 key;
@@ -283,8 +291,9 @@ static void lme2510_int_response(struct urb *lme_urb)
283 ? (ibuf[3] ^ 0xff) << 8 : 0; 291 ? (ibuf[3] ^ 0xff) << 8 : 0;
284 key += (ibuf[2] ^ 0xff) << 16; 292 key += (ibuf[2] ^ 0xff) << 16;
285 deb_info(1, "INT Key =%08x", key); 293 deb_info(1, "INT Key =%08x", key);
286 if (adap->dev->rc_dev != NULL) 294 if (adap_to_d(adap)->rc_dev != NULL)
287 rc_keydown(adap->dev->rc_dev, key, 0); 295 rc_keydown(adap_to_d(adap)->rc_dev,
296 key, 0);
288 } 297 }
289 break; 298 break;
290 case 0xbb: 299 case 0xbb:
@@ -313,12 +322,12 @@ static void lme2510_int_response(struct urb *lme_urb)
313 } 322 }
314 break; 323 break;
315 case TUNER_RS2000: 324 case TUNER_RS2000:
316 if (ibuf[2] > 0) 325 if (ibuf[1] == 0x3 && ibuf[6] == 0xff)
317 st->signal_lock = 0xff; 326 st->signal_lock = 0xff;
318 else 327 else
319 st->signal_lock = 0xf0; 328 st->signal_lock = 0x00;
320 st->signal_level = ibuf[4]; 329 st->signal_level = ibuf[5];
321 st->signal_sn = ibuf[5]; 330 st->signal_sn = ibuf[4];
322 st->time_key = ibuf[7]; 331 st->time_key = ibuf[7];
323 default: 332 default:
324 break; 333 break;
@@ -338,22 +347,23 @@ static void lme2510_int_response(struct urb *lme_urb)
338 347
339static int lme2510_int_read(struct dvb_usb_adapter *adap) 348static int lme2510_int_read(struct dvb_usb_adapter *adap)
340{ 349{
341 struct lme2510_state *lme_int = adap->dev->priv; 350 struct dvb_usb_device *d = adap_to_d(adap);
351 struct lme2510_state *lme_int = adap_to_priv(adap);
342 352
343 lme_int->lme_urb = usb_alloc_urb(0, GFP_ATOMIC); 353 lme_int->lme_urb = usb_alloc_urb(0, GFP_ATOMIC);
344 354
345 if (lme_int->lme_urb == NULL) 355 if (lme_int->lme_urb == NULL)
346 return -ENOMEM; 356 return -ENOMEM;
347 357
348 lme_int->buffer = usb_alloc_coherent(adap->dev->udev, 128, GFP_ATOMIC, 358 lme_int->buffer = usb_alloc_coherent(d->udev, 128, GFP_ATOMIC,
349 &lme_int->lme_urb->transfer_dma); 359 &lme_int->lme_urb->transfer_dma);
350 360
351 if (lme_int->buffer == NULL) 361 if (lme_int->buffer == NULL)
352 return -ENOMEM; 362 return -ENOMEM;
353 363
354 usb_fill_int_urb(lme_int->lme_urb, 364 usb_fill_int_urb(lme_int->lme_urb,
355 adap->dev->udev, 365 d->udev,
356 usb_rcvintpipe(adap->dev->udev, 0xa), 366 usb_rcvintpipe(d->udev, 0xa),
357 lme_int->buffer, 367 lme_int->buffer,
358 128, 368 128,
359 lme2510_int_response, 369 lme2510_int_response,
@@ -370,17 +380,18 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)
370 380
371static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) 381static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
372{ 382{
373 struct lme2510_state *st = adap->dev->priv; 383 struct dvb_usb_device *d = adap_to_d(adap);
384 struct lme2510_state *st = adap_to_priv(adap);
374 static u8 clear_pid_reg[] = LME_ALL_PIDS; 385 static u8 clear_pid_reg[] = LME_ALL_PIDS;
375 static u8 rbuf[1]; 386 static u8 rbuf[1];
376 int ret = 0; 387 int ret = 0;
377 388
378 deb_info(1, "PID Clearing Filter"); 389 deb_info(1, "PID Clearing Filter");
379 390
380 mutex_lock(&adap->dev->i2c_mutex); 391 mutex_lock(&d->i2c_mutex);
381 392
382 if (!onoff) { 393 if (!onoff) {
383 ret |= lme2510_usb_talk(adap->dev, clear_pid_reg, 394 ret |= lme2510_usb_talk(d, clear_pid_reg,
384 sizeof(clear_pid_reg), rbuf, sizeof(rbuf)); 395 sizeof(clear_pid_reg), rbuf, sizeof(rbuf));
385 st->pid_off = true; 396 st->pid_off = true;
386 } else 397 } else
@@ -388,7 +399,7 @@ static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
388 399
389 st->pid_size = 0; 400 st->pid_size = 0;
390 401
391 mutex_unlock(&adap->dev->i2c_mutex); 402 mutex_unlock(&d->i2c_mutex);
392 403
393 return 0; 404 return 0;
394} 405}
@@ -396,15 +407,16 @@ static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
396static int lme2510_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, 407static int lme2510_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
397 int onoff) 408 int onoff)
398{ 409{
410 struct dvb_usb_device *d = adap_to_d(adap);
399 int ret = 0; 411 int ret = 0;
400 412
401 deb_info(3, "%s PID=%04x Index=%04x onoff=%02x", __func__, 413 deb_info(3, "%s PID=%04x Index=%04x onoff=%02x", __func__,
402 pid, index, onoff); 414 pid, index, onoff);
403 415
404 if (onoff) { 416 if (onoff) {
405 mutex_lock(&adap->dev->i2c_mutex); 417 mutex_lock(&d->i2c_mutex);
406 ret |= lme2510_enable_pid(adap->dev, index, pid); 418 ret |= lme2510_enable_pid(d, index, pid);
407 mutex_unlock(&adap->dev->i2c_mutex); 419 mutex_unlock(&d->i2c_mutex);
408 } 420 }
409 421
410 422
@@ -412,7 +424,7 @@ static int lme2510_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
412} 424}
413 425
414 426
415static int lme2510_return_status(struct usb_device *dev) 427static int lme2510_return_status(struct dvb_usb_device *d)
416{ 428{
417 int ret = 0; 429 int ret = 0;
418 u8 *data; 430 u8 *data;
@@ -421,7 +433,7 @@ static int lme2510_return_status(struct usb_device *dev)
421 if (!data) 433 if (!data)
422 return -ENOMEM; 434 return -ENOMEM;
423 435
424 ret |= usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 436 ret |= usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
425 0x06, 0x80, 0x0302, 0x00, data, 0x0006, 200); 437 0x06, 0x80, 0x0302, 0x00, data, 0x0006, 200);
426 info("Firmware Status: %x (%x)", ret , data[2]); 438 info("Firmware Status: %x (%x)", ret , data[2]);
427 439
@@ -613,10 +625,6 @@ static int lme2510_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
613 if (gate == 0) 625 if (gate == 0)
614 gate = 5; 626 gate = 5;
615 627
616 if (num > 2)
617 warn("more than 2 i2c messages"
618 "at a time is not handled yet. TODO.");
619
620 for (i = 0; i < num; i++) { 628 for (i = 0; i < num; i++) {
621 read_o = 1 & (msg[i].flags & I2C_M_RD); 629 read_o = 1 & (msg[i].flags & I2C_M_RD);
622 read = i+1 < num && (msg[i+1].flags & I2C_M_RD); 630 read = i+1 < num && (msg[i+1].flags & I2C_M_RD);
@@ -676,22 +684,11 @@ static struct i2c_algorithm lme2510_i2c_algo = {
676 .functionality = lme2510_i2c_func, 684 .functionality = lme2510_i2c_func,
677}; 685};
678 686
679/* Callbacks for DVB USB */ 687static int lme2510_streaming_ctrl(struct dvb_frontend *fe, int onoff)
680static int lme2510_identify_state(struct usb_device *udev,
681 struct dvb_usb_device_properties *props,
682 struct dvb_usb_device_description **desc,
683 int *cold)
684{ 688{
685 if (pid_filter != 2) 689 struct dvb_usb_adapter *adap = fe_to_adap(fe);
686 props->adapter[0].fe[0].caps &= 690 struct dvb_usb_device *d = adap_to_d(adap);
687 ~DVB_USB_ADAP_NEED_PID_FILTERING; 691 struct lme2510_state *st = adap_to_priv(adap);
688 *cold = 0;
689 return 0;
690}
691
692static int lme2510_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
693{
694 struct lme2510_state *st = adap->dev->priv;
695 static u8 clear_reg_3[] = LME_ALL_PIDS; 692 static u8 clear_reg_3[] = LME_ALL_PIDS;
696 static u8 rbuf[1]; 693 static u8 rbuf[1];
697 int ret = 0, rlen = sizeof(rbuf); 694 int ret = 0, rlen = sizeof(rbuf);
@@ -704,14 +701,14 @@ static int lme2510_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
704 else { 701 else {
705 deb_info(1, "STM Steam Off"); 702 deb_info(1, "STM Steam Off");
706 /* mutex is here only to avoid collision with I2C */ 703 /* mutex is here only to avoid collision with I2C */
707 mutex_lock(&adap->dev->i2c_mutex); 704 mutex_lock(&d->i2c_mutex);
708 705
709 ret = lme2510_usb_talk(adap->dev, clear_reg_3, 706 ret = lme2510_usb_talk(d, clear_reg_3,
710 sizeof(clear_reg_3), rbuf, rlen); 707 sizeof(clear_reg_3), rbuf, rlen);
711 st->stream_on = 0; 708 st->stream_on = 0;
712 st->i2c_talk_onoff = 1; 709 st->i2c_talk_onoff = 1;
713 710
714 mutex_unlock(&adap->dev->i2c_mutex); 711 mutex_unlock(&d->i2c_mutex);
715 } 712 }
716 713
717 return (ret < 0) ? -ENODEV : 0; 714 return (ret < 0) ? -ENODEV : 0;
@@ -725,7 +722,7 @@ static u8 check_sum(u8 *p, u8 len)
725 return sum; 722 return sum;
726} 723}
727 724
728static int lme2510_download_firmware(struct usb_device *dev, 725static int lme2510_download_firmware(struct dvb_usb_device *d,
729 const struct firmware *fw) 726 const struct firmware *fw)
730{ 727{
731 int ret = 0; 728 int ret = 0;
@@ -737,9 +734,10 @@ static int lme2510_download_firmware(struct usb_device *dev,
737 packet_size = 0x31; 734 packet_size = 0x31;
738 len_in = 1; 735 len_in = 1;
739 736
740 data = kzalloc(512, GFP_KERNEL); 737 data = kzalloc(128, GFP_KERNEL);
741 if (!data) { 738 if (!data) {
742 info("FRM Could not start Firmware Download (Buffer allocation failed)"); 739 info("FRM Could not start Firmware Download"\
740 "(Buffer allocation failed)");
743 return -ENOMEM; 741 return -ENOMEM;
744 } 742 }
745 743
@@ -763,21 +761,19 @@ static int lme2510_download_firmware(struct usb_device *dev,
763 data[wlen-1] = check_sum(fw_data, dlen+1); 761 data[wlen-1] = check_sum(fw_data, dlen+1);
764 deb_info(1, "Data S=%02x:E=%02x CS= %02x", data[3], 762 deb_info(1, "Data S=%02x:E=%02x CS= %02x", data[3],
765 data[dlen+2], data[dlen+3]); 763 data[dlen+2], data[dlen+3]);
766 ret |= lme2510_bulk_write(dev, data, wlen, 1); 764 lme2510_usb_talk(d, data, wlen, data, len_in);
767 ret |= lme2510_bulk_read(dev, data, len_in , 1);
768 ret |= (data[0] == 0x88) ? 0 : -1; 765 ret |= (data[0] == 0x88) ? 0 : -1;
769 } 766 }
770 } 767 }
771 768
772 usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 769 usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
773 0x06, 0x80, 0x0200, 0x00, data, 0x0109, 1000); 770 0x06, 0x80, 0x0200, 0x00, data, 0x0109, 1000);
774 771
775 772
776 data[0] = 0x8a; 773 data[0] = 0x8a;
777 len_in = 1; 774 len_in = 1;
778 msleep(2000); 775 msleep(2000);
779 ret |= lme2510_bulk_write(dev, data , len_in, 1); /*Resetting*/ 776 lme2510_usb_talk(d, data, len_in, data, len_in);
780 ret |= lme2510_bulk_read(dev, data, len_in, 1);
781 msleep(400); 777 msleep(400);
782 778
783 if (ret < 0) 779 if (ret < 0)
@@ -786,44 +782,42 @@ static int lme2510_download_firmware(struct usb_device *dev,
786 info("FRM Firmware Download Completed - Resetting Device"); 782 info("FRM Firmware Download Completed - Resetting Device");
787 783
788 kfree(data); 784 kfree(data);
789 return (ret < 0) ? -ENODEV : 0; 785 return RECONNECTS_USB;
790} 786}
791 787
792static void lme_coldreset(struct usb_device *dev) 788static void lme_coldreset(struct dvb_usb_device *d)
793{ 789{
794 int ret = 0, len_in; 790 u8 data[1] = {0};
795 u8 data[512] = {0};
796
797 data[0] = 0x0a; 791 data[0] = 0x0a;
798 len_in = 1;
799 info("FRM Firmware Cold Reset"); 792 info("FRM Firmware Cold Reset");
800 ret |= lme2510_bulk_write(dev, data , len_in, 1); /*Cold Resetting*/ 793
801 ret |= lme2510_bulk_read(dev, data, len_in, 1); 794 lme2510_usb_talk(d, data, sizeof(data), data, sizeof(data));
802 795
803 return; 796 return;
804} 797}
805 798
806static int lme_firmware_switch(struct usb_device *udev, int cold) 799static const char fw_c_s7395[] = LME2510_C_S7395;
800static const char fw_c_lg[] = LME2510_C_LG;
801static const char fw_c_s0194[] = LME2510_C_S0194;
802static const char fw_c_rs2000[] = LME2510_C_RS2000;
803static const char fw_lg[] = LME2510_LG;
804static const char fw_s0194[] = LME2510_S0194;
805
806const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
807{ 807{
808 struct lme2510_state *st = d->priv;
809 struct usb_device *udev = d->udev;
808 const struct firmware *fw = NULL; 810 const struct firmware *fw = NULL;
809 const char fw_c_s7395[] = "dvb-usb-lme2510c-s7395.fw";
810 const char fw_c_lg[] = "dvb-usb-lme2510c-lg.fw";
811 const char fw_c_s0194[] = "dvb-usb-lme2510c-s0194.fw";
812 const char fw_c_rs2000[] = "dvb-usb-lme2510c-rs2000.fw";
813 const char fw_lg[] = "dvb-usb-lme2510-lg.fw";
814 const char fw_s0194[] = "dvb-usb-lme2510-s0194.fw";
815 const char *fw_lme; 811 const char *fw_lme;
816 int ret = 0, cold_fw; 812 int ret = 0;
817 813
818 cold = (cold > 0) ? (cold & 1) : 0; 814 cold = (cold > 0) ? (cold & 1) : 0;
819 815
820 cold_fw = !cold;
821
822 switch (le16_to_cpu(udev->descriptor.idProduct)) { 816 switch (le16_to_cpu(udev->descriptor.idProduct)) {
823 case 0x1122: 817 case 0x1122:
824 switch (dvb_usb_lme2510_firmware) { 818 switch (st->dvb_usb_lme2510_firmware) {
825 default: 819 default:
826 dvb_usb_lme2510_firmware = TUNER_S0194; 820 st->dvb_usb_lme2510_firmware = TUNER_S0194;
827 case TUNER_S0194: 821 case TUNER_S0194:
828 fw_lme = fw_s0194; 822 fw_lme = fw_s0194;
829 ret = request_firmware(&fw, fw_lme, &udev->dev); 823 ret = request_firmware(&fw, fw_lme, &udev->dev);
@@ -831,23 +825,20 @@ static int lme_firmware_switch(struct usb_device *udev, int cold)
831 cold = 0; 825 cold = 0;
832 break; 826 break;
833 } 827 }
834 dvb_usb_lme2510_firmware = TUNER_LG; 828 st->dvb_usb_lme2510_firmware = TUNER_LG;
835 case TUNER_LG: 829 case TUNER_LG:
836 fw_lme = fw_lg; 830 fw_lme = fw_lg;
837 ret = request_firmware(&fw, fw_lme, &udev->dev); 831 ret = request_firmware(&fw, fw_lme, &udev->dev);
838 if (ret == 0) 832 if (ret == 0)
839 break; 833 break;
840 info("FRM No Firmware Found - please install"); 834 st->dvb_usb_lme2510_firmware = TUNER_DEFAULT;
841 dvb_usb_lme2510_firmware = TUNER_DEFAULT;
842 cold = 0;
843 cold_fw = 0;
844 break; 835 break;
845 } 836 }
846 break; 837 break;
847 case 0x1120: 838 case 0x1120:
848 switch (dvb_usb_lme2510_firmware) { 839 switch (st->dvb_usb_lme2510_firmware) {
849 default: 840 default:
850 dvb_usb_lme2510_firmware = TUNER_S7395; 841 st->dvb_usb_lme2510_firmware = TUNER_S7395;
851 case TUNER_S7395: 842 case TUNER_S7395:
852 fw_lme = fw_c_s7395; 843 fw_lme = fw_c_s7395;
853 ret = request_firmware(&fw, fw_lme, &udev->dev); 844 ret = request_firmware(&fw, fw_lme, &udev->dev);
@@ -855,53 +846,41 @@ static int lme_firmware_switch(struct usb_device *udev, int cold)
855 cold = 0; 846 cold = 0;
856 break; 847 break;
857 } 848 }
858 dvb_usb_lme2510_firmware = TUNER_LG; 849 st->dvb_usb_lme2510_firmware = TUNER_LG;
859 case TUNER_LG: 850 case TUNER_LG:
860 fw_lme = fw_c_lg; 851 fw_lme = fw_c_lg;
861 ret = request_firmware(&fw, fw_lme, &udev->dev); 852 ret = request_firmware(&fw, fw_lme, &udev->dev);
862 if (ret == 0) 853 if (ret == 0)
863 break; 854 break;
864 dvb_usb_lme2510_firmware = TUNER_S0194; 855 st->dvb_usb_lme2510_firmware = TUNER_S0194;
865 case TUNER_S0194: 856 case TUNER_S0194:
866 fw_lme = fw_c_s0194; 857 fw_lme = fw_c_s0194;
867 ret = request_firmware(&fw, fw_lme, &udev->dev); 858 ret = request_firmware(&fw, fw_lme, &udev->dev);
868 if (ret == 0) 859 if (ret == 0)
869 break; 860 break;
870 info("FRM No Firmware Found - please install"); 861 st->dvb_usb_lme2510_firmware = TUNER_DEFAULT;
871 dvb_usb_lme2510_firmware = TUNER_DEFAULT;
872 cold = 0; 862 cold = 0;
873 cold_fw = 0;
874 break; 863 break;
875 } 864 }
876 break; 865 break;
877 case 0x22f0: 866 case 0x22f0:
878 fw_lme = fw_c_rs2000; 867 fw_lme = fw_c_rs2000;
879 ret = request_firmware(&fw, fw_lme, &udev->dev); 868 st->dvb_usb_lme2510_firmware = TUNER_RS2000;
880 dvb_usb_lme2510_firmware = TUNER_RS2000;
881 if (ret == 0)
882 break;
883 info("FRM No Firmware Found - please install");
884 cold_fw = 0;
885 break; 869 break;
886 default: 870 default:
887 fw_lme = fw_c_s7395; 871 fw_lme = fw_c_s7395;
888 } 872 }
889 873
890
891 if (cold_fw) {
892 info("FRM Loading %s file", fw_lme);
893 ret = lme2510_download_firmware(udev, fw);
894 }
895
896 release_firmware(fw); 874 release_firmware(fw);
897 875
898 if (cold) { 876 if (cold) {
877 dvb_usb_lme2510_firmware = st->dvb_usb_lme2510_firmware;
899 info("FRM Changing to %s firmware", fw_lme); 878 info("FRM Changing to %s firmware", fw_lme);
900 lme_coldreset(udev); 879 lme_coldreset(d);
901 return -ENODEV; 880 return NULL;
902 } 881 }
903 882
904 return ret; 883 return fw_lme;
905} 884}
906 885
907static int lme2510_kill_urb(struct usb_data_stream *stream) 886static int lme2510_kill_urb(struct usb_data_stream *stream)
@@ -953,8 +932,8 @@ static struct stv0299_config sharp_z0194_config = {
953static int dm04_rs2000_set_ts_param(struct dvb_frontend *fe, 932static int dm04_rs2000_set_ts_param(struct dvb_frontend *fe,
954 int caller) 933 int caller)
955{ 934{
956 struct dvb_usb_adapter *adap = fe->dvb->priv; 935 struct dvb_usb_adapter *adap = fe_to_adap(fe);
957 struct dvb_usb_device *d = adap->dev; 936 struct dvb_usb_device *d = adap_to_d(adap);
958 struct lme2510_state *st = d->priv; 937 struct lme2510_state *st = d->priv;
959 938
960 mutex_lock(&d->i2c_mutex); 939 mutex_lock(&d->i2c_mutex);
@@ -976,29 +955,35 @@ static struct m88rs2000_config m88rs2000_config = {
976static int dm04_lme2510_set_voltage(struct dvb_frontend *fe, 955static int dm04_lme2510_set_voltage(struct dvb_frontend *fe,
977 fe_sec_voltage_t voltage) 956 fe_sec_voltage_t voltage)
978{ 957{
979 struct dvb_usb_adapter *adap = fe->dvb->priv; 958 struct dvb_usb_device *d = fe_to_d(fe);
980 static u8 voltage_low[] = LME_VOLTAGE_L; 959 struct lme2510_state *st = fe_to_priv(fe);
960 static u8 voltage_low[] = LME_VOLTAGE_L;
981 static u8 voltage_high[] = LME_VOLTAGE_H; 961 static u8 voltage_high[] = LME_VOLTAGE_H;
982 static u8 rbuf[1]; 962 static u8 rbuf[1];
983 int ret = 0, len = 3, rlen = 1; 963 int ret = 0, len = 3, rlen = 1;
984 964
985 mutex_lock(&adap->dev->i2c_mutex); 965 mutex_lock(&d->i2c_mutex);
986 966
987 switch (voltage) { 967 switch (voltage) {
988 case SEC_VOLTAGE_18: 968 case SEC_VOLTAGE_18:
989 ret |= lme2510_usb_talk(adap->dev, 969 ret |= lme2510_usb_talk(d,
990 voltage_high, len, rbuf, rlen); 970 voltage_high, len, rbuf, rlen);
991 break; 971 break;
992 972
993 case SEC_VOLTAGE_OFF: 973 case SEC_VOLTAGE_OFF:
994 case SEC_VOLTAGE_13: 974 case SEC_VOLTAGE_13:
995 default: 975 default:
996 ret |= lme2510_usb_talk(adap->dev, 976 ret |= lme2510_usb_talk(d,
997 voltage_low, len, rbuf, rlen); 977 voltage_low, len, rbuf, rlen);
998 break; 978 break;
999 } 979 }
1000 980
1001 mutex_unlock(&adap->dev->i2c_mutex); 981 mutex_unlock(&d->i2c_mutex);
982
983 if (st->tuner_config == TUNER_RS2000)
984 if (st->fe_set_voltage)
985 st->fe_set_voltage(fe, voltage);
986
1002 987
1003 return (ret < 0) ? -ENODEV : 0; 988 return (ret < 0) ? -ENODEV : 0;
1004} 989}
@@ -1006,29 +991,44 @@ static int dm04_lme2510_set_voltage(struct dvb_frontend *fe,
1006static int dm04_rs2000_read_signal_strength(struct dvb_frontend *fe, 991static int dm04_rs2000_read_signal_strength(struct dvb_frontend *fe,
1007 u16 *strength) 992 u16 *strength)
1008{ 993{
1009 struct dvb_usb_adapter *adap = fe->dvb->priv; 994 struct lme2510_state *st = fe_to_priv(fe);
1010 struct lme2510_state *st = adap->dev->priv; 995
996 *strength = (u16)((u32)st->signal_level * 0xffff / 0xff);
1011 997
1012 *strength = (u16)((u32)st->signal_level * 0xffff / 0x7f);
1013 return 0; 998 return 0;
1014} 999}
1015 1000
1016static int dm04_rs2000_read_snr(struct dvb_frontend *fe, u16 *snr) 1001static int dm04_rs2000_read_snr(struct dvb_frontend *fe, u16 *snr)
1017{ 1002{
1018 struct dvb_usb_adapter *adap = fe->dvb->priv; 1003 struct lme2510_state *st = fe_to_priv(fe);
1019 struct lme2510_state *st = adap->dev->priv; 1004
1005 *snr = (u16)((u32)st->signal_sn * 0xffff / 0x7f);
1006
1007 return 0;
1008}
1009
1010static int dm04_read_ber(struct dvb_frontend *fe, u32 *ber)
1011{
1012 *ber = 0;
1013
1014 return 0;
1015}
1016
1017static int dm04_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
1018{
1019 *ucblocks = 0;
1020 1020
1021 *snr = (u16)((u32)st->signal_sn * 0xffff / 0xff);
1022 return 0; 1021 return 0;
1023} 1022}
1024 1023
1025static int lme_name(struct dvb_usb_adapter *adap) 1024static int lme_name(struct dvb_usb_adapter *adap)
1026{ 1025{
1027 struct lme2510_state *st = adap->dev->priv; 1026 struct dvb_usb_device *d = adap_to_d(adap);
1028 const char *desc = adap->dev->desc->name; 1027 struct lme2510_state *st = adap_to_priv(adap);
1028 const char *desc = d->name;
1029 char *fe_name[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395", 1029 char *fe_name[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395",
1030 " SHARP:BS2F7HZ0194", " RS2000"}; 1030 " SHARP:BS2F7HZ0194", " RS2000"};
1031 char *name = adap->fe_adap[0].fe->ops.info.name; 1031 char *name = adap->fe[0]->ops.info.name;
1032 1032
1033 strlcpy(name, desc, 128); 1033 strlcpy(name, desc, 128);
1034 strlcat(name, fe_name[st->tuner_config], 128); 1034 strlcat(name, fe_name[st->tuner_config], 128);
@@ -1038,120 +1038,128 @@ static int lme_name(struct dvb_usb_adapter *adap)
1038 1038
1039static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) 1039static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap)
1040{ 1040{
1041 struct lme2510_state *st = adap->dev->priv; 1041 struct dvb_usb_device *d = adap_to_d(adap);
1042 1042 struct lme2510_state *st = d->priv;
1043 int ret = 0; 1043 int ret = 0;
1044 1044
1045 st->i2c_talk_onoff = 1; 1045 st->i2c_talk_onoff = 1;
1046 switch (le16_to_cpu(adap->dev->udev->descriptor.idProduct)) { 1046 switch (le16_to_cpu(d->udev->descriptor.idProduct)) {
1047 case 0x1122: 1047 case 0x1122:
1048 case 0x1120: 1048 case 0x1120:
1049 st->i2c_gate = 4; 1049 st->i2c_gate = 4;
1050 adap->fe_adap[0].fe = dvb_attach(tda10086_attach, 1050 adap->fe[0] = dvb_attach(tda10086_attach,
1051 &tda10086_config, &adap->dev->i2c_adap); 1051 &tda10086_config, &d->i2c_adap);
1052 if (adap->fe_adap[0].fe) { 1052 if (adap->fe[0]) {
1053 info("TUN Found Frontend TDA10086"); 1053 info("TUN Found Frontend TDA10086");
1054 st->i2c_tuner_gate_w = 4; 1054 st->i2c_tuner_gate_w = 4;
1055 st->i2c_tuner_gate_r = 4; 1055 st->i2c_tuner_gate_r = 4;
1056 st->i2c_tuner_addr = 0xc0; 1056 st->i2c_tuner_addr = 0xc0;
1057 st->tuner_config = TUNER_LG; 1057 st->tuner_config = TUNER_LG;
1058 if (dvb_usb_lme2510_firmware != TUNER_LG) { 1058 if (st->dvb_usb_lme2510_firmware != TUNER_LG) {
1059 dvb_usb_lme2510_firmware = TUNER_LG; 1059 st->dvb_usb_lme2510_firmware = TUNER_LG;
1060 ret = lme_firmware_switch(adap->dev->udev, 1); 1060 ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1061 } 1061 }
1062 break; 1062 break;
1063 } 1063 }
1064 1064
1065 st->i2c_gate = 4; 1065 st->i2c_gate = 4;
1066 adap->fe_adap[0].fe = dvb_attach(stv0299_attach, 1066 adap->fe[0] = dvb_attach(stv0299_attach,
1067 &sharp_z0194_config, &adap->dev->i2c_adap); 1067 &sharp_z0194_config, &d->i2c_adap);
1068 if (adap->fe_adap[0].fe) { 1068 if (adap->fe[0]) {
1069 info("FE Found Stv0299"); 1069 info("FE Found Stv0299");
1070 st->i2c_tuner_gate_w = 4; 1070 st->i2c_tuner_gate_w = 4;
1071 st->i2c_tuner_gate_r = 5; 1071 st->i2c_tuner_gate_r = 5;
1072 st->i2c_tuner_addr = 0xc0; 1072 st->i2c_tuner_addr = 0xc0;
1073 st->tuner_config = TUNER_S0194; 1073 st->tuner_config = TUNER_S0194;
1074 if (dvb_usb_lme2510_firmware != TUNER_S0194) { 1074 if (st->dvb_usb_lme2510_firmware != TUNER_S0194) {
1075 dvb_usb_lme2510_firmware = TUNER_S0194; 1075 st->dvb_usb_lme2510_firmware = TUNER_S0194;
1076 ret = lme_firmware_switch(adap->dev->udev, 1); 1076 ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1077 } 1077 }
1078 break; 1078 break;
1079 } 1079 }
1080 1080
1081 st->i2c_gate = 5; 1081 st->i2c_gate = 5;
1082 adap->fe_adap[0].fe = dvb_attach(stv0288_attach, &lme_config, 1082 adap->fe[0] = dvb_attach(stv0288_attach, &lme_config,
1083 &adap->dev->i2c_adap); 1083 &d->i2c_adap);
1084 1084
1085 if (adap->fe_adap[0].fe) { 1085 if (adap->fe[0]) {
1086 info("FE Found Stv0288"); 1086 info("FE Found Stv0288");
1087 st->i2c_tuner_gate_w = 4; 1087 st->i2c_tuner_gate_w = 4;
1088 st->i2c_tuner_gate_r = 5; 1088 st->i2c_tuner_gate_r = 5;
1089 st->i2c_tuner_addr = 0xc0; 1089 st->i2c_tuner_addr = 0xc0;
1090 st->tuner_config = TUNER_S7395; 1090 st->tuner_config = TUNER_S7395;
1091 if (dvb_usb_lme2510_firmware != TUNER_S7395) { 1091 if (st->dvb_usb_lme2510_firmware != TUNER_S7395) {
1092 dvb_usb_lme2510_firmware = TUNER_S7395; 1092 st->dvb_usb_lme2510_firmware = TUNER_S7395;
1093 ret = lme_firmware_switch(adap->dev->udev, 1); 1093 ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1094 } 1094 }
1095 break; 1095 break;
1096 } 1096 }
1097 case 0x22f0: 1097 case 0x22f0:
1098 st->i2c_gate = 5; 1098 st->i2c_gate = 5;
1099 adap->fe_adap[0].fe = dvb_attach(m88rs2000_attach, 1099 adap->fe[0] = dvb_attach(m88rs2000_attach,
1100 &m88rs2000_config, &adap->dev->i2c_adap); 1100 &m88rs2000_config, &d->i2c_adap);
1101 1101
1102 if (adap->fe_adap[0].fe) { 1102 if (adap->fe[0]) {
1103 info("FE Found M88RS2000"); 1103 info("FE Found M88RS2000");
1104 st->i2c_tuner_gate_w = 5; 1104 st->i2c_tuner_gate_w = 5;
1105 st->i2c_tuner_gate_r = 5; 1105 st->i2c_tuner_gate_r = 5;
1106 st->i2c_tuner_addr = 0xc0; 1106 st->i2c_tuner_addr = 0xc0;
1107 st->tuner_config = TUNER_RS2000; 1107 st->tuner_config = TUNER_RS2000;
1108 adap->fe_adap[0].fe->ops.read_signal_strength = 1108 st->fe_set_voltage =
1109 adap->fe[0]->ops.set_voltage;
1110
1111 adap->fe[0]->ops.read_signal_strength =
1109 dm04_rs2000_read_signal_strength; 1112 dm04_rs2000_read_signal_strength;
1110 adap->fe_adap[0].fe->ops.read_snr = 1113 adap->fe[0]->ops.read_snr =
1111 dm04_rs2000_read_snr; 1114 dm04_rs2000_read_snr;
1115 adap->fe[0]->ops.read_ber =
1116 dm04_read_ber;
1117 adap->fe[0]->ops.read_ucblocks =
1118 dm04_read_ucblocks;
1112 } 1119 }
1113 break; 1120 break;
1114 } 1121 }
1115 1122
1116 if (adap->fe_adap[0].fe == NULL) { 1123 if (adap->fe[0] == NULL) {
1117 info("DM04/QQBOX Not Powered up or not Supported"); 1124 info("DM04/QQBOX Not Powered up or not Supported");
1118 return -ENODEV; 1125 return -ENODEV;
1119 } 1126 }
1120 1127
1121 if (ret) { 1128 if (ret) {
1122 if (adap->fe_adap[0].fe) { 1129 if (adap->fe[0]) {
1123 dvb_frontend_detach(adap->fe_adap[0].fe); 1130 dvb_frontend_detach(adap->fe[0]);
1124 adap->fe_adap[0].fe = NULL; 1131 adap->fe[0] = NULL;
1125 } 1132 }
1126 adap->dev->props.rc.core.rc_codes = NULL; 1133 d->rc_map = NULL;
1127 return -ENODEV; 1134 return -ENODEV;
1128 } 1135 }
1129 1136
1130 adap->fe_adap[0].fe->ops.set_voltage = dm04_lme2510_set_voltage; 1137 adap->fe[0]->ops.set_voltage = dm04_lme2510_set_voltage;
1131 ret = lme_name(adap); 1138 ret = lme_name(adap);
1132 return ret; 1139 return ret;
1133} 1140}
1134 1141
1135static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap) 1142static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap)
1136{ 1143{
1137 struct lme2510_state *st = adap->dev->priv; 1144 struct dvb_usb_device *d = adap_to_d(adap);
1145 struct lme2510_state *st = adap_to_priv(adap);
1138 char *tun_msg[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA", "RS2000"}; 1146 char *tun_msg[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA", "RS2000"};
1139 int ret = 0; 1147 int ret = 0;
1140 1148
1141 switch (st->tuner_config) { 1149 switch (st->tuner_config) {
1142 case TUNER_LG: 1150 case TUNER_LG:
1143 if (dvb_attach(tda826x_attach, adap->fe_adap[0].fe, 0xc0, 1151 if (dvb_attach(tda826x_attach, adap->fe[0], 0xc0,
1144 &adap->dev->i2c_adap, 1)) 1152 &d->i2c_adap, 1))
1145 ret = st->tuner_config; 1153 ret = st->tuner_config;
1146 break; 1154 break;
1147 case TUNER_S7395: 1155 case TUNER_S7395:
1148 if (dvb_attach(ix2505v_attach , adap->fe_adap[0].fe, &lme_tuner, 1156 if (dvb_attach(ix2505v_attach , adap->fe[0], &lme_tuner,
1149 &adap->dev->i2c_adap)) 1157 &d->i2c_adap))
1150 ret = st->tuner_config; 1158 ret = st->tuner_config;
1151 break; 1159 break;
1152 case TUNER_S0194: 1160 case TUNER_S0194:
1153 if (dvb_attach(dvb_pll_attach , adap->fe_adap[0].fe, 0xc0, 1161 if (dvb_attach(dvb_pll_attach , adap->fe[0], 0xc0,
1154 &adap->dev->i2c_adap, DVB_PLL_OPERA1)) 1162 &d->i2c_adap, DVB_PLL_OPERA1))
1155 ret = st->tuner_config; 1163 ret = st->tuner_config;
1156 break; 1164 break;
1157 case TUNER_RS2000: 1165 case TUNER_RS2000:
@@ -1165,7 +1173,7 @@ static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap)
1165 info("TUN Found %s tuner", tun_msg[ret]); 1173 info("TUN Found %s tuner", tun_msg[ret]);
1166 else { 1174 else {
1167 info("TUN No tuner found --- resetting device"); 1175 info("TUN No tuner found --- resetting device");
1168 lme_coldreset(adap->dev->udev); 1176 lme_coldreset(d);
1169 return -ENODEV; 1177 return -ENODEV;
1170 } 1178 }
1171 1179
@@ -1201,158 +1209,57 @@ static int lme2510_powerup(struct dvb_usb_device *d, int onoff)
1201 return ret; 1209 return ret;
1202} 1210}
1203 1211
1204/* DVB USB Driver stuff */ 1212static int lme2510_get_adapter_count(struct dvb_usb_device *d)
1205static struct dvb_usb_device_properties lme2510_properties;
1206static struct dvb_usb_device_properties lme2510c_properties;
1207
1208static int lme2510_probe(struct usb_interface *intf,
1209 const struct usb_device_id *id)
1210{ 1213{
1211 struct usb_device *udev = interface_to_usbdev(intf); 1214 return 1;
1215}
1212 1216
1213 usb_reset_configuration(udev); 1217static int lme2510_identify_state(struct dvb_usb_device *d, const char **name)
1218{
1219 struct lme2510_state *st = d->priv;
1214 1220
1215 usb_set_interface(udev, intf->cur_altsetting->desc.bInterfaceNumber, 1); 1221 usb_reset_configuration(d->udev);
1216 1222
1217 if (udev->speed != USB_SPEED_HIGH) { 1223 usb_set_interface(d->udev,
1218 usb_reset_device(udev); 1224 d->intf->cur_altsetting->desc.bInterfaceNumber, 1);
1219 info("DEV Failed to connect in HIGH SPEED mode");
1220 return -ENODEV;
1221 }
1222 1225
1223 if (lme2510_return_status(udev) == 0x44) { 1226 st->dvb_usb_lme2510_firmware = dvb_usb_lme2510_firmware;
1224 lme_firmware_switch(udev, 0);
1225 return -ENODEV;
1226 }
1227 1227
1228 if (0 == dvb_usb_device_init(intf, &lme2510_properties, 1228 if (lme2510_return_status(d) == 0x44) {
1229 THIS_MODULE, NULL, adapter_nr)) { 1229 *name = lme_firmware_switch(d, 0);
1230 info("DEV registering device driver"); 1230 return COLD;
1231 return 0;
1232 }
1233 if (0 == dvb_usb_device_init(intf, &lme2510c_properties,
1234 THIS_MODULE, NULL, adapter_nr)) {
1235 info("DEV registering device driver");
1236 return 0;
1237 } 1231 }
1238 1232
1239 info("DEV lme2510 Error"); 1233 return 0;
1240 return -ENODEV;
1241
1242} 1234}
1243 1235
1244static struct usb_device_id lme2510_table[] = { 1236static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
1245 { USB_DEVICE(0x3344, 0x1122) }, /* LME2510 */ 1237 struct usb_data_stream_properties *stream)
1246 { USB_DEVICE(0x3344, 0x1120) }, /* LME2510C */ 1238{
1247 { USB_DEVICE(0x3344, 0x22f0) }, /* LME2510C RS2000 */ 1239 struct dvb_usb_adapter *adap = fe_to_adap(fe);
1248 {} /* Terminating entry */ 1240 struct dvb_usb_device *d = adap_to_d(adap);
1249};
1250
1251MODULE_DEVICE_TABLE(usb, lme2510_table);
1252
1253static struct dvb_usb_device_properties lme2510_properties = {
1254 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1255 .size_of_priv = sizeof(struct lme2510_state),
1256 .num_adapters = 1,
1257 .adapter = {
1258 {
1259 .num_frontends = 1,
1260 .fe = {{
1261 .caps = DVB_USB_ADAP_HAS_PID_FILTER|
1262 DVB_USB_ADAP_NEED_PID_FILTERING|
1263 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1264 .streaming_ctrl = lme2510_streaming_ctrl,
1265 .pid_filter_count = 32,
1266 .pid_filter = lme2510_pid_filter,
1267 .pid_filter_ctrl = lme2510_pid_filter_ctrl,
1268 .frontend_attach = dm04_lme2510_frontend_attach,
1269 .tuner_attach = dm04_lme2510_tuner,
1270 /* parameter for the MPEG2-data transfer */
1271 .stream = {
1272 .type = USB_BULK,
1273 .count = 10,
1274 .endpoint = 0x06,
1275 .u = {
1276 .bulk = {
1277 .buffersize = 4096,
1278
1279 }
1280 }
1281 }
1282 }},
1283 }
1284 },
1285 .rc.core = {
1286 .protocol = RC_TYPE_NEC,
1287 .module_name = "LME2510 Remote Control",
1288 .allowed_protos = RC_TYPE_NEC,
1289 .rc_codes = RC_MAP_LME2510,
1290 },
1291 .power_ctrl = lme2510_powerup,
1292 .identify_state = lme2510_identify_state,
1293 .i2c_algo = &lme2510_i2c_algo,
1294 .generic_bulk_ctrl_endpoint = 0,
1295 .num_device_descs = 1,
1296 .devices = {
1297 { "DM04_LME2510_DVB-S",
1298 { &lme2510_table[0], NULL },
1299 },
1300 1241
1242 if (adap == NULL)
1243 return 0;
1244 /* Turn PID filter on the fly by module option */
1245 if (pid_filter == 2) {
1246 adap->pid_filtering = 1;
1247 adap->max_feed_count = 15;
1301 } 1248 }
1302};
1303 1249
1304static struct dvb_usb_device_properties lme2510c_properties = { 1250 if (!(le16_to_cpu(d->udev->descriptor.idProduct)
1305 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1251 == 0x1122))
1306 .size_of_priv = sizeof(struct lme2510_state), 1252 stream->endpoint = 0x8;
1307 .num_adapters = 1,
1308 .adapter = {
1309 {
1310 .num_frontends = 1,
1311 .fe = {{
1312 .caps = DVB_USB_ADAP_HAS_PID_FILTER|
1313 DVB_USB_ADAP_NEED_PID_FILTERING|
1314 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1315 .streaming_ctrl = lme2510_streaming_ctrl,
1316 .pid_filter_count = 32,
1317 .pid_filter = lme2510_pid_filter,
1318 .pid_filter_ctrl = lme2510_pid_filter_ctrl,
1319 .frontend_attach = dm04_lme2510_frontend_attach,
1320 .tuner_attach = dm04_lme2510_tuner,
1321 /* parameter for the MPEG2-data transfer */
1322 .stream = {
1323 .type = USB_BULK,
1324 .count = 10,
1325 .endpoint = 0x8,
1326 .u = {
1327 .bulk = {
1328 .buffersize = 4096,
1329 1253
1330 } 1254 return 0;
1331 } 1255}
1332 } 1256
1333 }}, 1257static int lme2510_get_rc_config(struct dvb_usb_device *d,
1334 } 1258 struct dvb_usb_rc *rc)
1335 }, 1259{
1336 .rc.core = { 1260 rc->allowed_protos = RC_TYPE_NEC;
1337 .protocol = RC_TYPE_NEC, 1261 return 0;
1338 .module_name = "LME2510 Remote Control", 1262}
1339 .allowed_protos = RC_TYPE_NEC,
1340 .rc_codes = RC_MAP_LME2510,
1341 },
1342 .power_ctrl = lme2510_powerup,
1343 .identify_state = lme2510_identify_state,
1344 .i2c_algo = &lme2510_i2c_algo,
1345 .generic_bulk_ctrl_endpoint = 0,
1346 .num_device_descs = 2,
1347 .devices = {
1348 { "DM04_LME2510C_DVB-S",
1349 { &lme2510_table[1], NULL },
1350 },
1351 { "DM04_LME2510C_DVB-S RS2000",
1352 { &lme2510_table[2], NULL },
1353 },
1354 }
1355};
1356 1263
1357static void *lme2510_exit_int(struct dvb_usb_device *d) 1264static void *lme2510_exit_int(struct dvb_usb_device *d)
1358{ 1265{
@@ -1361,8 +1268,7 @@ static void *lme2510_exit_int(struct dvb_usb_device *d)
1361 void *buffer = NULL; 1268 void *buffer = NULL;
1362 1269
1363 if (adap != NULL) { 1270 if (adap != NULL) {
1364 lme2510_kill_urb(&adap->fe_adap[0].stream); 1271 lme2510_kill_urb(&adap->stream);
1365 adap->feedcount = 0;
1366 } 1272 }
1367 1273
1368 if (st->usb_buffer != NULL) { 1274 if (st->usb_buffer != NULL) {
@@ -1383,29 +1289,85 @@ static void *lme2510_exit_int(struct dvb_usb_device *d)
1383 return buffer; 1289 return buffer;
1384} 1290}
1385 1291
1386static void lme2510_exit(struct usb_interface *intf) 1292static void lme2510_exit(struct dvb_usb_device *d)
1387{ 1293{
1388 struct dvb_usb_device *d = usb_get_intfdata(intf);
1389 void *usb_buffer; 1294 void *usb_buffer;
1390 1295
1391 if (d != NULL) { 1296 if (d != NULL) {
1392 usb_buffer = lme2510_exit_int(d); 1297 usb_buffer = lme2510_exit_int(d);
1393 dvb_usb_device_exit(intf);
1394 if (usb_buffer != NULL) 1298 if (usb_buffer != NULL)
1395 kfree(usb_buffer); 1299 kfree(usb_buffer);
1396 } 1300 }
1397} 1301}
1398 1302
1303static struct dvb_usb_device_properties lme2510_props = {
1304 .driver_name = KBUILD_MODNAME,
1305 .owner = THIS_MODULE,
1306 .bInterfaceNumber = 0,
1307 .adapter_nr = adapter_nr,
1308 .size_of_priv = sizeof(struct lme2510_state),
1309
1310 .download_firmware = lme2510_download_firmware,
1311
1312 .power_ctrl = lme2510_powerup,
1313 .identify_state = lme2510_identify_state,
1314 .i2c_algo = &lme2510_i2c_algo,
1315
1316 .frontend_attach = dm04_lme2510_frontend_attach,
1317 .tuner_attach = dm04_lme2510_tuner,
1318 .get_stream_config = lme2510_get_stream_config,
1319 .get_adapter_count = lme2510_get_adapter_count,
1320 .streaming_ctrl = lme2510_streaming_ctrl,
1321
1322 .get_rc_config = lme2510_get_rc_config,
1323
1324 .exit = lme2510_exit,
1325 .adapter = {
1326 {
1327 .caps = DVB_USB_ADAP_HAS_PID_FILTER|
1328 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1329 .pid_filter_count = 15,
1330 .pid_filter = lme2510_pid_filter,
1331 .pid_filter_ctrl = lme2510_pid_filter_ctrl,
1332 .stream =
1333 DVB_USB_STREAM_BULK(0x86, 10, 4096),
1334 },
1335 {
1336 }
1337 },
1338};
1339
1340static const struct usb_device_id lme2510_id_table[] = {
1341 { DVB_USB_DEVICE(0x3344, 0x1122, &lme2510_props,
1342 "DM04_LME2510_DVB-S", RC_MAP_LME2510) },
1343 { DVB_USB_DEVICE(0x3344, 0x1120, &lme2510_props,
1344 "DM04_LME2510C_DVB-S", RC_MAP_LME2510) },
1345 { DVB_USB_DEVICE(0x3344, 0x22f0, &lme2510_props,
1346 "DM04_LME2510C_DVB-S RS2000", RC_MAP_LME2510) },
1347 {} /* Terminating entry */
1348};
1349
1350MODULE_DEVICE_TABLE(usb, lme2510_id_table);
1351
1399static struct usb_driver lme2510_driver = { 1352static struct usb_driver lme2510_driver = {
1400 .name = "LME2510C_DVB-S", 1353 .name = KBUILD_MODNAME,
1401 .probe = lme2510_probe, 1354 .probe = dvb_usbv2_probe,
1402 .disconnect = lme2510_exit, 1355 .disconnect = dvb_usbv2_disconnect,
1403 .id_table = lme2510_table, 1356 .id_table = lme2510_id_table,
1357 .no_dynamic_id = 1,
1358 .soft_unbind = 1,
1404}; 1359};
1405 1360
1406module_usb_driver(lme2510_driver); 1361module_usb_driver(lme2510_driver);
1407 1362
1408MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>"); 1363MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1409MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0"); 1364MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0");
1410MODULE_VERSION("1.99"); 1365MODULE_VERSION("2.06");
1411MODULE_LICENSE("GPL"); 1366MODULE_LICENSE("GPL");
1367MODULE_FIRMWARE(LME2510_C_S7395);
1368MODULE_FIRMWARE(LME2510_C_LG);
1369MODULE_FIRMWARE(LME2510_C_S0194);
1370MODULE_FIRMWARE(LME2510_C_RS2000);
1371MODULE_FIRMWARE(LME2510_LG);
1372MODULE_FIRMWARE(LME2510_S0194);
1373