drm/i915: Replace intel_bios_is_lspcon_present() with intel_bios_encoder_is_lspcon()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 8 Feb 2023 01:55:01 +0000 (03:55 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 14 Feb 2023 12:03:57 +0000 (14:03 +0200)
We always have encoder->devdata available on the platforms
that can have LSPCON. So let's start looking there instead
of digging it out from vbt.ports[].

And let's rename the function to fit the common pattern
for these things.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230208015508.24824-4-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
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_dp.c
drivers/gpu/drm/i915/display/intel_hdmi.c
drivers/gpu/drm/i915/display/intel_lspcon.c

index 201315985f83c576607ffa03dead94fde613ea34..40dd143fdd1fc16cabc38c01d250266729509905 100644 (file)
@@ -2598,6 +2598,12 @@ intel_bios_encoder_supports_dsi(const struct intel_bios_encoder_data *devdata)
        return devdata->child.device_type & DEVICE_TYPE_MIPI_OUTPUT;
 }
 
+bool
+intel_bios_encoder_is_lspcon(const struct intel_bios_encoder_data *devdata)
+{
+       return devdata && HAS_LSPCON(devdata->i915) && devdata->child.lspcon;
+}
+
 static int _intel_bios_hdmi_level_shift(const struct intel_bios_encoder_data *devdata)
 {
        if (!devdata || devdata->i915->display.vbt.version < 158)
@@ -2664,7 +2670,7 @@ static void print_ddi_port(const struct intel_bios_encoder_data *devdata,
        drm_dbg_kms(&i915->drm,
                    "Port %c VBT info: CRT:%d DVI:%d HDMI:%d DP:%d eDP:%d DSI:%d LSPCON:%d USB-Type-C:%d TBT:%d DSC:%d\n",
                    port_name(port), is_crt, is_dvi, is_hdmi, is_dp, is_edp, is_dsi,
-                   HAS_LSPCON(i915) && child->lspcon,
+                   intel_bios_encoder_is_lspcon(devdata),
                    supports_typec_usb, supports_tbt,
                    devdata->dsc != NULL);
 
@@ -3588,22 +3594,6 @@ intel_bios_is_port_hpd_inverted(const struct drm_i915_private *i915,
        return devdata && devdata->child.hpd_invert;
 }
 
-/**
- * intel_bios_is_lspcon_present - if LSPCON is attached on %port
- * @i915:      i915 device instance
- * @port:      port to check
- *
- * Return true if LSPCON is present on this port
- */
-bool
-intel_bios_is_lspcon_present(const struct drm_i915_private *i915,
-                            enum port port)
-{
-       const struct intel_bios_encoder_data *devdata = i915->display.vbt.ports[port];
-
-       return HAS_LSPCON(i915) && devdata && devdata->child.lspcon;
-}
-
 /**
  * intel_bios_is_lane_reversal_needed - if lane reversal needed on port
  * @i915:       i915 device instance
index d221f784aa88d207d1820f4dac285bf7bcd6e757..ad3edfe6ec3a3de241a84f2ef55e915eec3f8a14 100644 (file)
@@ -250,8 +250,6 @@ bool intel_bios_is_port_dp_dual_mode(struct drm_i915_private *dev_priv, enum por
 bool intel_bios_is_dsi_present(struct drm_i915_private *dev_priv, enum port *port);
 bool intel_bios_is_port_hpd_inverted(const struct drm_i915_private *i915,
                                     enum port port);
-bool intel_bios_is_lspcon_present(const struct drm_i915_private *i915,
-                                 enum port port);
 bool intel_bios_is_lane_reversal_needed(const struct drm_i915_private *i915,
                                        enum port port);
 enum aux_ch intel_bios_port_aux_ch(struct drm_i915_private *dev_priv, enum port port);
@@ -274,6 +272,7 @@ bool intel_bios_encoder_supports_hdmi(const struct intel_bios_encoder_data *devd
 bool intel_bios_encoder_supports_dp(const struct intel_bios_encoder_data *devdata);
 bool intel_bios_encoder_supports_typec_usb(const struct intel_bios_encoder_data *devdata);
 bool intel_bios_encoder_supports_tbt(const struct intel_bios_encoder_data *devdata);
+bool intel_bios_encoder_is_lspcon(const struct intel_bios_encoder_data *devdata);
 int intel_bios_encoder_dp_boost_level(const struct intel_bios_encoder_data *devdata);
 int intel_bios_encoder_hdmi_boost_level(const struct intel_bios_encoder_data *devdata);
 
index 254559abedfba554e834860ae6303f95c5162444..2c64d5f4b8f3bf6d5956ec8de86010ea1fd1c626 100644 (file)
@@ -4305,7 +4305,7 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
                intel_bios_encoder_supports_hdmi(devdata);
        init_dp = intel_bios_encoder_supports_dp(devdata);
 
-       if (intel_bios_is_lspcon_present(dev_priv, port)) {
+       if (intel_bios_encoder_is_lspcon(devdata)) {
                /*
                 * Lspcon device needs to be driven with DP connector
                 * with special detection sequence. So make sure DP
index bc7bb4eb4b50b67d80fed6bcf9a61ce31c719293..15a1157f53715168f537a2a6f796ca210914268b 100644 (file)
@@ -4863,7 +4863,7 @@ intel_dp_connector_register(struct drm_connector *connector)
        if (!ret)
                drm_dp_cec_register_connector(&intel_dp->aux, connector);
 
-       if (!intel_bios_is_lspcon_present(i915, dig_port->base.port))
+       if (!intel_bios_encoder_is_lspcon(dig_port->base.devdata))
                return ret;
 
        /*
@@ -5158,9 +5158,12 @@ bool intel_dp_is_port_edp(struct drm_i915_private *dev_priv, enum port port)
 }
 
 static bool
-has_gamut_metadata_dip(struct drm_i915_private *i915, enum port port)
+has_gamut_metadata_dip(struct intel_encoder *encoder)
 {
-       if (intel_bios_is_lspcon_present(i915, port))
+       struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+       enum port port = encoder->port;
+
+       if (intel_bios_encoder_is_lspcon(encoder->devdata))
                return false;
 
        if (DISPLAY_VER(i915) >= 11)
@@ -5195,14 +5198,14 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
                drm_connector_attach_max_bpc_property(connector, 6, 12);
 
        /* Register HDMI colorspace for case of lspcon */
-       if (intel_bios_is_lspcon_present(dev_priv, port)) {
+       if (intel_bios_encoder_is_lspcon(dp_to_dig_port(intel_dp)->base.devdata)) {
                drm_connector_attach_content_type_property(connector);
                intel_attach_hdmi_colorspace_property(connector);
        } else {
                intel_attach_dp_colorspace_property(connector);
        }
 
-       if (has_gamut_metadata_dip(dev_priv, port))
+       if (has_gamut_metadata_dip(&dp_to_dig_port(intel_dp)->base))
                drm_connector_attach_hdr_output_metadata_property(connector);
 
        if (HAS_VRR(dev_priv))
index 7468b570a72a833695c82acc2218ab39f8703781..619865b45eca251c2e0adc2329c3efa4b0a7c1c1 100644 (file)
@@ -2923,7 +2923,7 @@ void intel_infoframe_init(struct intel_digital_port *dig_port)
                dig_port->set_infoframes = g4x_set_infoframes;
                dig_port->infoframes_enabled = g4x_infoframes_enabled;
        } else if (HAS_DDI(dev_priv)) {
-               if (intel_bios_is_lspcon_present(dev_priv, dig_port->base.port)) {
+               if (intel_bios_encoder_is_lspcon(dig_port->base.devdata)) {
                        dig_port->write_infoframe = lspcon_write_infoframe;
                        dig_port->read_infoframe = lspcon_read_infoframe;
                        dig_port->set_infoframes = lspcon_set_infoframes;
index 9ff1c0b223ad427d4740e93eef060c12b169b741..bb3b5355a0d9a91c01666e326fe96be7f907d75a 100644 (file)
@@ -689,7 +689,7 @@ void lspcon_resume(struct intel_digital_port *dig_port)
        struct drm_i915_private *i915 = to_i915(dev);
        enum drm_lspcon_mode expected_mode;
 
-       if (!intel_bios_is_lspcon_present(i915, dig_port->base.port))
+       if (!intel_bios_encoder_is_lspcon(dig_port->base.devdata))
                return;
 
        if (!lspcon->active) {