drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
authorSean Paul <seanpaul@chromium.org>
Tue, 11 Jun 2019 16:08:18 +0000 (12:08 -0400)
committerSean Paul <seanpaul@chromium.org>
Thu, 13 Jun 2019 18:30:07 +0000 (14:30 -0400)
Everyone who implements connector_helper_funcs->atomic_check reaches
into the connector state to get the atomic state. Instead of continuing
this pattern, change the callback signature to just give atomic state
and let the driver determine what it does and does not need from it.

Eventually all atomic functions should do this, but that's just too much
busy work for me.

Changes in v3:
- Added to the set
Changes in v4:
- None
Changes in v5:
- intel_digital_connector_atomic_check declaration moved to i915_atomic.h

Link to v3: https://patchwork.freedesktop.org/patch/msgid/20190502194956.218441-5-sean@poorly.run
Link to v4: https://patchwork.freedesktop.org/patch/msgid/20190508160920.144739-5-sean@poorly.run

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Eric Anholt <eric@anholt.net>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [for rcar lvds]
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190611160844.257498-5-sean@poorly.run
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/i915/intel_atomic.c
drivers/gpu/drm/i915/intel_atomic.h
drivers/gpu/drm/i915/intel_dp_mst.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/i915/intel_tv.c
drivers/gpu/drm/nouveau/dispnv50/disp.c
drivers/gpu/drm/rcar-du/rcar_lvds.c
drivers/gpu/drm/vc4/vc4_txp.c
include/drm/drm_modeset_helper_vtables.h

index 2133f625391768f8c1b6cc3909c92bb477e8bc81..e58be69960692e4afa218cb284d2eeac8250fede 100644 (file)
@@ -686,7 +686,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
                }
 
                if (funcs->atomic_check)
-                       ret = funcs->atomic_check(connector, new_connector_state);
+                       ret = funcs->atomic_check(connector, state);
                if (ret)
                        return ret;
 
@@ -728,7 +728,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
                        continue;
 
                if (funcs->atomic_check)
-                       ret = funcs->atomic_check(connector, new_connector_state);
+                       ret = funcs->atomic_check(connector, state);
                if (ret)
                        return ret;
        }
index 58b8049649a0f929b9e5d90637d3b243bcd74a10..ab40448a19d564eb5c8d20d85dd810d55854ce6f 100644 (file)
@@ -106,12 +106,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,
 }
 
 int intel_digital_connector_atomic_check(struct drm_connector *conn,
-                                        struct drm_connector_state *new_state)
+                                        struct drm_atomic_state *state)
 {
+       struct drm_connector_state *new_state =
+               drm_atomic_get_new_connector_state(state, conn);
        struct intel_digital_connector_state *new_conn_state =
                to_intel_digital_connector_state(new_state);
        struct drm_connector_state *old_state =
-               drm_atomic_get_old_connector_state(new_state->state, conn);
+               drm_atomic_get_old_connector_state(state, conn);
        struct intel_digital_connector_state *old_conn_state =
                to_intel_digital_connector_state(old_state);
        struct drm_crtc_state *crtc_state;
@@ -121,7 +123,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,
        if (!new_state->crtc)
                return 0;
 
-       crtc_state = drm_atomic_get_new_crtc_state(new_state->state, new_state->crtc);
+       crtc_state = drm_atomic_get_new_crtc_state(state, new_state->crtc);
 
        /*
         * These properties are handled by fastset, and might not end
index 1c8507da1a690ba7255622a88a4cdf7c9e53d621..58065d3161a34190b0b7602b69eb3643462789f9 100644 (file)
@@ -28,7 +28,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,
                                                struct drm_property *property,
                                                u64 val);
 int intel_digital_connector_atomic_check(struct drm_connector *conn,
-                                        struct drm_connector_state *new_state);
+                                        struct drm_atomic_state *state);
 struct drm_connector_state *
 intel_digital_connector_duplicate_state(struct drm_connector *connector);
 
index 0caf645fbbb841b38a63e05c73ea198e4ed70d22..60652ebbdf610a1cfda5228147265c77fe30f438 100644 (file)
@@ -151,9 +151,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,
 
 static int
 intel_dp_mst_atomic_check(struct drm_connector *connector,
-                         struct drm_connector_state *new_conn_state)
+                         struct drm_atomic_state *state)
 {
-       struct drm_atomic_state *state = new_conn_state->state;
+       struct drm_connector_state *new_conn_state =
+               drm_atomic_get_new_connector_state(state, connector);
        struct drm_connector_state *old_conn_state =
                drm_atomic_get_old_connector_state(state, connector);
        struct intel_connector *intel_connector =
@@ -163,7 +164,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,
        struct drm_dp_mst_topology_mgr *mgr;
        int ret;
 
-       ret = intel_digital_connector_atomic_check(connector, new_conn_state);
+       ret = intel_digital_connector_atomic_check(connector, state);
        if (ret)
                return ret;
 
index 6c98b35790db5e3841edf753b3267938e95d4ffc..368b99f6f7fbd2bff510a2bb93f0fb32184c7cc4 100644 (file)
@@ -2353,9 +2353,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = {
 };
 
 static int intel_sdvo_atomic_check(struct drm_connector *conn,
-                                  struct drm_connector_state *new_conn_state)
+                                  struct drm_atomic_state *state)
 {
-       struct drm_atomic_state *state = new_conn_state->state;
+       struct drm_connector_state *new_conn_state =
+               drm_atomic_get_new_connector_state(state, conn);
        struct drm_connector_state *old_conn_state =
                drm_atomic_get_old_connector_state(state, conn);
        struct intel_sdvo_connector_state *old_state =
@@ -2367,13 +2368,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn,
            (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) ||
             memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {
                struct drm_crtc_state *crtc_state =
-                       drm_atomic_get_new_crtc_state(new_conn_state->state,
+                       drm_atomic_get_new_crtc_state(state,
                                                      new_conn_state->crtc);
 
                crtc_state->connectors_changed = true;
        }
 
-       return intel_digital_connector_atomic_check(conn, new_conn_state);
+       return intel_digital_connector_atomic_check(conn, state);
 }
 
 static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {
index 5dc594eafaf2f1c98d768d0d083c9b86e591d92a..0a95df6c6a57f52401facfbaf88623780963fd8b 100644 (file)
@@ -1821,16 +1821,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = {
 };
 
 static int intel_tv_atomic_check(struct drm_connector *connector,
-                                struct drm_connector_state *new_state)
+                                struct drm_atomic_state *state)
 {
+       struct drm_connector_state *new_state;
        struct drm_crtc_state *new_crtc_state;
        struct drm_connector_state *old_state;
 
+       new_state = drm_atomic_get_new_connector_state(state, connector);
        if (!new_state->crtc)
                return 0;
 
-       old_state = drm_atomic_get_old_connector_state(new_state->state, connector);
-       new_crtc_state = drm_atomic_get_new_crtc_state(new_state->state, new_state->crtc);
+       old_state = drm_atomic_get_old_connector_state(state, connector);
+       new_crtc_state = drm_atomic_get_new_crtc_state(state, new_state->crtc);
 
        if (old_state->tv.mode != new_state->tv.mode ||
            old_state->tv.margins.left != new_state->tv.margins.left ||
index 4b1650f51955d14022cb1fb4b068b3eb00dad0b7..7ba373f493b298ea90326321df28daab7de21ce2 100644 (file)
@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)
 
 static int
 nv50_mstc_atomic_check(struct drm_connector *connector,
-                      struct drm_connector_state *new_conn_state)
+                      struct drm_atomic_state *state)
 {
-       struct drm_atomic_state *state = new_conn_state->state;
        struct nv50_mstc *mstc = nv50_mstc(connector);
        struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr;
+       struct drm_connector_state *new_conn_state =
+               drm_atomic_get_new_connector_state(state, connector);
        struct drm_connector_state *old_conn_state =
                drm_atomic_get_old_connector_state(state, connector);
        struct drm_crtc_state *crtc_state;
index 620b51aab291f9ea646b2517a1f243e7375f4b8b..5b81ba2a7f272b1368a23534813a929f11386a28 100644 (file)
@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector)
 }
 
 static int rcar_lvds_connector_atomic_check(struct drm_connector *connector,
-                                           struct drm_connector_state *state)
+                                           struct drm_atomic_state *state)
 {
        struct rcar_lvds *lvds = connector_to_rcar_lvds(connector);
        const struct drm_display_mode *panel_mode;
+       struct drm_connector_state *conn_state;
        struct drm_crtc_state *crtc_state;
 
-       if (!state->crtc)
+       conn_state = drm_atomic_get_new_connector_state(state, connector);
+       if (!conn_state->crtc)
                return 0;
 
        if (list_empty(&connector->modes)) {
@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector,
                                      struct drm_display_mode, head);
 
        /* We're not allowed to modify the resolution. */
-       crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
-       if (IS_ERR(crtc_state))
-               return PTR_ERR(crtc_state);
+       crtc_state = drm_atomic_get_crtc_state(state, conn_state->crtc);
+       if (!crtc_state)
+               return -EINVAL;
 
        if (crtc_state->mode.hdisplay != panel_mode->hdisplay ||
            crtc_state->mode.vdisplay != panel_mode->vdisplay)
index c8b89a78f9f4f9b7d4327a4e6bd2307938dedb95..96f91c1b4b6e655ac542f807a04671175172a031 100644 (file)
@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = {
 };
 
 static int vc4_txp_connector_atomic_check(struct drm_connector *conn,
-                                       struct drm_connector_state *conn_state)
+                                         struct drm_atomic_state *state)
 {
+       struct drm_connector_state *conn_state;
        struct drm_crtc_state *crtc_state;
        struct drm_framebuffer *fb;
        int i;
 
+       conn_state = drm_atomic_get_new_connector_state(state, conn);
        if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
                return 0;
 
-       crtc_state = drm_atomic_get_new_crtc_state(conn_state->state,
-                                                  conn_state->crtc);
+       crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
 
        fb = conn_state->writeback_job->fb;
        if (fb->width != crtc_state->mode.hdisplay ||
index 13f0e3ca0a29e512110cfee0da4f70187f7971b5..f36be43bd052c7d4cf313cde6fb14b10c45411ba 100644 (file)
@@ -1028,7 +1028,7 @@ struct drm_connector_helper_funcs {
         * deadlock.
         */
        int (*atomic_check)(struct drm_connector *connector,
-                           struct drm_connector_state *state);
+                           struct drm_atomic_state *state);
 
        /**
         * @atomic_commit: