diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2019-06-27 11:09:09 +0300 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2019-06-27 20:19:04 +0300 |
commit | 5d17718997367c435dbe5341a8e270d9b19478d3 (patch) | |
tree | 100895abce41ced623ffe042a2f66735b8ca42b9 /drivers/gpu/drm/mgag200/mgag200_fb.c | |
parent | fdb29b738017672069f95747c48eac947b9beba2 (diff) | |
download | linux-5d17718997367c435dbe5341a8e270d9b19478d3.tar.xz |
drm/mgag200: Replace struct mga_framebuffer with GEM framebuffer helpers
The mgag200 driver's struct mga_framebuffer is a buffer object with GEM
interface. There are already GEM framebuffer helpers that implement the
same functionality. Convert mgag200 to these.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20190627080909.30471-1-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/mgag200/mgag200_fb.c')
-rw-r--r-- | drivers/gpu/drm/mgag200/mgag200_fb.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index 8adb33228732..e02d5479ea46 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -11,6 +11,7 @@ #include <drm/drmP.h> #include <drm/drm_util.h> #include <drm/drm_fb_helper.h> +#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_crtc_helper.h> #include "mgag200_drv.h" @@ -19,19 +20,18 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev, int x, int y, int width, int height) { int i; - struct drm_gem_object *obj; struct drm_gem_vram_object *gbo; int src_offset, dst_offset; - int bpp = mfbdev->mfb.base.format->cpp[0]; int ret; u8 *dst; bool unmap = false; bool store_for_later = false; int x2, y2; unsigned long flags; + struct drm_framebuffer *fb = mfbdev->helper.fb; + int bpp = fb->format->cpp[0]; - obj = mfbdev->mfb.obj; - gbo = drm_gem_vram_of_gem(obj); + gbo = drm_gem_vram_of_gem(fb->obj[0]); if (drm_can_sleep()) { /* We pin the BO so it won't be moved during the @@ -89,8 +89,7 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev, for (i = y; i <= y2; i++) { /* assume equal stride for now */ - src_offset = dst_offset = - i * mfbdev->mfb.base.pitches[0] + (x * bpp); + src_offset = dst_offset = i * fb->pitches[0] + (x * bpp); memcpy_toio(dst + dst_offset, mfbdev->sysram + src_offset, (x2 - x + 1) * bpp); } @@ -192,24 +191,24 @@ static int mgag200fb_create(struct drm_fb_helper *helper, sysram = vmalloc(size); if (!sysram) { ret = -ENOMEM; - goto err_sysram; + goto err_drm_gem_object_put_unlocked; } info = drm_fb_helper_alloc_fbi(helper); if (IS_ERR(info)) { ret = PTR_ERR(info); - goto err_alloc_fbi; + goto err_vfree; } - ret = mgag200_framebuffer_init(dev, &mfbdev->mfb, &mode_cmd, gobj); - if (ret) - goto err_alloc_fbi; + fb = drm_gem_fbdev_fb_create(dev, sizes, 0, gobj, NULL); + if (IS_ERR(fb)) { + ret = PTR_ERR(fb); + goto err_vfree; + } mfbdev->sysram = sysram; mfbdev->size = size; - fb = &mfbdev->mfb.base; - /* setup helper */ mfbdev->helper.fb = fb; @@ -230,29 +229,21 @@ static int mgag200fb_create(struct drm_fb_helper *helper, return 0; -err_alloc_fbi: +err_vfree: vfree(sysram); -err_sysram: +err_drm_gem_object_put_unlocked: drm_gem_object_put_unlocked(gobj); - return ret; } static int mga_fbdev_destroy(struct drm_device *dev, struct mga_fbdev *mfbdev) { - struct mga_framebuffer *mfb = &mfbdev->mfb; - drm_fb_helper_unregister_fbi(&mfbdev->helper); - - if (mfb->obj) { - drm_gem_object_put_unlocked(mfb->obj); - mfb->obj = NULL; - } drm_fb_helper_fini(&mfbdev->helper); + drm_framebuffer_put(mfbdev->helper.fb); + vfree(mfbdev->sysram); - drm_framebuffer_unregister_private(&mfb->base); - drm_framebuffer_cleanup(&mfb->base); return 0; } |