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

COMPILE TESTED ONLY.

Cc: Alex Deucher <alexander.deuc...@amd.com>
Cc: Oded Gabbay <oded.gab...@gmail.com>
Cc: "Christian König" <christian.koe...@amd.com>
Signed-off-by: Archit Taneja <arch...@codeaurora.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  4 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c  | 43 +++++++++++----------------------
 2 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 56da962..52d7cfd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -35,6 +35,7 @@
 #include "amdgpu_drv.h"
 
 #include <drm/drm_pciids.h>
+#include <drm/drm_fb_helper.h>
 #include <linux/console.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
@@ -267,7 +268,8 @@ static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev)
 #ifdef CONFIG_X86
        primary = pdev->resource[PCI_ROM_RESOURCE].flags & 
IORESOURCE_ROM_SHADOW;
 #endif
-       remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary);
+       drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb",
+               primary);
        kfree(ap);
 
        return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index c1645d2..f49fdc2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -53,9 +53,9 @@ static struct fb_ops amdgpufb_ops = {
        .owner = THIS_MODULE,
        .fb_check_var = drm_fb_helper_check_var,
        .fb_set_par = drm_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,
@@ -201,9 +201,9 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
        rbo = gem_to_amdgpu_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(ret);
                goto out_unref;
        }
 
@@ -212,14 +212,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
        ret = amdgpu_framebuffer_init(adev->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, amdgpu_bo_size(rbo));
 
@@ -239,11 +238,6 @@ static int amdgpufb_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 = adev->ddev->mode_config.fb_base;
        info->apertures->ranges[0].size = adev->mc.aper_size;
 
@@ -251,13 +245,7 @@ static int amdgpufb_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);
@@ -269,6 +257,8 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
        vga_switcheroo_client_fb_set(adev->ddev->pdev, info);
        return 0;
 
+out_destroy_fbi:
+       drm_fb_helper_release_fbi(helper);
 out_unref:
        if (rbo) {
 
@@ -293,14 +283,8 @@ static int amdgpu_fbdev_destroy(struct drm_device *dev, 
struct amdgpu_fbdev *rfb
        struct fb_info *info;
        struct amdgpu_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) {
                amdgpufb_destroy_pinned_object(rfb->obj);
@@ -395,7 +379,8 @@ void amdgpu_fbdev_fini(struct amdgpu_device *adev)
 void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state)
 {
        if (adev->mode_info.rfbdev)
-               fb_set_suspend(adev->mode_info.rfbdev->helper.fbdev, state);
+               drm_fb_helper_set_suspend(&adev->mode_info.rfbdev->helper,
+                       state);
 }
 
 int amdgpu_fbdev_total_size(struct amdgpu_device *adev)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to