Commit 2dbaf392 authored by Archit Taneja's avatar Archit Taneja Committed by Daniel Vetter

drm/amdgpu: 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.

v3:
- Don't touch remove_conflicting_framebuffers

v2:
- Fixed PTR_ERR issue mentioned by kbuild bot

Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Oded Gabbay <oded.gabbay@gmail.com>
Cc: "Christian König" <christian.koenig@amd.com>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 6a752972
...@@ -53,9 +53,9 @@ static struct fb_ops amdgpufb_ops = { ...@@ -53,9 +53,9 @@ static struct fb_ops amdgpufb_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.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_fillrect = cfb_fillrect, .fb_fillrect = drm_fb_helper_cfb_fillrect,
.fb_copyarea = cfb_copyarea, .fb_copyarea = drm_fb_helper_cfb_copyarea,
.fb_imageblit = cfb_imageblit, .fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display, .fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank, .fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap, .fb_setcmap = drm_fb_helper_setcmap,
...@@ -179,7 +179,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper, ...@@ -179,7 +179,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
struct drm_mode_fb_cmd2 mode_cmd; struct drm_mode_fb_cmd2 mode_cmd;
struct drm_gem_object *gobj = NULL; struct drm_gem_object *gobj = NULL;
struct amdgpu_bo *rbo = NULL; struct amdgpu_bo *rbo = NULL;
struct device *device = &adev->pdev->dev;
int ret; int ret;
unsigned long tmp; unsigned long tmp;
...@@ -201,9 +200,9 @@ static int amdgpufb_create(struct drm_fb_helper *helper, ...@@ -201,9 +200,9 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
rbo = gem_to_amdgpu_bo(gobj); rbo = gem_to_amdgpu_bo(gobj);
/* okay we have an object now allocate the framebuffer */ /* okay we have an object now allocate the framebuffer */
info = framebuffer_alloc(0, device); info = drm_fb_helper_alloc_fbi(helper);
if (info == NULL) { if (IS_ERR(info)) {
ret = -ENOMEM; ret = PTR_ERR(info);
goto out_unref; goto out_unref;
} }
...@@ -212,14 +211,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper, ...@@ -212,14 +211,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
ret = amdgpu_framebuffer_init(adev->ddev, &rfbdev->rfb, &mode_cmd, gobj); ret = amdgpu_framebuffer_init(adev->ddev, &rfbdev->rfb, &mode_cmd, gobj);
if (ret) { if (ret) {
DRM_ERROR("failed to initialize framebuffer %d\n", ret); DRM_ERROR("failed to initialize framebuffer %d\n", ret);
goto out_unref; goto out_destroy_fbi;
} }
fb = &rfbdev->rfb.base; fb = &rfbdev->rfb.base;
/* setup helper */ /* setup helper */
rfbdev->helper.fb = fb; rfbdev->helper.fb = fb;
rfbdev->helper.fbdev = info;
memset_io(rbo->kptr, 0x0, amdgpu_bo_size(rbo)); memset_io(rbo->kptr, 0x0, amdgpu_bo_size(rbo));
...@@ -239,11 +237,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper, ...@@ -239,11 +237,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height); drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height);
/* setup aperture base/size for vesafb takeover */ /* 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].base = adev->ddev->mode_config.fb_base;
info->apertures->ranges[0].size = adev->mc.aper_size; info->apertures->ranges[0].size = adev->mc.aper_size;
...@@ -251,13 +244,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper, ...@@ -251,13 +244,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
if (info->screen_base == NULL) { if (info->screen_base == NULL) {
ret = -ENOSPC; ret = -ENOSPC;
goto out_unref; goto out_destroy_fbi;
}
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret) {
ret = -ENOMEM;
goto out_unref;
} }
DRM_INFO("fb mappable at 0x%lX\n", info->fix.smem_start); DRM_INFO("fb mappable at 0x%lX\n", info->fix.smem_start);
...@@ -269,6 +256,8 @@ static int amdgpufb_create(struct drm_fb_helper *helper, ...@@ -269,6 +256,8 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(adev->ddev->pdev, info); vga_switcheroo_client_fb_set(adev->ddev->pdev, info);
return 0; return 0;
out_destroy_fbi:
drm_fb_helper_release_fbi(helper);
out_unref: out_unref:
if (rbo) { if (rbo) {
...@@ -290,17 +279,10 @@ void amdgpu_fb_output_poll_changed(struct amdgpu_device *adev) ...@@ -290,17 +279,10 @@ void amdgpu_fb_output_poll_changed(struct amdgpu_device *adev)
static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev) static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev)
{ {
struct fb_info *info;
struct amdgpu_framebuffer *rfb = &rfbdev->rfb; struct amdgpu_framebuffer *rfb = &rfbdev->rfb;
if (rfbdev->helper.fbdev) { drm_fb_helper_unregister_fbi(&rfbdev->helper);
info = rfbdev->helper.fbdev; drm_fb_helper_release_fbi(&rfbdev->helper);
unregister_framebuffer(info);
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
if (rfb->obj) { if (rfb->obj) {
amdgpufb_destroy_pinned_object(rfb->obj); amdgpufb_destroy_pinned_object(rfb->obj);
...@@ -395,7 +377,8 @@ void amdgpu_fbdev_fini(struct amdgpu_device *adev) ...@@ -395,7 +377,8 @@ void amdgpu_fbdev_fini(struct amdgpu_device *adev)
void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state) void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state)
{ {
if (adev->mode_info.rfbdev) 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) int amdgpu_fbdev_total_size(struct amdgpu_device *adev)
......
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