Commit 00450052 authored by Archit Taneja's avatar Archit Taneja Committed by Daniel Vetter

drm/radeon: 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:
- 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: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 4f72a6ea
...@@ -82,9 +82,9 @@ static struct fb_ops radeonfb_ops = { ...@@ -82,9 +82,9 @@ static struct fb_ops radeonfb_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 = radeon_fb_helper_set_par, .fb_set_par = radeon_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,
...@@ -227,7 +227,6 @@ static int radeonfb_create(struct drm_fb_helper *helper, ...@@ -227,7 +227,6 @@ static int radeonfb_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 radeon_bo *rbo = NULL; struct radeon_bo *rbo = NULL;
struct device *device = &rdev->pdev->dev;
int ret; int ret;
unsigned long tmp; unsigned long tmp;
...@@ -250,9 +249,9 @@ static int radeonfb_create(struct drm_fb_helper *helper, ...@@ -250,9 +249,9 @@ static int radeonfb_create(struct drm_fb_helper *helper,
rbo = gem_to_radeon_bo(gobj); rbo = gem_to_radeon_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;
} }
...@@ -262,14 +261,13 @@ static int radeonfb_create(struct drm_fb_helper *helper, ...@@ -262,14 +261,13 @@ static int radeonfb_create(struct drm_fb_helper *helper,
ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->rfb, &mode_cmd, gobj); ret = radeon_framebuffer_init(rdev->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, radeon_bo_size(rbo)); memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo));
...@@ -289,11 +287,6 @@ static int radeonfb_create(struct drm_fb_helper *helper, ...@@ -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); 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 = rdev->ddev->mode_config.fb_base; info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
info->apertures->ranges[0].size = rdev->mc.aper_size; info->apertures->ranges[0].size = rdev->mc.aper_size;
...@@ -301,13 +294,7 @@ static int radeonfb_create(struct drm_fb_helper *helper, ...@@ -301,13 +294,7 @@ static int radeonfb_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);
...@@ -319,6 +306,8 @@ static int radeonfb_create(struct drm_fb_helper *helper, ...@@ -319,6 +306,8 @@ static int radeonfb_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(rdev->ddev->pdev, info); vga_switcheroo_client_fb_set(rdev->ddev->pdev, info);
return 0; return 0;
out_destroy_fbi:
drm_fb_helper_release_fbi(helper);
out_unref: out_unref:
if (rbo) { if (rbo) {
...@@ -339,17 +328,10 @@ void radeon_fb_output_poll_changed(struct radeon_device *rdev) ...@@ -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) static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev)
{ {
struct fb_info *info;
struct radeon_framebuffer *rfb = &rfbdev->rfb; struct radeon_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) {
radeonfb_destroy_pinned_object(rfb->obj); radeonfb_destroy_pinned_object(rfb->obj);
......
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