drm/exynos: update exynos_drm_framebuffer_init() for multiple buffers
authorJoonyoung Shim <jy0922.shim@samsung.com>
Tue, 1 Sep 2015 07:22:52 +0000 (16:22 +0900)
committerInki Dae <daeinki@gmail.com>
Wed, 2 Sep 2015 14:10:32 +0000 (23:10 +0900)
This modifies exynos_drm_framebuffer_init() to be possible to support
multiple buffers. Then it can be used by exynos_user_fb_create().

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
drivers/gpu/drm/exynos/exynos_drm_fb.c
drivers/gpu/drm/exynos/exynos_drm_fb.h
drivers/gpu/drm/exynos/exynos_drm_fbdev.c

index 33911c10491a934df45bd7327f71d292e6ee085f..8f94eac93b1d820c45d7b1f2126179193f0e4c30 100644 (file)
@@ -23,7 +23,6 @@
 #include "exynos_drm_drv.h"
 #include "exynos_drm_fb.h"
 #include "exynos_drm_fbdev.h"
-#include "exynos_drm_gem.h"
 #include "exynos_drm_iommu.h"
 #include "exynos_drm_crtc.h"
 
@@ -134,36 +133,41 @@ unsigned int exynos_drm_fb_get_buf_cnt(struct drm_framebuffer *fb)
 struct drm_framebuffer *
 exynos_drm_framebuffer_init(struct drm_device *dev,
                            struct drm_mode_fb_cmd2 *mode_cmd,
-                           struct drm_gem_object *obj)
+                           struct exynos_drm_gem_obj **gem_obj,
+                           int count)
 {
        struct exynos_drm_fb *exynos_fb;
-       struct exynos_drm_gem_obj *exynos_gem_obj;
+       int i;
        int ret;
 
-       exynos_gem_obj = to_exynos_gem_obj(obj);
-
-       ret = check_fb_gem_memory_type(dev, exynos_gem_obj);
-       if (ret < 0)
-               return ERR_PTR(ret);
-
        exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL);
        if (!exynos_fb)
                return ERR_PTR(-ENOMEM);
 
-       drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd);
-       exynos_fb->exynos_gem_obj[0] = exynos_gem_obj;
+       exynos_fb->buf_cnt = count;
+       DRM_DEBUG_KMS("buf_cnt = %d\n", exynos_fb->buf_cnt);
 
-       /* buffer count to framebuffer always is 1 at booting time. */
-       exynos_fb->buf_cnt = 1;
+       for (i = 0; i < count; i++) {
+               ret = check_fb_gem_memory_type(dev, gem_obj[i]);
+               if (ret < 0)
+                       goto err;
+
+               exynos_fb->exynos_gem_obj[i] = gem_obj[i];
+       }
+
+       drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd);
 
        ret = drm_framebuffer_init(dev, &exynos_fb->fb, &exynos_drm_fb_funcs);
-       if (ret) {
-               kfree(exynos_fb);
+       if (ret < 0) {
                DRM_ERROR("failed to initialize framebuffer\n");
-               return ERR_PTR(ret);
+               goto err;
        }
 
        return &exynos_fb->fb;
+
+err:
+       kfree(exynos_fb);
+       return ERR_PTR(ret);
 }
 
 static struct drm_framebuffer *
index 897d2cff6287f41540029d71672dfce2bbbda5b3..8900f6baf315313cec51a5d353343b5e88e23fca 100644 (file)
 #ifndef _EXYNOS_DRM_FB_H_
 #define _EXYNOS_DRM_FB_H
 
+#include "exynos_drm_gem.h"
+
 struct drm_framebuffer *
 exynos_drm_framebuffer_init(struct drm_device *dev,
                            struct drm_mode_fb_cmd2 *mode_cmd,
-                           struct drm_gem_object *obj);
+                           struct exynos_drm_gem_obj **gem_obj,
+                           int count);
 
 /* get gem object of a drm framebuffer */
 struct exynos_drm_gem_obj *exynos_drm_fb_gem_obj(struct drm_framebuffer *fb,
index 133cf5f2701fab212f692f5c34e52d7eba25a9d6..a221f753ad9c7a971450b2cf2836dc43f63b3d1b 100644 (file)
@@ -21,7 +21,6 @@
 #include "exynos_drm_drv.h"
 #include "exynos_drm_fb.h"
 #include "exynos_drm_fbdev.h"
-#include "exynos_drm_gem.h"
 #include "exynos_drm_iommu.h"
 
 #define MAX_CONNECTOR          4
@@ -160,7 +159,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
 
        exynos_fbdev->obj = obj;
 
-       helper->fb = exynos_drm_framebuffer_init(dev, &mode_cmd, &obj->base);
+       helper->fb = exynos_drm_framebuffer_init(dev, &mode_cmd, &obj, 1);
        if (IS_ERR(helper->fb)) {
                DRM_ERROR("failed to create drm framebuffer.\n");
                ret = PTR_ERR(helper->fb);