Commit 85f2edf2 authored by Archit Taneja's avatar Archit Taneja Committed by Daniel Vetter

drm/fb_cma_helper: Use new drm_fb_helper functions

Use the newly created wrapper drm_fb_helper functions instead of calling
core fbdev functions directly. They also simplify the fb_info creation.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 41ba2f34
...@@ -222,9 +222,9 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show); ...@@ -222,9 +222,9 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
static struct fb_ops drm_fbdev_cma_ops = { static struct fb_ops drm_fbdev_cma_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.fb_fillrect = sys_fillrect, .fb_fillrect = drm_fb_helper_sys_fillrect,
.fb_copyarea = sys_copyarea, .fb_copyarea = drm_fb_helper_sys_copyarea,
.fb_imageblit = sys_imageblit, .fb_imageblit = drm_fb_helper_sys_imageblit,
.fb_check_var = drm_fb_helper_check_var, .fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par, .fb_set_par = drm_fb_helper_set_par,
.fb_blank = drm_fb_helper_blank, .fb_blank = drm_fb_helper_blank,
...@@ -263,10 +263,9 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper, ...@@ -263,10 +263,9 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
if (IS_ERR(obj)) if (IS_ERR(obj))
return -ENOMEM; return -ENOMEM;
fbi = framebuffer_alloc(0, dev->dev); fbi = drm_fb_helper_alloc_fbi(helper);
if (!fbi) { if (IS_ERR(fbi)) {
dev_err(dev->dev, "Failed to allocate framebuffer info.\n"); ret = PTR_ERR(fbi);
ret = -ENOMEM;
goto err_drm_gem_cma_free_object; goto err_drm_gem_cma_free_object;
} }
...@@ -274,23 +273,16 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper, ...@@ -274,23 +273,16 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
if (IS_ERR(fbdev_cma->fb)) { if (IS_ERR(fbdev_cma->fb)) {
dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n"); dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n");
ret = PTR_ERR(fbdev_cma->fb); ret = PTR_ERR(fbdev_cma->fb);
goto err_framebuffer_release; goto err_fb_info_destroy;
} }
fb = &fbdev_cma->fb->fb; fb = &fbdev_cma->fb->fb;
helper->fb = fb; helper->fb = fb;
helper->fbdev = fbi;
fbi->par = helper; fbi->par = helper;
fbi->flags = FBINFO_FLAG_DEFAULT; fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->fbops = &drm_fbdev_cma_ops; fbi->fbops = &drm_fbdev_cma_ops;
ret = fb_alloc_cmap(&fbi->cmap, 256, 0);
if (ret) {
dev_err(dev->dev, "Failed to allocate color map.\n");
goto err_drm_fb_cma_destroy;
}
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth); drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
...@@ -305,11 +297,8 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper, ...@@ -305,11 +297,8 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
return 0; return 0;
err_drm_fb_cma_destroy: err_fb_info_destroy:
drm_framebuffer_unregister_private(fb); drm_fb_helper_release_fbi(helper);
drm_fb_cma_destroy(fb);
err_framebuffer_release:
framebuffer_release(fbi);
err_drm_gem_cma_free_object: err_drm_gem_cma_free_object:
drm_gem_cma_free_object(&obj->base); drm_gem_cma_free_object(&obj->base);
return ret; return ret;
...@@ -385,20 +374,8 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_init); ...@@ -385,20 +374,8 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_init);
*/ */
void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma) void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma)
{ {
if (fbdev_cma->fb_helper.fbdev) { drm_fb_helper_unregister_fbi(&fbdev_cma->fb_helper);
struct fb_info *info; drm_fb_helper_release_fbi(&fbdev_cma->fb_helper);
int ret;
info = fbdev_cma->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_cma->fb) { if (fbdev_cma->fb) {
drm_framebuffer_unregister_private(&fbdev_cma->fb->fb); drm_framebuffer_unregister_private(&fbdev_cma->fb->fb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment