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

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

This is an effort to create a top level drm fbdev emulation option.

Cc: Mark Yao <mark.yao@rock-chips.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent fdefa58a
...@@ -37,9 +37,9 @@ static int rockchip_fbdev_mmap(struct fb_info *info, ...@@ -37,9 +37,9 @@ static int rockchip_fbdev_mmap(struct fb_info *info,
static struct fb_ops rockchip_drm_fbdev_ops = { static struct fb_ops rockchip_drm_fbdev_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.fb_mmap = rockchip_fbdev_mmap, .fb_mmap = rockchip_fbdev_mmap,
.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_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_blank = drm_fb_helper_blank, .fb_blank = drm_fb_helper_blank,
...@@ -77,10 +77,10 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -77,10 +77,10 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper,
private->fbdev_bo = &rk_obj->base; private->fbdev_bo = &rk_obj->base;
fbi = framebuffer_alloc(0, dev->dev); fbi = drm_fb_helper_alloc_fbi(helper);
if (!fbi) { if (IS_ERR(fbi)) {
dev_err(dev->dev, "Failed to allocate framebuffer info.\n"); dev_err(dev->dev, "Failed to create framebuffer info.\n");
ret = -ENOMEM; ret = PTR_ERR(fbi);
goto err_rockchip_gem_free_object; goto err_rockchip_gem_free_object;
} }
...@@ -89,21 +89,13 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -89,21 +89,13 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper,
if (IS_ERR(helper->fb)) { if (IS_ERR(helper->fb)) {
dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n"); dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n");
ret = PTR_ERR(helper->fb); ret = PTR_ERR(helper->fb);
goto err_framebuffer_release; goto err_release_fbi;
} }
helper->fbdev = fbi;
fbi->par = helper; fbi->par = helper;
fbi->flags = FBINFO_FLAG_DEFAULT; fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->fbops = &rockchip_drm_fbdev_ops; fbi->fbops = &rockchip_drm_fbdev_ops;
ret = fb_alloc_cmap(&fbi->cmap, 256, 0);
if (ret) {
dev_err(dev->dev, "Failed to allocate color map.\n");
goto err_drm_framebuffer_unref;
}
fb = helper->fb; fb = helper->fb;
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth); drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
...@@ -124,10 +116,8 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -124,10 +116,8 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper,
return 0; return 0;
err_drm_framebuffer_unref: err_release_fbi:
drm_framebuffer_unreference(helper->fb); drm_fb_helper_release_fbi(helper);
err_framebuffer_release:
framebuffer_release(fbi);
err_rockchip_gem_free_object: err_rockchip_gem_free_object:
rockchip_gem_free_object(&rk_obj->base); rockchip_gem_free_object(&rk_obj->base);
return ret; return ret;
...@@ -190,21 +180,8 @@ void rockchip_drm_fbdev_fini(struct drm_device *dev) ...@@ -190,21 +180,8 @@ void rockchip_drm_fbdev_fini(struct drm_device *dev)
helper = &private->fbdev_helper; helper = &private->fbdev_helper;
if (helper->fbdev) { drm_fb_helper_unregister_fbi(helper);
struct fb_info *info; drm_fb_helper_release_fbi(helper);
int ret;
info = helper->fbdev;
ret = unregister_framebuffer(info);
if (ret < 0)
DRM_DEBUG_KMS("failed unregister_framebuffer() - %d\n",
ret);
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
if (helper->fb) if (helper->fb)
drm_framebuffer_unreference(helper->fb); drm_framebuffer_unreference(helper->fb);
......
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