drivers/gpu/drm/openchrome/openchrome_crtc.c   |   12 ---
 drivers/gpu/drm/openchrome/openchrome_cursor.c |    4 -
 drivers/gpu/drm/openchrome/openchrome_drv.h    |    8 --
 drivers/gpu/drm/openchrome/openchrome_fb.c     |   91 ++++++-------------------
 4 files changed, 30 insertions(+), 85 deletions(-)

New commits:
commit d7cb0f01765df06740cb4a13258f56a3018cd78d
Author: Kevin Brace <kevinbr...@gmx.com>
Date:   Mon Sep 14 14:55:03 2020 -0700

    drm/openchrome: Version bumped to 3.3.5
    
    Signed-off-by: Kevin Brace <kevinbr...@gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h 
b/drivers/gpu/drm/openchrome/openchrome_drv.h
index 51ef0277a5a7..6e43547127df 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -61,7 +61,7 @@
 
 #define DRIVER_MAJOR           3
 #define DRIVER_MINOR           3
-#define DRIVER_PATCHLEVEL      4
+#define DRIVER_PATCHLEVEL      5
 #define DRIVER_NAME            "openchrome"
 #define DRIVER_DESC            "OpenChrome DRM for VIA Technologies Chrome IGP"
 #define DRIVER_DATE            "20200914"
commit edd6b31f6e15aa9b267e51a5bbee3f4cc57525e5
Author: Kevin Brace <kevinbr...@gmx.com>
Date:   Sun Sep 13 04:42:26 2020 -0700

    drm/openchrome: Use GEM framebuffer helpers for drm_framebuffer_funcs
    
    This avoids code duplication.
    
    Signed-off-by: Kevin Brace <kevinbr...@gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c 
b/drivers/gpu/drm/openchrome/openchrome_fb.c
index f6326912aded..13a3945f8841 100644
--- a/drivers/gpu/drm/openchrome/openchrome_fb.c
+++ b/drivers/gpu/drm/openchrome/openchrome_fb.c
@@ -28,40 +28,15 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_fourcc.h>
 #include <drm/drm_gem.h>
+#include <drm_gem_framebuffer_helper.h>
 
 #include "openchrome_drv.h"
 
 
-static int
-via_user_framebuffer_create_handle(struct drm_framebuffer *fb,
-                                       struct drm_file *file_priv,
-                                       unsigned int *handle)
-{
-       int ret;
-
-       DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
-       ret = drm_gem_handle_create(file_priv, fb->obj[0], handle);
-
-       DRM_DEBUG_KMS("Exiting %s.\n", __func__);
-       return ret;
-}
-
-static void
-via_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-       DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
-       drm_gem_object_put(fb->obj[0]);
-       drm_framebuffer_cleanup(fb);
-       kfree(fb);
-
-       DRM_DEBUG_KMS("Exiting %s.\n", __func__);
-}
-
-static const struct drm_framebuffer_funcs via_fb_funcs = {
-       .create_handle  = via_user_framebuffer_create_handle,
-       .destroy        = via_user_framebuffer_destroy,
+static const struct drm_framebuffer_funcs
+openchrome_drm_framebuffer_funcs = {
+       .create_handle  = drm_gem_fb_create_handle,
+       .destroy        = drm_gem_fb_destroy,
 };
 
 static struct drm_framebuffer *
@@ -87,7 +62,8 @@ via_user_framebuffer_create(struct drm_device *dev,
 
        drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
        fb->obj[0] = gem;
-       ret = drm_framebuffer_init(dev, fb, &via_fb_funcs);
+       ret = drm_framebuffer_init(dev, fb,
+                               &openchrome_drm_framebuffer_funcs);
        if (ret) {
                drm_gem_object_put(gem);
                kfree(fb);
@@ -204,7 +180,8 @@ via_fb_probe(struct drm_fb_helper *helper,
 
        drm_helper_mode_fill_fb_struct(dev, fb, &mode_cmd);
        fb->obj[0] = &via_fbdev->bo->gem;
-       ret = drm_framebuffer_init(dev, fb, &via_fb_funcs);
+       ret = drm_framebuffer_init(dev, fb,
+                               &openchrome_drm_framebuffer_funcs);
        if (unlikely(ret)) {
                goto out_err;
        }
commit 15ef643b08865d25799ab4332426cca2546b8447
Author: Kevin Brace <kevinbr...@gmx.com>
Date:   Mon Sep 14 14:51:21 2020 -0700

    drm/openchrome: Pass dev pointer to drm_framebuffer_init()
    
    Signed-off-by: Kevin Brace <kevinbr...@gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c 
b/drivers/gpu/drm/openchrome/openchrome_fb.c
index 46fd7a7dd8d9..f6326912aded 100644
--- a/drivers/gpu/drm/openchrome/openchrome_fb.c
+++ b/drivers/gpu/drm/openchrome/openchrome_fb.c
@@ -204,7 +204,7 @@ via_fb_probe(struct drm_fb_helper *helper,
 
        drm_helper_mode_fill_fb_struct(dev, fb, &mode_cmd);
        fb->obj[0] = &via_fbdev->bo->gem;
-       ret = drm_framebuffer_init(helper->dev, fb, &via_fb_funcs);
+       ret = drm_framebuffer_init(dev, fb, &via_fb_funcs);
        if (unlikely(ret)) {
                goto out_err;
        }
commit 328777a72993ec9ee832aa452ce78faaced1692e
Author: Kevin Brace <kevinbr...@gmx.com>
Date:   Mon Sep 14 14:50:59 2020 -0700

    drm/openchrome: Store GEM handle with drm_framebuffer struct
    
    Rather than allocating private storage for allocating a GEM handle,
    store it with drm_framebuffer struct.  Also, stop the use of
    via_framebuffer struct since it is no longer needed.
    
    Signed-off-by: Kevin Brace <kevinbr...@gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c 
b/drivers/gpu/drm/openchrome/openchrome_crtc.c
index ab467aadcda1..b35fa2d1fd22 100644
--- a/drivers/gpu/drm/openchrome/openchrome_crtc.c
+++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c
@@ -1681,8 +1681,6 @@ static int openchrome_crtc_mode_set_base(struct drm_crtc 
*crtc,
                                        struct drm_framebuffer *old_fb)
 {
        struct drm_framebuffer *fb = crtc->primary->fb;
-       struct via_framebuffer *via_fb = container_of(fb,
-                                       struct via_framebuffer, fb);
        struct openchrome_bo *bo;
        struct drm_gem_object *gem;
        int ret = 0;
@@ -1697,7 +1695,7 @@ static int openchrome_crtc_mode_set_base(struct drm_crtc 
*crtc,
                goto exit;
        }
 
-       gem = via_fb->gem;
+       gem = fb->obj[0];
        bo = container_of(gem, struct openchrome_bo, gem);
 
        ret = ttm_bo_reserve(&bo->ttm_bo, true, false, NULL);
@@ -1732,9 +1730,7 @@ static int openchrome_crtc_mode_set_base(struct drm_crtc 
*crtc,
         * Free the old framebuffer if it exists.
         */
        if (old_fb) {
-               via_fb = container_of(old_fb,
-                                       struct via_framebuffer, fb);
-               gem = via_fb->gem;
+               gem = old_fb->obj[0];
                bo = container_of(gem, struct openchrome_bo, gem);
 
                ret = ttm_bo_reserve(&bo->ttm_bo, true, false, NULL);
@@ -1971,9 +1967,7 @@ static int openchrome_crtc_mode_set_base_atomic(struct 
drm_crtc *crtc,
        struct via_crtc *iga = container_of(crtc, struct via_crtc, base);
        struct openchrome_drm_private *dev_private =
                                                crtc->dev->dev_private;
-       struct via_framebuffer *via_fb = container_of(fb,
-                                       struct via_framebuffer, fb);
-       struct drm_gem_object *gem = via_fb->gem;
+       struct drm_gem_object *gem = fb->obj[0];
        struct openchrome_bo *bo = container_of(gem,
                                        struct openchrome_bo, gem);
        int ret = 0;
diff --git a/drivers/gpu/drm/openchrome/openchrome_cursor.c 
b/drivers/gpu/drm/openchrome/openchrome_cursor.c
index a54b7fa20526..612ff28fa69c 100644
--- a/drivers/gpu/drm/openchrome/openchrome_cursor.c
+++ b/drivers/gpu/drm/openchrome/openchrome_cursor.c
@@ -257,7 +257,6 @@ static int openchrome_cursor_update_plane(struct drm_plane 
*plane,
                                struct drm_modeset_acquire_ctx *ctx)
 {
        struct drm_device *dev = plane->dev;
-       struct via_framebuffer *via_fb;
        struct openchrome_bo *ttm_bo;
        struct drm_gem_object *gem;
        int ret = 0;
@@ -306,8 +305,7 @@ static int openchrome_cursor_update_plane(struct drm_plane 
*plane,
        }
 
        if (fb != crtc->cursor->fb) {
-               via_fb = container_of(fb, struct via_framebuffer, fb);
-               gem = via_fb->gem;
+               gem = fb->obj[0];
                ttm_bo = container_of(gem, struct openchrome_bo, gem);
                openchrome_cursor_address(crtc, ttm_bo);
        } else {
diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h 
b/drivers/gpu/drm/openchrome/openchrome_drv.h
index 2d2262e8a3b7..51ef0277a5a7 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -199,14 +199,8 @@ struct openchrome_bo {
        struct drm_gem_object           gem;
 };
 
-struct via_framebuffer {
-       struct drm_framebuffer          fb;
-       struct drm_gem_object           *gem;
-};
-
 struct via_framebuffer_device {
        struct drm_fb_helper            helper;
-       struct via_framebuffer          via_fb;
        struct openchrome_bo            *bo;
 };
 
diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c 
b/drivers/gpu/drm/openchrome/openchrome_fb.c
index 068f39f2d132..46fd7a7dd8d9 100644
--- a/drivers/gpu/drm/openchrome/openchrome_fb.c
+++ b/drivers/gpu/drm/openchrome/openchrome_fb.c
@@ -37,13 +37,11 @@ via_user_framebuffer_create_handle(struct drm_framebuffer 
*fb,
                                        struct drm_file *file_priv,
                                        unsigned int *handle)
 {
-       struct via_framebuffer *via_fb = container_of(fb,
-                                       struct via_framebuffer, fb);
        int ret;
 
        DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
-       ret = drm_gem_handle_create(file_priv, via_fb->gem, handle);
+       ret = drm_gem_handle_create(file_priv, fb->obj[0], handle);
 
        DRM_DEBUG_KMS("Exiting %s.\n", __func__);
        return ret;
@@ -52,18 +50,11 @@ via_user_framebuffer_create_handle(struct drm_framebuffer 
*fb,
 static void
 via_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
-       struct via_framebuffer *via_fb = container_of(fb,
-                                       struct via_framebuffer, fb);
-
        DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
-       if (via_fb->gem) {
-               drm_gem_object_put(via_fb->gem);
-               via_fb->gem = NULL;
-       }
-
+       drm_gem_object_put(fb->obj[0]);
        drm_framebuffer_cleanup(fb);
-       kfree(via_fb);
+       kfree(fb);
 
        DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
@@ -78,7 +69,7 @@ via_user_framebuffer_create(struct drm_device *dev,
                                struct drm_file *file_priv,
                                const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-       struct via_framebuffer *via_fb;
+       struct drm_framebuffer *fb;
        struct drm_gem_object *gem;
        int ret;
 
@@ -89,23 +80,21 @@ via_user_framebuffer_create(struct drm_device *dev,
                return ERR_PTR(-ENOENT);
        }
 
-       via_fb = kzalloc(sizeof(struct via_framebuffer), GFP_KERNEL);
-       if (!via_fb) {
+       fb = kzalloc(sizeof(struct drm_framebuffer), GFP_KERNEL);
+       if (!fb) {
                return ERR_PTR(-ENOMEM);
        }
 
-       via_fb->gem = gem;
-
-       drm_helper_mode_fill_fb_struct(dev, &via_fb->fb, mode_cmd);
-       ret = drm_framebuffer_init(dev, &via_fb->fb, &via_fb_funcs);
+       drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
+       fb->obj[0] = gem;
+       ret = drm_framebuffer_init(dev, fb, &via_fb_funcs);
        if (ret) {
-               drm_gem_object_put(via_fb->gem);
-               via_fb->gem = NULL;
-               kfree(via_fb);
+               drm_gem_object_put(gem);
+               kfree(fb);
                return ERR_PTR(ret);
        }
 
-       return &via_fb->fb;
+       return fb;
 }
 
 static const struct drm_mode_config_funcs via_mode_funcs = {
@@ -167,8 +156,7 @@ via_fb_probe(struct drm_fb_helper *helper,
                                        helper->dev->dev_private;
        struct via_framebuffer_device *via_fbdev = container_of(helper,
                                struct via_framebuffer_device, helper);
-       struct via_framebuffer *via_fb = &via_fbdev->via_fb;
-       struct drm_framebuffer *fb = &via_fbdev->via_fb.fb;
+       struct drm_framebuffer *fb;
        struct fb_info *info = helper->fbdev;
        const struct drm_format_info *format_info;
        struct drm_mode_fb_cmd2 mode_cmd;
@@ -201,6 +189,11 @@ via_fb_probe(struct drm_fb_helper *helper,
                goto exit;
        }
 
+       fb = kzalloc(sizeof(struct drm_framebuffer), GFP_KERNEL);
+       if (!fb) {
+               return ret;
+       }
+
        info = drm_fb_helper_alloc_fbi(helper);
        if (IS_ERR(info)) {
                ret = PTR_ERR(info);
@@ -210,12 +203,12 @@ via_fb_probe(struct drm_fb_helper *helper,
        info->skip_vt_switch = true;
 
        drm_helper_mode_fill_fb_struct(dev, fb, &mode_cmd);
+       fb->obj[0] = &via_fbdev->bo->gem;
        ret = drm_framebuffer_init(helper->dev, fb, &via_fb_funcs);
        if (unlikely(ret)) {
                goto out_err;
        }
 
-       via_fb->gem = &via_fbdev->bo->gem;
        via_fbdev->helper.fb = fb;
        via_fbdev->helper.fbdev = info;
 
@@ -247,10 +240,7 @@ out_err:
                via_fbdev->bo = NULL;
        }
 
-       if (via_fb->gem) {
-               drm_gem_object_put(via_fb->gem);
-               via_fb->gem = NULL;
-       }
+       kfree(fb);
 exit:
        DRM_DEBUG_KMS("Exiting %s.\n", __func__);
        return ret;
@@ -307,8 +297,6 @@ void via_fbdev_fini(struct drm_device *dev)
        struct openchrome_drm_private *dev_private = dev->dev_private;
        struct drm_fb_helper *fb_helper = &dev_private->
                                                via_fbdev->helper;
-       struct via_framebuffer *via_fb = &dev_private->
-                                               via_fbdev->via_fb;
        struct fb_info *info;
 
        DRM_DEBUG_KMS("Entered %s.\n", __func__);
@@ -325,13 +313,7 @@ void via_fbdev_fini(struct drm_device *dev)
                fb_helper->fbdev = NULL;
        }
 
-       if (via_fb->gem) {
-               drm_gem_object_put(via_fb->gem);
-               via_fb->gem = NULL;
-       }
-
        drm_fb_helper_fini(&dev_private->via_fbdev->helper);
-       drm_framebuffer_cleanup(&dev_private->via_fbdev->via_fb.fb);
        if (dev_private->via_fbdev) {
                kfree(dev_private->via_fbdev);
                dev_private->via_fbdev = NULL;
_______________________________________________
openchrome-devel mailing list
openchrome-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/openchrome-devel

Reply via email to