[linux-dvb] LG TDQC-S001F

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I have been trying to get this tuner (LG TDQC-S001F, (STV0299 + SL 1925 
+ TSA5059)) working for a little while for now. This tuner looks very 
similar to the LG TDQF-S001F, that which is already supported, looking 
at the header in STV0299.c in the frontends directory.

I have tried similar setups to what does exist for the current PLL's, 
but i have been unable to get a valid lock, till now, doing a szap.

Now if somebody has come accross this tuner it would be helpful, if he 
can either
point out the difference between the 2 tuners, or
as to how/what i maybe doing wrong, that would be quite helpful.

The suggestion from the vendor(s) was to do adaptive tuning, according 
to the STV0299 reference code, from ST.
But since we don't do that for any of that for the drivers, i can't see 
how that would fit in ..

Any suggestions/comments which would help ... ?


Thanks,
Manu

-------------- next part --------------

static u8 lgtdqcs001f_inittab[] = {
	0x01, 0x15,
	0x02, 0x00,
	0x03, 0x00,
	0x04, 0x2a,
	0x05, 0x85,
	0x06, 0x02,
	0x07, 0x00,
	0x08, 0x00,
	0x0c, 0x01,
	0x0d, 0x81,
	0x0e, 0x44,
	0x0f, 0x14,
	0x10, 0x3c,
	0x11, 0x84,
	0x12, 0xb9,
	0x13, 0xb5,
	0x14, 0x4f,
	0x15, 0xc9,
	0x16, 0x80,
	0x17, 0x36,
	0x18, 0xfb,
	0x19, 0xcf,
	0x1a, 0xbc,
	0x1c, 0x2b,
	0x1d, 0x27,
	0x1e, 0x00,
	0x1f, 0x0b,
	0x20, 0xa1,
	0x21, 0x60,
	0x22, 0x00,
	0x23, 0x00,
	0x28, 0x00,
	0x29, 0x28,
	0x2a, 0x14,
	0x2b, 0x0f,
	0x2c, 0x09,
	0x2d, 0x05,
	0x31, 0x1f,
	0x32, 0x19,
	0x33, 0xfc,
	0x34, 0x13,
	0xff, 0xff,
};

static int lgtdqcs001f_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
{
	u8 buf[4];
	u32 div;
	struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
	struct i2c_msg msg_r = { .addr = 0x61, .flags = I2C_M_RD, .buf = buf, .len = 2};

	if ((params->frequency < 950000) || (params->frequency > 2150000))
		return -EINVAL;

	/*
	 *	Divider setup, Comparison frequency = 250kHz
	 *	Ratio = 8,
	 *	R3 = 0, R2 = 0, R1 = 1, R0 = 0
	 *	Prescaler PE = 0
	 */
//	div = params->frequency / 250;
//	div = params->frequency / 125;
	div = (params->frequency + (125 - 1)) / 125;

	buf[0] = (div >> 8) & 0x7f;
	buf[1] =  div & 0xff;
//	buf[2] =  0x83;
//	buf[2] =  0x84;
	buf[2] =  0x80 | ((div & 0x18000) >> 10) | 4;
	buf[3] =  0xc0;

	if (params->frequency < 1531000)
		buf[3] |= 0x04;
	else
		buf[3] &= ~0x04;
	dprintk(verbose, MANTIS_DEBUG, 1, "STV0299 PLL setup");
	if (i2c_transfer(i2c, &msg, 4) < 0) {
		dprintk(verbose, MANTIS_DEBUG, 1, "Write: I2C Transfer failed");
		return -EIO;
	}
	
	msleep(10);

	buf[0] = 0x00;
	buf[1] = 0x00;
	buf[2] = 0x00;
	buf[3] = 0x00;
	if (i2c_transfer(i2c, &msg_r, 1) < 0) {
		dprintk(verbose, MANTIS_ERROR, 1, "Read: I2C Transfer failed");
		return -EIO;
	}
	dprintk(verbose, MANTIS_ERROR, 1, "TSA5059 read=[0x%02x, 0x%02x]", buf[0], buf[1]);


	return 0;
}

static int lgtdqcs001f_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
{

	u8 aclk = 0;
	u8 bclk = 0;

	if (srate < 1500000) {
		aclk = 0xb7;
		bclk = 0x47;
	} else if (srate < 3000000) {
		aclk = 0xb7;
		bclk = 0x4b;
	} else if (srate < 7000000) {
		aclk = 0xb7;
		bclk = 0x4f;
	} else if (srate < 14000000) {
		aclk = 0xb7;
		bclk = 0x53;
	} else if (srate < 30000000) {
		aclk = 0xb6;
		bclk = 0x53;
	} else if (srate < 45000000) {
		aclk = 0xb4;
		bclk = 0x51;
	}

	stv0299_writereg(fe, 0x13, aclk);
	stv0299_writereg(fe, 0x14, bclk);
	stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
	stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
	stv0299_writereg(fe, 0x21, (ratio) & 0xf0);


	return 0;
}


static struct stv0299_config lgtdqcs001f_config = {

	.demod_address = 0x68,
	.inittab = lgtdqcs001f_inittab,
	.mclk = 88000000UL,
//	.invert = 0,
	.invert = 1,
//	.enhanced_tuning = 0,
	.skip_reinit = 0,
	.lock_output = STV0229_LOCKOUTPUT_0,
	.volt13_op0_op1 = STV0299_VOLT13_OP0,
	.min_delay_ms = 100,
	.set_symbol_rate = lgtdqcs001f_set_symbol_rate,
	.pll_set = lgtdqcs001f_pll_set,
};



[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux