Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Cc: jani.nikula@linux.intel.com, suraj.kandpal@intel.com
Subject: [PATCH 5/5] drm/i915/cx0_phy: Use HDMI PLL algorithm for C10 PHY
Date: Mon, 20 Jan 2025 09:51:21 +0530	[thread overview]
Message-ID: <20250120042122.1029481-6-ankit.k.nautiyal@intel.com> (raw)
In-Reply-To: <20250120042122.1029481-1-ankit.k.nautiyal@intel.com>

Try HDMI PLL alogorithm for C10 PHY, if there are no pre-computed tables.
Also get rid of the helpers to get rate for HDMI for C10/20 PHY, as we no
longer depend only on pre-computed tables.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_cx0_phy.c | 49 +++++---------------
 drivers/gpu/drm/i915/display/intel_cx0_phy.h |  1 -
 drivers/gpu/drm/i915/display/intel_hdmi.c    | 10 ----
 3 files changed, 11 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cx0_phy.c b/drivers/gpu/drm/i915/display/intel_cx0_phy.c
index 058013c74991..1c7d9467e81c 100644
--- a/drivers/gpu/drm/i915/display/intel_cx0_phy.c
+++ b/drivers/gpu/drm/i915/display/intel_cx0_phy.c
@@ -18,6 +18,7 @@
 #include "intel_hdmi.h"
 #include "intel_panel.h"
 #include "intel_psr.h"
+#include "intel_snps_hdmi_pll.h"
 #include "intel_tc.h"
 
 #define MB_WRITE_COMMITTED      true
@@ -2003,19 +2004,6 @@ static const struct intel_c20pll_state * const mtl_c20_hdmi_tables[] = {
 	NULL,
 };
 
-static int intel_c10_phy_check_hdmi_link_rate(int clock)
-{
-	const struct intel_c10pll_state * const *tables = mtl_c10_hdmi_tables;
-	int i;
-
-	for (i = 0; tables[i]; i++) {
-		if (clock == tables[i]->clock)
-			return MODE_OK;
-	}
-
-	return MODE_CLOCK_RANGE;
-}
-
 static const struct intel_c10pll_state * const *
 intel_c10pll_tables_get(struct intel_crtc_state *crtc_state,
 			struct intel_encoder *encoder)
@@ -2077,6 +2065,16 @@ static int intel_c10pll_calc_state(struct intel_crtc_state *crtc_state,
 		}
 	}
 
+	/* For HDMI PLLs try SNPS PHY algorithm, if there are no precomputed tables */
+	if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		intel_snps_hdmi_pll_compute_c10pll(&crtc_state->dpll_hw_state.cx0pll.c10,
+						   crtc_state->port_clock);
+		intel_c10pll_update_pll(crtc_state, encoder);
+		crtc_state->dpll_hw_state.cx0pll.use_c10 = true;
+
+		return 0;
+	}
+
 	return -EINVAL;
 }
 
@@ -2281,31 +2279,6 @@ static int intel_c20_compute_hdmi_tmds_pll(struct intel_crtc_state *crtc_state)
 	return 0;
 }
 
-static int intel_c20_phy_check_hdmi_link_rate(int clock)
-{
-	const struct intel_c20pll_state * const *tables = mtl_c20_hdmi_tables;
-	int i;
-
-	for (i = 0; tables[i]; i++) {
-		if (clock == tables[i]->clock)
-			return MODE_OK;
-	}
-
-	if (clock >= 25175 && clock <= 594000)
-		return MODE_OK;
-
-	return MODE_CLOCK_RANGE;
-}
-
-int intel_cx0_phy_check_hdmi_link_rate(struct intel_hdmi *hdmi, int clock)
-{
-	struct intel_digital_port *dig_port = hdmi_to_dig_port(hdmi);
-
-	if (intel_encoder_is_c10phy(&dig_port->base))
-		return intel_c10_phy_check_hdmi_link_rate(clock);
-	return intel_c20_phy_check_hdmi_link_rate(clock);
-}
-
 static const struct intel_c20pll_state * const *
 intel_c20_pll_tables_get(struct intel_crtc_state *crtc_state,
 			 struct intel_encoder *encoder)
diff --git a/drivers/gpu/drm/i915/display/intel_cx0_phy.h b/drivers/gpu/drm/i915/display/intel_cx0_phy.h
index 711168882684..573fa7d3e88f 100644
--- a/drivers/gpu/drm/i915/display/intel_cx0_phy.h
+++ b/drivers/gpu/drm/i915/display/intel_cx0_phy.h
@@ -41,7 +41,6 @@ bool intel_cx0pll_compare_hw_state(const struct intel_cx0pll_state *a,
 				   const struct intel_cx0pll_state *b);
 void intel_cx0_phy_set_signal_levels(struct intel_encoder *encoder,
 				     const struct intel_crtc_state *crtc_state);
-int intel_cx0_phy_check_hdmi_link_rate(struct intel_hdmi *hdmi, int clock);
 int intel_mtl_tbt_calc_port_clock(struct intel_encoder *encoder);
 
 #endif /* __INTEL_CX0_PHY_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index 9a4bc3c4611d..3b51238022f4 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -1909,16 +1909,6 @@ hdmi_port_clock_valid(struct intel_hdmi *hdmi,
 	if (intel_encoder_is_tc(encoder) && clock > 500000 && clock < 532800)
 		return MODE_CLOCK_RANGE;
 
-	/*
-	 * SNPS PHYs' MPLLB table-based programming can only handle a fixed
-	 * set of link rates.
-	 *
-	 * FIXME: We will hopefully get an algorithmic way of programming
-	 * the MPLLB for HDMI in the future.
-	 */
-	if (DISPLAY_VER(display) >= 14)
-		return intel_cx0_phy_check_hdmi_link_rate(hdmi, clock);
-
 	return MODE_OK;
 }
 
-- 
2.45.2


  parent reply	other threads:[~2025-01-20  4:32 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20  4:21 [PATCH 0/5] Add HDMI PLL Algorithm for SNPS/C10PHY Ankit Nautiyal
2025-01-20  4:21 ` [PATCH 1/5] drm/i915/display: Add support for SNPS PHY HDMI PLL algorithm for DG2 Ankit Nautiyal
2025-01-21  4:37   ` Kandpal, Suraj
2025-01-20  4:21 ` [PATCH 2/5] drm/i915/snps_phy: Use " Ankit Nautiyal
2025-01-20  4:21 ` [PATCH 3/5] drm/i915/cx0_phy_regs: Add C10 registers bits Ankit Nautiyal
2025-01-22 11:10   ` Jani Nikula
2025-01-22 16:28   ` Ankit Nautiyal
2025-01-20  4:21 ` [PATCH 4/5] drm/i915/intel_snps_hdmi_pll: Compute C10 HDMI PLLs with algorithm Ankit Nautiyal
2025-01-20  4:21 ` Ankit Nautiyal [this message]
2025-01-20  6:23 ` ✓ CI.Patch_applied: success for Add HDMI PLL Algorithm for SNPS/C10PHY (rev4) Patchwork
2025-01-20  6:23 ` ✗ CI.checkpatch: warning " Patchwork
2025-01-20  6:24 ` ✓ CI.KUnit: success " Patchwork
2025-01-20  6:42 ` ✓ CI.Build: " Patchwork
2025-01-20  6:44 ` ✓ CI.Hooks: " Patchwork
2025-01-20  6:46 ` ✗ CI.checksparse: warning " Patchwork
2025-01-20  7:13 ` ✓ Xe.CI.BAT: success " Patchwork
2025-01-20  9:05 ` ✗ Xe.CI.Full: failure " Patchwork
2025-01-20 12:31 ` ✓ CI.Patch_applied: success for Add HDMI PLL Algorithm for SNPS/C10PHY (rev5) Patchwork
2025-01-20 12:31 ` ✗ CI.checkpatch: warning " Patchwork
2025-01-20 12:32 ` ✓ CI.KUnit: success " Patchwork
2025-01-20 12:49 ` ✓ CI.Build: " Patchwork
2025-01-20 12:51 ` ✓ CI.Hooks: " Patchwork
2025-01-20 12:52 ` ✗ CI.checksparse: warning " Patchwork
2025-01-20 13:19 ` ✓ Xe.CI.BAT: success " Patchwork
2025-01-20 14:58 ` ✗ Xe.CI.Full: failure " Patchwork
2025-01-21 22:45 ` [PATCH 0/5] Add HDMI PLL Algorithm for SNPS/C10PHY Almahallawy, Khaled
2025-01-22  9:10   ` Nautiyal, Ankit K
2025-01-22 16:52     ` Jani Nikula
2025-01-23  5:26       ` Nautiyal, Ankit K
2025-01-22 17:01 ` ✓ CI.Patch_applied: success for Add HDMI PLL Algorithm for SNPS/C10PHY (rev6) Patchwork
2025-01-22 17:02 ` ✗ CI.checkpatch: warning " Patchwork
2025-01-22 17:03 ` ✓ CI.KUnit: success " Patchwork
2025-01-22 17:19 ` ✓ CI.Build: " Patchwork
2025-01-22 17:22 ` ✓ CI.Hooks: " Patchwork
2025-01-22 17:23 ` ✗ CI.checksparse: warning " Patchwork
2025-01-22 17:50 ` ✓ Xe.CI.BAT: success " Patchwork
2025-01-23  6:14 ` ✗ Xe.CI.Full: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2024-08-13  3:19 [PATCH 0/5] Add HDMI PLL Algorithm for SNPS/C10PHY Ankit Nautiyal
2024-08-13  3:19 ` [PATCH 5/5] drm/i915/cx0_phy: Use HDMI PLL algorithm for C10 PHY Ankit Nautiyal
2025-01-10  6:24   ` Kandpal, Suraj
2024-08-06 12:58 [PATCH 0/5] Add HDMI PLL Algorithm for SNPS/C10PHY Ankit Nautiyal
2024-08-06 12:58 ` [PATCH 5/5] drm/i915/cx0_phy: Use HDMI PLL algorithm for C10 PHY Ankit Nautiyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250120042122.1029481-6-ankit.k.nautiyal@intel.com \
    --to=ankit.k.nautiyal@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=suraj.kandpal@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox