📄 s3c2410fb.c
字号:
//#endif //LCDINTMSK |=(3); LCDLPCSEL &= (~7); TPAL = 0; #ifdef CONFIG_S3C2410_SMDK_STN_640480 DITHMODE=0x0; REDLUT =0xfdb96420; GREENLUT=0xfdb96420; BLUELUT =0xfb40; #endif LCDCON1 |= LCD1_ENVID;#if 0 { printk("con1 = 0x%08lx\n", LCDCON1); printk("con2 = 0x%08lx\n", LCDCON2); printk("con3 = 0x%08lx\n", LCDCON3); printk("con4 = 0x%08lx\n", LCDCON4); printk("con5 = 0x%08lx\n", LCDCON5); printk("addr1 = 0x%08lx\n", LCDADDR1); printk("addr2 = 0x%08lx\n", LCDADDR2); printk("addr3 = 0x%08lx\n", LCDADDR3); }#endif restore_flags(flags); return 0;}static inline void s3c2410fb_set_truecolor(u_int is_true_color){ if (is_true_color) { } else { }} static voids3c2410fb_hw_set_var(struct fb_var_screeninfo *var, struct s3c2410fb_info *fbi){ u_long palette_mem_size; fbi->palette_size = var->bits_per_pixel == 8 ? 256 : 16; 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); 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);}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;int i,j,k; 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) {#ifdef FBCON_HAS_CFB4 case 4: if (fbi->cmap_static) display->visual = FB_VISUAL_STATIC_PSEUDOCOLOR; else display->visual = FB_VISUAL_PSEUDOCOLOR; display->line_length = var->xres / 2; display->dispsw = &fbcon_cfb4; rgbidx = RGB_8; break;#endif#ifdef FBCON_HAS_CFB8 case 8: if (fbi->cmap_static) display->visual = FB_VISUAL_STATIC_PSEUDOCOLOR; else display->visual = FB_VISUAL_PSEUDOCOLOR; display->line_length = var->xres; display->dispsw = &fbcon_cfb8; rgbidx = RGB_8; break;#endif#ifdef FBCON_HAS_CFB16 case 16: display->visual = FB_VISUAL_TRUECOLOR;#ifdef CONFIG_FB_S3C2410_EMUL display->line_length = 240*2;#else display->line_length = var->xres * 2;#endif display->dispsw = &fbcon_cfb16; display->dispsw_data = fbi->fb.pseudo_palette; rgbidx = RGB_16; break;#endif 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 = 0; display->inverse = fbi->cmap_inverse; *dvar = *var; dvar->activate &= ~FB_ACTIVATE_ALL; dvar->red = fbi->rgb[rgbidx]->red; dvar->green = fbi->rgb[rgbidx]->green; dvar->blue = fbi->rgb[rgbidx]->blue; dvar->transp = fbi->rgb[rgbidx]->transp; display->var = *dvar; if (var->activate & FB_ACTIVATE_ALL) fbi->fb.disp->var = *dvar; if (chgvar && info && fbi->fb.changevar) fbi->fb.changevar(con); 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; 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;}#ifdef CONFIG_PMstatic ints3c2410fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg, int con, struct fb_info *info) {#ifdef CONFIG_MIZI if (mz_pm_ops.fb_ioctl == NULL) return -EINVAL; return (*(mz_pm_ops.fb_ioctl))(inode, file, cmd, arg, PROC_CONSOLE(info), info);#endif /* CONFIG_MIZI */}#endif /* CONFIG_PM */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,#ifdef CONFIG_PM fb_ioctl: s3c2410fb_ioctl,#endif /* CONFIG_PM */};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; 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; 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;}#ifdef CONFIG_PM/* * Power management hook. Note that we won't be called from IRQ context, * unlike the blank functions above, so we may sleep */static int s3c2410_pm_callback(struct pm_dev *pm_dev, pm_request_t req, void *data){ struct s3c2410fb_info *fbi = pm_dev->data; u_long flags; //printk("pm_callback: %d\n", req); if (req == PM_SUSPEND) { /* disable LCD controller */ LCDCON1 &= ~(1 << 0); } else if (req == PM_RESUME) { /* reinitialize LCD controllers and GPIOs */ save_flags_cli(flags); LCDCON1 = fbi->reg.lcdcon1; LCDCON2 = fbi->reg.lcdcon2; LCDCON3 = fbi->reg.lcdcon3; LCDCON4 = fbi->reg.lcdcon4; LCDCON5 = fbi->reg.lcdcon5; LCDADDR1 = fbi->reg.lcdsaddr1; LCDADDR2 = fbi->reg.lcdsaddr2; LCDADDR3 = fbi->reg.lcdsaddr3;//#if defined(CONFIG_S3C2410_SMDK) && !defined(CONFIG_SMDK_AIJI) LCDLPCSEL = 0x2; //#elif defined(CONFIG_S3C2410_SMDK) && defined(CONFIG_SMDK_AIJI) LCDLPCSEL = 0x7;//#endif LCDLPCSEL &= (~7); TPAL = 0; LCDCON1 |= LCD1_ENVID; restore_flags(flags); } //printk("done\n"); return 0;}#endifstatic int __init s3c2410fb_map_video_memory(struct s3c2410fb_info *fbi){ fbi->map_size = PAGE_ALIGN(fbi->fb.fix.smem_len + PAGE_SIZE); fbi->map_cpu = consistent_alloc(GFP_KERNEL, fbi->map_size, &fbi->map_dma); if (fbi->map_cpu) { fbi->screen_cpu = fbi->map_cpu + PAGE_SIZE; fbi->screen_dma = fbi->map_dma + PAGE_SIZE; fbi->fb.fix.smem_start = fbi->screen_dma; } return fbi->map_cpu ? 0 : -ENOMEM;}static int s3c2410fb_updatevar(int con, struct fb_info *info){ return 0;}static void s3c2410fb_blank(int blank, struct fb_info *info){}static struct fb_monspecs monspecs __initdata = { 30000, 70000, 50, 65, 0};static struct s3c2410fb_info * __init s3c2410fb_init_fbinfo(void){ struct s3c2410fb_mach_info *inf; struct s3c2410fb_info *fbi; fbi = kmalloc(sizeof(struct s3c2410fb_info) + sizeof(struct display) + sizeof(u16)*16, GFP_KERNEL); if (!fbi) return NULL; memset(fbi, 0, sizeof(struct s3c2410fb_info) + sizeof(struct display)); fbi->currcon = -1; strcpy(fbi->fb.fix.id, S3C2410_NAME); fbi->fb.fix.type = FB_TYPE_PACKED_PIXELS; fbi->fb.fix.type_aux = 0; fbi->fb.fix.xpanstep = 0; fbi->fb.fix.ypanstep = 0; fbi->fb.fix.ywrapstep = 0; fbi->fb.fix.accel = FB_ACCEL_NONE; fbi->fb.var.nonstd = 0; fbi->fb.var.activate = FB_ACTIVATE_NOW; fbi->fb.var.height = -1; fbi->fb.var.width = -1; fbi->fb.var.accel_flags = 0; fbi->fb.var.vmode = FB_VMODE_NONINTERLACED; strcpy(fbi->fb.modename, S3C2410_NAME); strcpy(fbi->fb.fontname, "Acorn8x8"); fbi->fb.fbops = &s3c2410fb_ops; fbi->fb.changevar = NULL; fbi->fb.switch_con = s3c2410fb_switch; fbi->fb.updatevar = s3c2410fb_updatevar; fbi->fb.blank = s3c2410fb_blank; fbi->fb.flags = FBINFO_FLAG_DEFAULT; fbi->fb.node = -1; fbi->fb.monspecs = monspecs; fbi->fb.disp = (struct display *)(fbi + 1); fbi->fb.pseudo_palette = (void *)(fbi->fb.disp + 1); fbi->rgb[RGB_8] = &rgb_8; fbi->rgb[RGB_16] = &def_rgb_16; inf = s3c2410fb_get_machine_info(fbi);#ifdef CONFIG_FB_S3C2410_EMUL fbi->max_xres = 240;#else fbi->max_xres = inf->xres;#endif fbi->fb.var.xres = inf->xres; fbi->fb.var.xres_virtual = inf->xres; fbi->max_yres = inf->yres; fbi->fb.var.yres = inf->yres; fbi->fb.var.yres_virtual = inf->yres; fbi->max_bpp = inf->bpp; fbi->fb.var.bits_per_pixel = inf->bpp; fbi->fb.var.pixclock = inf->pixclock; fbi->fb.var.hsync_len = inf->hsync_len; fbi->fb.var.left_margin = inf->left_margin; fbi->fb.var.right_margin = inf->right_margin; fbi->fb.var.vsync_len = inf->vsync_len; fbi->fb.var.upper_margin = inf->upper_margin; fbi->fb.var.lower_margin = inf->lower_margin; fbi->fb.var.sync = inf->sync; fbi->fb.var.grayscale = inf->cmap_grayscale; fbi->cmap_inverse = inf->cmap_inverse; fbi->cmap_static = inf->cmap_static; fbi->fb.fix.smem_len = fbi->max_xres * fbi->max_yres * fbi->max_bpp / 8; return fbi;}void s3c2410_lcd_init(void){ GPCUP = 0xffffffff; GPDUP = 0xffffffff; GPDCON = 0xaaaaaaaa;#ifdef CONFIG_S3C2410_SMDK_320240 GPBCON = (GPBCON & (~(1<<11))) | (1<<10); GPBDAT = GPBDAT | (1 << 5); printk("test lcd backlight\n");#endif#ifdef CONFIG_S3C2410_SMDK GPCCON = 0xaaaaaaaa; //set_gpio_ctrl(GPIO_G4 | GPIO_PULLUP_EN | GPIO_MODE_LCD_PWRDN); set_gpio_ctrl(GPIO_G4 | GPIO_PULLUP_DIS | GPIO_MODE_LCD_PWRDN);#endif#ifdef CONFIG_S3C2410_SMDK_800480_WHL GPGUP=GPGUP&(~(1<<4))|(1<<4); // Pull-up disable GPGCON=GPGCON&(~(3<<8))|(3<<8); //GPG4=LCD_PWREN#endif#if defined(CONFIG_MIZI) && defined(CONFIG_PM) && defined(sdfs) if (mz_pm_ops.blank_helper != NULL) (*(mz_pm_ops.blank_helper))(MZ_BLANK_ON);#endif }int __init s3c2410fb_init(void){ struct s3c2410fb_info *fbi; int ret; int i,j,k; fbi = s3c2410fb_init_fbinfo(); ret = -ENOMEM; if (!fbi) goto failed; ret = s3c2410fb_map_video_memory(fbi); if (ret) goto failed; s3c2410_lcd_init(); s3c2410fb_set_var(&fbi->fb.var, -1, &fbi->fb); ret = register_framebuffer(&fbi->fb); if (ret < 0) goto failed;#ifdef CONFIG_PM /* * Note that console registers this as well, but we want to * power donw the display prior to sleeping */ fbi->pm = pm_register(PM_DEBUG_DEV, PM_SYS_VGA, s3c2410_pm_callback); if (fbi->pm) fbi->pm->data = fbi;#endif /* enable the LCD controller) */ #ifdef CONFIG_S3C2410_SMDK_800480 printk("Installed S3C2410 frame buffer for TFT 800x480 LCD.\n"); #endif #ifdef CONFIG_S3C2410_SMDK_640480 printk("Installed S3C2410 frame buffer for TFT 640x480 LCD.\n"); #endif #ifdef CONFIG_S3C2410_SMDK_320240 printk("Installed S3C2410 frame buffer for TFT 320x240 LCD.\n"); #endif #ifdef CONFIG_S3C2410_SMDK_STN_640480 printk("Installed S3C2410 frame buffer for STN 640x480 LCD.\n"); #endif #ifdef CONFIG_S3C2410_SMDK_240320 printk("Installed S3C2410 frame buffer for TFT 240x320 LCD.\n"); #endif //printk("Installed S3C2410 frame buffer\n"); MOD_INC_USE_COUNT ; return 0;failed: if (fbi) kfree(fbi); return ret;}int __init s3c2410fb_setup(char *options){ return 0;}#ifdef MODULEmodule_init(s3c2410fb_init);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -