drm/radeon: Use new drm_fb_helper functions
authorArchit Taneja <architt@codeaurora.org>
Fri, 31 Jul 2015 10:51:54 +0000 (16:21 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 6 Aug 2015 12:13:04 +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:
- Fix build break because of missing include of drm_fb_helper in
  radeon_drv.c

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/radeon/radeon_fb.c

index aeb676708e60cfb1871326bfc5a689631bb98741..7214858ffceaa8c20409206533dcc332fd663705 100644 (file)
@@ -82,9 +82,9 @@ static struct fb_ops radeonfb_ops = {
        .owner = THIS_MODULE,
        .fb_check_var = drm_fb_helper_check_var,
        .fb_set_par = radeon_fb_helper_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 = drm_fb_helper_pan_display,
        .fb_blank = drm_fb_helper_blank,
        .fb_setcmap = drm_fb_helper_setcmap,
@@ -227,7 +227,6 @@ static int radeonfb_create(struct drm_fb_helper *helper,
        struct drm_mode_fb_cmd2 mode_cmd;
        struct drm_gem_object *gobj = NULL;
        struct radeon_bo *rbo = NULL;
-       struct device *device = &rdev->pdev->dev;
        int ret;
        unsigned long tmp;
 
@@ -250,9 +249,9 @@ static int radeonfb_create(struct drm_fb_helper *helper,
        rbo = gem_to_radeon_bo(gobj);
 
        /* okay we have an object now allocate the framebuffer */
-       info = framebuffer_alloc(0, device);
-       if (info == NULL) {
-               ret = -ENOMEM;
+       info = drm_fb_helper_alloc_fbi(helper);
+       if (IS_ERR(info)) {
+               ret = PTR_ERR(info);
                goto out_unref;
        }
 
@@ -262,14 +261,13 @@ static int radeonfb_create(struct drm_fb_helper *helper,
        ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->rfb, &mode_cmd, gobj);
        if (ret) {
                DRM_ERROR("failed to initialize framebuffer %d\n", ret);
-               goto out_unref;
+               goto out_destroy_fbi;
        }
 
        fb = &rfbdev->rfb.base;
 
        /* setup helper */
        rfbdev->helper.fb = fb;
-       rfbdev->helper.fbdev = info;
 
        memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo));
 
@@ -289,11 +287,6 @@ static int radeonfb_create(struct drm_fb_helper *helper,
        drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height);
 
        /* setup aperture base/size for vesafb takeover */
-       info->apertures = alloc_apertures(1);
-       if (!info->apertures) {
-               ret = -ENOMEM;
-               goto out_unref;
-       }
        info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
        info->apertures->ranges[0].size = rdev->mc.aper_size;
 
@@ -301,13 +294,7 @@ static int radeonfb_create(struct drm_fb_helper *helper,
 
        if (info->screen_base == NULL) {
                ret = -ENOSPC;
-               goto out_unref;
-       }
-
-       ret = fb_alloc_cmap(&info->cmap, 256, 0);
-       if (ret) {
-               ret = -ENOMEM;
-               goto out_unref;
+               goto out_destroy_fbi;
        }
 
        DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
@@ -319,6 +306,8 @@ static int radeonfb_create(struct drm_fb_helper *helper,
        vga_switcheroo_client_fb_set(rdev->ddev->pdev, info);
        return 0;
 
+out_destroy_fbi:
+       drm_fb_helper_release_fbi(helper);
 out_unref:
        if (rbo) {
 
@@ -339,17 +328,10 @@ void radeon_fb_output_poll_changed(struct radeon_device *rdev)
 
 static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev)
 {
-       struct fb_info *info;
        struct radeon_framebuffer *rfb = &rfbdev->rfb;
 
-       if (rfbdev->helper.fbdev) {
-               info = rfbdev->helper.fbdev;
-
-               unregister_framebuffer(info);
-               if (info->cmap.len)
-                       fb_dealloc_cmap(&info->cmap);
-               framebuffer_release(info);
-       }
+       drm_fb_helper_unregister_fbi(&rfbdev->helper);
+       drm_fb_helper_release_fbi(&rfbdev->helper);
 
        if (rfb->obj) {
                radeonfb_destroy_pinned_object(rfb->obj);