Use drm_fb_cma_fbdev_init() and drm_fb_cma_fbdev_fini() which relies on
the fact that drm_device holds a pointer to the drm_fb_helper structure.
This means that the driver doesn't have to keep track of that.
Also use the drm_fb_helper functions directly.
Remove duplicate ldev assignment.

Cc: Yannick Fertre <yannick.fer...@st.com>
Cc: Philippe Cornu <philippe.co...@st.com>
Cc: Benjamin Gaignard <benjamin.gaign...@linaro.org>
Cc: Vincent Abriou <vincent.abr...@st.com>
Signed-off-by: Noralf Trønnes <nor...@tronnes.org>
Acked-by: Philippe Cornu <philippe.co...@st.com>
---
 drivers/gpu/drm/stm/drv.c  | 38 ++++++--------------------------------
 drivers/gpu/drm/stm/ltdc.h |  1 -
 2 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index c857663eafc2..555b05010e9b 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -15,6 +15,7 @@
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
@@ -24,35 +25,19 @@
 #define STM_MAX_FB_WIDTH       2048
 #define STM_MAX_FB_HEIGHT      2048 /* same as width to handle orientation */
 
-static void drv_output_poll_changed(struct drm_device *ddev)
-{
-       struct ltdc_device *ldev = ddev->dev_private;
-
-       drm_fbdev_cma_hotplug_event(ldev->fbdev);
-}
-
 static const struct drm_mode_config_funcs drv_mode_config_funcs = {
        .fb_create = drm_gem_fb_create,
-       .output_poll_changed = drv_output_poll_changed,
+       .output_poll_changed = drm_fb_helper_output_poll_changed,
        .atomic_check = drm_atomic_helper_check,
        .atomic_commit = drm_atomic_helper_commit,
 };
 
-static void drv_lastclose(struct drm_device *ddev)
-{
-       struct ltdc_device *ldev = ddev->dev_private;
-
-       DRM_DEBUG("%s\n", __func__);
-
-       drm_fbdev_cma_restore_mode(ldev->fbdev);
-}
-
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
 
 static struct drm_driver drv_driver = {
        .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
                           DRIVER_ATOMIC,
-       .lastclose = drv_lastclose,
+       .lastclose = drm_fb_helper_lastclose,
        .name = "stm",
        .desc = "STMicroelectronics SoC DRM",
        .date = "20170330",
@@ -79,7 +64,6 @@ static struct drm_driver drv_driver = {
 static int drv_load(struct drm_device *ddev)
 {
        struct platform_device *pdev = to_platform_device(ddev->dev);
-       struct drm_fbdev_cma *fbdev;
        struct ltdc_device *ldev;
        int ret;
 
@@ -112,14 +96,9 @@ static int drv_load(struct drm_device *ddev)
        drm_kms_helper_poll_init(ddev);
 
        if (ddev->mode_config.num_connector) {
-               ldev = ddev->dev_private;
-               fbdev = drm_fbdev_cma_init(ddev, 16,
-                                          ddev->mode_config.num_connector);
-               if (IS_ERR(fbdev)) {
+               ret = drm_fb_cma_fbdev_init(ddev, 16, 0);
+               if (ret)
                        DRM_DEBUG("Warning: fails to create fbdev\n");
-                       fbdev = NULL;
-               }
-               ldev->fbdev = fbdev;
        }
 
        platform_set_drvdata(pdev, ddev);
@@ -132,14 +111,9 @@ static int drv_load(struct drm_device *ddev)
 
 static void drv_unload(struct drm_device *ddev)
 {
-       struct ltdc_device *ldev = ddev->dev_private;
-
        DRM_DEBUG("%s\n", __func__);
 
-       if (ldev->fbdev) {
-               drm_fbdev_cma_fini(ldev->fbdev);
-               ldev->fbdev = NULL;
-       }
+       drm_fb_cma_fbdev_fini(ddev);
        drm_kms_helper_poll_fini(ddev);
        ltdc_unload(ddev);
        drm_mode_config_cleanup(ddev);
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index ae437557d715..27ac217406be 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -21,7 +21,6 @@ struct ltdc_caps {
 };
 
 struct ltdc_device {
-       struct drm_fbdev_cma *fbdev;
        void __iomem *regs;
        struct clk *pixel_clk;  /* lcd pixel clock */
        struct mutex err_lock;  /* protecting error_status */
-- 
2.14.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to