Re: [Intel-gfx] [PATCH 6/6 v3] drm/i915: Enable HDMI on DDI-E

2015-08-31 Thread Jani Nikula
On Mon, 17 Aug 2015, Xiong Zhang  wrote:
> DDI-E doesn't have the correspondent GMBUS pin.
>
> We rely on VBT to tell us which one it being used instead.
>
> The DVI/HDMI on shared port couldn't exist.
>
> This patch isn't tested without hardware wchich has HDMI
> on DDI-E.
>
> v2: fix trailing whitespace
> v3: MISSING_CASE take place of BUG()
>
> Signed-off-by: Xiong Zhang 
> Reviewed-by: Rodrigo Vivi 

Pushed to drm-intel-next-fixes.

BR,
Jani.

> ---
>  drivers/gpu/drm/i915/i915_drv.h   |  5 +
>  drivers/gpu/drm/i915/intel_bios.c | 25 +
>  drivers/gpu/drm/i915/intel_hdmi.c | 21 +
>  3 files changed, 47 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 35192d2..22e8bf0 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1418,6 +1418,10 @@ enum modeset_restore {
>  #define DP_AUX_C 0x20
>  #define DP_AUX_D 0x30
>  
> +#define DDC_PIN_B  0x05
> +#define DDC_PIN_C  0x04
> +#define DDC_PIN_D  0x06
> +
>  struct ddi_vbt_port_info {
>   /*
>* This is an index in the HDMI/DVI DDI buffer translation table.
> @@ -1432,6 +1436,7 @@ struct ddi_vbt_port_info {
>   uint8_t supports_dp:1;
>  
>   uint8_t alternate_aux_channel;
> + uint8_t alternate_ddc_pin;
>  
>   uint8_t dp_boost_level;
>   uint8_t hdmi_boost_level;
> diff --git a/drivers/gpu/drm/i915/intel_bios.c 
> b/drivers/gpu/drm/i915/intel_bios.c
> index 8e46149..a2ee347 100644
> --- a/drivers/gpu/drm/i915/intel_bios.c
> +++ b/drivers/gpu/drm/i915/intel_bios.c
> @@ -905,7 +905,7 @@ static void parse_ddi_port(struct drm_i915_private 
> *dev_priv, enum port port,
>   uint8_t hdmi_level_shift;
>   int i, j;
>   bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
> - uint8_t aux_channel;
> + uint8_t aux_channel, ddc_pin;
>   /* Each DDI port can have more than one value on the "DVO Port" field,
>* so look for all the possible values for each port and abort if more
>* than one is found. */
> @@ -939,6 +939,7 @@ static void parse_ddi_port(struct drm_i915_private 
> *dev_priv, enum port port,
>   return;
>  
>   aux_channel = child->raw[25];
> + ddc_pin = child->common.ddc_pin;
>  
>   is_dvi = child->common.device_type & DEVICE_TYPE_TMDS_DVI_SIGNALING;
>   is_dp = child->common.device_type & DEVICE_TYPE_DISPLAYPORT_OUTPUT;
> @@ -970,11 +971,27 @@ static void parse_ddi_port(struct drm_i915_private 
> *dev_priv, enum port port,
>   DRM_DEBUG_KMS("Port %c is internal DP\n", port_name(port));
>  
>   if (is_dvi) {
> - if (child->common.ddc_pin == 0x05 && port != PORT_B)
> + if (port == PORT_E) {
> + info->alternate_ddc_pin = ddc_pin;
> + /* if DDIE share ddc pin with other port, then
> +  * dvi/hdmi couldn't exist on the shared port.
> +  * Otherwise they share the same ddc bin and system
> +  * couldn't communicate with them seperately. */
> + if (ddc_pin == DDC_PIN_B) {
> + 
> dev_priv->vbt.ddi_port_info[PORT_B].supports_dvi = 0;
> + 
> dev_priv->vbt.ddi_port_info[PORT_B].supports_hdmi = 0;
> + } else if (ddc_pin == DDC_PIN_C) {
> + 
> dev_priv->vbt.ddi_port_info[PORT_C].supports_dvi = 0;
> + 
> dev_priv->vbt.ddi_port_info[PORT_C].supports_hdmi = 0;
> + } else if (ddc_pin == DDC_PIN_D) {
> + 
> dev_priv->vbt.ddi_port_info[PORT_D].supports_dvi = 0;
> + 
> dev_priv->vbt.ddi_port_info[PORT_D].supports_hdmi = 0;
> + }
> + } else if (ddc_pin == DDC_PIN_B && port != PORT_B)
>   DRM_DEBUG_KMS("Unexpected DDC pin for port B\n");
> - if (child->common.ddc_pin == 0x04 && port != PORT_C)
> + else if (ddc_pin == DDC_PIN_C && port != PORT_C)
>   DRM_DEBUG_KMS("Unexpected DDC pin for port C\n");
> - if (child->common.ddc_pin == 0x06 && port != PORT_D)
> + else if (ddc_pin == DDC_PIN_D && port != PORT_D)
>   DRM_DEBUG_KMS("Unexpected DDC pin for port D\n");
>   }
>  
> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
> b/drivers/gpu/drm/i915/intel_hdmi.c
> index 7185062..d1a7f7b 100644
> --- a/drivers/gpu/drm/i915/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> @@ -1956,6 +1956,7 @@ void intel_hdmi_init_connector(struct 
> intel_digital_port *intel_dig_port,
>   struct drm_device *dev = intel_encoder->base.dev;
>   struct drm_i915_private *dev_priv = dev->dev_private;
>   enum port port = intel_dig_port->port;
> + uint8_t 

[Intel-gfx] [PATCH 6/6 v3] drm/i915: Enable HDMI on DDI-E

2015-08-17 Thread Xiong Zhang
DDI-E doesn't have the correspondent GMBUS pin.

We rely on VBT to tell us which one it being used instead.

The DVI/HDMI on shared port couldn't exist.

This patch isn't tested without hardware wchich has HDMI
on DDI-E.

v2: fix trailing whitespace
v3: MISSING_CASE take place of BUG()

Signed-off-by: Xiong Zhang xiong.y.zh...@intel.com
Reviewed-by: Rodrigo Vivi rodrigo.v...@intel.com
---
 drivers/gpu/drm/i915/i915_drv.h   |  5 +
 drivers/gpu/drm/i915/intel_bios.c | 25 +
 drivers/gpu/drm/i915/intel_hdmi.c | 21 +
 3 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 35192d2..22e8bf0 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1418,6 +1418,10 @@ enum modeset_restore {
 #define DP_AUX_C 0x20
 #define DP_AUX_D 0x30
 
+#define DDC_PIN_B  0x05
+#define DDC_PIN_C  0x04
+#define DDC_PIN_D  0x06
+
 struct ddi_vbt_port_info {
/*
 * This is an index in the HDMI/DVI DDI buffer translation table.
@@ -1432,6 +1436,7 @@ struct ddi_vbt_port_info {
uint8_t supports_dp:1;
 
uint8_t alternate_aux_channel;
+   uint8_t alternate_ddc_pin;
 
uint8_t dp_boost_level;
uint8_t hdmi_boost_level;
diff --git a/drivers/gpu/drm/i915/intel_bios.c 
b/drivers/gpu/drm/i915/intel_bios.c
index 8e46149..a2ee347 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -905,7 +905,7 @@ static void parse_ddi_port(struct drm_i915_private 
*dev_priv, enum port port,
uint8_t hdmi_level_shift;
int i, j;
bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
-   uint8_t aux_channel;
+   uint8_t aux_channel, ddc_pin;
/* Each DDI port can have more than one value on the DVO Port field,
 * so look for all the possible values for each port and abort if more
 * than one is found. */
@@ -939,6 +939,7 @@ static void parse_ddi_port(struct drm_i915_private 
*dev_priv, enum port port,
return;
 
aux_channel = child-raw[25];
+   ddc_pin = child-common.ddc_pin;
 
is_dvi = child-common.device_type  DEVICE_TYPE_TMDS_DVI_SIGNALING;
is_dp = child-common.device_type  DEVICE_TYPE_DISPLAYPORT_OUTPUT;
@@ -970,11 +971,27 @@ static void parse_ddi_port(struct drm_i915_private 
*dev_priv, enum port port,
DRM_DEBUG_KMS(Port %c is internal DP\n, port_name(port));
 
if (is_dvi) {
-   if (child-common.ddc_pin == 0x05  port != PORT_B)
+   if (port == PORT_E) {
+   info-alternate_ddc_pin = ddc_pin;
+   /* if DDIE share ddc pin with other port, then
+* dvi/hdmi couldn't exist on the shared port.
+* Otherwise they share the same ddc bin and system
+* couldn't communicate with them seperately. */
+   if (ddc_pin == DDC_PIN_B) {
+   
dev_priv-vbt.ddi_port_info[PORT_B].supports_dvi = 0;
+   
dev_priv-vbt.ddi_port_info[PORT_B].supports_hdmi = 0;
+   } else if (ddc_pin == DDC_PIN_C) {
+   
dev_priv-vbt.ddi_port_info[PORT_C].supports_dvi = 0;
+   
dev_priv-vbt.ddi_port_info[PORT_C].supports_hdmi = 0;
+   } else if (ddc_pin == DDC_PIN_D) {
+   
dev_priv-vbt.ddi_port_info[PORT_D].supports_dvi = 0;
+   
dev_priv-vbt.ddi_port_info[PORT_D].supports_hdmi = 0;
+   }
+   } else if (ddc_pin == DDC_PIN_B  port != PORT_B)
DRM_DEBUG_KMS(Unexpected DDC pin for port B\n);
-   if (child-common.ddc_pin == 0x04  port != PORT_C)
+   else if (ddc_pin == DDC_PIN_C  port != PORT_C)
DRM_DEBUG_KMS(Unexpected DDC pin for port C\n);
-   if (child-common.ddc_pin == 0x06  port != PORT_D)
+   else if (ddc_pin == DDC_PIN_D  port != PORT_D)
DRM_DEBUG_KMS(Unexpected DDC pin for port D\n);
}
 
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 7185062..d1a7f7b 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1956,6 +1956,7 @@ void intel_hdmi_init_connector(struct intel_digital_port 
*intel_dig_port,
struct drm_device *dev = intel_encoder-base.dev;
struct drm_i915_private *dev_priv = dev-dev_private;
enum port port = intel_dig_port-port;
+   uint8_t alternate_ddc_pin;
 
drm_connector_init(dev, connector, intel_hdmi_connector_funcs,
   DRM_MODE_CONNECTOR_HDMIA);
@@ -1996,6 +1997,26 @@ void intel_hdmi_init_connector(struct intel_digital_port 
*intel_dig_port,
intel_hdmi-ddc_bus = 

Re: [Intel-gfx] [PATCH 6/6 v3] drm/i915: Enable HDMI on DDI-E

2015-08-14 Thread Daniel Vetter
On Thu, Aug 13, 2015 at 02:57:38AM +, Zhang, Xiong Y wrote:
  On Wed, Aug 12, 2015 at 06:39:34PM +0800, Xiong Zhang wrote:
   DDI-E doesn't have the correspondent GMBUS pin.
  
   We rely on VBT to tell us which one it being used instead.
  
   The DVI/HDMI on shared port couldn't exist.
  
   This patch isn't tested without hardware wchich has HDMI on DDI-E.
  
   v2: fix trailing whitespace
   v3: WARN() take place of BUG()
  
  I asked for MISSING_CASE, not WARN.
  -Daniel
 [Zhang, Xiong Y] Because DDI-E on SKL doesn't have correspondent GMBUS pin, 
 it should share such pin with DDI-B/C/D. We don't know the default GMBUS pin 
 for DDI-E if VBT doesn't tell us. 
 If VBT don't tell us or give us an invalid GMBUS pin, driver will fail in 
 getting HDMI info. In such case, we really need a warn which tell us why 
 driver couldn't read EDID info for HDMI on DDI-E.

Have you bothered to look at the MISSING_CASE macro?! It does boil down to
a WARN, but I prefer it much over a WARN_ON since it's nicely
standardized.

Thanks, Daniel

 
 thanks
  
  
   Signed-off-by: Xiong Zhang xiong.y.zh...@intel.com
   Reviewed-by: Rodrigo Vivi rodrigo.v...@intel.com
   ---
drivers/gpu/drm/i915/i915_drv.h   |  5 +
drivers/gpu/drm/i915/intel_bios.c | 25 +
   drivers/gpu/drm/i915/intel_hdmi.c | 18 ++
3 files changed, 44 insertions(+), 4 deletions(-)
  
   diff --git a/drivers/gpu/drm/i915/i915_drv.h
   b/drivers/gpu/drm/i915/i915_drv.h index 6d93334..5d8e7fe 100644
   --- a/drivers/gpu/drm/i915/i915_drv.h
   +++ b/drivers/gpu/drm/i915/i915_drv.h
   @@ -1414,6 +1414,10 @@ enum modeset_restore {  #define DP_AUX_C
  0x20
   #define DP_AUX_D 0x30
  
   +#define DDC_PIN_B  0x05
   +#define DDC_PIN_C  0x04
   +#define DDC_PIN_D  0x06
   +
struct ddi_vbt_port_info {
 /*
  * This is an index in the HDMI/DVI DDI buffer translation table.
   @@ -1428,6 +1432,7 @@ struct ddi_vbt_port_info {
 uint8_t supports_dp:1;
  
 uint8_t alternate_aux_channel;
   + uint8_t alternate_ddc_pin;
};
  
enum psr_lines_to_wait {
   diff --git a/drivers/gpu/drm/i915/intel_bios.c
   b/drivers/gpu/drm/i915/intel_bios.c
   index 16cdf17..8140531 100644
   --- a/drivers/gpu/drm/i915/intel_bios.c
   +++ b/drivers/gpu/drm/i915/intel_bios.c
   @@ -894,7 +894,7 @@ static void parse_ddi_port(struct drm_i915_private
  *dev_priv, enum port port,
 uint8_t hdmi_level_shift;
 int i, j;
 bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
   - uint8_t aux_channel;
   + uint8_t aux_channel, ddc_pin;
 /* Each DDI port can have more than one value on the DVO Port field,
  * so look for all the possible values for each port and abort if more
  * than one is found. */
   @@ -928,6 +928,7 @@ static void parse_ddi_port(struct drm_i915_private
  *dev_priv, enum port port,
 return;
  
 aux_channel = child-raw[25];
   + ddc_pin = child-common.ddc_pin;
  
 is_dvi = child-common.device_type 
  DEVICE_TYPE_TMDS_DVI_SIGNALING;
 is_dp = child-common.device_type 
  DEVICE_TYPE_DISPLAYPORT_OUTPUT;
   @@ -959,11 +960,27 @@ static void parse_ddi_port(struct
  drm_i915_private *dev_priv, enum port port,
 DRM_DEBUG_KMS(Port %c is internal DP\n, port_name(port));
  
 if (is_dvi) {
   - if (child-common.ddc_pin == 0x05  port != PORT_B)
   + if (port == PORT_E) {
   + info-alternate_ddc_pin = ddc_pin;
   + /* if DDIE share ddc pin with other port, then
   +  * dvi/hdmi couldn't exist on the shared port.
   +  * Otherwise they share the same ddc bin and system
   +  * couldn't communicate with them seperately. */
   + if (ddc_pin == DDC_PIN_B) {
   + 
   dev_priv-vbt.ddi_port_info[PORT_B].supports_dvi = 0;
   + 
   dev_priv-vbt.ddi_port_info[PORT_B].supports_hdmi = 0;
   + } else if (ddc_pin == DDC_PIN_C) {
   + 
   dev_priv-vbt.ddi_port_info[PORT_C].supports_dvi = 0;
   + 
   dev_priv-vbt.ddi_port_info[PORT_C].supports_hdmi = 0;
   + } else if (ddc_pin == DDC_PIN_D) {
   + 
   dev_priv-vbt.ddi_port_info[PORT_D].supports_dvi = 0;
   + 
   dev_priv-vbt.ddi_port_info[PORT_D].supports_hdmi = 0;
   + }
   + } else if (ddc_pin == DDC_PIN_B  port != PORT_B)
 DRM_DEBUG_KMS(Unexpected DDC pin for port B\n);
   - if (child-common.ddc_pin == 0x04  port != PORT_C)
   + else if (ddc_pin == DDC_PIN_C  port != PORT_C)
 DRM_DEBUG_KMS(Unexpected DDC pin for port C\n);
   - if (child-common.ddc_pin == 0x06  port != PORT_D)
   + else if (ddc_pin == DDC_PIN_D  port != PORT_D)
 DRM_DEBUG_KMS(Unexpected DDC pin for port D\n);
 }
  
   diff --git 

Re: [Intel-gfx] [PATCH 6/6 v3] drm/i915: Enable HDMI on DDI-E

2015-08-14 Thread Zhang, Xiong Y
 On Thu, Aug 13, 2015 at 02:57:38AM +, Zhang, Xiong Y wrote:
   On Wed, Aug 12, 2015 at 06:39:34PM +0800, Xiong Zhang wrote:
DDI-E doesn't have the correspondent GMBUS pin.
   
We rely on VBT to tell us which one it being used instead.
   
The DVI/HDMI on shared port couldn't exist.
   
This patch isn't tested without hardware wchich has HDMI on DDI-E.
   
v2: fix trailing whitespace
v3: WARN() take place of BUG()
  
   I asked for MISSING_CASE, not WARN.
   -Daniel
  [Zhang, Xiong Y] Because DDI-E on SKL doesn't have correspondent GMBUS
 pin, it should share such pin with DDI-B/C/D. We don't know the default
 GMBUS pin for DDI-E if VBT doesn't tell us.
  If VBT don't tell us or give us an invalid GMBUS pin, driver will fail in 
  getting
 HDMI info. In such case, we really need a warn which tell us why driver
 couldn't read EDID info for HDMI on DDI-E.
 
 Have you bothered to look at the MISSING_CASE macro?! It does boil down to
 a WARN, but I prefer it much over a WARN_ON since it's nicely standardized.
 
[Zhang, Xiong Y] Please forgive my innocence! I misunderstand MISSING_CASE at 
the beginning.

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 6/6 v3] drm/i915: Enable HDMI on DDI-E

2015-08-12 Thread Zhang, Xiong Y
 On Wed, Aug 12, 2015 at 06:39:34PM +0800, Xiong Zhang wrote:
  DDI-E doesn't have the correspondent GMBUS pin.
 
  We rely on VBT to tell us which one it being used instead.
 
  The DVI/HDMI on shared port couldn't exist.
 
  This patch isn't tested without hardware wchich has HDMI on DDI-E.
 
  v2: fix trailing whitespace
  v3: WARN() take place of BUG()
 
 I asked for MISSING_CASE, not WARN.
 -Daniel
[Zhang, Xiong Y] Because DDI-E on SKL doesn't have correspondent GMBUS pin, it 
should share such pin with DDI-B/C/D. We don't know the default GMBUS pin for 
DDI-E if VBT doesn't tell us. 
If VBT don't tell us or give us an invalid GMBUS pin, driver will fail in 
getting HDMI info. In such case, we really need a warn which tell us why driver 
couldn't read EDID info for HDMI on DDI-E.

thanks
 
 
  Signed-off-by: Xiong Zhang xiong.y.zh...@intel.com
  Reviewed-by: Rodrigo Vivi rodrigo.v...@intel.com
  ---
   drivers/gpu/drm/i915/i915_drv.h   |  5 +
   drivers/gpu/drm/i915/intel_bios.c | 25 +
  drivers/gpu/drm/i915/intel_hdmi.c | 18 ++
   3 files changed, 44 insertions(+), 4 deletions(-)
 
  diff --git a/drivers/gpu/drm/i915/i915_drv.h
  b/drivers/gpu/drm/i915/i915_drv.h index 6d93334..5d8e7fe 100644
  --- a/drivers/gpu/drm/i915/i915_drv.h
  +++ b/drivers/gpu/drm/i915/i915_drv.h
  @@ -1414,6 +1414,10 @@ enum modeset_restore {  #define DP_AUX_C
 0x20
  #define DP_AUX_D 0x30
 
  +#define DDC_PIN_B  0x05
  +#define DDC_PIN_C  0x04
  +#define DDC_PIN_D  0x06
  +
   struct ddi_vbt_port_info {
  /*
   * This is an index in the HDMI/DVI DDI buffer translation table.
  @@ -1428,6 +1432,7 @@ struct ddi_vbt_port_info {
  uint8_t supports_dp:1;
 
  uint8_t alternate_aux_channel;
  +   uint8_t alternate_ddc_pin;
   };
 
   enum psr_lines_to_wait {
  diff --git a/drivers/gpu/drm/i915/intel_bios.c
  b/drivers/gpu/drm/i915/intel_bios.c
  index 16cdf17..8140531 100644
  --- a/drivers/gpu/drm/i915/intel_bios.c
  +++ b/drivers/gpu/drm/i915/intel_bios.c
  @@ -894,7 +894,7 @@ static void parse_ddi_port(struct drm_i915_private
 *dev_priv, enum port port,
  uint8_t hdmi_level_shift;
  int i, j;
  bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
  -   uint8_t aux_channel;
  +   uint8_t aux_channel, ddc_pin;
  /* Each DDI port can have more than one value on the DVO Port field,
   * so look for all the possible values for each port and abort if more
   * than one is found. */
  @@ -928,6 +928,7 @@ static void parse_ddi_port(struct drm_i915_private
 *dev_priv, enum port port,
  return;
 
  aux_channel = child-raw[25];
  +   ddc_pin = child-common.ddc_pin;
 
  is_dvi = child-common.device_type 
 DEVICE_TYPE_TMDS_DVI_SIGNALING;
  is_dp = child-common.device_type 
 DEVICE_TYPE_DISPLAYPORT_OUTPUT;
  @@ -959,11 +960,27 @@ static void parse_ddi_port(struct
 drm_i915_private *dev_priv, enum port port,
  DRM_DEBUG_KMS(Port %c is internal DP\n, port_name(port));
 
  if (is_dvi) {
  -   if (child-common.ddc_pin == 0x05  port != PORT_B)
  +   if (port == PORT_E) {
  +   info-alternate_ddc_pin = ddc_pin;
  +   /* if DDIE share ddc pin with other port, then
  +* dvi/hdmi couldn't exist on the shared port.
  +* Otherwise they share the same ddc bin and system
  +* couldn't communicate with them seperately. */
  +   if (ddc_pin == DDC_PIN_B) {
  +   
  dev_priv-vbt.ddi_port_info[PORT_B].supports_dvi = 0;
  +   
  dev_priv-vbt.ddi_port_info[PORT_B].supports_hdmi = 0;
  +   } else if (ddc_pin == DDC_PIN_C) {
  +   
  dev_priv-vbt.ddi_port_info[PORT_C].supports_dvi = 0;
  +   
  dev_priv-vbt.ddi_port_info[PORT_C].supports_hdmi = 0;
  +   } else if (ddc_pin == DDC_PIN_D) {
  +   
  dev_priv-vbt.ddi_port_info[PORT_D].supports_dvi = 0;
  +   
  dev_priv-vbt.ddi_port_info[PORT_D].supports_hdmi = 0;
  +   }
  +   } else if (ddc_pin == DDC_PIN_B  port != PORT_B)
  DRM_DEBUG_KMS(Unexpected DDC pin for port B\n);
  -   if (child-common.ddc_pin == 0x04  port != PORT_C)
  +   else if (ddc_pin == DDC_PIN_C  port != PORT_C)
  DRM_DEBUG_KMS(Unexpected DDC pin for port C\n);
  -   if (child-common.ddc_pin == 0x06  port != PORT_D)
  +   else if (ddc_pin == DDC_PIN_D  port != PORT_D)
  DRM_DEBUG_KMS(Unexpected DDC pin for port D\n);
  }
 
  diff --git a/drivers/gpu/drm/i915/intel_hdmi.c
  b/drivers/gpu/drm/i915/intel_hdmi.c
  index 70bad5b..a4129f2 100644
  --- a/drivers/gpu/drm/i915/intel_hdmi.c
  +++ b/drivers/gpu/drm/i915/intel_hdmi.c
  @@ -1991,6 +1991,24 @@ void intel_hdmi_init_connector(struct
 intel_digital_port *intel_dig_port,

[Intel-gfx] [PATCH 6/6 v3] drm/i915: Enable HDMI on DDI-E

2015-08-12 Thread Xiong Zhang
DDI-E doesn't have the correspondent GMBUS pin.

We rely on VBT to tell us which one it being used instead.

The DVI/HDMI on shared port couldn't exist.

This patch isn't tested without hardware wchich has HDMI
on DDI-E.

v2: fix trailing whitespace
v3: WARN() take place of BUG()

Signed-off-by: Xiong Zhang xiong.y.zh...@intel.com
Reviewed-by: Rodrigo Vivi rodrigo.v...@intel.com
---
 drivers/gpu/drm/i915/i915_drv.h   |  5 +
 drivers/gpu/drm/i915/intel_bios.c | 25 +
 drivers/gpu/drm/i915/intel_hdmi.c | 18 ++
 3 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 6d93334..5d8e7fe 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1414,6 +1414,10 @@ enum modeset_restore {
 #define DP_AUX_C 0x20
 #define DP_AUX_D 0x30
 
+#define DDC_PIN_B  0x05
+#define DDC_PIN_C  0x04
+#define DDC_PIN_D  0x06
+
 struct ddi_vbt_port_info {
/*
 * This is an index in the HDMI/DVI DDI buffer translation table.
@@ -1428,6 +1432,7 @@ struct ddi_vbt_port_info {
uint8_t supports_dp:1;
 
uint8_t alternate_aux_channel;
+   uint8_t alternate_ddc_pin;
 };
 
 enum psr_lines_to_wait {
diff --git a/drivers/gpu/drm/i915/intel_bios.c 
b/drivers/gpu/drm/i915/intel_bios.c
index 16cdf17..8140531 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -894,7 +894,7 @@ static void parse_ddi_port(struct drm_i915_private 
*dev_priv, enum port port,
uint8_t hdmi_level_shift;
int i, j;
bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
-   uint8_t aux_channel;
+   uint8_t aux_channel, ddc_pin;
/* Each DDI port can have more than one value on the DVO Port field,
 * so look for all the possible values for each port and abort if more
 * than one is found. */
@@ -928,6 +928,7 @@ static void parse_ddi_port(struct drm_i915_private 
*dev_priv, enum port port,
return;
 
aux_channel = child-raw[25];
+   ddc_pin = child-common.ddc_pin;
 
is_dvi = child-common.device_type  DEVICE_TYPE_TMDS_DVI_SIGNALING;
is_dp = child-common.device_type  DEVICE_TYPE_DISPLAYPORT_OUTPUT;
@@ -959,11 +960,27 @@ static void parse_ddi_port(struct drm_i915_private 
*dev_priv, enum port port,
DRM_DEBUG_KMS(Port %c is internal DP\n, port_name(port));
 
if (is_dvi) {
-   if (child-common.ddc_pin == 0x05  port != PORT_B)
+   if (port == PORT_E) {
+   info-alternate_ddc_pin = ddc_pin;
+   /* if DDIE share ddc pin with other port, then
+* dvi/hdmi couldn't exist on the shared port.
+* Otherwise they share the same ddc bin and system
+* couldn't communicate with them seperately. */
+   if (ddc_pin == DDC_PIN_B) {
+   
dev_priv-vbt.ddi_port_info[PORT_B].supports_dvi = 0;
+   
dev_priv-vbt.ddi_port_info[PORT_B].supports_hdmi = 0;
+   } else if (ddc_pin == DDC_PIN_C) {
+   
dev_priv-vbt.ddi_port_info[PORT_C].supports_dvi = 0;
+   
dev_priv-vbt.ddi_port_info[PORT_C].supports_hdmi = 0;
+   } else if (ddc_pin == DDC_PIN_D) {
+   
dev_priv-vbt.ddi_port_info[PORT_D].supports_dvi = 0;
+   
dev_priv-vbt.ddi_port_info[PORT_D].supports_hdmi = 0;
+   }
+   } else if (ddc_pin == DDC_PIN_B  port != PORT_B)
DRM_DEBUG_KMS(Unexpected DDC pin for port B\n);
-   if (child-common.ddc_pin == 0x04  port != PORT_C)
+   else if (ddc_pin == DDC_PIN_C  port != PORT_C)
DRM_DEBUG_KMS(Unexpected DDC pin for port C\n);
-   if (child-common.ddc_pin == 0x06  port != PORT_D)
+   else if (ddc_pin == DDC_PIN_D  port != PORT_D)
DRM_DEBUG_KMS(Unexpected DDC pin for port D\n);
}
 
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 70bad5b..a4129f2 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1991,6 +1991,24 @@ void intel_hdmi_init_connector(struct intel_digital_port 
*intel_dig_port,
intel_hdmi-ddc_bus = GMBUS_PIN_DPD;
intel_encoder-hpd_pin = HPD_PORT_D;
break;
+   case PORT_E:
+   /* On SKL PORT E doesn't have seperate GMBUS pin
+*  We rely on VBT to set a proper alternate GMBUS pin. */
+   switch (dev_priv-vbt.ddi_port_info[PORT_E].alternate_ddc_pin) {
+   case DDC_PIN_B:
+   intel_hdmi-ddc_bus = GMBUS_PIN_DPB;
+   break;
+   

Re: [Intel-gfx] [PATCH 6/6 v3] drm/i915: Enable HDMI on DDI-E

2015-08-12 Thread Daniel Vetter
On Wed, Aug 12, 2015 at 06:39:34PM +0800, Xiong Zhang wrote:
 DDI-E doesn't have the correspondent GMBUS pin.
 
 We rely on VBT to tell us which one it being used instead.
 
 The DVI/HDMI on shared port couldn't exist.
 
 This patch isn't tested without hardware wchich has HDMI
 on DDI-E.
 
 v2: fix trailing whitespace
 v3: WARN() take place of BUG()

I asked for MISSING_CASE, not WARN.
-Daniel

 
 Signed-off-by: Xiong Zhang xiong.y.zh...@intel.com
 Reviewed-by: Rodrigo Vivi rodrigo.v...@intel.com
 ---
  drivers/gpu/drm/i915/i915_drv.h   |  5 +
  drivers/gpu/drm/i915/intel_bios.c | 25 +
  drivers/gpu/drm/i915/intel_hdmi.c | 18 ++
  3 files changed, 44 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
 index 6d93334..5d8e7fe 100644
 --- a/drivers/gpu/drm/i915/i915_drv.h
 +++ b/drivers/gpu/drm/i915/i915_drv.h
 @@ -1414,6 +1414,10 @@ enum modeset_restore {
  #define DP_AUX_C 0x20
  #define DP_AUX_D 0x30
  
 +#define DDC_PIN_B  0x05
 +#define DDC_PIN_C  0x04
 +#define DDC_PIN_D  0x06
 +
  struct ddi_vbt_port_info {
   /*
* This is an index in the HDMI/DVI DDI buffer translation table.
 @@ -1428,6 +1432,7 @@ struct ddi_vbt_port_info {
   uint8_t supports_dp:1;
  
   uint8_t alternate_aux_channel;
 + uint8_t alternate_ddc_pin;
  };
  
  enum psr_lines_to_wait {
 diff --git a/drivers/gpu/drm/i915/intel_bios.c 
 b/drivers/gpu/drm/i915/intel_bios.c
 index 16cdf17..8140531 100644
 --- a/drivers/gpu/drm/i915/intel_bios.c
 +++ b/drivers/gpu/drm/i915/intel_bios.c
 @@ -894,7 +894,7 @@ static void parse_ddi_port(struct drm_i915_private 
 *dev_priv, enum port port,
   uint8_t hdmi_level_shift;
   int i, j;
   bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
 - uint8_t aux_channel;
 + uint8_t aux_channel, ddc_pin;
   /* Each DDI port can have more than one value on the DVO Port field,
* so look for all the possible values for each port and abort if more
* than one is found. */
 @@ -928,6 +928,7 @@ static void parse_ddi_port(struct drm_i915_private 
 *dev_priv, enum port port,
   return;
  
   aux_channel = child-raw[25];
 + ddc_pin = child-common.ddc_pin;
  
   is_dvi = child-common.device_type  DEVICE_TYPE_TMDS_DVI_SIGNALING;
   is_dp = child-common.device_type  DEVICE_TYPE_DISPLAYPORT_OUTPUT;
 @@ -959,11 +960,27 @@ static void parse_ddi_port(struct drm_i915_private 
 *dev_priv, enum port port,
   DRM_DEBUG_KMS(Port %c is internal DP\n, port_name(port));
  
   if (is_dvi) {
 - if (child-common.ddc_pin == 0x05  port != PORT_B)
 + if (port == PORT_E) {
 + info-alternate_ddc_pin = ddc_pin;
 + /* if DDIE share ddc pin with other port, then
 +  * dvi/hdmi couldn't exist on the shared port.
 +  * Otherwise they share the same ddc bin and system
 +  * couldn't communicate with them seperately. */
 + if (ddc_pin == DDC_PIN_B) {
 + 
 dev_priv-vbt.ddi_port_info[PORT_B].supports_dvi = 0;
 + 
 dev_priv-vbt.ddi_port_info[PORT_B].supports_hdmi = 0;
 + } else if (ddc_pin == DDC_PIN_C) {
 + 
 dev_priv-vbt.ddi_port_info[PORT_C].supports_dvi = 0;
 + 
 dev_priv-vbt.ddi_port_info[PORT_C].supports_hdmi = 0;
 + } else if (ddc_pin == DDC_PIN_D) {
 + 
 dev_priv-vbt.ddi_port_info[PORT_D].supports_dvi = 0;
 + 
 dev_priv-vbt.ddi_port_info[PORT_D].supports_hdmi = 0;
 + }
 + } else if (ddc_pin == DDC_PIN_B  port != PORT_B)
   DRM_DEBUG_KMS(Unexpected DDC pin for port B\n);
 - if (child-common.ddc_pin == 0x04  port != PORT_C)
 + else if (ddc_pin == DDC_PIN_C  port != PORT_C)
   DRM_DEBUG_KMS(Unexpected DDC pin for port C\n);
 - if (child-common.ddc_pin == 0x06  port != PORT_D)
 + else if (ddc_pin == DDC_PIN_D  port != PORT_D)
   DRM_DEBUG_KMS(Unexpected DDC pin for port D\n);
   }
  
 diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
 b/drivers/gpu/drm/i915/intel_hdmi.c
 index 70bad5b..a4129f2 100644
 --- a/drivers/gpu/drm/i915/intel_hdmi.c
 +++ b/drivers/gpu/drm/i915/intel_hdmi.c
 @@ -1991,6 +1991,24 @@ void intel_hdmi_init_connector(struct 
 intel_digital_port *intel_dig_port,
   intel_hdmi-ddc_bus = GMBUS_PIN_DPD;
   intel_encoder-hpd_pin = HPD_PORT_D;
   break;
 + case PORT_E:
 + /* On SKL PORT E doesn't have seperate GMBUS pin
 +  *  We rely on VBT to set a proper alternate GMBUS pin. */
 + switch (dev_priv-vbt.ddi_port_info[PORT_E].alternate_ddc_pin) {
 + case