Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@intel.com>
Subject: [PATCH v2 03/11] drm/i915/ddi: Make all the PORT_WIDTH macros work the same way
Date: Fri, 14 Feb 2025 16:19:53 +0200	[thread overview]
Message-ID: <20250214142001.552916-4-imre.deak@intel.com> (raw)
In-Reply-To: <20250214142001.552916-1-imre.deak@intel.com>

Make the PORT_WIDTH macro of the XELPDP_PORT_CTL1 register work the same
way as those used for the DDI_BUF_CTL and the TRANS_DDI_FUNC_CTL
registers: accept a width parameter and convert it to the given
register's encoding.

v2: Robustify macro calls with parens. (Jani)

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 .../gpu/drm/i915/display/intel_cx0_phy_regs.h |  3 ++-
 drivers/gpu/drm/i915/display/intel_ddi.c      | 22 ++-----------------
 2 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cx0_phy_regs.h b/drivers/gpu/drm/i915/display/intel_cx0_phy_regs.h
index 4a3cf08007e31..960f7f778fb81 100644
--- a/drivers/gpu/drm/i915/display/intel_cx0_phy_regs.h
+++ b/drivers/gpu/drm/i915/display/intel_cx0_phy_regs.h
@@ -110,7 +110,8 @@
 #define   XELPDP_TCSS_POWER_REQUEST			REG_BIT(5)
 #define   XELPDP_TCSS_POWER_STATE			REG_BIT(4)
 #define   XELPDP_PORT_WIDTH_MASK			REG_GENMASK(3, 1)
-#define   XELPDP_PORT_WIDTH(val)			REG_FIELD_PREP(XELPDP_PORT_WIDTH_MASK, val)
+#define   XELPDP_PORT_WIDTH(width)			REG_FIELD_PREP(XELPDP_PORT_WIDTH_MASK, \
+								       ((width) == 3 ? 4 : (width) - 1))
 
 #define _XELPDP_PORT_BUF_CTL2(idx)			_MMIO(_PICK_EVEN_2RANGES(idx, PORT_TC1, \
 										 _XELPDP_PORT_BUF_CTL1_LN0_A, \
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
index 5ef7857a893f8..a09363e5dc148 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -2525,23 +2525,6 @@ static void intel_ddi_mso_configure(const struct intel_crtc_state *crtc_state)
 		     OVERLAP_PIXELS_MASK, dss1);
 }
 
-static u8 mtl_get_port_width(u8 lane_count)
-{
-	switch (lane_count) {
-	case 1:
-		return 0;
-	case 2:
-		return 1;
-	case 3:
-		return 4;
-	case 4:
-		return 3;
-	default:
-		MISSING_CASE(lane_count);
-		return 4;
-	}
-}
-
 static void
 mtl_ddi_enable_d2d(struct intel_encoder *encoder)
 {
@@ -2575,7 +2558,7 @@ static void mtl_port_buf_ctl_program(struct intel_encoder *encoder,
 	enum port port = encoder->port;
 	u32 val = 0;
 
-	val |= XELPDP_PORT_WIDTH(mtl_get_port_width(crtc_state->lane_count));
+	val |= XELPDP_PORT_WIDTH(crtc_state->lane_count);
 
 	if (intel_dp_is_uhbr(crtc_state))
 		val |= XELPDP_PORT_BUF_PORT_DATA_40BIT;
@@ -3500,10 +3483,9 @@ static void intel_ddi_enable_hdmi(struct intel_atomic_state *state,
 		buf_ctl |= DDI_A_4_LANES;
 
 	if (DISPLAY_VER(dev_priv) >= 14) {
-		u8  lane_count = mtl_get_port_width(crtc_state->lane_count);
 		u32 port_buf = 0;
 
-		port_buf |= XELPDP_PORT_WIDTH(lane_count);
+		port_buf |= XELPDP_PORT_WIDTH(crtc_state->lane_count);
 
 		if (dig_port->lane_reversal)
 			port_buf |= XELPDP_PORT_REVERSAL;
-- 
2.44.2


  parent reply	other threads:[~2025-02-14 14:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14 14:19 [PATCH v2 00/11] drm/i915/ddi: Fix/simplify port enabling/disabling Imre Deak
2025-02-14 14:19 ` [PATCH v2 01/11] drm/i915/dsi: Use TRANS_DDI_FUNC_CTL's own port width macro Imre Deak
2025-02-14 14:19 ` [PATCH v2 02/11] drm/i915/ddi: Fix HDMI port width programming in DDI_BUF_CTL Imre Deak
2025-02-14 14:19 ` Imre Deak [this message]
2025-02-14 14:19 ` [PATCH v2 04/11] drm/i915/ddi: Set missing TC DP PHY lane stagger delay " Imre Deak
2025-02-14 14:19 ` [PATCH v2 05/11] drm/i915/ddi: Simplify the port enabling via DDI_BUF_CTL Imre Deak
2025-02-14 14:19 ` [PATCH v2 06/11] drm/i915/ddi: Simplify the port disabling " Imre Deak
2025-02-14 14:19 ` [PATCH v2 07/11] drm/i915/ddi: Simplify waiting for a port to get active/idle " Imre Deak
2025-02-14 14:19 ` [PATCH v2 08/11] drm/i915/ddi: Move platform checks within mtl_ddi_enable/disable_d2d_link() Imre Deak
2025-02-14 14:19 ` [PATCH v2 09/11] drm/i915/ddi: Unify the platform specific functions disabling a port Imre Deak
2025-02-14 14:20 ` [PATCH v2 10/11] drm/i915/ddi: Add a helper to enable " Imre Deak
2025-02-14 14:20 ` [PATCH v2 11/11] drm/i915/ddi: Sanitize DDI_BUF_CTL register definitions Imre Deak
2025-02-14 15:09 ` ✓ CI.Patch_applied: success for drm/i915/ddi: Fix/simplify port enabling/disabling (rev2) Patchwork
2025-02-14 15:09 ` ✗ CI.checkpatch: warning " Patchwork
2025-02-14 15:10 ` ✓ CI.KUnit: success " Patchwork
2025-02-14 15:27 ` ✓ CI.Build: " Patchwork
2025-02-14 15:29 ` ✓ CI.Hooks: " Patchwork
2025-02-14 15:31 ` ✗ CI.checksparse: warning " Patchwork
2025-02-14 15:37 ` [PATCH v2 00/11] drm/i915/ddi: Fix/simplify port enabling/disabling Jani Nikula
2025-02-14 15:50 ` ✓ Xe.CI.BAT: success for drm/i915/ddi: Fix/simplify port enabling/disabling (rev2) Patchwork
2025-02-15 14:55 ` ✗ Xe.CI.Full: failure " Patchwork

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=20250214142001.552916-4-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@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