⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sa1100fb.c

📁 linux下的VIDEO接口驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
 */static void sa1100fb_blank(int blank, struct fb_info *info){	struct sa1100fb_info *fbi = (struct sa1100fb_info *)info;	int i;	DPRINTK("sa1100fb_blank: blank=%d info->modename=%s\n", blank,		fbi->fb.modename);	switch (blank) {	case VESA_POWERDOWN:	case VESA_VSYNC_SUSPEND:	case VESA_HSYNC_SUSPEND:		if (fbi->fb.disp->visual == FB_VISUAL_PSEUDOCOLOR ||		    fbi->fb.disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR)			for (i = 0; i < fbi->palette_size; i++)				sa1100fb_setpalettereg(i, 0, 0, 0, 0, info);		sa1100fb_schedule_task(fbi, C_DISABLE);		if (sa1100fb_blank_helper)			sa1100fb_blank_helper(blank);		break;	case VESA_NO_BLANKING:		if (sa1100fb_blank_helper)			sa1100fb_blank_helper(blank);		if (fbi->fb.disp->visual == FB_VISUAL_PSEUDOCOLOR ||		    fbi->fb.disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR)			fb_set_cmap(&fbi->fb.cmap, 1, sa1100fb_setcolreg, info);		sa1100fb_schedule_task(fbi, C_ENABLE);	}}static int sa1100fb_updatevar(int con, struct fb_info *info){	DPRINTK("entered\n");	return 0;}/* * Calculate the PCD value from the clock rate (in picoseconds). * We take account of the PPCR clock setting. */static inline int get_pcd(unsigned int pixclock){	unsigned int pcd;	if (pixclock) {		pcd = cpufreq_get(0) / 100;		pcd *= pixclock;		pcd /= 10000000;		pcd += 1;	/* make up for integer math truncations */	} else {		/*		 * People seem to be missing this message.  Make it big.		 * Make it stand out.  Make sure people see it.		 */		printk(KERN_WARNING "******************************************************\n");		printk(KERN_WARNING "**            ZERO PIXEL CLOCK DETECTED             **\n");		printk(KERN_WARNING "** You are using a zero pixclock.  This means that  **\n");		printk(KERN_WARNING "** clock scaling will not be able to adjust your    **\n");		printk(KERN_WARNING "** your timing parameters appropriately, and the    **\n");		printk(KERN_WARNING "** bandwidth calculations will fail to work.  This  **\n");		printk(KERN_WARNING "** will shortly become an error condition, which    **\n");		printk(KERN_WARNING "** will prevent your LCD display working.  Please   **\n");		printk(KERN_WARNING "** send your patches in as soon as possible to shut **\n");		printk(KERN_WARNING "** this message up.                                 **\n");		printk(KERN_WARNING "******************************************************\n");		pcd = 0;	}	return pcd;}/* * sa1100fb_activate_var(): *	Configures LCD Controller based on entries in var parameter.  Settings are       *	only written to the controller if changes were made.   */static int sa1100fb_activate_var(struct fb_var_screeninfo *var, struct sa1100fb_info *fbi){	struct sa1100fb_lcd_reg new_regs;	u_int half_screen_size, yres, pcd = get_pcd(var->pixclock);	u_long flags;	DPRINTK("Configuring SA1100 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);#if DEBUG_VAR	if (var->xres < 16        || var->xres > 1024)		printk(KERN_ERR "%s: invalid xres %d\n",			fbi->fb.fix.id, var->xres);	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_LEN | LCCR0_LDM | LCCR0_BAM |		LCCR0_ERM | LCCR0_LtlEnd | LCCR0_DMADel(0);	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, then we need to halve	 * the YRES parameter.	 */	yres = var->yres;	if (fbi->lccr0 & LCCR0_Dual)		yres /= 2;	new_regs.lccr2 =		LCCR2_DisHght(yres) +		LCCR2_VrtSnchWdth(var->vsync_len) +		LCCR2_BegFrmDel(var->upper_margin) +		LCCR2_EndFrmDel(var->lower_margin);	new_regs.lccr3 = fbi->lccr3 |		(var->sync & FB_SYNC_HOR_HIGH_ACT ? LCCR3_HorSnchH : LCCR3_HorSnchL) |		(var->sync & FB_SYNC_VERT_HIGH_ACT ? LCCR3_VrtSnchH : LCCR3_VrtSnchL) |		LCCR3_ACBsCntOff;	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);	half_screen_size = var->bits_per_pixel;	half_screen_size = half_screen_size * var->xres * var->yres / 16;	/* Update shadow copy atomically */	local_irq_save(flags);	fbi->dbar1 = fbi->palette_dma;	fbi->dbar2 = fbi->screen_dma + half_screen_size;	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) ||	    (DBAR1 != fbi->dbar1) || (DBAR2 != fbi->dbar2))		sa1100fb_schedule_task(fbi, C_REENABLE);	return 0;}/* * NOTE!  The following functions are purely helpers for set_ctrlr_state. * Do not call them directly; set_ctrlr_state does the correct serialisation * to ensure that things happen in the right way 100% of time time. *	-- rmk *//* * FIXME: move LCD power stuff into sa1100fb_power_up_lcd() * Also, I'm expecting that the backlight stuff should * be handled differently. */static void sa1100fb_backlight_on(struct sa1100fb_info *fbi){	DPRINTK("backlight on\n");#ifdef CONFIG_SA1100_FREEBIRD#error FIXME	if (machine_is_freebird()) {		BCR_set(BCR_FREEBIRD_LCD_PWR | BCR_FREEBIRD_LCD_DISP);	}#endif#ifdef CONFIG_SA1100_FREEBIRD	if (machine_is_freebird()) {		/* Turn on backlight ,Chester */		BCR_set(BCR_FREEBIRD_LCD_BACKLIGHT);	}#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL#error FIXME	if (machine_is_huw_webpanel()) {		BCR_set(BCR_CCFL_POW + BCR_PWM_BACKLIGHT);		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_task(200 * HZ / 1000);		BCR_set(BCR_TFT_ENA);	}#endif#ifdef CONFIG_SA1100_OMNIMETER	if (machine_is_omnimeter())		LEDBacklightOn();#endif#ifdef CONFIG_SA1100_FRODO	if (machine_is_frodo())		frodo_cpld_set (FRODO_CPLD_GENERAL,FRODO_LCD_BACKLIGHT);#endif}/* * FIXME: move LCD power stuf into sa1100fb_power_down_lcd() * Also, I'm expecting that the backlight stuff should * be handled differently. */static void sa1100fb_backlight_off(struct sa1100fb_info *fbi){	DPRINTK("backlight off\n");#ifdef CONFIG_SA1100_FREEBIRD#error FIXME	if (machine_is_freebird()) {		BCR_clear(BCR_FREEBIRD_LCD_PWR | BCR_FREEBIRD_LCD_DISP			  /*| BCR_FREEBIRD_LCD_BACKLIGHT */ );	}#endif#ifdef CONFIG_SA1100_OMNIMETER	if (machine_is_omnimeter())		LEDBacklightOff();#endif#ifdef CONFIG_SA1100_FRODO	if (machine_is_frodo())		frodo_cpld_clear (FRODO_CPLD_GENERAL,FRODO_LCD_BACKLIGHT);#endif}static void sa1100fb_power_up_lcd(struct sa1100fb_info *fbi){	DPRINTK("LCD power on\n");#ifndef ASSABET_PAL_VIDEO	if (machine_is_assabet())		ASSABET_BCR_set(ASSABET_BCR_LCD_ON);#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL	if (machine_is_huw_webpanel())		BCR_clear(BCR_TFT_NPWR);#endif#ifdef CONFIG_SA1100_OMNIMETER	if (machine_is_omnimeter())		LCDPowerOn();#endif	if (machine_is_h3xxx())		set_h3600_egpio( IPAQ_EGPIO_LCD_ON );     /* Turn on power to the LCD */#ifdef CONFIG_SA1100_STORK	if (machine_is_stork()) {		storkSetLCDCPLD(0, 1);		storkSetLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON); 	}#endif#ifdef CONFIG_SA1100_FRODO	if (machine_is_frodo())		sa1100fb_backlight_on(fbi);#endif#ifdef CONFIG_SA1100_ADSBITSYPLUS	if (machine_is_adsbitsyplus()) {		ADS_CPLD_PCON &= ~ADS_PCON_PANEL_ON;		ADS_CPLD_SUPPC |= ADS_SUPPC_VEE_ON;	}#endif}static void sa1100fb_power_down_lcd(struct sa1100fb_info *fbi){	DPRINTK("LCD power off\n");#ifndef ASSABET_PAL_VIDEO	if (machine_is_assabet())		ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL	// dont forget to set the control lines to zero (?)	if (machine_is_huw_webpanel())		BCR_set(BCR_TFT_NPWR);#endif	if (machine_is_h3xxx())		clr_h3600_egpio( IPAQ_EGPIO_LCD_ON );#ifdef CONFIG_SA1100_STORK	if (machine_is_stork()) {		storkSetLCDCPLD(0, 0);		storkClearLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON);	}#endif#ifdef CONFIG_SA1100_FRODO	if (machine_is_frodo())		sa1100fb_backlight_off(fbi);#endif#ifdef CONFIG_SA1100_ADSBITSYPLUS	if (machine_is_adsbitsyplus()) {		ADS_CPLD_PCON |= ADS_PCON_PANEL_ON;		ADS_CPLD_SUPPC &= ~ADS_SUPPC_VEE_ON;	}#endif}static void sa1100fb_setup_gpio(struct sa1100fb_info *fbi){	u_int mask = 0;	/*	 * Enable GPIO<9:2> for LCD use if:	 *  1. Active display, or	 *  2. Color Dual Passive display	 *	 * see table 11.8 on page 11-27 in the SA1100 manual	 *   -- Erik.	 *	 * SA1110 spec update nr. 25 says we can and should	 * clear LDD15 to 12 for 4 or 8bpp modes with active	 * panels.  	 */	if ((fbi->reg_lccr0 & LCCR0_CMS) == LCCR0_Color &&	    (fbi->reg_lccr0 & (LCCR0_Dual|LCCR0_Act)) != 0) {		mask = GPIO_LDD11 | GPIO_LDD10 | GPIO_LDD9  | GPIO_LDD8;		if (fbi->fb.var.bits_per_pixel > 8 ||		    (fbi->reg_lccr0 & (LCCR0_Dual|LCCR0_Act)) == LCCR0_Dual)			mask |= GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12;	}#ifdef CONFIG_SA1100_FREEBIRD#error Please contact <rmk@arm.linux.org.uk> about this	if (machine_is_freebird()) {		/* Color single passive */		mask |= GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 |			GPIO_LDD11 | GPIO_LDD10 | GPIO_LDD9  | GPIO_LDD8;	}#endif	if (machine_is_cerf()) {		/* GPIO15 is used as a bypass for 3.8" displays */		mask |= GPIO_GPIO15;#ifdef CONFIG_SA1100_CERF#warning Read Me Now!#endif#if 0 /* if this causes you problems, mail <rmk@arm.linux.org.uk> please. */      /*       * This was enabled for the 72_A version only, which is a _color_       * _dual_ LCD.  Now look at the generic test above, and calculate       * the mask value for a colour dual display...       *       * I therefore conclude that the code below is redundant, and will       * be killed at the start of November 2001.       */		/* FIXME: why is this? The Cerf's display doesn't seem		 * to be dual scan or active. I just leave it here,		 * but in my opinion this is definitively wrong.		 *  -- Erik <J.A.K.Mouw@its.tudelft.nl>		 */		/* REPLY: Umm.. Well to be honest, the 5.7" LCD which		 * this was used for does not use these pins, but		 * apparently all hell breaks loose if they are not		 * set on the Cerf, so we decided to leave them in ;)		 *  -- Daniel Chemko <dchemko@intrinsyc.com>		 */		/* color {dual/single} passive */		mask |= GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 |			GPIO_LDD11 | GPIO_LDD10 | GPIO_LDD9  | GPIO_LDD8;#endif	}	if (mask) {		GPDR |= mask;		GAFR |= mask;	}}static void sa1100fb_enable_controller(struct sa1100fb_info *fbi){	DPRINTK("Enabling LCD controller\n");	/*	 * Make sure the mode bits are present in the first palette entry	 */	fbi->palette_cpu[0] &= 0xcfff;	fbi->palette_cpu[0] |= palette_pbs(&fbi->fb.var);	/* Sequence from 11.7.10 */	LCCR3 = fbi->reg_lccr3;	LCCR2 = fbi->reg_lccr2;	LCCR1 = fbi->reg_lccr1;	LCCR0 = fbi->reg_lccr0 & ~LCCR0_LEN;	DBAR1 = fbi->dbar1;	DBAR2 = fbi->dbar2;	LCCR0 |= LCCR0_LEN;#ifdef CONFIG_SA1100_GRAPHICSCLIENT	if (machine_is_graphicsclient()) {		// From ADS doc again...same as disable		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(20 * HZ / 1000);		GPDR |= GPIO_GPIO24;		GPSR = GPIO_GPIO24;	}#endif#ifdef CONFIG_SA1100_GRAPHICSMASTER	if (machine_is_graphicsmaster()) {		// From ADS doc again...same as disable		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(20 * HZ / 1000);		GPDR |= GPIO_GPIO24;		GPSR = GPIO_GPIO24;	}#endif	if (machine_is_shannon()) {		GPDR |= SHANNON_GPIO_DISP_EN;		GPSR |= SHANNON_GPIO_DISP_EN;	}		DPRINTK("DBAR1 = %p\n", DBAR1);	DPRINTK("DBAR2 = %p\n", DBAR2);	DPRINTK("LCCR0 = 0x%08x\n", LCCR0);	DPRINTK("LCCR1 = 0x%08x\n", LCCR1);	DPRINTK("LCCR2 = 0x%08x\n", LCCR2);	DPRINTK("LCCR3 = 0x%08x\n", LCCR3);}static void sa1100fb_disable_controller(struct sa1100fb_info *fbi){	DECLARE_WAITQUEUE(wait, current);	DPRINTK("Disabling LCD controller\n");#ifdef CONFIG_SA1100_GRAPHICSCLIENT	if (machine_is_graphicsclient()) {		/*		 * From ADS internal document:		 *  GPIO24 should be LOW at least 10msec prior to disabling		 *  the LCD interface.		 *		 * We'll wait 20msec.		 */		GPDR |= GPIO_GPIO24;		GPCR |= GPIO_GPIO24;		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(20 * HZ / 1000);	}#endif#ifdef CONFIG_SA1100_GRAPHICSMASTER	if (machine_is_graphicsmaster()) {		/*		 * From ADS internal document:		 *  GPIO24 should be LOW at least 10msec prior to disabling		 *  the LCD interface.		 *		 * We'll wait 20msec.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -