drm/fb_cma_helper: Use new drm_fb_helper functions
authorArchit Taneja <architt@codeaurora.org>
Wed, 22 Jul 2015 09:28:20 +0000 (14:58 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 6 Aug 2015 12:13:00 +0000 (14:13 +0200)
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: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_fb_cma_helper.c

index f01dc25df2dcb61477f9cb4bbb6537516dda2b58..c19a62561183537046dc896254d09d4ac3a70b1e 100644 (file)
@@ -222,9 +222,9 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
 
 static struct fb_ops drm_fbdev_cma_ops = {
        .owner          = THIS_MODULE,
-       .fb_fillrect    = sys_fillrect,
-       .fb_copyarea    = sys_copyarea,
-       .fb_imageblit   = sys_imageblit,
+       .fb_fillrect    = drm_fb_helper_sys_fillrect,
+       .fb_copyarea    = drm_fb_helper_sys_copyarea,
+       .fb_imageblit   = drm_fb_helper_sys_imageblit,
        .fb_check_var   = drm_fb_helper_check_var,
        .fb_set_par     = drm_fb_helper_set_par,
        .fb_blank       = drm_fb_helper_blank,
@@ -263,10 +263,9 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
        if (IS_ERR(obj))
                return -ENOMEM;
 
-       fbi = framebuffer_alloc(0, dev->dev);
-       if (!fbi) {
-               dev_err(dev->dev, "Failed to allocate framebuffer info.\n");
-               ret = -ENOMEM;
+       fbi = drm_fb_helper_alloc_fbi(helper);
+       if (IS_ERR(fbi)) {
+               ret = PTR_ERR(fbi);
                goto err_drm_gem_cma_free_object;
        }
 
@@ -274,23 +273,16 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
        if (IS_ERR(fbdev_cma->fb)) {
                dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n");
                ret = PTR_ERR(fbdev_cma->fb);
-               goto err_framebuffer_release;
+               goto err_fb_info_destroy;
        }
 
        fb = &fbdev_cma->fb->fb;
        helper->fb = fb;
-       helper->fbdev = fbi;
 
        fbi->par = helper;
        fbi->flags = FBINFO_FLAG_DEFAULT;
        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_var(fbi, helper, sizes->fb_width, sizes->fb_height);
 
@@ -305,11 +297,8 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
 
        return 0;
 
-err_drm_fb_cma_destroy:
-       drm_framebuffer_unregister_private(fb);
-       drm_fb_cma_destroy(fb);
-err_framebuffer_release:
-       framebuffer_release(fbi);
+err_fb_info_destroy:
+       drm_fb_helper_release_fbi(helper);
 err_drm_gem_cma_free_object:
        drm_gem_cma_free_object(&obj->base);
        return ret;
@@ -385,20 +374,8 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_init);
  */
 void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma)
 {
-       if (fbdev_cma->fb_helper.fbdev) {
-               struct fb_info *info;
-               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);
-       }
+       drm_fb_helper_unregister_fbi(&fbdev_cma->fb_helper);
+       drm_fb_helper_release_fbi(&fbdev_cma->fb_helper);
 
        if (fbdev_cma->fb) {
                drm_framebuffer_unregister_private(&fbdev_cma->fb->fb);