drm/i915: Restructure intel_bios_port_aux_ch()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 16 Feb 2023 23:13:09 +0000 (01:13 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 17 Feb 2023 21:15:19 +0000 (23:15 +0200)
Restructure intel_bios_port_aux_ch() to resemble the ddc_pin
counterpart, where the intel_bios.c stuff only deals with the
child device definition, and the platform default will come from
elsewhere.

This requires the introduction of AUX_CH_NONE as the value 0
is already taken to mean AUX_CH_A.

v2: Sort includes alphabetically (Ankit)
vCould we ask them to do a BIOS fix for all of them so that
we wouldn't keep getting these bug reports for each model
separately?

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230216231312.32664-1-ville.syrjala@linux.intel.com
Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
drivers/gpu/drm/i915/display/g4x_dp.c
drivers/gpu/drm/i915/display/g4x_hdmi.c
drivers/gpu/drm/i915/display/intel_bios.c
drivers/gpu/drm/i915/display/intel_bios.h
drivers/gpu/drm/i915/display/intel_ddi.c
drivers/gpu/drm/i915/display/intel_display.h
drivers/gpu/drm/i915/display/intel_dp_aux.c
drivers/gpu/drm/i915/display/intel_dp_aux.h

index 6ccbc22..a50ad0f 100644 (file)
@@ -17,6 +17,7 @@
 #include "intel_display_power.h"
 #include "intel_display_types.h"
 #include "intel_dp.h"
+#include "intel_dp_aux.h"
 #include "intel_dp_link_training.h"
 #include "intel_dpio_phy.h"
 #include "intel_fifo_underrun.h"
@@ -1397,7 +1398,7 @@ bool g4x_dp_init(struct drm_i915_private *dev_priv,
        if (port != PORT_A)
                intel_infoframe_init(dig_port);
 
-       dig_port->aux_ch = intel_bios_port_aux_ch(dev_priv, devdata, port);
+       dig_port->aux_ch = intel_dp_aux_ch(intel_encoder);
        if (!intel_dp_init_connector(dig_port, intel_connector))
                goto err_init_connector;
 
index e965c55..448ea26 100644 (file)
@@ -13,6 +13,7 @@
 #include "intel_de.h"
 #include "intel_display_power.h"
 #include "intel_display_types.h"
+#include "intel_dp_aux.h"
 #include "intel_dpio_phy.h"
 #include "intel_fifo_underrun.h"
 #include "intel_hdmi.h"
@@ -639,6 +640,6 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv,
 
        intel_infoframe_init(dig_port);
 
-       dig_port->aux_ch = intel_bios_port_aux_ch(dev_priv, devdata, port);
+       dig_port->aux_ch = intel_dp_aux_ch(intel_encoder);
        intel_hdmi_init_connector(dig_port, intel_connector);
 }
index 8cf2392..f35ef36 100644 (file)
@@ -3572,21 +3572,10 @@ bool intel_bios_get_dsc_params(struct intel_encoder *encoder,
        return false;
 }
 
-enum aux_ch intel_bios_port_aux_ch(struct drm_i915_private *i915,
-                                  const struct intel_bios_encoder_data *devdata,
-                                  enum port port)
+static enum aux_ch map_aux_ch(struct drm_i915_private *i915, u8 aux_channel)
 {
        enum aux_ch aux_ch;
 
-       if (!devdata || !devdata->child.aux_channel) {
-               aux_ch = (enum aux_ch)port;
-
-               drm_dbg_kms(&i915->drm,
-                           "using AUX %c for port %c (platform default)\n",
-                           aux_ch_name(aux_ch), port_name(port));
-               return aux_ch;
-       }
-
        /*
         * RKL/DG1 VBT uses PHY based mapping. Combo PHYs A,B,C,D
         * map to DDI A,B,TC1,TC2 respectively.
@@ -3594,7 +3583,7 @@ enum aux_ch intel_bios_port_aux_ch(struct drm_i915_private *i915,
         * ADL-S VBT uses PHY based mapping. Combo PHYs A,B,C,D,E
         * map to DDI A,TC1,TC2,TC3,TC4 respectively.
         */
-       switch (devdata->child.aux_channel) {
+       switch (aux_channel) {
        case DP_AUX_A:
                aux_ch = AUX_CH_A;
                break;
@@ -3655,17 +3644,21 @@ enum aux_ch intel_bios_port_aux_ch(struct drm_i915_private *i915,
                        aux_ch = AUX_CH_I;
                break;
        default:
-               MISSING_CASE(devdata->child.aux_channel);
+               MISSING_CASE(aux_channel);
                aux_ch = AUX_CH_A;
                break;
        }
 
-       drm_dbg_kms(&i915->drm, "using AUX %c for port %c (VBT)\n",
-                   aux_ch_name(aux_ch), port_name(port));
-
        return aux_ch;
 }
 
+enum aux_ch intel_bios_dp_aux_ch(const struct intel_bios_encoder_data *devdata)
+{
+       if (!devdata || !devdata->child.aux_channel)
+               return AUX_CH_NONE;
+
+       return map_aux_ch(devdata->i915, devdata->child.aux_channel);
+}
 
 int intel_bios_dp_boost_level(const struct intel_bios_encoder_data *devdata)
 {
index 49a9e8d..8a0730c 100644 (file)
@@ -38,6 +38,7 @@ struct intel_bios_encoder_data;
 struct intel_crtc_state;
 struct intel_encoder;
 struct intel_panel;
+enum aux_ch;
 enum port;
 
 enum intel_backlight_type {
@@ -248,9 +249,6 @@ bool intel_bios_is_port_present(struct drm_i915_private *dev_priv, enum port por
 bool intel_bios_is_port_edp(struct drm_i915_private *dev_priv, enum port port);
 bool intel_bios_is_port_dp_dual_mode(struct drm_i915_private *dev_priv, enum port port);
 bool intel_bios_is_dsi_present(struct drm_i915_private *dev_priv, enum port *port);
-enum aux_ch intel_bios_port_aux_ch(struct drm_i915_private *i915,
-                                  const struct intel_bios_encoder_data *devdata,
-                                  enum port port);
 bool intel_bios_get_dsc_params(struct intel_encoder *encoder,
                               struct intel_crtc_state *crtc_state,
                               int dsc_max_bpc);
@@ -269,6 +267,7 @@ bool intel_bios_encoder_supports_tbt(const struct intel_bios_encoder_data *devda
 bool intel_bios_encoder_is_lspcon(const struct intel_bios_encoder_data *devdata);
 bool intel_bios_encoder_lane_reversal(const struct intel_bios_encoder_data *devdata);
 bool intel_bios_encoder_hpd_invert(const struct intel_bios_encoder_data *devdata);
+enum aux_ch intel_bios_dp_aux_ch(const struct intel_bios_encoder_data *devdata);
 int intel_bios_dp_boost_level(const struct intel_bios_encoder_data *devdata);
 int intel_bios_dp_max_lane_count(const struct intel_bios_encoder_data *devdata);
 int intel_bios_dp_max_link_rate(const struct intel_bios_encoder_data *devdata);
index e917d91..3f5a81e 100644 (file)
@@ -47,6 +47,7 @@
 #include "intel_dkl_phy.h"
 #include "intel_dkl_phy_regs.h"
 #include "intel_dp.h"
+#include "intel_dp_aux.h"
 #include "intel_dp_link_training.h"
 #include "intel_dp_mst.h"
 #include "intel_dpio_phy.h"
@@ -4486,7 +4487,7 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
 
        dig_port->dp.output_reg = INVALID_MMIO_REG;
        dig_port->max_lanes = intel_ddi_max_lanes(dig_port);
-       dig_port->aux_ch = intel_bios_port_aux_ch(dev_priv, devdata, port);
+       dig_port->aux_ch = intel_dp_aux_ch(encoder);
 
        if (intel_phy_is_tc(dev_priv, phy)) {
                bool is_legacy =
index ed852f6..50285fb 100644 (file)
@@ -172,6 +172,8 @@ enum tc_port_mode {
 };
 
 enum aux_ch {
+       AUX_CH_NONE = -1,
+
        AUX_CH_A,
        AUX_CH_B,
        AUX_CH_C,
index 5a176bf..c4e72c1 100644 (file)
@@ -6,6 +6,7 @@
 #include "i915_drv.h"
 #include "i915_reg.h"
 #include "i915_trace.h"
+#include "intel_bios.h"
 #include "intel_de.h"
 #include "intel_display_types.h"
 #include "intel_dp_aux.h"
@@ -737,3 +738,25 @@ void intel_dp_aux_init(struct intel_dp *intel_dp)
        intel_dp->aux.transfer = intel_dp_aux_transfer;
        cpu_latency_qos_add_request(&intel_dp->pm_qos, PM_QOS_DEFAULT_VALUE);
 }
+
+enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder)
+{
+       struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+       enum port port = encoder->port;
+       enum aux_ch aux_ch;
+
+       aux_ch = intel_bios_dp_aux_ch(encoder->devdata);
+       if (aux_ch != AUX_CH_NONE) {
+               drm_dbg_kms(&i915->drm, "using AUX %c for port %c (VBT)\n",
+                           aux_ch_name(aux_ch), port_name(port));
+               return aux_ch;
+       }
+
+       aux_ch = (enum aux_ch)port;
+
+       drm_dbg_kms(&i915->drm,
+                   "using AUX %c for port %c (platform default)\n",
+                   aux_ch_name(aux_ch), port_name(port));
+
+       return aux_ch;
+}
index 7385775..138e340 100644 (file)
@@ -6,9 +6,13 @@
 #ifndef __INTEL_DP_AUX_H__
 #define __INTEL_DP_AUX_H__
 
+enum aux_ch;
 struct intel_dp;
+struct intel_encoder;
 
 void intel_dp_aux_fini(struct intel_dp *intel_dp);
 void intel_dp_aux_init(struct intel_dp *intel_dp);
 
+enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder);
+
 #endif /* __INTEL_DP_AUX_H__ */