mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-23 08:55:56 -04:00
drm/exynos: remove buffer creation of fbdev from drm framebuffer creation
The fbdev fb and the user fb is created from same function - exynos_drm_fb_create, but this function creates not only drm framebuffer but buffer of fbdev. Remove it because it complicates codes and use exynos_drm_gem_create() than exynos_drm_buf_create() to create buffer of fbdev, it give better consistency of codes and more clear implementation. Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
This commit is contained in:
@@ -43,8 +43,8 @@
|
||||
drm_fb_helper)
|
||||
|
||||
struct exynos_drm_fbdev {
|
||||
struct drm_fb_helper drm_fb_helper;
|
||||
struct drm_framebuffer *fb;
|
||||
struct drm_fb_helper drm_fb_helper;
|
||||
struct exynos_drm_gem_obj *exynos_gem_obj;
|
||||
};
|
||||
|
||||
static int exynos_drm_fbdev_set_par(struct fb_info *info)
|
||||
@@ -90,15 +90,12 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
|
||||
{
|
||||
struct fb_info *fbi = helper->fbdev;
|
||||
struct drm_device *dev = helper->dev;
|
||||
struct exynos_drm_fbdev *exynos_fb = to_exynos_fbdev(helper);
|
||||
struct exynos_drm_gem_buf *buffer;
|
||||
unsigned int size = fb->width * fb->height * (fb->bits_per_pixel >> 3);
|
||||
unsigned long offset;
|
||||
|
||||
DRM_DEBUG_KMS("%s\n", __FILE__);
|
||||
|
||||
exynos_fb->fb = fb;
|
||||
|
||||
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
|
||||
drm_fb_helper_fill_var(fbi, helper, fb->width, fb->height);
|
||||
|
||||
@@ -124,10 +121,12 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
|
||||
struct drm_fb_helper_surface_size *sizes)
|
||||
{
|
||||
struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper);
|
||||
struct exynos_drm_gem_obj *exynos_gem_obj;
|
||||
struct drm_device *dev = helper->dev;
|
||||
struct fb_info *fbi;
|
||||
struct drm_mode_fb_cmd2 mode_cmd = { 0 };
|
||||
struct platform_device *pdev = dev->platformdev;
|
||||
unsigned long size;
|
||||
int ret;
|
||||
|
||||
DRM_DEBUG_KMS("%s\n", __FILE__);
|
||||
@@ -151,14 +150,23 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
|
||||
goto out;
|
||||
}
|
||||
|
||||
exynos_fbdev->fb = exynos_drm_fb_create(dev, NULL, &mode_cmd);
|
||||
if (IS_ERR_OR_NULL(exynos_fbdev->fb)) {
|
||||
DRM_ERROR("failed to create drm framebuffer.\n");
|
||||
ret = PTR_ERR(exynos_fbdev->fb);
|
||||
size = mode_cmd.pitches[0] * mode_cmd.height;
|
||||
exynos_gem_obj = exynos_drm_gem_create(dev, size);
|
||||
if (IS_ERR(exynos_gem_obj)) {
|
||||
ret = PTR_ERR(exynos_gem_obj);
|
||||
goto out;
|
||||
}
|
||||
|
||||
exynos_fbdev->exynos_gem_obj = exynos_gem_obj;
|
||||
|
||||
helper->fb = exynos_drm_framebuffer_init(dev, &mode_cmd,
|
||||
&exynos_gem_obj->base);
|
||||
if (IS_ERR_OR_NULL(helper->fb)) {
|
||||
DRM_ERROR("failed to create drm framebuffer.\n");
|
||||
ret = PTR_ERR(helper->fb);
|
||||
goto out;
|
||||
}
|
||||
|
||||
helper->fb = exynos_fbdev->fb;
|
||||
helper->fbdev = fbi;
|
||||
|
||||
fbi->par = helper;
|
||||
@@ -172,8 +180,10 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
|
||||
}
|
||||
|
||||
ret = exynos_drm_fbdev_update(helper, helper->fb);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
fb_dealloc_cmap(&fbi->cmap);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* if failed, all resources allocated above would be released by
|
||||
@@ -206,16 +216,13 @@ static int exynos_drm_fbdev_recreate(struct drm_fb_helper *helper,
|
||||
{
|
||||
struct drm_device *dev = helper->dev;
|
||||
struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper);
|
||||
struct drm_framebuffer *fb = exynos_fbdev->fb;
|
||||
struct exynos_drm_gem_obj *exynos_gem_obj;
|
||||
struct drm_framebuffer *fb = helper->fb;
|
||||
struct drm_mode_fb_cmd2 mode_cmd = { 0 };
|
||||
unsigned long size;
|
||||
|
||||
DRM_DEBUG_KMS("%s\n", __FILE__);
|
||||
|
||||
if (helper->fb != fb) {
|
||||
DRM_ERROR("drm framebuffer is different\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (exynos_drm_fbdev_is_samefb(fb, sizes))
|
||||
return 0;
|
||||
|
||||
@@ -225,16 +232,26 @@ static int exynos_drm_fbdev_recreate(struct drm_fb_helper *helper,
|
||||
mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
|
||||
sizes->surface_depth);
|
||||
|
||||
if (exynos_fbdev->exynos_gem_obj)
|
||||
exynos_drm_gem_destroy(exynos_fbdev->exynos_gem_obj);
|
||||
|
||||
if (fb->funcs->destroy)
|
||||
fb->funcs->destroy(fb);
|
||||
|
||||
exynos_fbdev->fb = exynos_drm_fb_create(dev, NULL, &mode_cmd);
|
||||
if (IS_ERR(exynos_fbdev->fb)) {
|
||||
DRM_ERROR("failed to allocate fb.\n");
|
||||
return PTR_ERR(exynos_fbdev->fb);
|
||||
size = mode_cmd.pitches[0] * mode_cmd.height;
|
||||
exynos_gem_obj = exynos_drm_gem_create(dev, size);
|
||||
if (IS_ERR(exynos_gem_obj))
|
||||
return PTR_ERR(exynos_gem_obj);
|
||||
|
||||
exynos_fbdev->exynos_gem_obj = exynos_gem_obj;
|
||||
|
||||
helper->fb = exynos_drm_framebuffer_init(dev, &mode_cmd,
|
||||
&exynos_gem_obj->base);
|
||||
if (IS_ERR_OR_NULL(helper->fb)) {
|
||||
DRM_ERROR("failed to create drm framebuffer.\n");
|
||||
return PTR_ERR(helper->fb);
|
||||
}
|
||||
|
||||
helper->fb = exynos_fbdev->fb;
|
||||
return exynos_drm_fbdev_update(helper, helper->fb);
|
||||
}
|
||||
|
||||
@@ -368,6 +385,9 @@ void exynos_drm_fbdev_fini(struct drm_device *dev)
|
||||
|
||||
fbdev = to_exynos_fbdev(private->fb_helper);
|
||||
|
||||
if (fbdev->exynos_gem_obj)
|
||||
exynos_drm_gem_destroy(fbdev->exynos_gem_obj);
|
||||
|
||||
exynos_drm_fbdev_destroy(dev, private->fb_helper);
|
||||
kfree(fbdev);
|
||||
private->fb_helper = NULL;
|
||||
|
||||
Reference in New Issue
Block a user