Skip to contentSkip to conversation

drm/i915: Split pin mapping into per platform functions

PATCH In review Anusha Srivatsa 3 participants 4 messages Aug 10, 2017 – Aug 14, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Split pin mapping into per platform functions

Cleanup the code. Map the pins in accordance to individual platforms rather than according to ports. Create separate functions for platforms.

v2:
- Add missing condition for CoffeeLake. Make platform specific functions static. Add function i915_ddc_pin_mapping().

Sugested-by Ville Syrjala <[email protected]>

Cc Ville Syrjala <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Clinton Tayloe <[email protected]>
---
 drivers/gpu/drm/i915/intel_hdmi.c | 115 ++++++++++++++++++++++++++++++--------
 1 file changed, 92 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/intel_hdmi.c +92 -23
index 2ef1ee85129d..41e6ba01ec1c 100644
@@ -1843,49 +1843,118 @@ void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder,
 	DRM_DEBUG_KMS("sink scrambling handled\n");
 }
 
-static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv,
-			     enum port port)
+static u8 chv_ddc_pin_mapping(struct drm_i915_private *dev_priv, enum port port)
 {
-	const struct ddi_vbt_port_info *info =
-		&dev_priv->vbt.ddi_port_info[port];
 	u8 ddc_pin;
 
-	if (info->alternate_ddc_pin) {
-		DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (VBT)\n",
-			      info->alternate_ddc_pin, port_name(port));
-		return info->alternate_ddc_pin;
+	switch (port) {
+
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_DPC;
+		break;
+	case PORT_D:
+		ddc_pin = GMBUS_PIN_DPD_CHV;
+		break;
+	default:
+		MISSING_CASE(port);
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
 	}
+	return ddc_pin;
+}
+
+static u8 bxt_ddc_pin_mapping(struct drm_i915_private *dev_priv, enum port port)
+{
+	u8 ddc_pin;
 
 	switch (port) {
 	case PORT_B:
-		if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_1_BXT;
-		else
-			ddc_pin = GMBUS_PIN_DPB;
+		ddc_pin = GMBUS_PIN_1_BXT;
 		break;
 	case PORT_C:
-		if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_2_BXT;
-		else
-			ddc_pin = GMBUS_PIN_DPC;
+		ddc_pin = GMBUS_PIN_2_BXT;
+		break;
+	default:
+		MISSING_CASE(port);
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	}
+	return ddc_pin;
+}
+
+static u8 cnp_ddc_pin_mapping(struct drm_i915_private *dev_priv,
+		enum port port)
+{
+	u8 ddc_pin;
+
+	switch (port) {
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_1_BXT;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_2_BXT;
 		break;
 	case PORT_D:
-		if (HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_4_CNP;
-		else if (IS_CHERRYVIEW(dev_priv))
-			ddc_pin = GMBUS_PIN_DPD_CHV;
-		else
-			ddc_pin = GMBUS_PIN_DPD;
+		ddc_pin = GMBUS_PIN_4_CNP;
+		break;
+	default:
+		MISSING_CASE(port);
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	}
+	return ddc_pin;
+}
+
+static u8 i915_ddc_pin_mapping(struct drm_i915_private *dev_priv,
+		enum port port)
+{
+	u8 ddc_pin;
+
+	switch (port) {
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_DPC;
+		break;
+	case PORT_D:
+		ddc_pin = GMBUS_PIN_DPD;
 		break;
 	default:
 		MISSING_CASE(port);
 		ddc_pin = GMBUS_PIN_DPB;
 		break;
 	}
+	return ddc_pin;
+
+}
+static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv,
+			     enum port port)
+{
+	const struct ddi_vbt_port_info *info =
+		&dev_priv->vbt.ddi_port_info[port];
+	u8 ddc_pin = 0;
+
+	if (info->alternate_ddc_pin) {
+		DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (VBT)\n",
+			      info->alternate_ddc_pin, port_name(port));
+		return info->alternate_ddc_pin;
+	}
+
+	if (IS_CHERRYVIEW(dev_priv))
+		ddc_pin = chv_ddc_pin_mapping(dev_priv, port);
+	else if (IS_GEN9_LP(dev_priv))
+		ddc_pin = bxt_ddc_pin_mapping(dev_priv, port);
+	else if (HAS_PCH_CNP(dev_priv))
+		ddc_pin = cnp_ddc_pin_mapping(dev_priv, port);
+	else
+		ddc_pin = i915_ddc_pin_mapping(dev_priv, port);
 
 	DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (platform default)\n",
 		      ddc_pin, port_name(port));
-
 	return ddc_pin;
 }
 
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✓ Fi.CI.BAT: success for drm/i915: Split pin mapping into per platform functions (rev2)

== Series Details ==

== Series Details ==

Series: drm/i915: Split pin mapping into per platform functions (rev2)
URL : https://patchwork.freedesktop.org/series/27965/
State : success

== Summary ==

Series 27965v2 drm/i915: Split pin mapping into per platform functions
https://patchwork.freedesktop.org/api/1.0/series/27965/revisions/2/mbox/

Test kms_cursor_legacy:

        Subgroup basic-busy-flip-before-cursor-legacy:
                fail       -> PASS       (fi-snb-2600) fdo#100215
Test kms_flip:
        Subgroup basic-flip-vs-modeset:
                skip       -> PASS       (fi-skl-x1585l) fdo#101781
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-byt-n2820) fdo#101705

fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705

fi-bdw-5557u     total:279  pass:268  dwarn:0   dfail:0   fail:0   skip:11  time:446s
fi-bdw-gvtdvm    total:279  pass:265  dwarn:0   dfail:0   fail:0   skip:14  time:430s
fi-blb-e6850     total:279  pass:224  dwarn:1   dfail:0   fail:0   skip:54  time:360s
fi-bsw-n3050     total:279  pass:243  dwarn:0   dfail:0   fail:0   skip:36  time:542s
fi-bxt-j4205     total:279  pass:260  dwarn:0   dfail:0   fail:0   skip:19  time:515s
fi-byt-j1900     total:279  pass:254  dwarn:1   dfail:0   fail:0   skip:24  time:523s
fi-byt-n2820     total:279  pass:251  dwarn:0   dfail:0   fail:0   skip:28  time:511s
fi-glk-2a        total:279  pass:260  dwarn:0   dfail:0   fail:0   skip:19  time:603s
fi-hsw-4770      total:279  pass:263  dwarn:0   dfail:0   fail:0   skip:16  time:442s
fi-hsw-4770r     total:279  pass:263  dwarn:0   dfail:0   fail:0   skip:16  time:421s
fi-ilk-650       total:279  pass:229  dwarn:0   dfail:0   fail:0   skip:50  time:413s
fi-ivb-3520m     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:512s
fi-ivb-3770      total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:478s
fi-kbl-7500u     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:471s
fi-kbl-7560u     total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:587s
fi-kbl-r         total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:593s
fi-pnv-d510      total:279  pass:223  dwarn:1   dfail:0   fail:0   skip:55  time:529s
fi-skl-6260u     total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:464s
fi-skl-6700k     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:467s
fi-skl-6770hq    total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:481s
fi-skl-gvtdvm    total:279  pass:266  dwarn:0   dfail:0   fail:0   skip:13  time:436s
fi-skl-x1585l    total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:496s
fi-snb-2520m     total:279  pass:251  dwarn:0   dfail:0   fail:0   skip:28  time:544s
fi-snb-2600      total:279  pass:250  dwarn:0   dfail:0   fail:0   skip:29  time:409s

a8f0812284aa77e62aba1e4b430ac3bc090f43d0 drm-tip: 2017y-08m-11d-07h-22m-37s UTC integration manifest 48bcdd1ade9d drm/i915: Split pin mapping into per platform functions

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5371/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Anusha Srivatsa

Em Qui, 2017-08-10 às 11:42 -0700, Anusha Srivatsa escreveu:

Quoted 29 lines

Cleanup the code. Map the pins in accordance to individual platforms rather than according to ports. Create separate functions for platforms.

v2:
 - Add missing condition for CoffeeLake. Make platform specific functions static. Add function i915_ddc_pin_mapping().

Sugested-by Ville Syrjala <[email protected]>

Cc Ville Syrjala <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Clinton Tayloe <[email protected]>

---
 drivers/gpu/drm/i915/intel_hdmi.c | 115
++++++++++++++++++++++++++++++--------

 1 file changed, 92 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 2ef1ee85129d..41e6ba01ec1c 100644
@@ -1843,49 +1843,118 @@ void
 intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder,
  	DRM_DEBUG_KMS("sink scrambling handled\n");
  }

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder,

Quoted 3 lines
drivers/gpu/drm/i915/intel_hdmi.c +1 -2
-static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv,
-			     enum port port)
+static u8 chv_ddc_pin_mapping(struct drm_i915_private *dev_priv, 

Bikeshedding: what these functions do is pretty much map ports to DDC pins, so I'd have named them x_port_to_ddc_pin() since that's the most usual naming when converting "units", but I'm not opposed to the current naming. Your choice.

Quoted 11 lines

enum port port)
 {

drivers/gpu/drm/i915/intel_hdmi.c +0 -2
-	const struct ddi_vbt_port_info *info =
-		&dev_priv->vbt.ddi_port_info[port];

  u8 ddc_pin;

drivers/gpu/drm/i915/intel_hdmi.c +0 -2
-	if (info->alternate_ddc_pin) {
-		DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c

(VBT)\n",

drivers/gpu/drm/i915/intel_hdmi.c +0 -1
-			      info->alternate_ddc_pin,

port_name(port));

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1851

Quoted 3 lines
drivers/gpu/drm/i915/intel_hdmi.c +2 -1
-		return info->alternate_ddc_pin;
+	switch (port) {
+

This is the only switch statement where you added a blank line at this point. Doing this is not our usual coding style.

Quoted 14 lines
drivers/gpu/drm/i915/intel_hdmi.c +13 -0
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_DPC;
+		break;
+	case PORT_D:
+		ddc_pin = GMBUS_PIN_DPD_CHV;
+		break;
+	default:
+		MISSING_CASE(port);
+		ddc_pin = GMBUS_PIN_DPB;
+		break;

  }

drivers/gpu/drm/i915/intel_hdmi.c

Quoted 1 line
drivers/gpu/drm/i915/intel_hdmi.c +1 -0
+	return ddc_pin;

Another bikeshedding which you don't need to implement: just returning the pins inside the switch statements (return GMBUX_PIN_XYZ) without the ddc_pin variable would have made the functions much shorter.

Quoted 16 lines
drivers/gpu/drm/i915/intel_hdmi.c +3 -0
+}
+
+static u8 bxt_ddc_pin_mapping(struct drm_i915_private *dev_priv,

enum port port)

drivers/gpu/drm/i915/intel_hdmi.c +2 -0
+{
+	u8 ddc_pin;


  switch (port) {
  case PORT_B:

drivers/gpu/drm/i915/intel_hdmi.c +1 -4
-		if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_1_BXT;
-		else
-			ddc_pin = GMBUS_PIN_DPB;
+		ddc_pin = GMBUS_PIN_1_BXT;

  break;
  case PORT_C:

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1882

Quoted 9 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -4
-		if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_2_BXT;
-		else
-			ddc_pin = GMBUS_PIN_DPC;
+		ddc_pin = GMBUS_PIN_2_BXT;
+		break;
+	default:
+		MISSING_CASE(port);
+		ddc_pin = GMBUS_PIN_DPB;

Now that you've reorganized the code it's very easy to notice that on bxt/cnp the default value doesn't even match what we return from port B. I wouldn't complain if you addressed this issue in a follow-up patch.

Quoted 26 lines
drivers/gpu/drm/i915/intel_hdmi.c +16 -0
+		break;
+	}
+	return ddc_pin;
+}
+
+static u8 cnp_ddc_pin_mapping(struct drm_i915_private *dev_priv,
+		enum port port)
+{
+	u8 ddc_pin;
+
+	switch (port) {
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_1_BXT;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_2_BXT;

  break;
  case PORT_D:

drivers/gpu/drm/i915/intel_hdmi.c +2 -6
-		if (HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_4_CNP;
-		else if (IS_CHERRYVIEW(dev_priv))
-			ddc_pin = GMBUS_PIN_DPD_CHV;
-		else
-			ddc_pin = GMBUS_PIN_DPD;
+		ddc_pin = GMBUS_PIN_4_CNP;
+		break;

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1912

Quoted 10 lines
drivers/gpu/drm/i915/intel_hdmi.c +10 -0
+	default:
+		MISSING_CASE(port);
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	}
+	return ddc_pin;
+}
+
+static u8 i915_ddc_pin_mapping(struct drm_i915_private *dev_priv,
+		enum port port)

The first platform to run this is g4x, so please make the function name start with g4x_

Quoted 18 lines
drivers/gpu/drm/i915/intel_hdmi.c +12 -0
+{
+	u8 ddc_pin;
+
+	switch (port) {
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_DPC;
+		break;
+	case PORT_D:
+		ddc_pin = GMBUS_PIN_DPD;

  break;
  default:
  MISSING_CASE(port);
  ddc_pin = GMBUS_PIN_DPB;
  break;
  }

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1935

Quoted 5 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
+	return ddc_pin;
+
+}
+static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv,
+			     enum port port)

Missing blank line between functions.

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1939

Quoted 4 lines
drivers/gpu/drm/i915/intel_hdmi.c +4 -0
+{
+	const struct ddi_vbt_port_info *info =
+		&dev_priv->vbt.ddi_port_info[port];
+	u8 ddc_pin = 0;

In our coding style we usually don't zero-initialize things when they don't need to be zero-initialized. The advantage of not zero- initializing when we don't need is that if some rework happens and we suddenly start forgetting to set a sane value, the compiler will tell us.

Quoted 7 lines
drivers/gpu/drm/i915/intel_hdmi.c +3 -0
+
+	if (info->alternate_ddc_pin) {
+		DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c

(VBT)\n",

drivers/gpu/drm/i915/intel_hdmi.c +1 -0
+			      info->alternate_ddc_pin,

port_name(port));

drivers/gpu/drm/i915/intel_hdmi.c +1 -0
+		return info->alternate_ddc_pin;

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1954

Quoted 10 lines
drivers/gpu/drm/i915/intel_hdmi.c +10 -0
+	}
+
+	if (IS_CHERRYVIEW(dev_priv))
+		ddc_pin = chv_ddc_pin_mapping(dev_priv, port);
+	else if (IS_GEN9_LP(dev_priv))
+		ddc_pin = bxt_ddc_pin_mapping(dev_priv, port);
+	else if (HAS_PCH_CNP(dev_priv))
+		ddc_pin = cnp_ddc_pin_mapping(dev_priv, port);
+	else
+		ddc_pin = i915_ddc_pin_mapping(dev_priv, port);

Quoted 4 lines

  DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (platform default)\n",
        ddc_pin, port_name(port));
-

Please don't remove this line.

Quoted 3 lines

  return ddc_pin;
 }

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 56 lines

-----Original Message-----
From: Zanoni, Paulo R
Sent: Monday, August 14, 2017 2:14 PM
To: Srivatsa, Anusha <[email protected]>; intel- [email protected]
Cc: Vivi, Rodrigo <[email protected]>
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Split pin mapping into per platform functions

Em Qui, 2017-08-10 às 11:42 -0700, Anusha Srivatsa escreveu:

Quoted 25 lines

Cleanup the code. Map the pins in accordance to individual platforms rather than according to ports.
Create separate functions for platforms.

v2:
 - Add missing condition for CoffeeLake. Make platform specific functions static. Add function i915_ddc_pin_mapping().

Sugested-by Ville Syrjala <[email protected]>

Cc Ville Syrjala <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Clinton Tayloe <[email protected]>

---
 drivers/gpu/drm/i915/intel_hdmi.c | 115
++++++++++++++++++++++++++++++--------

 1 file changed, 92 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 2ef1ee85129d..41e6ba01ec1c 100644

drivers/gpu/drm/i915/intel_hdmi.c void · line 1847

Quoted 7 lines
drivers/gpu/drm/i915/intel_hdmi.c +1 -2
@@ -1843,49 +1843,118 @@ void
 intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder,
  	DRM_DEBUG_KMS("sink scrambling handled\n");
  }
 
-static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv,
-			     enum port port)
+static u8 chv_ddc_pin_mapping(struct drm_i915_private *dev_priv,

Bikeshedding: what these functions do is pretty much map ports to DDC pins, so I'd have named them x_port_to_ddc_pin() since that's the most usual naming when converting "units", but I'm not opposed to the current naming. Your choice.

Quoted 6 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -2
 enum port port)
  {
-	const struct ddi_vbt_port_info *info =
-		&dev_priv->vbt.ddi_port_info[port];
  	u8 ddc_pin;
 
Quoted 11 lines

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1851

Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c +2 -4
-	if (info->alternate_ddc_pin) {
-		DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c
 (VBT)\n",
-			      info->alternate_ddc_pin,
 port_name(port));
-		return info->alternate_ddc_pin;
+	switch (port) {
+

This is the only switch statement where you added a blank line at this point. Doing this is not our usual coding style.

Will change in the next version.

Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_hdmi.c +11 -0
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_DPC;
+		break;
+	case PORT_D:
+		ddc_pin = GMBUS_PIN_DPD_CHV;
+		break;
+	default:
+		MISSING_CASE(port);
Quoted 9 lines

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1866

Quoted 4 lines
drivers/gpu/drm/i915/intel_hdmi.c +3 -0
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
  	}
+	return ddc_pin;

Another bikeshedding which you don't need to implement: just returning the pins inside the switch statements (return GMBUX_PIN_XYZ) without the ddc_pin variable would have made the functions much shorter.

Hmm... yes. I agree.

Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
+}
+
+static u8 bxt_ddc_pin_mapping(struct drm_i915_private *dev_priv,
 enum port port)
+{
+	u8 ddc_pin;
 
  	switch (port) {

  case PORT_B:

drivers/gpu/drm/i915/intel_hdmi.c +1 -4
-		if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_1_BXT;
-		else
-			ddc_pin = GMBUS_PIN_DPB;
+		ddc_pin = GMBUS_PIN_1_BXT;

  break;
  case PORT_C:

drivers/gpu/drm/i915/intel_hdmi.c +1 -4
-		if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_2_BXT;
-		else
-			ddc_pin = GMBUS_PIN_DPC;
+		ddc_pin = GMBUS_PIN_2_BXT;
Quoted 9 lines

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1863

Quoted 4 lines
drivers/gpu/drm/i915/intel_hdmi.c +4 -0
+		break;
+	default:
+		MISSING_CASE(port);
+		ddc_pin = GMBUS_PIN_DPB;

Now that you've reorganized the code it's very easy to notice that on bxt/cnp the default value doesn't even match what we return from port B. I wouldn't complain if you addressed this issue in a follow-up patch.

Yes. Will change.

Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/i915/intel_hdmi.c +16 -0
+		break;
+	}
+	return ddc_pin;
+}
+
+static u8 cnp_ddc_pin_mapping(struct drm_i915_private *dev_priv,
+		enum port port)
+{
+	u8 ddc_pin;
+
+	switch (port) {
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_1_BXT;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_2_BXT;

  break;
  case PORT_D:

drivers/gpu/drm/i915/intel_hdmi.c +7 -6
-		if (HAS_PCH_CNP(dev_priv))
-			ddc_pin = GMBUS_PIN_4_CNP;
-		else if (IS_CHERRYVIEW(dev_priv))
-			ddc_pin = GMBUS_PIN_DPD_CHV;
-		else
-			ddc_pin = GMBUS_PIN_DPD;
+		ddc_pin = GMBUS_PIN_4_CNP;
+		break;
+	default:
+		MISSING_CASE(port);
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	}
Quoted 8 lines

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1912

Quoted 5 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
+	return ddc_pin;
+}
+
+static u8 i915_ddc_pin_mapping(struct drm_i915_private *dev_priv,
+		enum port port)

The first platform to run this is g4x, so please make the function name start with g4x_

I thought having i915_ will make it more readable. But will change to g4x_ in the next version.

Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/i915/intel_hdmi.c +12 -0
+{
+	u8 ddc_pin;
+
+	switch (port) {
+	case PORT_B:
+		ddc_pin = GMBUS_PIN_DPB;
+		break;
+	case PORT_C:
+		ddc_pin = GMBUS_PIN_DPC;
+		break;
+	case PORT_D:
+		ddc_pin = GMBUS_PIN_DPD;

  break;
  default:
  MISSING_CASE(port);
  ddc_pin = GMBUS_PIN_DPB;
  break;

Quoted 8 lines

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1935

Quoted 6 lines

  }

drivers/gpu/drm/i915/intel_hdmi.c +5 -0
+	return ddc_pin;
+
+}
+static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv,
+			     enum port port)

Missing blank line between functions.

Will take care in the next version.

Quoted 10 lines

drivers/gpu/drm/i915/intel_hdmi.c void intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, · line 1939

Quoted 5 lines
drivers/gpu/drm/i915/intel_hdmi.c +4 -0
+{
+	const struct ddi_vbt_port_info *info =
+		&dev_priv->vbt.ddi_port_info[port];
+	u8 ddc_pin = 0;

In our coding style we usually don't zero-initialize things when they don't need to be zero-initialized. The advantage of not zero- initializing when we don't need is that if some rework happens and we suddenly start forgetting to set a sane value, the compiler will tell us.

Got it. Thanks a lot Paulo.

Quoted 19 lines
Quoted 18 lines
drivers/gpu/drm/i915/intel_hdmi.c +3 -0
+
+	if (info->alternate_ddc_pin) {
+		DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c

(VBT)\n",

drivers/gpu/drm/i915/intel_hdmi.c +1 -0
+			      info->alternate_ddc_pin,

port_name(port));

drivers/gpu/drm/i915/intel_hdmi.c +11 -0
+		return info->alternate_ddc_pin;
+	}
+
+	if (IS_CHERRYVIEW(dev_priv))
+		ddc_pin = chv_ddc_pin_mapping(dev_priv, port);
+	else if (IS_GEN9_LP(dev_priv))
+		ddc_pin = bxt_ddc_pin_mapping(dev_priv, port);
+	else if (HAS_PCH_CNP(dev_priv))
+		ddc_pin = cnp_ddc_pin_mapping(dev_priv, port);
+	else
+		ddc_pin = i915_ddc_pin_mapping(dev_priv, port);
Quoted 6 lines
Quoted 1 line

  DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (platform

default)\n",

Quoted 2 lines

        ddc_pin, port_name(port));
-

Please don't remove this line.

Yes. Will send the next version with changes soon.

Anusha

Quoted 4 lines
Quoted 4 lines

  return ddc_pin;
 }

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx