Fwd: Re: VGA output and cpufreq.

Matan Ziv-Av matan@svgalib.org
Mon Jun 28 12:16:22 CEST 2004


On Sun, 27 Jun 2004, Oleg Gusev wrote:

> > Do you not use the same as windows does. LCD displays are usully not
> > multiscanning, so the best is to use the same clock that windows uses.
> > The formula given in the SA1100 manual is PCD=(CCLK/(2*pixclock))+2.

My mistake - the formula should end with -2.
 
> Yes. The problem is that if we use wince value, then the LCD flickers.
> George Almasi put a much lower value and i have simply doubled
> his value. This setting is 10% higher than in wince, and everybody
> is happy. Since i do not completely understand the theory behind it,
> it will be great if somebody knowledgeable like you can explain the
> rationale.

Here's a patch that makes the calculation more obvious. The thing to 
remember is that fb alway tacks about pixel clock period (in 
femtoseconds), while the datasheet formula uses pixel clock frequency.


-- 
Matan Ziv-Av.                         matan@svgalib.org
-------------- next part --------------
--- drivers/video/sa1100fb.c	2004-02-22 16:21:49.000000000 +0200
+++ drivers/video/sa1100fb.c	2004-06-28 13:07:24.000000000 +0300
@@ -709,8 +709,8 @@
 
 #ifdef CONFIG_SA1100_JORNADA820
 static struct sa1100fb_mach_info j820_info __initdata = {
-	/* wince: 237222 - too low */
-  pixclock:       305000,          bpp:            8,
+	/* Windows uses 4.17MHz pixclock */
+  pixclock:       238000,          bpp:            8,
   xres:           640,        yres:           480,
   
   hsync_len:      3,          vsync_len:      1,
@@ -1481,10 +1481,8 @@
 	unsigned int pcd;
 
 	if (pixclock) {
-		pcd = cpufreq_get(0) / 100;
-		pcd *= pixclock;
-		pcd /= 10000000;
-		pcd += 1;	/* make up for integer math truncations */
+		pixclock = 4000000000/(pixclock/250); /* convert period to frequency */
+		pcd = (cpufreq_get(0)*1000+pixclock)/(2*pixclock)-2; /* Formula from SA1100 manual. */
 	} else {
 		/*
 		 * People seem to be missing this message.  Make it big.
@@ -1583,7 +1581,7 @@
 		LCCR3_ACBsCntOff;
 
 	if (pcd)
-		new_regs.lccr3 |= LCCR3_PixClkDiv(pcd);
+		new_regs.lccr3 |= pcd;
 
 	DPRINTK("nlccr0 = 0x%08x\n", new_regs.lccr0);
 	DPRINTK("nlccr1 = 0x%08x\n", new_regs.lccr1);
@@ -2143,7 +2141,7 @@
 
 	case CPUFREQ_POSTCHANGE:
 		pcd = get_pcd(fbi->fb.var.pixclock);
-		fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | LCCR3_PixClkDiv(pcd);
+		fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | pcd;
 		set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE);
 		break;
 	}


More information about the Jornada820 mailing list