set_hsync_time(fbi, pcd); 
static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *fbi){	struct pxafb_lcd_reg new_regs;	u_long flags;	u_int lines_per_panel, pcd = get_pcd(var->pixclock);	DPRINTK("Configuring PXA LCD\n");	DPRINTK("var: xres=%d hslen=%d lm=%d rm=%d\n",		var->xres, var->hsync_len,		var->left_margin, var->right_margin);	DPRINTK("var: yres=%d vslen=%d um=%d bm=%d\n",		var->yres, var->vsync_len,		var->upper_margin, var->lower_margin);	DPRINTK("var: pixclock=%d pcd=%d\n", var->pixclock, pcd);#if DEBUG_VAR	if (var->xres < 16        || var->xres > 1024)		printk(KERN_ERR "%s: invalid xres %d\n",			fbi->fb.fix.id, var->xres);	switch(var->bits_per_pixel) {	case 1:	case 2:	case 4:	case 8:	case 16:		break;	default:		printk(KERN_ERR "%s: invalid bit depth %d\n",		       fbi->fb.fix.id, var->bits_per_pixel);		break;	}	if (var->hsync_len < 1    || var->hsync_len > 64)		printk(KERN_ERR "%s: invalid hsync_len %d\n",			fbi->fb.fix.id, var->hsync_len);	if (var->left_margin < 1  || var->left_margin > 255)		printk(KERN_ERR "%s: invalid left_margin %d\n",			fbi->fb.fix.id, var->left_margin);	if (var->right_margin < 1 || var->right_margin > 255)		printk(KERN_ERR "%s: invalid right_margin %d\n",			fbi->fb.fix.id, var->right_margin);	if (var->yres < 1         || var->yres > 1024)		printk(KERN_ERR "%s: invalid yres %d\n",			fbi->fb.fix.id, var->yres);	if (var->vsync_len < 1    || var->vsync_len > 64)		printk(KERN_ERR "%s: invalid vsync_len %d\n",			fbi->fb.fix.id, var->vsync_len);	if (var->upper_margin < 0 || var->upper_margin > 255)		printk(KERN_ERR "%s: invalid upper_margin %d\n",			fbi->fb.fix.id, var->upper_margin);	if (var->lower_margin < 0 || var->lower_margin > 255)		printk(KERN_ERR "%s: invalid lower_margin %d\n",			fbi->fb.fix.id, var->lower_margin);#endif	new_regs.lccr0 = fbi->lccr0 |		(LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM |                 LCCR0_QDM | LCCR0_BM  | LCCR0_OUM);	new_regs.lccr1 =		LCCR1_DisWdth(var->xres) +		LCCR1_HorSnchWdth(var->hsync_len) +		LCCR1_BegLnDel(var->left_margin) +		LCCR1_EndLnDel(var->right_margin);	/*	 * If we have a dual scan LCD, we need to halve	 * the YRES parameter.	 */	lines_per_panel = var->yres;	if ((fbi->lccr0 & LCCR0_SDS) == LCCR0_Dual)		lines_per_panel /= 2;	new_regs.lccr2 =		LCCR2_DisHght(lines_per_panel) +		LCCR2_VrtSnchWdth(var->vsync_len) +		LCCR2_BegFrmDel(var->upper_margin) +		LCCR2_EndFrmDel(var->lower_margin);	new_regs.lccr3 = fbi->lccr3 |		pxafb_bpp_to_lccr3(var) |		(var->sync & FB_SYNC_HOR_HIGH_ACT ? LCCR3_HorSnchH : LCCR3_HorSnchL) |		(var->sync & FB_SYNC_VERT_HIGH_ACT ? LCCR3_VrtSnchH : LCCR3_VrtSnchL);	if (pcd)		new_regs.lccr3 |= LCCR3_PixClkDiv(pcd);	DPRINTK("nlccr0 = 0x%08x\n", new_regs.lccr0);	DPRINTK("nlccr1 = 0x%08x\n", new_regs.lccr1);	DPRINTK("nlccr2 = 0x%08x\n", new_regs.lccr2);	DPRINTK("nlccr3 = 0x%08x\n", new_regs.lccr3);	/* Update shadow copy atomically */	local_irq_save(flags);	/* setup dma descriptors */	fbi->dmadesc_fblow_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 3*16);	fbi->dmadesc_fbhigh_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 2*16);	fbi->dmadesc_palette_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 1*16);	fbi->dmadesc_fblow_dma = fbi->palette_dma - 3*16;	fbi->dmadesc_fbhigh_dma = fbi->palette_dma - 2*16;	fbi->dmadesc_palette_dma = fbi->palette_dma - 1*16;#define BYTES_PER_PANEL (lines_per_panel * fbi->fb.fix.line_length)	/* populate descriptors */	fbi->dmadesc_fblow_cpu->fdadr = fbi->dmadesc_fblow_dma;	fbi->dmadesc_fblow_cpu->fsadr = fbi->screen_dma + BYTES_PER_PANEL;	fbi->dmadesc_fblow_cpu->fidr  = 0;	fbi->dmadesc_fblow_cpu->ldcmd = BYTES_PER_PANEL;	fbi->fdadr1 = fbi->dmadesc_fblow_dma; /* only used in dual-panel mode */	fbi->dmadesc_fbhigh_cpu->fsadr = fbi->screen_dma;	fbi->dmadesc_fbhigh_cpu->fidr = 0;	fbi->dmadesc_fbhigh_cpu->ldcmd = BYTES_PER_PANEL;	fbi->dmadesc_palette_cpu->fsadr = fbi->palette_dma;	fbi->dmadesc_palette_cpu->fidr  = 0;	fbi->dmadesc_palette_cpu->ldcmd = (fbi->palette_size * 2) | LDCMD_PAL;	if (var->bits_per_pixel == 16) {		/* palette shouldn't be loaded in true-color mode */		fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_fbhigh_dma;		fbi->fdadr0 = fbi->dmadesc_fbhigh_dma; /* no pal just fbhigh */		/* init it to something, even though we won't be using it */		fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_palette_dma;	} else {		fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_fbhigh_dma;		fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_palette_dma;		fbi->fdadr0 = fbi->dmadesc_palette_dma; /* flips back and forth between pal and fbhigh */	}#if 0	DPRINTK("fbi->dmadesc_fblow_cpu = 0x%p\n", fbi->dmadesc_fblow_cpu);	DPRINTK("fbi->dmadesc_fbhigh_cpu = 0x%p\n", fbi->dmadesc_fbhigh_cpu);	DPRINTK("fbi->dmadesc_palette_cpu = 0x%p\n", fbi->dmadesc_palette_cpu);	DPRINTK("fbi->dmadesc_fblow_dma = 0x%x\n", fbi->dmadesc_fblow_dma);	DPRINTK("fbi->dmadesc_fbhigh_dma = 0x%x\n", fbi->dmadesc_fbhigh_dma);	DPRINTK("fbi->dmadesc_palette_dma = 0x%x\n", fbi->dmadesc_palette_dma);	DPRINTK("fbi->dmadesc_fblow_cpu->fdadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fdadr);	DPRINTK("fbi->dmadesc_fbhigh_cpu->fdadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fdadr);	DPRINTK("fbi->dmadesc_palette_cpu->fdadr = 0x%x\n", fbi->dmadesc_palette_cpu->fdadr);	DPRINTK("fbi->dmadesc_fblow_cpu->fsadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fsadr);	DPRINTK("fbi->dmadesc_fbhigh_cpu->fsadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fsadr);	DPRINTK("fbi->dmadesc_palette_cpu->fsadr = 0x%x\n", fbi->dmadesc_palette_cpu->fsadr);	DPRINTK("fbi->dmadesc_fblow_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fblow_cpu->ldcmd);	DPRINTK("fbi->dmadesc_fbhigh_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fbhigh_cpu->ldcmd);	DPRINTK("fbi->dmadesc_palette_cpu->ldcmd = 0x%x\n", fbi->dmadesc_palette_cpu->ldcmd);#endif	fbi->reg_lccr0 = new_regs.lccr0;	fbi->reg_lccr1 = new_regs.lccr1;	fbi->reg_lccr2 = new_regs.lccr2;	fbi->reg_lccr3 = new_regs.lccr3;	local_irq_restore(flags);	/*	 * Only update the registers if the controller is enabled	 * and something has changed.	 */	if ((LCCR0  != fbi->reg_lccr0) || (LCCR1  != fbi->reg_lccr1) ||	    (LCCR2  != fbi->reg_lccr2) || (LCCR3  != fbi->reg_lccr3) ||	    (FDADR0 != fbi->fdadr0)    || (FDADR1 != fbi->fdadr1))		pxafb_schedule_work(fbi, C_REENABLE);	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/ba44cd2d8abc3271a608b42cdbf55e1e575e2ba5/pxafb.c/buggy/drivers/video/pxafb.c