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

📄 s3c2410fb.c

📁 s3c2410在linux2.4.18上LCD移植
💻 C
📖 第 1 页 / 共 3 页
字号:
{	int ret = -EINVAL;	if (var->xres < MIN_XRES)		var->xres = MIN_XRES;	if (var->yres < MIN_YRES)		var->yres = MIN_YRES;	if (var->xres > fbi->max_xres)		var->xres = fbi->max_xres;	if (var->yres > fbi->max_yres)		var->yres = fbi->max_yres;	var->xres_virtual =	    var->xres_virtual < var->xres ? var->xres : var->xres_virtual;	var->yres_virtual =	    var->yres_virtual < var->yres ? var->yres : var->yres_virtual;	switch (var->bits_per_pixel) {#ifdef FBCON_HAS_CFB4	case 4:		ret = 0; break;#endif#ifdef FBCON_HAS_CFB8	case 8:		ret = 0; break;#endif#ifdef FBCON_HAS_CFB16	case 16:	ret = 0; break;#endif	default:		break;	}	return ret;}static inline void s3c2410fb_set_truecolor(u_int is_true_color){	DPRINTK("true_color = %d\n", is_true_color);}static voids3c2410fb_hw_set_var(struct fb_var_screeninfo *var, struct s3c2410fb_info *fbi){	u_long palette_mem_size;	fbi->palette_size =  256;	palette_mem_size = fbi->palette_size * sizeof(u16);	fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size);	fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size;	fb_set_cmap(&fbi->fb.cmap, 1, s3c2410fb_setcolreg, &fbi->fb);	/* Set board control register to handle new color depth */	s3c2410fb_set_truecolor(var->bits_per_pixel >= 16);	s3c2410fb_activate_var(var, fbi);	fbi->palette_cpu[0] = (fbi->palette_cpu[0] &					 0xcfff) | palette_pbs(var);}/* * s3c2410fb_set_var(): *	Set the user defined part of the display for the specified console */static ints3c2410fb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info){	struct s3c2410fb_info *fbi = (struct s3c2410fb_info *)info;	struct fb_var_screeninfo *dvar = get_con_var(&fbi->fb, con);	struct display *display = get_con_display(&fbi->fb, con);	int err, chgvar = 0, rgbidx;	/*	 * Decode var contents into a par structure, adjusting any	 * out of range values.	 */	err = s3c2410fb_validate_var(var, fbi);	if (err)	return err;	if (var->activate & FB_ACTIVATE_TEST)	{			return 0;	}	if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)	{		return -EINVAL;	}	if (dvar->xres != var->xres)		chgvar = 1;	if (dvar->yres != var->yres)		chgvar = 1;	if (dvar->xres_virtual != var->xres_virtual)		chgvar = 1;	if (dvar->yres_virtual != var->yres_virtual)		chgvar = 1;	if (dvar->bits_per_pixel != var->bits_per_pixel)		chgvar = 1;	if (con < 0)		chgvar = 0;	switch (var->bits_per_pixel) {	case 16:		display->visual		= FB_VISUAL_TRUECOLOR;		display->line_length	= var->xres * 2;		display->dispsw		= &fbcon_cfb16;		display->dispsw_data	= fbi->fb.pseudo_palette;		rgbidx			= RGB_16;		break;	default:		rgbidx = 0;		display->dispsw = &fbcon_dummy;		break;	}	display->screen_base	= fbi->screen_cpu;	display->next_line	= display->line_length;	display->type		= fbi->fb.fix.type;	display->type_aux	= fbi->fb.fix.type_aux;	display->ypanstep	= fbi->fb.fix.ypanstep;	display->ywrapstep	= fbi->fb.fix.ywrapstep;	display->can_soft_blank	= 1;	display->inverse	= fbi->cmap_inverse;	*dvar			= *var;	dvar->activate		&= ~FB_ACTIVATE_ALL;	/*	 * Copy the RGB parameters for this display	 * from the machine specific parameters.	 */	dvar->red		= fbi->rgb[rgbidx]->red;	dvar->green		= fbi->rgb[rgbidx]->green;	dvar->blue		= fbi->rgb[rgbidx]->blue;	dvar->transp		= fbi->rgb[rgbidx]->transp;	/*	 * Update the old var.  The fbcon drivers still use this.	 * Once they are using fbi->fb.var, this can be dropped.	 */	display->var = *dvar;	/*	 * If we are setting all the virtual consoles, also set the	 * defaults used to create new consoles.	 */	if (var->activate & FB_ACTIVATE_ALL)		fbi->fb.disp->var = *dvar;	/*	 * If the console has changed and the console has defined	 * a changevar function, call that function.	 */	if (chgvar && info && fbi->fb.changevar)		fbi->fb.changevar(con);	/* If the current console is selected, activate the new var. */	if (con != fbi->currcon)		return 0;	s3c2410fb_hw_set_var(dvar, fbi);	return 0;}static int__do_set_cmap(struct fb_cmap *cmap, int kspc, int con,	      struct fb_info *info){	struct s3c2410fb_info *fbi = (struct s3c2410fb_info *)info;	struct fb_cmap *dcmap = get_con_cmap(info, con);	int err = 0;	if (con == -1)		con = fbi->currcon;	/* no colormap allocated? (we always have "this" colour map allocated) */	if (con >= 0)		err = fb_alloc_cmap(&fb_display[con].cmap, fbi->palette_size, 0);	if (!err && con == fbi->currcon)		err = fb_set_cmap(cmap, kspc, s3c2410fb_setcolreg, info);	if (!err)		fb_copy_cmap(cmap, dcmap, kspc ? 0 : 1);	return err;}static ints3c2410fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,		  struct fb_info *info){	struct display *disp = get_con_display(info, con);	if (disp->visual == FB_VISUAL_TRUECOLOR ||	    disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR)		return -EINVAL;	return __do_set_cmap(cmap, kspc, con, info);}static ints3c2410fb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info){	struct display *display = get_con_display(info, con);	*fix = info->fix;	fix->line_length = display->line_length;	fix->visual	 = display->visual;	return 0;}static ints3c2410fb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info){	*var = *get_con_var(info, con);	return 0;}static ints3c2410fb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){	struct fb_cmap *dcmap = get_con_cmap(info, con);	fb_copy_cmap(dcmap, cmap, kspc ? 0 : 2);	return 0;}static struct fb_ops s3c2410fb_ops = {	owner:		THIS_MODULE,	fb_get_fix:	s3c2410fb_get_fix,	fb_get_var:	s3c2410fb_get_var,	fb_set_var:	s3c2410fb_set_var,	fb_get_cmap:	s3c2410fb_get_cmap,	fb_set_cmap:	s3c2410fb_set_cmap,};/* *  s3c2410fb_switch():        *	Change to the specified console.  Palette and video mode *      are changed to the console's stored parameters. * *	Uh oh, this can be called from a tasklet (IRQ) */static int s3c2410fb_switch(int con, struct fb_info *info){	struct s3c2410fb_info *fbi = (struct s3c2410fb_info *)info;	struct display *disp;	struct fb_cmap *cmap;	if (con == fbi->currcon)		return 0;	if (fbi->currcon >= 0) {		disp = fb_display + fbi->currcon;		/*		 * Save the old colormap and video mode.		 */		disp->var = fbi->fb.var;		if (disp->cmap.len)			fb_copy_cmap(&fbi->fb.cmap, &disp->cmap, 0);	}	fbi->currcon = con;	disp = fb_display + con;	/*	 * Make sure that our colourmap contains 256 entries.	 */	fb_alloc_cmap(&fbi->fb.cmap, 256, 0);	if (disp->cmap.len)		cmap = &disp->cmap;	else		cmap = fb_default_cmap(1 << disp->var.bits_per_pixel);	fb_copy_cmap(cmap, &fbi->fb.cmap, 0);	fbi->fb.var = disp->var;	fbi->fb.var.activate = FB_ACTIVATE_NOW;	s3c2410fb_set_var(&fbi->fb.var, con, info);	return 0;}/* * Formal definition of the VESA spec: *  On *  	This refers to the state of the display when it is in full operation *  Stand-By *  	This defines an optional operating state of minimal power reduction with *  	the shortest recovery time *  Suspend *  	This refers to a level of power management in which substantial power *  	reduction is achieved by the display.  The display can have a longer  *  	recovery time from this state than from the Stand-by state *  Off *  	This indicates that the display is consuming the lowest level of power *  	and is non-operational. Recovery from this state may optionally require *  	the user to manually power on the monitor * *  Now, the fbdev driver adds an additional state, (blank), where they *  turn off the video (maybe by colormap tricks), but don't mess with the *  video itself: think of it semantically between on and Stand-By. * *  So here's what we should do in our fbdev blank routine: * *  	VESA_NO_BLANKING (mode 0)	Video on,  front/back light on *  	VESA_VSYNC_SUSPEND (mode 1)  	Video on,  front/back light off *  	VESA_HSYNC_SUSPEND (mode 2)  	Video on,  front/back light off *  	VESA_POWERDOWN (mode 3)		Video off, front/back light off * *  This will match the matrox implementation. *//* * s3c2410fb_blank(): *	Blank the display by setting all palette values to zero.  Note, the  * 	12 and 16 bpp modes don't really use the palette, so this will not *      blank the display in all modes. *      blank = 0 unblank ; *      blank > 0 , VESA level          */static void s3c2410fb_blank(int blank, struct fb_info *info){#ifdef S3C2410_REAL_BLANK	struct s3c2410fb_info *fbi = (struct s3c2410fb_info *)info;	int i,j;        struct FrameBuffer * pBlankFB;#endif#ifdef S3C2410_SUPPORT_PALETTE	switch (blank) {	case VESA_POWERDOWN:	case VESA_VSYNC_SUSPEND:	case VESA_HSYNC_SUSPEND:	case VESA_NO_BLANKING:		if (s3c2410fb_blank_helper)			s3c2410fb_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, s3c2410fb_setcolreg, info);		s3c2410fb_schedule_task(fbi, C_ENABLE);	}#endif#ifdef S3C2410_REAL_BLANK        pBlankFB = (struct FrameBuffer *) (fbi->screen_cpu);        for(i=0 ;i<FR_HEIGHT;i++)               for(j=0;j<FR_WIDTH;j++)                           pBlankFB->pixel[i][j]= 0xffff; #endif }static int s3c2410fb_updatevar(int con, struct fb_info *info){	DPRINTK("entered\n");	return 0;}/* * s3c2410fb_activate_var(): *	Configures LCD Controller based on entries in var parameter.  Settings are       *	only written to the controller if changes were made.   */static int s3c2410fb_activate_var(struct fb_var_screeninfo *var, struct s3c2410fb_info *fbi){	struct s3c2410fb_lcd_reg new_regs;	u_long flags;#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);

⌨️ 快捷键说明

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