drm/i915: Use new drm_fb_helper functions
authorArchit Taneja <architt@codeaurora.org>
Fri, 31 Jul 2015 10:51:56 +0000 (16:21 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 6 Aug 2015 12:13:05 +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.

v3:
- Don't touch remove_conflicting_framebuffers

v2:
- No changes

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_fbdev.c

index f786c9b8927e29b296b0bfbb574e7864dacf4ebe..8c6a6fa460057d38c71fe8f01986cde39f234442 100644 (file)
@@ -104,9 +104,9 @@ static struct fb_ops intelfb_ops = {
        .owner = THIS_MODULE,
        .fb_check_var = drm_fb_helper_check_var,
        .fb_set_par = intel_fbdev_set_par,
-       .fb_fillrect = cfb_fillrect,
-       .fb_copyarea = cfb_copyarea,
-       .fb_imageblit = cfb_imageblit,
+       .fb_fillrect = drm_fb_helper_cfb_fillrect,
+       .fb_copyarea = drm_fb_helper_cfb_copyarea,
+       .fb_imageblit = drm_fb_helper_cfb_imageblit,
        .fb_pan_display = intel_fbdev_pan_display,
        .fb_blank = intel_fbdev_blank,
        .fb_setcmap = drm_fb_helper_setcmap,
@@ -215,9 +215,9 @@ static int intelfb_create(struct drm_fb_helper *helper,
        obj = intel_fb->obj;
        size = obj->base.size;
 
-       info = framebuffer_alloc(0, &dev->pdev->dev);
-       if (!info) {
-               ret = -ENOMEM;
+       info = drm_fb_helper_alloc_fbi(helper);
+       if (IS_ERR(info)) {
+               ret = PTR_ERR(info);
                goto out_unpin;
        }
 
@@ -226,24 +226,13 @@ static int intelfb_create(struct drm_fb_helper *helper,
        fb = &ifbdev->fb->base;
 
        ifbdev->helper.fb = fb;
-       ifbdev->helper.fbdev = info;
 
        strcpy(info->fix.id, "inteldrmfb");
 
        info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
        info->fbops = &intelfb_ops;
 
-       ret = fb_alloc_cmap(&info->cmap, 256, 0);
-       if (ret) {
-               ret = -ENOMEM;
-               goto out_unpin;
-       }
        /* setup aperture base/size for vesafb takeover */
-       info->apertures = alloc_apertures(1);
-       if (!info->apertures) {
-               ret = -ENOMEM;
-               goto out_unpin;
-       }
        info->apertures->ranges[0].base = dev->mode_config.fb_base;
        info->apertures->ranges[0].size = dev_priv->gtt.mappable_end;
 
@@ -255,7 +244,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
                           size);
        if (!info->screen_base) {
                ret = -ENOSPC;
-               goto out_unpin;
+               goto out_destroy_fbi;
        }
        info->screen_size = size;
 
@@ -282,6 +271,8 @@ static int intelfb_create(struct drm_fb_helper *helper,
        vga_switcheroo_client_fb_set(dev->pdev, info);
        return 0;
 
+out_destroy_fbi:
+       drm_fb_helper_release_fbi(helper);
 out_unpin:
        i915_gem_object_ggtt_unpin(obj);
        drm_gem_object_unreference(&obj->base);
@@ -523,16 +514,9 @@ static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
 static void intel_fbdev_destroy(struct drm_device *dev,
                                struct intel_fbdev *ifbdev)
 {
-       if (ifbdev->helper.fbdev) {
-               struct fb_info *info = ifbdev->helper.fbdev;
 
-               unregister_framebuffer(info);
-               iounmap(info->screen_base);
-               if (info->cmap.len)
-                       fb_dealloc_cmap(&info->cmap);
-
-               framebuffer_release(info);
-       }
+       drm_fb_helper_unregister_fbi(&ifbdev->helper);
+       drm_fb_helper_release_fbi(&ifbdev->helper);
 
        drm_fb_helper_fini(&ifbdev->helper);
 
@@ -781,7 +765,7 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous
        if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen)
                memset_io(info->screen_base, 0, info->screen_size);
 
-       fb_set_suspend(info, state);
+       drm_fb_helper_set_suspend(&ifbdev->helper, state);
        console_unlock();
 }