Commit 990e8440 authored by Archit Taneja's avatar Archit Taneja Committed by Daniel Vetter

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

Cleaned up the error handling in astfb_create a bit.

v2:
- removed unused variable 'device' in astfb_create

Cc: David Airlie <airlied@linux.ie>
Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent e8b70e4d
...@@ -125,7 +125,7 @@ static void ast_fillrect(struct fb_info *info, ...@@ -125,7 +125,7 @@ static void ast_fillrect(struct fb_info *info,
const struct fb_fillrect *rect) const struct fb_fillrect *rect)
{ {
struct ast_fbdev *afbdev = info->par; struct ast_fbdev *afbdev = info->par;
sys_fillrect(info, rect); drm_fb_helper_sys_fillrect(info, rect);
ast_dirty_update(afbdev, rect->dx, rect->dy, rect->width, ast_dirty_update(afbdev, rect->dx, rect->dy, rect->width,
rect->height); rect->height);
} }
...@@ -134,7 +134,7 @@ static void ast_copyarea(struct fb_info *info, ...@@ -134,7 +134,7 @@ static void ast_copyarea(struct fb_info *info,
const struct fb_copyarea *area) const struct fb_copyarea *area)
{ {
struct ast_fbdev *afbdev = info->par; struct ast_fbdev *afbdev = info->par;
sys_copyarea(info, area); drm_fb_helper_sys_copyarea(info, area);
ast_dirty_update(afbdev, area->dx, area->dy, area->width, ast_dirty_update(afbdev, area->dx, area->dy, area->width,
area->height); area->height);
} }
...@@ -143,7 +143,7 @@ static void ast_imageblit(struct fb_info *info, ...@@ -143,7 +143,7 @@ static void ast_imageblit(struct fb_info *info,
const struct fb_image *image) const struct fb_image *image)
{ {
struct ast_fbdev *afbdev = info->par; struct ast_fbdev *afbdev = info->par;
sys_imageblit(info, image); drm_fb_helper_sys_imageblit(info, image);
ast_dirty_update(afbdev, image->dx, image->dy, image->width, ast_dirty_update(afbdev, image->dx, image->dy, image->width,
image->height); image->height);
} }
...@@ -193,7 +193,6 @@ static int astfb_create(struct drm_fb_helper *helper, ...@@ -193,7 +193,6 @@ static int astfb_create(struct drm_fb_helper *helper,
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
struct fb_info *info; struct fb_info *info;
int size, ret; int size, ret;
struct device *device = &dev->pdev->dev;
void *sysram; void *sysram;
struct drm_gem_object *gobj = NULL; struct drm_gem_object *gobj = NULL;
struct ast_bo *bo = NULL; struct ast_bo *bo = NULL;
...@@ -217,40 +216,28 @@ static int astfb_create(struct drm_fb_helper *helper, ...@@ -217,40 +216,28 @@ static int astfb_create(struct drm_fb_helper *helper,
if (!sysram) if (!sysram)
return -ENOMEM; return -ENOMEM;
info = framebuffer_alloc(0, device); info = drm_fb_helper_alloc_fbi(helper);
if (!info) { if (IS_ERR(info)) {
ret = -ENOMEM; ret = PTR_ERR(info);
goto out; goto err_free_vram;
} }
info->par = afbdev; info->par = afbdev;
ret = ast_framebuffer_init(dev, &afbdev->afb, &mode_cmd, gobj); ret = ast_framebuffer_init(dev, &afbdev->afb, &mode_cmd, gobj);
if (ret) if (ret)
goto out; goto err_release_fbi;
afbdev->sysram = sysram; afbdev->sysram = sysram;
afbdev->size = size; afbdev->size = size;
fb = &afbdev->afb.base; fb = &afbdev->afb.base;
afbdev->helper.fb = fb; afbdev->helper.fb = fb;
afbdev->helper.fbdev = info;
strcpy(info->fix.id, "astdrmfb"); strcpy(info->fix.id, "astdrmfb");
info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT; info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
info->fbops = &astfb_ops; info->fbops = &astfb_ops;
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret) {
ret = -ENOMEM;
goto out;
}
info->apertures = alloc_apertures(1);
if (!info->apertures) {
ret = -ENOMEM;
goto out;
}
info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0); info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0);
info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0); info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0);
...@@ -266,7 +253,11 @@ static int astfb_create(struct drm_fb_helper *helper, ...@@ -266,7 +253,11 @@ static int astfb_create(struct drm_fb_helper *helper,
fb->width, fb->height); fb->width, fb->height);
return 0; return 0;
out:
err_release_fbi:
drm_fb_helper_release_fbi(helper);
err_free_vram:
vfree(afbdev->sysram);
return ret; return ret;
} }
...@@ -297,15 +288,10 @@ static const struct drm_fb_helper_funcs ast_fb_helper_funcs = { ...@@ -297,15 +288,10 @@ static const struct drm_fb_helper_funcs ast_fb_helper_funcs = {
static void ast_fbdev_destroy(struct drm_device *dev, static void ast_fbdev_destroy(struct drm_device *dev,
struct ast_fbdev *afbdev) struct ast_fbdev *afbdev)
{ {
struct fb_info *info;
struct ast_framebuffer *afb = &afbdev->afb; struct ast_framebuffer *afb = &afbdev->afb;
if (afbdev->helper.fbdev) {
info = afbdev->helper.fbdev; drm_fb_helper_unregister_fbi(&afbdev->helper);
unregister_framebuffer(info); drm_fb_helper_release_fbi(&afbdev->helper);
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
if (afb->obj) { if (afb->obj) {
drm_gem_object_unreference_unlocked(afb->obj); drm_gem_object_unreference_unlocked(afb->obj);
...@@ -377,5 +363,5 @@ void ast_fbdev_set_suspend(struct drm_device *dev, int state) ...@@ -377,5 +363,5 @@ void ast_fbdev_set_suspend(struct drm_device *dev, int state)
if (!ast->fbdev) if (!ast->fbdev)
return; return;
fb_set_suspend(ast->fbdev->helper.fbdev, state); drm_fb_helper_set_suspend(&ast->fbdev->helper, state);
} }
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