The vc4 HDMI connector reset implementation creates a pristine state,
initializes the HDMI state, and sets the TV margins. It does not
perform any hardware reset.

Since this is equivalent to what atomic_create_state expects, convert
the reset function to an atomic_create_state hook that returns the
initialized state.

Reviewed-by: Maíra Canal <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
Cc: "Maíra Canal" <[email protected]>
Cc: Dave Stevenson <[email protected]>
Cc: Raspberry Pi Kernel Maintenance <[email protected]>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index e14cbe4b5f15..82618f43b0a5 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -505,10 +505,19 @@ static int vc4_hdmi_connector_atomic_check(struct 
drm_connector *connector,
 }
 
-static void vc4_hdmi_connector_reset(struct drm_connector *connector)
+static struct drm_connector_state *
+vc4_hdmi_connector_create_state(struct drm_connector *connector)
 {
-       drm_atomic_helper_connector_reset(connector);
-       __drm_atomic_helper_connector_hdmi_state_init(connector->state, 
connector);
-       drm_atomic_helper_connector_tv_margins_state_init(connector->state,
+       struct drm_connector_state *connector_state;
+
+       connector_state = drm_atomic_helper_connector_create_state(connector);
+       if (IS_ERR(connector_state))
+               return connector_state;
+
+       __drm_atomic_helper_connector_hdmi_state_init(connector_state, 
connector);
+
+       drm_atomic_helper_connector_tv_margins_state_init(connector_state,
                                                          connector);
+
+       return connector_state;
 }
 
@@ -517,5 +526,5 @@ static const struct drm_connector_funcs 
vc4_hdmi_connector_funcs = {
        .force = drm_atomic_helper_connector_hdmi_force,
        .fill_modes = drm_helper_probe_single_connector_modes,
-       .reset = vc4_hdmi_connector_reset,
+       .atomic_create_state = vc4_hdmi_connector_create_state,
        .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
@@ -568,6 +577,13 @@ static int vc4_hdmi_connector_init(struct drm_device *dev,
         * Allocate some default initial connector state with our reset helper.
         */
-       if (connector->funcs->reset)
-               connector->funcs->reset(connector);
+       if (!connector->state) {
+               struct drm_connector_state *conn_state;
+
+               conn_state = vc4_hdmi_connector_create_state(connector);
+               if (IS_ERR(conn_state))
+                       return PTR_ERR(conn_state);
+
+               connector->state = conn_state;
+       }
 
        /* Create and attach TV margin props to this connector. */

-- 
2.55.0

Reply via email to