]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/i915/dp_tunnel: Split update_tunnel_state()
authorImre Deak <imre.deak@intel.com>
Thu, 19 Feb 2026 18:28:21 +0000 (20:28 +0200)
committerImre Deak <imre.deak@intel.com>
Wed, 25 Feb 2026 13:30:16 +0000 (15:30 +0200)
Split update_tunnel_state() into two helpers: one that updates the
tunnel state, and another that detects whether the tunnel bandwidth
has changed.

This prepares for a follow-up change that needs to compare the current
bandwidth against the value from before the DP tunnel was detected and
bandwidth allocation mode was enabled.

While at it, document the return value of update_tunnel_state().

Reviewed-by: Arun R Murthy <arun.r.murthy@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20260219182823.926702-4-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_dp_tunnel.c

index b95fdafa3d36c68906c5ff90b178f40f00a494d7..b3b3c064ac2aefbd78e46a4692663132256619b6 100644 (file)
@@ -62,16 +62,12 @@ static int get_current_link_bw(struct intel_dp *intel_dp)
        return intel_dp_max_link_data_rate(intel_dp, rate, lane_count);
 }
 
-static int update_tunnel_state(struct intel_dp *intel_dp)
+static int __update_tunnel_state(struct intel_dp *intel_dp)
 {
        struct intel_display *display = to_intel_display(intel_dp);
        struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
-       int old_bw;
-       int new_bw;
        int ret;
 
-       old_bw = get_current_link_bw(intel_dp);
-
        ret = drm_dp_tunnel_update_state(intel_dp->tunnel);
        if (ret < 0) {
                drm_dbg_kms(display->drm,
@@ -89,11 +85,20 @@ static int update_tunnel_state(struct intel_dp *intel_dp)
 
        intel_dp_update_sink_caps(intel_dp);
 
+       return 0;
+}
+
+static bool has_tunnel_bw_changed(struct intel_dp *intel_dp, int old_bw)
+{
+       struct intel_display *display = to_intel_display(intel_dp);
+       struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
+       int new_bw;
+
        new_bw = get_current_link_bw(intel_dp);
 
        /* Suppress the notification if the mode list can't change due to bw. */
        if (old_bw == new_bw)
-               return 0;
+               return false;
 
        drm_dbg_kms(display->drm,
                    "[DPTUN %s][ENCODER:%d:%s] Notify users about BW change: %d -> %d\n",
@@ -101,7 +106,29 @@ static int update_tunnel_state(struct intel_dp *intel_dp)
                    encoder->base.base.id, encoder->base.name,
                    kbytes_to_mbits(old_bw), kbytes_to_mbits(new_bw));
 
-       return 1;
+       return true;
+}
+
+/*
+ * Returns:
+ * - 0 in case of success - if there wasn't any change in the tunnel state
+ *   requiring a user notification
+ * - 1 in case of success - if there was a change in the tunnel state
+ *   requiring a user notification
+ * - Negative error code if updating the tunnel state failed
+ */
+static int update_tunnel_state(struct intel_dp *intel_dp)
+{
+       int old_bw;
+       int err;
+
+       old_bw = get_current_link_bw(intel_dp);
+
+       err = __update_tunnel_state(intel_dp);
+       if (err)
+               return err;
+
+       return has_tunnel_bw_changed(intel_dp, old_bw) ? 1 : 0;
 }
 
 /*