Re: (bttv-0.7.82) final patch candidate for voodoo tv 200 (us/NTSC version)

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



here's the spur avoidance patch again. this time in diff -up format :-)
btw: the second mask should be 0x997fff for ntsc. i've tested w/ DScaler under windows as i dont know how to select the second (MSP/radio) input under linux.


--On Friday, October 12, 2001 8:13 PM +0200 Gunther Mayer <Gunther.Mayer@xxxxxxxxxxx> wrote:

Ivan T Tarnavsky wrote:

i guess it calls for 2 entries in the bttv-cards.c one for the us and one
for europe.

> Torgeir Veimo wrote:
>>
>>  > i'm including a patch for the spur avoidance and also i've
>>  > rearranged the compute freq routine a bit.
>>
>> This seems to slightly improve picture quality on PAL as well.
>>
>> Gunther, I hope the last GPIO fix will only be used when in NTSC mode,
>> it seriously breaks my sound.. Strangely, if I mute in xawtv, the
>> picture usually becomes ok.
>
> This was just a temporary patch to test NTSC setup and breaking PAL
> was expected side-effect. Final patch needs to be done...

This patch should work on both PAL and NTSC (incl. mute).
I already tested PAL OK.

NTSC testers wanted.

Note: Some bttv applications don't set the "norm" via VIDIOCSCHAN,
these get the default (i.e. PAL)! Xawtv works fine, of course.



cheers,
ivan.
--- tuner.c.old	Wed Oct 10 15:16:22 2001
+++ tuner.c	Fri Oct 12 13:25:10 2001
@@ -281,7 +281,7 @@ int mt2032_init(struct i2c_client *c)
         ret=i2c_master_send(c,buf,1);
         i2c_master_recv(c,buf,21);
 
-        printk("MT2032: Companycode=%02x%02x Part=%02x Revision=%02x\n",
+        printk("MT2032: Companycode=%c%c Part=%02x Revision=%02x\n",
                 buf[0x11],buf[0x12],buf[0x13],buf[0x14]);
 
         if(debug) {
@@ -290,7 +290,7 @@ int mt2032_init(struct i2c_client *c)
                 for(i=0;i<21;i++) {
                         printk(" %02x",buf[i]);
                         if(((i+1)%8)==0) printk(" ");
-                        if(((i+1)%16)==0) printk("\n ");
+                        if(((i+1)%16)==0) printk("\n");
                 }
                 printk("\n ");
         }
@@ -364,29 +364,45 @@ int mt2032_spurcheck(int f1, int f2, int
 		f=f-f2;
 		dprintk(" spurtest n1=%d n2=%d ftest=%d\n",n1,n2,f);
 
-		if( (f>spectrum_from) && (f<spectrum_to))
+		if( (f>spectrum_from) && (f<spectrum_to)) {
 			printk("mt2032 spurcheck triggered: %d\n",n1);
+			return 1;
+		}
 	    } while ( (f>(f2-spectrum_to)) || (n2>-5));
 	    n1++;
 	} while (n1<5);
 
-	return 1;
+	return 0;
 }
 
 int mt2032_compute_freq(int rfin, int if1, int if2, int spectrum_from,
 	int spectrum_to, unsigned char *buf, int *ret_sel, int xogc) //all in Hz
 {
         int fref,lo1,lo1n,lo1a,s,sel,lo1freq, desired_lo1,
-		desired_lo2,lo2,lo2n,lo2a,lo2num,lo2freq;
+		desired_lo2,lo2,lo2n,lo2a,lo2num,lo2freq,nLO1adjust;
 
         fref= 5250 *1000; //5.25MHz
-	desired_lo1=rfin+if1;
 
-	lo1=(2*(desired_lo1/1000)+(fref/1000)) / (2*fref/1000);
-        lo1n=lo1/8;
-        lo1a=lo1-(lo1n*8);
+	// 2.3.1
+	desired_lo1 = rfin + if1;
+	lo1 = (2 * (desired_lo1 / 1000) + (fref / 1000)) / (2 * fref / 1000);
+	lo1freq = lo1 * fref;
+	desired_lo2 = lo1freq - rfin - if2;
+
+	// 2.3.2
+	for(nLO1adjust = 1; nLO1adjust < 3; nLO1adjust++) {
+		if (!mt2032_spurcheck(lo1freq, desired_lo2,  spectrum_from, spectrum_to))
+			break;
+		if (lo1freq < desired_lo1)
+			lo1 += nLO1adjust;
+		else
+			lo1 -= nLO1adjust;
+		lo1freq = lo1 * fref;
+		desired_lo2 = lo1freq - rfin - if2;
+	}
 
-        s=rfin/1000/1000+1090;
+	// 2.3.3
+        s = lo1freq/1000/1000;
 
 	if(optimize_vco) {
 		if(s>1890) sel=0;
@@ -404,12 +420,13 @@ int mt2032_compute_freq(int rfin, int if
 	}
 	*ret_sel=sel;
 
-        lo1freq=(lo1a+8*lo1n)*fref;
+	// 2.3.4
+	lo1n=lo1/8;
+        lo1a=lo1-(lo1n*8);
 
         dprintk("mt2032: rfin=%d lo1=%d lo1n=%d lo1a=%d sel=%d, lo1freq=%d\n",
 		rfin,lo1,lo1n,lo1a,sel,lo1freq);
 
-        desired_lo2=lo1freq-rfin-if2;
         lo2=(desired_lo2)/fref;
         lo2n=lo2/8;
         lo2a=lo2-(lo2n*8);
@@ -424,9 +441,6 @@ int mt2032_compute_freq(int rfin, int if
 		       lo1a, lo1n, lo2a,lo2n);
                 return(-1);
         }
-
-	mt2032_spurcheck(lo1freq, desired_lo2,  spectrum_from, spectrum_to);
-	// should recalculate lo1 (one step up/down)
 
 	// set up MT2032 register map for transfer over i2c
 	buf[0]=lo1n-1;

[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux