drm/exynos: Move GEM BOs to drm_framebuffer
authorDaniel Stone <daniels@collabora.com>
Fri, 30 Mar 2018 14:11:30 +0000 (15:11 +0100)
committerInki Dae <inki.dae@samsung.com>
Tue, 17 Apr 2018 05:55:41 +0000 (14:55 +0900)
Since drm_framebuffer can now store GEM objects directly, place them
there rather than in our own subclass. As this makes the framebuffer
create_handle and destroy functions the same as the GEM framebuffer
helper, we can reuse those.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
drivers/gpu/drm/exynos/exynos_drm_fb.c

index 0faaf82..f28ce49 100644 (file)
@@ -18,6 +18,7 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 #include <uapi/drm/exynos_drm.h>
 
 #include "exynos_drm_drv.h"
@@ -36,7 +37,6 @@
  */
 struct exynos_drm_fb {
        struct drm_framebuffer  fb;
-       struct exynos_drm_gem   *exynos_gem[MAX_FB_BUFFER];
        dma_addr_t                      dma_addr[MAX_FB_BUFFER];
 };
 
@@ -66,40 +66,9 @@ static int check_fb_gem_memory_type(struct drm_device *drm_dev,
        return 0;
 }
 
-static void exynos_drm_fb_destroy(struct drm_framebuffer *fb)
-{
-       struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
-       unsigned int i;
-
-       drm_framebuffer_cleanup(fb);
-
-       for (i = 0; i < ARRAY_SIZE(exynos_fb->exynos_gem); i++) {
-               struct drm_gem_object *obj;
-
-               if (exynos_fb->exynos_gem[i] == NULL)
-                       continue;
-
-               obj = &exynos_fb->exynos_gem[i]->base;
-               drm_gem_object_unreference_unlocked(obj);
-       }
-
-       kfree(exynos_fb);
-       exynos_fb = NULL;
-}
-
-static int exynos_drm_fb_create_handle(struct drm_framebuffer *fb,
-                                       struct drm_file *file_priv,
-                                       unsigned int *handle)
-{
-       struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
-
-       return drm_gem_handle_create(file_priv,
-                                    &exynos_fb->exynos_gem[0]->base, handle);
-}
-
 static const struct drm_framebuffer_funcs exynos_drm_fb_funcs = {
-       .destroy        = exynos_drm_fb_destroy,
-       .create_handle  = exynos_drm_fb_create_handle,
+       .destroy        = drm_gem_fb_destroy,
+       .create_handle  = drm_gem_fb_create_handle,
 };
 
 struct drm_framebuffer *
@@ -121,7 +90,7 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
                if (ret < 0)
                        goto err;
 
-               exynos_fb->exynos_gem[i] = exynos_gem[i];
+               exynos_fb->fb.obj[i] = &exynos_gem[i]->base;
                exynos_fb->dma_addr[i] = exynos_gem[i]->dma_addr
                                                + mode_cmd->offsets[i];
        }