void fbgen_install_cmap(int con, struct fb_info_gen *info) { struct fbgen_hwswitch *fbhw = info->fbhw; if (con != currcon) return; if (fb_display[con].cmap.len) fb_set_cmap(&fb_display[con].cmap, 1, fbhw->setcolreg, &info->info); else { int size = fb_display[con].var.bits_per_pixel == 16 ? 64 : 256; fb_set_cmap(fb_default_cmap(size), 1, fbhw->setcolreg, &info->info); } }
static void do_install_cmap(int con, struct fb_info *fb_info) { struct fb_info_iga *info = (struct fb_info_iga*) fb_info; if (con != info->currcon) return; if (fb_display[con].cmap.len) fb_set_cmap(&fb_display[con].cmap, 1, iga_setcolreg, &info->fb_info); else fb_set_cmap(fb_default_cmap(info->video_cmap_len), 1, iga_setcolreg, &info->fb_info); }
int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info) { int rc, size = cmap->len * sizeof(u16); struct fb_cmap umap; memset(&umap, 0, sizeof(struct fb_cmap)); rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL); if (rc) return rc; if (copy_from_user(umap.red, cmap->red, size) || copy_from_user(umap.green, cmap->green, size) || copy_from_user(umap.blue, cmap->blue, size) || (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) { rc = -EFAULT; goto out; } umap.start = cmap->start; if (!lock_fb_info(info)) { rc = -ENODEV; goto out; } if (cmap->start < 0 || (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap)) { rc = -EINVAL; goto out1; } rc = fb_set_cmap(&umap, info); out1: unlock_fb_info(info); out: fb_dealloc_cmap(&umap); return rc; }
static void fb_set_logocmap(struct fb_info *info, const struct linux_logo *logo) { struct fb_cmap palette_cmap; u16 palette_green[16]; u16 palette_blue[16]; u16 palette_red[16]; int i, j, n; const unsigned char *clut = logo->clut; palette_cmap.start = 0; palette_cmap.len = 16; palette_cmap.red = palette_red; palette_cmap.green = palette_green; palette_cmap.blue = palette_blue; palette_cmap.transp = NULL; for (i = 0; i < logo->clutsize; i += n) { n = logo->clutsize - i; /* palette_cmap provides space for only 16 colors at once */ if (n > 16) n = 16; palette_cmap.start = 32 + i; palette_cmap.len = n; for (j = 0; j < n; ++j) { palette_cmap.red[j] = clut[0] << 8 | clut[0]; palette_cmap.green[j] = clut[1] << 8 | clut[1]; palette_cmap.blue[j] = clut[2] << 8 | clut[2]; clut += 3; } fb_set_cmap(&palette_cmap, info); } }
void fb_cleanup(void) { Debug("fb_cleanup()\n"); if (saved_fb) fb_restore(); if (fb) fb_unmap(); if (fb_fd != -1) { if (saved_cmap.len) { fb_cmap = saved_cmap; RESTORE_AND_FREE_COMPONENT(red); RESTORE_AND_FREE_COMPONENT(green); RESTORE_AND_FREE_COMPONENT(blue); if (fb_cmap.transp) RESTORE_AND_FREE_COMPONENT(transp); fb_set_cmap(); } //fb_var = saved_var; memcpy(&fb_var, &saved_var, sizeof(struct fb_var_screeninfo)); fb_set_var(); fb_get_var(); /* FIXME: compare fb_var with saved_var */ fb_get_fix(); /* FIXME: compare fb_fix with saved_fix */ fb_close(); } }
static int offb_blank(int blank, struct fb_info *info) { struct offb_par *par = (struct offb_par *) info->par; int i, j; if (!par->cmap_adr) return 0; if (!par->blanked) if (!blank) return 0; par->blanked = blank; if (blank) for (i = 0; i < 256; i++) { switch (par->cmap_type) { case cmap_m64: writeb(i, par->cmap_adr); for (j = 0; j < 3; j++) writeb(0, par->cmap_data); break; case cmap_M3A: /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ out_le32(par->cmap_adr + 0x58, in_le32(par->cmap_adr + 0x58) & ~0x20); case cmap_r128: /* Set palette index & data */ out_8(par->cmap_adr + 0xb0, i); out_le32(par->cmap_adr + 0xb4, 0); break; case cmap_M3B: /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ out_le32(par->cmap_adr + 0x58, in_le32(par->cmap_adr + 0x58) | 0x20); /* Set palette index & data */ out_8(par->cmap_adr + 0xb0, i); out_le32(par->cmap_adr + 0xb4, 0); break; case cmap_radeon: out_8(par->cmap_adr + 0xb0, i); out_le32(par->cmap_adr + 0xb4, 0); break; case cmap_gxt2000: out_le32(((unsigned __iomem *) par->cmap_adr) + i, 0); break; case cmap_avivo: writel(1, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT); writeb(i, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX); writel(0, par->cmap_adr + AVIVO_DC_LUT_30_COLOR); writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT); writeb(i, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX); writel(0, par->cmap_adr + AVIVO_DC_LUT_30_COLOR); break; } } else fb_set_cmap(&info->cmap, info); return 0; }
int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info) { int rc, size = cmap->len * sizeof(u16); struct fb_cmap umap; if (size < 0 || size < cmap->len) return -E2BIG; memset(&umap, 0, sizeof(struct fb_cmap)); rc = fb_alloc_cmap_gfp(&umap, cmap->len, cmap->transp != NULL, GFP_KERNEL); if (rc) return rc; if (copy_from_user(umap.red, cmap->red, size) || copy_from_user(umap.green, cmap->green, size) || copy_from_user(umap.blue, cmap->blue, size) || (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) { rc = -EFAULT; goto out; } umap.start = cmap->start; if (!lock_fb_info(info)) { rc = -ENODEV; goto out; } rc = fb_set_cmap(&umap, info); unlock_fb_info(info); out: fb_dealloc_cmap(&umap); return rc; }
int fbgen_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { struct fb_info_gen *info2 = (struct fb_info_gen *)info; struct fbgen_hwswitch *fbhw = info2->fbhw; int err; if (!fb_display[con].cmap.len) { /* no colormap allocated ? */ int size = fb_display[con].var.bits_per_pixel == 16 ? 64 : 256; if ((err = fb_alloc_cmap(&fb_display[con].cmap, size, 0))) return err; } if (con == currcon) /* current console ? */ return fb_set_cmap(cmap, kspc, fbhw->setcolreg, info); else fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1); return 0; }
static int igafb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { int err; struct fb_info_iga *fb = (struct fb_info_iga*) info; if (!fb_display[con].cmap.len) { /* no colormap allocated? */ err = fb_alloc_cmap(&fb_display[con].cmap, fb->video_cmap_len,0); if (err) return err; } if (con == fb->currcon) /* current console? */ return fb_set_cmap(cmap, kspc, iga_setcolreg, info); else fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1); return 0; }
static int stmfb_resume(struct platform_device *pdev) { struct stmfb_info *i = (struct stmfb_info *)platform_get_drvdata(pdev); DPRINTK("\n"); if(!i) return 0; if(pdev->dev.power.power_state.event == PM_EVENT_ON) return 0; acquire_console_sem(); if(down_interruptible(&i->framebufferLock)) { release_console_sem(); return -EINTR; } if(i->pFBMainOutput) stm_display_output_resume(i->pFBMainOutput); if(i->pFBDVO) stm_display_output_resume(i->pFBDVO); up(&i->framebufferLock); /* * Now the hardware is back, kick the framebuffer into life */ fb_pan_display(&i->info, &i->info.var); fb_set_cmap(&i->info.cmap, &i->info); fb_set_suspend(&i->info, 0); release_console_sem(); DPRINTK("resumed\n"); return 0; }
void fbgen_blank(int blank, struct fb_info *info) { struct fb_info_gen *info2 = (struct fb_info_gen *)info; struct fbgen_hwswitch *fbhw = info2->fbhw; u16 black[16]; struct fb_cmap cmap; if (fbhw->blank && !fbhw->blank(blank, info2)) return; if (blank) { memset(black, 0, 16*sizeof(u16)); cmap.red = black; cmap.green = black; cmap.blue = black; cmap.transp = NULL; cmap.start = 0; cmap.len = 16; fb_set_cmap(&cmap, 1, fbhw->setcolreg, info); } else fbgen_install_cmap(currcon, info2); }
/** * fbgen_set_var - set the user defined part of display * @var: fb_var_screeninfo user defined part of the display * @con: virtual console number * @info: frame buffer info structure * * Set the user defined part of the display as dictated by @var * for virtual console @con on device @info. * * Returns negative errno on error, or zero for success. * */ int fbgen_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) { struct fb_bitfield oldred, oldgreen, oldblue, oldalpha; int oldbpp, err; if (memcmp(&info->var, var, sizeof(var)) || con < 0) { if ((err = info->fbops->fb_check_var(var, info))) return err; if (var->activate & FB_ACTIVATE_ALL) info->disp->var = *var; if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) { oldbpp = info->var.bits_per_pixel; oldred = info->var.red; oldblue = info->var.blue; oldgreen = info->var.green; oldalpha = info->var.transp; if (info->fbops->fb_set_par) info->fbops->fb_set_par(info); info->var = *var; fbgen2_set_disp(con, info); if (info->changevar) (*info->changevar)(con); if (oldbpp != var->bits_per_pixel || memcmp(&oldred,&info->var.red,sizeof(oldred)) || memcmp(&oldgreen,&info->var.green,sizeof(oldgreen)) || memcmp(&oldblue, &info->var.blue, sizeof(oldblue)) || memcmp(&oldalpha,&info->var.transp,sizeof(oldalpha))){ if ((err = fb_alloc_cmap(&info->cmap, 0, 0))) return err; fb_set_cmap(&info->cmap, 1, info->fbops->fb_setcolreg, info); } } var->activate = 0; } return 0; }
static int sun3fb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { int err; if (!fb_display[con].cmap.len) { /* no colormap allocated? */ if ((err = fb_alloc_cmap(&fb_display[con].cmap, 1<<fb_display[con].var.bits_per_pixel, 0))) return err; } if (con == info->currcon) { /* current console? */ err = fb_set_cmap(cmap, kspc, info); if (!err) { struct fb_info_sbusfb *fb = sbusfbinfo(info); if (fb->loadcmap) (*fb->loadcmap)(fb, &fb_display[con], cmap->start, cmap->len); } return err; } else fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1); return 0; }
int fbgen_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { struct fb_cmap *dcmap; int err = 0; if (con == info->currcon) dcmap = &info->cmap; else dcmap = &fb_display[con].cmap; /* no colormap allocated? */ if (!dcmap->len) err = fb_alloc_cmap(dcmap, 256, 0); if (!err && con == info->currcon) err = fb_set_cmap(cmap, kspc, info->fbops->fb_setcolreg, info); if (!err) fb_copy_cmap(cmap, dcmap, kspc ? 0 : 1); return err; }
int radeonfb_pci_resume(struct pci_dev *pdev) { struct fb_info *info = pci_get_drvdata(pdev); struct radeonfb_info *rinfo = info->par; if (pdev->dev.power_state == 0) return 0; acquire_console_sem(); /* Wakeup chip */ #ifdef CONFIG_RADEON_HAS_D2 if (radeon_suspend_to_d2(rinfo, 0)) radeon_set_suspend(rinfo, 0); #endif /* CONFIG_RADEON_HAS_D2 */ rinfo->asleep = 0; /* Restore display & engine */ radeonfb_set_par(info); fb_pan_display(info, &info->var); fb_set_cmap(&info->cmap, 1, info); /* Refresh */ fb_set_suspend(info, 0); /* Unblank */ rinfo->lock_blank = 0; radeonfb_blank(0, info); release_console_sem(); pdev->dev.power_state = 0; printk(KERN_DEBUG "radeonfb: resumed !\n"); return 0; }
int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info) { int rc, size = cmap->len * sizeof(u16); struct fb_cmap umap; if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) return -EINVAL; memset(&umap, 0, sizeof(struct fb_cmap)); rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL); if (rc) return rc; if (copy_from_user(umap.red, cmap->red, size) || copy_from_user(umap.green, cmap->green, size) || copy_from_user(umap.blue, cmap->blue, size) || (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) { fb_dealloc_cmap(&umap); return -EFAULT; } umap.start = cmap->start; rc = fb_set_cmap(&umap, info); fb_dealloc_cmap(&umap); return rc; }
static int tcx_probe(struct platform_device *op) { struct device_node *dp = op->dev.of_node; struct fb_info *info; struct tcx_par *par; int linebytes, i, err; info = framebuffer_alloc(sizeof(struct tcx_par), &op->dev); err = -ENOMEM; if (!info) goto out_err; par = info->par; spin_lock_init(&par->lock); par->lowdepth = (of_find_property(dp, "tcx-8-bit", NULL) != NULL); sbusfb_fill_var(&info->var, dp, 8); info->var.red.length = 8; info->var.green.length = 8; info->var.blue.length = 8; linebytes = of_getintprop_default(dp, "linebytes", info->var.xres); info->fix.smem_len = PAGE_ALIGN(linebytes * info->var.yres); par->tec = of_ioremap(&op->resource[7], 0, sizeof(struct tcx_tec), "tcx tec"); par->thc = of_ioremap(&op->resource[9], 0, sizeof(struct tcx_thc), "tcx thc"); par->bt = of_ioremap(&op->resource[8], 0, sizeof(struct bt_regs), "tcx dac"); info->screen_base = of_ioremap(&op->resource[0], 0, info->fix.smem_len, "tcx ram"); if (!par->tec || !par->thc || !par->bt || !info->screen_base) goto out_unmap_regs; memcpy(&par->mmap_map, &__tcx_mmap_map, sizeof(par->mmap_map)); if (!par->lowdepth) { par->cplane = of_ioremap(&op->resource[4], 0, info->fix.smem_len * sizeof(u32), "tcx cplane"); if (!par->cplane) goto out_unmap_regs; } else { par->mmap_map[1].size = SBUS_MMAP_EMPTY; par->mmap_map[4].size = SBUS_MMAP_EMPTY; par->mmap_map[5].size = SBUS_MMAP_EMPTY; par->mmap_map[6].size = SBUS_MMAP_EMPTY; } info->fix.smem_start = op->resource[0].start; par->which_io = op->resource[0].flags & IORESOURCE_BITS; for (i = 0; i < TCX_MMAP_ENTRIES; i++) { int j; switch (i) { case 10: j = 12; break; case 11: case 12: j = i - 1; break; default: j = i; break; } par->mmap_map[i].poff = op->resource[j].start; } info->flags = FBINFO_DEFAULT; info->fbops = &tcx_ops; /* Initialize brooktree DAC. */ sbus_writel(0x04 << 24, &par->bt->addr); /* color planes */ sbus_writel(0xff << 24, &par->bt->control); sbus_writel(0x05 << 24, &par->bt->addr); sbus_writel(0x00 << 24, &par->bt->control); sbus_writel(0x06 << 24, &par->bt->addr); /* overlay plane */ sbus_writel(0x73 << 24, &par->bt->control); sbus_writel(0x07 << 24, &par->bt->addr); sbus_writel(0x00 << 24, &par->bt->control); tcx_reset(info); tcx_blank(FB_BLANK_UNBLANK, info); if (fb_alloc_cmap(&info->cmap, 256, 0)) goto out_unmap_regs; fb_set_cmap(&info->cmap, info); tcx_init_fix(info, linebytes); err = register_framebuffer(info); if (err < 0) goto out_dealloc_cmap; dev_set_drvdata(&op->dev, info); printk(KERN_INFO "%s: TCX at %lx:%lx, %s\n", dp->full_name, par->which_io, info->fix.smem_start, par->lowdepth ? "8-bit only" : "24-bit depth"); return 0; out_dealloc_cmap: fb_dealloc_cmap(&info->cmap); out_unmap_regs: tcx_unmap_regs(op, info, par); framebuffer_release(info); out_err: return err; }
/** * s3c_fb_probe_win() - register an hardware window * @sfb: The base resources for the hardware * @res: Pointer to where to place the resultant window. * * Allocate and do the basic initialisation for one of the hardware's graphics * windows. */ static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no, struct s3c_fb_win **res) { struct fb_var_screeninfo *var; struct fb_videomode *initmode; struct s3c_fb_pd_win *windata; struct s3c_fb_win *win; struct fb_info *fbinfo; int palette_size; int ret; dev_dbg(sfb->dev, "probing window %d\n", win_no); palette_size = s3c_fb_win_pal_size(win_no); fbinfo = framebuffer_alloc(sizeof(struct s3c_fb_win) + palette_size * sizeof(u32), sfb->dev); if (!fbinfo) { dev_err(sfb->dev, "failed to allocate framebuffer\n"); return -ENOENT; } windata = sfb->pdata->win[win_no]; initmode = &windata->win_mode; WARN_ON(windata->max_bpp == 0); WARN_ON(windata->win_mode.xres == 0); WARN_ON(windata->win_mode.yres == 0); win = fbinfo->par; var = &fbinfo->var; win->fbinfo = fbinfo; win->parent = sfb; win->windata = windata; win->index = win_no; win->palette_buffer = (u32 *)(win + 1); ret = s3c_fb_alloc_memory(sfb, win); if (ret) { dev_err(sfb->dev, "failed to allocate display memory\n"); return ret; } /* setup the r/b/g positions for the window's palette */ s3c_fb_init_palette(win_no, &win->palette); /* setup the initial video mode from the window */ fb_videomode_to_var(&fbinfo->var, initmode); fbinfo->fix.type = FB_TYPE_PACKED_PIXELS; fbinfo->fix.accel = FB_ACCEL_NONE; fbinfo->var.activate = FB_ACTIVATE_NOW; fbinfo->var.vmode = FB_VMODE_NONINTERLACED; fbinfo->var.bits_per_pixel = windata->default_bpp; fbinfo->fbops = &s3c_fb_ops; fbinfo->flags = FBINFO_FLAG_DEFAULT; fbinfo->pseudo_palette = &win->pseudo_palette; /* prepare to actually start the framebuffer */ ret = s3c_fb_check_var(&fbinfo->var, fbinfo); if (ret < 0) { dev_err(sfb->dev, "check_var failed on initial video params\n"); return ret; } /* create initial colour map */ ret = fb_alloc_cmap(&fbinfo->cmap, s3c_fb_win_pal_size(win_no), 1); if (ret == 0) fb_set_cmap(&fbinfo->cmap, fbinfo); else dev_err(sfb->dev, "failed to allocate fb cmap\n"); s3c_fb_set_par(fbinfo); dev_dbg(sfb->dev, "about to register framebuffer\n"); /* run the check_var and set_par on our configuration. */ ret = register_framebuffer(fbinfo); if (ret < 0) { dev_err(sfb->dev, "failed to register framebuffer\n"); return ret; } *res = win; dev_info(sfb->dev, "window %d: fb %s\n", win_no, fbinfo->fix.id); return 0; }
static int fb_info_set_color(struct fb_info *info) { struct fb_fix_screeninfo *fix = &info->fix; struct fb_var_screeninfo *var = &info->var; D("Called."); dump_fb_info_var(var); switch (var->bits_per_pixel) { case 1: /* Mono */ fix->visual = FB_VISUAL_MONO01; fix->line_length = (var->xres * var->bits_per_pixel) / 8; break; case 2: /* Mono */ var->red.offset = 0; var->red.length = 2; var->green.offset = 0; var->green.length = 2; var->blue.offset = 0; var->blue.length = 2; fix->visual = FB_VISUAL_PSEUDOCOLOR; fix->line_length = (var->xres * var->bits_per_pixel) / 8; break; case 4: /* PSEUDOCOLOUR */ var->red.offset = 0; var->red.length = 4; var->green.offset = 0; var->green.length = 4; var->blue.offset = 0; var->blue.length = 4; fix->visual = FB_VISUAL_PSEUDOCOLOR; fix->line_length = var->xres / 2; break; case 8: /* PSEUDOCOLOUR, 256 */ var->red.offset = 0; var->red.length = 8; var->green.offset = 0; var->green.length = 8; var->blue.offset = 0; var->blue.length = 8; fix->visual = FB_VISUAL_PSEUDOCOLOR; fix->line_length = var->xres; break; case 15: /* DIRECTCOLOUR, 32k */ var->red.offset = 10; var->red.length = 5; var->green.offset = 5; var->green.length = 5; var->blue.offset = 0; var->blue.length = 5; fix->visual = FB_VISUAL_DIRECTCOLOR; fix->line_length = var->xres_virtual * 2; break; case 16: /* DIRECTCOLOUR, 64k */ var->red.offset = 11; var->red.length = 5; var->green.offset = 5; var->green.length = 6; var->blue.offset = 0; var->blue.length = 5; fix->visual = FB_VISUAL_TRUECOLOR; fix->line_length = var->xres_virtual * 2; break; case 17 ... 32: /* DIRECTCOLOUR, 256 */ var->bits_per_pixel = 32; var->red.offset = 16; var->red.length = 8; var->green.offset = 8; var->green.length = 8; var->blue.offset = 0; var->blue.length = 8; var->transp.offset = 24; var->transp.length = 8; fix->visual = FB_VISUAL_TRUECOLOR; fix->line_length = var->xres_virtual * 4; break; default: E("BPP %d not support.", var->bits_per_pixel); return -EINVAL; } D("fix->line_length: 0x%08x.", fix->line_length); fb_set_cmap(&info->cmap, info); return 0; }
static int __devinit cg14_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; struct fb_info *info; struct cg14_par *par; int is_8mb, linebytes, i, err; info = framebuffer_alloc(sizeof(struct cg14_par), &op->dev); err = -ENOMEM; if (!info) goto out_err; par = info->par; spin_lock_init(&par->lock); sbusfb_fill_var(&info->var, dp, 8); info->var.red.length = 8; info->var.green.length = 8; info->var.blue.length = 8; linebytes = of_getintprop_default(dp, "linebytes", info->var.xres); info->fix.smem_len = PAGE_ALIGN(linebytes * info->var.yres); if (!strcmp(dp->parent->name, "sbus") || !strcmp(dp->parent->name, "sbi")) { info->fix.smem_start = op->resource[0].start; par->iospace = op->resource[0].flags & IORESOURCE_BITS; } else { info->fix.smem_start = op->resource[1].start; par->iospace = op->resource[0].flags & IORESOURCE_BITS; } par->regs = of_ioremap(&op->resource[0], 0, sizeof(struct cg14_regs), "cg14 regs"); par->clut = of_ioremap(&op->resource[0], CG14_CLUT1, sizeof(struct cg14_clut), "cg14 clut"); par->cursor = of_ioremap(&op->resource[0], CG14_CURSORREGS, sizeof(struct cg14_cursor), "cg14 cursor"); info->screen_base = of_ioremap(&op->resource[1], 0, info->fix.smem_len, "cg14 ram"); if (!par->regs || !par->clut || !par->cursor || !info->screen_base) goto out_unmap_regs; is_8mb = (((op->resource[1].end - op->resource[1].start) + 1) == (8 * 1024 * 1024)); BUILD_BUG_ON(sizeof(par->mmap_map) != sizeof(__cg14_mmap_map)); memcpy(&par->mmap_map, &__cg14_mmap_map, sizeof(par->mmap_map)); for (i = 0; i < CG14_MMAP_ENTRIES; i++) { struct sbus_mmap_map *map = &par->mmap_map[i]; if (!map->size) break; if (map->poff & 0x80000000) map->poff = (map->poff & 0x7fffffff) + (op->resource[0].start - op->resource[1].start); if (is_8mb && map->size >= 0x100000 && map->size <= 0x400000) map->size *= 2; } par->mode = MDI_8_PIX; par->ramsize = (is_8mb ? 0x800000 : 0x400000); info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; info->fbops = &cg14_ops; __cg14_reset(par); if (fb_alloc_cmap(&info->cmap, 256, 0)) goto out_unmap_regs; fb_set_cmap(&info->cmap, info); cg14_init_fix(info, linebytes, dp); err = register_framebuffer(info); if (err < 0) goto out_dealloc_cmap; dev_set_drvdata(&op->dev, info); printk(KERN_INFO "%s: cgfourteen at %lx:%lx, %dMB\n", dp->full_name, par->iospace, info->fix.smem_start, par->ramsize >> 20); return 0; out_dealloc_cmap: fb_dealloc_cmap(&info->cmap); out_unmap_regs: cg14_unmap_regs(op, info, par); out_err: return err; }
static int __devinit cg14_init_one(struct of_device *op) { struct device_node *dp = op->node; struct all_info *all; int is_8mb, linebytes, i, err; all = kzalloc(sizeof(*all), GFP_KERNEL); if (!all) return -ENOMEM; spin_lock_init(&all->par.lock); sbusfb_fill_var(&all->info.var, dp->node, 8); all->info.var.red.length = 8; all->info.var.green.length = 8; all->info.var.blue.length = 8; linebytes = of_getintprop_default(dp, "linebytes", all->info.var.xres); all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); if (!strcmp(dp->parent->name, "sbus") || !strcmp(dp->parent->name, "sbi")) { all->par.physbase = op->resource[0].start; all->par.iospace = op->resource[0].flags & IORESOURCE_BITS; } else { all->par.physbase = op->resource[1].start; all->par.iospace = op->resource[0].flags & IORESOURCE_BITS; } all->par.regs = of_ioremap(&op->resource[0], 0, sizeof(struct cg14_regs), "cg14 regs"); all->par.clut = of_ioremap(&op->resource[0], CG14_CLUT1, sizeof(struct cg14_clut), "cg14 clut"); all->par.cursor = of_ioremap(&op->resource[0], CG14_CURSORREGS, sizeof(struct cg14_cursor), "cg14 cursor"); all->info.screen_base = of_ioremap(&op->resource[1], 0, all->par.fbsize, "cg14 ram"); if (!all->par.regs || !all->par.clut || !all->par.cursor || !all->info.screen_base) cg14_unmap_regs(all); is_8mb = (((op->resource[1].end - op->resource[1].start) + 1) == (8 * 1024 * 1024)); BUILD_BUG_ON(sizeof(all->par.mmap_map) != sizeof(__cg14_mmap_map)); memcpy(&all->par.mmap_map, &__cg14_mmap_map, sizeof(all->par.mmap_map)); for (i = 0; i < CG14_MMAP_ENTRIES; i++) { struct sbus_mmap_map *map = &all->par.mmap_map[i]; if (!map->size) break; if (map->poff & 0x80000000) map->poff = (map->poff & 0x7fffffff) + (op->resource[0].start - op->resource[1].start); if (is_8mb && map->size >= 0x100000 && map->size <= 0x400000) map->size *= 2; } all->par.mode = MDI_8_PIX; all->par.ramsize = (is_8mb ? 0x800000 : 0x400000); all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; all->info.fbops = &cg14_ops; all->info.par = &all->par; __cg14_reset(&all->par); if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { cg14_unmap_regs(all); kfree(all); return -ENOMEM; } fb_set_cmap(&all->info.cmap, &all->info); cg14_init_fix(&all->info, linebytes, dp); err = register_framebuffer(&all->info); if (err < 0) { fb_dealloc_cmap(&all->info.cmap); cg14_unmap_regs(all); kfree(all); return err; } dev_set_drvdata(&op->dev, all); printk("%s: cgfourteen at %lx:%lx, %dMB\n", dp->full_name, all->par.iospace, all->par.physbase, all->par.ramsize >> 20); return 0; }
int wisky_charger_logo_display(int index) { if(NULL == g_fb0_inf){ pr_info("NULL framebuffer information, show logo fail!\n"); return -EINVAL; } switch(index) { case LOGO_BLANK: { memset(blank_clut224_data, 0x20, WISKY_LCD_WIDTH*WISKY_LCD_HEIGHT); if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&blank_clut224)) return 0; } break; case LOGO_NUM1: if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&logo_charge0_clut224)) return 0; break; case LOGO_NUM2: if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&logo_charge1_clut224)) return 0; break; case LOGO_NUM3: if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&logo_charge2_clut224)) return 0; break; case LOGO_NUM4: if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&logo_charge3_clut224)) return 0; break; case LOGO_NUM5: if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&logo_charge4_clut224)) return 0; break; // case LOGO_NUM6: // set_logo(&logo_charge6_clut224); // fb_show_logo(inf->fb0, 0); // break; case LOGO_POOR: if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&logo_charge_poor_clut224)) return 0; break; case LOGO_FULL: if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&logo_charge_full_clut224)) return 0; break; case LOGO_BOOTUP: if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,NULL)) return 0; break; default: memset(blank_clut224_data, 0x20, WISKY_LCD_WIDTH*WISKY_LCD_HEIGHT); if(!fb_prepare_logo(g_fb0_inf, FB_ROTATE_UR,&blank_clut224)) return 0; break; } fb_set_cmap(&g_fb0_inf->cmap, g_fb0_inf); fb_show_logo(g_fb0_inf, FB_ROTATE_UR); g_fb0_inf->fbops->fb_pan_display(&(g_fb0_inf->var), g_fb0_inf); return 0; }
static int __devinit s3cfb_probe(struct platform_device *pdev) { struct s3c_platform_fb *pdata; struct s3cfb_global *fbdev; struct resource *res; int i, j, ret = 0; printk("%s\n",__func__); fbdev = kzalloc(sizeof(struct s3cfb_global), GFP_KERNEL); if (!fbdev) { dev_err(&pdev->dev, "failed to allocate for " "global fb structure\n"); ret = -ENOMEM; goto err_global; } fbdev->dev = &pdev->dev; #ifdef CONFIG_FB_S3C_LTE480WV s3cfb_set_lcd_info(fbdev); #endif fbdev->regulator = regulator_get(&pdev->dev, "pd"); if (!fbdev->regulator) { dev_err(fbdev->dev, "failed to get regulator\n"); ret = -EINVAL; goto err_regulator; } ret = regulator_enable(fbdev->regulator); if (ret < 0) { dev_err(fbdev->dev, "failed to enable regulator\n"); ret = -EINVAL; goto err_regulator; } pdata = to_fb_plat(&pdev->dev); if (!pdata) { dev_err(fbdev->dev, "failed to get platform data\n"); ret = -EINVAL; goto err_pdata; } //fbdev->lcd = (struct s3cfb_lcd *)pdata->lcd; if (pdata->cfg_gpio) pdata->cfg_gpio(pdev); if (pdata->clk_on) pdata->clk_on(pdev, &fbdev->clock); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(fbdev->dev, "failed to get io memory region\n"); ret = -EINVAL; goto err_io; } res = request_mem_region(res->start, res->end - res->start + 1, pdev->name); if (!res) { dev_err(fbdev->dev, "failed to request io memory region\n"); ret = -EINVAL; goto err_io; } fbdev->regs = ioremap(res->start, res->end - res->start + 1); if (!fbdev->regs) { dev_err(fbdev->dev, "failed to remap io region\n"); ret = -EINVAL; goto err_mem; } /*set gamma LUT*/ //SSCR xuhui 110130 s3cfb_set_gamma(fbdev); s3cfb_set_vsync_interrupt(fbdev, 1); s3cfb_set_global_interrupt(fbdev, 1); s3cfb_init_global(fbdev); if (s3cfb_alloc_framebuffer(fbdev)) { ret = -ENOMEM; goto err_alloc; } if (s3cfb_register_framebuffer(fbdev)) { ret = -EINVAL; goto err_register; } s3cfb_set_clock(fbdev); s3cfb_set_window(fbdev, pdata->default_win, 1); s3cfb_display_on(fbdev); fbdev->irq = platform_get_irq(pdev, 0); if (request_irq(fbdev->irq, s3cfb_irq_frame, IRQF_SHARED, pdev->name, fbdev)) { dev_err(fbdev->dev, "request_irq failed\n"); ret = -EINVAL; goto err_irq; } #ifdef CONFIG_FB_S3C_LCD_INIT if (pdata->backlight_on) pdata->backlight_on(pdev); if (!bootloaderfb && pdata->reset_lcd) pdata->reset_lcd(pdev); if (pdata->lcd_on) pdata->lcd_on(pdev); #endif #ifdef CONFIG_HAS_EARLYSUSPEND fbdev->early_suspend.suspend = s3cfb_early_suspend; fbdev->early_suspend.resume = s3cfb_late_resume; fbdev->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; register_early_suspend(&fbdev->early_suspend); #endif ret = device_create_file(&(pdev->dev), &dev_attr_win_power); if (ret < 0) dev_err(fbdev->dev, "failed to add sysfs entries\n"); dev_info(fbdev->dev, "registered successfully\n"); #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO) if (fb_prepare_logo( fbdev->fb[pdata->default_win], FB_ROTATE_UR)) { printk("Start display and show logo\n"); /* Start display and show logo on boot */ fb_set_cmap(&fbdev->fb[pdata->default_win]->cmap, fbdev->fb[pdata->default_win]); fb_show_logo(fbdev->fb[pdata->default_win], FB_ROTATE_UR); } #endif return 0; err_irq: s3cfb_display_off(fbdev); s3cfb_set_window(fbdev, pdata->default_win, 0); for (i = pdata->default_win; i < pdata->nr_wins + pdata->default_win; i++) { j = i % pdata->nr_wins; unregister_framebuffer(fbdev->fb[j]); } err_register: for (i = 0; i < pdata->nr_wins; i++) { if (i == pdata->default_win) s3cfb_unmap_default_video_memory(fbdev->fb[i]); framebuffer_release(fbdev->fb[i]); } kfree(fbdev->fb); err_alloc: iounmap(fbdev->regs); err_mem: release_mem_region(res->start, res->end - res->start + 1); err_io: pdata->clk_off(pdev, &fbdev->clock); err_pdata: regulator_disable(fbdev->regulator); err_regulator: kfree(fbdev); err_global: return ret; }
static int __devinit tcx_init_one(struct of_device *op) { struct device_node *dp = op->node; struct all_info *all; int linebytes, i, err; all = kzalloc(sizeof(*all), GFP_KERNEL); if (!all) return -ENOMEM; spin_lock_init(&all->par.lock); all->par.lowdepth = (of_find_property(dp, "tcx-8-bit", NULL) != NULL); sbusfb_fill_var(&all->info.var, dp->node, 8); all->info.var.red.length = 8; all->info.var.green.length = 8; all->info.var.blue.length = 8; linebytes = of_getintprop_default(dp, "linebytes", all->info.var.xres); all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); all->par.tec = of_ioremap(&op->resource[7], 0, sizeof(struct tcx_tec), "tcx tec"); all->par.thc = of_ioremap(&op->resource[9], 0, sizeof(struct tcx_thc), "tcx thc"); all->par.bt = of_ioremap(&op->resource[8], 0, sizeof(struct bt_regs), "tcx dac"); all->info.screen_base = of_ioremap(&op->resource[0], 0, all->par.fbsize, "tcx ram"); if (!all->par.tec || !all->par.thc || !all->par.bt || !all->info.screen_base) { tcx_unmap_regs(all); kfree(all); return -ENOMEM; } memcpy(&all->par.mmap_map, &__tcx_mmap_map, sizeof(all->par.mmap_map)); if (!all->par.lowdepth) { all->par.cplane = of_ioremap(&op->resource[4], 0, all->par.fbsize * sizeof(u32), "tcx cplane"); if (!all->par.cplane) { tcx_unmap_regs(all); kfree(all); return -ENOMEM; } } else { all->par.mmap_map[1].size = SBUS_MMAP_EMPTY; all->par.mmap_map[4].size = SBUS_MMAP_EMPTY; all->par.mmap_map[5].size = SBUS_MMAP_EMPTY; all->par.mmap_map[6].size = SBUS_MMAP_EMPTY; } all->par.physbase = 0; all->par.which_io = op->resource[0].flags & IORESOURCE_BITS; for (i = 0; i < TCX_MMAP_ENTRIES; i++) { int j; switch (i) { case 10: j = 12; break; case 11: case 12: j = i - 1; break; default: j = i; break; }; all->par.mmap_map[i].poff = op->resource[j].start; } all->info.flags = FBINFO_DEFAULT; all->info.fbops = &tcx_ops; all->info.par = &all->par; /* Initialize brooktree DAC. */ sbus_writel(0x04 << 24, &all->par.bt->addr); /* color planes */ sbus_writel(0xff << 24, &all->par.bt->control); sbus_writel(0x05 << 24, &all->par.bt->addr); sbus_writel(0x00 << 24, &all->par.bt->control); sbus_writel(0x06 << 24, &all->par.bt->addr); /* overlay plane */ sbus_writel(0x73 << 24, &all->par.bt->control); sbus_writel(0x07 << 24, &all->par.bt->addr); sbus_writel(0x00 << 24, &all->par.bt->control); tcx_reset(&all->info); tcx_blank(FB_BLANK_UNBLANK, &all->info); if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { tcx_unmap_regs(all); kfree(all); return -ENOMEM; } fb_set_cmap(&all->info.cmap, &all->info); tcx_init_fix(&all->info, linebytes); err = register_framebuffer(&all->info); if (err < 0) { fb_dealloc_cmap(&all->info.cmap); tcx_unmap_regs(all); kfree(all); return err; } dev_set_drvdata(&op->dev, all); printk("%s: TCX at %lx:%lx, %s\n", dp->full_name, all->par.which_io, op->resource[0].start, all->par.lowdepth ? "8-bit only" : "24-bit depth"); return 0; }