Skip to contentSkip to conversation

Fix for "MT2032 Fatal Error: PLLs didn't lock"

DISCUSSION Gerd Knorr 2 participants 4 messages Nov 24, 2003 – Nov 27, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Gerd Knorr

author
#1 lore raw
Quoted 6 lines

I saw others report same issues but didnt see any fixes/patches/solutions. With the debug option on for bttv and tuner in /etc/modules.conf and the TV frequency set to 133.25MHz and then 140.25MHz, the sign extension defect pops up in rfin value below. This is because 133.25MHz is 0x7F13BD0 and 140.25MHz is 0x85C0B90. The high bit gets sign extended in as 0xFFFFFFFFF85C0B90 (-128185456)

Huh? I can't see where a sign extension happens. 0x85C0B90 has the bit #27 set to one, not #31 ...

Beside that the values are passed around as unsigned values everythere. Can you please explain in more detail what is going on?

Quoted 7 lines
Nov 16 21:45:56 localhost kernel: tuner: tv freq set to 133.25
Nov 16 21:45:56 localhost kernel: mt2032_set_if_freq rfin=133250000

if1=1090000000 if2=38900000 from=32900000 to=39900000

Nov 16 21:45:58 localhost kernel: tuner: tv freq set to 140.25
Nov 16 21:45:58 localhost kernel: mt2032_set_if_freq rfin=-128185456

if1=1090000000 if2=38900000 from=32900000 to=39900000

Works fine here:

tuner: tv freq set to 140.25
mt2032_set_if_freq rfin=140250000 if1=1090000000 if2=38900000 from=32900000 to=39900000

Review

Quoted 4 lines
(quoted diff) +1 -1
 	case VIDIOCSFREQ:
 	{
-		unsigned long *v = arg;
+		unsigned int *v = arg;

Wrong, VIDIOCSFREQ is "_IOW('v',15, unsigned long)". Beside that I'm very surprised that this actually makes a difference. What architecture is that? And what size int/long have there?

Review

Quoted 2 lines
(quoted diff) +1 -1
-				(*iarg)/16,(*iarg)%16*100/16);
+				(*v)/16,(*v)%16*100/16);

That is ok.

Gerd

Signature · 1 line
You have a new virus in /var/mail/kraxel
#2 lore raw
Quoted 9 lines · Gerd Knorr
Quoted 6 lines

I saw others report same issues but didnt see any fixes/patches/solutions. With the debug option on for bttv and tuner in /etc/modules.conf and the TV frequency set to 133.25MHz and then 140.25MHz, the sign extension defect pops up in rfin value below. This is because 133.25MHz is 0x7F13BD0 and 140.25MHz is 0x85C0B90. The high bit gets sign extended in as 0xFFFFFFFFF85C0B90 (-128185456)

Huh? I can't see where a sign extension happens. 0x85C0B90 has the bit #27 set to one, not #31 ...

I know this sounds weird, but sign extension is happening between invocation of set_tv_freq and the dprintk in mt2032_set_tv_freq.

Quoted 2 lines

Beside that the values are passed around as unsigned values everythere. Can you please explain in more detail what is going on?

Except in one place where there is an implicit conversion to signed ints in line 746:

746 mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,

Quoted 4 lines
Quoted 3 lines
Nov 16 21:45:56 localhost kernel: tuner: tv freq set to 133.25
Nov 16 21:45:56 localhost kernel: mt2032_set_if_freq rfin=133250000

if1=1090000000 if2=38900000 from=32900000 to=39900000

Quoted 8 lines
Quoted 3 lines
Nov 16 21:45:58 localhost kernel: tuner: tv freq set to 140.25
Nov 16 21:45:58 localhost kernel: mt2032_set_if_freq rfin=-128185456

if1=1090000000 if2=38900000 from=32900000 to=39900000

Works fine here:

tuner: tv freq set to 140.25
mt2032_set_if_freq rfin=140250000 if1=1090000000 if2=38900000 from=32900000 to=39900000

Thanks for the clue. Perhaps the problem is gcc/athlon related?

Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +1 -1
 	case VIDIOCSFREQ:
 	{
-		unsigned long *v = arg;
+		unsigned int *v = arg;

Wrong, VIDIOCSFREQ is "_IOW('v',15, unsigned long)". Beside that I'm very surprised that this actually makes a difference. What architecture is that? And what size int/long have there?

I agree that the change is rather kludgy. I was using stock Mandrake 9.1/gcc3.2.2 on AMD Athlon 1.4GHz. I have seen the error pop up on the Knoppix (2.4.18..2.4.20 kernels) also on the same box so it doesnt seem to be distro-specific. I dont have a Intel system to check if the problem is related to the cpu. Clues anyone?

Let me poke around in the assembly code tonight to find out why the sign change happens on my box. I suspect this could be due to gcc/athlon combo.

Subbu K. K.

author
#3 lore raw
Quoted 4 lines

Except in one place where there is an implicit conversion to signed ints in line 746:

746 mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,

Sure? Both freq and second mt2032_set_if_freq argument are declared unsigned int ...
What happens with "62500" changed to "(unsigned)62500" ?

Quoted 3 lines
Quoted 2 lines

tuner: tv freq set to 140.25
mt2032_set_if_freq rfin=140250000 if1=1090000000 if2=38900000 from=32900000 to=39900000

Thanks for the clue. Perhaps the problem is gcc/athlon related?

Maybe. gcc 3.3.1 here.

Gerd

Signature · 1 line
You have a new virus in /var/mail/kraxel
#4 lore raw
In reply to Subbu K. K.
Quoted 4 lines · Subbu K. K.

Let me poke around in the assembly code tonight to find out why the sign change happens on my box. I suspect this could be due to gcc/athlon combo.

ok. Found the error.

bttv-0.7.103 and earlier (kernel 2.4.20 and earlier) had the following lines in two places:
mt2032_set_if_freq(c,freq* 1000*1000/16, ...
When freq is defined as int, this computation causes a sign extension error when freq is 2244 (140.25MHz). The error disappears if 1000*1000/16 is replaced with 62500 and/or if freq is defined as unsigned int.

Here is a simple test to surface this error:
// test with gcc -o signext signext.c && ./signext main(int argc, char *argv[])

{
	int s; unsigned f;

	s = 2244; f = s;
	printf("freq=%d rfin=%d\n", s*62500, s*1000*1000/16);
	printf("freq=%d rfin=%d\n", f*62500, f*1000*1000/16);
}

the output shows:
freq=14025000 rfin=-128185456
freq=14025000 rfin=140250000

bttv-0.7.104+ and kernel 2.4.21+ have the fix. Still, I thought of recording the error for those still on older kernels.

Subbu K. K.