Mailing List archive

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

[linux-dvb] [PATCH] Re: Typhoon/budget*



On Thursday 18 March 2004 18:18, Johannes Stezenbach wrote:
> Kenneth Aafløy wrote:
> > I get an oops because of the fact that the card does not have the av
> > saa7146 extension. The attached patch named typhoon.diff fixes this
> > problem, but i'm unsure if i've if'ed out too much or too little of the
> > code if the av extension is not found. 
>
> I've not much experience with the budget drivers, but to me this
> patch looks OK.

Cool ,any chance it'll get committed then? :)

> > how can I detect if there is a bsru6 or sa1278 on the i2c address x?
>
> I have no idea how to probe this. I guess we need to use the
> strcmp(adapter->name, "...Typhoon...") thing as used for
> PHILIPS_SU1278_TSA_TT.

I've done that and also added a disable_typhoon module parameter in case it 
breaks something.

> EIO usually means the I2C communication failed. Probably the
> general purpose IOs are wired differently on your card, and
> the code in stv0299_set_voltage does bad things for you. To proceed
> you need data sheets and a multimeter and find out how things are
> connected. Or try to ask Typhoon for that information.

I got confused, because szap was returning permission denied for 
fe_set_voltage, but that's -13. Guess i just picked the closest number..

As you mentioned, It was just some crossed wires out from the stv0299b, it's 
fixed in the attached patch. I've also done a fix to the standby off value in 
uni0299_attach, since the default value would not bring my stv0299 out of 
standby (have no idea how this will work on other card, but i can confirm it 
working on my nexus-s which has stv0299/bsru6).

> > I've downloaded the saa7146 datasheet from Philips, but where can i get
> > the frontend (stv0299 based primarily) datasheets?
>
> They are usually secret.

That's nice...found the stv0299b paper somewhere on the net anyways.

> > Btw, I've also tested the budget-ci driver, and that is also doing the
> > job fine..if the pci ids is added that is. Could not these budget drivers
> > be combined?
>
> Well, if more variations of the budget cards surface, so that it is
> no longer possible to tell from the PCI ids alone which driver to use,
> then the code might have to be restructured. But IMHO not yet.

OK, just thought that since the av extension on the knc1 card could probably 
be detected just as fine in the budget-ci driver it would be worth getting 
rid of the budget-av driver.

Kenneth

-- 

Kenneth
ke-aa@frisurf.no
Index: stv0299.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/stv0299.c,v
retrieving revision 1.40
diff -u -r1.40 stv0299.c
--- stv0299.c	14 Mar 2004 13:48:32 -0000	1.40
+++ stv0299.c	19 Mar 2004 00:28:19 -0000
@@ -62,6 +62,7 @@
 #endif
 
 static int stv0299_status = 0;
+static int disable_typhoon = 0;
 
 #define STATUS_BER 0
 #define STATUS_UCBLOCKS 1
@@ -75,6 +76,7 @@
 #define PHILIPS_SU1278_TUA	3 // SU1278 with TUA6100 synth
 #define SAMSUNG_TBMU24112IMB	4
 #define PHILIPS_SU1278_TSA_TT	5 // SU1278 with TSA5059 synth and TechnoTrend settings
+#define PHILIPS_SU1278_TSA_TY	6 // SU1278 with TUA5059 synth and Typhoon wiring
 
 /* Master Clock = 88 MHz */
 #define M_CLK (88000000UL)
@@ -386,7 +388,12 @@
 	switch(ftype) {
 	case PHILIPS_SU1278_TSA:
 	case PHILIPS_SU1278_TSA_TT:
-		addr = 0x60;
+	case PHILIPS_SU1278_TSA_TY:
+		if (ftype == PHILIPS_SU1278_TSA_TY)
+			addr = 0x61;
+		else
+			addr = 0x60;
+
 		buf[3] |= 0x20;
 
 		if (srate < 4000000) buf[3] |= 1;
@@ -609,7 +616,7 @@
 			stv0299_writereg (i2c, init_tab[i], init_tab[i+1]);
 
 		/* AGC1 reference register setup */
-		if (ftype == PHILIPS_SU1278_TSA)
+		if (ftype == PHILIPS_SU1278_TSA || ftype == PHILIPS_SU1278_TSA_TY)
 		  stv0299_writereg (i2c, 0x0f, 0x92);  /* Iagc = Inverse, m1 = 18 */
 		else if (ftype == PHILIPS_SU1278_TUA)
 		  stv0299_writereg (i2c, 0x0f, 0x94);  /* Iagc = Inverse, m1 = 20 */
@@ -821,7 +828,8 @@
 }
 
 
-static int stv0299_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage)
+static int stv0299_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage,
+				int tuner_type)
 {
 	u8 reg0x08;
 	u8 reg0x0c;
@@ -832,28 +840,32 @@
 
 	reg0x08 = stv0299_readreg (i2c, 0x08);
 	reg0x0c = stv0299_readreg (i2c, 0x0c);
-
+    
 	/**
 	 *  H/V switching over OP0, OP1 and OP2 are LNB power enable bits
 	 */
 	reg0x0c &= 0x0f;
 
 	if (voltage == SEC_VOLTAGE_OFF) {
-		stv0299_writereg (i2c, 0x08, reg0x08 & ~0x40);
-		return stv0299_writereg (i2c, 0x0c, reg0x0c & ~0x40);
-	} else {
-		stv0299_writereg (i2c, 0x08, reg0x08 | 0x40);
-		reg0x0c |= 0x40;   /* LNB power on */
+		stv0299_writereg (i2c, 0x0c, 0x00); /*	LNB power off! */
+		return stv0299_writereg (i2c, 0x08, 0x00); /*	LNB power off! */
+	}
+	
+	stv0299_writereg (i2c, 0x08, reg0x08 | 0x40);
 
-		switch (voltage) {
-		case SEC_VOLTAGE_13:
-			return stv0299_writereg (i2c, 0x0c, reg0x0c);
-		case SEC_VOLTAGE_18:
+	switch (voltage) {
+	case SEC_VOLTAGE_13:
+		if (tuner_type == PHILIPS_SU1278_TSA_TY)
 			return stv0299_writereg (i2c, 0x0c, reg0x0c | 0x10);
-		default:
-			return -EINVAL;
-		};
-	}
+		else
+			return stv0299_writereg (i2c, 0x0c, reg0x0c | 0x40);
+
+	case SEC_VOLTAGE_18:
+		return stv0299_writereg (i2c, 0x0c, reg0x0c | 0x50);
+
+	default:
+		return -EINVAL;
+	};
 }
 
 
@@ -908,6 +920,7 @@
 		stv0299_writereg (i2c, 0x21, (ratio	 ) & 0xf0);
 		break;
 	    
+	case PHILIPS_SU1278_TSA_TY:
 	case PHILIPS_SU1278_TSA:
 		aclk = 0xb5;
 		if (srate < 2000000) bclk = 0x86;
@@ -1196,7 +1209,8 @@
 		return stv0299_set_tone (i2c, (fe_sec_tone_mode_t) arg);
 
 	case FE_SET_VOLTAGE:
-		return stv0299_set_voltage (i2c, (fe_sec_voltage_t) arg);
+		return stv0299_set_voltage (i2c, (fe_sec_voltage_t) arg,
+					    state->tuner_type);
 
 	case FE_GET_TUNE_SETTINGS:
 	{
@@ -1269,18 +1283,28 @@
 	if ((ret = i2c->xfer(i2c, msg1, 2)) == 2) {
 		if ( strcmp(adapter->name, "TT-Budget/WinTV-NOVA-CI PCI") == 0 ) {
 			// technotrend cards require non-datasheet settings
-			printk ("%s: setup for tuner SU1278 (TSA5059 synth) on TechnoTrend hardware\n", __FILE__);
+			printk ("%s: setup for tuner SU1278 (TSA5059 synth) on"
+				" TechnoTrend hardware\n", __FILE__);
 			return PHILIPS_SU1278_TSA_TT;
 		}  else {
 			// fall back to datasheet-recommended settings
-			printk ("%s: setup for tuner SU1278 (TSA5059 synth)\n", __FILE__);
+			printk ("%s: setup for tuner SU1278 (TSA5059 synth)\n",
+				__FILE__);
 			return PHILIPS_SU1278_TSA;
 		}
 	}
 
 	if ((ret = i2c->xfer(i2c, msg2, 2)) == 2) {
-		//if ((stat[0] & 0x3f) == 0) {
-		if (0) {
+		if ( strcmp(adapter->name, "KNC1 DVB-S") == 0 &&
+		     !disable_typhoon )
+		{
+			// Typhoon cards have unusual wiring.
+			printk ("%s: setup for tuner SU1278 (TSA5059 synth) on"
+				" Typhoon hardware\n", __FILE__);
+			return PHILIPS_SU1278_TSA_TY;
+		}
+		//else if ((stat[0] & 0x3f) == 0) {
+		else if (0) {
 			printk ("%s: setup for tuner TDQF-S001F\n", __FILE__);
 			return LG_TDQF_S001F;
 		} else {
@@ -1296,7 +1320,8 @@
 	stv0299_writereg (i2c, 0x02, 0x00);
 
 	if ((ret = i2c->xfer(i2c, msg3, 2)) == 2) {
-		printk ("%s: setup for tuner Philips SU1278 (TUA6100 synth)\n", __FILE__);
+		printk ("%s: setup for tuner Philips SU1278 (TUA6100 synth)\n",
+			__FILE__);
 		return PHILIPS_SU1278_TUA;
 	}
 
@@ -1314,7 +1339,8 @@
 	int tuner_type;
 	u8 id;
 
-	stv0299_writereg (i2c, 0x02, 0x00); /* standby off */
+	stv0299_writereg (i2c, 0x02, 0x34); /* standby off */
+	dvb_delay(200);
 	id = stv0299_readreg (i2c, 0x00);
 
 	dprintk ("%s: id == 0x%02x\n", __FUNCTION__, id);
@@ -1330,7 +1356,7 @@
 	if ((state = kmalloc(sizeof(struct stv0299_state), GFP_KERNEL)) == NULL) {
 		return -ENOMEM;
 	}
-   
+
 	*data = state;
 	state->tuner_type = tuner_type;
 	state->tuner_frequency = 0;
@@ -1370,3 +1396,6 @@
 
 MODULE_PARM(stv0299_status, "i");
 MODULE_PARM_DESC(stv0299_status, "Which status value to support (0: BER, 1: UCBLOCKS)");
+
+MODULE_PARM(disable_typhoon, "i");
+MODULE_PARM_DESC(disable_typhoon, "Disable support for Philips SU1278 on Typhoon hardware.");

Home | Main Index | Thread Index