Commit 6a752972 authored by Archit Taneja's avatar Archit Taneja Committed by Daniel Vetter

drm/bochs: 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 variable device in bochsfb_create

Cc: David Airlie <airlied@linux.ie>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent b166aeb9
...@@ -109,7 +109,7 @@ static int bochs_pm_suspend(struct device *dev) ...@@ -109,7 +109,7 @@ static int bochs_pm_suspend(struct device *dev)
if (bochs->fb.initialized) { if (bochs->fb.initialized) {
console_lock(); console_lock();
fb_set_suspend(bochs->fb.helper.fbdev, 1); drm_fb_helper_set_suspend(&bochs->fb.helper, 1);
console_unlock(); console_unlock();
} }
...@@ -126,7 +126,7 @@ static int bochs_pm_resume(struct device *dev) ...@@ -126,7 +126,7 @@ static int bochs_pm_resume(struct device *dev)
if (bochs->fb.initialized) { if (bochs->fb.initialized) {
console_lock(); console_lock();
fb_set_suspend(bochs->fb.helper.fbdev, 0); drm_fb_helper_set_suspend(&bochs->fb.helper, 0);
console_unlock(); console_unlock();
} }
......
...@@ -24,9 +24,9 @@ static struct fb_ops bochsfb_ops = { ...@@ -24,9 +24,9 @@ static struct fb_ops bochsfb_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 = sys_fillrect, .fb_fillrect = drm_fb_helper_sys_fillrect,
.fb_copyarea = sys_copyarea, .fb_copyarea = drm_fb_helper_sys_copyarea,
.fb_imageblit = sys_imageblit, .fb_imageblit = drm_fb_helper_sys_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,
...@@ -56,11 +56,9 @@ static int bochsfb_create(struct drm_fb_helper *helper, ...@@ -56,11 +56,9 @@ static int bochsfb_create(struct drm_fb_helper *helper,
{ {
struct bochs_device *bochs = struct bochs_device *bochs =
container_of(helper, struct bochs_device, fb.helper); container_of(helper, struct bochs_device, fb.helper);
struct drm_device *dev = bochs->dev;
struct fb_info *info; struct fb_info *info;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
struct drm_mode_fb_cmd2 mode_cmd; struct drm_mode_fb_cmd2 mode_cmd;
struct device *device = &dev->pdev->dev;
struct drm_gem_object *gobj = NULL; struct drm_gem_object *gobj = NULL;
struct bochs_bo *bo = NULL; struct bochs_bo *bo = NULL;
int size, ret; int size, ret;
...@@ -106,22 +104,23 @@ static int bochsfb_create(struct drm_fb_helper *helper, ...@@ -106,22 +104,23 @@ static int bochsfb_create(struct drm_fb_helper *helper,
ttm_bo_unreserve(&bo->bo); ttm_bo_unreserve(&bo->bo);
/* init fb device */ /* init fb device */
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 = &bochs->fb.helper; info->par = &bochs->fb.helper;
ret = bochs_framebuffer_init(bochs->dev, &bochs->fb.gfb, &mode_cmd, gobj); ret = bochs_framebuffer_init(bochs->dev, &bochs->fb.gfb, &mode_cmd, gobj);
if (ret) if (ret) {
drm_fb_helper_release_fbi(helper);
return ret; return ret;
}
bochs->fb.size = size; bochs->fb.size = size;
/* setup helper */ /* setup helper */
fb = &bochs->fb.gfb.base; fb = &bochs->fb.gfb.base;
bochs->fb.helper.fb = fb; bochs->fb.helper.fb = fb;
bochs->fb.helper.fbdev = info;
strcpy(info->fix.id, "bochsdrmfb"); strcpy(info->fix.id, "bochsdrmfb");
...@@ -139,30 +138,17 @@ static int bochsfb_create(struct drm_fb_helper *helper, ...@@ -139,30 +138,17 @@ static int bochsfb_create(struct drm_fb_helper *helper,
info->fix.smem_start = 0; info->fix.smem_start = 0;
info->fix.smem_len = size; info->fix.smem_len = size;
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret) {
DRM_ERROR("%s: can't allocate color map\n", info->fix.id);
return -ENOMEM;
}
return 0; return 0;
} }
static int bochs_fbdev_destroy(struct bochs_device *bochs) static int bochs_fbdev_destroy(struct bochs_device *bochs)
{ {
struct bochs_framebuffer *gfb = &bochs->fb.gfb; struct bochs_framebuffer *gfb = &bochs->fb.gfb;
struct fb_info *info;
DRM_DEBUG_DRIVER("\n"); DRM_DEBUG_DRIVER("\n");
if (bochs->fb.helper.fbdev) { drm_fb_helper_unregister_fbi(&bochs->fb.helper);
info = bochs->fb.helper.fbdev; drm_fb_helper_release_fbi(&bochs->fb.helper);
unregister_framebuffer(info);
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
if (gfb->obj) { if (gfb->obj) {
drm_gem_object_unreference_unlocked(gfb->obj); drm_gem_object_unreference_unlocked(gfb->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