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 (cmap->start < 0 || (!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; }
int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp) { int size = len*sizeof(u16); if (cmap->len != len) { fb_dealloc_cmap(cmap); if (!len) return 0; if (!(cmap->red = kmalloc(size, GFP_ATOMIC))) goto fail; if (!(cmap->green = kmalloc(size, GFP_ATOMIC))) goto fail; if (!(cmap->blue = kmalloc(size, GFP_ATOMIC))) goto fail; if (transp) { if (!(cmap->transp = kmalloc(size, GFP_ATOMIC))) goto fail; } else cmap->transp = NULL; } cmap->start = 0; cmap->len = len; fb_copy_cmap(fb_default_cmap(len), cmap); return 0; fail: fb_dealloc_cmap(cmap); return -ENOMEM; }
static int bochs_fbdev_destroy(struct bochs_device *bochs) { struct bochs_framebuffer *gfb = &bochs->fb.gfb; struct fb_info *info; DRM_DEBUG_DRIVER("\n"); if (bochs->fb.helper.fbdev) { info = bochs->fb.helper.fbdev; unregister_framebuffer(info); if (info->cmap.len) fb_dealloc_cmap(&info->cmap); framebuffer_release(info); } if (gfb->obj) { drm_gem_object_unreference_unlocked(gfb->obj); gfb->obj = NULL; } drm_fb_helper_fini(&bochs->fb.helper); drm_framebuffer_unregister_private(&gfb->base); drm_framebuffer_cleanup(&gfb->base); 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; 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 ((!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; }
void mtk_fbdev_destroy(struct drm_device *dev) { struct mtk_drm_private *priv = (struct mtk_drm_private *)dev->dev_private; struct drm_fb_helper *fbdev = priv->fb_helper; struct fb_info *info = priv->fb_helper->fbdev; if (info) { int err; err = unregister_framebuffer(info); if (err < 0) DRM_DEBUG_KMS("failed to unregister framebuffer\n"); if (info->cmap.len) fb_dealloc_cmap(&info->cmap); framebuffer_release(info); } if (fbdev->fb) { drm_framebuffer_unregister_private(fbdev->fb); mtk_drm_fb_destroy(fbdev->fb); } drm_fb_helper_fini(fbdev); kfree(fbdev); }
__s32 Display_Fb_Release(__u32 fb_id) { struct fb_info *info = g_fbi.fbinfo[fb_id]; __u32 sel = 0; __inf("Display_Fb_Release, fb_id:%d\n", fb_id); if (!g_fbi.fb_enable[fb_id]) return DIS_SUCCESS; for (sel = 0; sel < 2; sel++) if (((sel == 0) && (g_fbi.fb_mode[fb_id] != FB_MODE_SCREEN1)) || ((sel == 1) && (g_fbi.fb_mode[fb_id] != FB_MODE_SCREEN0))) { __s32 layer_hdl = g_fbi.layer_hdl[fb_id][sel]; BSP_disp_layer_release(sel, layer_hdl); } g_fbi.layer_hdl[fb_id][0] = 0; g_fbi.layer_hdl[fb_id][1] = 0; g_fbi.fb_mode[fb_id] = FB_MODE_SCREEN0; memset(&g_fbi.fb_para[fb_id], 0, sizeof(__disp_fb_create_para_t)); g_fbi.fb_enable[fb_id] = 0; fb_dealloc_cmap(&info->cmap); Fb_unmap_video_memory(info); return DIS_SUCCESS; }
static void hisi_drm_fbdev_fini(struct hisi_drm_fbdev *fbdev) { if (fbdev->fb_helper.fbdev) { struct fb_info *info; int ret; info = fbdev->fb_helper.fbdev; ret = unregister_framebuffer(info); if (ret < 0) DRM_DEBUG_KMS("failed unregister_framebuffer()\n"); if (info->cmap.len) fb_dealloc_cmap(&info->cmap); framebuffer_release(info); } if (fbdev->fb) { drm_framebuffer_unregister_private(&fbdev->fb->fb); hisi_drm_fb_destroy(&fbdev->fb->fb); } drm_fb_helper_fini(&fbdev->fb_helper); kfree(fbdev); }
static int mxc_elcdif_fb_remove(struct platform_device *pdev) { struct fb_info *fbi = platform_get_drvdata(pdev); struct mxc_elcdif_fb_data *data = (struct mxc_elcdif_fb_data *)fbi->par; mxc_elcdif_fb_blank(FB_BLANK_POWERDOWN, fbi); mxc_elcdif_stop(); release_dotclk_panel(); mxc_elcdif_dma_release(); if (g_elcdif_axi_clk_enable) { clk_disable(g_elcdif_axi_clk); g_elcdif_axi_clk_enable = false; } if (g_elcdif_pix_clk_enable) { clk_disable(g_elcdif_pix_clk); g_elcdif_pix_clk_enable = false; } clk_put(g_elcdif_axi_clk); clk_put(g_elcdif_pix_clk); free_irq(data->dma_irq, data); mxc_elcdif_fb_unmap_video_memory(fbi); if (&fbi->cmap) fb_dealloc_cmap(&fbi->cmap); unregister_framebuffer(fbi); framebuffer_release(fbi); platform_set_drvdata(pdev, NULL); return 0; }
static void einkfb_remove(struct fb_info *info, einkfb_init_err_t err) { switch ( err ) { case einkfb_init_err_none: BLANK_DONE(); unregister_framebuffer(info); case einkfb_init_err_register_framebuffer: HAL_HW_DONE(einkfb_hw_shutdown_mode); fb_dealloc_cmap(&info->cmap); case einkfb_init_err_fb_alloc_cmap: EINKFB_FREE_HAL(einkfb, einkfb_dma ? &einkfb_phys : NULL); case einkfb_init_err_einkfb_malloc_hal: HAL_SW_DONE(); case einkfb_init_err_hw_sw_init: framebuffer_release(info); default: case einkfb_init_err_framebuffer_alloc: if ( err ) einkfb_print_crit("failed to initialize, err = %d\n", err); break; } boot_milestone_write(EINK_HAL_STOPPED_BOM, EINK_HAL_STOPPED_BOM_SZ); }
static void intel_fbdev_destroy(struct drm_device *dev, struct intel_fbdev *ifbdev) { #if 0 struct fb_info *info; #endif struct intel_framebuffer *ifb = &ifbdev->ifb; #if 0 if (ifbdev->helper.fbdev) { info = ifbdev->helper.fbdev; unregister_framebuffer(info); iounmap(info->screen_base); if (info->cmap.len) fb_dealloc_cmap(&info->cmap); framebuffer_release(info); } #endif drm_fb_helper_fini(&ifbdev->helper); drm_framebuffer_cleanup(&ifb->base); if (ifb->obj) { drm_gem_object_unreference_unlocked(&ifb->obj->base); ifb->obj = NULL; } }
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; }
static void gfb_free_framebuffer_work(struct work_struct *work) { struct gfb_data *data = container_of(work, struct gfb_data, free_framebuffer_work.work); struct fb_info *info = data->fb_info; /* int node = info->node; */ unregister_framebuffer(info); if (info->cmap.len != 0) fb_dealloc_cmap(&info->cmap); if (info->monspecs.modedb) fb_destroy_modedb(info->monspecs.modedb); if (info->screen_base) vfree(info->screen_base); fb_destroy_modelist(&info->modelist); fb_deferred_io_cleanup(info); usb_free_urb(data->fb_urb); vfree(data->fb_bitmap); kfree(data->fb_vbitmap); framebuffer_release(info); kfree(data); }
static void tegra_fbdev_free(struct tegra_fbdev *fbdev) { struct fb_info *info = fbdev->base.fbdev; if (info) { int err; err = unregister_framebuffer(info); if (err < 0) DRM_DEBUG_KMS("failed to unregister framebuffer\n"); if (info->cmap.len) fb_dealloc_cmap(&info->cmap); framebuffer_release(info); } if (fbdev->fb) { drm_framebuffer_unregister_private(&fbdev->fb->base); tegra_fb_destroy(&fbdev->fb->base); } drm_fb_helper_fini(&fbdev->base); kfree(fbdev); }
static int __devinit milkymistfb_probe(struct platform_device *pdev) { struct milkymistfb *milkymistfb; struct fb_info *info; int ret = -ENOMEM; info = framebuffer_alloc(sizeof(*milkymistfb), &pdev->dev); if (!info) return -ENOMEM; info->fbops = &milkymistfb_ops; milkymistfb = info->par; milkymistfb->fb = info; fb_find_mode(&info->var, info, milkymistfb_mode_option, milkymist_modedb, ARRAY_SIZE(milkymist_modedb), NULL, 16); /* milkymistfb->vidmem = dma_alloc_coherent(&pdev->dev, videomemorysize, &milkymistfb->vidmem_phys, GFP_KERNEL);*/ milkymistfb->vidmem = vmalloc(videomemorysize); milkymistfb->vidmem_phys = (unsigned int)milkymistfb->vidmem; if (!milkymistfb->vidmem) { ret = -ENOMEM; goto err_framebuffer_release; } memset(milkymistfb->vidmem, 0, videomemorysize); info->screen_base = milkymistfb->vidmem; info->fix = milkymistfb_fix; info->pseudo_palette = milkymistfb->pseudo_palette; info->flags = FBINFO_FLAG_DEFAULT; info->fix.smem_start = milkymistfb->vidmem_phys; info->fix.smem_len = videomemorysize; ret = fb_alloc_cmap(&info->cmap, 256, 0); if (ret < 0) goto err_dma_free; ret = register_framebuffer(info); if (ret < 0) goto err_dealloc_cmap; platform_set_drvdata(pdev, milkymistfb); dev_info(&pdev->dev, "fb%d: Milkymist frame buffer at %p, size %ld k\n", info->node, milkymistfb->vidmem, videomemorysize >> 10); return 0; err_dealloc_cmap: fb_dealloc_cmap(&info->cmap); err_dma_free: /* dma_free_coherent(&pdev->dev, videomemorysize, milkymistfb->vidmem, milkymistfb->vidmem_phys);*/ vfree(milkymistfb->vidmem); err_framebuffer_release: framebuffer_release(info); return ret; }
/** * s3c_fb_release_win() - release resources for a framebuffer window. * @win: The window to cleanup the resources for. * * Release the resources that where claimed for the hardware window, * such as the framebuffer instance and any memory claimed for it. */ static void s3c_fb_release_win(struct s3c_fb *sfb, struct s3c_fb_win *win) { if (win->fbinfo) { unregister_framebuffer(win->fbinfo); fb_dealloc_cmap(&win->fbinfo->cmap); s3c_fb_free_memory(sfb, win); framebuffer_release(win->fbinfo); } }
static void hpfb_remove_one(struct dio_dev *d) { unregister_framebuffer(&fb_info); if (d->scode >= DIOII_SCBASE) iounmap((void *)fb_regs); release_mem_region(d->resource.start, resource_size(&d->resource)); fb_dealloc_cmap(&fb_info.cmap); if (fb_info.screen_base) iounmap(fb_info.screen_base); }
/*! * @brief Install framebuffer into the system. * * @param info framebuffer information pointer * @param pdev pointer to struct device * @return Negative errno on error, or zero on success. */ static int __init _install_fb(struct fb_info *info, struct platform_device *pdev) { struct mx2fb_info *mx2fbi = (struct mx2fb_info *)info->par; if (_init_fbinfo(info, pdev)) return -EINVAL; if (fb_mode == 0) fb_mode = pdev->dev.platform_data; if (!fb_find_mode(&info->var, info, fb_mode, mxcfb_modedb, mxcfb_modedb_sz, NULL, default_bpp)) { fb_dealloc_cmap(&info->cmap); return -EBUSY; } /* Default Y virtual size is 2x panel size */ /* info->var.yres_virtual = info->var.yres << 1; */ if (mx2fbi->type == MX2FB_TYPE_GW) mx2fbi->blank = FB_BLANK_NORMAL; else mx2fbi->blank = FB_BLANK_UNBLANK; if (mx2fb_set_par(info)) { fb_dealloc_cmap(&info->cmap); return -EINVAL; } if (register_framebuffer(info) < 0) { _unmap_video_memory(info); fb_dealloc_cmap(&info->cmap); return -EINVAL; } mx2fbi->registered = 1; dev_info(info->device, "fb%d: %s fb device registered successfully.\n", info->node, info->fix.id); return 0; }
/*! * Probe routine for the framebuffer driver. It is called during the * driver binding process. The following functions are performed in * this routine: Framebuffer initialization, Memory allocation and * mapping, Framebuffer registration, IPU initialization. * * @return Appropriate error code to the kernel common code */ static int mxcfb_probe(struct platform_device *pdev) { struct fb_info *fbi; struct mxcfb_info *mxc_fbi; int ret; platform_set_drvdata(pdev, &mxcfb_drv_data); /* * Initialize FB structures */ fbi = mxcfb_init_fbinfo(&pdev->dev, &mxcfb_ops); if (!fbi) { ret = -ENOMEM; goto err0; } mxcfb_drv_data.fbi = fbi; mxc_fbi = fbi->par; mxcfb_drv_data.suspended = false; init_waitqueue_head(&mxcfb_drv_data.suspend_wq); /* * Allocate memory */ ret = mxcfb_map_video_memory(fbi); if (ret < 0) { goto err1; } mxcfb_init_panel(fbi); /* * Register framebuffer */ ret = register_framebuffer(fbi); if (ret < 0) { goto err2; } dev_info(&pdev->dev, "%s registered\n", MXCFB_NAME); return 0; err2: mxcfb_unmap_video_memory(fbi); err1: if (&fbi->cmap) fb_dealloc_cmap(&fbi->cmap); framebuffer_release(fbi); err0: return ret; }
int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags) { int size = len * sizeof(u16); int ret = -ENOMEM; if (cmap->len != len) { fb_dealloc_cmap(cmap); if (!len) return 0; cmap->red = kmalloc(size, flags); if (!cmap->red) goto fail; cmap->green = kmalloc(size, flags); if (!cmap->green) goto fail; cmap->blue = kmalloc(size, flags); if (!cmap->blue) goto fail; if (transp) { cmap->transp = kmalloc(size, flags); if (!cmap->transp) goto fail; } else { cmap->transp = NULL; } } cmap->start = 0; cmap->len = len; ret = fb_copy_cmap(fb_default_cmap(len), cmap); if (ret) goto fail; return 0; fail: fb_dealloc_cmap(cmap); return ret; }
/*! * @brief Uninstall framebuffer from the system. * * @param info framebuffer information pointer */ static void __exit _uninstall_fb(struct fb_info *info) { struct mx2fb_info *mx2fbi = (struct mx2fb_info *)info->par; if (!mx2fbi->registered) return; unregister_framebuffer(info); _unmap_video_memory(info); if (&info->cmap) fb_dealloc_cmap(&info->cmap); mx2fbi->registered = 0; }
static int tcx_remove(struct platform_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct tcx_par *par = info->par; unregister_framebuffer(info); fb_dealloc_cmap(&info->cmap); tcx_unmap_regs(op, info, par); framebuffer_release(info); return 0; }
static int vfb_remove(struct platform_device *dev) { struct fb_info *info = platform_get_drvdata(dev); if (info) { unregister_framebuffer(info); fb_dealloc_cmap(&(info->cmap)); kfree(info->pseudo_palette); iounmap(info->screen_base); framebuffer_release(info); } release_mem_region(vfb_addr, vfb_size); return 0; }
static int __devexit tcx_remove(struct of_device *dev) { struct all_info *all = dev_get_drvdata(&dev->dev); unregister_framebuffer(&all->info); fb_dealloc_cmap(&all->info.cmap); tcx_unmap_regs(all); kfree(all); dev_set_drvdata(&dev->dev, NULL); return 0; }
static void fb_free_resources(struct sprdfb_device *dev) { if (dev == NULL) return; if (&dev->fb->cmap != NULL) { fb_dealloc_cmap(&dev->fb->cmap); } if (dev->fb->screen_base) { free_pages((unsigned long)dev->fb->screen_base, get_order(dev->fb->fix.smem_len)); } unregister_framebuffer(dev->fb); framebuffer_release(dev->fb); }
static int wm8505fb_remove(struct platform_device *pdev) { struct wm8505fb_info *fbi = platform_get_drvdata(pdev); device_remove_file(&pdev->dev, &dev_attr_contrast); unregister_framebuffer(&fbi->fb); writel(0, fbi->regbase); if (fbi->fb.cmap.len) fb_dealloc_cmap(&fbi->fb.cmap); return 0; }
static int qtft_fb_remove(struct platform_device *dev) { struct fb_info *info = platform_get_drvdata(dev); func_in(); if (info) { lcd_exit(); unregister_framebuffer(info); fb_dealloc_cmap(&info->cmap); framebuffer_release(info); rvfree(videomemory, videomemorysize); } func_out(); return 0; }
static int vdmafb_remove(struct platform_device *pdev) { struct vdmafb_dev *fbdev = platform_get_drvdata(pdev); if (fbdev->backlight) backlight_device_unregister(fbdev->backlight); unregister_framebuffer(&fbdev->info); /* Disable display */ vdmafb_writereg(fbdev, VDMAFB_BACKLIGHT_CONTROL, 0); vdmafb_writereg(fbdev, VDMAFB_CONTROL, 0); dma_release_channel(fbdev->dma); dma_free_coherent(&pdev->dev, PAGE_ALIGN(fbdev->info.fix.smem_len), fbdev->fb_virt, fbdev->fb_phys); fb_dealloc_cmap(&fbdev->info.cmap); return 0; }
static int __devexit leo_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct leo_par *par = info->par; unregister_framebuffer(info); fb_dealloc_cmap(&info->cmap); leo_unmap_regs(op, info, par); framebuffer_release(info); dev_set_drvdata(&op->dev, NULL); return 0; }
static int gxfb_set_par(struct fb_info *info) { if (info->var.bits_per_pixel > 8) { info->fix.visual = FB_VISUAL_TRUECOLOR; fb_dealloc_cmap(&info->cmap); } else { info->fix.visual = FB_VISUAL_PSEUDOCOLOR; fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0); } info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel); gx_set_mode(info); return 0; }