Commit 4f72a6ea authored by Archit Taneja's avatar Archit Taneja Committed by Daniel Vetter

drm/mgag200: 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:
- remove unused goto label 'out'

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
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 231e6faf
...@@ -101,7 +101,7 @@ static void mga_fillrect(struct fb_info *info, ...@@ -101,7 +101,7 @@ static void mga_fillrect(struct fb_info *info,
const struct fb_fillrect *rect) const struct fb_fillrect *rect)
{ {
struct mga_fbdev *mfbdev = info->par; struct mga_fbdev *mfbdev = info->par;
sys_fillrect(info, rect); drm_fb_helper_sys_fillrect(info, rect);
mga_dirty_update(mfbdev, rect->dx, rect->dy, rect->width, mga_dirty_update(mfbdev, rect->dx, rect->dy, rect->width,
rect->height); rect->height);
} }
...@@ -110,7 +110,7 @@ static void mga_copyarea(struct fb_info *info, ...@@ -110,7 +110,7 @@ static void mga_copyarea(struct fb_info *info,
const struct fb_copyarea *area) const struct fb_copyarea *area)
{ {
struct mga_fbdev *mfbdev = info->par; struct mga_fbdev *mfbdev = info->par;
sys_copyarea(info, area); drm_fb_helper_sys_copyarea(info, area);
mga_dirty_update(mfbdev, area->dx, area->dy, area->width, mga_dirty_update(mfbdev, area->dx, area->dy, area->width,
area->height); area->height);
} }
...@@ -119,7 +119,7 @@ static void mga_imageblit(struct fb_info *info, ...@@ -119,7 +119,7 @@ static void mga_imageblit(struct fb_info *info,
const struct fb_image *image) const struct fb_image *image)
{ {
struct mga_fbdev *mfbdev = info->par; struct mga_fbdev *mfbdev = info->par;
sys_imageblit(info, image); drm_fb_helper_sys_imageblit(info, image);
mga_dirty_update(mfbdev, image->dx, image->dy, image->width, mga_dirty_update(mfbdev, image->dx, image->dy, image->width,
image->height); image->height);
} }
...@@ -166,7 +166,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper, ...@@ -166,7 +166,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
struct fb_info *info; struct fb_info *info;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
struct drm_gem_object *gobj = NULL; struct drm_gem_object *gobj = NULL;
struct device *device = &dev->pdev->dev;
int ret; int ret;
void *sysram; void *sysram;
int size; int size;
...@@ -189,9 +188,9 @@ static int mgag200fb_create(struct drm_fb_helper *helper, ...@@ -189,9 +188,9 @@ static int mgag200fb_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 == NULL) if (IS_ERR(info))
return -ENOMEM; return PTR_ERR(info);
info->par = mfbdev; info->par = mfbdev;
...@@ -206,14 +205,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper, ...@@ -206,14 +205,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
/* setup helper */ /* setup helper */
mfbdev->helper.fb = fb; mfbdev->helper.fb = fb;
mfbdev->helper.fbdev = info;
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret) {
DRM_ERROR("%s: can't allocate color map\n", info->fix.id);
ret = -ENOMEM;
goto out;
}
strcpy(info->fix.id, "mgadrmfb"); strcpy(info->fix.id, "mgadrmfb");
...@@ -221,11 +212,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper, ...@@ -221,11 +212,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
info->fbops = &mgag200fb_ops; info->fbops = &mgag200fb_ops;
/* 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;
}
info->apertures->ranges[0].base = mdev->dev->mode_config.fb_base; info->apertures->ranges[0].base = mdev->dev->mode_config.fb_base;
info->apertures->ranges[0].size = mdev->mc.vram_size; info->apertures->ranges[0].size = mdev->mc.vram_size;
...@@ -240,24 +226,15 @@ static int mgag200fb_create(struct drm_fb_helper *helper, ...@@ -240,24 +226,15 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
DRM_DEBUG_KMS("allocated %dx%d\n", DRM_DEBUG_KMS("allocated %dx%d\n",
fb->width, fb->height); fb->width, fb->height);
return 0; return 0;
out:
return ret;
} }
static int mga_fbdev_destroy(struct drm_device *dev, static int mga_fbdev_destroy(struct drm_device *dev,
struct mga_fbdev *mfbdev) struct mga_fbdev *mfbdev)
{ {
struct fb_info *info;
struct mga_framebuffer *mfb = &mfbdev->mfb; struct mga_framebuffer *mfb = &mfbdev->mfb;
if (mfbdev->helper.fbdev) { drm_fb_helper_unregister_fbi(&mfbdev->helper);
info = mfbdev->helper.fbdev; drm_fb_helper_release_fbi(&mfbdev->helper);
unregister_framebuffer(info);
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
if (mfb->obj) { if (mfb->obj) {
drm_gem_object_unreference_unlocked(mfb->obj); drm_gem_object_unreference_unlocked(mfb->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