lmedm04.c 30.8 KB
Newer Older
1 2 3
/* DVB USB compliant linux driver for
 *
 * 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 10 11
 *
 * MVB7395 (LME2510C+SHARP:BS2F7HZ7395)
 * SHARP:BS2F7HZ7395 = (STV0288+Sharp IX2505V)
 *
12
 * MV001F (LME2510+LGTDQY-P001F)
13 14
 * LG TDQY - P001F =(TDA8263 + TDA10086H)
 *
15 16
 * MVB0001F (LME2510C+LGTDQT-P001F)
 *
17 18 19 20 21
 * MV0194 (LME2510+SHARP:BS2F7HZ0194)
 * SHARP:BS2F7HZ0194 = (STV0299+IX2410)
 *
 * MVB0194 (LME2510C+SHARP0194)
 *
22 23
 * LME2510C + M88RS2000
 *
24 25 26 27 28
 * For firmware see Documentation/dvb/lmedm04.txt
 *
 * I2C addresses:
 * 0xd0 - STV0288	- Demodulator
 * 0xc0 - Sharp IX2505V	- Tuner
29
 * --
30 31
 * 0x1c - TDA10086   - Demodulator
 * 0xc0 - TDA8263    - Tuner
32 33 34
 * --
 * 0xd0 - STV0299	- Demodulator
 * 0xc0 - IX2410	- Tuner
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
 *
 *
 * VID = 3344  PID LME2510=1122 LME2510C=1120
 *
 * Copyright (C) 2010 Malcolm Priestley (tvboxspy@gmail.com)
 * LME2510(C)(C) Leaguerme (Shenzhen) MicroElectronics Co., Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2, as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 * see Documentation/dvb/README.dvb-usb for more information
 *
 * Known Issues :
 *	LME2510: Non Intel USB chipsets fail to maintain High Speed on
 * Boot or Hot Plug.
 *
62
 * QQbox suffers from noise on LNB voltage.
63
 *
64 65 66
 *	LME2510: SHARP:BS2F7HZ0194(MV0194) cannot cold reset and share system
 * with other tuners. After a cold reset streaming will not start.
 *
67
 * M88RS2000 suffers from loss of lock.
68 69 70 71
 */
#define DVB_USB_LOG_PREFIX "LME2510(C)"
#include <linux/usb.h>
#include <linux/usb/input.h>
72
#include <media/rc-core.h>
73

74
#include "dvb_usb.h"
75 76 77 78 79
#include "lmedm04.h"
#include "tda826x.h"
#include "tda10086.h"
#include "stv0288.h"
#include "ix2505v.h"
80 81 82
#include "stv0299.h"
#include "dvb-pll.h"
#include "z0194a.h"
83
#include "m88rs2000.h"
84
#include "ts2020.h"
85 86


87 88 89 90 91 92
#define LME2510_C_S7395	"dvb-usb-lme2510c-s7395.fw";
#define LME2510_C_LG	"dvb-usb-lme2510c-lg.fw";
#define LME2510_C_S0194	"dvb-usb-lme2510c-s0194.fw";
#define LME2510_C_RS2000 "dvb-usb-lme2510c-rs2000.fw";
#define LME2510_LG	"dvb-usb-lme2510-lg.fw";
#define LME2510_S0194	"dvb-usb-lme2510-s0194.fw";
93 94 95

/* debug */
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 102 103 104
#define debug_data_snipet(level, name, p) \
	 deb_info(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
		*p, *(p+1), *(p+2), *(p+3), *(p+4), \
			*(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 111 112 113
static int dvb_usb_lme2510_firmware;
module_param_named(firmware, dvb_usb_lme2510_firmware, int, 0644);
MODULE_PARM_DESC(firmware, "set default firmware 0=Sharp7395 1=LG");

114 115
static int pid_filter;
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 123
#define TUNER_LG	0x1
#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 130 131 132 133 134 135 136 137 138 139
	u8 id;
	u8 tuner_config;
	u8 signal_lock;
	u8 signal_level;
	u8 signal_sn;
	u8 time_key;
	u8 i2c_talk_onoff;
	u8 i2c_gate;
	u8 i2c_tuner_gate_w;
	u8 i2c_tuner_gate_r;
	u8 i2c_tuner_addr;
140
	u8 stream_on;
141
	u8 pid_size;
142
	u8 pid_off;
143 144 145
	void *buffer;
	struct urb *lme_urb;
	void *usb_buffer;
146 147
	int (*fe_set_voltage)(struct dvb_frontend *, fe_sec_voltage_t);
	u8 dvb_usb_lme2510_firmware;
148 149 150 151 152 153
};

static int lme2510_bulk_write(struct usb_device *dev,
				u8 *snd, int len, u8 pipe)
{
	int ret, actual_l;
154

155
	ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe),
156
				snd, len , &actual_l, 100);
157 158 159 160 161 162 163 164 165
	return ret;
}

static int lme2510_bulk_read(struct usb_device *dev,
				u8 *rev, int len, u8 pipe)
{
	int ret, actual_l;

	ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe),
166
				 rev, len , &actual_l, 200);
167 168 169 170 171 172 173 174 175 176 177
	return ret;
}

static int lme2510_usb_talk(struct dvb_usb_device *d,
		u8 *wbuf, int wlen, u8 *rbuf, int rlen)
{
	struct lme2510_state *st = d->priv;
	u8 *buff;
	int ret = 0;

	if (st->usb_buffer == NULL) {
178
		st->usb_buffer = kmalloc(64, GFP_KERNEL);
179 180 181 182 183 184 185 186 187 188 189 190
		if (st->usb_buffer == NULL) {
			info("MEM Error no memory");
			return -ENOMEM;
		}
	}
	buff = st->usb_buffer;

	ret = mutex_lock_interruptible(&d->usb_mutex);

	if (ret < 0)
		return -EAGAIN;

191 192
	/* the read/write capped at 64 */
	memcpy(buff, wbuf, (wlen < 64) ? wlen : 64);
193

194 195
	ret |= lme2510_bulk_write(d->udev, buff, wlen , 0x01);

196 197
	ret |= lme2510_bulk_read(d->udev, buff, (rlen < 64) ?
			rlen : 64 , 0x01);
198 199 200 201 202 203 204 205 206

	if (rlen > 0)
		memcpy(rbuf, buff, rlen);

	mutex_unlock(&d->usb_mutex);

	return (ret < 0) ? -ENODEV : 0;
}

207 208
static int lme2510_stream_restart(struct dvb_usb_device *d)
{
209 210 211
	struct lme2510_state *st = d->priv;
	u8 all_pids[] = LME_ALL_PIDS;
	u8 stream_on[] = LME_ST_ON_W;
212
	int ret;
213 214 215 216
	u8 rbuff[1];
	if (st->pid_off)
		ret = lme2510_usb_talk(d, all_pids, sizeof(all_pids),
			rbuff, sizeof(rbuff));
217
	/*Restart Stream Command*/
218
	ret = lme2510_usb_talk(d, stream_on, sizeof(stream_on),
219 220 221
			rbuff, sizeof(rbuff));
	return ret;
}
222

223 224 225 226 227 228
static int lme2510_enable_pid(struct dvb_usb_device *d, u8 index, u16 pid_out)
{
	struct lme2510_state *st = d->priv;
	static u8 pid_buff[] = LME_ZERO_PID;
	static u8 rbuf[1];
	u8 pid_no = index * 2;
229
	u8 pid_len = pid_no + 2;
230 231 232
	int ret = 0;
	deb_info(1, "PID Setting Pid %04x", pid_out);

233 234 235
	if (st->pid_size == 0)
		ret |= lme2510_stream_restart(d);

236 237 238 239 240
	pid_buff[2] = pid_no;
	pid_buff[3] = (u8)pid_out & 0xff;
	pid_buff[4] = pid_no + 1;
	pid_buff[5] = (u8)(pid_out >> 8);

241 242 243
	if (pid_len > st->pid_size)
		st->pid_size = pid_len;
	pid_buff[7] = 0x80 + st->pid_size;
244 245 246 247

	ret |= lme2510_usb_talk(d, pid_buff ,
		sizeof(pid_buff) , rbuf, sizeof(rbuf));

248
	if (st->stream_on)
249 250 251 252 253
		ret |= lme2510_stream_restart(d);

	return ret;
}

254 255 256
static void lme2510_int_response(struct urb *lme_urb)
{
	struct dvb_usb_adapter *adap = lme_urb->context;
257
	struct lme2510_state *st = adap_to_priv(adap);
258 259
	static u8 *ibuf, *rbuf;
	int i = 0, offset;
260
	u32 key;
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286

	switch (lme_urb->status) {
	case 0:
	case -ETIMEDOUT:
		break;
	case -ECONNRESET:
	case -ENOENT:
	case -ESHUTDOWN:
		return;
	default:
		info("Error %x", lme_urb->status);
		break;
	}

	rbuf = (u8 *) lme_urb->transfer_buffer;

	offset = ((lme_urb->actual_length/8) > 4)
			? 4 : (lme_urb->actual_length/8) ;

	for (i = 0; i < offset; ++i) {
		ibuf = (u8 *)&rbuf[i*8];
		deb_info(5, "INT O/S C =%02x C/O=%02x Type =%02x%02x",
		offset, i, ibuf[0], ibuf[1]);

		switch (ibuf[0]) {
		case 0xaa:
287 288
			debug_data_snipet(1, "INT Remote data snipet", ibuf);
			if ((ibuf[4] + ibuf[5]) == 0xff) {
289 290 291
				key = RC_SCANCODE_NECX((ibuf[2] ^ 0xff) << 8 |
						       (ibuf[3] > 0) ? (ibuf[3] ^ 0xff) : 0,
						       ibuf[5]);
292
				deb_info(1, "INT Key =%08x", key);
293 294
				if (adap_to_d(adap)->rc_dev != NULL)
					rc_keydown(adap_to_d(adap)->rc_dev,
295
						   RC_TYPE_NEC, key, 0);
296
			}
297 298 299 300
			break;
		case 0xbb:
			switch (st->tuner_config) {
			case TUNER_LG:
301 302
				if (ibuf[2] > 0)
					st->signal_lock = ibuf[2];
303 304 305 306 307
				st->signal_level = ibuf[4];
				st->signal_sn = ibuf[3];
				st->time_key = ibuf[7];
				break;
			case TUNER_S7395:
308
			case TUNER_S0194:
309 310
				/* Tweak for earlier firmware*/
				if (ibuf[1] == 0x03) {
311 312
					if (ibuf[2] > 1)
						st->signal_lock = ibuf[2];
313
					st->signal_level = ibuf[3];
314
					st->signal_sn = ibuf[4];
315 316 317
				} else {
					st->signal_level = ibuf[4];
					st->signal_sn = ibuf[5];
318 319 320
					st->signal_lock =
						(st->signal_lock & 0xf7) +
						((ibuf[2] & 0x01) << 0x03);
321 322
				}
				break;
323
			case TUNER_RS2000:
324
				if (ibuf[2] & 0x1)
325 326
					st->signal_lock = 0xff;
				else
327 328 329
					st->signal_lock = 0x00;
				st->signal_level = ibuf[5];
				st->signal_sn = ibuf[4];
330
				st->time_key = ibuf[7];
331 332 333 334 335 336 337 338 339 340 341 342 343
			default:
				break;
			}
			debug_data_snipet(5, "INT Remote data snipet in", ibuf);
		break;
		case 0xcc:
			debug_data_snipet(1, "INT Control data snipet", ibuf);
			break;
		default:
			debug_data_snipet(1, "INT Unknown data snipet", ibuf);
		break;
		}
	}
344

345
	usb_submit_urb(lme_urb, GFP_ATOMIC);
346 347 348 349

	/* interrupt urb is due every 48 msecs while streaming
	 *	add 12msecs for system lag */
	st->int_urb_due = jiffies + msecs_to_jiffies(60);
350 351 352 353
}

static int lme2510_int_read(struct dvb_usb_adapter *adap)
{
354 355
	struct dvb_usb_device *d = adap_to_d(adap);
	struct lme2510_state *lme_int = adap_to_priv(adap);
356 357 358 359 360 361

	lme_int->lme_urb = usb_alloc_urb(0, GFP_ATOMIC);

	if (lme_int->lme_urb == NULL)
			return -ENOMEM;

362
	lme_int->buffer = usb_alloc_coherent(d->udev, 128, GFP_ATOMIC,
363 364 365 366 367 368
					&lme_int->lme_urb->transfer_dma);

	if (lme_int->buffer == NULL)
			return -ENOMEM;

	usb_fill_int_urb(lme_int->lme_urb,
369 370
				d->udev,
				usb_rcvintpipe(d->udev, 0xa),
371
				lme_int->buffer,
372
				128,
373 374
				lme2510_int_response,
				adap,
375
				8);
376 377 378 379

	lme_int->lme_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;

	usb_submit_urb(lme_int->lme_urb, GFP_ATOMIC);
L
Lucas De Marchi 已提交
380
	info("INT Interrupt Service Started");
381 382 383 384

	return 0;
}

385 386
static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
{
387 388
	struct dvb_usb_device *d = adap_to_d(adap);
	struct lme2510_state *st = adap_to_priv(adap);
389
	static u8 clear_pid_reg[] = LME_ALL_PIDS;
390
	static u8 rbuf[1];
391
	int ret = 0;
392 393 394

	deb_info(1, "PID Clearing Filter");

395
	mutex_lock(&d->i2c_mutex);
396

397
	if (!onoff) {
398
		ret |= lme2510_usb_talk(d, clear_pid_reg,
399
			sizeof(clear_pid_reg), rbuf, sizeof(rbuf));
400 401 402
		st->pid_off = true;
	} else
		st->pid_off = false;
403

404 405
	st->pid_size = 0;

406
	mutex_unlock(&d->i2c_mutex);
407 408 409 410 411 412 413

	return 0;
}

static int lme2510_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
	int onoff)
{
414
	struct dvb_usb_device *d = adap_to_d(adap);
415 416 417 418 419
	int ret = 0;

	deb_info(3, "%s PID=%04x Index=%04x onoff=%02x", __func__,
		pid, index, onoff);

420
	if (onoff) {
421 422 423
		mutex_lock(&d->i2c_mutex);
		ret |= lme2510_enable_pid(d, index, pid);
		mutex_unlock(&d->i2c_mutex);
424 425
	}

426 427 428 429 430

	return ret;
}


431
static int lme2510_return_status(struct dvb_usb_device *d)
432 433
{
	int ret = 0;
434 435 436 437 438
	u8 *data;

	data = kzalloc(10, GFP_KERNEL);
	if (!data)
		return -ENOMEM;
439

440
	ret |= usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
441 442 443
			0x06, 0x80, 0x0302, 0x00, data, 0x0006, 200);
	info("Firmware Status: %x (%x)", ret , data[2]);

444 445 446
	ret = (ret < 0) ? -ENODEV : data[2];
	kfree(data);
	return ret;
447 448 449 450 451 452 453 454
}

static int lme2510_msg(struct dvb_usb_device *d,
		u8 *wbuf, int wlen, u8 *rbuf, int rlen)
{
	int ret = 0;
	struct lme2510_state *st = d->priv;

455 456
	if (st->i2c_talk_onoff == 1) {

457 458 459
		ret = lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);

		switch (st->tuner_config) {
460 461 462 463 464 465
		case TUNER_LG:
			if (wbuf[2] == 0x1c) {
				if (wbuf[3] == 0x0e) {
					st->signal_lock = rbuf[1];
					if ((st->stream_on & 1) &&
						(st->signal_lock & 0x10)) {
466
						lme2510_stream_restart(d);
467 468
						st->i2c_talk_onoff = 0;
					}
469
					msleep(80);
470 471 472
				}
			}
			break;
473
		case TUNER_S7395:
474 475 476 477 478
			if (wbuf[2] == 0xd0) {
				if (wbuf[3] == 0x24) {
					st->signal_lock = rbuf[1];
					if ((st->stream_on & 1) &&
						(st->signal_lock & 0x8)) {
479
						lme2510_stream_restart(d);
480 481 482 483
						st->i2c_talk_onoff = 0;
					}
				}
			}
484
			break;
485 486 487 488 489 490 491 492 493 494 495 496
		case TUNER_S0194:
			if (wbuf[2] == 0xd0) {
				if (wbuf[3] == 0x1b) {
					st->signal_lock = rbuf[1];
					if ((st->stream_on & 1) &&
						(st->signal_lock & 0x8)) {
						lme2510_stream_restart(d);
						st->i2c_talk_onoff = 0;
					}
				}
			}
			break;
497
		case TUNER_RS2000:
498 499 500 501
		default:
			break;
		}
	} else {
502
		/* TODO rewrite this section */
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
		switch (st->tuner_config) {
		case TUNER_LG:
			switch (wbuf[3]) {
			case 0x0e:
				rbuf[0] = 0x55;
				rbuf[1] = st->signal_lock;
				break;
			case 0x43:
				rbuf[0] = 0x55;
				rbuf[1] = st->signal_level;
				break;
			case 0x1c:
				rbuf[0] = 0x55;
				rbuf[1] = st->signal_sn;
				break;
518 519 520 521 522 523 524
			case 0x15:
			case 0x16:
			case 0x17:
			case 0x18:
				rbuf[0] = 0x55;
				rbuf[1] = 0x00;
				break;
525
			default:
526 527
				lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
				st->i2c_talk_onoff = 1;
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
				break;
			}
			break;
		case TUNER_S7395:
			switch (wbuf[3]) {
			case 0x10:
				rbuf[0] = 0x55;
				rbuf[1] = (st->signal_level & 0x80)
						? 0 : (st->signal_level * 2);
				break;
			case 0x2d:
				rbuf[0] = 0x55;
				rbuf[1] = st->signal_sn;
				break;
			case 0x24:
				rbuf[0] = 0x55;
544
				rbuf[1] = st->signal_lock;
545
				break;
546 547 548
			case 0x2e:
			case 0x26:
			case 0x27:
549 550
				rbuf[0] = 0x55;
				rbuf[1] = 0x00;
551
				break;
552 553 554 555
			default:
				lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
				st->i2c_talk_onoff = 1;
				break;
556 557
			}
			break;
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585
		case TUNER_S0194:
			switch (wbuf[3]) {
			case 0x18:
				rbuf[0] = 0x55;
				rbuf[1] = (st->signal_level & 0x80)
						? 0 : (st->signal_level * 2);
				break;
			case 0x24:
				rbuf[0] = 0x55;
				rbuf[1] = st->signal_sn;
				break;
			case 0x1b:
				rbuf[0] = 0x55;
				rbuf[1] = st->signal_lock;
				break;
			case 0x19:
			case 0x25:
			case 0x1e:
			case 0x1d:
				rbuf[0] = 0x55;
				rbuf[1] = 0x00;
				break;
			default:
				lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
				st->i2c_talk_onoff = 1;
				break;
			}
			break;
586 587 588 589
		case TUNER_RS2000:
			switch (wbuf[3]) {
			case 0x8c:
				rbuf[0] = 0x55;
590 591 592 593 594 595 596
				rbuf[1] = st->signal_lock;

				/* If int_urb_due overdue
				 *  set rbuf[1] to 0 to clear lock */
				if (time_after(jiffies,	st->int_urb_due))
					rbuf[1] = 0;

597 598 599 600 601 602
				break;
			default:
				lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen);
				st->i2c_talk_onoff = 1;
				break;
			}
603 604 605 606
		default:
			break;
		}

L
Lucas De Marchi 已提交
607
		deb_info(4, "I2C From Interrupt Message out(%02x) in(%02x)",
608 609 610 611 612 613 614 615 616 617 618 619 620
				wbuf[3], rbuf[1]);

	}

	return ret;
}


static int lme2510_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
				 int num)
{
	struct dvb_usb_device *d = i2c_get_adapdata(adap);
	struct lme2510_state *st = d->priv;
621
	static u8 obuf[64], ibuf[64];
622 623 624 625
	int i, read, read_o;
	u16 len;
	u8 gate = st->i2c_gate;

626 627
	mutex_lock(&d->i2c_mutex);

628 629 630 631
	if (gate == 0)
		gate = 5;

	for (i = 0; i < num; i++) {
632 633
		read_o = msg[i].flags & I2C_M_RD;
		read = i + 1 < num && msg[i + 1].flags & I2C_M_RD;
634 635 636 637 638 639 640 641 642 643 644 645
		read |= read_o;
		gate = (msg[i].addr == st->i2c_tuner_addr)
			? (read)	? st->i2c_tuner_gate_r
					: st->i2c_tuner_gate_w
			: st->i2c_gate;
		obuf[0] = gate | (read << 7);

		if (gate == 5)
			obuf[1] = (read) ? 2 : msg[i].len + 1;
		else
			obuf[1] = msg[i].len + read + 1;

646 647
		obuf[2] = msg[i].addr << 1;

648 649 650 651 652 653 654 655 656 657 658 659 660
		if (read) {
			if (read_o)
				len = 3;
			else {
				memcpy(&obuf[3], msg[i].buf, msg[i].len);
				obuf[msg[i].len+3] = msg[i+1].len;
				len = msg[i].len+4;
			}
		} else {
			memcpy(&obuf[3], msg[i].buf, msg[i].len);
			len = msg[i].len+3;
		}

661
		if (lme2510_msg(d, obuf, len, ibuf, 64) < 0) {
662
			deb_info(1, "i2c transfer failed.");
663
			mutex_unlock(&d->i2c_mutex);
664 665 666 667 668 669 670 671 672 673 674 675
			return -EAGAIN;
		}

		if (read) {
			if (read_o)
				memcpy(msg[i].buf, &ibuf[1], msg[i].len);
			else {
				memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
				i++;
			}
		}
	}
676 677

	mutex_unlock(&d->i2c_mutex);
678 679 680 681 682 683 684 685 686 687 688 689 690
	return i;
}

static u32 lme2510_i2c_func(struct i2c_adapter *adapter)
{
	return I2C_FUNC_I2C;
}

static struct i2c_algorithm lme2510_i2c_algo = {
	.master_xfer   = lme2510_i2c_xfer,
	.functionality = lme2510_i2c_func,
};

691
static int lme2510_streaming_ctrl(struct dvb_frontend *fe, int onoff)
692
{
693 694 695
	struct dvb_usb_adapter *adap = fe_to_adap(fe);
	struct dvb_usb_device *d = adap_to_d(adap);
	struct lme2510_state *st = adap_to_priv(adap);
696
	static u8 clear_reg_3[] = LME_ALL_PIDS;
697
	static u8 rbuf[1];
698
	int ret = 0, rlen = sizeof(rbuf);
699 700 701

	deb_info(1, "STM  (%02x)", onoff);

702 703
	/* Streaming is started by FE_HAS_LOCK */
	if (onoff == 1)
704
		st->stream_on = 1;
705
	else {
706
		deb_info(1, "STM Steam Off");
707
		/* mutex is here only to avoid collision with I2C */
708
		mutex_lock(&d->i2c_mutex);
709

710
		ret = lme2510_usb_talk(d, clear_reg_3,
711
				sizeof(clear_reg_3), rbuf, rlen);
712
		st->stream_on = 0;
713
		st->i2c_talk_onoff = 1;
714

715
		mutex_unlock(&d->i2c_mutex);
716 717 718 719 720 721 722 723 724 725 726 727 728
	}

	return (ret < 0) ? -ENODEV : 0;
}

static u8 check_sum(u8 *p, u8 len)
{
	u8 sum = 0;
	while (len--)
		sum += *p++;
	return sum;
}

729
static int lme2510_download_firmware(struct dvb_usb_device *d,
730 731 732
					const struct firmware *fw)
{
	int ret = 0;
733
	u8 *data;
734 735 736 737 738 739 740
	u16 j, wlen, len_in, start, end;
	u8 packet_size, dlen, i;
	u8 *fw_data;

	packet_size = 0x31;
	len_in = 1;

741
	data = kzalloc(128, GFP_KERNEL);
742
	if (!data) {
743 744
		info("FRM Could not start Firmware Download"\
			"(Buffer allocation failed)");
745 746
		return -ENOMEM;
	}
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761

	info("FRM Starting Firmware Download");

	for (i = 1; i < 3; i++) {
		start = (i == 1) ? 0 : 512;
		end = (i == 1) ? 512 : fw->size;
		for (j = start; j < end; j += (packet_size+1)) {
			fw_data = (u8 *)(fw->data + j);
			if ((end - j) > packet_size) {
				data[0] = i;
				dlen = packet_size;
			} else {
				data[0] = i | 0x80;
				dlen = (u8)(end - j)-1;
			}
762 763 764 765 766
			data[1] = dlen;
			memcpy(&data[2], fw_data, dlen+1);
			wlen = (u8) dlen + 4;
			data[wlen-1] = check_sum(fw_data, dlen+1);
			deb_info(1, "Data S=%02x:E=%02x CS= %02x", data[3],
767
				data[dlen+2], data[dlen+3]);
768
			lme2510_usb_talk(d, data, wlen, data, len_in);
769
			ret |= (data[0] == 0x88) ? 0 : -1;
770 771
		}
	}
772

773 774 775
	data[0] = 0x8a;
	len_in = 1;
	msleep(2000);
776
	lme2510_usb_talk(d, data, len_in, data, len_in);
777 778 779 780 781 782 783
	msleep(400);

	if (ret < 0)
		info("FRM Firmware Download Failed (%04x)" , ret);
	else
		info("FRM Firmware Download Completed - Resetting Device");

784
	kfree(data);
785
	return RECONNECTS_USB;
786 787
}

788
static void lme_coldreset(struct dvb_usb_device *d)
789
{
790
	u8 data[1] = {0};
791 792
	data[0] = 0x0a;
	info("FRM Firmware Cold Reset");
793 794

	lme2510_usb_talk(d, data, sizeof(data), data, sizeof(data));
795

796 797 798
	return;
}

799 800 801 802 803 804 805
static const char fw_c_s7395[] = LME2510_C_S7395;
static const char fw_c_lg[] = LME2510_C_LG;
static const char fw_c_s0194[] = LME2510_C_S0194;
static const char fw_c_rs2000[] = LME2510_C_RS2000;
static const char fw_lg[] = LME2510_LG;
static const char fw_s0194[] = LME2510_S0194;

806
static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
807
{
808 809
	struct lme2510_state *st = d->priv;
	struct usb_device *udev = d->udev;
810
	const struct firmware *fw = NULL;
811
	const char *fw_lme;
812
	int ret = 0;
813

814 815
	cold = (cold > 0) ? (cold & 1) : 0;

816 817
	switch (le16_to_cpu(udev->descriptor.idProduct)) {
	case 0x1122:
818
		switch (st->dvb_usb_lme2510_firmware) {
819
		default:
820
			st->dvb_usb_lme2510_firmware = TUNER_S0194;
821 822 823 824
		case TUNER_S0194:
			fw_lme = fw_s0194;
			ret = request_firmware(&fw, fw_lme, &udev->dev);
			if (ret == 0) {
825
				cold = 0;
826 827
				break;
			}
828
			st->dvb_usb_lme2510_firmware = TUNER_LG;
829 830 831 832 833
		case TUNER_LG:
			fw_lme = fw_lg;
			ret = request_firmware(&fw, fw_lme, &udev->dev);
			if (ret == 0)
				break;
834
			st->dvb_usb_lme2510_firmware = TUNER_DEFAULT;
835 836
			break;
		}
837 838
		break;
	case 0x1120:
839
		switch (st->dvb_usb_lme2510_firmware) {
840
		default:
841
			st->dvb_usb_lme2510_firmware = TUNER_S7395;
842 843 844
		case TUNER_S7395:
			fw_lme = fw_c_s7395;
			ret = request_firmware(&fw, fw_lme, &udev->dev);
845 846
			if (ret == 0) {
				cold = 0;
847
				break;
848
			}
849
			st->dvb_usb_lme2510_firmware = TUNER_LG;
850 851 852 853 854
		case TUNER_LG:
			fw_lme = fw_c_lg;
			ret = request_firmware(&fw, fw_lme, &udev->dev);
			if (ret == 0)
				break;
855
			st->dvb_usb_lme2510_firmware = TUNER_S0194;
856 857 858 859 860
		case TUNER_S0194:
			fw_lme = fw_c_s0194;
			ret = request_firmware(&fw, fw_lme, &udev->dev);
			if (ret == 0)
				break;
861
			st->dvb_usb_lme2510_firmware = TUNER_DEFAULT;
862 863 864
			cold = 0;
			break;
		}
865 866 867
		break;
	case 0x22f0:
		fw_lme = fw_c_rs2000;
868
		st->dvb_usb_lme2510_firmware = TUNER_RS2000;
869 870 871
		break;
	default:
		fw_lme = fw_c_s7395;
872
	}
873

874 875
	release_firmware(fw);

876
	if (cold) {
877
		dvb_usb_lme2510_firmware = st->dvb_usb_lme2510_firmware;
878
		info("FRM Changing to %s firmware", fw_lme);
879 880
		lme_coldreset(d);
		return NULL;
881
	}
882

883
	return fw_lme;
884
}
885 886 887 888

static int lme2510_kill_urb(struct usb_data_stream *stream)
{
	int i;
889

890 891 892 893 894 895
	for (i = 0; i < stream->urbs_submitted; i++) {
		deb_info(3, "killing URB no. %d.", i);
		/* stop the URB */
		usb_kill_urb(stream->urb_list[i]);
	}
	stream->urbs_submitted = 0;
896

897 898 899 900
	return 0;
}

static struct tda10086_config tda10086_config = {
901
	.demod_address = 0x0e,
902 903 904 905 906 907
	.invert = 0,
	.diseqc_tone = 1,
	.xtal_freq = TDA10086_XTAL_16M,
};

static struct stv0288_config lme_config = {
908
	.demod_address = 0x68,
909 910 911 912 913
	.min_delay_ms = 15,
	.inittab = s7395_inittab,
};

static struct ix2505v_config lme_tuner = {
914
	.tuner_address = 0x60,
915 916 917 918 919
	.min_delay_ms = 100,
	.tuner_gain = 0x0,
	.tuner_chargepump = 0x3,
};

920
static struct stv0299_config sharp_z0194_config = {
921
	.demod_address = 0x68,
922 923 924 925 926 927 928 929 930 931
	.inittab = sharp_z0194a_inittab,
	.mclk = 88000000UL,
	.invert = 0,
	.skip_reinit = 0,
	.lock_output = STV0299_LOCKOUTPUT_1,
	.volt13_op0_op1 = STV0299_VOLT13_OP1,
	.min_delay_ms = 100,
	.set_symbol_rate = sharp_z0194a_set_symbol_rate,
};

932 933 934
static int dm04_rs2000_set_ts_param(struct dvb_frontend *fe,
	int caller)
{
935 936
	struct dvb_usb_adapter *adap = fe_to_adap(fe);
	struct dvb_usb_device *d = adap_to_d(adap);
937 938 939 940 941 942 943 944 945 946 947 948 949
	struct lme2510_state *st = d->priv;

	mutex_lock(&d->i2c_mutex);
	if ((st->i2c_talk_onoff == 1) && (st->stream_on & 1)) {
		st->i2c_talk_onoff = 0;
		lme2510_stream_restart(d);
	}
	mutex_unlock(&d->i2c_mutex);

	return 0;
}

static struct m88rs2000_config m88rs2000_config = {
950
	.demod_addr = 0x68,
951 952 953
	.set_ts_params = dm04_rs2000_set_ts_param,
};

954 955 956 957 958
static struct ts2020_config ts2020_config = {
	.tuner_address = 0x60,
	.clk_out_div = 7,
};

959 960 961
static int dm04_lme2510_set_voltage(struct dvb_frontend *fe,
					fe_sec_voltage_t voltage)
{
962 963 964
	struct dvb_usb_device *d = fe_to_d(fe);
	struct lme2510_state *st = fe_to_priv(fe);
	static u8 voltage_low[] = LME_VOLTAGE_L;
965 966 967 968
	static u8 voltage_high[] = LME_VOLTAGE_H;
	static u8 rbuf[1];
	int ret = 0, len = 3, rlen = 1;

969
	mutex_lock(&d->i2c_mutex);
970

971 972
	switch (voltage) {
	case SEC_VOLTAGE_18:
973
		ret |= lme2510_usb_talk(d,
974
			voltage_high, len, rbuf, rlen);
975 976
		break;

977 978 979
	case SEC_VOLTAGE_OFF:
	case SEC_VOLTAGE_13:
	default:
980
		ret |= lme2510_usb_talk(d,
981 982
				voltage_low, len, rbuf, rlen);
		break;
983
	}
984

985 986 987 988 989 990
	mutex_unlock(&d->i2c_mutex);

	if (st->tuner_config == TUNER_RS2000)
		if (st->fe_set_voltage)
			st->fe_set_voltage(fe, voltage);

991 992 993 994

	return (ret < 0) ? -ENODEV : 0;
}

995 996 997
static int dm04_rs2000_read_signal_strength(struct dvb_frontend *fe,
	u16 *strength)
{
998 999 1000
	struct lme2510_state *st = fe_to_priv(fe);

	*strength = (u16)((u32)st->signal_level * 0xffff / 0xff);
1001 1002 1003 1004 1005 1006

	return 0;
}

static int dm04_rs2000_read_snr(struct dvb_frontend *fe, u16 *snr)
{
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
	struct lme2510_state *st = fe_to_priv(fe);

	*snr = (u16)((u32)st->signal_sn * 0xffff / 0x7f);

	return 0;
}

static int dm04_read_ber(struct dvb_frontend *fe, u32 *ber)
{
	*ber = 0;

	return 0;
}

static int dm04_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{
	*ucblocks = 0;
1024 1025 1026 1027

	return 0;
}

1028 1029
static int lme_name(struct dvb_usb_adapter *adap)
{
1030 1031 1032
	struct dvb_usb_device *d = adap_to_d(adap);
	struct lme2510_state *st = adap_to_priv(adap);
	const char *desc = d->name;
1033
	char *fe_name[] = {"", " LG TDQY-P001F", " SHARP:BS2F7HZ7395",
1034
				" SHARP:BS2F7HZ0194", " RS2000"};
1035
	char *name = adap->fe[0]->ops.info.name;
1036 1037 1038 1039 1040 1041 1042

	strlcpy(name, desc, 128);
	strlcat(name, fe_name[st->tuner_config], 128);

	return 0;
}

1043 1044
static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap)
{
1045 1046
	struct dvb_usb_device *d = adap_to_d(adap);
	struct lme2510_state *st = d->priv;
1047
	int ret = 0;
1048 1049

	st->i2c_talk_onoff = 1;
1050
	switch (le16_to_cpu(d->udev->descriptor.idProduct)) {
1051 1052 1053
	case 0x1122:
	case 0x1120:
		st->i2c_gate = 4;
1054 1055 1056
		adap->fe[0] = dvb_attach(tda10086_attach,
			&tda10086_config, &d->i2c_adap);
		if (adap->fe[0]) {
1057 1058 1059
			info("TUN Found Frontend TDA10086");
			st->i2c_tuner_gate_w = 4;
			st->i2c_tuner_gate_r = 4;
1060
			st->i2c_tuner_addr = 0x60;
1061
			st->tuner_config = TUNER_LG;
1062 1063 1064
			if (st->dvb_usb_lme2510_firmware != TUNER_LG) {
				st->dvb_usb_lme2510_firmware = TUNER_LG;
				ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1065 1066 1067
			}
			break;
		}
1068

1069
		st->i2c_gate = 4;
1070 1071 1072
		adap->fe[0] = dvb_attach(stv0299_attach,
				&sharp_z0194_config, &d->i2c_adap);
		if (adap->fe[0]) {
1073 1074 1075
			info("FE Found Stv0299");
			st->i2c_tuner_gate_w = 4;
			st->i2c_tuner_gate_r = 5;
1076
			st->i2c_tuner_addr = 0x60;
1077
			st->tuner_config = TUNER_S0194;
1078 1079 1080
			if (st->dvb_usb_lme2510_firmware != TUNER_S0194) {
				st->dvb_usb_lme2510_firmware = TUNER_S0194;
				ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1081 1082
			}
			break;
1083 1084
		}

1085
		st->i2c_gate = 5;
1086 1087
		adap->fe[0] = dvb_attach(stv0288_attach, &lme_config,
			&d->i2c_adap);
1088

1089
		if (adap->fe[0]) {
1090 1091 1092
			info("FE Found Stv0288");
			st->i2c_tuner_gate_w = 4;
			st->i2c_tuner_gate_r = 5;
1093
			st->i2c_tuner_addr = 0x60;
1094
			st->tuner_config = TUNER_S7395;
1095 1096 1097
			if (st->dvb_usb_lme2510_firmware != TUNER_S7395) {
				st->dvb_usb_lme2510_firmware = TUNER_S7395;
				ret = lme_firmware_switch(d, 1) ? 0 : -ENODEV;
1098 1099
			}
			break;
1100
		}
1101 1102
	case 0x22f0:
		st->i2c_gate = 5;
1103 1104
		adap->fe[0] = dvb_attach(m88rs2000_attach,
			&m88rs2000_config, &d->i2c_adap);
1105

1106
		if (adap->fe[0]) {
1107
			info("FE Found M88RS2000");
1108 1109
			dvb_attach(ts2020_attach, adap->fe[0], &ts2020_config,
					&d->i2c_adap);
1110 1111
			st->i2c_tuner_gate_w = 5;
			st->i2c_tuner_gate_r = 5;
1112
			st->i2c_tuner_addr = 0x60;
1113
			st->tuner_config = TUNER_RS2000;
1114 1115 1116 1117
			st->fe_set_voltage =
				adap->fe[0]->ops.set_voltage;

			adap->fe[0]->ops.read_signal_strength =
1118
				dm04_rs2000_read_signal_strength;
1119
			adap->fe[0]->ops.read_snr =
1120
				dm04_rs2000_read_snr;
1121 1122 1123 1124
			adap->fe[0]->ops.read_ber =
				dm04_read_ber;
			adap->fe[0]->ops.read_ucblocks =
				dm04_read_ucblocks;
1125
		}
1126
		break;
1127 1128
	}

1129 1130 1131
	if (adap->fe[0] == NULL) {
		info("DM04/QQBOX Not Powered up or not Supported");
		return -ENODEV;
1132
	}
1133

1134
	if (ret) {
1135 1136 1137
		if (adap->fe[0]) {
			dvb_frontend_detach(adap->fe[0]);
			adap->fe[0] = NULL;
1138
		}
1139
		d->rc_map = NULL;
1140
		return -ENODEV;
1141 1142
	}

1143
	adap->fe[0]->ops.set_voltage = dm04_lme2510_set_voltage;
1144 1145 1146 1147 1148 1149
	ret = lme_name(adap);
	return ret;
}

static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap)
{
1150 1151
	struct dvb_usb_device *d = adap_to_d(adap);
	struct lme2510_state *st = adap_to_priv(adap);
1152
	char *tun_msg[] = {"", "TDA8263", "IX2505V", "DVB_PLL_OPERA", "RS2000"};
1153 1154 1155 1156
	int ret = 0;

	switch (st->tuner_config) {
	case TUNER_LG:
1157
		if (dvb_attach(tda826x_attach, adap->fe[0], 0x60,
1158
			&d->i2c_adap, 1))
1159 1160 1161
			ret = st->tuner_config;
		break;
	case TUNER_S7395:
1162 1163
		if (dvb_attach(ix2505v_attach , adap->fe[0], &lme_tuner,
			&d->i2c_adap))
1164 1165
			ret = st->tuner_config;
		break;
1166
	case TUNER_S0194:
1167
		if (dvb_attach(dvb_pll_attach , adap->fe[0], 0x60,
1168
			&d->i2c_adap, DVB_PLL_OPERA1))
1169 1170
			ret = st->tuner_config;
		break;
1171 1172 1173
	case TUNER_RS2000:
		ret = st->tuner_config;
		break;
1174 1175 1176 1177 1178 1179 1180
	default:
		break;
	}

	if (ret)
		info("TUN Found %s tuner", tun_msg[ret]);
	else {
1181
		info("TUN No tuner found --- resetting device");
1182
		lme_coldreset(d);
1183 1184 1185
		return -ENODEV;
	}

1186 1187 1188 1189 1190 1191
	/* Start the Interrupt*/
	ret = lme2510_int_read(adap);
	if (ret < 0) {
		info("INT Unable to start Interrupt Service");
		return -ENODEV;
	}
1192 1193

	return ret;
1194 1195 1196 1197 1198
}

static int lme2510_powerup(struct dvb_usb_device *d, int onoff)
{
	struct lme2510_state *st = d->priv;
1199 1200 1201
	static u8 lnb_on[] = LNB_ON;
	static u8 lnb_off[] = LNB_OFF;
	static u8 rbuf[1];
1202
	int ret = 0, len = 3, rlen = 1;
1203

1204
	mutex_lock(&d->i2c_mutex);
1205 1206

	if (onoff)
1207
		ret = lme2510_usb_talk(d, lnb_on, len, rbuf, rlen);
1208
	else
1209
		ret = lme2510_usb_talk(d, lnb_off, len, rbuf, rlen);
1210

1211
	st->i2c_talk_onoff = 1;
1212 1213 1214 1215

	mutex_unlock(&d->i2c_mutex);

	return ret;
1216 1217
}

1218
static int lme2510_get_adapter_count(struct dvb_usb_device *d)
1219
{
1220 1221
	return 1;
}
1222

1223 1224 1225
static int lme2510_identify_state(struct dvb_usb_device *d, const char **name)
{
	struct lme2510_state *st = d->priv;
1226

1227
	usb_reset_configuration(d->udev);
1228

1229
	usb_set_interface(d->udev,
1230
		d->props->bInterfaceNumber, 1);
1231

1232
	st->dvb_usb_lme2510_firmware = dvb_usb_lme2510_firmware;
1233

1234 1235 1236
	if (lme2510_return_status(d) == 0x44) {
		*name = lme_firmware_switch(d, 0);
		return COLD;
1237 1238
	}

1239
	return 0;
1240 1241
}

1242 1243 1244 1245
static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
		struct usb_data_stream_properties *stream)
{
	struct dvb_usb_adapter *adap = fe_to_adap(fe);
1246
	struct dvb_usb_device *d;
1247

1248 1249
	if (adap == NULL)
		return 0;
1250 1251 1252

	d = adap_to_d(adap);

1253 1254 1255 1256
	/* Turn PID filter on the fly by module option */
	if (pid_filter == 2) {
		adap->pid_filtering  = 1;
		adap->max_feed_count = 15;
1257 1258
	}

1259 1260 1261
	if (!(le16_to_cpu(d->udev->descriptor.idProduct)
		== 0x1122))
		stream->endpoint = 0x8;
1262

1263 1264 1265 1266 1267 1268
	return 0;
}

static int lme2510_get_rc_config(struct dvb_usb_device *d,
	struct dvb_usb_rc *rc)
{
1269
	rc->allowed_protos = RC_BIT_NEC;
1270 1271
	return 0;
}
1272

1273
static void *lme2510_exit_int(struct dvb_usb_device *d)
1274 1275
{
	struct lme2510_state *st = d->priv;
1276 1277 1278 1279
	struct dvb_usb_adapter *adap = &d->adapter[0];
	void *buffer = NULL;

	if (adap != NULL) {
1280
		lme2510_kill_urb(&adap->stream);
1281 1282
	}

1283
	if (st->usb_buffer != NULL) {
1284
		st->i2c_talk_onoff = 1;
1285 1286 1287
		st->signal_lock = 0;
		st->signal_level = 0;
		st->signal_sn = 0;
1288
		buffer = st->usb_buffer;
1289 1290 1291
	}

	if (st->lme_urb != NULL) {
1292
		usb_kill_urb(st->lme_urb);
1293
		usb_free_coherent(d->udev, 128, st->buffer,
1294
				  st->lme_urb->transfer_dma);
L
Lucas De Marchi 已提交
1295
		info("Interrupt Service Stopped");
1296
	}
1297

1298
	return buffer;
1299 1300
}

1301
static void lme2510_exit(struct dvb_usb_device *d)
1302
{
1303 1304
	void *usb_buffer;

1305
	if (d != NULL) {
1306
		usb_buffer = lme2510_exit_int(d);
1307
		kfree(usb_buffer);
1308 1309 1310
	}
}

1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359
static struct dvb_usb_device_properties lme2510_props = {
	.driver_name = KBUILD_MODNAME,
	.owner = THIS_MODULE,
	.bInterfaceNumber = 0,
	.adapter_nr = adapter_nr,
	.size_of_priv = sizeof(struct lme2510_state),

	.download_firmware = lme2510_download_firmware,

	.power_ctrl       = lme2510_powerup,
	.identify_state   = lme2510_identify_state,
	.i2c_algo         = &lme2510_i2c_algo,

	.frontend_attach  = dm04_lme2510_frontend_attach,
	.tuner_attach = dm04_lme2510_tuner,
	.get_stream_config = lme2510_get_stream_config,
	.get_adapter_count = lme2510_get_adapter_count,
	.streaming_ctrl   = lme2510_streaming_ctrl,

	.get_rc_config = lme2510_get_rc_config,

	.exit = lme2510_exit,
	.adapter = {
		{
			.caps = DVB_USB_ADAP_HAS_PID_FILTER|
				DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
			.pid_filter_count = 15,
			.pid_filter = lme2510_pid_filter,
			.pid_filter_ctrl  = lme2510_pid_filter_ctrl,
			.stream =
			DVB_USB_STREAM_BULK(0x86, 10, 4096),
		},
		{
		}
	},
};

static const struct usb_device_id lme2510_id_table[] = {
	{	DVB_USB_DEVICE(0x3344, 0x1122, &lme2510_props,
		"DM04_LME2510_DVB-S", RC_MAP_LME2510)	},
	{	DVB_USB_DEVICE(0x3344, 0x1120, &lme2510_props,
		"DM04_LME2510C_DVB-S", RC_MAP_LME2510)	},
	{	DVB_USB_DEVICE(0x3344, 0x22f0, &lme2510_props,
		"DM04_LME2510C_DVB-S RS2000", RC_MAP_LME2510)	},
	{}		/* Terminating entry */
};

MODULE_DEVICE_TABLE(usb, lme2510_id_table);

1360
static struct usb_driver lme2510_driver = {
1361 1362 1363 1364 1365 1366
	.name		= KBUILD_MODNAME,
	.probe		= dvb_usbv2_probe,
	.disconnect	= dvb_usbv2_disconnect,
	.id_table	= lme2510_id_table,
	.no_dynamic_id = 1,
	.soft_unbind = 1,
1367 1368
};

1369
module_usb_driver(lme2510_driver);
1370 1371

MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
1372
MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0");
1373
MODULE_VERSION("2.06");
1374
MODULE_LICENSE("GPL");
1375 1376 1377 1378 1379 1380 1381
MODULE_FIRMWARE(LME2510_C_S7395);
MODULE_FIRMWARE(LME2510_C_LG);
MODULE_FIRMWARE(LME2510_C_S0194);
MODULE_FIRMWARE(LME2510_C_RS2000);
MODULE_FIRMWARE(LME2510_LG);
MODULE_FIRMWARE(LME2510_S0194);