Wire up CRTCs', planes' and connectors' ->reset, ->duplicate and ->destroy state
hooks to use the default implementations from the atomic helper library.
The helpers track each DRM object state.

Signed-off-by: Liu Ying <gnuiyl at gmail.com>
---
 drivers/gpu/drm/bridge/dw-hdmi.c       | 19 +++----------------
 drivers/gpu/drm/imx/imx-drm-core.c     |  2 ++
 drivers/gpu/drm/imx/imx-ldb.c          |  4 ++++
 drivers/gpu/drm/imx/imx-tve.c          |  4 ++++
 drivers/gpu/drm/imx/ipuv3-crtc.c       |  4 ++++
 drivers/gpu/drm/imx/ipuv3-plane.c      |  4 ++++
 drivers/gpu/drm/imx/parallel-display.c |  4 ++++
 7 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index 9795b72..6541b3c 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -1508,14 +1508,6 @@ static void dw_hdmi_connector_force(struct drm_connector 
*connector)
        mutex_unlock(&hdmi->mutex);
 }

-static const struct drm_connector_funcs dw_hdmi_connector_funcs = {
-       .dpms = drm_helper_connector_dpms,
-       .fill_modes = drm_helper_probe_single_connector_modes,
-       .detect = dw_hdmi_connector_detect,
-       .destroy = dw_hdmi_connector_destroy,
-       .force = dw_hdmi_connector_force,
-};
-
 static const struct drm_connector_funcs dw_hdmi_atomic_connector_funcs = {
        .dpms = drm_atomic_helper_connector_dpms,
        .fill_modes = drm_helper_probe_single_connector_modes,
@@ -1650,14 +1642,9 @@ static int dw_hdmi_register(struct drm_device *drm, 
struct dw_hdmi *hdmi)
        drm_connector_helper_add(&hdmi->connector,
                                 &dw_hdmi_connector_helper_funcs);

-       if (drm_core_check_feature(drm, DRIVER_ATOMIC))
-               drm_connector_init(drm, &hdmi->connector,
-                                  &dw_hdmi_atomic_connector_funcs,
-                                  DRM_MODE_CONNECTOR_HDMIA);
-       else
-               drm_connector_init(drm, &hdmi->connector,
-                                  &dw_hdmi_connector_funcs,
-                                  DRM_MODE_CONNECTOR_HDMIA);
+       drm_connector_init(drm, &hdmi->connector,
+                          &dw_hdmi_atomic_connector_funcs,
+                          DRM_MODE_CONNECTOR_HDMIA);

        drm_mode_connector_attach_encoder(&hdmi->connector, encoder);

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 05229b9..e15f887 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -283,6 +283,8 @@ static int imx_drm_driver_load(struct drm_device *drm, 
unsigned long flags)
                }
        }

+       drm_mode_config_reset(drm);
+
        /*
         * All components are now initialised, so setup the fb helper.
         * The fb helper takes copies of key hardware information, so the
diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index a58eee5..8f17b64 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -17,6 +17,7 @@
 #include <linux/clk.h>
 #include <linux/component.h>
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_of.h>
@@ -357,6 +358,9 @@ static const struct drm_connector_funcs 
imx_ldb_connector_funcs = {
        .fill_modes = drm_helper_probe_single_connector_modes,
        .detect = imx_ldb_connector_detect,
        .destroy = imx_drm_connector_destroy,
+       .reset = drm_atomic_helper_connector_reset,
+       .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };

 static const struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs 
= {
diff --git a/drivers/gpu/drm/imx/imx-tve.c b/drivers/gpu/drm/imx/imx-tve.c
index ae7a9fb..9b45deb 100644
--- a/drivers/gpu/drm/imx/imx-tve.c
+++ b/drivers/gpu/drm/imx/imx-tve.c
@@ -23,6 +23,7 @@
 #include <linux/spinlock.h>
 #include <linux/videodev2.h>
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_crtc_helper.h>
 #include <video/imx-ipu-v3.h>
@@ -358,6 +359,9 @@ static const struct drm_connector_funcs 
imx_tve_connector_funcs = {
        .fill_modes = drm_helper_probe_single_connector_modes,
        .detect = imx_tve_connector_detect,
        .destroy = imx_drm_connector_destroy,
+       .reset = drm_atomic_helper_connector_reset,
+       .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };

 static const struct drm_connector_helper_funcs imx_tve_connector_helper_funcs 
= {
diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index 11fad87..bd3b99e 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -18,6 +18,7 @@
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
 #include <linux/fb.h>
 #include <linux/clk.h>
@@ -233,6 +234,9 @@ static const struct drm_crtc_funcs ipu_crtc_funcs = {
        .set_config = drm_crtc_helper_set_config,
        .destroy = drm_crtc_cleanup,
        .page_flip = ipu_page_flip,
+       .reset = drm_atomic_helper_crtc_reset,
+       .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };

 static void ipu_crtc_handle_pageflip(struct ipu_crtc *ipu_crtc)
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c 
b/drivers/gpu/drm/imx/ipuv3-plane.c
index 4511b84..347b581 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -14,6 +14,7 @@
  */

 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_plane_helper.h>
@@ -362,6 +363,9 @@ static const struct drm_plane_funcs ipu_plane_funcs = {
        .update_plane   = drm_plane_helper_update,
        .disable_plane  = drm_plane_helper_disable,
        .destroy        = ipu_plane_destroy,
+       .reset          = drm_atomic_helper_plane_reset,
+       .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+       .atomic_destroy_state   = drm_atomic_helper_plane_destroy_state,
 };

 static int ipu_plane_atomic_check(struct drm_plane *plane,
diff --git a/drivers/gpu/drm/imx/parallel-display.c 
b/drivers/gpu/drm/imx/parallel-display.c
index 363e2c7..252c0ea 100644
--- a/drivers/gpu/drm/imx/parallel-display.c
+++ b/drivers/gpu/drm/imx/parallel-display.c
@@ -16,6 +16,7 @@
 #include <linux/component.h>
 #include <linux/module.h>
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_panel.h>
@@ -146,6 +147,9 @@ static const struct drm_connector_funcs 
imx_pd_connector_funcs = {
        .fill_modes = drm_helper_probe_single_connector_modes,
        .detect = imx_pd_connector_detect,
        .destroy = imx_drm_connector_destroy,
+       .reset = drm_atomic_helper_connector_reset,
+       .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };

 static const struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = 
{
-- 
2.7.4

Reply via email to