Re: [Intel-gfx] [PATCH] drm/i915: use the new hdmi_force_audio enum more

2012-02-24 Thread Wu Fengguang
On Thu, Feb 23, 2012 at 05:14:47PM +0100, Daniel Vetter wrote:
 While fixing up a merge conflict with drm-next I've noticed that we
 use the same audio drm connector property also for dp and sdvo
 outputs.
 
 So put the new enum to some good use and convert these paths, too. The
 HDMI_AUDIO_ prefix is a bit a misnomer. But at least for sdvo it makes
 sense (and you can also connect a hdmi monitor with a dp-hdmi cable),
 so I've decided to stick with it.
 
 Cc: Wu Fengguang fengguang...@intel.com
 Signed-Off-by: Daniel Vetter daniel.vet...@ffwll.ch

Reviewed-by: Wu Fengguang fengguang...@intel.com

Thanks!

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


Re: [Intel-gfx] [PATCH] drm/i915: add a force-dvi HDMI audio mode

2012-02-13 Thread Wu Fengguang
On Mon, Feb 13, 2012 at 08:22:01PM +0100, Daniel Vetter wrote:
 On Wed, Feb 08, 2012 at 10:48:20AM +0800, Wu Fengguang wrote:
  When HDMI-DVI converter is used, it's not only necessary to turn off
  audio, but also to disable HDMI_MODE_SELECT and video infoframe. Since
  the DVI mode is mainly tied to audio functionality from end user POV,
  add a new force-dvi audio mode:
  
  xrandr --output HDMI1 --set audio force-dvi
  
  Note that most users won't need to set this and happily rely on the
  EDID based DVI auto detection.
  
  Reported-by: Andrea Arcangeli aarca...@redhat.com
  Signed-off-by: Wu Fengguang fengguang...@intel.com
 
 Jesse acked this patch on irc, but I've noticed a few little things. See
 below for the details.

OK, thanks!

  --- linux-next.orig/drivers/gpu/drm/i915/intel_hdmi.c   2012-01-07 
  20:47:34.0 +0800
  +++ linux-next/drivers/gpu/drm/i915/intel_hdmi.c2012-02-08 
  10:37:30.0 +0800
  @@ -339,7 +339,9 @@ intel_hdmi_detect(struct drm_connector *
  if (edid) {
  if (edid-input  DRM_EDID_INPUT_DIGITAL) {
  status = connector_status_connected;
  -   intel_hdmi-has_hdmi_sink = 
  drm_detect_hdmi_monitor(edid);
  +   if (intel_hdmi-force_audio != HDMI_AUDIO_OFF_DVI)
  +   intel_hdmi-has_hdmi_sink =
  +   drm_detect_hdmi_monitor(edid);
  intel_hdmi-has_audio = drm_detect_monitor_audio(edid);
  }
  connector-display_info.raw_edid = NULL;
  @@ -415,8 +417,8 @@ intel_hdmi_set_property(struct drm_conne
  else
  has_audio = i  0;
 
 All these comparison with i use magic values instead of your new enum
 definitions. Can you replace these with the enums like you've done below,
 i.e. for the above if block:
 
   if (i == HDMI_AUDIO_AUOT)
   ...
   else if (i == HDMI_AUDIO_ON)
   has_audio = true;

Done.

 intel_hdmi_detect is also a place that checks these values (with
 intel_hdmi-force_audio) - please use the enum values there, too. Also
 please change the type of intel_hdmi-force_audio from int to the enum.

Done.

 Another thing I've noticed is that in intel_hdmi_detect you don't force
 has_hdmi_sink to false if the force_dvi option is set.

It's implicitly initialized to false at the beginning. Isn't that enough?

Updated patch follows. Compile tested.

Thanks,
Fengguang
---
Subject: drm/i915: add an force-dvi HDMI audio mode
Date: Fri Jan 06 11:04:00 CST 2012

When HDMI-DVI converter is used, it's not only necessary to turn off
audio, but also to disable HDMI_MODE_SELECT and video infoframe. Since
the DVI mode is mainly tied to audio functionality from end user POV,
add a new force-dvi audio mode:

xrandr --output HDMI1 --set audio force-dvi

Note that most users won't need to set this and happily rely on the EDID
based DVI auto detection.

Reported-by: Andrea Arcangeli aarca...@redhat.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_drv.h|7 +++
 drivers/gpu/drm/i915/intel_hdmi.c  |   21 -
 drivers/gpu/drm/i915/intel_modes.c |4 +++-
 3 files changed, 22 insertions(+), 10 deletions(-)

--- linux-next.orig/drivers/gpu/drm/i915/i915_drv.h 2012-02-08 
18:44:59.0 +0800
+++ linux-next/drivers/gpu/drm/i915/i915_drv.h  2012-02-14 11:21:03.0 
+0800
@@ -749,6 +749,13 @@ typedef struct drm_i915_private {
struct drm_property *force_audio_property;
 } drm_i915_private_t;
 
+enum hdmi_force_audio {
+   HDMI_AUDIO_OFF_DVI = -2,/* no aux data for HDMI-DVI converter */
+   HDMI_AUDIO_OFF, /* force turn off HDMI audio */
+   HDMI_AUDIO_AUTO,/* trust EDID */
+   HDMI_AUDIO_ON,  /* force turn on HDMI audio */
+};
+
 enum i915_cache_level {
I915_CACHE_NONE,
I915_CACHE_LLC,
--- linux-next.orig/drivers/gpu/drm/i915/intel_hdmi.c   2012-02-08 
18:44:59.0 +0800
+++ linux-next/drivers/gpu/drm/i915/intel_hdmi.c2012-02-14 
11:25:16.0 +0800
@@ -44,7 +44,7 @@ struct intel_hdmi {
uint32_t color_range;
bool has_hdmi_sink;
bool has_audio;
-   int force_audio;
+   enum hdmi_force_audio force_audio;
void (*write_infoframe)(struct drm_encoder *encoder,
struct dip_infoframe *frame);
 };
@@ -339,7 +339,9 @@ intel_hdmi_detect(struct drm_connector *
if (edid) {
if (edid-input  DRM_EDID_INPUT_DIGITAL) {
status = connector_status_connected;
-   intel_hdmi-has_hdmi_sink = 
drm_detect_hdmi_monitor(edid);
+   if (intel_hdmi-force_audio != HDMI_AUDIO_OFF_DVI)
+   intel_hdmi-has_hdmi_sink

[Intel-gfx] [PATCH] drm/i915: add a force-dvi HDMI audio mode

2012-02-07 Thread Wu Fengguang
When HDMI-DVI converter is used, it's not only necessary to turn off
audio, but also to disable HDMI_MODE_SELECT and video infoframe. Since
the DVI mode is mainly tied to audio functionality from end user POV,
add a new force-dvi audio mode:

xrandr --output HDMI1 --set audio force-dvi

Note that most users won't need to set this and happily rely on the
EDID based DVI auto detection.

Reported-by: Andrea Arcangeli aarca...@redhat.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_drv.h|7 +++
 drivers/gpu/drm/i915/intel_hdmi.c  |8 +---
 drivers/gpu/drm/i915/intel_modes.c |4 +++-
 3 files changed, 15 insertions(+), 4 deletions(-)

--- linux-next.orig/drivers/gpu/drm/i915/i915_drv.h 2012-01-31 
20:44:59.0 +0800
+++ linux-next/drivers/gpu/drm/i915/i915_drv.h  2012-02-08 10:37:30.0 
+0800
@@ -749,6 +749,13 @@ typedef struct drm_i915_private {
struct drm_property *force_audio_property;
 } drm_i915_private_t;
 
+enum hdmi_force_audio {
+   HDMI_AUDIO_OFF_DVI = -2,/* no aux data for HDMI-DVI converter */
+   HDMI_AUDIO_OFF, /* force turn off HDMI audio */
+   HDMI_AUDIO_AUTO,/* trust EDID */
+   HDMI_AUDIO_ON,  /* force turn on HDMI audio */
+};
+
 enum i915_cache_level {
I915_CACHE_NONE,
I915_CACHE_LLC,
--- linux-next.orig/drivers/gpu/drm/i915/intel_hdmi.c   2012-01-07 
20:47:34.0 +0800
+++ linux-next/drivers/gpu/drm/i915/intel_hdmi.c2012-02-08 
10:37:30.0 +0800
@@ -339,7 +339,9 @@ intel_hdmi_detect(struct drm_connector *
if (edid) {
if (edid-input  DRM_EDID_INPUT_DIGITAL) {
status = connector_status_connected;
-   intel_hdmi-has_hdmi_sink = 
drm_detect_hdmi_monitor(edid);
+   if (intel_hdmi-force_audio != HDMI_AUDIO_OFF_DVI)
+   intel_hdmi-has_hdmi_sink =
+   drm_detect_hdmi_monitor(edid);
intel_hdmi-has_audio = drm_detect_monitor_audio(edid);
}
connector-display_info.raw_edid = NULL;
@@ -415,8 +417,8 @@ intel_hdmi_set_property(struct drm_conne
else
has_audio = i  0;
 
-   if (has_audio == intel_hdmi-has_audio)
-   return 0;
+   if (i == HDMI_AUDIO_OFF_DVI)
+   intel_hdmi-has_hdmi_sink = 0;
 
intel_hdmi-has_audio = has_audio;
goto done;
--- linux-next.orig/drivers/gpu/drm/i915/intel_modes.c  2011-10-19 
11:11:20.0 +0800
+++ linux-next/drivers/gpu/drm/i915/intel_modes.c   2012-02-08 
10:37:30.0 +0800
@@ -84,6 +84,7 @@ int intel_ddc_get_modes(struct drm_conne
 }
 
 static const char *force_audio_names[] = {
+   force-dvi,
off,
auto,
on,
@@ -106,7 +107,8 @@ intel_attach_force_audio_property(struct
return;
 
for (i = 0; i  ARRAY_SIZE(force_audio_names); i++)
-   drm_property_add_enum(prop, i, i-1, 
force_audio_names[i]);
+   drm_property_add_enum(prop, i, i-2,
+ force_audio_names[i]);
 
dev_priv-force_audio_property = prop;
}
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH][rebased] drm/i915: set AUD_CONFIG N_value_index for DisplayPort

2012-01-29 Thread Wu Fengguang
  Daniel, this is now based on linux-next. I use quilt, hope it also
  works for you :)
 
 On a quick check this patch is missing the hunk to actually write the
 aud configuration into the register. I presume that's not intentional,
 so can you please resend?

This is weird, my outbox has the below chunk. Anyway here is the
attached patch.

@@ -6107,7 +6111,9 @@ static void ironlake_write_eld(struct dr
if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
-   }
+   I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
+   } else
+   I915_WRITE(aud_config, 0);

Thanks,
Fengguang
Subject: drm/i915: set AUD_CONFIG N_value_index for DisplayPort
Date: Fri Jan 06 14:41:31 CST 2012

It should be programmed to 0 for HDMI or 1 for DisplayPort.

This enables DisplayPort audio for

- HP EliteBook 8460p
  (whose BIOS does not set the N_value_index bit for us)

- DisplayPort monitor hot plugged after boot
  (otherwise most BIOS will fill the N_value_index bit for us)

Tested-by: Robert Lemaire rlema...@suse.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |   12 
 drivers/gpu/drm/i915/intel_display.c |8 +++-
 2 files changed, 19 insertions(+), 1 deletion(-)

--- linux-next.orig/drivers/gpu/drm/i915/i915_reg.h	2012-01-07 20:47:34.0 +0800
+++ linux-next/drivers/gpu/drm/i915/i915_reg.h	2012-01-29 12:37:31.0 +0800
@@ -3742,4 +3742,16 @@
  */
 #define GEN7_SO_WRITE_OFFSET(n)		(0x5280 + (n) * 4)
 
+#define IBX_AUD_CONFIG_A			0xe2000
+#define CPT_AUD_CONFIG_A			0xe5000
+#define   AUD_CONFIG_N_VALUE_INDEX		(1  29)
+#define   AUD_CONFIG_N_PROG_ENABLE		(1  28)
+#define   AUD_CONFIG_UPPER_N_SHIFT		20
+#define   AUD_CONFIG_UPPER_N_VALUE		(0xff  20)
+#define   AUD_CONFIG_LOWER_N_SHIFT		4
+#define   AUD_CONFIG_LOWER_N_VALUE		(0xfff  4)
+#define   AUD_CONFIG_PIXEL_CLOCK_HDMI_SHIFT	16
+#define   AUD_CONFIG_PIXEL_CLOCK_HDMI		(0xf  16)
+#define   AUD_CONFIG_DISABLE_NCTS		(1  3)
+
 #endif /* _I915_REG_H_ */
--- linux-next.orig/drivers/gpu/drm/i915/intel_display.c	2012-01-29 12:23:17.0 +0800
+++ linux-next/drivers/gpu/drm/i915/intel_display.c	2012-01-29 12:37:31.0 +0800
@@ -6072,15 +6072,18 @@ static void ironlake_write_eld(struct dr
 	uint32_t i;
 	int len;
 	int hdmiw_hdmiedid;
+	int aud_config;
 	int aud_cntl_st;
 	int aud_cntrl_st2;
 
 	if (HAS_PCH_IBX(connector-dev)) {
 		hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID_A;
+		aud_config = IBX_AUD_CONFIG_A;
 		aud_cntl_st = IBX_AUD_CNTL_ST_A;
 		aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
 	} else {
 		hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
+		aud_config = CPT_AUD_CONFIG_A;
 		aud_cntl_st = CPT_AUD_CNTL_ST_A;
 		aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
 	}
@@ -6088,6 +6091,7 @@ static void ironlake_write_eld(struct dr
 	i = to_intel_crtc(crtc)-pipe;
 	hdmiw_hdmiedid += i * 0x100;
 	aud_cntl_st += i * 0x100;
+	aud_config += i * 0x100;
 
 	DRM_DEBUG_DRIVER(ELD on pipe %c\n, pipe_name(i));
 
@@ -6107,7 +6111,9 @@ static void ironlake_write_eld(struct dr
 	if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
 		DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
 		eld[5] |= (1  2);	/* Conn_Type, 0x1 = DisplayPort */
-	}
+		I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
+	} else
+		I915_WRITE(aud_config, 0);
 
 	if (intel_eld_uptodate(connector,
 			   aud_cntrl_st2, eldv,
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH][rebased] drm/i915: set AUD_CONFIG N_value_index for DisplayPort

2012-01-28 Thread Wu Fengguang
It should be programmed to 0 for HDMI or 1 for DisplayPort.

This enables DisplayPort audio for

- HP EliteBook 8460p
  (whose BIOS does not set the N_value_index bit for us)

- DisplayPort monitor hot plugged after boot
  (otherwise most BIOS will fill the N_value_index bit for us)

Tested-by: Robert Lemaire rlema...@suse.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |   12 
 drivers/gpu/drm/i915/intel_display.c |8 +++-
 2 files changed, 19 insertions(+), 1 deletion(-)
 
 I've tried to apply this patch but it has a conflict in i915_reg.h (with
 the SOL reset stuff). Care to rebase and resend? Also, git patches as
 produced by git format-patch highly preferred.

Daniel, this is now based on linux-next. I use quilt, hope it also
works for you :)

--- linux-next.orig/drivers/gpu/drm/i915/i915_reg.h 2012-01-07 
20:47:34.0 +0800
+++ linux-next/drivers/gpu/drm/i915/i915_reg.h  2012-01-29 12:37:31.0 
+0800
@@ -3742,4 +3742,16 @@
  */
 #define GEN7_SO_WRITE_OFFSET(n)(0x5280 + (n) * 4)
 
+#define IBX_AUD_CONFIG_A   0xe2000
+#define CPT_AUD_CONFIG_A   0xe5000
+#define   AUD_CONFIG_N_VALUE_INDEX (1  29)
+#define   AUD_CONFIG_N_PROG_ENABLE (1  28)
+#define   AUD_CONFIG_UPPER_N_SHIFT 20
+#define   AUD_CONFIG_UPPER_N_VALUE (0xff  20)
+#define   AUD_CONFIG_LOWER_N_SHIFT 4
+#define   AUD_CONFIG_LOWER_N_VALUE (0xfff  4)
+#define   AUD_CONFIG_PIXEL_CLOCK_HDMI_SHIFT16
+#define   AUD_CONFIG_PIXEL_CLOCK_HDMI  (0xf  16)
+#define   AUD_CONFIG_DISABLE_NCTS  (1  3)
+
 #endif /* _I915_REG_H_ */
--- linux-next.orig/drivers/gpu/drm/i915/intel_display.c2012-01-29 
12:23:17.0 +0800
+++ linux-next/drivers/gpu/drm/i915/intel_display.c 2012-01-29 
12:37:31.0 +0800
@@ -6072,15 +6072,18 @@ static void ironlake_write_eld(struct dr
uint32_t i;
int len;
int hdmiw_hdmiedid;
+   int aud_config;
int aud_cntl_st;
int aud_cntrl_st2;
 
if (HAS_PCH_IBX(connector-dev)) {
hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID_A;
+   aud_config = IBX_AUD_CONFIG_A;
aud_cntl_st = IBX_AUD_CNTL_ST_A;
aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
} else {
hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
+   aud_config = CPT_AUD_CONFIG_A;
aud_cntl_st = CPT_AUD_CNTL_ST_A;
aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
}
@@ -6088,6 +6091,7 @@ static void ironlake_write_eld(struct dr
i = to_intel_crtc(crtc)-pipe;
hdmiw_hdmiedid += i * 0x100;
aud_cntl_st += i * 0x100;
+   aud_config += i * 0x100;
 
DRM_DEBUG_DRIVER(ELD on pipe %c\n, pipe_name(i));
 
@@ -6107,7 +6111,9 @@ static void ironlake_write_eld(struct dr
if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
-   }
+   I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
+   } else
+   I915_WRITE(aud_config, 0);
 
if (intel_eld_uptodate(connector,
   aud_cntrl_st2, eldv,
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: set AUD_CONFIG N_value_index for DisplayPort

2012-01-16 Thread Wu Fengguang
On Thu, Jan 12, 2012 at 09:33:34AM -0800, Keith Packard wrote:
 On Tue, 10 Jan 2012 13:45:19 +0800, Wu Fengguang fengguang...@intel.com 
 wrote:
 
  @@ -5943,6 +5947,7 @@ static void ironlake_write_eld(struct dr
  if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
  DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
  eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
  +   I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
  }
 
 Do we need to clear this bit in the HDMI case? Or do we just trust the
 BIOS to either leave this bit zero or set it correctly?

I tried booting

1) with HDMI monitor plugged
2) plug HDMI monitor after BIOS boot

In both cases, I get the same AUD_CONFIG values for the host/sink matrix

RX-V1800SONY TV
ivybridge   0x  0x
ironlake0x  0x

HDMI audio is working fine in all cases. So I guess it's fine to leave
HDMI as (unconfigured) 0.

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


Re: [Intel-gfx] [PATCH] drm/i915: set AUD_CONFIG N_value_index for DisplayPort

2012-01-16 Thread Wu Fengguang
On Mon, Jan 16, 2012 at 12:44:43PM -0800, Keith Packard wrote:
 On Mon, 16 Jan 2012 21:26:18 +0100, Daniel Vetter dan...@ffwll.ch wrote:
 
  Keith, does this address your concern and this patch is r-b: Keith or do
  we want an
  
  } else {
  I915_WRITE(aud_config, 0);
  }
  
  for paranoia?
 
 I think we want this added, just to be sure we set the configuration
 correctly in all cases; it's easy to imagine moving from DP to HDMI and
 leaving this bit set.

Ah good point! Here is the updated patch.

---
Subject: drm/i915: set AUD_CONFIG N_value_index for DisplayPort
Date: Fri Jan 06 14:41:31 CST 2012

It should be programmed to 0 for HDMI or 1 for DisplayPort.

This enables DisplayPort audio for

- HP EliteBook 8460p
  (whose BIOS does not set the N_value_index bit for us)

- DisplayPort monitor hot plugged after boot
  (otherwise most BIOS will fill the N_value_index bit for us)

Tested-by: Robert Lemaire rlema...@suse.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |   12 
 drivers/gpu/drm/i915/intel_display.c |8 +++-
 2 files changed, 19 insertions(+), 1 deletion(-)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2012-01-07 23:11:10.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2012-01-10 13:20:17.0 
+0800
@@ -3582,4 +3582,16 @@
 #define CPT_AUD_CNTL_ST_A  0xE50B4
 #define CPT_AUD_CNTRL_ST2  0xE50C0
 
+#define IBX_AUD_CONFIG_A   0xe2000
+#define CPT_AUD_CONFIG_A   0xe5000
+#define   AUD_CONFIG_N_VALUE_INDEX (1  29)
+#define   AUD_CONFIG_N_PROG_ENABLE (1  28)
+#define   AUD_CONFIG_UPPER_N_SHIFT 20
+#define   AUD_CONFIG_UPPER_N_VALUE (0xff  20)
+#define   AUD_CONFIG_LOWER_N_SHIFT 4
+#define   AUD_CONFIG_LOWER_N_VALUE (0xfff  4)
+#define   AUD_CONFIG_PIXEL_CLOCK_HDMI_SHIFT16
+#define   AUD_CONFIG_PIXEL_CLOCK_HDMI  (0xf  16)
+#define   AUD_CONFIG_DISABLE_NCTS  (1  3)
+
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2012-01-07 
23:11:10.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2012-01-17 07:06:29.0 
+0800
@@ -5908,15 +5908,18 @@ static void ironlake_write_eld(struct dr
uint32_t i;
int len;
int hdmiw_hdmiedid;
+   int aud_config;
int aud_cntl_st;
int aud_cntrl_st2;
 
if (HAS_PCH_IBX(connector-dev)) {
hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID_A;
+   aud_config = IBX_AUD_CONFIG_A;
aud_cntl_st = IBX_AUD_CNTL_ST_A;
aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
} else {
hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
+   aud_config = CPT_AUD_CONFIG_A;
aud_cntl_st = CPT_AUD_CNTL_ST_A;
aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
}
@@ -5924,6 +5927,7 @@ static void ironlake_write_eld(struct dr
i = to_intel_crtc(crtc)-pipe;
hdmiw_hdmiedid += i * 0x100;
aud_cntl_st += i * 0x100;
+   aud_config += i * 0x100;
 
DRM_DEBUG_DRIVER(ELD on pipe %c\n, pipe_name(i));
 
@@ -5943,7 +5947,9 @@ static void ironlake_write_eld(struct dr
if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
-   }
+   I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
+   } else
+   I915_WRITE(aud_config, 0);
 
if (intel_eld_uptodate(connector,
   aud_cntrl_st2, eldv,
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 1/2] intel_audio_dump: fix missing Audio DIP tabs

2012-01-16 Thread Wu Fengguang
This makes the SNB/IVY Audio DIP values aligned with others.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2012-01-16 
15:33:11.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2012-01-16 15:33:18.0 
+0800
@@ -1207,7 +1207,7 @@ static void dump_cpt(void)
 dword = INREG(AUD_CNTL_ST_A);
 printf(AUD_CNTL_ST_A  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
BITS(dword, 30, 29), 
dip_port[BITS(dword, 30, 29)]);
-printf(AUD_CNTL_ST_A  DIP_type_enable_status Audio DIP\t%lu\n, 
BIT(dword, 21));
+printf(AUD_CNTL_ST_A  DIP_type_enable_status Audio DIP\t\t%lu\n, 
BIT(dword, 21));
 printf(AUD_CNTL_ST_A  DIP_type_enable_status ACP DIP\t\t%lu\n, 
BIT(dword, 22));
 printf(AUD_CNTL_ST_A  DIP_type_enable_status Generic 2 DIP\t%lu\n, 
BIT(dword, 23));
 printf(AUD_CNTL_ST_A  DIP_transmission_frequency\t\t[0x%lx] %s\n,
@@ -1218,7 +1218,7 @@ static void dump_cpt(void)
 dword = INREG(AUD_CNTL_ST_B);
 printf(AUD_CNTL_ST_B  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
BITS(dword, 30, 29), 
dip_port[BITS(dword, 30, 29)]);
-printf(AUD_CNTL_ST_B  DIP_type_enable_status Audio DIP\t%lu\n, 
BIT(dword, 21));
+printf(AUD_CNTL_ST_B  DIP_type_enable_status Audio DIP\t\t%lu\n, 
BIT(dword, 21));
 printf(AUD_CNTL_ST_B  DIP_type_enable_status ACP DIP\t\t%lu\n, 
BIT(dword, 22));
 printf(AUD_CNTL_ST_B  DIP_type_enable_status Generic 2 DIP\t%lu\n, 
BIT(dword, 23));
 printf(AUD_CNTL_ST_B  DIP_transmission_frequency\t\t[0x%lx] %s\n,
@@ -1229,7 +1229,7 @@ static void dump_cpt(void)
 dword = INREG(AUD_CNTL_ST_C);
 printf(AUD_CNTL_ST_C  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
BITS(dword, 30, 29), 
dip_port[BITS(dword, 30, 29)]);
-printf(AUD_CNTL_ST_C  DIP_type_enable_status Audio DIP\t%lu\n, 
BIT(dword, 21));
+printf(AUD_CNTL_ST_C  DIP_type_enable_status Audio DIP\t\t%lu\n, 
BIT(dword, 21));
 printf(AUD_CNTL_ST_C  DIP_type_enable_status ACP DIP\t\t%lu\n, 
BIT(dword, 22));
 printf(AUD_CNTL_ST_C  DIP_type_enable_status Generic 2 DIP\t%lu\n, 
BIT(dword, 23));
 printf(AUD_CNTL_ST_C  DIP_transmission_frequency\t\t[0x%lx] %s\n,
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 2/2] intel_audio_dump: show more AUD_CONFIG bits

2012-01-16 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   35 +++
 1 file changed, 35 insertions(+)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2012-01-16 
15:33:18.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2012-01-16 16:13:08.0 
+0800
@@ -168,6 +168,11 @@ static const char *sdvo_hdmi_encoding[] 
[3] = reserved,
 };
 
+static const char *n_index_value[] = {
+   [0] = HDMI,
+   [1] = DisplayPort,
+};
+
 static void do_self_tests(void)
 {
 if (BIT(1, 0) != 1)
@@ -627,11 +632,23 @@ static void dump_ironlake(void)
 printf(PCH_DP_D Audio_Output_Enable\t\t\t\t%lu\n, BIT(dword, 6));
 
 dword = INREG(AUD_CONFIG_A);
+printf(AUD_CONFIG_A  N_index_value\t\t\t\t[0x%lx] %s\n, BIT(dword, 29),
+   n_index_value[BIT(dword, 29)]);
+printf(AUD_CONFIG_A  N_programming_enable\t\t\t%lu\n, BIT(dword, 28));
+printf(AUD_CONFIG_A  Upper_N_value\t\t\t\t0x%02lx\n, BITS(dword, 27, 
20));
+printf(AUD_CONFIG_A  Lower_N_value\t\t\t\t0x%03lx\n, BITS(dword, 15, 4));
 printf(AUD_CONFIG_A  Pixel_Clock\t\t\t\t[0x%lx] %s\n, BITS(dword, 19, 
16),
OPNAME(pixel_clock, BITS(dword, 19, 16)));
+printf(AUD_CONFIG_A  Disable_NCTS\t\t\t\t%lu\n, BIT(dword, 3));
 dword = INREG(AUD_CONFIG_B);
+printf(AUD_CONFIG_B  N_index_value\t\t\t\t[0x%lx] %s\n, BIT(dword, 29),
+   n_index_value[BIT(dword, 29)]);
+printf(AUD_CONFIG_B  N_programming_enable\t\t\t%lu\n, BIT(dword, 28));
+printf(AUD_CONFIG_B  Upper_N_value\t\t\t\t0x%02lx\n, BITS(dword, 27, 
20));
+printf(AUD_CONFIG_B  Lower_N_value\t\t\t\t0x%03lx\n, BITS(dword, 15, 4));
 printf(AUD_CONFIG_B  Pixel_Clock\t\t\t\t[0x%lx] %s\n, BITS(dword, 19, 
16),
OPNAME(pixel_clock, BITS(dword, 19, 16)));
+printf(AUD_CONFIG_B  Disable_NCTS\t\t\t\t%lu\n, BIT(dword, 3));
 
 dword = INREG(AUD_CTS_ENABLE_A);
 printf(AUD_CTS_ENABLE_A  Enable_CTS_or_M_programming\t\t%lu\n, 
BIT(dword, 20));
@@ -1063,14 +1080,32 @@ static void dump_cpt(void)
 printf(DP_CTL_D Audio_Output_Enable\t\t\t\t%lu\n, BIT(dword, 6));
 
 dword = INREG(AUD_CONFIG_A);
+printf(AUD_CONFIG_A  N_index_value\t\t\t\t[0x%lx] %s\n, BIT(dword, 29),
+   n_index_value[BIT(dword, 29)]);
+printf(AUD_CONFIG_A  N_programming_enable\t\t\t%lu\n, BIT(dword, 28));
+printf(AUD_CONFIG_A  Upper_N_value\t\t\t\t0x%02lx\n, BITS(dword, 27, 
20));
+printf(AUD_CONFIG_A  Lower_N_value\t\t\t\t0x%03lx\n, BITS(dword, 15, 4));
 printf(AUD_CONFIG_A  Pixel_Clock_HDMI\t\t\t\t[0x%lx] %s\n, BITS(dword, 
19, 16),
OPNAME(pixel_clock, BITS(dword, 19, 16)));
+printf(AUD_CONFIG_A  Disable_NCTS\t\t\t\t%lu\n, BIT(dword, 3));
 dword = INREG(AUD_CONFIG_B);
+printf(AUD_CONFIG_B  N_index_value\t\t\t\t[0x%lx] %s\n, BIT(dword, 29),
+   n_index_value[BIT(dword, 29)]);
+printf(AUD_CONFIG_B  N_programming_enable\t\t\t%lu\n, BIT(dword, 28));
+printf(AUD_CONFIG_B  Upper_N_value\t\t\t\t0x%02lx\n, BITS(dword, 27, 
20));
+printf(AUD_CONFIG_B  Lower_N_value\t\t\t\t0x%03lx\n, BITS(dword, 15, 4));
 printf(AUD_CONFIG_B  Pixel_Clock_HDMI\t\t\t\t[0x%lx] %s\n, BITS(dword, 
19, 16),
OPNAME(pixel_clock, BITS(dword, 19, 16)));
+printf(AUD_CONFIG_B  Disable_NCTS\t\t\t\t%lu\n, BIT(dword, 3));
 dword = INREG(AUD_CONFIG_C);
+printf(AUD_CONFIG_C  N_index_value\t\t\t\t[0x%lx] %s\n, BIT(dword, 29),
+   n_index_value[BIT(dword, 29)]);
+printf(AUD_CONFIG_C  N_programming_enable\t\t\t%lu\n, BIT(dword, 28));
+printf(AUD_CONFIG_C  Upper_N_value\t\t\t\t0x%02lx\n, BITS(dword, 27, 
20));
+printf(AUD_CONFIG_C  Lower_N_value\t\t\t\t0x%03lx\n, BITS(dword, 15, 4));
 printf(AUD_CONFIG_C  Pixel_Clock_HDMI\t\t\t\t[0x%lx] %s\n, BITS(dword, 
19, 16),
OPNAME(pixel_clock, BITS(dword, 19, 16)));
+printf(AUD_CONFIG_C  Disable_NCTS\t\t\t\t%lu\n, BIT(dword, 3));
 
 dword = INREG(AUD_CTS_ENABLE_A);
 printf(AUD_CTS_ENABLE_A  Enable_CTS_or_M_programming\t\t%lu\n, 
BIT(dword, 20));
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: add an off-dvi HDMI audio mode

2012-01-10 Thread Wu Fengguang
On Sat, Jan 07, 2012 at 09:39:19PM +0800, Wu Fengguang wrote:
 On Fri, Jan 06, 2012 at 07:08:33AM -0800, Jesse Barnes wrote:
  On Fri, 6 Jan 2012 11:26:40 +0800
  Wu Fengguang fengguang...@intel.com wrote:
  
   Andrea,
   
   Would you test this patch at convenient time?
   
   Thanks,
   Fengguang
   
   ---
   Subject: drm/i915: add an off-dvi HDMI audio mode
   Date: Fri Jan 06 11:04:00 CST 2012
   
   When HDMI-DVI converter is used, it's not only necessary to turn off
   audio, but also to disable HDMI_MODE_SELECT and video infoframe. Since
   the DVI mode is mainly tied to audio functionality from end user POV,
   add a new off-dvi audio mode:
   
 xrandr --output HDMI1 --set audio off-dvi
   
   Reported-by: Andrea Arcangeli aarca...@redhat.com
   Signed-off-by: Wu Fengguang fengguang...@intel.com
   ---
  
  My only complaint here is that off-dvi isn't an intuitive name.  We
  don't have any better way of detecting an HDMI-DVI converter with
  other EDID bits perhaps?
 
 We have 
 
 intel_hdmi-has_hdmi_sink = drm_detect_hdmi_monitor(edid);
 
 which _should_ auto detect HDMI/DVI connections.
 
 I guess Andrea ran into problem with that due to broken EDID. Anyway
 I'll try to test if that drm_detect_hdmi_monitor() will ever work for
 the HDMI/DVI monitors in my lab.

I verified that drm_detect_hdmi_monitor() at least works fine for me
when HDMIDVI converter is used:

[   12.567158] [drm:intel_hdmi_detect], has_hdmi_sink=0 has_audio=0 
force_audio=0

So it's probably Andrea's monitor sending the wrong EDID.

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


[Intel-gfx] [PATCH] drm/i915: set AUD_CONFIG N_value_index for DisplayPort

2012-01-09 Thread Wu Fengguang
It should be programmed to 0 for HDMI or 1 for DisplayPort.

This enables DisplayPort audio for

- HP EliteBook 8460p
  (whose BIOS does not set the N_value_index bit for us)

- DisplayPort monitor hot plugged after boot
  (otherwise most BIOS will fill the N_value_index bit for us)

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |3 +++
 drivers/gpu/drm/i915/intel_display.c |5 +
 2 files changed, 8 insertions(+)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2012-01-06 15:00:55.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2012-01-06 15:04:10.0 
+0800
@@ -3582,4 +3582,7 @@
 #define CPT_AUD_CNTL_ST_A  0xE50B4
 #define CPT_AUD_CNTRL_ST2  0xE50C0
 
+#define IBX_AUD_CONFIG_A   0xe2000
+#define CPT_AUD_CONFIG_A   0xe5000
+
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2012-01-06 
15:05:47.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2012-01-06 16:07:59.0 
+0800
@@ -5908,15 +5908,18 @@ static void ironlake_write_eld(struct dr
uint32_t i;
int len;
int hdmiw_hdmiedid;
+   int aud_config;
int aud_cntl_st;
int aud_cntrl_st2;
 
if (HAS_PCH_IBX(connector-dev)) {
hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID_A;
+   aud_config = IBX_AUD_CONFIG_A;
aud_cntl_st = IBX_AUD_CNTL_ST_A;
aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
} else {
hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
+   aud_config = CPT_AUD_CONFIG_A;
aud_cntl_st = CPT_AUD_CNTL_ST_A;
aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
}
@@ -5924,6 +5927,7 @@ static void ironlake_write_eld(struct dr
i = to_intel_crtc(crtc)-pipe;
hdmiw_hdmiedid += i * 0x100;
aud_cntl_st += i * 0x100;
+   aud_config += i * 0x100;
 
DRM_DEBUG_DRIVER(ELD on pipe %c\n, pipe_name(i));
 
@@ -5943,6 +5947,7 @@ static void ironlake_write_eld(struct dr
if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
+   I915_WRITE(aud_config, 1  29); /* N value index, 0x1 = DP */
}
 
if (intel_eld_uptodate(connector,
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: set AUD_CONFIG N_value_index for DisplayPort

2012-01-09 Thread Wu Fengguang
On Mon, Jan 09, 2012 at 09:22:47AM -0800, Keith Packard wrote:
 On Mon, 9 Jan 2012 21:17:17 +0800, Wu Fengguang fengguang...@intel.com 
 wrote:
 
  +#define IBX_AUD_CONFIG_A   0xe2000
  +#define CPT_AUD_CONFIG_A   0xe5000
 
 These register addresses match the docs.
 
  +   I915_WRITE(aud_config, 1  29); /* N value index, 0x1 = DP */
 
 Please don't use constants here, instead add #defines for all of the
 bits in this new register, in case someone else needs to use the
 register later.

OK. Updated patch to use macro as follows.

 Do we also need to program the pixel clock values in this register?

The pixel clock value is only for HDMI. I'd not touch this as long as
it works fine ;)

Thanks,
Fengguang
---
Subject: drm/i915: set AUD_CONFIG N_value_index for DisplayPort
Date: Fri Jan 06 14:41:31 CST 2012

It should be programmed to 0 for HDMI or 1 for DisplayPort.

This enables DisplayPort audio for

- HP EliteBook 8460p
  (whose BIOS does not set the N_value_index bit for us)

- DisplayPort monitor hot plugged after boot
  (otherwise most BIOS will fill the N_value_index bit for us)

Tested-by: Robert Lemaire rlema...@suse.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |   12 
 drivers/gpu/drm/i915/intel_display.c |5 +
 2 files changed, 17 insertions(+)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2012-01-07 23:11:10.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2012-01-10 13:20:17.0 
+0800
@@ -3582,4 +3582,16 @@
 #define CPT_AUD_CNTL_ST_A  0xE50B4
 #define CPT_AUD_CNTRL_ST2  0xE50C0
 
+#define IBX_AUD_CONFIG_A   0xe2000
+#define CPT_AUD_CONFIG_A   0xe5000
+#define   AUD_CONFIG_N_VALUE_INDEX (1  29)
+#define   AUD_CONFIG_N_PROG_ENABLE (1  28)
+#define   AUD_CONFIG_UPPER_N_SHIFT 20
+#define   AUD_CONFIG_UPPER_N_VALUE (0xff  20)
+#define   AUD_CONFIG_LOWER_N_SHIFT 4
+#define   AUD_CONFIG_LOWER_N_VALUE (0xfff  4)
+#define   AUD_CONFIG_PIXEL_CLOCK_HDMI_SHIFT16
+#define   AUD_CONFIG_PIXEL_CLOCK_HDMI  (0xf  16)
+#define   AUD_CONFIG_DISABLE_NCTS  (1  3)
+
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2012-01-07 
23:11:10.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2012-01-10 13:23:25.0 
+0800
@@ -5908,15 +5908,18 @@ static void ironlake_write_eld(struct dr
uint32_t i;
int len;
int hdmiw_hdmiedid;
+   int aud_config;
int aud_cntl_st;
int aud_cntrl_st2;
 
if (HAS_PCH_IBX(connector-dev)) {
hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID_A;
+   aud_config = IBX_AUD_CONFIG_A;
aud_cntl_st = IBX_AUD_CNTL_ST_A;
aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
} else {
hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
+   aud_config = CPT_AUD_CONFIG_A;
aud_cntl_st = CPT_AUD_CNTL_ST_A;
aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
}
@@ -5924,6 +5927,7 @@ static void ironlake_write_eld(struct dr
i = to_intel_crtc(crtc)-pipe;
hdmiw_hdmiedid += i * 0x100;
aud_cntl_st += i * 0x100;
+   aud_config += i * 0x100;
 
DRM_DEBUG_DRIVER(ELD on pipe %c\n, pipe_name(i));
 
@@ -5943,6 +5947,7 @@ static void ironlake_write_eld(struct dr
if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
+   I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
}
 
if (intel_eld_uptodate(connector,
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: add an off-dvi HDMI audio mode

2012-01-07 Thread Wu Fengguang
On Fri, Jan 06, 2012 at 07:08:33AM -0800, Jesse Barnes wrote:
 On Fri, 6 Jan 2012 11:26:40 +0800
 Wu Fengguang fengguang...@intel.com wrote:
 
  Andrea,
  
  Would you test this patch at convenient time?
  
  Thanks,
  Fengguang
  
  ---
  Subject: drm/i915: add an off-dvi HDMI audio mode
  Date: Fri Jan 06 11:04:00 CST 2012
  
  When HDMI-DVI converter is used, it's not only necessary to turn off
  audio, but also to disable HDMI_MODE_SELECT and video infoframe. Since
  the DVI mode is mainly tied to audio functionality from end user POV,
  add a new off-dvi audio mode:
  
  xrandr --output HDMI1 --set audio off-dvi
  
  Reported-by: Andrea Arcangeli aarca...@redhat.com
  Signed-off-by: Wu Fengguang fengguang...@intel.com
  ---
 
 My only complaint here is that off-dvi isn't an intuitive name.  We
 don't have any better way of detecting an HDMI-DVI converter with
 other EDID bits perhaps?

We have 

intel_hdmi-has_hdmi_sink = drm_detect_hdmi_monitor(edid);

which _should_ auto detect HDMI/DVI connections.

I guess Andrea ran into problem with that due to broken EDID. Anyway
I'll try to test if that drm_detect_hdmi_monitor() will ever work for
the HDMI/DVI monitors in my lab.

 A better name might be off-dvi-mode or off-dvi-only or something.

OK, will change to off-dvi-mode.

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


Re: [Intel-gfx] [PATCH] drm/i915: add an off-dvi HDMI audio mode

2012-01-07 Thread Wu Fengguang
On Fri, Jan 06, 2012 at 05:12:57PM +0100, Andrea Arcangeli wrote:
 On Fri, Jan 06, 2012 at 07:08:33AM -0800, Jesse Barnes wrote:
  A better name might be off-dvi-mode or off-dvi-only or something.
 
 force-dvi is probably better name, off is counter intuitive.

Yeah, force-dvi looks good!

 I didn't test the patch yet, I'll do soon.

Thank you! It did take effect judging from the dmesg on my HDMI box,
however I've not yet tested the HDMI-to-DVI setup.

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


[Intel-gfx] [PATCH] drm/i915: add an off-dvi HDMI audio mode

2012-01-05 Thread Wu Fengguang
Andrea,

Would you test this patch at convenient time?

Thanks,
Fengguang

---
Subject: drm/i915: add an off-dvi HDMI audio mode
Date: Fri Jan 06 11:04:00 CST 2012

When HDMI-DVI converter is used, it's not only necessary to turn off
audio, but also to disable HDMI_MODE_SELECT and video infoframe. Since
the DVI mode is mainly tied to audio functionality from end user POV,
add a new off-dvi audio mode:

xrandr --output HDMI1 --set audio off-dvi

Reported-by: Andrea Arcangeli aarca...@redhat.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_drv.h|7 +++
 drivers/gpu/drm/i915/intel_hdmi.c  |8 +---
 drivers/gpu/drm/i915/intel_modes.c |4 +++-
 3 files changed, 15 insertions(+), 4 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/i915_drv.h  2011-12-22 10:53:26.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_drv.h   2012-01-06 11:20:03.0 
+0800
@@ -736,6 +736,13 @@ typedef struct drm_i915_private {
atomic_t forcewake_count;
 } drm_i915_private_t;
 
+enum hdmi_force_audio {
+   HDMI_AUDIO_OFF_DVI = -2,/* no aux data for HDMI-DVI converter */
+   HDMI_AUDIO_OFF, /* force turn off HDMI audio */
+   HDMI_AUDIO_AUTO,/* trust EDID */
+   HDMI_AUDIO_ON,  /* force turn on HDMI audio */
+};
+
 enum i915_cache_level {
I915_CACHE_NONE,
I915_CACHE_LLC,
--- linux.orig/drivers/gpu/drm/i915/intel_hdmi.c2011-12-22 
10:53:27.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_hdmi.c 2012-01-06 11:03:56.0 
+0800
@@ -335,7 +335,9 @@ intel_hdmi_detect(struct drm_connector *
if (edid) {
if (edid-input  DRM_EDID_INPUT_DIGITAL) {
status = connector_status_connected;
-   intel_hdmi-has_hdmi_sink = 
drm_detect_hdmi_monitor(edid);
+   if (intel_hdmi-force_audio != HDMI_AUDIO_OFF_DVI)
+   intel_hdmi-has_hdmi_sink =
+   drm_detect_hdmi_monitor(edid);
intel_hdmi-has_audio = drm_detect_monitor_audio(edid);
}
connector-display_info.raw_edid = NULL;
@@ -411,8 +413,8 @@ intel_hdmi_set_property(struct drm_conne
else
has_audio = i  0;
 
-   if (has_audio == intel_hdmi-has_audio)
-   return 0;
+   if (i == HDMI_AUDIO_OFF_DVI)
+   intel_hdmi-has_hdmi_sink = 0;
 
intel_hdmi-has_audio = has_audio;
goto done;
--- linux.orig/drivers/gpu/drm/i915/intel_modes.c   2011-12-22 
10:53:27.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_modes.c2012-01-06 11:21:19.0 
+0800
@@ -84,6 +84,7 @@ int intel_ddc_get_modes(struct drm_conne
 }
 
 static const char *force_audio_names[] = {
+   off-dvi,
off,
auto,
on,
@@ -106,7 +107,8 @@ intel_attach_force_audio_property(struct
return;
 
for (i = 0; i  ARRAY_SIZE(force_audio_names); i++)
-   drm_property_add_enum(prop, i, i-1, 
force_audio_names[i]);
+   drm_property_add_enum(prop, i, i-2,
+ force_audio_names[i]);
 
dev_priv-force_audio_property = prop;
}
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] force DVI mode without audio

2011-12-31 Thread Wu Fengguang
On Sat, Dec 31, 2011 at 01:20:11PM +0100, Andrea Arcangeli wrote:
 On Sat, Dec 31, 2011 at 09:28:37AM +0800, Wu Fengguang wrote:
  Hi Andrea,
  
  On Fri, Dec 30, 2011 at 08:07:27PM +0100, Andrea Arcangeli wrote:
   Hi,
   
   after upgrading my HTPC to HD3000 graphics (2700K), I didn't find
   anymore a way to disable the hdmi audio from the DVI2HDMI cable (I
   connect DVI output of the motherboard to the HDMI input of the LCDTV
   in HD). So I added it to the driver as it looks a missing tweak that I
   need.
   
   (I also have proper audio setup connected to the second output of the
   soundcard, but unless I watch a movie or listen music I keep it off so
   I like the LCDTV speaker to work too, and if I turn on the proper
   sound then I mute the TV)
   
   With the readon I was using radeon.audio=0 at boot to achieve the
   exact same thing. Without this, the LCDTV won't play the audio coming
   from the line in analog cable as it's fooled into thinking the audio
   comes through the hdmi cable when it cannot.
   
   It's all working perfectly now.
  
  Have you tried the audio property which can be listed with
  
  xrandr --prop
 
 I wasn't aware about this one, thanks for the tip.
 
 I tried:
 
 xrandr --output HDMI1 --set audio off
 
 that made the sound working for half a second, then it stops working.
 
 If I run:
 
 xrandr --output HDMI1 --set audio on
 xrandr --output HDMI1 --set audio off
 
 at every invocation (including on) I can hear sound for half a
 second and then it stops no matter if it's left on or off.

That's an interesting bug. What's the kernel version you are running?
The dmesg may tell something (especially if boot with drm.debug=6).

 So I applied my patch again for now. If you fix the above I guess
 adding a little script to my KDE autostart directory would work fine.

OK.

 Also note, CTRL+ALT+F1 going back to console doesn't help either. I
 didn't try to play audio before starting X though, not sure what
 happens if I never run X and I try to play audio.

Yeah, that could be a problem. I see that

/sys/class/drm/card0/card0-HDMI-A-1/

exports several drm connector properties, however the (currently still
i915 specific) audio property is not there. It should be good to
make it a general one and export it in drivers/gpu/drm/drm_sysfs.c.

 BTW, initially I tried to set only has_audio to false, but that wasn't
 enough I had to set hdmi to off too and force it to DVI mode to make
 audio work with my TVLCD (LG brand).

You mean the has_hdmi_sink = false? Well does that mean we need to
one more property for it? The property _interface_ is per port, which
can support 2+ HDMI/DP jacks well.

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


Re: [Intel-gfx] force DVI mode without audio

2011-12-30 Thread Wu Fengguang
Hi Andrea,

On Fri, Dec 30, 2011 at 08:07:27PM +0100, Andrea Arcangeli wrote:
 Hi,
 
 after upgrading my HTPC to HD3000 graphics (2700K), I didn't find
 anymore a way to disable the hdmi audio from the DVI2HDMI cable (I
 connect DVI output of the motherboard to the HDMI input of the LCDTV
 in HD). So I added it to the driver as it looks a missing tweak that I
 need.
 
 (I also have proper audio setup connected to the second output of the
 soundcard, but unless I watch a movie or listen music I keep it off so
 I like the LCDTV speaker to work too, and if I turn on the proper
 sound then I mute the TV)
 
 With the readon I was using radeon.audio=0 at boot to achieve the
 exact same thing. Without this, the LCDTV won't play the audio coming
 from the line in analog cable as it's fooled into thinking the audio
 comes through the hdmi cable when it cannot.
 
 It's all working perfectly now.

Have you tried the audio property which can be listed with

xrandr --prop

Thanks,
Fengguang
---

Related commits:

commit 3f43c48d333777e815ae68d66396cb6dfbc2dd79
Author: Chris Wilson ch...@chris-wilson.co.uk
Date:   Thu May 12 22:17:24 2011 +0100

drm/i915: Share the common force-audio property between connectors

Make the audio property creation routine common and share the single
property between the connectors.

Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk
Reviewed-by: Keith Packard kei...@keithp.com
Signed-off-by: Keith Packard kei...@keithp.com

commit 55b7d6e8c4690047ac001026cb75a47f747db816
Author: Chris Wilson ch...@chris-wilson.co.uk
Date:   Sun Sep 19 09:29:33 2010 +0100

drm/i915/hdmi: Add 'force_audio' property

Allow the user to override the detection of the sink's audio capabilities
from EDID. Not all sinks support the required EDID level to specify
whether they handle audio over the display connection, so allow the user
to enable it manually.

Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk

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


[Intel-gfx] i915_wait_request: BUG_ON(seqno == 0) triggered on IvyBridge

2011-12-18 Thread Wu Fengguang
Hi,

I managed to trigger the below BUG_ON when switching modes in an IvyBridge box.

i915_wait_request():

BUG_ON(seqno == 0);

The call trace is at the bottom of the following dmesg.  Any ideas?

Thanks,
Fengguang
---
[  554.872849] [drm:drm_mode_getconnector], [CONNECTOR:6:?]
[  554.874490] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:6:VGA-1]
[  554.876059] [drm:intel_ironlake_crt_detect_hotplug], ironlake hotplug 
adpa=0x83f40018, result 1
[  554.878080] [drm:intel_crt_detect], CRT detected via hotplug
[  554.942138] [drm:drm_edid_to_eld], ELD: no CEA Extension found
[  554.948658] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:6:VGA-1] probed modes :
[  554.956306] [drm:drm_mode_debug_printmodeline], Modeline 19:1280x1024 60 
108000 1280 1328 1440 1688 1024 1025 1028 1066 0x48 0x5
[  554.968661] [drm:drm_mode_debug_printmodeline], Modeline 25:1280x1024 75 
135000 1280 1296 1440 1688 1024 1025 1028 1066 0x40 0x5
[  554.979304] [drm:drm_mode_debug_printmodeline], Modeline 20:1152x864 75 
108000 1152 1216 1344 1600 864 865 868 900 0x40 0x5
[  554.989715] [drm:drm_mode_debug_printmodeline], Modeline 26:1024x768 75 
78800 1024 1040 1136 1312 768 769 772 800 0x40 0x5
[  554.999572] [drm:drm_mode_debug_printmodeline], Modeline 27:1024x768 60 
65000 1024 1048 1184 1344 768 771 777 806 0x40 0xa
[  555.009914] [drm:drm_mode_debug_printmodeline], Modeline 28:800x600 75 
49500 800 816 896 1056 600 601 604 625 0x40 0x5
[  555.019513] [drm:drm_mode_debug_printmodeline], Modeline 21:800x600 60 
4 800 840 968 1056 600 601 605 628 0x40 0x5
[  555.029576] [drm:drm_mode_debug_printmodeline], Modeline 22:640x480 75 
31500 640 656 720 840 480 481 484 500 0x40 0xa
[  555.039131] [drm:drm_mode_debug_printmodeline], Modeline 23:640x480 60 
25200 640 656 752 800 480 490 492 525 0x40 0xa
[  555.046116] [drm:drm_mode_debug_printmodeline], Modeline 24:720x400 70 
28320 720 738 846 900 400 412 414 449 0x40 0x6
[  555.048700] [drm:drm_mode_getconnector], [CONNECTOR:6:?]
[  555.051126] [drm:drm_mode_getconnector], [CONNECTOR:9:?]
[  555.053007] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:9:HDMI-A-1]
[  555.066494] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:9:HDMI-A-1] disconnected
[  555.069830] [drm:drm_mode_getconnector], [CONNECTOR:9:?]
[  555.071982] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:9:HDMI-A-1]
[  555.087300] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:9:HDMI-A-1] disconnected
[  555.089683] [drm:drm_mode_getconnector], [CONNECTOR:13:?]
[  555.091775] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:13:HDMI-A-2]
[  555.105115] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:13:HDMI-A-2] disconnected
[  555.108413] [drm:drm_mode_getconnector], [CONNECTOR:13:?]
[  555.109646] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:13:HDMI-A-2]
[  555.124139] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:13:HDMI-A-2] disconnected
[  555.126380] [drm:drm_mode_getconnector], [CONNECTOR:14:?]
[  555.129581] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:14:DP-1]
[  555.132459] [drm:intel_dp_detect], DPCD: 110a840101000100
[  555.136364] [drm:i2c_algo_dp_aux_xfer], dp_aux_xfer return 2
[  555.165869] [drm:i2c_algo_dp_aux_xfer], dp_aux_xfer return 2
[  555.195046] [drm:i2c_algo_dp_aux_xfer], dp_aux_xfer return 2
[  555.197126] [drm:drm_detect_monitor_audio], Monitor has basic audio support
[  555.200698] [drm:i2c_algo_dp_aux_xfer], dp_aux_xfer return 2
[  555.230215] [drm:i2c_algo_dp_aux_xfer], dp_aux_xfer return 2
[  555.259247] [drm:i2c_algo_dp_aux_xfer], dp_aux_xfer return 2
[  555.265006] [drm:drm_edid_to_eld], ELD monitor 221P3LPY
[  555.269556] [drm:drm_edid_to_eld], ELD size 8, SAD count 1
[  555.274536] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:14:DP-1] probed modes :
[  555.282117] [drm:drm_mode_debug_printmodeline], Modeline 33:1920x1080 60 
148500 1920 2008 2052 2200 1080 1084 1089 1125 0x48 0x9
[  555.292807] [drm:drm_mode_debug_printmodeline], Modeline 36:1680x1050 60 
146250 1680 1784 1960 2240 1050 1053 1059 1089 0x40 0x6
[  555.303118] [drm:drm_mode_debug_printmodeline], Modeline 45:1280x1024 75 
135000 1280 1296 1440 1688 1024 1025 1028 1066 0x40 0x5
[  555.313819] [drm:drm_mode_debug_printmodeline], Modeline 35:1280x1024 60 
108000 1280 1328 1440 1688 1024 1025 1028 1066 0x40 0x5
[  555.324613] [drm:drm_mode_debug_printmodeline], Modeline 38:1440x900 75 
136750 1440 1536 1688 1936 900 903 909 942 0x40 0x6
[  555.334564] [drm:drm_mode_debug_printmodeline], Modeline 37:1440x900 60 
106500 1440 1520 1672 1904 900 903 909 934 0x40 0x6
[  555.344871] [drm:drm_mode_debug_printmodeline], Modeline 34:1280x720 60 
74250 1280 1390 1430 1650 720 725 730 750 0x40 0xa
[  555.354808] [drm:drm_mode_debug_printmodeline], Modeline 46:1024x768 75 
78800 1024 1040 1136 1312 768 769 772 800 0x40 0x5
[  555.363206] [drm:drm_mode_debug_printmodeline], Modeline 

[Intel-gfx] [PATCH] drm/i915: DisplayPort hot remove notification to audio driver

2011-12-09 Thread Wu Fengguang
On DP monitor hot remove, clear DP_AUDIO_OUTPUT_ENABLE accordingly,
so that the audio driver will receive hot plug events and take action
to refresh its device state and ELD contents.

Note that the DP_AUDIO_OUTPUT_ENABLE bit may be enabled or disabled
only when the link training is complete and set to Normal.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_dp.c |1 +
 1 file changed, 1 insertion(+)

This works both on KMS console and gnome desktop.
Hot plug/unplug and DPMS on/off are all tested OK.

--- linux.orig/drivers/gpu/drm/i915/intel_dp.c  2011-12-09 16:51:21.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_dp.c   2011-12-09 16:59:45.0 
+0800
@@ -1771,6 +1771,7 @@ intel_dp_link_down(struct intel_dp *inte
intel_wait_for_vblank(dev, to_intel_crtc(crtc)-pipe);
}
 
+   DP = ~DP_AUDIO_OUTPUT_ENABLE;
I915_WRITE(intel_dp-output_reg, DP  ~DP_PORT_EN);
POSTING_READ(intel_dp-output_reg);
msleep(intel_dp-panel_power_down_delay);
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 0/5] Intel HDMI ELD fixes v2

2011-12-09 Thread Wu Fengguang
Keith,

The complete set of fixes for passing HDMI/DP ELD to audio driver.

 [PATCH 1/5] drm/i915: fix ELD writing for SandyBridge
 [PATCH 2/5] drm/i915: rename audio ELD registers
 [PATCH 3/5] drm/i915: dont trigger hotplug events on unchanged ELD
 [PATCH 4/5] drm/i915: HDMI hot remove notification to audio driver
 [PATCH 5/5] drm/i915: DisplayPort hot remove notification to audio driver

 drivers/gpu/drm/i915/i915_reg.h  |   22 +++
 drivers/gpu/drm/i915/intel_display.c |   75 +++--
 drivers/gpu/drm/i915/intel_dp.c  |1 
 drivers/gpu/drm/i915/intel_hdmi.c|8 ++
 4 files changed, 76 insertions(+), 30 deletions(-)

Thanks,
Fengguang

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


[Intel-gfx] [PATCH 2/5] drm/i915: rename audio ELD registers

2011-12-09 Thread Wu Fengguang
Change the definitions from GEN5 to IBX as they aren't in the CPU and
some SNB systems actually shipped with IBX chipsets (or, at least that's
a supported configuration).

The GEN7_* register addresses actually take effect since GEN6 and should
be prefixed by CPT, the PCH code name.

Suggested-by: Keith Packard kei...@keithp.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |   22 +++---
 drivers/gpu/drm/i915/intel_display.c |   22 +++---
 2 files changed, 22 insertions(+), 22 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2011-11-29 19:50:27.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2011-11-29 19:51:38.0 
+0800
@@ -3534,17 +3534,17 @@
 #define G4X_ELD_ACK(1  4)
 #define G4X_HDMIW_HDMIEDID 0x6210C
 
-#define GEN5_HDMIW_HDMIEDID_A  0xE2050
-#define GEN5_AUD_CNTL_ST_A 0xE20B4
-#define GEN5_ELD_BUFFER_SIZE   (0x1f  10)
-#define GEN5_ELD_ADDRESS   (0x1f  5)
-#define GEN5_ELD_ACK   (1  4)
-#define GEN5_AUD_CNTL_ST2  0xE20C0
-#define GEN5_ELD_VALIDB(1  0)
-#define GEN5_CP_READYB (1  1)
+#define IBX_HDMIW_HDMIEDID_A   0xE2050
+#define IBX_AUD_CNTL_ST_A  0xE20B4
+#define IBX_ELD_BUFFER_SIZE(0x1f  10)
+#define IBX_ELD_ADDRESS(0x1f  5)
+#define IBX_ELD_ACK(1  4)
+#define IBX_AUD_CNTL_ST2   0xE20C0
+#define IBX_ELD_VALIDB (1  0)
+#define IBX_CP_READYB  (1  1)
 
-#define GEN7_HDMIW_HDMIEDID_A  0xE5050
-#define GEN7_AUD_CNTRL_ST_A0xE50B4
-#define GEN7_AUD_CNTRL_ST2 0xE50C0
+#define CPT_HDMIW_HDMIEDID_A   0xE5050
+#define CPT_AUD_CNTL_ST_A  0xE50B4
+#define CPT_AUD_CNTRL_ST2  0xE50C0
 
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-29 
19:51:28.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-29 19:52:01.0 
+0800
@@ -5858,13 +5858,13 @@ static void ironlake_write_eld(struct dr
int aud_cntrl_st2;
 
if (HAS_PCH_IBX(connector-dev)) {
-   hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN5_AUD_CNTL_ST_A;
-   aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID_A;
+   aud_cntl_st = IBX_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
} else {
-   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
-   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
+   hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
+   aud_cntl_st = CPT_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
}
 
i = to_intel_crtc(crtc)-pipe;
@@ -5878,12 +5878,12 @@ static void ironlake_write_eld(struct dr
if (!i) {
DRM_DEBUG_DRIVER(Audio directed to unknown port\n);
/* operate blindly on all ports */
-   eldv = GEN5_ELD_VALIDB;
-   eldv |= GEN5_ELD_VALIDB  4;
-   eldv |= GEN5_ELD_VALIDB  8;
+   eldv = IBX_ELD_VALIDB;
+   eldv |= IBX_ELD_VALIDB  4;
+   eldv |= IBX_ELD_VALIDB  8;
} else {
DRM_DEBUG_DRIVER(ELD on port %c\n, 'A' + i);
-   eldv = GEN5_ELD_VALIDB  ((i - 1) * 4);
+   eldv = IBX_ELD_VALIDB  ((i - 1) * 4);
}
 
i = I915_READ(aud_cntrl_st2);
@@ -5899,7 +5899,7 @@ static void ironlake_write_eld(struct dr
}
 
i = I915_READ(aud_cntl_st);
-   i = ~GEN5_ELD_ADDRESS;
+   i = ~IBX_ELD_ADDRESS;
I915_WRITE(aud_cntl_st, i);
 
len = min_t(uint8_t, eld[2], 21);   /* 84 bytes of hw ELD buffer */


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


[Intel-gfx] [PATCH 3/5] drm/i915: dont trigger hotplug events on unchanged ELD

2011-12-09 Thread Wu Fengguang
The ELD may or may not change when switching the video mode.
If unchanged, don't trigger hot plug events to HDMI audio driver.

This avoids disturbing the user with repeated printks.

Reported-by: Nick Bowler nbow...@elliptictech.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_display.c |   51 ++---
 1 file changed, 46 insertions(+), 5 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-24 
08:25:26.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-24 08:25:27.0 
+0800
@@ -5811,6 +5811,35 @@ static int intel_crtc_mode_set(struct dr
return ret;
 }
 
+static bool intel_eld_uptodate(struct drm_connector *connector,
+  int reg_eldv, uint32_t bits_eldv,
+  int reg_elda, uint32_t bits_elda,
+  int reg_edid)
+{
+   struct drm_i915_private *dev_priv = connector-dev-dev_private;
+   uint8_t *eld = connector-eld;
+   uint32_t i;
+
+   i = I915_READ(reg_eldv);
+   i = bits_eldv;
+
+   if (!eld[0])
+   return !i;
+
+   if (!i)
+   return false;
+
+   i = I915_READ(reg_elda);
+   i = ~bits_elda;
+   I915_WRITE(reg_elda, i);
+
+   for (i = 0; i  eld[2]; i++)
+   if (I915_READ(reg_edid) != *((uint32_t *)eld + i))
+   return false;
+
+   return true;
+}
+
 static void g4x_write_eld(struct drm_connector *connector,
  struct drm_crtc *crtc)
 {
@@ -5827,6 +5856,12 @@ static void g4x_write_eld(struct drm_con
else
eldv = G4X_ELDV_DEVCTG;
 
+   if (intel_eld_uptodate(connector,
+  G4X_AUD_CNTL_ST, eldv,
+  G4X_AUD_CNTL_ST, G4X_ELD_ADDR,
+  G4X_HDMIW_HDMIEDID))
+   return;
+
i = I915_READ(G4X_AUD_CNTL_ST);
i = ~(eldv | G4X_ELD_ADDR);
len = (i  9)  0x1f;  /* ELD buffer size */
@@ -5886,6 +5921,17 @@ static void ironlake_write_eld(struct dr
eldv = IBX_ELD_VALIDB  ((i - 1) * 4);
}
 
+   if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
+   DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
+   eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
+   }
+
+   if (intel_eld_uptodate(connector,
+  aud_cntrl_st2, eldv,
+  aud_cntl_st, IBX_ELD_ADDRESS,
+  hdmiw_hdmiedid))
+   return;
+
i = I915_READ(aud_cntrl_st2);
i = ~eldv;
I915_WRITE(aud_cntrl_st2, i);
@@ -5893,11 +5939,6 @@ static void ironlake_write_eld(struct dr
if (!eld[0])
return;
 
-   if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
-   DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
-   eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
-   }
-
i = I915_READ(aud_cntl_st);
i = ~IBX_ELD_ADDRESS;
I915_WRITE(aud_cntl_st, i);


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


[Intel-gfx] [PATCH 1/5] drm/i915: fix ELD writing for SandyBridge

2011-12-09 Thread Wu Fengguang
SandyBridge should be using the same register addresses as IvyBridge.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_display.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-28 
15:33:04.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-29 19:51:28.0 
+0800
@@ -5857,14 +5857,14 @@ static void ironlake_write_eld(struct dr
int aud_cntl_st;
int aud_cntrl_st2;
 
-   if (IS_IVYBRIDGE(connector-dev)) {
-   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
-   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
-   } else {
+   if (HAS_PCH_IBX(connector-dev)) {
hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
aud_cntl_st = GEN5_AUD_CNTL_ST_A;
aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   } else {
+   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
+   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
+   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
}
 
i = to_intel_crtc(crtc)-pipe;


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


[Intel-gfx] Philips 221P3LPYEB has working DP audio

2011-12-09 Thread Wu Fengguang
On Mon, Nov 28, 2011 at 04:06:37PM +0800, Wu Fengguang wrote:
  The only missing part is hot plug notification for DP -- most DP monitors in
  the market don't support DP audio well. So I cannot test this for now.
 
 btw, we'd like to buy a Philips 221P3LPYEB that _seems_ to have DP
 audio support. I'd appreciate if any one can help confirm.

I'm glad to say that its DP audio works great! And the built in
speakers make the testing really convenient :-)

For the record, here is the ELD:

monitor_present 1
eld_valid   1
monitor_name221P3LPY
connection_type DisplayPort
eld_version [0x2] CEA-861D or below
edid_version[0x3] CEA-861-B, C or D
manufacture_id  0xc41
product_id  0x8a3
port_id 0x0
support_hdcp0
support_ai  0
audio_sync_delay0
speakers[0x1] FL/FR
sad_count   1
sad0_coding_type[0x1] LPCM
sad0_channels   2
sad0_rates  [0x6e0] 32000 44100 48000 96000 176400
sad0_bits   [0xe] 16 20 24

Note that we didn't buy the 24 241P3LYEB because it's temporarily not
available.

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


[Intel-gfx] [PATCH 1/4 v2] drm/i915: fix ELD writing for SandyBridge

2011-11-29 Thread Wu Fengguang
SandyBridge should be using the same register addresses as IvyBridge.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_display.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

Sorry, this moves some necessary changes from patch 2/4 to here.

--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-28 
15:33:04.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-29 19:51:28.0 
+0800
@@ -5857,14 +5857,14 @@ static void ironlake_write_eld(struct dr
int aud_cntl_st;
int aud_cntrl_st2;
 
-   if (IS_IVYBRIDGE(connector-dev)) {
-   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
-   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
-   } else {
+   if (HAS_PCH_IBX(connector-dev)) {
hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
aud_cntl_st = GEN5_AUD_CNTL_ST_A;
aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   } else {
+   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
+   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
+   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
}
 
i = to_intel_crtc(crtc)-pipe;
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 2/4 v2] drm/i915: rename audio ELD registers

2011-11-29 Thread Wu Fengguang
Change the definitions from GEN5 to IBX as they aren't in the CPU and
some SNB systems actually shipped with IBX chipsets (or, at least that's
a supported configuration).

The GEN7_* register addresses actually take effect since GEN6 and should
be prefixed by CPT, the PCH code name.

Suggested-by: Keith Packard kei...@keithp.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |   22 +++---
 drivers/gpu/drm/i915/intel_display.c |   22 +++---
 2 files changed, 22 insertions(+), 22 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2011-11-29 19:50:27.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2011-11-29 19:51:38.0 
+0800
@@ -3534,17 +3534,17 @@
 #define G4X_ELD_ACK(1  4)
 #define G4X_HDMIW_HDMIEDID 0x6210C
 
-#define GEN5_HDMIW_HDMIEDID_A  0xE2050
-#define GEN5_AUD_CNTL_ST_A 0xE20B4
-#define GEN5_ELD_BUFFER_SIZE   (0x1f  10)
-#define GEN5_ELD_ADDRESS   (0x1f  5)
-#define GEN5_ELD_ACK   (1  4)
-#define GEN5_AUD_CNTL_ST2  0xE20C0
-#define GEN5_ELD_VALIDB(1  0)
-#define GEN5_CP_READYB (1  1)
+#define IBX_HDMIW_HDMIEDID_A   0xE2050
+#define IBX_AUD_CNTL_ST_A  0xE20B4
+#define IBX_ELD_BUFFER_SIZE(0x1f  10)
+#define IBX_ELD_ADDRESS(0x1f  5)
+#define IBX_ELD_ACK(1  4)
+#define IBX_AUD_CNTL_ST2   0xE20C0
+#define IBX_ELD_VALIDB (1  0)
+#define IBX_CP_READYB  (1  1)
 
-#define GEN7_HDMIW_HDMIEDID_A  0xE5050
-#define GEN7_AUD_CNTRL_ST_A0xE50B4
-#define GEN7_AUD_CNTRL_ST2 0xE50C0
+#define CPT_HDMIW_HDMIEDID_A   0xE5050
+#define CPT_AUD_CNTL_ST_A  0xE50B4
+#define CPT_AUD_CNTRL_ST2  0xE50C0
 
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-29 
19:51:28.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-29 19:52:01.0 
+0800
@@ -5858,13 +5858,13 @@ static void ironlake_write_eld(struct dr
int aud_cntrl_st2;
 
if (HAS_PCH_IBX(connector-dev)) {
-   hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN5_AUD_CNTL_ST_A;
-   aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID_A;
+   aud_cntl_st = IBX_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
} else {
-   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
-   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
+   hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
+   aud_cntl_st = CPT_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
}
 
i = to_intel_crtc(crtc)-pipe;
@@ -5878,12 +5878,12 @@ static void ironlake_write_eld(struct dr
if (!i) {
DRM_DEBUG_DRIVER(Audio directed to unknown port\n);
/* operate blindly on all ports */
-   eldv = GEN5_ELD_VALIDB;
-   eldv |= GEN5_ELD_VALIDB  4;
-   eldv |= GEN5_ELD_VALIDB  8;
+   eldv = IBX_ELD_VALIDB;
+   eldv |= IBX_ELD_VALIDB  4;
+   eldv |= IBX_ELD_VALIDB  8;
} else {
DRM_DEBUG_DRIVER(ELD on port %c\n, 'A' + i);
-   eldv = GEN5_ELD_VALIDB  ((i - 1) * 4);
+   eldv = IBX_ELD_VALIDB  ((i - 1) * 4);
}
 
i = I915_READ(aud_cntrl_st2);
@@ -5899,7 +5899,7 @@ static void ironlake_write_eld(struct dr
}
 
i = I915_READ(aud_cntl_st);
-   i = ~GEN5_ELD_ADDRESS;
+   i = ~IBX_ELD_ADDRESS;
I915_WRITE(aud_cntl_st, i);
 
len = min_t(uint8_t, eld[2], 21);   /* 84 bytes of hw ELD buffer */
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 0/4] Intel HDMI ELD fixes

2011-11-28 Thread Wu Fengguang
 The only missing part is hot plug notification for DP -- most DP monitors in
 the market don't support DP audio well. So I cannot test this for now.

btw, we'd like to buy a Philips 221P3LPYEB that _seems_ to have DP
audio support. I'd appreciate if any one can help confirm.

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


[Intel-gfx] [PATCH 1/4] drm/i915: fix ELD writing for SandyBridge

2011-11-27 Thread Wu Fengguang
SandyBridge should be using the same register addresses as IvyBridge.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_display.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-24 
08:09:41.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-24 08:10:32.0 
+0800
@@ -5857,7 +5857,7 @@ static void ironlake_write_eld(struct dr
int aud_cntl_st;
int aud_cntrl_st2;
 
-   if (IS_IVYBRIDGE(connector-dev)) {
+   if (HAS_PCH_IBX(connector-dev)) {
hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;


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


[Intel-gfx] [PATCH 3/4] drm/i915: dont trigger hotplug events on unchanged ELD

2011-11-27 Thread Wu Fengguang
The ELD may or may not change when switching the video mode.
If unchanged, don't trigger hot plug events to HDMI audio driver.

This avoids disturbing the user with repeated printks.

Reported-by: Nick Bowler nbow...@elliptictech.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_display.c |   51 ++---
 1 file changed, 46 insertions(+), 5 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-24 
08:25:26.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-24 08:25:27.0 
+0800
@@ -5811,6 +5811,35 @@ static int intel_crtc_mode_set(struct dr
return ret;
 }
 
+static bool intel_eld_uptodate(struct drm_connector *connector,
+  int reg_eldv, uint32_t bits_eldv,
+  int reg_elda, uint32_t bits_elda,
+  int reg_edid)
+{
+   struct drm_i915_private *dev_priv = connector-dev-dev_private;
+   uint8_t *eld = connector-eld;
+   uint32_t i;
+
+   i = I915_READ(reg_eldv);
+   i = bits_eldv;
+
+   if (!eld[0])
+   return !i;
+
+   if (!i)
+   return false;
+
+   i = I915_READ(reg_elda);
+   i = ~bits_elda;
+   I915_WRITE(reg_elda, i);
+
+   for (i = 0; i  eld[2]; i++)
+   if (I915_READ(reg_edid) != *((uint32_t *)eld + i))
+   return false;
+
+   return true;
+}
+
 static void g4x_write_eld(struct drm_connector *connector,
  struct drm_crtc *crtc)
 {
@@ -5827,6 +5856,12 @@ static void g4x_write_eld(struct drm_con
else
eldv = G4X_ELDV_DEVCTG;
 
+   if (intel_eld_uptodate(connector,
+  G4X_AUD_CNTL_ST, eldv,
+  G4X_AUD_CNTL_ST, G4X_ELD_ADDR,
+  G4X_HDMIW_HDMIEDID))
+   return;
+
i = I915_READ(G4X_AUD_CNTL_ST);
i = ~(eldv | G4X_ELD_ADDR);
len = (i  9)  0x1f;  /* ELD buffer size */
@@ -5886,6 +5921,17 @@ static void ironlake_write_eld(struct dr
eldv = IBX_ELD_VALIDB  ((i - 1) * 4);
}
 
+   if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
+   DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
+   eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
+   }
+
+   if (intel_eld_uptodate(connector,
+  aud_cntrl_st2, eldv,
+  aud_cntl_st, IBX_ELD_ADDRESS,
+  hdmiw_hdmiedid))
+   return;
+
i = I915_READ(aud_cntrl_st2);
i = ~eldv;
I915_WRITE(aud_cntrl_st2, i);
@@ -5893,11 +5939,6 @@ static void ironlake_write_eld(struct dr
if (!eld[0])
return;
 
-   if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
-   DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
-   eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
-   }
-
i = I915_READ(aud_cntl_st);
i = ~IBX_ELD_ADDRESS;
I915_WRITE(aud_cntl_st, i);


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


[Intel-gfx] [PATCH 0/4] Intel HDMI ELD fixes

2011-11-27 Thread Wu Fengguang
Keith,

The 4 patches are well tested and integrates the review comments.

The only missing part is hot plug notification for DP -- most DP monitors in
the market don't support DP audio well. So I cannot test this for now.

Thanks,
Fengguang

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


[Intel-gfx] [PATCH 4/4] drm/i915: HDMI hot remove notification to audio driver

2011-11-27 Thread Wu Fengguang
On HDMI monitor hot remove, clear SDVO_AUDIO_ENABLE accordingly, so that
the audio driver will receive hot plug events and take action to refresh
its device state and ELD contents.

The cleared SDVO_AUDIO_ENABLE bit needs to be restored to prevent losing
HDMI audio after DPMS on.

CC: Wang Zhenyu zhenyu.z.w...@intel.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_dp.c   |4 +++-
 drivers/gpu/drm/i915/intel_hdmi.c |8 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_hdmi.c2011-11-24 
17:11:38.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_hdmi.c 2011-11-24 17:15:03.0 
+0800
@@ -269,6 +269,10 @@ static void intel_hdmi_dpms(struct drm_e
struct drm_i915_private *dev_priv = dev-dev_private;
struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
u32 temp;
+   u32 enable_bits = SDVO_ENABLE;
+
+   if (intel_hdmi-has_audio)
+   enable_bits |= SDVO_AUDIO_ENABLE;
 
temp = I915_READ(intel_hdmi-sdvox_reg);
 
@@ -281,9 +285,9 @@ static void intel_hdmi_dpms(struct drm_e
}
 
if (mode != DRM_MODE_DPMS_ON) {
-   temp = ~SDVO_ENABLE;
+   temp = ~enable_bits;
} else {
-   temp |= SDVO_ENABLE;
+   temp |= enable_bits;
}
 
I915_WRITE(intel_hdmi-sdvox_reg, temp);


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


[Intel-gfx] [PATCH 2/4] drm/i915: rename audio ELD registers

2011-11-27 Thread Wu Fengguang
Change the definitions from GEN5 to IBX as they aren't in the CPU and
some SNB systems actually shipped with IBX chipsets (or, at least that's
a supported configuration).

The GEN7_* register addresses actually take effect since GEN6 and should
be prefixed by CPT, the PCH code name.

Suggested-by: Keith Packard kei...@keithp.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |   22 +++---
 drivers/gpu/drm/i915/intel_display.c |   22 +++---
 2 files changed, 22 insertions(+), 22 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2011-11-24 08:09:28.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2011-11-24 08:10:02.0 
+0800
@@ -3534,17 +3534,17 @@
 #define G4X_ELD_ACK(1  4)
 #define G4X_HDMIW_HDMIEDID 0x6210C
 
-#define GEN5_HDMIW_HDMIEDID_A  0xE2050
-#define GEN5_AUD_CNTL_ST_A 0xE20B4
-#define GEN5_ELD_BUFFER_SIZE   (0x1f  10)
-#define GEN5_ELD_ADDRESS   (0x1f  5)
-#define GEN5_ELD_ACK   (1  4)
-#define GEN5_AUD_CNTL_ST2  0xE20C0
-#define GEN5_ELD_VALIDB(1  0)
-#define GEN5_CP_READYB (1  1)
+#define IBX_HDMIW_HDMIEDID_A   0xE2050
+#define IBX_AUD_CNTL_ST_A  0xE20B4
+#define IBX_ELD_BUFFER_SIZE(0x1f  10)
+#define IBX_ELD_ADDRESS(0x1f  5)
+#define IBX_ELD_ACK(1  4)
+#define IBX_AUD_CNTL_ST2   0xE20C0
+#define IBX_ELD_VALIDB (1  0)
+#define IBX_CP_READYB  (1  1)
 
-#define GEN7_HDMIW_HDMIEDID_A  0xE5050
-#define GEN7_AUD_CNTRL_ST_A0xE50B4
-#define GEN7_AUD_CNTRL_ST2 0xE50C0
+#define CPT_HDMIW_HDMIEDID_A   0xE5050
+#define CPT_AUD_CNTL_ST_A  0xE50B4
+#define CPT_AUD_CNTRL_ST2  0xE50C0
 
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-24 
08:09:53.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-24 08:10:05.0 
+0800
@@ -5858,13 +5858,13 @@ static void ironlake_write_eld(struct dr
int aud_cntrl_st2;
 
if (HAS_PCH_IBX(connector-dev)) {
-   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
-   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
+   hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID_A;
+   aud_cntl_st = IBX_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
} else {
-   hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN5_AUD_CNTL_ST_A;
-   aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
+   aud_cntl_st = CPT_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
}
 
i = to_intel_crtc(crtc)-pipe;
@@ -5878,12 +5878,12 @@ static void ironlake_write_eld(struct dr
if (!i) {
DRM_DEBUG_DRIVER(Audio directed to unknown port\n);
/* operate blindly on all ports */
-   eldv = GEN5_ELD_VALIDB;
-   eldv |= GEN5_ELD_VALIDB  4;
-   eldv |= GEN5_ELD_VALIDB  8;
+   eldv = IBX_ELD_VALIDB;
+   eldv |= IBX_ELD_VALIDB  4;
+   eldv |= IBX_ELD_VALIDB  8;
} else {
DRM_DEBUG_DRIVER(ELD on port %c\n, 'A' + i);
-   eldv = GEN5_ELD_VALIDB  ((i - 1) * 4);
+   eldv = IBX_ELD_VALIDB  ((i - 1) * 4);
}
 
i = I915_READ(aud_cntrl_st2);
@@ -5899,7 +5899,7 @@ static void ironlake_write_eld(struct dr
}
 
i = I915_READ(aud_cntl_st);
-   i = ~GEN5_ELD_ADDRESS;
+   i = ~IBX_ELD_ADDRESS;
I915_WRITE(aud_cntl_st, i);
 
len = min_t(uint8_t, eld[2], 21);   /* 84 bytes of hw ELD buffer */


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


Re: [Intel-gfx] [PATCH 3/3 v2] drm/i915: hot plug/unplug notification to HDMI audio driver

2011-11-24 Thread Wu Fengguang
On Thu, Nov 24, 2011 at 03:26:49AM +0800, Keith Packard wrote:
 On Wed, 23 Nov 2011 16:29:58 +0800, Wu Fengguang fengguang...@intel.com 
 wrote:
 
  What I need is a hot plug hook that knows whether the monitor is
  plugged or removed, which is only possible if the hook is called
  after -detect().
 
 That would be mode_set to tell you that the monitor is in use, and the
 disable function to tell you when the monitor is no longer in use.
 
 You do not want to do anything to the hardware in the hot_plug paths;
 those are strictly informative; telling user space which connectors are
 present.

Thanks a lot for the tips! When doing things in the right path, I got
a much reduced patch :-)

Due to DP being a bit more tricky than HDMI and no convenient DP test
environment, I'll have to delay the DP part to next week...

Thanks,
Fengguang
---
Subject: drm/i915: HDMI hot remove notification to audio driver
Date: Fri Nov 11 13:49:04 CST 2011

On HDMI monitor hot remove, clear SDVO_AUDIO_ENABLE accordingly, so that
the audio driver will receive hot plug events and take action to refresh
its device state and ELD contents.

The cleared SDVO_AUDIO_ENABLE bit needs to be restored to prevent losing
HDMI audio after DPMS on.

CC: Wang Zhenyu zhenyu.z.w...@intel.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_dp.c   |4 +++-
 drivers/gpu/drm/i915/intel_hdmi.c |8 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_hdmi.c2011-11-24 
17:11:38.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_hdmi.c 2011-11-24 17:15:03.0 
+0800
@@ -269,6 +269,10 @@ static void intel_hdmi_dpms(struct drm_e
struct drm_i915_private *dev_priv = dev-dev_private;
struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
u32 temp;
+   u32 enable_bits = SDVO_ENABLE;
+
+   if (intel_hdmi-has_audio)
+   enable_bits |= SDVO_AUDIO_ENABLE;
 
temp = I915_READ(intel_hdmi-sdvox_reg);
 
@@ -281,9 +285,9 @@ static void intel_hdmi_dpms(struct drm_e
}
 
if (mode != DRM_MODE_DPMS_ON) {
-   temp = ~SDVO_ENABLE;
+   temp = ~enable_bits;
} else {
-   temp |= SDVO_ENABLE;
+   temp |= enable_bits;
}
 
I915_WRITE(intel_hdmi-sdvox_reg, temp);
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 3/3 v2] drm/i915: hot plug/unplug notification to HDMI audio driver

2011-11-23 Thread Wu Fengguang
On Wed, Nov 23, 2011 at 02:25:14AM +0800, Keith Packard wrote:
 On Tue, 22 Nov 2011 15:40:55 +0800, Wu Fengguang fengguang...@intel.com 
 wrote:
 
  So the v3 patch will behave equally well on KMS console, gnome desktop
  and bare X. Shall we just use it, or go back and use the original
  -hot_remove patch?
 
 I'm not sure why we need any change to the core DRM code. The HDMI and
 DP drivers will be told when to turn the monitors on and off, and that's

Yeah, The DP driver will be notified via the intel_dp_hot_plug() hook
if I understand it right.

 the appropriate time to control whether audio is routed to them.

However -hot_plug() is called too early to be useful for this case.

What I need is a hot plug hook that knows whether the monitor is
plugged or removed, which is only possible if the hook is called
after -detect().

Or, we can avoid adding the -hotplug() hook and just add the call
directly to intel_hdmi_detect() and intel_dp_detect().

The below patch does this and eliminates the DRM callback :-)

 Hotplug is considered simply a notification to user space that
 something has changed -- user space is in charge of configuring
 which outputs are in use.

Yeah, and here is another notification to the audio driver demanded by
the HD audio spec.

Thanks,
Fengguang
---
Subject: drm/i915: hot plug/remove notification to HDMI audio driver
Date: Fri Nov 11 13:49:04 CST 2011

On monitor hot plug/unplug, set/clear SDVO_AUDIO_ENABLE or
DP_AUDIO_OUTPUT_ENABLE accordingly, so that the audio driver will
receive hot plug events and take action to refresh its device state and
ELD contents.

After intel_dp_detect() knows whether the monitor is plugged or
removed, it will call intel_dp_hotplug_audio() to notify the audio
driver of the event.

It's noticed that bare metal X may not call -mode_set() at monitor hot
plug, so it's necessary to call drm_edid_to_eld() earlier at -detect()
time rather than in intel_ddc_get_modes(), so that intel_write_eld() can
see the new ELD in intel_dp_hotplug_audio().

The call sequence on hot plug is

- KMS console, full blown X (eg. gnome desktop)
-detect
  drm_edid_to_eld
-mode_set
  intel_write_eld
  set SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE
- bare metal X (eg. fluxbox)
-detect
  drm_edid_to_eld
  intel_dp_hotplug_audio()
intel_write_eld
set SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE

On hot remove, the call sequence is

-detect
  intel_dp_hotplug_audio()
clear SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE

cc: Wang Zhenyu zhenyu.z.w...@intel.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_dp.c|   47 ---
 drivers/gpu/drm/i915/intel_hdmi.c  |   32 ++
 drivers/gpu/drm/i915/intel_modes.c |2 -
 3 files changed, 68 insertions(+), 13 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_dp.c  2011-11-23 15:16:10.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_dp.c   2011-11-23 16:20:25.0 
+0800
@@ -28,6 +28,7 @@
 #include linux/i2c.h
 #include linux/slab.h
 #include linux/export.h
+#include drm/drm_edid.h
 #include drmP.h
 #include drm.h
 #include drm_crtc.h
@@ -1940,6 +1941,27 @@ intel_dp_get_edid_modes(struct drm_conne
return ret;
 }
 
+static void intel_dp_hotplug_audio(struct drm_connector *connector,
+  enum drm_connector_status status)
+{
+   struct intel_dp *intel_dp = intel_attached_dp(connector);
+   struct drm_device *dev = intel_dp-base.base.dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct drm_crtc *crtc = intel_dp-base.base.crtc;
+
+   DRM_DEBUG_DRIVER(hotplug status %d crtc %p eld %#x\n,
+status, crtc, (unsigned int)connector-eld[0]);
+
+   if (status == connector_status_disconnected)
+   intel_dp-DP = ~DP_AUDIO_OUTPUT_ENABLE;
+   else if (status == connector_status_connected  crtc) {
+   intel_write_eld(intel_dp-base.base, crtc-mode);
+   intel_dp-DP |= DP_AUDIO_OUTPUT_ENABLE;
+   } else
+   return;
+   I915_WRITE(intel_dp-output_reg, intel_dp-DP);
+   POSTING_READ(intel_dp-output_reg);
+}
 
 /**
  * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect DP connection.
@@ -1968,20 +1990,23 @@ intel_dp_detect(struct drm_connector *co
  intel_dp-dpcd[6], intel_dp-dpcd[7]);
 
if (status != connector_status_connected)
-   return status;
+   goto out;
 
-   if (intel_dp-force_audio) {
-   intel_dp-has_audio = intel_dp-force_audio  0;
-   } else {
-   edid = intel_dp_get_edid(connector, intel_dp-adapter);
-   if (edid) {
-   intel_dp-has_audio = drm_detect_monitor_audio(edid);
-   connector-display_info.raw_edid = NULL;
-   kfree(edid

Re: [Intel-gfx] [PATCH 3/3 v2] drm/i915: hot plug/unplug notification to HDMI audio driver

2011-11-22 Thread Wu Fengguang
  The X environment will eventually call mode_set when the user
  environment decides to use the monitor. Any audio bits can, and should,
  await the user's choice of a video mode before choosing the audio format
  to use. We should not be adding eld information until the monitor is in
  use.
 
 Yeah. I just tested the full gnome desktop and find it behave like the
 KMS console:
 
 1) -mode_set will be called
 2) crtc is 0 in intel_hdmi_hotplug(), hence skipping the ELD code there
 
 So the v3 patch will behave equally well on KMS console, gnome desktop
 and bare X. Shall we just use it, or go back and use the original
 -hot_remove patch?

Here is the patch with updated comments and changelog to reflect the
new findings.

---
Subject: drm/i915: hot plug/unplug notification to HDMI audio driver
Date: Fri Nov 11 13:49:04 CST 2011

On monitor hot plug/unplug, update ELD and set/clear SDVO_AUDIO_ENABLE
or DP_AUDIO_OUTPUT_ENABLE accordingly.  So that the audio driver will
receive hot plug events and take action to refresh its device state and
ELD contents.

A new callback -hotplug() is added to struct drm_connector_funcs which
will be called immediately after -detect() knowing that the monitor is
either plugged or unplugged.

It's noticed that X may not call -mode_set() at monitor hot plug, so it's
necessary to call drm_edid_to_eld() earlier at -detect() time rather than
in intel_ddc_get_modes(), so that intel_write_eld() can see the new ELD
in -hotplug.

The call sequence on hot plug is
(the difference part lies in -mode_set vs -hotplug)

- KMS console
-detect
  drm_edid_to_eld
-mode_set
  intel_write_eld
  set SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE
- X
-detect
  drm_edid_to_eld
-hotplug
  intel_write_eld
  set SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE

On hot remove, the call sequence is

-hotplug
  clear SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE

cc: Wang Zhenyu zhenyu.z.w...@intel.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/drm_crtc_helper.c  |6 +++
 drivers/gpu/drm/i915/intel_dp.c|   44 +--
 drivers/gpu/drm/i915/intel_hdmi.c  |   31 +++
 drivers/gpu/drm/i915/intel_modes.c |2 -
 include/drm/drm_crtc.h |1 
 5 files changed, 72 insertions(+), 12 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_dp.c  2011-11-21 11:26:09.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_dp.c   2011-11-21 14:12:21.0 
+0800
@@ -28,6 +28,7 @@
 #include linux/i2c.h
 #include linux/slab.h
 #include linux/export.h
+#include drm/drm_edid.h
 #include drmP.h
 #include drm.h
 #include drm_crtc.h
@@ -1970,20 +1971,44 @@ intel_dp_detect(struct drm_connector *co
if (status != connector_status_connected)
return status;
 
-   if (intel_dp-force_audio) {
-   intel_dp-has_audio = intel_dp-force_audio  0;
-   } else {
-   edid = intel_dp_get_edid(connector, intel_dp-adapter);
-   if (edid) {
-   intel_dp-has_audio = drm_detect_monitor_audio(edid);
-   connector-display_info.raw_edid = NULL;
-   kfree(edid);
-   }
+   edid = intel_dp_get_edid(connector, intel_dp-adapter);
+   if (edid) {
+   intel_dp-has_audio = drm_detect_monitor_audio(edid);
+   drm_edid_to_eld(connector, edid);
+   connector-display_info.raw_edid = NULL;
+   kfree(edid);
}
 
+   if (intel_dp-force_audio)
+   intel_dp-has_audio = intel_dp-force_audio  0;
+
return connector_status_connected;
 }
 
+static void intel_dp_hotplug(struct drm_connector *connector)
+{
+   struct intel_dp *intel_dp = intel_attached_dp(connector);
+   struct drm_device *dev = intel_dp-base.base.dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct drm_crtc *crtc = intel_dp-base.base.crtc;
+
+   DRM_DEBUG_DRIVER(DisplayPort hotplug status %d crtc %p eld %#x\n,
+connector-status,
+crtc,
+(unsigned int)connector-eld[0]);
+
+   if (connector-status == connector_status_disconnected) {
+   intel_dp-DP = ~DP_AUDIO_OUTPUT_ENABLE;
+   } else if (connector-status == connector_status_connected  crtc) {
+   intel_write_eld(intel_dp-base.base, crtc-mode);
+   intel_dp-DP |= DP_AUDIO_OUTPUT_ENABLE;
+   } else {
+   return;
+   }
+   I915_WRITE(intel_dp-output_reg, intel_dp-DP);
+   POSTING_READ(intel_dp-output_reg);
+}
+
 static int intel_dp_get_modes(struct drm_connector *connector)
 {
struct intel_dp *intel_dp = intel_attached_dp(connector);
@@ -2143,6 +2168,7 @@ static const struct drm_connector_funcs 
.detect = intel_dp_detect,
.fill_modes

Re: [Intel-gfx] [PATCH 3/3] drm/i915: hot removal notification to HDMI audio driver

2011-11-21 Thread Wu Fengguang
On Mon, Nov 21, 2011 at 04:47:38PM +0800, Takashi Iwai wrote:
 At Mon, 21 Nov 2011 09:58:09 +0800,
 Wu Fengguang wrote:
  
  On Sat, Nov 19, 2011 at 01:46:44AM +0800, Keith Packard wrote:
   On Fri, 18 Nov 2011 17:37:40 +0800, Wu Fengguang fengguang...@intel.com 
   wrote:
   
However when in X, -mode_set won't be called at all.  Only
-get_modes and -detect are called...
   
   The desktop software will call mode_set when it configures the
   monitor. Otherwise, it's not being used (and so shouldn't have audio
   routed to it by default).
  
  Keith, I experimented playing HDMI audio in X, and during the time
  unplug and plug the monitor. The HDMI audio/graphics all continue to
  work when plugged in the monitor again. Here is the dmesg showed for
  the plug event, no -mode_set is called at all...
 
 Which desktop system are you using?  At hotplug/unplugging, the kernel
 drm issues a udev event, X Intel driver receives it and updates
 Xrandr.  Then it's supposed that a daemon like gnome-settings-daemon
 receives Xrandr notification and changes the modes appropriately.
 Without such a background task, there will be no mode change.

Ah I got it. I'm running debian+fluxbox w/o those fancy features...

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


Re: [Intel-gfx] [PATCH 3/3 v2] drm/i915: hot plug/unplug notification to HDMI audio driver

2011-11-21 Thread Wu Fengguang
On Tue, Nov 22, 2011 at 12:55:43AM +0800, Keith Packard wrote:
 On Mon, 21 Nov 2011 14:37:49 +0800, Wu Fengguang fengguang...@intel.com 
 wrote:
  On monitor hot plug/unplug, update ELD and set/clear SDVO_AUDIO_ENABLE
  or DP_AUDIO_OUTPUT_ENABLE accordingly.  So that the audio driver will
  receive hot plug events and take action to refresh its device state and
  ELD contents.
  
  A new callback -hotplug() is added to struct drm_connector_funcs which
  will be called immediately after -detect() knowing that the monitor is
  either plugged or unplugged.
  
  It's noticed that X may not call -mode_set() at monitor hot plug, so it's
  necessary to call drm_edid_to_eld() earlier at -detect() time rather than
  in intel_ddc_get_modes(), so that intel_write_eld() can see the new ELD
  in -hotplug.
 
 The X environment will eventually call mode_set when the user
 environment decides to use the monitor. Any audio bits can, and should,
 await the user's choice of a video mode before choosing the audio format
 to use. We should not be adding eld information until the monitor is in
 use.

Yeah. I just tested the full gnome desktop and find it behave like the
KMS console:

1) -mode_set will be called
2) crtc is 0 in intel_hdmi_hotplug(), hence skipping the ELD code there

So the v3 patch will behave equally well on KMS console, gnome desktop
and bare X. Shall we just use it, or go back and use the original
-hot_remove patch?

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


Re: [Intel-gfx] [PATCH 3/3] drm/i915: hot removal notification to HDMI audio driver

2011-11-20 Thread Wu Fengguang
On Sat, Nov 19, 2011 at 01:46:44AM +0800, Keith Packard wrote:
 On Fri, 18 Nov 2011 17:37:40 +0800, Wu Fengguang fengguang...@intel.com 
 wrote:
 
  However when in X, -mode_set won't be called at all.  Only
  -get_modes and -detect are called...
 
 The desktop software will call mode_set when it configures the
 monitor. Otherwise, it's not being used (and so shouldn't have audio
 routed to it by default).

Keith, I experimented playing HDMI audio in X, and during the time
unplug and plug the monitor. The HDMI audio/graphics all continue to
work when plugged in the monitor again. Here is the dmesg showed for
the plug event, no -mode_set is called at all...

[ 1296.469103] [drm:drm_mode_getconnector], [CONNECTOR:5:?]
[ 1296.475442] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:5:VGA-1]
[ 1296.483649] [drm:intel_ironlake_crt_detect_hotplug], ironlake hotplug 
adpa=0x83f4, result 1
[ 1296.493417] [drm:intel_crt_detect], CRT detected via hotplug
[ 1296.562579] [drm:drm_edid_to_eld], ELD: no CEA Extension found
[ 1296.564700] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:5:VGA-1] probed modes :
[ 1296.567609] [drm:drm_mode_debug_printmodeline], Modeline 24:1024x768 60 
65000 1024 1048 1184 1344 768 771 777 806 0x48 0xa
[ 1296.572112] [drm:drm_mode_debug_printmodeline], Modeline 23:1024x768 75 
78800 1024 1040 1136 1312 768 769 772 800 0x40 0x5
[ 1296.576561] [drm:drm_mode_debug_printmodeline], Modeline 25:800x600 75 
49500 800 816 896 1056 600 601 604 625 0x40 0x5
[ 1296.579109] [drm:drm_mode_debug_printmodeline], Modeline 19:800x600 60 
4 800 840 968 1056 600 601 605 628 0x40 0x5
[ 1296.581403] [drm:drm_mode_debug_printmodeline], Modeline 20:640x480 75 
31500 640 656 720 840 480 481 484 500 0x40 0xa
[ 1296.584027] [drm:drm_mode_debug_printmodeline], Modeline 21:640x480 60 
25200 640 656 752 800 480 490 492 525 0x40 0xa
[ 1296.587294] [drm:drm_mode_debug_printmodeline], Modeline 22:720x400 70 
28320 720 738 846 900 400 412 414 449 0x40 0x6
[ 1296.589849] [drm:drm_mode_getconnector], [CONNECTOR:5:?]
[ 1296.593635] [drm:drm_mode_getconnector], [CONNECTOR:8:?]
[ 1296.595157] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:8:HDMI-A-1]
[ 1296.608219] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:8:HDMI-A-1] disconnected
[ 1296.610732] [drm:drm_mode_getconnector], [CONNECTOR:8:?]
[ 1296.611939] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:8:HDMI-A-1]
[ 1296.624882] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:8:HDMI-A-1] disconnected
[ 1296.627445] [drm:drm_mode_getconnector], [CONNECTOR:12:?]
[ 1296.628814] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:12:HDMI-A-2]
[ 1296.750591] [drm:drm_detect_monitor_audio], Monitor has basic audio support
[ 1296.873062] [drm:drm_edid_to_eld], ELD monitor SONY TV
[ 1296.874819] HDMI: DVI dual 0, max TMDS clock 5, latency present 0 0, video 
latency 0 81, audio latency 114 208
[ 1296.877018] [drm:drm_edid_to_eld], ELD size 8, SAD count 1
[ 1296.878468] [drm:drm_mode_debug_printmodeline], Modeline 45:1920x1080i 0 
74250 1920 2448 2492 2640 1080 1084 1094 1125 0x40 0x15
[ 1296.880862] [drm:drm_mode_prune_invalid], Not using 1920x1080i mode 7
[ 1296.882454] [drm:drm_mode_debug_printmodeline], Modeline 44:1920x1080i 0 
74250 1920 2008 2052 2200 1080 1084 1094 1125 0x40 0x15
[ 1296.885996] [drm:drm_mode_prune_invalid], Not using 1920x1080i mode 7
[ 1296.887573] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:12:HDMI-A-2] probed modes :
[ 1296.889507] [drm:drm_mode_debug_printmodeline], Modeline 37:1920x1080 50 
148500 1920 2448 2492 2640 1080 1084 1089 1125 0x48 0x5
[ 1296.892084] [drm:drm_mode_debug_printmodeline], Modeline 43:1280x720 50 
74250 1280 1720 1760 1980 720 725 730 750 0x40 0x5
[ 1296.894657] [drm:drm_mode_debug_printmodeline], Modeline 41:1280x720 60 
74250 1280 1390 1430 1650 720 725 730 750 0x40 0x5
[ 1296.897053] [drm:drm_mode_debug_printmodeline], Modeline 32:720x576 50 
27000 720 732 796 864 576 581 586 625 0x40 0xa
[ 1296.899603] [drm:drm_mode_debug_printmodeline], Modeline 29:720x480 60 
27000 720 736 798 858 480 489 495 525 0x40 0xa
[ 1296.901979] [drm:drm_mode_getconnector], [CONNECTOR:12:?]
[ 1296.906084] [drm:drm_mode_getconnector], [CONNECTOR:13:?]
[ 1296.907545] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:13:DP-1]
[ 1296.909659] [drm:intel_dp_aux_ch], dp_aux_ch timeout status 0x5145003e
[ 1296.913429] [drm:intel_dp_aux_ch], dp_aux_ch timeout status 0x5145003e
[ 1296.917418] [drm:intel_dp_aux_ch], dp_aux_ch timeout status 0x5145003e
[ 1296.920908] [drm:intel_dp_detect], DPCD: 
[ 1296.922663] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:13:DP-1] disconnected
[ 1296.924543] [drm:drm_mode_getconnector], [CONNECTOR:13:?]
[ 1296.925793] [drm:drm_helper_probe_single_connector_modes], 
[CONNECTOR:13:DP-1]
[ 1296.927920] [drm:intel_dp_aux_ch], dp_aux_ch timeout status 0x5145003e
[ 1296.931393] [drm:intel_dp_aux_ch

[Intel-gfx] [PATCH 3/3 v2] drm/i915: hot plug/unplug notification to HDMI audio driver

2011-11-20 Thread Wu Fengguang
On monitor hot plug/unplug, update ELD and set/clear SDVO_AUDIO_ENABLE
or DP_AUDIO_OUTPUT_ENABLE accordingly.  So that the audio driver will
receive hot plug events and take action to refresh its device state and
ELD contents.

A new callback -hotplug() is added to struct drm_connector_funcs which
will be called immediately after -detect() knowing that the monitor is
either plugged or unplugged.

It's noticed that X may not call -mode_set() at monitor hot plug, so it's
necessary to call drm_edid_to_eld() earlier at -detect() time rather than
in intel_ddc_get_modes(), so that intel_write_eld() can see the new ELD
in -hotplug.

The call sequence on hot plug is
(the difference part lies in -mode_set vs -hotplug)

- KMS console
-detect
  drm_edid_to_eld
-mode_set
  intel_write_eld
  set SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE
- X
-detect
  drm_edid_to_eld
-hotplug
  intel_write_eld
  set SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE

On hot remove, the call sequence is

-hotplug
  clear SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE

cc: Wang Zhenyu zhenyu.z.w...@intel.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/drm_crtc_helper.c  |5 ++-
 drivers/gpu/drm/i915/intel_dp.c|   44 +--
 drivers/gpu/drm/i915/intel_hdmi.c  |   31 +++
 drivers/gpu/drm/i915/intel_modes.c |2 -
 include/drm/drm_crtc.h |1 
 5 files changed, 71 insertions(+), 12 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_dp.c  2011-11-21 11:26:09.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_dp.c   2011-11-21 14:12:21.0 
+0800
@@ -28,6 +28,7 @@
 #include linux/i2c.h
 #include linux/slab.h
 #include linux/export.h
+#include drm/drm_edid.h
 #include drmP.h
 #include drm.h
 #include drm_crtc.h
@@ -1970,20 +1971,44 @@ intel_dp_detect(struct drm_connector *co
if (status != connector_status_connected)
return status;
 
-   if (intel_dp-force_audio) {
-   intel_dp-has_audio = intel_dp-force_audio  0;
-   } else {
-   edid = intel_dp_get_edid(connector, intel_dp-adapter);
-   if (edid) {
-   intel_dp-has_audio = drm_detect_monitor_audio(edid);
-   connector-display_info.raw_edid = NULL;
-   kfree(edid);
-   }
+   edid = intel_dp_get_edid(connector, intel_dp-adapter);
+   if (edid) {
+   intel_dp-has_audio = drm_detect_monitor_audio(edid);
+   drm_edid_to_eld(connector, edid);
+   connector-display_info.raw_edid = NULL;
+   kfree(edid);
}
 
+   if (intel_dp-force_audio)
+   intel_dp-has_audio = intel_dp-force_audio  0;
+
return connector_status_connected;
 }
 
+static void intel_dp_hotplug(struct drm_connector *connector)
+{
+   struct intel_dp *intel_dp = intel_attached_dp(connector);
+   struct drm_device *dev = intel_dp-base.base.dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct drm_crtc *crtc = intel_dp-base.base.crtc;
+
+   DRM_DEBUG_DRIVER(DisplayPort hotplug status %d crtc %p eld %#x\n,
+connector-status,
+crtc,
+(unsigned int)connector-eld[0]);
+
+   if (connector-status == connector_status_disconnected) {
+   intel_dp-DP = ~DP_AUDIO_OUTPUT_ENABLE;
+   } else if (connector-status == connector_status_connected  crtc) {
+   intel_write_eld(intel_dp-base.base, crtc-mode);
+   intel_dp-DP |= DP_AUDIO_OUTPUT_ENABLE;
+   } else {
+   return;
+   }
+   I915_WRITE(intel_dp-output_reg, intel_dp-DP);
+   POSTING_READ(intel_dp-output_reg);
+}
+
 static int intel_dp_get_modes(struct drm_connector *connector)
 {
struct intel_dp *intel_dp = intel_attached_dp(connector);
@@ -2143,6 +2168,7 @@ static const struct drm_connector_funcs 
.detect = intel_dp_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = intel_dp_set_property,
+   .hotplug = intel_dp_hotplug,
.destroy = intel_dp_destroy,
 };
 
--- linux.orig/drivers/gpu/drm/i915/intel_hdmi.c2011-11-21 
11:26:09.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_hdmi.c 2011-11-21 14:12:26.0 
+0800
@@ -337,6 +337,7 @@ intel_hdmi_detect(struct drm_connector *
status = connector_status_connected;
intel_hdmi-has_hdmi_sink = 
drm_detect_hdmi_monitor(edid);
intel_hdmi-has_audio = drm_detect_monitor_audio(edid);
+   drm_edid_to_eld(connector, edid);
}
connector-display_info.raw_edid = NULL;
kfree(edid);
@@ -350,6 +351,35 @@ intel_hdmi_detect(struct drm_connector *
return

Re: [Intel-gfx] [PATCH 3/3] drm/i915: hot removal notification to HDMI audio driver

2011-11-18 Thread Wu Fengguang
Update: Just tested DP and its working!

However, it's found that hot plug under X won't work...

The previous hot plug tests are done in KMS console which are all
fine: on re-inserting the monitor, -mode_set will be called and
HDMI/DP audio will be re-enabled and ELD be transfered.

However when in X, -mode_set won't be called at all.  Only
-get_modes and -detect are called...

Thanks,
Fengguang

On Wed, Nov 16, 2011 at 09:35:48PM +0800, Wu Fengguang wrote:
 Sorry forgot to remove this left over chunk...
 
 Note that I've not yet got the hardware to test the DisplayPort part
 of this patch, but should be able to do so this week.
 
  --- linux.orig/drivers/gpu/drm/i915/intel_drv.h 2011-11-16 
  20:54:27.0 +0800
  +++ linux/drivers/gpu/drm/i915/intel_drv.h  2011-11-16 21:19:42.0 
  +0800
  @@ -382,6 +382,10 @@ extern void intel_fb_restore_mode(struct
   extern void intel_init_clock_gating(struct drm_device *dev);
   extern void intel_write_eld(struct drm_encoder *encoder,
  struct drm_display_mode *mode);
  +extern void intel_hotplug_status(struct drm_device *dev,
  + struct drm_connector *connector,
  + struct drm_crtc *crtc,
  + enum drm_connector_status status);
   extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
   
   #endif /* __INTEL_DRV_H__ */
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 3/3] drm/i915: hot removal notification to HDMI audio driver

2011-11-18 Thread Wu Fengguang
On Sat, Nov 19, 2011 at 01:46:44AM +0800, Keith Packard wrote:
 On Fri, 18 Nov 2011 17:37:40 +0800, Wu Fengguang fengguang...@intel.com 
 wrote:
 
  However when in X, -mode_set won't be called at all.  Only
  -get_modes and -detect are called...
 
 The desktop software will call mode_set when it configures the
 monitor. Otherwise, it's not being used (and so shouldn't have audio
 routed to it by default).

Thanks for the info! I'll (borrow some monitor and) double check next week.

Anyway, the first two patches are good and may be taken first.

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


[Intel-gfx] [PATCH 0/3] HDMI ELD fixes for 3.2

2011-11-16 Thread Wu Fengguang
Keith,

Here are 3 fixes on HDMI/ELD audio.

The third one adds a -hot_remove hook to drm_connector_funcs. Please review.

[PATCH 1/3] drm/i915: fix ELD writing for SandyBridge
[PATCH 2/3] drm/i915: dont trigger hotplug events on unchanged ELD
[PATCH 3/3] drm/i915: hot removal notification to HDMI audio driver

Thanks,
Fengguang

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


[Intel-gfx] [PATCH 2/3] drm/i915: dont trigger hotplug events on unchanged ELD

2011-11-16 Thread Wu Fengguang
The ELD may or may not change when switching the video mode.
If unchanged, don't trigger hot plug events to HDMI audio driver.

This avoids disturbing the user with repeated printks.

Reported-by: Nick Bowler nbow...@elliptictech.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/intel_display.c |   51 ++---
 1 file changed, 46 insertions(+), 5 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-10 
17:23:04.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-10 17:59:25.0 
+0800
@@ -5811,6 +5811,35 @@ static int intel_crtc_mode_set(struct dr
return ret;
 }
 
+static bool intel_eld_uptodate(struct drm_connector *connector,
+  int reg_eldv, uint32_t bits_eldv,
+  int reg_elda, uint32_t bits_elda,
+  int reg_edid)
+{
+   struct drm_i915_private *dev_priv = connector-dev-dev_private;
+   uint8_t *eld = connector-eld;
+   uint32_t i;
+
+   i = I915_READ(reg_eldv);
+   i = bits_eldv;
+
+   if (!eld[0])
+   return !i;
+
+   if (!i)
+   return false;
+
+   i = I915_READ(reg_elda);
+   i = ~bits_elda;
+   I915_WRITE(reg_elda, i);
+
+   for (i = 0; i  eld[2]; i++)
+   if (I915_READ(reg_edid) != *((uint32_t *)eld + i))
+   return false;
+
+   return true;
+}
+
 static void g4x_write_eld(struct drm_connector *connector,
  struct drm_crtc *crtc)
 {
@@ -5827,6 +5856,12 @@ static void g4x_write_eld(struct drm_con
else
eldv = G4X_ELDV_DEVCTG;
 
+   if (intel_eld_uptodate(connector,
+  G4X_AUD_CNTL_ST, eldv,
+  G4X_AUD_CNTL_ST, G4X_ELD_ADDR,
+  G4X_HDMIW_HDMIEDID))
+   return;
+
i = I915_READ(G4X_AUD_CNTL_ST);
i = ~(eldv | G4X_ELD_ADDR);
len = (i  9)  0x1f;  /* ELD buffer size */
@@ -5886,6 +5921,17 @@ static void ironlake_write_eld(struct dr
eldv = GEN5_ELD_VALIDB  ((i - 1) * 4);
}
 
+   if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
+   DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
+   eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
+   }
+
+   if (intel_eld_uptodate(connector,
+  aud_cntrl_st2, eldv,
+  aud_cntl_st, GEN5_ELD_ADDRESS,
+  hdmiw_hdmiedid))
+   return;
+
i = I915_READ(aud_cntrl_st2);
i = ~eldv;
I915_WRITE(aud_cntrl_st2, i);
@@ -5893,11 +5939,6 @@ static void ironlake_write_eld(struct dr
if (!eld[0])
return;
 
-   if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
-   DRM_DEBUG_DRIVER(ELD: DisplayPort detected\n);
-   eld[5] |= (1  2); /* Conn_Type, 0x1 = DisplayPort */
-   }
-
i = I915_READ(aud_cntl_st);
i = ~GEN5_ELD_ADDRESS;
I915_WRITE(aud_cntl_st, i);


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


[Intel-gfx] [PATCH 1/3] drm/i915: fix ELD writing for SandyBridge

2011-11-16 Thread Wu Fengguang
SandyBridge should be using the same register addresses as IvyBridge.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |6 +++---
 drivers/gpu/drm/i915/intel_display.c |   10 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2011-11-09 13:17:19.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2011-11-09 13:18:39.0 
+0800
@@ -3543,8 +3543,8 @@
 #define GEN5_ELD_VALIDB(1  0)
 #define GEN5_CP_READYB (1  1)
 
-#define GEN7_HDMIW_HDMIEDID_A  0xE5050
-#define GEN7_AUD_CNTRL_ST_A0xE50B4
-#define GEN7_AUD_CNTRL_ST2 0xE50C0
+#define GEN6_HDMIW_HDMIEDID_A  0xE5050
+#define GEN6_AUD_CNTL_ST_A 0xE50B4
+#define GEN6_AUD_CNTRL_ST2 0xE50C0
 
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-09 
13:19:28.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-09 13:20:02.0 
+0800
@@ -5857,14 +5857,14 @@ static void ironlake_write_eld(struct dr
int aud_cntl_st;
int aud_cntrl_st2;
 
-   if (IS_IVYBRIDGE(connector-dev)) {
-   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
-   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
-   } else {
+   if (IS_GEN5(connector-dev)) {
hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
aud_cntl_st = GEN5_AUD_CNTL_ST_A;
aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   } else {
+   hdmiw_hdmiedid = GEN6_HDMIW_HDMIEDID_A;
+   aud_cntl_st = GEN6_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = GEN6_AUD_CNTRL_ST2;
}
 
i = to_intel_crtc(crtc)-pipe;


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


[Intel-gfx] [PATCH 3/3] drm/i915: hot removal notification to HDMI audio driver

2011-11-16 Thread Wu Fengguang
On monitor hot removal:

1) clear SDVO_AUDIO_ENABLE or DP_AUDIO_OUTPUT_ENABLE
2) clear ELD Valid bit

So that the audio driver will receive hot plug events and take action to
refresh its device state and ELD contents.

cc: Wang Zhenyu zhenyu.z.w...@intel.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/drm_crtc_helper.c |4 
 drivers/gpu/drm/i915/intel_dp.c   |   17 +
 drivers/gpu/drm/i915/intel_drv.h  |4 
 drivers/gpu/drm/i915/intel_hdmi.c |   17 +
 include/drm/drm_crtc.h|1 +
 5 files changed, 43 insertions(+)

--- linux.orig/drivers/gpu/drm/i915/intel_dp.c  2011-11-16 20:54:28.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_dp.c   2011-11-16 21:19:42.0 
+0800
@@ -1984,6 +1984,22 @@ intel_dp_detect(struct drm_connector *co
return connector_status_connected;
 }
 
+static void intel_dp_hot_remove(struct drm_connector *connector)
+{
+   struct intel_dp *intel_dp = intel_attached_dp(connector);
+   struct drm_device *dev = intel_dp-base.base.dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct drm_crtc *crtc = intel_dp-base.base.crtc;
+
+   intel_dp-DP = ~DP_AUDIO_OUTPUT_ENABLE;
+   I915_WRITE(intel_dp-output_reg, intel_dp-DP);
+   POSTING_READ(intel_dp-output_reg);
+
+   connector-eld[0] = 0;
+   if (dev_priv-display.write_eld)
+   dev_priv-display.write_eld(connector, crtc);
+}
+
 static int intel_dp_get_modes(struct drm_connector *connector)
 {
struct intel_dp *intel_dp = intel_attached_dp(connector);
@@ -2143,6 +2159,7 @@ static const struct drm_connector_funcs 
.detect = intel_dp_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = intel_dp_set_property,
+   .hot_remove = intel_dp_hot_remove,
.destroy = intel_dp_destroy,
 };
 
--- linux.orig/drivers/gpu/drm/i915/intel_drv.h 2011-11-16 20:54:27.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_drv.h  2011-11-16 21:19:42.0 
+0800
@@ -382,6 +382,10 @@ extern void intel_fb_restore_mode(struct
 extern void intel_init_clock_gating(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
struct drm_display_mode *mode);
+extern void intel_hotplug_status(struct drm_device *dev,
+ struct drm_connector *connector,
+ struct drm_crtc *crtc,
+ enum drm_connector_status status);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
 
 #endif /* __INTEL_DRV_H__ */
--- linux.orig/drivers/gpu/drm/i915/intel_hdmi.c2011-11-16 
20:55:13.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_hdmi.c 2011-11-16 21:19:42.0 
+0800
@@ -350,6 +350,22 @@ intel_hdmi_detect(struct drm_connector *
return status;
 }
 
+static void intel_hdmi_hot_remove(struct drm_connector *connector)
+{
+   struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
+   struct drm_i915_private *dev_priv = connector-dev-dev_private;
+   u32 temp;
+
+   temp = I915_READ(intel_hdmi-sdvox_reg);
+   I915_WRITE(intel_hdmi-sdvox_reg, temp  ~SDVO_AUDIO_ENABLE);
+   POSTING_READ(intel_hdmi-sdvox_reg);
+
+   connector-eld[0] = 0;
+   if (dev_priv-display.write_eld)
+   dev_priv-display.write_eld(connector,
+   intel_hdmi-base.base.crtc);
+}
+
 static int intel_hdmi_get_modes(struct drm_connector *connector)
 {
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
@@ -459,6 +475,7 @@ static const struct drm_connector_funcs 
.detect = intel_hdmi_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = intel_hdmi_set_property,
+   .hot_remove = intel_hdmi_hot_remove,
.destroy = intel_hdmi_destroy,
 };
 
--- linux.orig/drivers/gpu/drm/drm_crtc_helper.c2011-11-16 
20:55:13.0 +0800
+++ linux/drivers/gpu/drm/drm_crtc_helper.c 2011-11-16 21:19:42.0 
+0800
@@ -905,6 +905,10 @@ static void output_poll_execute(struct w
  old_status, connector-status);
if (old_status != connector-status)
changed = true;
+   if (old_status == connector_status_connected 
+   connector-status == connector_status_disconnected)
+   connector-funcs-hot_remove(connector);
+
}
 
mutex_unlock(dev-mode_config.mutex);
--- linux.orig/include/drm/drm_crtc.h   2011-11-16 20:54:28.0 +0800
+++ linux/include/drm/drm_crtc.h2011-11-16 21:19:42.0 +0800
@@ -419,6 +419,7 @@ struct drm_connector_funcs {
int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, 
uint32_t max_height);
int (*set_property)(struct drm_connector *connector, struct 
drm_property

Re: [Intel-gfx] [PATCH 3/3] drm/i915: hot removal notification to HDMI audio driver

2011-11-16 Thread Wu Fengguang
Sorry forgot to remove this left over chunk...

Note that I've not yet got the hardware to test the DisplayPort part
of this patch, but should be able to do so this week.

 --- linux.orig/drivers/gpu/drm/i915/intel_drv.h   2011-11-16 
 20:54:27.0 +0800
 +++ linux/drivers/gpu/drm/i915/intel_drv.h2011-11-16 21:19:42.0 
 +0800
 @@ -382,6 +382,10 @@ extern void intel_fb_restore_mode(struct
  extern void intel_init_clock_gating(struct drm_device *dev);
  extern void intel_write_eld(struct drm_encoder *encoder,
   struct drm_display_mode *mode);
 +extern void intel_hotplug_status(struct drm_device *dev,
 +   struct drm_connector *connector,
 +   struct drm_crtc *crtc,
 +   enum drm_connector_status status);
  extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
  
  #endif /* __INTEL_DRV_H__ */
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 3/3 v2] drm/i915: hot removal notification to HDMI audio driver

2011-11-16 Thread Wu Fengguang
On monitor hot removal:

1) clear SDVO_AUDIO_ENABLE or DP_AUDIO_OUTPUT_ENABLE
2) clear ELD Valid bit

So that the audio driver will receive hot plug events and take action to
refresh its device state and ELD contents.

cc: Wang Zhenyu zhenyu.z.w...@intel.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/drm_crtc_helper.c |4 
 drivers/gpu/drm/i915/intel_dp.c   |   17 +
 drivers/gpu/drm/i915/intel_hdmi.c |   17 +
 include/drm/drm_crtc.h|1 +
 4 files changed, 39 insertions(+)

--- linux.orig/drivers/gpu/drm/i915/intel_dp.c  2011-11-16 21:36:58.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_dp.c   2011-11-16 21:37:00.0 
+0800
@@ -1984,6 +1984,22 @@ intel_dp_detect(struct drm_connector *co
return connector_status_connected;
 }
 
+static void intel_dp_hot_remove(struct drm_connector *connector)
+{
+   struct intel_dp *intel_dp = intel_attached_dp(connector);
+   struct drm_device *dev = intel_dp-base.base.dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct drm_crtc *crtc = intel_dp-base.base.crtc;
+
+   intel_dp-DP = ~DP_AUDIO_OUTPUT_ENABLE;
+   I915_WRITE(intel_dp-output_reg, intel_dp-DP);
+   POSTING_READ(intel_dp-output_reg);
+
+   connector-eld[0] = 0;
+   if (dev_priv-display.write_eld)
+   dev_priv-display.write_eld(connector, crtc);
+}
+
 static int intel_dp_get_modes(struct drm_connector *connector)
 {
struct intel_dp *intel_dp = intel_attached_dp(connector);
@@ -2143,6 +2159,7 @@ static const struct drm_connector_funcs 
.detect = intel_dp_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = intel_dp_set_property,
+   .hot_remove = intel_dp_hot_remove,
.destroy = intel_dp_destroy,
 };
 
--- linux.orig/drivers/gpu/drm/i915/intel_hdmi.c2011-11-16 
21:36:58.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_hdmi.c 2011-11-16 21:37:00.0 
+0800
@@ -350,6 +350,22 @@ intel_hdmi_detect(struct drm_connector *
return status;
 }
 
+static void intel_hdmi_hot_remove(struct drm_connector *connector)
+{
+   struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
+   struct drm_i915_private *dev_priv = connector-dev-dev_private;
+   u32 temp;
+
+   temp = I915_READ(intel_hdmi-sdvox_reg);
+   I915_WRITE(intel_hdmi-sdvox_reg, temp  ~SDVO_AUDIO_ENABLE);
+   POSTING_READ(intel_hdmi-sdvox_reg);
+
+   connector-eld[0] = 0;
+   if (dev_priv-display.write_eld)
+   dev_priv-display.write_eld(connector,
+   intel_hdmi-base.base.crtc);
+}
+
 static int intel_hdmi_get_modes(struct drm_connector *connector)
 {
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
@@ -459,6 +475,7 @@ static const struct drm_connector_funcs 
.detect = intel_hdmi_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = intel_hdmi_set_property,
+   .hot_remove = intel_hdmi_hot_remove,
.destroy = intel_hdmi_destroy,
 };
 
--- linux.orig/drivers/gpu/drm/drm_crtc_helper.c2011-11-16 
21:36:58.0 +0800
+++ linux/drivers/gpu/drm/drm_crtc_helper.c 2011-11-16 21:37:00.0 
+0800
@@ -905,6 +905,10 @@ static void output_poll_execute(struct w
  old_status, connector-status);
if (old_status != connector-status)
changed = true;
+   if (old_status == connector_status_connected 
+   connector-status == connector_status_disconnected)
+   connector-funcs-hot_remove(connector);
+
}
 
mutex_unlock(dev-mode_config.mutex);
--- linux.orig/include/drm/drm_crtc.h   2011-11-16 21:36:58.0 +0800
+++ linux/include/drm/drm_crtc.h2011-11-16 21:37:00.0 +0800
@@ -419,6 +419,7 @@ struct drm_connector_funcs {
int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, 
uint32_t max_height);
int (*set_property)(struct drm_connector *connector, struct 
drm_property *property,
 uint64_t val);
+   void (*hot_remove)(struct drm_connector *connector);
void (*destroy)(struct drm_connector *connector);
void (*force)(struct drm_connector *connector);
 };
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [alsa-devel] [PATCH 2/2] hda - delayed ELD repoll

2011-11-16 Thread Wu Fengguang
On Wed, Nov 16, 2011 at 11:51:28PM +0800, Stephen Warren wrote:
 Wu Fengguang wrote at Tuesday, November 15, 2011 7:48 PM:
  On Wed, Nov 16, 2011 at 02:25:00AM +0800, Stephen Warren wrote:
   Wu Fengguang wrote at Tuesday, November 15, 2011 7:33 AM:
The Intel HDMI chips (ironlake at least) are found to have ~250ms delay
between the ELD_Valid=1 hotplug event is send and the ELD buffer becomes
actually readable. During the time the ELD buffer is mysteriously all 0.
   
Fix it by scheduling a delayed work to re-read ELD buffer after 300ms.
  
   Any idea why; is the graphics driver writing the ELD data to the audio HW
   after triggering the unsolicited even rather than before, or something
   like that?
  
  Nope. The graphics driver is doing
  
  eld_valid = 0
  write to eld buffer
  eld_valid = 1
 
 OK, that sounds fine.
 
   250mS almost sounds like it's setting ELDV in the audio HW,
   then going and reading the EDID, then writing the EDID to the audio HW;
   perhaps the graphics driver is accidentally setting PRESENT+ELDV when it's
   meant to be setting just PRESENT, and later setting ELDV?
  
  From the debug dmesg, I'm pretty sure that the ELDV events are
  triggered exactly by the eld_valid = 0 and eld_valid = 1 register
  writes. Since the ELD data is already prepared, there is no EDID read
  in between.
  
  Below is the dmesg representing a video mode set.
  
  ELD writes from the graphics driver
  
  [  424.254958] [drm:intel_write_eld], ELD on [CONNECTOR:12:HDMI-A-2], 
  [ENCODER:11:TMDS-11]
  [  424.257670] [drm:ironlake_write_eld], ELD on pipe B
  [  424.259833] [drm:ironlake_write_eld], Audio directed to unknown port
  [  424.262156] [drm:ironlake_write_eld], ELD size 13
  
  ELD events received by audio driver (eld reads 0)
  
  [  424.263258] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 
  ELD_Valid=0
 
 That line makes sense.
 
  [  424.265877] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
 
 I don't /think/ it's related to this issue, but I wonder why ELDV==1 in
 that message; it seems that the unsolicited response contains the correct
 data, but AC_VERB_GET_PIN_SENSE contains ELDV==1 all the time. That's odd.

It depends on timing. When audio driver receives the unsolicited event, 
graphics driver has finished with eld_valid = 1, hence
AC_VERB_GET_PIN_SENSE returns ELDV=1.

It's not happening /all the time/ though. For example here is another
dmesg showing a different timing on the same test box.

[  467.561516] [drm:intel_dp_mode_set], Enabling DP audio on pipe B
[  467.567503] [drm:intel_write_eld], ELD on [CONNECTOR:26:DP-3], 
[ENCODER:27:TMDS-27]
[  467.574207] [drm:ironlake_write_eld], ELD on pipe B
[  467.579346] [drm:ironlake_write_eld], Audio directed to unknown port
[  467.584724] [drm:ironlake_write_eld], ELD: DisplayPort detected
[  467.586540] HDMI hot plug event: Codec=3 Pin=7 Presence_Detect=1 ELD_Valid=0
[  467.599608] [drm:ironlake_write_eld],
[  467.599922] HDMI status: Codec=3 Pin=7 Presence_Detect=1 ELD_Valid=0
[  467.605834] ELD size 9   
[  467.610434] [drm:sandybridge_update_wm], FIFO watermarks For pipe A - plane 
7, cursor: 6
[  467.612365] HDMI hot plug event: Codec=3 Pin=7 Presence_Detect=1 ELD_Valid=1
[  467.620654] [drm:sandybridge_update_wm], 
[  467.620765] HDMI status: Codec=3 Pin=7 Presence_Detect=1 ELD_Valid=1

  [  424.272415] ALSA hda_eld.c:259 HDMI: Unknown ELD version 0
  [  424.274566] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 
  ELD_Valid=1
  [  424.277027] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
  [  424.283157] ALSA hda_eld.c:259 HDMI: Unknown ELD version 0
  
  graphics driver go on with its job
  
  [  424.314331] [drm:intel_wait_for_vblank], vblank wait timed out
  [  424.367183] [drm:intel_wait_for_vblank], vblank wait timed out
  [  424.368960] [drm:ironlake_update_wm], FIFO watermarks For pipe A - plane 
  5, cursor: 6
  [  424.370700] [drm:ironlake_update_wm], FIFO watermarks For pipe B - plane 
  42, cursor: 6
  [  424.424056] [drm:intel_wait_for_vblank], vblank wait timed out
  [  424.476906] [drm:intel_wait_for_vblank], vblank wait timed out
  [  424.479169] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x100
  [  424.481084] [drm:ironlake_fdi_link_train], FDI train 1 done.
  [  424.483452] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x600
  [  424.485444] [drm:ironlake_fdi_link_train], FDI train 2 done.
  [  424.486765] [drm:ironlake_fdi_link_train], FDI train done
  [  424.490820] [drm:intel_update_fbc],
  [  424.491841] [drm:drm_crtc_helper_set_config], Setting connector DPMS 
  state to on
  [  424.494449] [drm:drm_crtc_helper_set_config],
  [CONNECTOR:12:HDMI-A-2] set DPMS on
  [  424.505904] [drm:intel_prepare_page_flip], preparing flip with no unpin 
  work?
  
  audio driver repoll the ELD after 300ms (eld data readable now)
  
  [  424.574763] HDMI status: Codec=3

Re: [Intel-gfx] [alsa-devel] [PATCH 2/2] hda - delayed ELD repoll

2011-11-16 Thread Wu Fengguang
   Below is the dmesg representing a video mode set.
   
   ELD writes from the graphics driver
   
   [  424.254958] [drm:intel_write_eld], ELD on [CONNECTOR:12:HDMI-A-2], 
   [ENCODER:11:TMDS-11]
   [  424.257670] [drm:ironlake_write_eld], ELD on pipe B
   [  424.259833] [drm:ironlake_write_eld], Audio directed to unknown port
   [  424.262156] [drm:ironlake_write_eld], ELD size 13
   
   ELD events received by audio driver (eld reads 0)
   
   [  424.263258] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 
   ELD_Valid=0
  
  That line makes sense.
  
   [  424.265877] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
  
  I don't /think/ it's related to this issue, but I wonder why ELDV==1 in
  that message; it seems that the unsolicited response contains the correct
  data, but AC_VERB_GET_PIN_SENSE contains ELDV==1 all the time. That's odd.
 
 It depends on timing. When audio driver receives the unsolicited event, 
 graphics driver has finished with eld_valid = 1, hence
 AC_VERB_GET_PIN_SENSE returns ELDV=1.
 
 It's not happening /all the time/ though. For example here is another
 dmesg showing a different timing on the same test box.

Sorry this is actually from another test box. But I did see similar
ones from the same test box.

 [  467.561516] [drm:intel_dp_mode_set], Enabling DP audio on pipe B
 [  467.567503] [drm:intel_write_eld], ELD on [CONNECTOR:26:DP-3], 
 [ENCODER:27:TMDS-27]
 [  467.574207] [drm:ironlake_write_eld], ELD on pipe B
 [  467.579346] [drm:ironlake_write_eld], Audio directed to unknown port
 [  467.584724] [drm:ironlake_write_eld], ELD: DisplayPort detected
 [  467.586540] HDMI hot plug event: Codec=3 Pin=7 Presence_Detect=1 
 ELD_Valid=0
 [  467.599608] [drm:ironlake_write_eld],
 [  467.599922] HDMI status: Codec=3 Pin=7 Presence_Detect=1 ELD_Valid=0
 [  467.605834] ELD size 9   
 [  467.610434] [drm:sandybridge_update_wm], FIFO watermarks For pipe A - 
 plane 7, cursor: 6
 [  467.612365] HDMI hot plug event: Codec=3 Pin=7 Presence_Detect=1 
 ELD_Valid=1
 [  467.620654] [drm:sandybridge_update_wm], 
 [  467.620765] HDMI status: Codec=3 Pin=7 Presence_Detect=1 ELD_Valid=1
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 1/2] hda - fix ELD memory leak

2011-11-15 Thread Wu Fengguang
memset(eld) clears eld-proc_entry which will leak the struct
snd_info_entry when unloading the module.

Fix it by
- remove memset(eld)
- set eld-eld_valid to true _after_ all eld fields have been filled
- don't access the other eld fields when (eld-eld_valid == false)

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 sound/pci/hda/hda_eld.c|5 +
 sound/pci/hda/patch_hdmi.c |   11 +--
 2 files changed, 6 insertions(+), 10 deletions(-)

--- linux.orig/sound/pci/hda/hda_eld.c  2011-11-15 21:02:25.0 +0800
+++ linux/sound/pci/hda/hda_eld.c   2011-11-15 21:13:46.0 +0800
@@ -297,10 +297,10 @@ static int hdmi_update_eld(struct hdmi_e
buf + ELD_FIXED_BYTES + mnl + 3 * i);
}
 
+   e-eld_valid = true;
return 0;
 
 out_fail:
-   e-eld_ver = 0;
return -EINVAL;
 }
 
@@ -323,9 +323,6 @@ int snd_hdmi_get_eld(struct hdmi_eld *el
 * ELD is valid, actual eld_size is assigned in hdmi_update_eld()
 */
 
-   if (!eld-eld_valid)
-   return -ENOENT;
-
size = snd_hdmi_get_eld_size(codec, nid);
if (size == 0) {
/* wfg: workaround for ASUS P5E-VM HDMI board */
--- linux.orig/sound/pci/hda/patch_hdmi.c   2011-11-15 21:02:25.0 
+0800
+++ linux/sound/pci/hda/patch_hdmi.c2011-11-15 21:13:42.0 +0800
@@ -980,20 +980,19 @@ static void hdmi_present_sense(struct hd
 * the unsolicited response to avoid custom WARs.
 */
int present = snd_hda_pin_sense(codec, pin_nid);
+   bool eld_valid = false;
 
-   memset(eld, 0, sizeof(*eld));
+   eld-eld_valid = false;
 
eld-monitor_present= !!(present  AC_PINSENSE_PRESENCE);
if (eld-monitor_present)
-   eld-eld_valid  = !!(present  AC_PINSENSE_ELDV);
-   else
-   eld-eld_valid  = 0;
+   eld_valid   = !!(present  AC_PINSENSE_ELDV);
 
printk(KERN_INFO
HDMI status: Codec=%d Pin=%d Presence_Detect=%d 
ELD_Valid=%d\n,
-   codec-addr, pin_nid, eld-monitor_present, eld-eld_valid);
+   codec-addr, pin_nid, eld-monitor_present, eld_valid);
 
-   if (eld-eld_valid)
+   if (eld_valid)
if (!snd_hdmi_get_eld(eld, codec, pin_nid))
snd_hdmi_show_eld(eld);
 
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 2/2] hda - delayed ELD repoll

2011-11-15 Thread Wu Fengguang
The Intel HDMI chips (ironlake at least) are found to have ~250ms delay
between the ELD_Valid=1 hotplug event is send and the ELD buffer becomes
actually readable. During the time the ELD buffer is mysteriously all 0.

Fix it by scheduling a delayed work to re-read ELD buffer after 300ms.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 sound/pci/hda/hda_local.h  |2 +
 sound/pci/hda/patch_hdmi.c |   49 ++-
 2 files changed, 44 insertions(+), 7 deletions(-)

--- linux.orig/sound/pci/hda/hda_local.h2011-11-15 21:29:53.0 
+0800
+++ linux/sound/pci/hda/hda_local.h 2011-11-15 21:29:54.0 +0800
@@ -655,6 +655,8 @@ struct hdmi_eld {
 #ifdef CONFIG_PROC_FS
struct snd_info_entry *proc_entry;
 #endif
+   struct hda_codec *codec;
+   struct delayed_work work;
 };
 
 int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
--- linux.orig/sound/pci/hda/patch_hdmi.c   2011-11-15 21:29:53.0 
+0800
+++ linux/sound/pci/hda/patch_hdmi.c2011-11-15 21:31:48.0 +0800
@@ -746,7 +746,7 @@ static void hdmi_setup_audio_infoframe(s
  */
 
 static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
-  struct hdmi_eld *eld);
+  struct hdmi_eld *eld, bool retry);
 
 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
 {
@@ -766,7 +766,7 @@ static void hdmi_intrinsic_event(struct 
return;
eld = spec-pins[pin_idx].sink_eld;
 
-   hdmi_present_sense(codec, pin_nid, eld);
+   hdmi_present_sense(codec, pin_nid, eld, true);
 
/*
 * HDMI sink's ELD info cannot always be retrieved for now, e.g.
@@ -969,7 +969,7 @@ static int hdmi_read_pin_conn(struct hda
 }
 
 static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
-  struct hdmi_eld *eld)
+  struct hdmi_eld *eld, bool retry)
 {
/*
 * Always execute a GetPinSense verb here, even when called from
@@ -992,13 +992,31 @@ static void hdmi_present_sense(struct hd
HDMI status: Codec=%d Pin=%d Presence_Detect=%d 
ELD_Valid=%d\n,
codec-addr, pin_nid, eld-monitor_present, eld_valid);
 
-   if (eld_valid)
+   if (eld_valid) {
if (!snd_hdmi_get_eld(eld, codec, pin_nid))
snd_hdmi_show_eld(eld);
+   else {
+   queue_delayed_work(codec-bus-workq,
+  eld-work,
+  msecs_to_jiffies(300));
+   }
+   }
 
snd_hda_input_jack_report(codec, pin_nid);
 }
 
+static void hda_eld_work(struct work_struct *work)
+{
+   struct hdmi_eld *eld = container_of(
+   container_of(work, struct delayed_work, work),
+   struct hdmi_eld, work);
+   struct hdmi_spec_per_pin *per_pin =
+   container_of(eld, struct hdmi_spec_per_pin, sink_eld);
+   struct hda_codec *codec = eld-codec;
+
+   hdmi_present_sense(codec, per_pin-pin_nid, eld, false);
+}
+
 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
 {
struct hdmi_spec *spec = codec-spec;
@@ -1227,7 +1245,7 @@ static int generic_hdmi_build_jack(struc
if (err  0)
return err;
 
-   hdmi_present_sense(codec, per_pin-pin_nid, per_pin-sink_eld);
+   hdmi_present_sense(codec, per_pin-pin_nid, per_pin-sink_eld, false);
return 0;
 }
 
@@ -1263,6 +1281,23 @@ static int generic_hdmi_build_controls(s
return 0;
 }
 
+static void snd_hda_eld_init(struct hda_codec *codec, struct hdmi_eld *eld,
+int pin_idx)
+{
+   eld-codec = codec;
+   INIT_DELAYED_WORK(eld-work, hda_eld_work);
+
+   snd_hda_eld_proc_new(codec, eld, pin_idx);
+}
+
+static void snd_hda_eld_free(struct hda_codec *codec, struct hdmi_eld *eld)
+{
+   cancel_delayed_work(eld-work);
+   flush_workqueue(codec-bus-workq);
+
+   snd_hda_eld_proc_free(codec, eld);
+}
+
 static int generic_hdmi_init(struct hda_codec *codec)
 {
struct hdmi_spec *spec = codec-spec;
@@ -1278,7 +1313,7 @@ static int generic_hdmi_init(struct hda_
AC_VERB_SET_UNSOLICITED_ENABLE,
AC_USRSP_EN | pin_nid);
 
-   snd_hda_eld_proc_new(codec, eld, pin_idx);
+   snd_hda_eld_init(codec, eld, pin_idx);
}
return 0;
 }
@@ -1292,7 +1327,7 @@ static void generic_hdmi_free(struct hda
struct hdmi_spec_per_pin *per_pin = spec-pins[pin_idx];
struct hdmi_eld *eld = per_pin-sink_eld;
 
-   snd_hda_eld_proc_free(codec, eld);
+   snd_hda_eld_free(codec, eld);
}
snd_hda_input_jack_free(codec

Re: [Intel-gfx] [PATCH 1/2] hda - fix ELD memory leak

2011-11-15 Thread Wu Fengguang
On Tue, Nov 15, 2011 at 10:45:15PM +0800, Takashi Iwai wrote:
 At Tue, 15 Nov 2011 22:41:16 +0800,
 Wu Fengguang wrote:
  
  On Tue, Nov 15, 2011 at 10:35:41PM +0800, Takashi Iwai wrote:
   At Tue, 15 Nov 2011 22:31:55 +0800,
   Wu Fengguang wrote:

memset(eld) clears eld-proc_entry which will leak the struct
snd_info_entry when unloading the module.

Fix it by
- remove memset(eld)
- set eld-eld_valid to true _after_ all eld fields have been filled
- don't access the other eld fields when (eld-eld_valid == false)

Signed-off-by: Wu Fengguang fengguang...@intel.com
   
   This should be send to stable kernel, too, right?
   It appears in 3.1, at least.
  
  Yeah. Good point!  I'll resend it when everything goes fine.
 
 Ah, no, you don't need to resend.  I'd just need to put Cc to stable
 in the patch commit log.  Then Greg will pick it up automatically
 when the tree is merged to the upstream.

Ah OK, that would be convenient.

 But of course I need to know beforehand whether the patch is intended
 to be sent to stable or not.

Ack. The patch applies cleanly to 3.1.

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


Re: [Intel-gfx] [PATCH 2/2] hda - delayed ELD repoll

2011-11-15 Thread Wu Fengguang
 - if (eld_valid)
 + if (eld_valid) {
   if (!snd_hdmi_get_eld(eld, codec, pin_nid))
   snd_hdmi_show_eld(eld);
 + else {

Oops, forgot testing @retry here! Updated patch follows.

 + queue_delayed_work(codec-bus-workq,
 +eld-work,
 +msecs_to_jiffies(300));
 + }
 + }
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 2/2 v2] hda - delayed ELD repoll

2011-11-15 Thread Wu Fengguang
The Intel HDMI chips (ironlake at least) are found to have ~250ms delay
between the ELD_Valid=1 hotplug event is send and the ELD buffer becomes
actually readable. During the time the ELD buffer is mysteriously all 0.

Fix it by scheduling a delayed work to re-read ELD buffer after 300ms.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 sound/pci/hda/hda_local.h  |2 +
 sound/pci/hda/patch_hdmi.c |   49 ++-
 2 files changed, 44 insertions(+), 7 deletions(-)

--- linux.orig/sound/pci/hda/hda_local.h2011-11-15 21:29:53.0 
+0800
+++ linux/sound/pci/hda/hda_local.h 2011-11-15 21:29:54.0 +0800
@@ -655,6 +655,8 @@ struct hdmi_eld {
 #ifdef CONFIG_PROC_FS
struct snd_info_entry *proc_entry;
 #endif
+   struct hda_codec *codec;
+   struct delayed_work work;
 };
 
 int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
--- linux.orig/sound/pci/hda/patch_hdmi.c   2011-11-15 21:29:53.0 
+0800
+++ linux/sound/pci/hda/patch_hdmi.c2011-11-16 00:50:50.0 +0800
@@ -746,7 +746,7 @@ static void hdmi_setup_audio_infoframe(s
  */
 
 static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
-  struct hdmi_eld *eld);
+  struct hdmi_eld *eld, bool retry);
 
 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
 {
@@ -766,7 +766,7 @@ static void hdmi_intrinsic_event(struct 
return;
eld = spec-pins[pin_idx].sink_eld;
 
-   hdmi_present_sense(codec, pin_nid, eld);
+   hdmi_present_sense(codec, pin_nid, eld, true);
 
/*
 * HDMI sink's ELD info cannot always be retrieved for now, e.g.
@@ -969,7 +969,7 @@ static int hdmi_read_pin_conn(struct hda
 }
 
 static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
-  struct hdmi_eld *eld)
+  struct hdmi_eld *eld, bool retry)
 {
/*
 * Always execute a GetPinSense verb here, even when called from
@@ -992,13 +992,31 @@ static void hdmi_present_sense(struct hd
HDMI status: Codec=%d Pin=%d Presence_Detect=%d 
ELD_Valid=%d\n,
codec-addr, pin_nid, eld-monitor_present, eld_valid);
 
-   if (eld_valid)
+   if (eld_valid) {
if (!snd_hdmi_get_eld(eld, codec, pin_nid))
snd_hdmi_show_eld(eld);
+   else if (retry) {
+   queue_delayed_work(codec-bus-workq,
+  eld-work,
+  msecs_to_jiffies(300));
+   }
+   }
 
snd_hda_input_jack_report(codec, pin_nid);
 }
 
+static void hda_eld_work(struct work_struct *work)
+{
+   struct hdmi_eld *eld = container_of(
+   container_of(work, struct delayed_work, work),
+   struct hdmi_eld, work);
+   struct hdmi_spec_per_pin *per_pin =
+   container_of(eld, struct hdmi_spec_per_pin, sink_eld);
+   struct hda_codec *codec = eld-codec;
+
+   hdmi_present_sense(codec, per_pin-pin_nid, eld, false);
+}
+
 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
 {
struct hdmi_spec *spec = codec-spec;
@@ -1227,7 +1245,7 @@ static int generic_hdmi_build_jack(struc
if (err  0)
return err;
 
-   hdmi_present_sense(codec, per_pin-pin_nid, per_pin-sink_eld);
+   hdmi_present_sense(codec, per_pin-pin_nid, per_pin-sink_eld, false);
return 0;
 }
 
@@ -1263,6 +1281,23 @@ static int generic_hdmi_build_controls(s
return 0;
 }
 
+static void snd_hda_eld_init(struct hda_codec *codec, struct hdmi_eld *eld,
+int pin_idx)
+{
+   eld-codec = codec;
+   INIT_DELAYED_WORK(eld-work, hda_eld_work);
+
+   snd_hda_eld_proc_new(codec, eld, pin_idx);
+}
+
+static void snd_hda_eld_free(struct hda_codec *codec, struct hdmi_eld *eld)
+{
+   cancel_delayed_work(eld-work);
+   flush_workqueue(codec-bus-workq);
+
+   snd_hda_eld_proc_free(codec, eld);
+}
+
 static int generic_hdmi_init(struct hda_codec *codec)
 {
struct hdmi_spec *spec = codec-spec;
@@ -1278,7 +1313,7 @@ static int generic_hdmi_init(struct hda_
AC_VERB_SET_UNSOLICITED_ENABLE,
AC_USRSP_EN | pin_nid);
 
-   snd_hda_eld_proc_new(codec, eld, pin_idx);
+   snd_hda_eld_init(codec, eld, pin_idx);
}
return 0;
 }
@@ -1292,7 +1327,7 @@ static void generic_hdmi_free(struct hda
struct hdmi_spec_per_pin *per_pin = spec-pins[pin_idx];
struct hdmi_eld *eld = per_pin-sink_eld;
 
-   snd_hda_eld_proc_free(codec, eld);
+   snd_hda_eld_free(codec, eld);
}
snd_hda_input_jack_free(codec

Re: [Intel-gfx] [PATCH 2/2 v2] hda - delayed ELD repoll

2011-11-15 Thread Wu Fengguang
On Wed, Nov 16, 2011 at 01:10:37AM +0800, Takashi Iwai wrote:
 At Wed, 16 Nov 2011 00:57:08 +0800,
 Wu Fengguang wrote:
  +static void hda_eld_work(struct work_struct *work)
  +{
  +   struct hdmi_eld *eld = container_of(
  +   container_of(work, struct delayed_work, work),
  +   struct hdmi_eld, work);
 
 Ugh, hardly to read.  Slightly better to use to_delayed_work()?
 
   struct hdmi_eld *eld = container_of(to_delayed_work(work),
   struct hdmi_eld, work);

Yeah that looks much better! Changed to:

+static void hdmi_repoll_eld(struct work_struct *work)
+{ 
+   struct hdmi_spec_per_pin *per_pin =
+   container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work);
+   
+   hdmi_present_sense(per_pin, false);
+}

  +   struct hdmi_spec_per_pin *per_pin =
  +   container_of(eld, struct hdmi_spec_per_pin, sink_eld);
  +   struct hda_codec *codec = eld-codec;
  +
  +   hdmi_present_sense(codec, per_pin-pin_nid, eld, false);
  +}
  +
   static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
   {
  struct hdmi_spec *spec = codec-spec;
  @@ -1227,7 +1245,7 @@ static int generic_hdmi_build_jack(struc
  if (err  0)
  return err;
   
  -   hdmi_present_sense(codec, per_pin-pin_nid, per_pin-sink_eld);
  +   hdmi_present_sense(codec, per_pin-pin_nid, per_pin-sink_eld, false);
 ...
 
 Looking through the code, I wonder how about keeping work and codec
 pointer in struct hdmi_spec_per_pin instead of struct hdmi_eld.  Then
 we don't need to expose it in hda_local.h, and changes would be
 slightly more compact.
 
 hdmi_present_sense() can be modified to receive hdmi_sepc_per_pin*
 directly instead of individual nid and eld pointer.

Good idea! With the changes I get a much smaller patch :-)

I'll repost the patch series after some more testing.

Thanks,
Fengguang
---

Subject: hda - delayed ELD repoll
Date: Mon Nov 14 11:31:00 CST 2011

The Intel HDMI chips (ironlake at least) are found to have ~250ms delay
between the ELD_Valid=1 hotplug event is send and the ELD buffer becomes
actually readable. During the time the ELD buffer is mysteriously all 0.

Fix it by scheduling a delayed work to re-read ELD buffer after 300ms.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 sound/pci/hda/patch_hdmi.c |   36 ---
 1 file changed, 29 insertions(+), 7 deletions(-)

--- linux.orig/sound/pci/hda/patch_hdmi.c   2011-11-16 09:53:01.0 
+0800
+++ linux/sound/pci/hda/patch_hdmi.c2011-11-16 10:33:06.0 +0800
@@ -65,7 +65,10 @@ struct hdmi_spec_per_pin {
hda_nid_t pin_nid;
int num_mux_nids;
hda_nid_t mux_nids[HDA_MAX_CONNECTIONS];
+
+   struct hda_codec *codec;
struct hdmi_eld sink_eld;
+   struct delayed_work work;
 };
 
 struct hdmi_spec {
@@ -745,8 +748,7 @@ static void hdmi_setup_audio_infoframe(s
  * Unsolicited events
  */
 
-static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
-  struct hdmi_eld *eld);
+static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, bool retry);
 
 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
 {
@@ -766,7 +768,7 @@ static void hdmi_intrinsic_event(struct 
return;
eld = spec-pins[pin_idx].sink_eld;
 
-   hdmi_present_sense(codec, pin_nid, eld);
+   hdmi_present_sense(spec-pins[pin_idx], true);
 
/*
 * HDMI sink's ELD info cannot always be retrieved for now, e.g.
@@ -968,9 +970,11 @@ static int hdmi_read_pin_conn(struct hda
return 0;
 }
 
-static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
-  struct hdmi_eld *eld)
+static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, bool retry)
 {
+   struct hda_codec *codec = per_pin-codec;
+   struct hdmi_eld *eld = per_pin-sink_eld;
+   hda_nid_t pin_nid = per_pin-pin_nid;
/*
 * Always execute a GetPinSense verb here, even when called from
 * hdmi_intrinsic_event; for some NVIDIA HW, the unsolicited
@@ -992,13 +996,27 @@ static void hdmi_present_sense(struct hd
HDMI status: Codec=%d Pin=%d Presence_Detect=%d 
ELD_Valid=%d\n,
codec-addr, pin_nid, eld-monitor_present, eld_valid);
 
-   if (eld_valid)
+   if (eld_valid) {
if (!snd_hdmi_get_eld(eld, codec, pin_nid))
snd_hdmi_show_eld(eld);
+   else if (retry) {
+   queue_delayed_work(codec-bus-workq,
+  per_pin-work,
+  msecs_to_jiffies(300));
+   }
+   }
 
snd_hda_input_jack_report(codec, pin_nid);
 }
 
+static void hdmi_repoll_eld(struct work_struct *work)
+{
+   struct hdmi_spec_per_pin *per_pin

Re: [Intel-gfx] [alsa-devel] [PATCH 2/2] hda - delayed ELD repoll

2011-11-15 Thread Wu Fengguang
On Wed, Nov 16, 2011 at 02:25:00AM +0800, Stephen Warren wrote:
 Wu Fengguang wrote at Tuesday, November 15, 2011 7:33 AM:
  The Intel HDMI chips (ironlake at least) are found to have ~250ms delay
  between the ELD_Valid=1 hotplug event is send and the ELD buffer becomes
  actually readable. During the time the ELD buffer is mysteriously all 0.
  
  Fix it by scheduling a delayed work to re-read ELD buffer after 300ms.
 
 Any idea why; is the graphics driver writing the ELD data to the audio HW
 after triggering the unsolicited even rather than before, or something
 like that?

Nope. The graphics driver is doing

eld_valid = 0
write to eld buffer
eld_valid = 1

 250mS almost sounds like it's setting ELDV in the audio HW,
 then going and reading the EDID, then writing the EDID to the audio HW;
 perhaps the graphics driver is accidentally setting PRESENT+ELDV when it's
 meant to be setting just PRESENT, and later setting ELDV?

From the debug dmesg, I'm pretty sure that the ELDV events are
triggered exactly by the eld_valid = 0 and eld_valid = 1 register
writes. Since the ELD data is already prepared, there is no EDID read
in between.

Below is the dmesg representing a video mode set.

ELD writes from the graphics driver

[  424.254958] [drm:intel_write_eld], ELD on [CONNECTOR:12:HDMI-A-2], 
[ENCODER:11:TMDS-11]
[  424.257670] [drm:ironlake_write_eld], ELD on pipe B
[  424.259833] [drm:ironlake_write_eld], Audio directed to unknown port
[  424.262156] [drm:ironlake_write_eld], ELD size 13

ELD events received by audio driver (eld reads 0)

[  424.263258] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=0
[  424.265877] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
[  424.272415] ALSA hda_eld.c:259 HDMI: Unknown ELD version 0
[  424.274566] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
[  424.277027] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
[  424.283157] ALSA hda_eld.c:259 HDMI: Unknown ELD version 0

graphics driver go on with its job

[  424.314331] [drm:intel_wait_for_vblank], vblank wait timed out
[  424.367183] [drm:intel_wait_for_vblank], vblank wait timed out
[  424.368960] [drm:ironlake_update_wm], FIFO watermarks For pipe A - plane 5, 
cursor: 6
[  424.370700] [drm:ironlake_update_wm], FIFO watermarks For pipe B - plane 42, 
cursor: 6
[  424.424056] [drm:intel_wait_for_vblank], vblank wait timed out
[  424.476906] [drm:intel_wait_for_vblank], vblank wait timed out
[  424.479169] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x100
[  424.481084] [drm:ironlake_fdi_link_train], FDI train 1 done.
[  424.483452] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x600
[  424.485444] [drm:ironlake_fdi_link_train], FDI train 2 done.
[  424.486765] [drm:ironlake_fdi_link_train], FDI train done
[  424.490820] [drm:intel_update_fbc], 
[  424.491841] [drm:drm_crtc_helper_set_config], Setting connector DPMS state 
to on
[  424.494449] [drm:drm_crtc_helper_set_config],[CONNECTOR:12:HDMI-A-2] 
set DPMS on
[  424.505904] [drm:intel_prepare_page_flip], preparing flip with no unpin work?

audio driver repoll the ELD after 300ms (eld data readable now)

[  424.574763] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
[  424.580867] HDMI: detected monitor RX-V1800 at connection type HDMI
[  424.582413] HDMI: available speakers: FL/FR LFE FC RL/RR RC RLC/RRC
[  424.584740] HDMI: supports coding type LPCM: channels = 2, rates = 32000 
44100 48000 96000 176400 192000 384000, bits = 16 20 24
[  424.587429] HDMI: supports coding type LPCM: channels = 8, rates = 32000 
44100 48000 96000 176400 192000 384000, bits = 16 20 24
[  424.590968] HDMI: supports coding type AC-3: channels = 6, rates = 32000 
44100 48000, max bitrate = 64
[  424.594164] HDMI: supports coding type DTS: channels = 7, rates = 32000 
44100 48000 96000 176400, max bitrate = 1536000
[  424.597563] HDMI: supports coding type DSD (One Bit Audio): channels = 6, 
rates = 44100
[  424.600284] HDMI: supports coding type E-AC-3/DD+ (Dolby Digital Plus): 
channels = 8, rates = 44100 48000
[  424.602420] HDMI: supports coding type MLP (Dolby TrueHD): channels = 8, 
rates = 48000 176400 384000
[  424.604478] HDMI: supports coding type DTS-HD: channels = 8, rates = 48000 
176400 384000

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


Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-14 Thread Wu Fengguang
On Mon, Nov 14, 2011 at 05:45:12PM +0800, Takashi Iwai wrote:
 At Sat, 12 Nov 2011 10:27:26 +0800,
 Wu Fengguang wrote:
  
  (snip)
   And I'm not sure whether HDMI audio is played
   while DPMS is off.  I haven't tested it.
  
  It will go silence on DPMS. I noticed this while doing long term 
  HDMI
  audio playback tests.  This should better be fixed in future on the
  graphics side.
 
 Hm, but I wonder what could be done alternatively.
 Hopefully there is a register for video-only control...

There may be some mode that can keep video off while still keep
minimal signals to play HDMI sound?
   
   Let's hope :)
  
  Looks very possible, here is the clue of hardware support:
  
  TRANS_DP_CTL - Transcoder DisplayPort Control
  
  bit 26: Transcoder DP Audio Only Mode
 
 Good to know!  But what about HDMI?

I'm not sure.. There are no corresponding TRANS_HDMI_CTL registers...

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


Re: [Intel-gfx] HDMI monitor hot remove handling

2011-11-13 Thread Wu Fengguang
On Mon, Nov 14, 2011 at 10:05:05AM +0800, Zhenyu Wang wrote:
 On 2011.11.11 16:50:41 +0800, Wu Fengguang wrote:
 I still think you should do those in hot_plug(), to call detect() for 
 current
 status, write eld and set specific audio enable/disable bit for all 
 audio stuff.
 Just my sense, you may send RFC patch for other's comment. 
  
   yeah, mode_set() will only be in normal mode setting path and taking 
   current
   monitor's audio capability, but not on hot removal path. And if 
   connector's DPMS off,
   does audio need to care? I think no, as user might still like to hear 
   sound, right? ;)
   
   So looks currently nobody cares for hot removal, you need to set that by
   yourself somewhere.
  
  Zhenyu, according to your comments, here is the patch, tested OK on
  HDMI :)  DP not tested yet.
 
 Well, I don't think I suggested a new hook for hot removal. ;)

Yes, sorry.

 You know that hot_plug() hook is intel encoder thing, which is the place
 I think you can do audio config stuff. 

The problem is, -hot_plug() is called at the very beginning, before
-detect() is called. If doing the hot remove notifications in
-hot_plug(), the patch will add an _extra_ loop to call into
-detect().

Why not insert the functionalities somewhere after -detect() is
called and we already know it's a hot removal event?  That avoids
adding duplicate -detect() calls.

Thanks,
Fengguang

  
  This notifies the audio driver of the HDMI/DP monitor hot removal
  event.
  
  - clear SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE
  - clear ELD Valid bit
  
  Signed-off-by: Wu Fengguang fengguang...@intel.com
  ---
   drivers/gpu/drm/drm_crtc_helper.c |4 
   drivers/gpu/drm/i915/intel_dp.c   |   19 +++
   drivers/gpu/drm/i915/intel_drv.h  |4 
   drivers/gpu/drm/i915/intel_hdmi.c |   17 +
   include/drm/drm_crtc.h|1 +
   5 files changed, 45 insertions(+)
  
  --- linux.orig/drivers/gpu/drm/i915/intel_dp.c  2011-11-11 
  16:42:58.0 +0800
  +++ linux/drivers/gpu/drm/i915/intel_dp.c   2011-11-11 16:42:59.0 
  +0800
  @@ -1984,6 +1984,24 @@ intel_dp_detect(struct drm_connector *co
  return connector_status_connected;
   }
   
  +static void intel_dp_hot_remove(struct drm_connector *connector)
  +{
  +   struct intel_dp *intel_dp = intel_attached_dp(connector);
  +   struct drm_device *dev = intel_dp-base.base.dev;
  +   struct drm_i915_private *dev_priv = dev-dev_private;
  +   struct drm_crtc *crtc = intel_dp-base.base.crtc;
  +   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  +
  +   intel_dp-DP = ~DP_AUDIO_OUTPUT_ENABLE;
  +   I915_WRITE(intel_dp-output_reg, intel_dp-DP);
  +   POSTING_READ(intel_dp-output_reg);
  +   intel_wait_for_vblank(dev, intel_crtc-pipe);
  +
  +   connector-eld[0] = 0;
  +   if (dev_priv-display.write_eld)
  +   dev_priv-display.write_eld(connector, crtc);
  +}
  +
   static int intel_dp_get_modes(struct drm_connector *connector)
   {
  struct intel_dp *intel_dp = intel_attached_dp(connector);
  @@ -2143,6 +2161,7 @@ static const struct drm_connector_funcs 
  .detect = intel_dp_detect,
  .fill_modes = drm_helper_probe_single_connector_modes,
  .set_property = intel_dp_set_property,
  +   .hot_remove = intel_dp_hot_remove,
  .destroy = intel_dp_destroy,
   };
   
  --- linux.orig/drivers/gpu/drm/i915/intel_drv.h 2011-11-11 
  16:42:58.0 +0800
  +++ linux/drivers/gpu/drm/i915/intel_drv.h  2011-11-11 16:42:59.0 
  +0800
  @@ -382,6 +382,10 @@ extern void intel_fb_restore_mode(struct
   extern void intel_init_clock_gating(struct drm_device *dev);
   extern void intel_write_eld(struct drm_encoder *encoder,
  struct drm_display_mode *mode);
  +extern void intel_hotplug_status(struct drm_device *dev,
  + struct drm_connector *connector,
  + struct drm_crtc *crtc,
  + enum drm_connector_status status);
   extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
   
   #endif /* __INTEL_DRV_H__ */
  --- linux.orig/drivers/gpu/drm/i915/intel_hdmi.c2011-11-11 
  16:42:58.0 +0800
  +++ linux/drivers/gpu/drm/i915/intel_hdmi.c 2011-11-11 16:42:59.0 
  +0800
  @@ -352,6 +352,22 @@ intel_hdmi_detect(struct drm_connector *
  return status;
   }
   
  +static void intel_hdmi_hot_remove(struct drm_connector *connector)
  +{
  +   struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
  +   struct drm_i915_private *dev_priv = connector-dev-dev_private;
  +   u32 temp;
  +
  +   temp = I915_READ(intel_hdmi-sdvox_reg);
  +   I915_WRITE(intel_hdmi-sdvox_reg, temp  ~SDVO_AUDIO_ENABLE);
  +   POSTING_READ(intel_hdmi-sdvox_reg);
  +
  +   connector-eld[0] = 0;
  +   if (dev_priv-display.write_eld)
  +   dev_priv-display.write_eld(connector,
  +   intel_hdmi-base.base.crtc);
  +}
  +
   static int

Re: [Intel-gfx] HDMI monitor hot remove handling

2011-11-11 Thread Wu Fengguang
   I still think you should do those in hot_plug(), to call detect() for 
   current
   status, write eld and set specific audio enable/disable bit for all audio 
   stuff.
   Just my sense, you may send RFC patch for other's comment. 

 yeah, mode_set() will only be in normal mode setting path and taking current
 monitor's audio capability, but not on hot removal path. And if connector's 
 DPMS off,
 does audio need to care? I think no, as user might still like to hear sound, 
 right? ;)
 
 So looks currently nobody cares for hot removal, you need to set that by
 yourself somewhere.

Zhenyu, according to your comments, here is the patch, tested OK on
HDMI :)  DP not tested yet.

This notifies the audio driver of the HDMI/DP monitor hot removal
event.

- clear SDVO_AUDIO_ENABLE/DP_AUDIO_OUTPUT_ENABLE
- clear ELD Valid bit

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/drm_crtc_helper.c |4 
 drivers/gpu/drm/i915/intel_dp.c   |   19 +++
 drivers/gpu/drm/i915/intel_drv.h  |4 
 drivers/gpu/drm/i915/intel_hdmi.c |   17 +
 include/drm/drm_crtc.h|1 +
 5 files changed, 45 insertions(+)

--- linux.orig/drivers/gpu/drm/i915/intel_dp.c  2011-11-11 16:42:58.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_dp.c   2011-11-11 16:42:59.0 
+0800
@@ -1984,6 +1984,24 @@ intel_dp_detect(struct drm_connector *co
return connector_status_connected;
 }
 
+static void intel_dp_hot_remove(struct drm_connector *connector)
+{
+   struct intel_dp *intel_dp = intel_attached_dp(connector);
+   struct drm_device *dev = intel_dp-base.base.dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct drm_crtc *crtc = intel_dp-base.base.crtc;
+   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
+   intel_dp-DP = ~DP_AUDIO_OUTPUT_ENABLE;
+   I915_WRITE(intel_dp-output_reg, intel_dp-DP);
+   POSTING_READ(intel_dp-output_reg);
+   intel_wait_for_vblank(dev, intel_crtc-pipe);
+
+   connector-eld[0] = 0;
+   if (dev_priv-display.write_eld)
+   dev_priv-display.write_eld(connector, crtc);
+}
+
 static int intel_dp_get_modes(struct drm_connector *connector)
 {
struct intel_dp *intel_dp = intel_attached_dp(connector);
@@ -2143,6 +2161,7 @@ static const struct drm_connector_funcs 
.detect = intel_dp_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = intel_dp_set_property,
+   .hot_remove = intel_dp_hot_remove,
.destroy = intel_dp_destroy,
 };
 
--- linux.orig/drivers/gpu/drm/i915/intel_drv.h 2011-11-11 16:42:58.0 
+0800
+++ linux/drivers/gpu/drm/i915/intel_drv.h  2011-11-11 16:42:59.0 
+0800
@@ -382,6 +382,10 @@ extern void intel_fb_restore_mode(struct
 extern void intel_init_clock_gating(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
struct drm_display_mode *mode);
+extern void intel_hotplug_status(struct drm_device *dev,
+ struct drm_connector *connector,
+ struct drm_crtc *crtc,
+ enum drm_connector_status status);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
 
 #endif /* __INTEL_DRV_H__ */
--- linux.orig/drivers/gpu/drm/i915/intel_hdmi.c2011-11-11 
16:42:58.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_hdmi.c 2011-11-11 16:42:59.0 
+0800
@@ -352,6 +352,22 @@ intel_hdmi_detect(struct drm_connector *
return status;
 }
 
+static void intel_hdmi_hot_remove(struct drm_connector *connector)
+{
+   struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
+   struct drm_i915_private *dev_priv = connector-dev-dev_private;
+   u32 temp;
+
+   temp = I915_READ(intel_hdmi-sdvox_reg);
+   I915_WRITE(intel_hdmi-sdvox_reg, temp  ~SDVO_AUDIO_ENABLE);
+   POSTING_READ(intel_hdmi-sdvox_reg);
+
+   connector-eld[0] = 0;
+   if (dev_priv-display.write_eld)
+   dev_priv-display.write_eld(connector,
+   intel_hdmi-base.base.crtc);
+}
+
 static int intel_hdmi_get_modes(struct drm_connector *connector)
 {
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
@@ -461,6 +477,7 @@ static const struct drm_connector_funcs 
.detect = intel_hdmi_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = intel_hdmi_set_property,
+   .hot_remove = intel_hdmi_hot_remove,
.destroy = intel_hdmi_destroy,
 };
 
--- linux.orig/drivers/gpu/drm/drm_crtc_helper.c2011-11-11 
16:42:58.0 +0800
+++ linux/drivers/gpu/drm/drm_crtc_helper.c 2011-11-11 16:42:59.0 
+0800
@@ -907,6 +907,10 @@ static void output_poll_execute(struct w
  old_status, connector-status);
if (old_status != connector

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-11 Thread Wu Fengguang
On Fri, Nov 11, 2011 at 04:49:57PM +0800, Takashi Iwai wrote:
 At Fri, 11 Nov 2011 16:22:41 +0800,
 Wu Fengguang wrote:
  
  On Fri, Nov 11, 2011 at 03:40:37PM +0800, Takashi Iwai wrote:
   At Fri, 11 Nov 2011 10:29:25 +0800,
   Wu Fengguang wrote:

On Thu, Nov 10, 2011 at 10:28:19PM +0800, Takashi Iwai wrote:
 At Thu, 10 Nov 2011 21:51:50 +0800,
 Wu Fengguang wrote:
  
  So maybe the hardware is in some state that is unable to 
  provide the
  real ELD content?
 That's my guess as well. I think the hardware may still be 
 doing some 
 form of data negotiation with the HDMI display device at that 
 stage, and 
 doesn't have the copy of the EDID+ELD buffer until a tiny bit 
 later. 
 Possibly?

Look at the below dmesg. The ELD seem to available immediately 
after the DPMS
state setting..
   
   Interesting.  Does HDMI audio work at all while HDMI DPMS off?
   It clears SDVO_ENABLE bit, so this might turn off both video and
   audio?
  
  We normally see transient blank screen and silence of audio when
  switching the video mode.
 
 Well, what I suspected is that ELD won't be transferred while
 SDVO_ENABLE is cleared.

It's not about SDVO_ENABLE. The transient ELD invalid state I see in
dmesg is caused by the graphics driver doing

ELD_Valid = 0   = trigger 1st unsolicited event
   
   But why this triggers at *plugging*?  Wasn't it zero beforehand?
   If I understand correctly, changing AUD_CNTL_ST register triggers the
   HD-audio codec unsol event.  Writing even the same value matters?
  
  Sorry I assumed the mode switching context.
 
 Ah, I see.  But this could be suppressed by your patch
drm/i915: don't trigger hotplug events on unchanged ELD
 no?

Mostly. The ELD may still change if the mode switching changes the
av-sync-delay field, or suppresses the bandwidth available to audio
samples.

 (snip)
Depending on the timing, the 1st unsolicited event may see
ELD_Valid=0 (if it's fast enough) or ELD_Valid=1 (if the event
handling is delayed after the graphics driver sets ELD_Valid=1).

I know that because I literally saw both cases happening in dmesg.
The 1st hot plug event itself will send ELD_Valid=0, however the audio
driver is not trusting this and always do a status query (the HDMI
status line) whose result depends on the timing.
   
   The problem in this procedure is that this looks as if you are
   re-connecting the HDMI from the audio-codec POV.
  
  The re-connecting events can be distinguished from the
  video-mode-switching events by the Presence_Detect bit.
 
 Hm, OK, so the codec driver can simply ignore (or postpone) the case
 when the connection is kept but ELD is invalidated.

Yes.

  Here is one hot removal event (I just wrote a patch to trigger this),
  with Presence_Detect=0:
 
 One note that we don't rely on PD bit because not all (non-Intel)
 hardware report it correctly.

Oops. Do you imply ELDV is reliable on all platforms? ;-)

  [   91.777028] [drm:ironlake_write_eld], ELD on pipe B 
  [   91.778561] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=0 
  ELD_Valid=1
  [   91.783078] HDMI status: Codec=3 Pin=6 Presence_Detect=0 ELD_Valid=0
  [   91.783083] [drm:ironlake_write_eld], Audio directed to unknown port
  [   91.783095] [drm:output_poll_execute], [CONNECTOR:12:HDMI-A-2] status 
  updated from 1 to 2
  
  The HDA spec even mentioned doing some timeout mechanism for the
  Presence_Detect=1 ELD_Valid=0 state. Well it may help some corner
  cases, but perhaps not an urgent feature.
 
 Yeah, this sounds like the workaround for such a case.

Yeah, your mentioned DVI case may be always in state

Presence_Detect=1 ELD_Valid=0

where audio playback should be denied.

And there might be the error case that the 2nd event is lost or not
generated at all for changing

Presence_Detect=1 ELD_Valid=0
to
Presence_Detect=1 ELD_Valid=1

   We might end up with some delayed probe with a dedicated work_struct
   (because it's bad to have a too long delay in unsol event handler
that run on a single workq).
  
  Understand. What if the graphics driver can delay the ELD writing (I
  can try that), so that the audio driver only need to wait for
  something like 10ms? 
 
 Or, we can introduce a dirty flag, and set it when ELD is changed,
 but don't prase ELD contents yet.  First upon the next access, the
 driver updates the status, and clear the dirty flag.  We may put a
 small delay at this update, too.

It should work fine for cat /proc/asound/card0/eld* and other
interfaces, however it could still delay the printks' significantly.

And it feels not good that accessing ELD may be blocked for some time..

So I now prefer to avoid the msleep totally and schedule a delayed
work for parsing ELD.

Thanks,
Fengguang

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-11 Thread Wu Fengguang
On Fri, Nov 11, 2011 at 07:23:05PM +0800, Takashi Iwai wrote:
 At Fri, 11 Nov 2011 19:12:57 +0800,
 Wu Fengguang wrote:
  
  (snip)
 One note that we don't rely on PD bit because not all (non-Intel)
 hardware report it correctly.

Oops. Do you imply ELDV is reliable on all platforms? ;-)
   
   Oh hell, no :)
   The driver tries to probe explicitly via GET_PIN_SENSE HD-audio verb.
  
  Yeah the below HDMI status:... line. Can we rely on it then?
 
 I guess yes.  At least, it worked with Nvidia and ATI, too, so far.
 The point is that the value passed in the codec unsol event is
 unreliable for some chips.

Yeah, for example the below HDMI hot plug event. When device is hot
removed, Presence_Detect and ELD_Valid both goes 0, but the driver has
to clear them one by one. As I choose to disable SDVO_AUDIO_ENABLE
first, we see the strange Presence_Detect=0 ELD_Valid=1 combination
below.

  [   91.777028] [drm:ironlake_write_eld], ELD on pipe B 
  [   91.778561] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=0 
  ELD_Valid=1
  [   91.783078] HDMI status: Codec=3 Pin=6 Presence_Detect=0 
  ELD_Valid=0
  [   91.783083] [drm:ironlake_write_eld], Audio directed to unknown 
  port
  [   91.783095] [drm:output_poll_execute], [CONNECTOR:12:HDMI-A-2] 
  status updated from 1 to 2
  
  The HDA spec even mentioned doing some timeout mechanism for the
  Presence_Detect=1 ELD_Valid=0 state. Well it may help some corner
  cases, but perhaps not an urgent feature.
 
 Yeah, this sounds like the workaround for such a case.

Yeah, your mentioned DVI case may be always in state

Presence_Detect=1 ELD_Valid=0

where audio playback should be denied.

And there might be the error case that the 2nd event is lost or not
generated at all for changing

Presence_Detect=1 ELD_Valid=0
to
Presence_Detect=1 ELD_Valid=1

   We might end up with some delayed probe with a dedicated 
   work_struct
   (because it's bad to have a too long delay in unsol event handler
that run on a single workq).
  
  Understand. What if the graphics driver can delay the ELD writing (I
  can try that), so that the audio driver only need to wait for
  something like 10ms? 
 
 Or, we can introduce a dirty flag, and set it when ELD is changed,
 but don't prase ELD contents yet.  First upon the next access, the
 driver updates the status, and clear the dirty flag.  We may put a
 small delay at this update, too.

It should work fine for cat /proc/asound/card0/eld* and other
interfaces, however it could still delay the printks' significantly.
   
   Well, this reminds me of another question -- do we need these printks
   unconditionally?
  
  Maybe not. How about the attached patch to remove them all?
 
 I'm fine with it (better after debugging the ELD problems :)

OK, when all the ELD/hotplug stuff calms down.

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


Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-11 Thread Wu Fengguang
(snip)
 And I'm not sure whether HDMI audio is played
 while DPMS is off.  I haven't tested it.

It will go silence on DPMS. I noticed this while doing long term HDMI
audio playback tests.  This should better be fixed in future on the
graphics side.
   
   Hm, but I wonder what could be done alternatively.
   Hopefully there is a register for video-only control...
  
  There may be some mode that can keep video off while still keep
  minimal signals to play HDMI sound?
 
 Let's hope :)

Looks very possible, here is the clue of hardware support:

TRANS_DP_CTL - Transcoder DisplayPort Control

bit 26: Transcoder DP Audio Only Mode

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


[Intel-gfx] [PATCH 00/18] intel-gpu-tools: intel_audio_dump updates

2011-11-11 Thread Wu Fengguang
A bunch of cleanups, fixes and new fields to intel_audio_dump, tested OK on
G45, Ironlake and IvyBridge.


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


[Intel-gfx] [PATCH 02/18] intel_audio_dump: cleanup ACP DIP name for ironlake and CPT

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
11:00:39.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 11:01:08.0 
+0800
@@ -666,7 +666,7 @@ static void dump_ironlake(void)
 printf(AUD_CNTL_ST_A  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
BITS(dword, 30, 29), 
dip_port[BITS(dword, 30, 29)]);
 printf(AUD_CNTL_ST_A  DIP_type_enable_status Audio DIP\t\t%lu\n, 
BIT(dword, 21));
-printf(AUD_CNTL_ST_A  DIP_type_enable_status Generic 1 ACP DIP\t%lu\n, 
BIT(dword, 22));
+printf(AUD_CNTL_ST_A  DIP_type_enable_status ACP DIP\t\t%lu\n, 
BIT(dword, 22));
 printf(AUD_CNTL_ST_A  DIP_type_enable_status Generic 2 DIP\t%lu\n, 
BIT(dword, 23));
 printf(AUD_CNTL_ST_A  DIP_transmission_frequency\t\t[0x%lx] %s\n,
BITS(dword, 17, 16), 
dip_trans[BITS(dword, 17, 16)]);
@@ -677,7 +677,7 @@ static void dump_ironlake(void)
 printf(AUD_CNTL_ST_B  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
BITS(dword, 30, 29), 
dip_port[BITS(dword, 30, 29)]);
 printf(AUD_CNTL_ST_B  DIP_type_enable_status Audio DIP\t\t%lu\n, 
BIT(dword, 21));
-printf(AUD_CNTL_ST_B  DIP_type_enable_status Generic 1 ACP DIP\t%lu\n, 
BIT(dword, 22));
+printf(AUD_CNTL_ST_B  DIP_type_enable_status ACP DIP\t\t%lu\n, 
BIT(dword, 22));
 printf(AUD_CNTL_ST_B  DIP_type_enable_status Generic 2 DIP\t%lu\n, 
BIT(dword, 23));
 printf(AUD_CNTL_ST_B  DIP_transmission_frequency\t\t[0x%lx] %s\n,
BITS(dword, 17, 16), 
dip_trans[BITS(dword, 17, 16)]);
@@ -1068,8 +1068,8 @@ static void dump_cpt(void)
 dword = INREG(AUD_CNTL_ST_A);
 printf(AUD_CNTL_ST_A  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
BITS(dword, 30, 29), 
dip_port[BITS(dword, 30, 29)]);
-printf(AUD_CNTL_ST_A  DIP_type_enable_status Audio DIP\t\t%lu\n, 
BIT(dword, 21));
-printf(AUD_CNTL_ST_A  DIP_type_enable_status Generic 1 ACP DIP\t%lu\n, 
BIT(dword, 22));
+printf(AUD_CNTL_ST_A  DIP_type_enable_status Audio DIP\t%lu\n, 
BIT(dword, 21));
+printf(AUD_CNTL_ST_A  DIP_type_enable_status ACP DIP\t\t%lu\n, 
BIT(dword, 22));
 printf(AUD_CNTL_ST_A  DIP_type_enable_status Generic 2 DIP\t%lu\n, 
BIT(dword, 23));
 printf(AUD_CNTL_ST_A  DIP_transmission_frequency\t\t[0x%lx] %s\n,
BITS(dword, 17, 16), 
dip_trans[BITS(dword, 17, 16)]);
@@ -1079,8 +1079,8 @@ static void dump_cpt(void)
 dword = INREG(AUD_CNTL_ST_B);
 printf(AUD_CNTL_ST_B  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
BITS(dword, 30, 29), 
dip_port[BITS(dword, 30, 29)]);
-printf(AUD_CNTL_ST_B  DIP_type_enable_status Audio DIP\t\t%lu\n, 
BIT(dword, 21));
-printf(AUD_CNTL_ST_B  DIP_type_enable_status Generic 1 ACP DIP\t%lu\n, 
BIT(dword, 22));
+printf(AUD_CNTL_ST_B  DIP_type_enable_status Audio DIP\t%lu\n, 
BIT(dword, 21));
+printf(AUD_CNTL_ST_B  DIP_type_enable_status ACP DIP\t\t%lu\n, 
BIT(dword, 22));
 printf(AUD_CNTL_ST_B  DIP_type_enable_status Generic 2 DIP\t%lu\n, 
BIT(dword, 23));
 printf(AUD_CNTL_ST_B  DIP_transmission_frequency\t\t[0x%lx] %s\n,
BITS(dword, 17, 16), 
dip_trans[BITS(dword, 17, 16)]);
@@ -1090,8 +1090,8 @@ static void dump_cpt(void)
 dword = INREG(AUD_CNTL_ST_C);
 printf(AUD_CNTL_ST_C  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
BITS(dword, 30, 29), 
dip_port[BITS(dword, 30, 29)]);
-printf(AUD_CNTL_ST_C  DIP_type_enable_status Audio DIP\t\t%lu\n, 
BIT(dword, 21));
-printf(AUD_CNTL_ST_C  DIP_type_enable_status Generic 1 ACP DIP\t%lu\n, 
BIT(dword, 22));
+printf(AUD_CNTL_ST_C  DIP_type_enable_status Audio DIP\t%lu\n, 
BIT(dword, 21));
+printf(AUD_CNTL_ST_C  DIP_type_enable_status ACP DIP\t\t%lu\n, 
BIT(dword, 22));
 printf(AUD_CNTL_ST_C  DIP_type_enable_status Generic 2 DIP\t%lu\n, 
BIT(dword, 23));
 printf(AUD_CNTL_ST_C  DIP_transmission_frequency\t\t[0x%lx] %s\n,
BITS(dword, 17, 16), 
dip_trans[BITS(dword, 17, 16)]);


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


[Intel-gfx] [PATCH 01/18] intel_audio_dump: cleanup hyphen character

2011-11-11 Thread Wu Fengguang
Convert ­ (Hex 00ad) to - (Hex 2d), the former leads to ugly outputs
in some situations.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   70 ++---
 1 file changed, 35 insertions(+), 35 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
11:01:19.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 11:01:26.0 
+0800
@@ -495,31 +495,31 @@ static void dump_ironlake(void)
 dump_reg(HDMIB,sDVO/HDMI Port B Control);
 dump_reg(HDMIC,HDMI Port C Control);
 dump_reg(HDMID,HDMI Port D Control);
-dump_reg(AUD_CONFIG_A, Audio Configuration ­ Transcoder A);
-dump_reg(AUD_CONFIG_B, Audio Configuration ­ Transcoder B);
-dump_reg(AUD_CTS_ENABLE_A, Audio CTS Programming Enable ­ 
Transcoder A);
-dump_reg(AUD_CTS_ENABLE_B, Audio CTS Programming Enable ­ 
Transcoder B);
+dump_reg(AUD_CONFIG_A, Audio Configuration - Transcoder A);
+dump_reg(AUD_CONFIG_B, Audio Configuration - Transcoder B);
+dump_reg(AUD_CTS_ENABLE_A, Audio CTS Programming Enable - 
Transcoder A);
+dump_reg(AUD_CTS_ENABLE_B, Audio CTS Programming Enable - 
Transcoder B);
 dump_reg(AUD_MISC_CTRL_A,  Audio MISC Control for Transcoder A);
 dump_reg(AUD_MISC_CTRL_B,  Audio MISC Control for Transcoder B);
 dump_reg(AUD_VID_DID,  Audio Vendor ID / Device ID);
 dump_reg(AUD_RID,  Audio Revision ID);
 dump_reg(AUD_PWRST,Audio Power State (Function 
Group, Convertor, Pin Widget));
 dump_reg(AUD_PORT_EN_HD_CFG,   Audio Port Enable HDAudio Config);
-dump_reg(AUD_OUT_DIG_CNVT_A,   Audio Digital Converter ­ Conv A);
-dump_reg(AUD_OUT_DIG_CNVT_B,   Audio Digital Converter ­ Conv B);
+dump_reg(AUD_OUT_DIG_CNVT_A,   Audio Digital Converter - Conv A);
+dump_reg(AUD_OUT_DIG_CNVT_B,   Audio Digital Converter - Conv B);
 dump_reg(AUD_OUT_CH_STR,   Audio Channel ID and Stream ID);
-dump_reg(AUD_OUT_STR_DESC_A,   Audio Stream Descriptor Format ­ Conv 
A);
-dump_reg(AUD_OUT_STR_DESC_B,   Audio Stream Descriptor Format ­ Conv 
B);
+dump_reg(AUD_OUT_STR_DESC_A,   Audio Stream Descriptor Format - Conv 
A);
+dump_reg(AUD_OUT_STR_DESC_B,   Audio Stream Descriptor Format - Conv 
B);
 dump_reg(AUD_PINW_CONNLNG_LIST,Audio Connection List);
 dump_reg(AUD_PINW_CONNLNG_SEL, Audio Connection Select);
-dump_reg(AUD_CNTL_ST_A,Audio Control State Register ­ 
Transcoder A);
-dump_reg(AUD_CNTL_ST_B,Audio Control State Register ­ 
Transcoder B);
+dump_reg(AUD_CNTL_ST_A,Audio Control State Register - 
Transcoder A);
+dump_reg(AUD_CNTL_ST_B,Audio Control State Register - 
Transcoder B);
 dump_reg(AUD_CNTL_ST2, Audio Control State 2);
 dump_reg(AUD_HDMIW_STATUS, Audio HDMI Status);
-dump_reg(AUD_HDMIW_HDMIEDID_A, HDMI Data EDID Block ­ Transcoder A);
-dump_reg(AUD_HDMIW_HDMIEDID_B, HDMI Data EDID Block ­ Transcoder B);
-dump_reg(AUD_HDMIW_INFOFR_A,   Audio Widget Data Island Packet ­ 
Transcoder A);
-dump_reg(AUD_HDMIW_INFOFR_B,   Audio Widget Data Island Packet ­ 
Transcoder B);
+dump_reg(AUD_HDMIW_HDMIEDID_A, HDMI Data EDID Block - Transcoder A);
+dump_reg(AUD_HDMIW_HDMIEDID_B, HDMI Data EDID Block - Transcoder B);
+dump_reg(AUD_HDMIW_INFOFR_A,   Audio Widget Data Island Packet - 
Transcoder A);
+dump_reg(AUD_HDMIW_INFOFR_B,   Audio Widget Data Island Packet - 
Transcoder B);
 
 printf(\nDetails:\n\n);
 
@@ -825,12 +825,12 @@ static void dump_cpt(void)
 dump_reg(HDMIB,sDVO/HDMI Port B Control);
 dump_reg(HDMIC,HDMI Port C Control);
 dump_reg(HDMID,HDMI Port D Control);
-dump_reg(AUD_CONFIG_A, Audio Configuration ­ Transcoder A);
-dump_reg(AUD_CONFIG_B, Audio Configuration ­ Transcoder B);
-dump_reg(AUD_CONFIG_C, Audio Configuration ­ Transcoder C);
-dump_reg(AUD_CTS_ENABLE_A, Audio CTS Programming Enable ­ 
Transcoder A);
-dump_reg(AUD_CTS_ENABLE_B, Audio CTS Programming Enable ­ 
Transcoder B);
-dump_reg(AUD_CTS_ENABLE_C, Audio CTS Programming Enable ­ 
Transcoder C);
+dump_reg(AUD_CONFIG_A, Audio Configuration - Transcoder A);
+dump_reg(AUD_CONFIG_B, Audio Configuration - Transcoder B);
+dump_reg(AUD_CONFIG_C, Audio Configuration - Transcoder C);
+dump_reg(AUD_CTS_ENABLE_A, Audio CTS Programming Enable - 
Transcoder A);
+dump_reg(AUD_CTS_ENABLE_B, Audio CTS Programming Enable - 
Transcoder B

[Intel-gfx] [PATCH 04/18] intel_audio_dump: report effective channel count

2011-11-11 Thread Wu Fengguang
The raw channel count is not user friendly and may be misleading.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-09 
16:21:43.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-09 16:22:23.0 
+0800
@@ -367,16 +367,16 @@ static void dump_eaglelake(void)
 
 dword = INREG(AUD_OUT_CH_STR);
 printf(AUD_OUT_CH_STR stream id\t\t0x%lx\n,BITS(dword, 7, 4));
-printf(AUD_OUT_CH_STR lowest channel\t\t0x%lx\n,   BITS(dword, 3, 0));
+printf(AUD_OUT_CH_STR lowest channel\t\t%lu\n, BITS(dword, 3, 0));
 
 dword = INREG(AUD_OUT_STR_DESC);
-printf(AUD_OUT_STR_DESC stream channels\t0x%lx\n,  BITS(dword, 3, 0));
+printf(AUD_OUT_STR_DESC stream channels\t%lu\n,BITS(dword, 3, 0) + 
1);
 
 dword = INREG(AUD_PINW_CAP);
 printf(AUD_PINW_CAP widget type\t\t0x%lx\n,BITS(dword, 23, 20));
 printf(AUD_PINW_CAP sample delay\t\t0x%lx\n,   BITS(dword, 19, 16));
-printf(AUD_PINW_CAP channel count\t\t0x%lx\n,
-   BITS(dword, 15, 13) * 2 + BIT(dword, 0));
+printf(AUD_PINW_CAP channel count\t\t%lu\n,
+   BITS(dword, 15, 13) * 2 + BIT(dword, 0) + 1);
 printf(AUD_PINW_CAP HDCP\t\t\t%lu\n,   BIT(dword, 12));
 printf(AUD_PINW_CAP L-R swap\t\t\t%lu\n,   BIT(dword, 11));
 printf(AUD_PINW_CAP power control\t\t%lu\n,BIT(dword, 10));
@@ -647,13 +647,13 @@ static void dump_ironlake(void)
 
 dword = INREG(AUD_OUT_STR_DESC_A);
 printf(AUD_OUT_STR_DESC_A  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
-printf(AUD_OUT_STR_DESC_A  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16));
+printf(AUD_OUT_STR_DESC_A  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
 printf(AUD_OUT_STR_DESC_A  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
 printf(AUD_OUT_STR_DESC_A  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_OUT_STR_DESC_B);
 printf(AUD_OUT_STR_DESC_B  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
-printf(AUD_OUT_STR_DESC_B  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16));
+printf(AUD_OUT_STR_DESC_B  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
 printf(AUD_OUT_STR_DESC_B  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
 printf(AUD_OUT_STR_DESC_B  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
@@ -1044,19 +1044,19 @@ static void dump_cpt(void)
 
 dword = INREG(AUD_OUT_STR_DESC_A);
 printf(AUD_OUT_STR_DESC_A  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
-printf(AUD_OUT_STR_DESC_A  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16));
+printf(AUD_OUT_STR_DESC_A  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
 printf(AUD_OUT_STR_DESC_A  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
 printf(AUD_OUT_STR_DESC_A  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_OUT_STR_DESC_B);
 printf(AUD_OUT_STR_DESC_B  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
-printf(AUD_OUT_STR_DESC_B  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16));
+printf(AUD_OUT_STR_DESC_B  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
 printf(AUD_OUT_STR_DESC_B  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
 printf(AUD_OUT_STR_DESC_B  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_OUT_STR_DESC_C);
 printf(AUD_OUT_STR_DESC_C  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
-printf(AUD_OUT_STR_DESC_C  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16));
+printf(AUD_OUT_STR_DESC_C  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
 printf(AUD_OUT_STR_DESC_C  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
 printf(AUD_OUT_STR_DESC_C  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 


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


[Intel-gfx] [PATCH 06/18] intel_audio_dump: fix Digital_Port_D_Detected copypaste error

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-09 
10:35:34.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-09 10:35:35.0 
+0800
@@ -537,7 +537,7 @@ static void dump_ironlake(void)
 printf(HDMIB HDMIB_Enable\t\t\t\t\t%u\n,  !!(dword  SDVO_ENABLE));
 printf(HDMIB Transcoder_Select\t\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
 printf(HDMIB HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
-printf(HDMIB Digital_Port_D_Detected\t\t\t\t%lu\n, BIT(dword, 2));
+printf(HDMIB Digital_Port_B_Detected\t\t\t\t%lu\n, BIT(dword, 2));
 printf(HDMIB Null_packets_enabled_during_Vsync\t\t\t%u\n,  !!(dword  
SDVO_NULL_PACKETS_DURING_VSYNC));
 printf(HDMIB Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 
@@ -545,7 +545,7 @@ static void dump_ironlake(void)
 printf(HDMIC HDMIC_Enable\t\t\t\t\t%u\n,  !!(dword  SDVO_ENABLE));
 printf(HDMIC Transcoder_Select\t\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
 printf(HDMIC HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
-printf(HDMIC Digital_Port_D_Detected\t\t\t\t%lu\n, BIT(dword, 2));
+printf(HDMIC Digital_Port_C_Detected\t\t\t\t%lu\n, BIT(dword, 2));
 printf(HDMIC Null_packets_enabled_during_Vsync\t\t\t%u\n,  !!(dword  
SDVO_NULL_PACKETS_DURING_VSYNC));
 printf(HDMIC Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 


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


[Intel-gfx] [PATCH 03/18] intel_audio_dump: cleanup hex output

2011-11-11 Thread Wu Fengguang
- no need to show the 1-bit AUD_OUT_DIG_CNVT_* as hex value
- show the Connection_select_Control_* bits as hex values

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
11:11:32.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 11:11:38.0 
+0800
@@ -615,7 +615,7 @@ static void dump_ironlake(void)
 printf(AUD_OUT_DIG_CNVT_A  VCFG\t\t\t\t%lu\n,BIT(dword, 2));
 printf(AUD_OUT_DIG_CNVT_A  PRE\t\t\t\t\t%lu\n,   BIT(dword, 3));
 printf(AUD_OUT_DIG_CNVT_A  Copy\t\t\t\t%lu\n,BIT(dword, 4));
-printf(AUD_OUT_DIG_CNVT_A  Non-Audio\t\t\t\t0x%lx\n, BIT(dword, 5));
+printf(AUD_OUT_DIG_CNVT_A  NonAudio\t\t\t\t%lu\n,
BIT(dword, 5));
 printf(AUD_OUT_DIG_CNVT_A  PRO\t\t\t\t\t%lu\n,   BIT(dword, 6));
 printf(AUD_OUT_DIG_CNVT_A  Level\t\t\t\t%lu\n,   BIT(dword, 7));
 printf(AUD_OUT_DIG_CNVT_A  Category_Code\t\t\t%lu\n, BITS(dword, 14, 
8));
@@ -627,7 +627,7 @@ static void dump_ironlake(void)
 printf(AUD_OUT_DIG_CNVT_B  VCFG\t\t\t\t%lu\n,BIT(dword, 2));
 printf(AUD_OUT_DIG_CNVT_B  PRE\t\t\t\t\t%lu\n,   BIT(dword, 3));
 printf(AUD_OUT_DIG_CNVT_B  Copy\t\t\t\t%lu\n,BIT(dword, 4));
-printf(AUD_OUT_DIG_CNVT_B  Non-Audio\t\t\t\t0x%lx\n, BIT(dword, 5));
+printf(AUD_OUT_DIG_CNVT_B  NonAudio\t\t\t\t%lu\n,
BIT(dword, 5));
 printf(AUD_OUT_DIG_CNVT_B  PRO\t\t\t\t\t%lu\n,   BIT(dword, 6));
 printf(AUD_OUT_DIG_CNVT_B  Level\t\t\t\t%lu\n,   BIT(dword, 7));
 printf(AUD_OUT_DIG_CNVT_B  Category_Code\t\t\t%lu\n, BITS(dword, 14, 
8));
@@ -1000,7 +1000,7 @@ static void dump_cpt(void)
 printf(AUD_OUT_DIG_CNVT_A  VCFG\t\t\t\t%lu\n,BIT(dword, 2));
 printf(AUD_OUT_DIG_CNVT_A  PRE\t\t\t\t\t%lu\n,   BIT(dword, 3));
 printf(AUD_OUT_DIG_CNVT_A  Copy\t\t\t\t%lu\n,BIT(dword, 4));
-printf(AUD_OUT_DIG_CNVT_A  NonAudio\t\t\t\t0x%lx\n,  BIT(dword, 5));
+printf(AUD_OUT_DIG_CNVT_A  NonAudio\t\t\t\t%lu\n,
BIT(dword, 5));
 printf(AUD_OUT_DIG_CNVT_A  PRO\t\t\t\t\t%lu\n,   BIT(dword, 6));
 printf(AUD_OUT_DIG_CNVT_A  Level\t\t\t\t%lu\n,   BIT(dword, 7));
 printf(AUD_OUT_DIG_CNVT_A  Category_Code\t\t\t%lu\n, BITS(dword, 14, 
8));
@@ -1012,7 +1012,7 @@ static void dump_cpt(void)
 printf(AUD_OUT_DIG_CNVT_B  VCFG\t\t\t\t%lu\n,BIT(dword, 2));
 printf(AUD_OUT_DIG_CNVT_B  PRE\t\t\t\t\t%lu\n,   BIT(dword, 3));
 printf(AUD_OUT_DIG_CNVT_B  Copy\t\t\t\t%lu\n,BIT(dword, 4));
-printf(AUD_OUT_DIG_CNVT_B  NonAudio\t\t\t\t0x%lx\n,  BIT(dword, 5));
+printf(AUD_OUT_DIG_CNVT_B  NonAudio\t\t\t\t%lu\n,
BIT(dword, 5));
 printf(AUD_OUT_DIG_CNVT_B  PRO\t\t\t\t\t%lu\n,   BIT(dword, 6));
 printf(AUD_OUT_DIG_CNVT_B  Level\t\t\t\t%lu\n,   BIT(dword, 7));
 printf(AUD_OUT_DIG_CNVT_B  Category_Code\t\t\t%lu\n, BITS(dword, 14, 
8));
@@ -1024,7 +1024,7 @@ static void dump_cpt(void)
 printf(AUD_OUT_DIG_CNVT_C  VCFG\t\t\t\t%lu\n,BIT(dword, 2));
 printf(AUD_OUT_DIG_CNVT_C  PRE\t\t\t\t\t%lu\n,   BIT(dword, 3));
 printf(AUD_OUT_DIG_CNVT_C  Copy\t\t\t\t%lu\n,BIT(dword, 4));
-printf(AUD_OUT_DIG_CNVT_C  NonAudio\t\t\t\t0x%lx\n,  BIT(dword, 5));
+printf(AUD_OUT_DIG_CNVT_C  NonAudio\t\t\t\t%lu\n,
BIT(dword, 5));
 printf(AUD_OUT_DIG_CNVT_C  PRO\t\t\t\t\t%lu\n,   BIT(dword, 6));
 printf(AUD_OUT_DIG_CNVT_C  Level\t\t\t\t%lu\n,   BIT(dword, 7));
 printf(AUD_OUT_DIG_CNVT_C  Category_Code\t\t\t%lu\n, BITS(dword, 14, 
8));
@@ -1061,9 +1061,9 @@ static void dump_cpt(void)
 printf(AUD_OUT_STR_DESC_C  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_PINW_CONNLNG_SEL);
-printf(AUD_PINW_CONNLNG_SEL  Connection_select_Control_B\t%lu\n, 
BITS(dword,  7,  0));
-printf(AUD_PINW_CONNLNG_SEL  Connection_select_Control_C\t%lu\n, 
BITS(dword, 15,  8));
-printf(AUD_PINW_CONNLNG_SEL  Connection_select_Control_D\t%lu\n, 
BITS(dword, 23, 16));
+printf(AUD_PINW_CONNLNG_SEL  Connection_select_Control_B\t%#lx\n, 
BITS(dword,  7,  0));
+printf(AUD_PINW_CONNLNG_SEL  Connection_select_Control_C\t%#lx\n, 
BITS(dword, 15,  8));
+printf(AUD_PINW_CONNLNG_SEL  Connection_select_Control_D\t%#lx\n, 
BITS(dword, 23, 16));
 
 dword = INREG(AUD_CNTL_ST_A);
 printf(AUD_CNTL_ST_A  DIP_Port_Select\t\t\t\t[%#lx] %s\n,


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


[Intel-gfx] [PATCH 09/18] intel_audio_dump: fix DP port width for CPT

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-09 
10:35:35.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-09 10:35:35.0 
+0800
@@ -142,8 +142,9 @@ static char *transcoder_select[] = {
 static char *dp_port_width[] = {
[0] = x1 mode,
[1] = x2 mode,
-   [2] = x4 mode,
-   [3] = reserved,
+   [2] = reserved,
+   [3] = x4 mode,
+   [4 ... 7] = reserved,
 };
 
 static void do_self_tests(void)


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


[Intel-gfx] [PATCH 05/18] intel_audio_dump: fix ironlake Stream_ID indents

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-09 
10:35:34.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-09 10:35:34.0 
+0800
@@ -620,7 +620,7 @@ static void dump_ironlake(void)
 printf(AUD_OUT_DIG_CNVT_A  Level\t\t\t\t%lu\n,   BIT(dword, 7));
 printf(AUD_OUT_DIG_CNVT_A  Category_Code\t\t\t%lu\n, BITS(dword, 14, 
8));
 printf(AUD_OUT_DIG_CNVT_A  Lowest_Channel_Number\t\t%lu\n,BITS(dword, 
19, 16));
-printf(AUD_OUT_DIG_CNVT_A  Stream_ID\t\t\t\t\t\t%lu\n,   BITS(dword, 23, 
20));
+printf(AUD_OUT_DIG_CNVT_A  Stream_ID\t\t\t\t%lu\n,   BITS(dword, 23, 
20));
 
 dword = INREG(AUD_OUT_DIG_CNVT_B);
 printf(AUD_OUT_DIG_CNVT_B  V\t\t\t\t\t%lu\n, BIT(dword, 1));
@@ -632,7 +632,7 @@ static void dump_ironlake(void)
 printf(AUD_OUT_DIG_CNVT_B  Level\t\t\t\t%lu\n,   BIT(dword, 7));
 printf(AUD_OUT_DIG_CNVT_B  Category_Code\t\t\t%lu\n, BITS(dword, 14, 
8));
 printf(AUD_OUT_DIG_CNVT_B  Lowest_Channel_Number\t\t%lu\n,BITS(dword, 
19, 16));
-printf(AUD_OUT_DIG_CNVT_B  Stream_ID\t\t\t%lu\n, BITS(dword, 23, 
20));
+printf(AUD_OUT_DIG_CNVT_B  Stream_ID\t\t\t\t%lu\n,   BITS(dword, 23, 
20));
 
 printf(AUD_OUT_CH_STR  Converter_Channel_MAP  PORTB   PORTC   
PORTD\n);
 for (i = 0; i  8; i++) {


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


[Intel-gfx] [PATCH 08/18] intel_audio_dump: fix DP control registers for CPT

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   47 +
 1 file changed, 27 insertions(+), 20 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:19:06.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:28:14.0 
+0800
@@ -764,6 +764,7 @@ static void dump_ironlake(void)
 /*
  * CougarPoint registers
  */
+#define DP_CTL_B  0xE4100
 #define DP_CTL_C  0xE4200
 #define DP_AUX_CTL_C  0xE4210
 #define DP_AUX_TST_C  0xE4228
@@ -825,6 +826,12 @@ static void dump_cpt(void)
 dump_reg(HDMIB,sDVO/HDMI Port B Control);
 dump_reg(HDMIC,HDMI Port C Control);
 dump_reg(HDMID,HDMI Port D Control);
+dump_reg(DP_CTL_B, DisplayPort B Control);
+dump_reg(DP_CTL_C, DisplayPort C Control);
+dump_reg(DP_CTL_D, DisplayPort D Control);
+dump_reg(TRANS_DP_CTL_A,   Transcoder A DisplayPort Control);
+dump_reg(TRANS_DP_CTL_B,   Transcoder B DisplayPort Control);
+dump_reg(TRANS_DP_CTL_C,   Transcoder C DisplayPort Control);
 dump_reg(AUD_CONFIG_A, Audio Configuration - Transcoder A);
 dump_reg(AUD_CONFIG_B, Audio Configuration - Transcoder B);
 dump_reg(AUD_CONFIG_C, Audio Configuration - Transcoder C);
@@ -902,29 +909,29 @@ static void dump_cpt(void)
 printf(HDMID HDMI_or_DVI_Select\t\t\t\t%s\n, BIT(dword, 9) ? HDMI : 
DVI);
 printf(HDMID Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 
-dword = INREG(TRANS_DP_CTL_A);
-printf(TRANS_DP_CTL_A DisplayPort_Enable\t\t\t%lu\n,  BIT(dword, 
31));
-printf(TRANS_DP_CTL_A Port_Width_Selection\t\t\t[0x%lx] %s\n,
+dword = INREG(DP_CTL_B);
+printf(DP_CTL_B DisplayPort_Enable\t\t\t\t%lu\n, BIT(dword, 31));
+printf(DP_CTL_B Port_Width_Selection\t\t\t\t[0x%lx] %s\n,
BITS(dword, 21, 19), dp_port_width[BITS(dword, 
21, 19)]);
-printf(TRANS_DP_CTL_A Port_Detected\t\t\t\t%lu\n, BIT(dword, 2));
-printf(TRANS_DP_CTL_A HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
-printf(TRANS_DP_CTL_A Audio_Output_Enable\t\t\t%lu\n, BIT(dword, 6));
-
-dword = INREG(TRANS_DP_CTL_B);
-printf(TRANS_DP_CTL_B DisplayPort_Enable\t\t\t%lu\n,  BIT(dword, 
31));
-printf(TRANS_DP_CTL_B Port_Width_Selection\t\t\t[0x%lx] %s\n,
+printf(DP_CTL_B Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(DP_CTL_B HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
+printf(DP_CTL_B Audio_Output_Enable\t\t\t\t%lu\n, BIT(dword, 6));
+
+dword = INREG(DP_CTL_C);
+printf(DP_CTL_C DisplayPort_Enable\t\t\t\t%lu\n, BIT(dword, 31));
+printf(DP_CTL_C Port_Width_Selection\t\t\t\t[0x%lx] %s\n,
BITS(dword, 21, 19), dp_port_width[BITS(dword, 
21, 19)]);
-printf(TRANS_DP_CTL_B Port_Detected\t\t\t\t%lu\n, BIT(dword, 2));
-printf(TRANS_DP_CTL_B HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
-printf(TRANS_DP_CTL_B Audio_Output_Enable\t\t\t%lu\n, BIT(dword, 6));
-
-dword = INREG(TRANS_DP_CTL_C);
-printf(TRANS_DP_CTL_C DisplayPort_Enable\t\t\t%lu\n,  BIT(dword, 
31));
-printf(TRANS_DP_CTL_C Port_Width_Selection\t\t\t[0x%lx] %s\n,
+printf(DP_CTL_C Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(DP_CTL_C HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
+printf(DP_CTL_C Audio_Output_Enable\t\t\t\t%lu\n, BIT(dword, 6));
+
+dword = INREG(DP_CTL_D);
+printf(DP_CTL_D DisplayPort_Enable\t\t\t\t%lu\n, BIT(dword, 31));
+printf(DP_CTL_D Port_Width_Selection\t\t\t\t[0x%lx] %s\n,
BITS(dword, 21, 19), dp_port_width[BITS(dword, 
21, 19)]);
-printf(TRANS_DP_CTL_C Port_Detected\t\t\t\t%lu\n, BIT(dword, 2));
-printf(TRANS_DP_CTL_C HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
-printf(TRANS_DP_CTL_C Audio_Output_Enable\t\t\t%lu\n, BIT(dword, 6));
+printf(DP_CTL_D Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(DP_CTL_D HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
+printf(DP_CTL_D Audio_Output_Enable\t\t\t\t%lu\n, BIT(dword, 6));
 
 dword = INREG(AUD_CONFIG_A);
 printf(AUD_CONFIG_A  Pixel_Clock_HDMI\t\t\t\t[0x%lx] %s\n, BITS(dword, 
19, 16),


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


[Intel-gfx] [PATCH 07/18] intel_audio_dump: fix Ironlake detection

2011-11-11 Thread Wu Fengguang
The original test mistakenly calls dump_cpt() for Ironlake,
due to HAS_PCH_SPLIT := IS_GEN5 || IS_GEN6 || IS_GEN7.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-09 
10:35:35.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-09 10:35:35.0 
+0800
@@ -1194,7 +1194,7 @@ int main(int argc, char **argv)
else
intel_get_mmio(pci_dev);
 
-   if (HAS_PCH_SPLIT(devid) || getenv(HAS_PCH_SPLIT)) {
+   if (IS_GEN6(devid) || IS_GEN7(devid) || getenv(HAS_PCH_SPLIT)) {
intel_check_pch();
dump_cpt();
} else if (IS_GEN5(devid))


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


[Intel-gfx] [PATCH 13/18] intel_audio_dump: show ELD contents for G45

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |8 
 1 file changed, 8 insertions(+)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:52:47.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:52:48.0 
+0800
@@ -455,6 +455,14 @@ static void dump_eaglelake(void)
printf(\t\t\t\t\t[0x%x] %u = %lu \n, dword, i, BITS(dword, 7, 
4));
 }
 
+printf(AUD_HDMIW_HDMIEDID HDMI ELD:\n\t);
+dword = INREG(AUD_CNTL_ST);
+dword = ~BITMASK(8, 5);
+OUTREG(AUD_CNTL_ST, dword);
+for (i = 0; i  BITS(dword, 14, 10) / 4; i++)
+   printf(%08x , htonl(INREG(AUD_HDMIW_HDMIEDID)));
+printf(\n);
+
 printf(AUD_HDMIW_INFOFR HDMI audio Infoframe:\n\t);
 dword = INREG(AUD_CNTL_ST);
 dword = ~BITMASK(20, 18);


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


[Intel-gfx] [PATCH 14/18] intel_audio_dump: show ironlake ELD_access_address

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |2 ++
 1 file changed, 2 insertions(+)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:52:48.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:52:48.0 
+0800
@@ -725,6 +725,7 @@ static void dump_ironlake(void)
BITS(dword, 17, 16), 
dip_trans[BITS(dword, 17, 16)]);
 printf(AUD_CNTL_ST_A  ELD_ACK\t\t\t\t\t%lu\n, BIT(dword, 4));
 printf(AUD_CNTL_ST_A  ELD_buffer_size\t\t\t\t%lu\n, BITS(dword, 14, 10));
+printf(AUD_CNTL_ST_A  ELD_access_address\t\t\t%lu\n, BITS(dword, 9, 5));
 
 dword = INREG(AUD_CNTL_ST_B);
 printf(AUD_CNTL_ST_B  DIP_Port_Select\t\t\t\t[%#lx] %s\n,
@@ -736,6 +737,7 @@ static void dump_ironlake(void)
BITS(dword, 17, 16), 
dip_trans[BITS(dword, 17, 16)]);
 printf(AUD_CNTL_ST_B  ELD_ACK\t\t\t\t\t%lu\n, BIT(dword, 4));
 printf(AUD_CNTL_ST_B  ELD_buffer_size\t\t\t\t%lu\n, BITS(dword, 14, 10));
+printf(AUD_CNTL_ST_B  ELD_access_address\t\t\t%lu\n, BITS(dword, 9, 5));
 
 dword = INREG(AUD_CNTL_ST2);
 printf(AUD_CNTL_ST2  CP_ReadyB\t\t\t\t\t%lu\n,   BIT(dword, 1));


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


[Intel-gfx] [PATCH 18/18] intel_audio_dump: show Gamut Metadata DIP

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:52:50.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:52:51.0 
+0800
@@ -112,7 +112,7 @@ static char *dip_trans[] = {
 static char *video_dip_index[] = {
[0] = AVI DIP,
[1] = Vendor-specific DIP,
-   [2] = Reserved,
+   [2] = Gamut Metadata DIP,
[3] = Source Product Description DIP,
 };
 


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


[Intel-gfx] [PATCH 17/18] intel_audio_dump: show interrupt enable bit

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |4 
 1 file changed, 4 insertions(+)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:52:50.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:52:50.0 
+0800
@@ -567,6 +567,7 @@ static void dump_ironlake(void)
 printf(HDMIB HDMIB_Enable\t\t\t\t\t%u\n,  !!(dword  SDVO_ENABLE));
 printf(HDMIB Transcoder_Select\t\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
 printf(HDMIB HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
+printf(HDMIB SDVOB Hot Plug Interrupt Detect Enable\t\t%lu\n, BIT(dword, 
23));
 printf(HDMIB Digital_Port_B_Detected\t\t\t\t%lu\n, BIT(dword, 2));
 printf(HDMIB Encoding\t\t\t\t\t\t[0x%lx] %s\n,
BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
@@ -999,6 +1000,7 @@ static void dump_cpt(void)
BITS(dword, 30, 29), 
transcoder_select[BITS(dword, 30, 29)]);
 printf(HDMIB sDVO_Border_Enable\t\t\t\t%lu\n, BIT(dword, 7));
 printf(HDMIB HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
+printf(HDMIB SDVO_HPD_Interrupt_Enable\t\t\t\t%lu\n, BIT(dword, 23));
 printf(HDMIB Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
 printf(HDMIB Encoding\t\t\t\t\t\t[0x%lx] %s\n,
BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
@@ -1011,6 +1013,7 @@ static void dump_cpt(void)
BITS(dword, 30, 29), 
transcoder_select[BITS(dword, 30, 29)]);
 printf(HDMIC sDVO_Border_Enable\t\t\t\t%lu\n, BIT(dword, 7));
 printf(HDMIC HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
+printf(HDMIC SDVO_HPD_Interrupt_Enable\t\t\t\t%lu\n, BIT(dword, 23));
 printf(HDMIC Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
 printf(HDMIC Encoding\t\t\t\t\t\t[0x%lx] %s\n,
BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
@@ -1023,6 +1026,7 @@ static void dump_cpt(void)
BITS(dword, 30, 29), 
transcoder_select[BITS(dword, 30, 29)]);
 printf(HDMID sDVO_Border_Enable\t\t\t\t%lu\n, BIT(dword, 7));
 printf(HDMID HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
+printf(HDMID SDVO_HPD_Interrupt_Enable\t\t\t\t%lu\n, BIT(dword, 23));
 printf(HDMID Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
 printf(HDMID Encoding\t\t\t\t\t\t[0x%lx] %s\n,
BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);


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


[Intel-gfx] [PATCH 12/18] intel_audio_dump: show detected chipset name

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:52:46.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:52:47.0 
+0800
@@ -1250,12 +1250,17 @@ int main(int argc, char **argv)
intel_get_mmio(pci_dev);
 
if (IS_GEN6(devid) || IS_GEN7(devid) || getenv(HAS_PCH_SPLIT)) {
+   printf(%s audio registers:\n\n,
+  IS_GEN6(devid) ? SandyBridge : IvyBridge);
intel_check_pch();
dump_cpt();
-   } else if (IS_GEN5(devid))
+   } else if (IS_GEN5(devid)) {
+   printf(Ironlake audio registers:\n\n);
dump_ironlake();
-   else
+   } else if (IS_G4X(devid)) {
+   printf(G45 audio registers:\n\n);
dump_eaglelake();
+   }
 
return 0;
 }


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


[Intel-gfx] [PATCH 10/18] intel_audio_dump: explain Bits_per_Sample

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:52:39.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:52:40.0 
+0800
@@ -147,6 +147,16 @@ static char *dp_port_width[] = {
[4 ... 7] = reserved,
 };
 
+static char *bits_per_sample[] = {
+   [0] = reserved,
+   [1] = 16 bits,
+   [2] = 24 bits,
+   [3] = 32 bits,
+   [4] = 20 bits,
+   [5] = reserved,
+};
+
+
 static void do_self_tests(void)
 {
 if (BIT(1, 0) != 1)
@@ -372,6 +382,8 @@ static void dump_eaglelake(void)
 
 dword = INREG(AUD_OUT_STR_DESC);
 printf(AUD_OUT_STR_DESC stream channels\t%lu\n,BITS(dword, 3, 0) + 
1);
+printf(AUD_OUT_STR_DESC Bits per Sample\t[%#lx] %s\n,
+  BITS(dword, 6, 4), OPNAME(bits_per_sample, BITS(dword, 6, 
4)));
 
 dword = INREG(AUD_PINW_CAP);
 printf(AUD_PINW_CAP widget type\t\t0x%lx\n,BITS(dword, 23, 20));
@@ -649,13 +661,15 @@ static void dump_ironlake(void)
 dword = INREG(AUD_OUT_STR_DESC_A);
 printf(AUD_OUT_STR_DESC_A  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
 printf(AUD_OUT_STR_DESC_A  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
-printf(AUD_OUT_STR_DESC_A  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
+printf(AUD_OUT_STR_DESC_A  Bits_per_Sample\t\t\t[%#lx] %s\n,
+   BITS(dword, 6, 4), OPNAME(bits_per_sample, 
BITS(dword, 6, 4)));
 printf(AUD_OUT_STR_DESC_A  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_OUT_STR_DESC_B);
 printf(AUD_OUT_STR_DESC_B  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
 printf(AUD_OUT_STR_DESC_B  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
-printf(AUD_OUT_STR_DESC_B  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
+printf(AUD_OUT_STR_DESC_B  Bits_per_Sample\t\t\t[%#lx] %s\n,
+   BITS(dword, 6, 4), OPNAME(bits_per_sample, 
BITS(dword, 6, 4)));
 printf(AUD_OUT_STR_DESC_B  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_PINW_CONNLNG_SEL);
@@ -1053,19 +1067,22 @@ static void dump_cpt(void)
 dword = INREG(AUD_OUT_STR_DESC_A);
 printf(AUD_OUT_STR_DESC_A  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
 printf(AUD_OUT_STR_DESC_A  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
-printf(AUD_OUT_STR_DESC_A  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
+printf(AUD_OUT_STR_DESC_A  Bits_per_Sample\t\t\t[%#lx] %s\n,
+   BITS(dword, 6, 4), OPNAME(bits_per_sample, 
BITS(dword, 6, 4)));
 printf(AUD_OUT_STR_DESC_A  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_OUT_STR_DESC_B);
 printf(AUD_OUT_STR_DESC_B  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
 printf(AUD_OUT_STR_DESC_B  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
-printf(AUD_OUT_STR_DESC_B  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
+printf(AUD_OUT_STR_DESC_B  Bits_per_Sample\t\t\t[%#lx] %s\n,
+   BITS(dword, 6, 4), OPNAME(bits_per_sample, 
BITS(dword, 6, 4)));
 printf(AUD_OUT_STR_DESC_B  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_OUT_STR_DESC_C);
 printf(AUD_OUT_STR_DESC_C  HBR_enable\t\t\t\t%lu\n,   BITS(dword, 
28, 27));
 printf(AUD_OUT_STR_DESC_C  Convertor_Channel_Count\t\t%lu\n, BITS(dword, 
20, 16) + 1);
-printf(AUD_OUT_STR_DESC_C  Bits_per_Sample\t\t\t%lu\n,BITS(dword, 6, 
4));
+printf(AUD_OUT_STR_DESC_C  Bits_per_Sample\t\t\t[%#lx] %s\n,
+   BITS(dword, 6, 4), OPNAME(bits_per_sample, 
BITS(dword, 6, 4)));
 printf(AUD_OUT_STR_DESC_C  Number_of_Channels_in_a_Stream\t%lu\n, 1 + 
BITS(dword, 3, 0));
 
 dword = INREG(AUD_PINW_CONNLNG_SEL);


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


[Intel-gfx] [PATCH 15/18] intel_audio_dump: show VIDEO_DIP_CTL_* for CPT

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   47 +
 1 file changed, 47 insertions(+)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
11:11:41.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 11:11:45.0 
+0800
@@ -872,6 +872,11 @@ static void dump_ironlake(void)
 #define AUD_OUT_STR_DESC_D0xE5384
 #define AUD_CNTL_ST_D 0xE53B4
 
+#define VIDEO_DIP_CTL_A0xE0200
+#define VIDEO_DIP_CTL_B0xE1200
+#define VIDEO_DIP_CTL_C0xE2200
+#define VIDEO_DIP_CTL_D0xE3200
+
 
 static void dump_cpt(void)
 {
@@ -924,6 +929,48 @@ static void dump_cpt(void)
 
 printf(\nDetails:\n\n);
 
+dword = INREG(VIDEO_DIP_CTL_A);
+printf(VIDEO_DIP_CTL_A Enable_Graphics_DIP\t\t\t%ld\n, BIT(dword, 
31)),
+printf(VIDEO_DIP_CTL_A GCP_DIP_enable\t\t\t\t%ld\n, BIT(dword, 25)),
+printf(VIDEO_DIP_CTL_A Video_DIP_type_enable AVI\t\t%lu\n,   
BIT(dword, 21));
+printf(VIDEO_DIP_CTL_A Video_DIP_type_enable Vendor\t\t%lu\n,  
BIT(dword, 22));
+printf(VIDEO_DIP_CTL_A Video_DIP_type_enable Gamut\t\t%lu\n,   
BIT(dword, 23));
+printf(VIDEO_DIP_CTL_A Video_DIP_type_enable Source \t\t%lu\n,   
BIT(dword, 24));
+printf(VIDEO_DIP_CTL_A Video_DIP_buffer_index\t\t\t[0x%lx] %s\n,
+   BITS(dword, 20, 19), video_dip_index[BITS(dword, 20, 19)]);
+printf(VIDEO_DIP_CTL_A Video_DIP_frequency\t\t\t[0x%lx] %s\n,
+   BITS(dword, 17, 16), video_dip_trans[BITS(dword, 17, 16)]);
+printf(VIDEO_DIP_CTL_A Video_DIP_buffer_size\t\t\t%lu\n, BITS(dword, 11, 
8));
+printf(VIDEO_DIP_CTL_A Video_DIP_access_address\t\t%lu\n, BITS(dword, 3, 
0));
+
+dword = INREG(VIDEO_DIP_CTL_B);
+printf(VIDEO_DIP_CTL_B Enable_Graphics_DIP\t\t\t%ld\n, BIT(dword, 
31)),
+printf(VIDEO_DIP_CTL_B GCP_DIP_enable\t\t\t\t%ld\n, BIT(dword, 25)),
+printf(VIDEO_DIP_CTL_B Video_DIP_type_enable AVI\t\t%lu\n,   
BIT(dword, 21));
+printf(VIDEO_DIP_CTL_B Video_DIP_type_enable Vendor\t\t%lu\n,  
BIT(dword, 22));
+printf(VIDEO_DIP_CTL_B Video_DIP_type_enable Gamut\t\t%lu\n,   
BIT(dword, 23));
+printf(VIDEO_DIP_CTL_B Video_DIP_type_enable Source \t\t%lu\n,   
BIT(dword, 24));
+printf(VIDEO_DIP_CTL_B Video_DIP_buffer_index\t\t\t[0x%lx] %s\n,
+   BITS(dword, 20, 19), video_dip_index[BITS(dword, 20, 19)]);
+printf(VIDEO_DIP_CTL_B Video_DIP_frequency\t\t\t[0x%lx] %s\n,
+   BITS(dword, 17, 16), video_dip_trans[BITS(dword, 17, 16)]);
+printf(VIDEO_DIP_CTL_B Video_DIP_buffer_size\t\t\t%lu\n, BITS(dword, 11, 
8));
+printf(VIDEO_DIP_CTL_B Video_DIP_access_address\t\t%lu\n, BITS(dword, 3, 
0));
+
+dword = INREG(VIDEO_DIP_CTL_C);
+printf(VIDEO_DIP_CTL_C Enable_Graphics_DIP\t\t\t%ld\n, BIT(dword, 
31)),
+printf(VIDEO_DIP_CTL_C GCP_DIP_enable\t\t\t\t%ld\n, BIT(dword, 25)),
+printf(VIDEO_DIP_CTL_C Video_DIP_type_enable AVI\t\t%lu\n,   
BIT(dword, 21));
+printf(VIDEO_DIP_CTL_C Video_DIP_type_enable Vendor\t\t%lu\n,  
BIT(dword, 22));
+printf(VIDEO_DIP_CTL_C Video_DIP_type_enable Gamut\t\t%lu\n,   
BIT(dword, 23));
+printf(VIDEO_DIP_CTL_C Video_DIP_type_enable Source \t\t%lu\n,   
BIT(dword, 24));
+printf(VIDEO_DIP_CTL_C Video_DIP_buffer_index\t\t\t[0x%lx] %s\n,
+   BITS(dword, 20, 19), video_dip_index[BITS(dword, 20, 19)]);
+printf(VIDEO_DIP_CTL_C Video_DIP_frequency\t\t\t[0x%lx] %s\n,
+   BITS(dword, 17, 16), video_dip_trans[BITS(dword, 17, 16)]);
+printf(VIDEO_DIP_CTL_C Video_DIP_buffer_size\t\t\t%lu\n, BITS(dword, 11, 
8));
+printf(VIDEO_DIP_CTL_C Video_DIP_access_address\t\t%lu\n, BITS(dword, 3, 
0));
+
 dword = INREG(AUD_VID_DID);
 printf(AUD_VID_DID vendor id\t\t\t\t\t0x%x\n, dword  16);
 printf(AUD_VID_DID device id\t\t\t\t\t0x%x\n, dword  0x);


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


[Intel-gfx] [PATCH 16/18] intel_audio_dump: show HDMI encoding

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   18 ++
 1 file changed, 18 insertions(+)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:52:49.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:52:50.0 
+0800
@@ -156,6 +156,12 @@ static char *bits_per_sample[] = {
[5] = reserved,
 };
 
+static char *sdvo_hdmi_encoding[] = {
+   [0] = SDVO,
+   [1] = reserved,
+   [2] = TMDS,
+   [3] = reserved,
+};
 
 static void do_self_tests(void)
 {
@@ -562,6 +568,8 @@ static void dump_ironlake(void)
 printf(HDMIB Transcoder_Select\t\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
 printf(HDMIB HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
 printf(HDMIB Digital_Port_B_Detected\t\t\t\t%lu\n, BIT(dword, 2));
+printf(HDMIB Encoding\t\t\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
 printf(HDMIB Null_packets_enabled_during_Vsync\t\t\t%u\n,  !!(dword  
SDVO_NULL_PACKETS_DURING_VSYNC));
 printf(HDMIB Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 
@@ -570,6 +578,8 @@ static void dump_ironlake(void)
 printf(HDMIC Transcoder_Select\t\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
 printf(HDMIC HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
 printf(HDMIC Digital_Port_C_Detected\t\t\t\t%lu\n, BIT(dword, 2));
+printf(HDMIC Encoding\t\t\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
 printf(HDMIC Null_packets_enabled_during_Vsync\t\t\t%u\n,  !!(dword  
SDVO_NULL_PACKETS_DURING_VSYNC));
 printf(HDMIC Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 
@@ -578,6 +588,8 @@ static void dump_ironlake(void)
 printf(HDMID Transcoder_Select\t\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
 printf(HDMID HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
 printf(HDMID Digital_Port_D_Detected\t\t\t\t%lu\n, BIT(dword, 2));
+printf(HDMID Encoding\t\t\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
 printf(HDMID Null_packets_enabled_during_Vsync\t\t\t%u\n,  !!(dword  
SDVO_NULL_PACKETS_DURING_VSYNC));
 printf(HDMID Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 
@@ -988,6 +1000,8 @@ static void dump_cpt(void)
 printf(HDMIB sDVO_Border_Enable\t\t\t\t%lu\n, BIT(dword, 7));
 printf(HDMIB HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
 printf(HDMIB Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(HDMIB Encoding\t\t\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
 printf(HDMIB HDMI_or_DVI_Select\t\t\t\t%s\n, BIT(dword, 9) ? HDMI : 
DVI);
 printf(HDMIB Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 
@@ -998,6 +1012,8 @@ static void dump_cpt(void)
 printf(HDMIC sDVO_Border_Enable\t\t\t\t%lu\n, BIT(dword, 7));
 printf(HDMIC HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
 printf(HDMIC Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(HDMIC Encoding\t\t\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
 printf(HDMIC HDMI_or_DVI_Select\t\t\t\t%s\n, BIT(dword, 9) ? HDMI : 
DVI);
 printf(HDMIC Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 
@@ -1008,6 +1024,8 @@ static void dump_cpt(void)
 printf(HDMID sDVO_Border_Enable\t\t\t\t%lu\n, BIT(dword, 7));
 printf(HDMID HDCP_Port_Select\t\t\t\t\t%lu\n, BIT(dword, 5));
 printf(HDMID Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(HDMID Encoding\t\t\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 11, 10), 
sdvo_hdmi_encoding[BITS(dword, 11, 10)]);
 printf(HDMID HDMI_or_DVI_Select\t\t\t\t%s\n, BIT(dword, 9) ? HDMI : 
DVI);
 printf(HDMID Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 


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


[Intel-gfx] [PATCH 11/18] intel_audio_dump: show DP control registers for Ironlake

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |   30 ++
 1 file changed, 30 insertions(+)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-12 
10:52:40.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-12 10:52:46.0 
+0800
@@ -508,6 +508,9 @@ static void dump_ironlake(void)
 dump_reg(HDMIB,sDVO/HDMI Port B Control);
 dump_reg(HDMIC,HDMI Port C Control);
 dump_reg(HDMID,HDMI Port D Control);
+dump_reg(PCH_DP_B, DisplayPort B Control Register);
+dump_reg(PCH_DP_C, DisplayPort C Control Register);
+dump_reg(PCH_DP_D, DisplayPort D Control Register);
 dump_reg(AUD_CONFIG_A, Audio Configuration - Transcoder A);
 dump_reg(AUD_CONFIG_B, Audio Configuration - Transcoder B);
 dump_reg(AUD_CTS_ENABLE_A, Audio CTS Programming Enable - 
Transcoder A);
@@ -570,6 +573,33 @@ static void dump_ironlake(void)
 printf(HDMID Null_packets_enabled_during_Vsync\t\t\t%u\n,  !!(dword  
SDVO_NULL_PACKETS_DURING_VSYNC));
 printf(HDMID Audio_Output_Enable\t\t\t\t%u\n, !!(dword  
SDVO_AUDIO_ENABLE));
 
+dword = INREG(PCH_DP_B);
+printf(PCH_DP_B DisplayPort_Enable\t\t\t\t%lu\n, BIT(dword, 31));
+printf(PCH_DP_B Transcoder_Select\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
+printf(PCH_DP_B Port_Width_Selection\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 21, 19), dp_port_width[BITS(dword, 
21, 19)]);
+printf(PCH_DP_B Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(PCH_DP_B HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
+printf(PCH_DP_B Audio_Output_Enable\t\t\t\t%lu\n, BIT(dword, 6));
+
+dword = INREG(PCH_DP_C);
+printf(PCH_DP_C DisplayPort_Enable\t\t\t\t%lu\n, BIT(dword, 31));
+printf(PCH_DP_C Transcoder_Select\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
+printf(PCH_DP_C Port_Width_Selection\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 21, 19), dp_port_width[BITS(dword, 
21, 19)]);
+printf(PCH_DP_C Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(PCH_DP_C HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
+printf(PCH_DP_C Audio_Output_Enable\t\t\t\t%lu\n, BIT(dword, 6));
+
+dword = INREG(PCH_DP_D);
+printf(PCH_DP_D DisplayPort_Enable\t\t\t\t%lu\n, BIT(dword, 31));
+printf(PCH_DP_D Transcoder_Select\t\t\t\t%s\n, BIT(dword, 30) ? 
Transcoder B : Transcoder A);
+printf(PCH_DP_D Port_Width_Selection\t\t\t\t[0x%lx] %s\n,
+   BITS(dword, 21, 19), dp_port_width[BITS(dword, 
21, 19)]);
+printf(PCH_DP_D Port_Detected\t\t\t\t\t%lu\n, BIT(dword, 2));
+printf(PCH_DP_D HDCP_Port_Select\t\t\t\t%lu\n, BIT(dword, 5));
+printf(PCH_DP_D Audio_Output_Enable\t\t\t\t%lu\n, BIT(dword, 6));
+
 dword = INREG(AUD_CONFIG_A);
 printf(AUD_CONFIG_A  Pixel_Clock\t\t\t\t[0x%lx] %s\n, BITS(dword, 19, 
16),
OPNAME(pixel_clock, BITS(dword, 19, 16)));


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


Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-10 Thread Wu Fengguang
On Thu, Nov 10, 2011 at 03:55:22PM +0800, Wu Fengguang wrote:
 On Thu, Nov 10, 2011 at 03:33:50PM +0800, Wu Fengguang wrote:
  Wow I reproduced the bug and got a very interesting dmesg:
  
  gfx =[ 4561.287980] [drm:intel_write_eld], ELD on 
  [CONNECTOR:12:HDMI-A-2], [ENCODER:11:TMDS-11]
  gfx =[ 4561.291730] [drm:ironlake_write_eld], ELD on pipe B
  gfx =[ 4561.293804] [drm:ironlake_write_eld], Audio directed to 
  unknown port
  gfx =[ 4561.295273] [drm:ironlake_write_eld],
alsa = [ 4561.295486] HDMI hot plug event: Codec=3 Pin=6 
  Presence_Detect=1 ELD_Valid=0
alsa = [ 4561.295564] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
  ELD_Valid=0
  gfx =[ 4561.300020] ELD size 13
alsa = [ 4561.300697] HDMI hot plug event: Codec=3 Pin=6 
  Presence_Detect=1 ELD_Valid=1
alsa = [ 4561.303322] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
  ELD_Valid=1
alsa = [ 4561.311120] ALSA hda_eld.c:259 HDMI: Unknown ELD version 0

  Hey the two parts are interleaved!
  
  But still it should work all fine, since the gfx driver does
  
  set ELD_Valid = 0
  write ELD
  set ELD_Valid = 1
  
  So the audio driver would read the correct ELD unless the ELD content
  and flag writes are somehow _reordered_ underneath. Or the ELD content
  writes take some time to take effect?
 
 Just confirmed that adding 1s delay can fix it!

My test steps are

1) fresh boot
2) cat /proc/asound/card0/eld* == OK
3) startx
4) DISPLAY=:0.0 xrandr --output HDMI2 --mode 720x480
5) cat /proc/asound/card0/eld* == ZEROS before patch, OK after patch

I guess avoiding the extra ELD passing can also fix this problem,
since we never meet timing problems with the first HDMI hot plug event.

Thanks,
Fengguang

 New dmesg is:
 
 [   48.564923] [drm:drm_crtc_helper_set_mode], [ENCODER:11:TMDS-11] set 
 [MODE:34:]
 [   48.567481] [drm:intel_hdmi_mode_set], Enabling HDMI audio on pipe B
 [   48.568975] [drm:intel_write_eld], ELD on [CONNECTOR:12:HDMI-A-2], 
 [ENCODER:11:TMDS-11]
 [   48.571728] [drm:ironlake_write_eld], ELD on pipe B
 [   48.572882] [drm:ironlake_write_eld], Audio directed to unknown port
 [   48.575252] [drm:ironlake_write_eld], 
 [   48.575400] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 
 ELD_Valid=0
 [   48.575487] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=0
 [   48.580116] ELD size 13
 [   48.580795] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 
 ELD_Valid=1
 [   48.583340] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
 [   48.632514] [drm:intel_wait_for_vblank], vblank wait timed out
 [   48.685322] [drm:intel_wait_for_vblank], vblank wait timed out
 [   48.687438] [drm:ironlake_update_wm], FIFO watermarks For pipe A - plane 
 5, cursor: 6
 [   48.687438] [drm:ironlake_update_wm], FIFO watermarks For pipe A - plane 
 5, cursor: 6
 [   48.690106] [drm:ironlake_update_wm], FIFO watermarks For pipe B - plane 
 42, cursor: 6
 [   48.745204] [drm:intel_wait_for_vblank], vblank wait timed out
 [   48.798035] [drm:intel_wait_for_vblank], vblank wait timed out
 [   48.799633] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x100
 [   48.802686] [drm:ironlake_fdi_link_train], FDI train 1 done.
 [   48.805103] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x600
 [   48.807246] [drm:ironlake_fdi_link_train], FDI train 2 done.
 [   48.809426] [drm:ironlake_fdi_link_train], FDI train done
 [   48.813960] [drm:intel_update_fbc], 
 [   48.814782] [drm:drm_crtc_helper_set_config], Setting connector DPMS state 
 to on
 [   48.818093] [drm:drm_crtc_helper_set_config],
 [CONNECTOR:12:HDMI-A-2] set DPMS on
 [   48.828633] [drm:intel_prepare_page_flip], preparing flip with no unpin 
 work?
 [   49.618962] HDMI: detected monitor RX-V1800 at connection type HDMI
 [   49.621013] HDMI: available speakers: FL/FR LFE FC RL/RR RC RLC/RRC
 [   49.622304] HDMI: supports coding type LPCM: channels = 2, rates = 32000 
 44100 48000 96000 176400 192000 384000, bits = 16 20 24
 [   49.625069] HDMI: supports coding type LPCM: channels = 8, rates = 32000 
 44100 48000 96000 176400 192000 384000, bits = 16 20 24
 [   49.628535] HDMI: supports coding type AC-3: channels = 6, rates = 32000 
 44100 48000, max bitrate = 64
 [   49.630810] HDMI: supports coding type DTS: channels = 7, rates = 32000 
 44100 48000 96000 176400, max bitrate = 1536000
 [   49.633148] HDMI: supports coding type DSD (One Bit Audio): channels = 6, 
 rates = 44100
 [   49.635039] HDMI: supports coding type E-AC-3/DD+ (Dolby Digital Plus): 
 channels = 8, rates = 44100 48000
 [   49.637130] HDMI: supports coding type MLP (Dolby TrueHD): channels = 8, 
 rates = 48000 176400 384000
 [   49.639172] HDMI: supports coding type DTS-HD: channels = 8, rates = 48000 
 176400 384000
 
 Thanks,
 Fengguang
 

 Subject: 
 Date: Thu Nov 10 15:41:11 CST 2011
 
 
 Signed-off-by: Wu Fengguang fengguang...@intel.com
 ---
  sound/pci/hda/hda_eld.c |3 +++
  1 file

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-10 Thread Wu Fengguang
On Thu, Nov 10, 2011 at 07:50:11PM +0800, Christopher White wrote:
 On 11/10/11 12:22 PM, Takashi Iwai wrote:
  At Thu, 10 Nov 2011 12:00:53 +0100,
  Christopher White wrote:
  On 11/10/11 9:55 AM, Christopher White wrote:
  On 11/10/11 8:55 AM, Wu Fengguang wrote:
  On Thu, Nov 10, 2011 at 03:33:50PM +0800, Wu Fengguang wrote:
  Wow I reproduced the bug and got a very interesting dmesg:
 
  gfx =  [ 4561.287980] [drm:intel_write_eld], ELD on
  [CONNECTOR:12:HDMI-A-2], [ENCODER:11:TMDS-11]
  gfx =  [ 4561.291730] [drm:ironlake_write_eld], ELD on pipe B
  gfx =  [ 4561.293804] [drm:ironlake_write_eld], Audio
  directed to unknown port
  gfx =  [ 4561.295273] [drm:ironlake_write_eld],
  alsa =   [ 4561.295486] HDMI hot plug event: Codec=3 Pin=6
  Presence_Detect=1 ELD_Valid=0
  alsa =   [ 4561.295564] HDMI status: Codec=3 Pin=6
  Presence_Detect=1 ELD_Valid=0
  gfx =  [ 4561.300020] ELD size 13
  alsa =   [ 4561.300697] HDMI hot plug event: Codec=3 Pin=6
  Presence_Detect=1 ELD_Valid=1
  alsa =   [ 4561.303322] HDMI status: Codec=3 Pin=6
  Presence_Detect=1 ELD_Valid=1
  alsa =   [ 4561.311120] ALSA hda_eld.c:259 HDMI: Unknown ELD
  version 0
 
  Hey the two parts are interleaved!
 
  But still it should work all fine, since the gfx driver does
 
set ELD_Valid = 0
write ELD
set ELD_Valid = 1
 
  So the audio driver would read the correct ELD unless the ELD content
  and flag writes are somehow _reordered_ underneath. Or the ELD content
  writes take some time to take effect?
  Just confirmed that adding 1s delay can fix it!
 
  New dmesg is:
 
  [   48.564923] [drm:drm_crtc_helper_set_mode], [ENCODER:11:TMDS-11]
  set [MODE:34:]
  [   48.567481] [drm:intel_hdmi_mode_set], Enabling HDMI audio on pipe B
  [   48.568975] [drm:intel_write_eld], ELD on [CONNECTOR:12:HDMI-A-2],
  [ENCODER:11:TMDS-11]
  [   48.571728] [drm:ironlake_write_eld], ELD on pipe B
  [   48.572882] [drm:ironlake_write_eld], Audio directed to unknown port
  [   48.575252] [drm:ironlake_write_eld],
  [   48.575400] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1
  ELD_Valid=0
  [   48.575487] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=0
  [   48.580116] ELD size 13
  [   48.580795] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1
  ELD_Valid=1
  [   48.583340] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
  [   48.632514] [drm:intel_wait_for_vblank], vblank wait timed out
  [   48.685322] [drm:intel_wait_for_vblank], vblank wait timed out
  [   48.687438] [drm:ironlake_update_wm], FIFO watermarks For pipe A -
  plane 5, cursor: 6
  [   48.687438] [drm:ironlake_update_wm], FIFO watermarks For pipe A -
  plane 5, cursor: 6
  [   48.690106] [drm:ironlake_update_wm], FIFO watermarks For pipe B -
  plane 42, cursor: 6
  [   48.745204] [drm:intel_wait_for_vblank], vblank wait timed out
  [   48.798035] [drm:intel_wait_for_vblank], vblank wait timed out
  [   48.799633] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x100
  [   48.802686] [drm:ironlake_fdi_link_train], FDI train 1 done.
  [   48.805103] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x600
  [   48.807246] [drm:ironlake_fdi_link_train], FDI train 2 done.
  [   48.809426] [drm:ironlake_fdi_link_train], FDI train done
  [   48.813960] [drm:intel_update_fbc],
  [   48.814782] [drm:drm_crtc_helper_set_config], Setting connector
  DPMS state to on
  [   48.818093] [drm:drm_crtc_helper_set_config],
  [CONNECTOR:12:HDMI-A-2] set DPMS on
  [   48.828633] [drm:intel_prepare_page_flip], preparing flip with no
  unpin work?
  [   49.618962] HDMI: detected monitor RX-V1800 at connection type HDMI
  [   49.621013] HDMI: available speakers: FL/FR LFE FC RL/RR RC RLC/RRC
  [   49.622304] HDMI: supports coding type LPCM: channels = 2, rates =
  32000 44100 48000 96000 176400 192000 384000, bits = 16 20 24
  [   49.625069] HDMI: supports coding type LPCM: channels = 8, rates =
  32000 44100 48000 96000 176400 192000 384000, bits = 16 20 24
  [   49.628535] HDMI: supports coding type AC-3: channels = 6, rates =
  32000 44100 48000, max bitrate = 64
  [   49.630810] HDMI: supports coding type DTS: channels = 7, rates =
  32000 44100 48000 96000 176400, max bitrate = 1536000
  [   49.633148] HDMI: supports coding type DSD (One Bit Audio):
  channels = 6, rates = 44100
  [   49.635039] HDMI: supports coding type E-AC-3/DD+ (Dolby Digital
  Plus): channels = 8, rates = 44100 48000
  [   49.637130] HDMI: supports coding type MLP (Dolby TrueHD):
  channels = 8, rates = 48000 176400 384000
  [   49.639172] HDMI: supports coding type DTS-HD: channels = 8, rates
  = 48000 176400 384000
 
  Thanks,
  Fengguang
  Wow, you were able to reproduce it! That's the best news ever. I will
  be applying this patch and rebuilding now to see what happens. So it
  was some sort of timing issue after all.
 
  Expect me to reply within 1h, but rebuild takes some time.
  I still had

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-10 Thread Wu Fengguang
On Thu, Nov 10, 2011 at 09:01:24PM +0800, Christopher White wrote:
 On 11/10/11 1:56 PM, Wu Fengguang wrote:
  On Thu, Nov 10, 2011 at 07:50:11PM +0800, Christopher White wrote:
  On 11/10/11 12:22 PM, Takashi Iwai wrote:
  At Thu, 10 Nov 2011 12:00:53 +0100,
  Christopher White wrote:
  On 11/10/11 9:55 AM, Christopher White wrote:
  On 11/10/11 8:55 AM, Wu Fengguang wrote:
  On Thu, Nov 10, 2011 at 03:33:50PM +0800, Wu Fengguang wrote:
  Wow I reproduced the bug and got a very interesting dmesg:
 
  gfx =   [ 4561.287980] [drm:intel_write_eld], ELD on
  [CONNECTOR:12:HDMI-A-2], [ENCODER:11:TMDS-11]
  gfx =   [ 4561.291730] [drm:ironlake_write_eld], ELD on pipe 
  B
  gfx =   [ 4561.293804] [drm:ironlake_write_eld], Audio
  directed to unknown port
  gfx =   [ 4561.295273] [drm:ironlake_write_eld],
   alsa =[ 4561.295486] HDMI hot plug event: Codec=3 Pin=6
  Presence_Detect=1 ELD_Valid=0
   alsa =[ 4561.295564] HDMI status: Codec=3 Pin=6
  Presence_Detect=1 ELD_Valid=0
  gfx =   [ 4561.300020] ELD size 13
   alsa =[ 4561.300697] HDMI hot plug event: Codec=3 Pin=6
  Presence_Detect=1 ELD_Valid=1
   alsa =[ 4561.303322] HDMI status: Codec=3 Pin=6
  Presence_Detect=1 ELD_Valid=1
   alsa =[ 4561.311120] ALSA hda_eld.c:259 HDMI: Unknown 
  ELD
  version 0
 
  Hey the two parts are interleaved!
 
  But still it should work all fine, since the gfx driver does
 
 set ELD_Valid = 0
 write ELD
 set ELD_Valid = 1
 
  So the audio driver would read the correct ELD unless the ELD content
  and flag writes are somehow _reordered_ underneath. Or the ELD content
  writes take some time to take effect?
  Just confirmed that adding 1s delay can fix it!
 
  New dmesg is:
 
  [   48.564923] [drm:drm_crtc_helper_set_mode], [ENCODER:11:TMDS-11]
  set [MODE:34:]
  [   48.567481] [drm:intel_hdmi_mode_set], Enabling HDMI audio on pipe B
  [   48.568975] [drm:intel_write_eld], ELD on [CONNECTOR:12:HDMI-A-2],
  [ENCODER:11:TMDS-11]
  [   48.571728] [drm:ironlake_write_eld], ELD on pipe B
  [   48.572882] [drm:ironlake_write_eld], Audio directed to unknown port
  [   48.575252] [drm:ironlake_write_eld],
  [   48.575400] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1
  ELD_Valid=0
  [   48.575487] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=0
  [   48.580116] ELD size 13
  [   48.580795] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1
  ELD_Valid=1
  [   48.583340] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
  [   48.632514] [drm:intel_wait_for_vblank], vblank wait timed out
  [   48.685322] [drm:intel_wait_for_vblank], vblank wait timed out
  [   48.687438] [drm:ironlake_update_wm], FIFO watermarks For pipe A -
  plane 5, cursor: 6
  [   48.687438] [drm:ironlake_update_wm], FIFO watermarks For pipe A -
  plane 5, cursor: 6
  [   48.690106] [drm:ironlake_update_wm], FIFO watermarks For pipe B -
  plane 42, cursor: 6
  [   48.745204] [drm:intel_wait_for_vblank], vblank wait timed out
  [   48.798035] [drm:intel_wait_for_vblank], vblank wait timed out
  [   48.799633] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x100
  [   48.802686] [drm:ironlake_fdi_link_train], FDI train 1 done.
  [   48.805103] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x600
  [   48.807246] [drm:ironlake_fdi_link_train], FDI train 2 done.
  [   48.809426] [drm:ironlake_fdi_link_train], FDI train done
  [   48.813960] [drm:intel_update_fbc],
  [   48.814782] [drm:drm_crtc_helper_set_config], Setting connector
  DPMS state to on
  [   48.818093] [drm:drm_crtc_helper_set_config],
  [CONNECTOR:12:HDMI-A-2] set DPMS on
  [   48.828633] [drm:intel_prepare_page_flip], preparing flip with no
  unpin work?
  [   49.618962] HDMI: detected monitor RX-V1800 at connection type HDMI
  [   49.621013] HDMI: available speakers: FL/FR LFE FC RL/RR RC RLC/RRC
  [   49.622304] HDMI: supports coding type LPCM: channels = 2, rates =
  32000 44100 48000 96000 176400 192000 384000, bits = 16 20 24
  [   49.625069] HDMI: supports coding type LPCM: channels = 8, rates =
  32000 44100 48000 96000 176400 192000 384000, bits = 16 20 24
  [   49.628535] HDMI: supports coding type AC-3: channels = 6, rates =
  32000 44100 48000, max bitrate = 64
  [   49.630810] HDMI: supports coding type DTS: channels = 7, rates =
  32000 44100 48000 96000 176400, max bitrate = 1536000
  [   49.633148] HDMI: supports coding type DSD (One Bit Audio):
  channels = 6, rates = 44100
  [   49.635039] HDMI: supports coding type E-AC-3/DD+ (Dolby Digital
  Plus): channels = 8, rates = 44100 48000
  [   49.637130] HDMI: supports coding type MLP (Dolby TrueHD):
  channels = 8, rates = 48000 176400 384000
  [   49.639172] HDMI: supports coding type DTS-HD: channels = 8, rates
  = 48000 176400 384000
 
  Thanks,
  Fengguang
  Wow, you were able to reproduce it! That's the best news ever. I will
  be applying this patch and rebuilding now to see what

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-10 Thread Wu Fengguang
  Got the delay - it's 72.986623-72.747632 = 239ms.
 
   [   72.739944] HDMI hot plug event: Codec=3 Pin=6 
  Presence_Detect=1 ELD_Valid=0
   [   72.742541] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
  ELD_Valid=0
   [   72.745082] HDMI hot plug event: Codec=3 Pin=6 
  Presence_Detect=1 ELD_Valid=1
   [   72.747632] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
  ELD_Valid=1
   [   72.794240] [drm:intel_wait_for_vblank], vblank wait timed out
   [   72.848099] [drm:intel_wait_for_vblank], vblank wait timed out
   [   72.850507] [drm:ironlake_update_wm], FIFO watermarks For pipe 
  A - plane 5, cursor: 6
   [   72.853244] [drm:ironlake_update_wm], FIFO watermarks For pipe 
  B - plane 42, cursor: 6
   [   72.907937] [drm:intel_wait_for_vblank], vblank wait timed out
   [   72.960790] [drm:intel_wait_for_vblank], vblank wait timed out
   [   72.962757] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x100
   [   72.964880] [drm:ironlake_fdi_link_train], FDI train 1 done.
   [   72.968341] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x600
   [   72.970274] [drm:ironlake_fdi_link_train], FDI train 2 done.
   [   72.972535] [drm:ironlake_fdi_link_train], FDI train done
   [   72.976751] [drm:intel_update_fbc],
   [   72.977558] [drm:drm_crtc_helper_set_config], Setting connector 
  DPMS state to on
  ==  [   72.981550] [drm:drm_crtc_helper_set_config],
  [CONNECTOR:12:HDMI-A-2] set DPMS on
   [   72.986623] HDMI: detected monitor RX-V1800 at connection type 
  HDMI
   [   72.988260] HDMI: available speakers: FL/FR LFE FC RL/RR RC 
  RLC/RRC
 
  I wonder if the DPMS line has anything to do with the delay...
 
  Thanks,
  Fengguang
 
 Nice find! It does seem likely since the ELD read worked right after
 that. Hmm. I am not familiar with the event order for the Intel
 hardware, and what's calling your edid_to_eld code, etc. Is it possible
 to move the EDID read call to after the DPMS state is ready?

I added a dump_stack() at the very beginning of drm_crtc_helper_set_config().

Judging from drm_crtc_helper_set_config()'s comment and the below dmesg, it's
called by user space.
 
[   84.470633] Pid: 2893, comm: Xorg Tainted: GW3.2.0-rc1-eld+ #244
[   84.472188] Call Trace:
[   84.472795]  [8195dfba] ? printk+0x41/0x43
[   84.474011]  [8148aa04] drm_crtc_helper_set_config+0x24/0x852
[   84.476342]  [81493e52] ? drm_ut_debug_printk+0x57/0x5e
[   84.477743]  [8196052d] ? mutex_unlock+0xe/0x10
[   84.479015]  [8149a403] ? drm_mode_object_find+0x61/0x70
[   84.481326]  [8149b632] drm_mode_setcrtc+0x35d/0x38e
[   84.482679]  [8196052d] ? mutex_unlock+0xe/0x10
[   84.483934]  [8148efc6] drm_ioctl+0x2c0/0x38c
[   84.486033]  [8149b2d5] ? drm_mode_getencoder+0x9b/0x9b
[   84.487463]  [811567b0] do_vfs_ioctl+0x490/0x4d1
[   84.489657]  [81156838] sys_ioctl+0x47/0x6b
[   84.490780]  [8149a3cf] ? drm_mode_object_find+0x2d/0x70
[   84.492235]  [81968a82] system_call_fastpath+0x16/0x1b
[   84.495536] [drm:drm_crtc_helper_set_config], 
[   84.496561] [drm:drm_crtc_helper_set_config], [CRTC:4] [FB:31] #connectors=1 
(x y) (0 0)
[   84.498323] [drm:drm_crtc_helper_set_config], modes are different, full mode 
set
[   84.499958] [drm:drm_mode_debug_printmodeline], Modeline 27:720x576 50 
27000 720 732 796 864 576 581 586 625 0x40 0xa
[   84.502454] [drm:drm_mode_debug_printmodeline], Modeline 34: 0 27000 720 
736 798 858 480 489 495 525 0x0 0xa
[   84.504672] [drm:drm_crtc_helper_set_config], [CONNECTOR:5:VGA-1] to [CRTC:3]
[   84.506205] [drm:drm_crtc_helper_set_config], [CONNECTOR:12:HDMI-A-2] to 
[CRTC:4]
[   84.507869] [drm:drm_crtc_helper_set_config], attempting to set mode from 
userspace
[   84.509699] [drm:drm_mode_debug_printmodeline], Modeline 34: 0 27000 720 
736 798 858 480 489 495 525 0x0 0xa
[   84.511903] [drm:drm_crtc_helper_set_mode], [CRTC:4]
[   84.521961] [drm:intel_prepare_page_flip], preparing flip with no unpin work?
[   84.564804] [drm:intel_wait_for_vblank], vblank wait timed out
[   84.603175] [drm:ironlake_update_wm], FIFO watermarks For pipe A - plane 5, 
cursor: 6
[   84.606681] [drm:ironlake_update_wm], FIFO watermarks For pipe B - plane 42, 
cursor: 6
[   84.610472] [drm:intel_update_fbc], 
[   84.611501] [drm:intel_choose_pipe_bpp_dither], forcing bpc to 8 for HDMI
[   84.613791] [drm:intel_choose_pipe_bpp_dither], setting pipe bpc to 8 (max 
display bpc 8)
[   84.616531] [drm:ironlake_crtc_mode_set], Mode for pipe 1:
[   84.617884] [drm:drm_mode_debug_printmodeline], Modeline 34: 0 27000 720 
736 798 858 480 489 495 525 0x0 0xa
[   84.622337] [drm:ironlake_crtc_mode_set], disabling CxSR downclocking
[   84.676554] [drm:intel_wait_for_vblank], vblank wait timed out
[   84.678981] [drm:ironlake_update_plane], Writing base 00343000 

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-10 Thread Wu Fengguang
On Thu, Nov 10, 2011 at 09:47:46PM +0800, Wu Fengguang wrote:
   Got the delay - it's 72.986623-72.747632 = 239ms.
  
[   72.739944] HDMI hot plug event: Codec=3 Pin=6 
   Presence_Detect=1 ELD_Valid=0
[   72.742541] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
   ELD_Valid=0
[   72.745082] HDMI hot plug event: Codec=3 Pin=6 
   Presence_Detect=1 ELD_Valid=1
[   72.747632] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
   ELD_Valid=1
[   72.794240] [drm:intel_wait_for_vblank], vblank wait timed out
[   72.848099] [drm:intel_wait_for_vblank], vblank wait timed out
[   72.850507] [drm:ironlake_update_wm], FIFO watermarks For 
   pipe A - plane 5, cursor: 6
[   72.853244] [drm:ironlake_update_wm], FIFO watermarks For 
   pipe B - plane 42, cursor: 6
[   72.907937] [drm:intel_wait_for_vblank], vblank wait timed out
[   72.960790] [drm:intel_wait_for_vblank], vblank wait timed out
[   72.962757] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x100
[   72.964880] [drm:ironlake_fdi_link_train], FDI train 1 done.
[   72.968341] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x600
[   72.970274] [drm:ironlake_fdi_link_train], FDI train 2 done.
[   72.972535] [drm:ironlake_fdi_link_train], FDI train done
[   72.976751] [drm:intel_update_fbc],
[   72.977558] [drm:drm_crtc_helper_set_config], Setting 
   connector DPMS state to on
   ==  [   72.981550] [drm:drm_crtc_helper_set_config],
   [CONNECTOR:12:HDMI-A-2] set DPMS on
[   72.986623] HDMI: detected monitor RX-V1800 at connection 
   type HDMI
[   72.988260] HDMI: available speakers: FL/FR LFE FC RL/RR RC 
   RLC/RRC
  
   I wonder if the DPMS line has anything to do with the delay...
  
   Thanks,
   Fengguang
  
  Nice find! It does seem likely since the ELD read worked right after
  that. Hmm. I am not familiar with the event order for the Intel
  hardware, and what's calling your edid_to_eld code, etc. Is it possible
  to move the EDID read call to after the DPMS state is ready?
 
 I added a dump_stack() at the very beginning of drm_crtc_helper_set_config().
 
 Judging from drm_crtc_helper_set_config()'s comment and the below dmesg, it's
 called by user space.
  
 [   84.470633] Pid: 2893, comm: Xorg Tainted: GW3.2.0-rc1-eld+ 
 #244
 [   84.472188] Call Trace:
 [   84.472795]  [8195dfba] ? printk+0x41/0x43
 [   84.474011]  [8148aa04] drm_crtc_helper_set_config+0x24/0x852
 [   84.476342]  [81493e52] ? drm_ut_debug_printk+0x57/0x5e
 [   84.477743]  [8196052d] ? mutex_unlock+0xe/0x10
 [   84.479015]  [8149a403] ? drm_mode_object_find+0x61/0x70
 [   84.481326]  [8149b632] drm_mode_setcrtc+0x35d/0x38e
 [   84.482679]  [8196052d] ? mutex_unlock+0xe/0x10
 [   84.483934]  [8148efc6] drm_ioctl+0x2c0/0x38c
 [   84.486033]  [8149b2d5] ? drm_mode_getencoder+0x9b/0x9b
 [   84.487463]  [811567b0] do_vfs_ioctl+0x490/0x4d1
 [   84.489657]  [81156838] sys_ioctl+0x47/0x6b
 [   84.490780]  [8149a3cf] ? drm_mode_object_find+0x2d/0x70
 [   84.492235]  [81968a82] system_call_fastpath+0x16/0x1b
 [   84.495536] [drm:drm_crtc_helper_set_config], 
 [   84.496561] [drm:drm_crtc_helper_set_config], [CRTC:4] [FB:31] 
 #connectors=1 (x y) (0 0)
 [   84.498323] [drm:drm_crtc_helper_set_config], modes are different, full 
 mode set
 [   84.499958] [drm:drm_mode_debug_printmodeline], Modeline 27:720x576 50 
 27000 720 732 796 864 576 581 586 625 0x40 0xa
 [   84.502454] [drm:drm_mode_debug_printmodeline], Modeline 34: 0 27000 720 
 736 798 858 480 489 495 525 0x0 0xa
 [   84.504672] [drm:drm_crtc_helper_set_config], [CONNECTOR:5:VGA-1] to 
 [CRTC:3]
 [   84.506205] [drm:drm_crtc_helper_set_config], [CONNECTOR:12:HDMI-A-2] to 
 [CRTC:4]
 [   84.507869] [drm:drm_crtc_helper_set_config], attempting to set mode from 
 userspace
 [   84.509699] [drm:drm_mode_debug_printmodeline], Modeline 34: 0 27000 720 
 736 798 858 480 489 495 525 0x0 0xa
 [   84.511903] [drm:drm_crtc_helper_set_mode], [CRTC:4]
 [   84.521961] [drm:intel_prepare_page_flip], preparing flip with no unpin 
 work?
 [   84.564804] [drm:intel_wait_for_vblank], vblank wait timed out
 [   84.603175] [drm:ironlake_update_wm], FIFO watermarks For pipe A - plane 
 5, cursor: 6
 [   84.606681] [drm:ironlake_update_wm], FIFO watermarks For pipe B - plane 
 42, cursor: 6
 [   84.610472] [drm:intel_update_fbc], 
 [   84.611501] [drm:intel_choose_pipe_bpp_dither], forcing bpc to 8 for HDMI
 [   84.613791] [drm:intel_choose_pipe_bpp_dither], setting pipe bpc to 8 (max 
 display bpc 8)
 [   84.616531] [drm:ironlake_crtc_mode_set], Mode for pipe 1:
 [   84.617884] [drm:drm_mode_debug_printmodeline], Modeline 34: 0 27000 720 
 736 798 858 480 489 495 525 0x0 0xa
 [   84.622337] [drm:ironlake_crtc_mode_set

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-10 Thread Wu Fengguang
On Thu, Nov 10, 2011 at 10:28:19PM +0800, Takashi Iwai wrote:
 At Thu, 10 Nov 2011 21:51:50 +0800,
 Wu Fengguang wrote:
  
  So maybe the hardware is in some state that is unable to provide the
  real ELD content?
 That's my guess as well. I think the hardware may still be doing some 
 form of data negotiation with the HDMI display device at that stage, 
 and 
 doesn't have the copy of the EDID+ELD buffer until a tiny bit later. 
 Possibly?

Look at the below dmesg. The ELD seem to available immediately after 
the DPMS
state setting..
   
   Interesting.  Does HDMI audio work at all while HDMI DPMS off?
   It clears SDVO_ENABLE bit, so this might turn off both video and
   audio?
  
  We normally see transient blank screen and silence of audio when
  switching the video mode.
 
 Well, what I suspected is that ELD won't be transferred while
 SDVO_ENABLE is cleared.

It's not about SDVO_ENABLE. The transient ELD invalid state I see in
dmesg is caused by the graphics driver doing

ELD_Valid = 0   = trigger 1st unsolicited event
write ELD contents
ELD_Valid = 1   = trigger 2nd unsolicited event

The two unsolicited events are described in Figure 72. PD and ELDV
unsolicited responses flow for digital display codecs of the High
Definition Audio Specification Rev. 1.0a.

[  467.574207] [drm:ironlake_write_eld], ELD on pipe B
[  467.579346] [drm:ironlake_write_eld], Audio directed to 
unknown port
[  467.584724] [drm:ironlake_write_eld], ELD: DisplayPort 
detected
1st event =[  467.586540] HDMI hot plug event: Codec=3 Pin=7 
Presence_Detect=1 ELD_Valid=0
[  467.599608] [drm:ironlake_write_eld], 
1st event =[  467.599922] HDMI status: Codec=3 Pin=7 Presence_Detect=1 
ELD_Valid=0
[  467.605834] ELD size 9
[  467.610434] [drm:sandybridge_update_wm], FIFO watermarks For 
pipe A - plane 7, cursor: 6
2nd event =[  467.612365] HDMI hot plug event: Codec=3 Pin=7 
Presence_Detect=1 ELD_Valid=1
[  467.620654] [drm:sandybridge_update_wm], 
2nd event =[  467.620765] HDMI status: Codec=3 Pin=7 Presence_Detect=1 
ELD_Valid=1

Depending on the timing, the 1st unsolicited event may see
ELD_Valid=0 (if it's fast enough) or ELD_Valid=1 (if the event
handling is delayed after the graphics driver sets ELD_Valid=1).

I know that because I literally saw both cases happening in dmesg.
The 1st hot plug event itself will send ELD_Valid=0, however the audio
driver is not trusting this and always do a status query (the HDMI
status line) whose result depends on the timing.

 And I'm not sure whether HDMI audio is played
 while DPMS is off.  I haven't tested it.

It will go silence on DPMS. I noticed this while doing long term HDMI
audio playback tests.  This should better be fixed in future on the
graphics side.

 Unfortunately I can't test it right now since my colleague is using a
 desk where the HDMI monitor is on...

I'm always borrowing HDMI/DP monitors and test boxes, too ;-)

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


Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-09 Thread Wu Fengguang
Hi Christopher,

 Now, onto the intel-gpu-tools test. I ran intel_audio_dump as requested 
 and it only comes back with Couldn't map MMIO region: No such file or 
 directory. I spent 10 minutes looking around on Google to no avail. It 
 seems it tries to mmap() something that doesn't exist.

What if you run it with

export HAS_PCH_SPLIT=1
intel_audio_dump

I also queued a patch for the tool. Note that if the above trick
failed to work, the applied patch won't help, too.

Thanks,
Fengguang
Subject: intel_audio_dump: fix CPT detection logic
Date: Wed Nov 02 17:16:39 CST 2011


Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 tools/intel_audio_dump.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- intel-gpu-tools.orig/tools/intel_audio_dump.c   2011-11-09 
10:35:35.0 +0800
+++ intel-gpu-tools/tools/intel_audio_dump.c2011-11-09 10:35:35.0 
+0800
@@ -1194,7 +1194,7 @@ int main(int argc, char **argv)
else
intel_get_mmio(pci_dev);
 
-   if (HAS_PCH_SPLIT(devid) || getenv(HAS_PCH_SPLIT)) {
+   if (IS_GEN6(devid) || IS_GEN7(devid) || getenv(HAS_PCH_SPLIT)) {
intel_check_pch();
dump_cpt();
} else if (IS_GEN5(devid))
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-09 Thread Wu Fengguang
Christopher,

 The dump tool did not work with that environment variable either.
 However, it occurred to me that intel_audio_dump may be too outdated in
 my distro. It was built on 2010-04-01, v1.0.2+git20100324. If I look at
 http://cgit.freedesktop.org/xorg/app/intel-gpu-tools/ I can see that the
 reason for this is that the latest stable was 1.0.2 tagged nearly two
 years ago.
 
 I decided to build intel-gpu-tools from the latest Git source instead.
 That took a while to figure out as it also needed xutils-dev package for
 xorg-macros.m4, required by the autoconf script, and libtool (needed by
 the resulting configure script). So the complete list of dependencies is
 autotools-dev pkg-config libpciaccess-dev libdrm-dev libdrm-intel1
 xutils-dev libtool. DebugFS must also be ready and mounted on

Sorry I should have reminded you of the build dependencies. I use
debian and it's fairly easy for me to install the relevant packages:

apt-get build-dep intel-gpu-tools

 /sys/kernel/debug and enabled in the kernel (kernel hacking  debug file
 system). Finally, building it is standard procedure with autogen.sh,
 configure, make and make install. (I am writing down these instructions
 just in case someone else reads this down the line; Google is a
 wonderful thing).
 
 After building, I tried running intel_audio_dump, and was first
 dumbfounded as it gave me the same error, Couldn't map MMIO region. I
 verified with which intel_audio_dump that it DID point to the NEW
 /usr/local/bin/intel_audio_dump path, and not the OLD
 /usr/bin/intel_audio_dump path.
 
 However, I thought that maybe it WAS running the OLD version for some
 reason despite claiming it was pointing to the new one. So, I tried
 calling it specifically with the full path to the new binary, and...
 SUCCESS! You need to tag a new release version of intel-gpu-tools soon
 so that distros are updated, since the old 1.0.2 release does NOT
 support SandyBridge.

FYI I'm preparing a bunch of patches for intel_audio_dump :-)

 I've attached the full dump here. Scroll down to the bottom and you can
 see that I was right in my theory that all the ELD data was zeroed out.
 But hey at least we're getting SOMEWHERE! ;-)
 
 So what we KNOW now: ELD parsing code = 100% correct. ELD writing to
 correct audio register = 100% correct, verified by looking at
 snd_hdmi_show_eld()'s output in dmesg log. However, SOMETIME after the
 boot, it seems that it gets corrupted/zeroed out. I'll replicate the

Yes, and I'm still puzzled how come ironlake_write_eld() writes
nonzero ELD to pipe A and the audio driver gets all zero. Some hw
reset in between (sounds very unlikely)?

 relevant dump portion here:
 
 AUD_HDMIW_HDMIEDID_A HDMI ELD:
  1d00 6882004f   3dcb6508

That's written by ironlake_write_eld(), which will never write all
zeros because it has an explicit test

if (!eld[0])
return;

 AUD_HDMIW_HDMIEDID_B HDMI ELD:
      
 AUD_HDMIW_HDMIEDID_C HDMI ELD:
      
 AUD_HDMIW_INFOFR_A HDMI audio Infoframe:
  84010a70 0100     
 
 AUD_HDMIW_INFOFR_B HDMI audio Infoframe:
        
 
 AUD_HDMIW_INFOFR_C HDMI audio Infoframe:
        
 
 
 I decided to look in /sys/class/drm/card0-HDMI-A-2/edid and it's 0
 bytes! This used to be 256 bytes! How freaking weird is that?! That

That's mysterious indeed.

 means: System boots up, Intel driver sees 256 byte EDID, parses it into
 ELD, writes it to the audio register, the system dmesg log shows that it
 parsed all supported audio modes correctly, then the system boots and
 edid becomes 0 bytes, and the ELD is zeroed out. What the heck is going
 on here? :-O I tried dmesg | grep HDMI: detected monitor and see
 NOTHING later than the initial boot event, meaning I have no freaking
 clue why it's zeroing out the EDID.

I'm sure that the gfx/audio driver code I wrote won't zero out the
ELD SILENTLY without any clues in dmesg. There must be something else
happening.

 It almost looks like the act of writing ELD to the audio register is
 tampering with the ability of the graphics card to read the EDID itself
 after that point. Erhmm... This is very odd.
 
 Finally, I tried a complete power cycle of every component, turning off
 the outlet power on everything. I then started the Receiver, then the
 Projector, and finally the computer. Not that startup order matters
 much, but this is the optimal order. However, it still did the same
 thing. With one difference. /sys/class/drm/card0-HDMI-A-2/edid now
 contains the correct contents. Everything else was as before:
 /proc/asound/card0/eld#3.0 full of zeroes as shown in the attached file.
 Intel_Audio_Dump showing the EXACT SAME zeroed out content as I have
 quoted above. 

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-09 Thread Wu Fengguang
Wow I reproduced the bug and got a very interesting dmesg:

gfx =[ 4561.287980] [drm:intel_write_eld], ELD on 
[CONNECTOR:12:HDMI-A-2], [ENCODER:11:TMDS-11]
gfx =[ 4561.291730] [drm:ironlake_write_eld], ELD on pipe B
gfx =[ 4561.293804] [drm:ironlake_write_eld], Audio directed to 
unknown port
gfx =[ 4561.295273] [drm:ironlake_write_eld],
  alsa = [ 4561.295486] HDMI hot plug event: Codec=3 Pin=6 
Presence_Detect=1 ELD_Valid=0
  alsa = [ 4561.295564] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
ELD_Valid=0
gfx =[ 4561.300020] ELD size 13
  alsa = [ 4561.300697] HDMI hot plug event: Codec=3 Pin=6 
Presence_Detect=1 ELD_Valid=1
  alsa = [ 4561.303322] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
ELD_Valid=1
  alsa = [ 4561.311120] ALSA hda_eld.c:259 HDMI: Unknown ELD version 0
  
Hey the two parts are interleaved!

But still it should work all fine, since the gfx driver does

set ELD_Valid = 0
write ELD
set ELD_Valid = 1

So the audio driver would read the correct ELD unless the ELD content
and flag writes are somehow _reordered_ underneath. Or the ELD content
writes take some time to take effect?

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


Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-09 Thread Wu Fengguang
On Thu, Nov 10, 2011 at 03:33:50PM +0800, Wu Fengguang wrote:
 Wow I reproduced the bug and got a very interesting dmesg:
 
 gfx =[ 4561.287980] [drm:intel_write_eld], ELD on 
 [CONNECTOR:12:HDMI-A-2], [ENCODER:11:TMDS-11]
 gfx =[ 4561.291730] [drm:ironlake_write_eld], ELD on pipe B
 gfx =[ 4561.293804] [drm:ironlake_write_eld], Audio directed to 
 unknown port
 gfx =[ 4561.295273] [drm:ironlake_write_eld],
   alsa = [ 4561.295486] HDMI hot plug event: Codec=3 Pin=6 
 Presence_Detect=1 ELD_Valid=0
   alsa = [ 4561.295564] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
 ELD_Valid=0
 gfx =[ 4561.300020] ELD size 13
   alsa = [ 4561.300697] HDMI hot plug event: Codec=3 Pin=6 
 Presence_Detect=1 ELD_Valid=1
   alsa = [ 4561.303322] HDMI status: Codec=3 Pin=6 Presence_Detect=1 
 ELD_Valid=1
   alsa = [ 4561.311120] ALSA hda_eld.c:259 HDMI: Unknown ELD version 0
   
 Hey the two parts are interleaved!
 
 But still it should work all fine, since the gfx driver does
 
 set ELD_Valid = 0
 write ELD
 set ELD_Valid = 1
 
 So the audio driver would read the correct ELD unless the ELD content
 and flag writes are somehow _reordered_ underneath. Or the ELD content
 writes take some time to take effect?

Just confirmed that adding 1s delay can fix it!

New dmesg is:

[   48.564923] [drm:drm_crtc_helper_set_mode], [ENCODER:11:TMDS-11] set 
[MODE:34:]
[   48.567481] [drm:intel_hdmi_mode_set], Enabling HDMI audio on pipe B
[   48.568975] [drm:intel_write_eld], ELD on [CONNECTOR:12:HDMI-A-2], 
[ENCODER:11:TMDS-11]
[   48.571728] [drm:ironlake_write_eld], ELD on pipe B
[   48.572882] [drm:ironlake_write_eld], Audio directed to unknown port
[   48.575252] [drm:ironlake_write_eld], 
[   48.575400] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=0
[   48.575487] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=0
[   48.580116] ELD size 13
[   48.580795] HDMI hot plug event: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
[   48.583340] HDMI status: Codec=3 Pin=6 Presence_Detect=1 ELD_Valid=1
[   48.632514] [drm:intel_wait_for_vblank], vblank wait timed out
[   48.685322] [drm:intel_wait_for_vblank], vblank wait timed out
[   48.687438] [drm:ironlake_update_wm], FIFO watermarks For pipe A - plane 5, 
cursor: 6
[   48.687438] [drm:ironlake_update_wm], FIFO watermarks For pipe A - plane 5, 
cursor: 6
[   48.690106] [drm:ironlake_update_wm], FIFO watermarks For pipe B - plane 42, 
cursor: 6
[   48.745204] [drm:intel_wait_for_vblank], vblank wait timed out
[   48.798035] [drm:intel_wait_for_vblank], vblank wait timed out
[   48.799633] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x100
[   48.802686] [drm:ironlake_fdi_link_train], FDI train 1 done.
[   48.805103] [drm:ironlake_fdi_link_train], FDI_RX_IIR 0x600
[   48.807246] [drm:ironlake_fdi_link_train], FDI train 2 done.
[   48.809426] [drm:ironlake_fdi_link_train], FDI train done
[   48.813960] [drm:intel_update_fbc], 
[   48.814782] [drm:drm_crtc_helper_set_config], Setting connector DPMS state 
to on
[   48.818093] [drm:drm_crtc_helper_set_config],[CONNECTOR:12:HDMI-A-2] 
set DPMS on
[   48.828633] [drm:intel_prepare_page_flip], preparing flip with no unpin work?
[   49.618962] HDMI: detected monitor RX-V1800 at connection type HDMI
[   49.621013] HDMI: available speakers: FL/FR LFE FC RL/RR RC RLC/RRC
[   49.622304] HDMI: supports coding type LPCM: channels = 2, rates = 32000 
44100 48000 96000 176400 192000 384000, bits = 16 20 24
[   49.625069] HDMI: supports coding type LPCM: channels = 8, rates = 32000 
44100 48000 96000 176400 192000 384000, bits = 16 20 24
[   49.628535] HDMI: supports coding type AC-3: channels = 6, rates = 32000 
44100 48000, max bitrate = 64
[   49.630810] HDMI: supports coding type DTS: channels = 7, rates = 32000 
44100 48000 96000 176400, max bitrate = 1536000
[   49.633148] HDMI: supports coding type DSD (One Bit Audio): channels = 6, 
rates = 44100
[   49.635039] HDMI: supports coding type E-AC-3/DD+ (Dolby Digital Plus): 
channels = 8, rates = 44100 48000
[   49.637130] HDMI: supports coding type MLP (Dolby TrueHD): channels = 8, 
rates = 48000 176400 384000
[   49.639172] HDMI: supports coding type DTS-HD: channels = 8, rates = 48000 
176400 384000

Thanks,
Fengguang

Subject: 
Date: Thu Nov 10 15:41:11 CST 2011


Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 sound/pci/hda/hda_eld.c |3 +++
 1 file changed, 3 insertions(+)

--- linux.orig/sound/pci/hda/hda_eld.c  2011-11-10 15:39:43.0 +0800
+++ linux/sound/pci/hda/hda_eld.c   2011-11-10 15:52:09.0 +0800
@@ -23,6 +23,7 @@
 
 #include linux/init.h
 #include linux/slab.h
+#include linux/delay.h
 #include sound/core.h
 #include asm/unaligned.h
 #include hda_codec.h
@@ -326,6 +327,8 @@ int snd_hdmi_get_eld(struct hdmi_eld *el
if (!eld-eld_valid)
return -ENOENT;
 
+   msleep(1000);
+
size = snd_hdmi_get_eld_size(codec

[Intel-gfx] [PATCH] drm/i915: fix ELD writing for SandyBridge

2011-11-08 Thread Wu Fengguang
SandyBridge should be using the same register addresses as IvyBridge.

btw, rename the register names accordingly.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |6 +++---
 drivers/gpu/drm/i915/intel_display.c |   10 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2011-11-09 13:17:19.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2011-11-09 13:18:39.0 
+0800
@@ -3543,8 +3543,8 @@
 #define GEN5_ELD_VALIDB(1  0)
 #define GEN5_CP_READYB (1  1)
 
-#define GEN7_HDMIW_HDMIEDID_A  0xE5050
-#define GEN7_AUD_CNTRL_ST_A0xE50B4
-#define GEN7_AUD_CNTRL_ST2 0xE50C0
+#define GEN6_HDMIW_HDMIEDID_A  0xE5050
+#define GEN6_AUD_CNTL_ST_A 0xE50B4
+#define GEN6_AUD_CNTRL_ST2 0xE50C0
 
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-09 
13:19:28.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-09 13:20:02.0 
+0800
@@ -5857,14 +5857,14 @@ static void ironlake_write_eld(struct dr
int aud_cntl_st;
int aud_cntrl_st2;
 
-   if (IS_IVYBRIDGE(connector-dev)) {
-   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
-   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
-   } else {
+   if (IS_GEN5(connector-dev)) {
hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
aud_cntl_st = GEN5_AUD_CNTL_ST_A;
aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   } else {
+   hdmiw_hdmiedid = GEN6_HDMIW_HDMIEDID_A;
+   aud_cntl_st = GEN6_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = GEN6_AUD_CNTRL_ST2;
}
 
i = to_intel_crtc(crtc)-pipe;
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-08 Thread Wu Fengguang
Hi Christopher,

I don't find anything wrong with the ELD parsing code, however I do
find a bug that prevented ELD from being passed to the audio driver on
SandyBridge.

I just posted the fix. For your convenience, it's attached in this
email too.

Thanks,
Fengguang

On Fri, Oct 28, 2011 at 03:57:23AM +0800, Christopher White wrote:
 There appears to be some issues with the patch? I'm on SandyBridge and 
 using the HD3000's HDMI.
 
 I've now tried manually merging the ELD patch (both files Wu Fengguang 
 submitted) and compiling Kernel 3.0.4. I've also tried drm-intel-next 
 Kernel 3.1 pre-built from 
 http://kernel.ubuntu.com/~kernel-ppa/mainline/drm-intel-next/current/ as 
 I knew it was built from keithp's latest drm-intel-next repository.
 
 Both of these methods had the patch applied, yet neither were able to 
 read the ELD correctly from my Onkyo TX-SR607 receiver.
 
 If I manually dump the EDID from my receiver and analyze it with Monitor 
 Asset Manager (by EnTech Taiwan), it shows that the ELD contains an 8 
 channel specification up to 192 kHz, and that's what's being exposed 
 over HDMI to the Intel graphics adapter, yet this isn't detected. It 
 just plain isn't being read, and is falling back to the default 2ch 
 16kHz configuration. It's exactly as it was in the past, before this 
 patch attempt.
 
 You can see my 256 byte EDID dump, straight from the receiver, over at:
 http://www.pulseforce.com/node/edid.dump
 
 It shows exactly what the receiver is exposing over HDMI, proving that 
 it's not the device that's at fault.
 
 Any ideas what's wrong? Here's the HDMI messages from the startup log:
 
 HDMI status: Pin=7 Presence_Detect=1 ELD_Valid=1
 HDMI: detected monitor  at connection type HDMI
 HDMI: available speakers: FL/FR
 HDMI: supports coding type LPCM: channels = 2, rates = 44100 48000 
 88200, bits = 16
 HDMI hot plug event: Pin=7 Presence_Detect=1 ELD_Valid=1
 HDMI status: Pin=7 Presence_Detect=1 ELD_Valid=1
 input: HDA Intel PCH HDMI/DP as 
 /devices/pci:00/:00:1b.0/sound/card0/input9
 HDMI: detected monitor  at connection type HDMI
 HDMI: available speakers: FL/FR
 HDMI: supports coding type LPCM: channels = 2, rates = 44100 48000 
 88200, bits = 16
 HDMI hot plug event: Pin=7 Presence_Detect=1 ELD_Valid=1
 HDMI status: Pin=7 Presence_Detect=1 ELD_Valid=1
 HDMI: detected monitor  at connection type HDMI
 HDMI: available speakers: FL/FR
 HDMI: supports coding type LPCM: channels = 2, rates = 44100 48000 
 88200, bits = 16
 
 
 
 Christopher White
Subject: drm/i915: fix ELD writing for SandyBridge
Date: Wed Nov 09 13:17:14 CST 2011

SandyBridge should be using the same register addresses as IvyBridge.

Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_reg.h  |6 +++---
 drivers/gpu/drm/i915/intel_display.c |   10 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

--- linux.orig/drivers/gpu/drm/i915/i915_reg.h  2011-11-09 13:17:19.0 
+0800
+++ linux/drivers/gpu/drm/i915/i915_reg.h   2011-11-09 13:18:39.0 
+0800
@@ -3543,8 +3543,8 @@
 #define GEN5_ELD_VALIDB(1  0)
 #define GEN5_CP_READYB (1  1)
 
-#define GEN7_HDMIW_HDMIEDID_A  0xE5050
-#define GEN7_AUD_CNTRL_ST_A0xE50B4
-#define GEN7_AUD_CNTRL_ST2 0xE50C0
+#define GEN6_HDMIW_HDMIEDID_A  0xE5050
+#define GEN6_AUD_CNTL_ST_A 0xE50B4
+#define GEN6_AUD_CNTRL_ST2 0xE50C0
 
 #endif /* _I915_REG_H_ */
--- linux.orig/drivers/gpu/drm/i915/intel_display.c 2011-11-09 
13:19:28.0 +0800
+++ linux/drivers/gpu/drm/i915/intel_display.c  2011-11-09 13:20:02.0 
+0800
@@ -5857,14 +5857,14 @@ static void ironlake_write_eld(struct dr
int aud_cntl_st;
int aud_cntrl_st2;
 
-   if (IS_IVYBRIDGE(connector-dev)) {
-   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
-   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
-   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
-   } else {
+   if (IS_GEN5(connector-dev)) {
hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
aud_cntl_st = GEN5_AUD_CNTL_ST_A;
aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   } else {
+   hdmiw_hdmiedid = GEN6_HDMIW_HDMIEDID_A;
+   aud_cntl_st = GEN6_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = GEN6_AUD_CNTRL_ST2;
}
 
i = to_intel_crtc(crtc)-pipe;
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] the monitors with working Displayport audio

2011-11-08 Thread Wu Fengguang
Hi Takashi,

I enumerated all the DELL DisplayPort monitors in our lab and find
only two of them being able to produce audible DisplayPort audio...

- DELL 2408WFP
- DELL 2709W
- DELL 3008WFP
no CEA extension found

- DELL U2410
ELD reports OK but cannot hear DP sound

monitor_present 1
eld_valid   1
monitor_nameDELL U2410
connection_type DisplayPort
eld_version [0x2] CEA-861D or below
edid_version[0x3] CEA-861-B, C or D
manufacture_id  0xac10
product_id  0xf017
port_id 0x0
support_hdcp0
support_ai  0
audio_sync_delay0
speakers[0x1] FL/FR
sad_count   1
sad0_coding_type[0x1] LPCM
sad0_channels   2
sad0_rates  [0xe0] 32000 44100 48000
sad0_bits   [0xe] 16 20 24

- DELL U3011
ELD and DP sound both OK

monitor_present 1
eld_valid   1
monitor_nameDELL U3011
connection_type DisplayPort
eld_version [0x2] CEA-861D or below
edid_version[0x3] CEA-861-B, C or D
manufacture_id  0xac10
product_id  0x4065
port_id 0x0
support_hdcp0
support_ai  0
audio_sync_delay0
speakers[0xf] FL/FR LFE FC RL/RR
sad_count   1
sad0_coding_type[0x1] LPCM
sad0_channels   6
sad0_rates  [0x1ee0] 32000 44100 48000 96000 176400 192000 
384000
sad0_bits   [0xe] 16 20 24

- Eizo FlexScan EV2333W
ELD and DP sound both OK

monitor_present 1
eld_valid   1
monitor_nameEV2333W
connection_type DisplayPort
eld_version [0x2] CEA-861D or below
edid_version[0x3] CEA-861-B, C or D
manufacture_id  0xc315
product_id  0x2068
port_id 0x0
support_hdcp0
support_ai  1
audio_sync_delay0
speakers[0x1] FL/FR
sad_count   1
sad0_coding_type[0x1] LPCM
sad0_channels   2
sad0_rates  [0x1ee0] 32000 44100 48000 96000 176400 192000 
384000
sad0_bits   [0xe] 16 20 24

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


Re: [Intel-gfx] the monitors with working Displayport audio

2011-11-08 Thread Wu Fengguang
Here are the EDID for the DELL monitors, grabbed by command

cp /sys/class/drm/card0-DP-3/edid .

Thanks,
Fengguang

On Wed, Nov 09, 2011 at 03:20:53PM +0800, Wu Fengguang wrote:
 Hi Takashi,
 
 I enumerated all the DELL DisplayPort monitors in our lab and find
 only two of them being able to produce audible DisplayPort audio...
 
 - DELL 2408WFP
 - DELL 2709W
 - DELL 3008WFP
 no CEA extension found
 
 - DELL U2410
 ELD reports OK but cannot hear DP sound
 
 monitor_present 1
 eld_valid   1
 monitor_nameDELL U2410
 connection_type DisplayPort
 eld_version [0x2] CEA-861D or below
 edid_version[0x3] CEA-861-B, C or D
 manufacture_id  0xac10
 product_id  0xf017
 port_id 0x0
 support_hdcp0
 support_ai  0
 audio_sync_delay0
 speakers[0x1] FL/FR
 sad_count   1
 sad0_coding_type[0x1] LPCM
 sad0_channels   2
 sad0_rates  [0xe0] 32000 44100 48000
 sad0_bits   [0xe] 16 20 24
 
 - DELL U3011
 ELD and DP sound both OK
 
 monitor_present 1
 eld_valid   1
 monitor_nameDELL U3011
 connection_type DisplayPort
 eld_version [0x2] CEA-861D or below
 edid_version[0x3] CEA-861-B, C or D
 manufacture_id  0xac10
 product_id  0x4065
 port_id 0x0
 support_hdcp0
 support_ai  0
 audio_sync_delay0
 speakers[0xf] FL/FR LFE FC RL/RR
 sad_count   1
 sad0_coding_type[0x1] LPCM
 sad0_channels   6
 sad0_rates  [0x1ee0] 32000 44100 48000 96000 176400 
 192000 384000
 sad0_bits   [0xe] 16 20 24
 
 - Eizo FlexScan EV2333W
 ELD and DP sound both OK
 
 monitor_present 1
 eld_valid   1
 monitor_nameEV2333W
 connection_type DisplayPort
 eld_version [0x2] CEA-861D or below
 edid_version[0x3] CEA-861-B, C or D
 manufacture_id  0xc315
 product_id  0x2068
 port_id 0x0
 support_hdcp0
 support_ai  1
 audio_sync_delay0
 speakers[0x1] FL/FR
 sad_count   1
 sad0_coding_type[0x1] LPCM
 sad0_channels   2
 sad0_rates  [0x1ee0] 32000 44100 48000 96000 176400 
 192000 384000
 sad0_bits   [0xe] 16 20 24
 
 Thanks,
 Fengguang


edid-dell-3008wfp
Description: Binary data


edid-dell-u2410
Description: Binary data


edid-dell-u3011
Description: Binary data


edid-dell-2709w
Description: Binary data


edid-dell-2408wfp
Description: Binary data
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-02 Thread Wu Fengguang
Hi Sander,

 On Tue, Nov 1, 2011 at 8:45 PM, Wu Fengguang fengguang...@intel.com wrote:
  Hi Christopher,
 
  The log does confirm that the drm_edid_to_eld function is running, and
  that we're not far from a solution:
  [   21.061417] [drm:drm_edid_to_eld], ELD monitor TX-SR607
  [   21.061421] [drm:drm_edid_to_eld], ELD size 13, SAD count 8
 
  It looks all sane to this point.
 
  As for where I am getting the EDID dump from, I am getting it from
  /sys/devices/pci:00/:00:02.0/drm/card0/card0-HDMI-A-2/edid,
  which provides direct virtual access to the EDID response of the
  connected device.
 
  I'm completely confident that the device doesn't report too small of a
  buffer size, and that it's completely compliant with the spec: If you
 
  Agreed.
 
  have a Windows virtual machine (or if you're masochistic enough - a real
  machine) you should download the excellent, free Monitor Asset Manager
  by EnTech Taiwan from http://www.entechtaiwan.com/util/moninfo.shtm. It
  will let you analyze EDID + ELD + extended timings, etc from an EDID
  dump, such as the one taken above. It understands every part of EDID.
 
  I've put together a small archive containing my exact EDID binary dump
  (taken from the above device path), the FULL dmesg log, as well as
  EnTech's interpretation of the EDID dump, showing the full list of
  supported channels, formats, etc.
 
  I'm guessing there is some tiny bug in your interpretation of how to
  read ELD, maybe an incorrect 1 byte offset or something like that.
 
  Here's the pack:
  http://www.pulseforce.com/node/edid_to_eld.zip
 
  Thanks! It's great tool and information!
 
  If you do a hex analysis of my EDID dump and compare it to what the
  edid_to_eld function is trying to do, it will probably show what's
  wrong. I'd love to have a look at that myself but am really busy with a
  project over here so I can't help out other than to recompile and test
  as fast as I can.
 
  Would you install the intel-gpu-tools package and run its
  intel_audio_dump utility? If not shipped with your distribution, the
  source code is also available in
 
  git://anongit.freedesktop.org/git/xorg/app/intel-gpu-tools
 
  You'll need to install packages autotools-dev pkg-config
  libpciaccess-dev libdrm-dev libdrm-intel1 in order to build it from
  source.
 
  intel_audio_dump will dump the ELD data in the hardware buffer for use
  by the audio driver. By verifying if that data is correct, we are able
  to analyze whether and how the audio driver goes wrong.
 
 
 I think I experience similar issues. In my case the multi-channel pcm
 playback through HDMI doesn't work. Stereo and passthrough seem to
 work fine though !? It's hookedup  to my TV via a yamaha receiver.

Yeah, multi-channel playback should not work due to the audio driver
not knowing the HDMI sink is multi-channel capable.

Stereo and passthrough should work always.

 I'm currently running Linux 3.1 with a G45 chipset.

 libdrm 2.4.27-1
 xf86-video-intel 2.16.0-1
 
 The eld seems be incorrectly parsed, though the kernel log didn't give
 much info. The eld info from alsa is rather empty:
 
In fact Linux 3.1 does not have the ELD patch yet. It should go into
the upcoming 3.2.

 cat /proc/asound/Intel/eld#3.0
 monitor_present   1
 eld_valid 0
 
 Using the same Monitor Asset Manager I was able to verify that the edid from
 (/sys/devices/pci\:00/\:00\:02.0/drm/card0/card0-HDMI-A-1/edid
 ) does seem to contain the correct information.

That's good.

 I've attached both the edid and the output of Monitor Asset Manager.In
 addition I also run the intel_audio_dump.
 
 Let me know if you need anymore information.
 

As the ELD patch is not there, intel_audio_dump correctly reports

AUD_CNTL_ST ELD valid   0

I'm not sure if it's convenient for you to compile new kernels (with
the ELD patch applied).  If not, we can wait Christopher White for the
feedback.

Thanks,
Fengguang

 Monitor
   Model name... SAMSUNG
   Manufacturer. Samsung
   Plug and Play ID. SAM050D
   Serial number 1
   Manufacture date. 2008, ISO week 48
   Filter driver None
   -
   EDID revision 1.3
   Input signal type Digital
   Color bit depth.. Undefined
   Display type. RGB color
   Screen size.. 160 x 90 mm (7.2 in)
   Power management. Not supported
   Extension blocs.. 1 (CEA-EXT)
   -
   DDC/CI... n/a
 
 Color characteristics
   Default color space.. Non-sRGB
   Display gamma 2.20
   Red chromaticity. Rx 0.640 - Ry 0.330
   Green chromaticity... Gx 0.300 - Gy 0.600
   Blue chromaticity Bx 0.150 - By 0.060
   White point (default) Wx 0.313 - Wy 0.329
   Additional descriptors... None
 
 Timing characteristics
   Horizontal scan range 26-81kHz
   Vertical scan range

Re: [Intel-gfx] [PATCH v5] drm/i915: pass ELD to HDMI/DP audio driver

2011-11-01 Thread Wu Fengguang
Hi Christopher,

 The log does confirm that the drm_edid_to_eld function is running, and 
 that we're not far from a solution:
 [   21.061417] [drm:drm_edid_to_eld], ELD monitor TX-SR607
 [   21.061421] [drm:drm_edid_to_eld], ELD size 13, SAD count 8

It looks all sane to this point.

 As for where I am getting the EDID dump from, I am getting it from 
 /sys/devices/pci:00/:00:02.0/drm/card0/card0-HDMI-A-2/edid, 
 which provides direct virtual access to the EDID response of the 
 connected device.
 
 I'm completely confident that the device doesn't report too small of a 
 buffer size, and that it's completely compliant with the spec: If you 

Agreed.

 have a Windows virtual machine (or if you're masochistic enough - a real 
 machine) you should download the excellent, free Monitor Asset Manager 
 by EnTech Taiwan from http://www.entechtaiwan.com/util/moninfo.shtm. It 
 will let you analyze EDID + ELD + extended timings, etc from an EDID 
 dump, such as the one taken above. It understands every part of EDID.
 
 I've put together a small archive containing my exact EDID binary dump 
 (taken from the above device path), the FULL dmesg log, as well as 
 EnTech's interpretation of the EDID dump, showing the full list of 
 supported channels, formats, etc.
 
 I'm guessing there is some tiny bug in your interpretation of how to 
 read ELD, maybe an incorrect 1 byte offset or something like that.
 
 Here's the pack:
 http://www.pulseforce.com/node/edid_to_eld.zip

Thanks! It's great tool and information!

 If you do a hex analysis of my EDID dump and compare it to what the 
 edid_to_eld function is trying to do, it will probably show what's 
 wrong. I'd love to have a look at that myself but am really busy with a 
 project over here so I can't help out other than to recompile and test 
 as fast as I can.

Would you install the intel-gpu-tools package and run its
intel_audio_dump utility? If not shipped with your distribution, the
source code is also available in

git://anongit.freedesktop.org/git/xorg/app/intel-gpu-tools

You'll need to install packages autotools-dev pkg-config
libpciaccess-dev libdrm-dev libdrm-intel1 in order to build it from
source.

intel_audio_dump will dump the ELD data in the hardware buffer for use
by the audio driver. By verifying if that data is correct, we are able
to analyze whether and how the audio driver goes wrong.

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


[Intel-gfx] [PATCH 1/2] drm: support routines for HDMI/DP ELD

2011-09-05 Thread Wu Fengguang
ELD (EDID-Like Data) describes to the HDMI/DP audio driver the audio
capabilities of the plugged monitor.

This adds drm_edid_to_eld() for converting EDID to ELD. The converted
ELD will be saved in a new drm_connector.eld[128] data field. This is
necessary because the graphics driver will need to fixup some of the
data fields (eg. HDMI/DP connection type, AV sync delay) before writing
to the hardware ELD buffer. drm_av_sync_delay() will help the graphics
drivers dynamically compute the AV sync delay for fixing-up the ELD.

ELD selection policy: it's possible for one encoder to be associated
with multiple connectors (ie. monitors), in which case the first found
ELD will be returned by drm_select_eld(). This policy may not be
suitable for all users, but let's start it simple first.

The impact of ELD selection policy: assume there are two monitors, one
supports stereo playback and the other has 8-channel output; cloned
display mode is used, so that the two monitors are associated with the
same internal encoder. If only the stereo playback capability is reported,
the user won't be able to start 8-channel playback; if the 8-channel ELD
is reported, then user space applications may send 8-channel samples
down, however the user may actually be listening to the 2-channel
monitor and not connecting speakers to the 8-channel monitor.

According to James, many TVs will either refuse the display anything or
pop-up an OSD warning whenever they receive hdmi audio which they cannot
handle. Eventually we will require configurability and/or per-monitor
audio control even when the video is cloned.

CC: Zhao Yakui yakui.z...@intel.com
CC: Wang Zhenyu zhenyu.z.w...@intel.com
CC: Jeremy Bush contractfrombe...@gmail.com
CC: Christopher White c.wh...@pulseforce.com
CC: Pierre-Louis Bossart pierre-louis.boss...@intel.com
CC: Paul Menzel paulepan...@users.sourceforge.net
CC: James Cloos cl...@jhcloos.com
CC: Chris Wilson ch...@chris-wilson.co.uk
Signed-off-by: Ben Skeggs bske...@redhat.com
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/drm_edid.c |  171 +++
 include/drm/drm_edid.h |9 +
 2 files changed, 180 insertions(+)

--- linux-next.orig/include/drm/drm_crtc.h  2011-09-04 09:42:19.0 
+0800
+++ linux-next/include/drm/drm_crtc.h   2011-09-05 09:00:25.0 +0800
@@ -466,6 +466,8 @@ enum drm_connector_force {
 /* DACs should rarely do this without a lot of testing */
 #define DRM_CONNECTOR_POLL_DISCONNECT (1  2)
 
+#define MAX_ELD_BYTES  128
+
 /**
  * drm_connector - central DRM connector control structure
  * @crtc: CRTC this connector is currently connected to, NULL if none
@@ -523,6 +525,13 @@ struct drm_connector {
uint32_t force_encoder_id;
struct drm_encoder *encoder; /* currently active encoder */
 
+   /* EDID bits */
+   uint8_t eld[MAX_ELD_BYTES];
+   bool dvi_dual;
+   int max_tmds_clock; /* in MHz */
+   bool latency_present[2];
+   int video_latency[2];   /* [0]: progressive, [1]: interlaced */
+   int audio_latency[2];
int null_edid_counter; /* needed to workaround some HW bugs where we 
get all 0s */
 };
 
--- linux-next.orig/include/drm/drm_edid.h  2011-09-05 12:35:36.0 
+0800
+++ linux-next/include/drm/drm_edid.h   2011-09-05 12:36:10.0 +0800
@@ -230,4 +230,13 @@ struct edid {
 
 #define EDID_PRODUCT_ID(e) ((e)-prod_code[0] | ((e)-prod_code[1]  8))
 
+struct drm_encoder;
+struct drm_connector;
+struct drm_display_mode;
+void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid);
+int drm_av_sync_delay(struct drm_connector *connector,
+ struct drm_display_mode *mode);
+struct drm_connector *drm_select_eld(struct drm_encoder *encoder,
+struct drm_display_mode *mode);
+
 #endif /* __DRM_EDID_H__ */
--- linux-next.orig/drivers/gpu/drm/drm_edid.c  2011-09-05 12:35:36.0 
+0800
+++ linux-next/drivers/gpu/drm/drm_edid.c   2011-09-05 12:36:10.0 
+0800
@@ -1319,6 +1319,7 @@ add_detailed_modes(struct drm_connector 
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VENDOR_BLOCK0x03
+#define SPEAKER_BLOCK  0x04
 #define EDID_BASIC_AUDIO   (1  6)
 
 /**
@@ -1347,6 +1348,176 @@ u8 *drm_find_cea_extension(struct edid *
 }
 EXPORT_SYMBOL(drm_find_cea_extension);
 
+static void
+parse_hdmi_vsdb(struct drm_connector *connector, uint8_t *db)
+{
+   connector-eld[5] |= (db[6]  7)  1;  /* Supports_AI */
+
+   connector-dvi_dual = db[6]  1;
+   connector-max_tmds_clock = db[7] * 5;
+
+   connector-latency_present[0] = db[8]  7;
+   connector-latency_present[1] = (db[8]  6)  1;
+   connector-video_latency[0] = db[9];
+   connector-audio_latency[0] = db[10];
+   connector-video_latency[1] = db[11];
+   connector-audio_latency[1] = db[12];
+
+   DRM_LOG_KMS(HDMI: DVI dual %d, 
+   max TMDS clock %d

[Intel-gfx] [PATCH 2/2] drm/i915: pass ELD to HDMI/DP audio driver

2011-09-05 Thread Wu Fengguang
Add ELD support for Intel Eaglelake, IbexPeak/Ironlake,
SandyBridge/CougarPoint and IvyBridge/PantherPoint chips.

ELD (EDID-Like Data) describes to the HDMI/DP audio driver the audio
capabilities of the plugged monitor. It's built and passed to audio
driver in 2 steps:

(1) at get_modes time, parse EDID and save ELD to drm_connector.eld[]

(2) at mode_set time, write drm_connector.eld[] to the Transcoder's hw
ELD buffer and set the ELD_valid bit to inform HDMI/DP audio driver

This patch is tested OK on G45/HDMI, IbexPeak/HDMI and IvyBridge/HDMI+DP.
Test scheme: plug in the HDMI/DP monitor, and run

cat /proc/asound/card0/eld*

to check if the monitor name, HDMI/DP type, etc. show up correctly.

Minor imperfection: the GEN5_AUD_CNTL_ST/DIP_Port_Select field always
reads 0 (reserved). Without knowing the port number, I worked it around
by setting the ELD_valid bit for ALL the three ports. It's tested to not
be a problem, because the audio driver will find invalid ELD data and
hence rightfully abort, even when it sees the ELD_valid indicator.

Thanks to Zhenyu and Pierre-Louis for a lot of valuable help and testing.

CC: Zhao Yakui yakui.z...@intel.com
CC: Wang Zhenyu zhenyu.z.w...@intel.com
CC: Jeremy Bush contractfrombe...@gmail.com
CC: Christopher White c.wh...@pulseforce.com
CC: Pierre-Louis Bossart pierre-louis.boss...@intel.com
CC: Paul Menzel paulepan...@users.sourceforge.net
Signed-off-by: Wu Fengguang fengguang...@intel.com
---
 drivers/gpu/drm/i915/i915_drv.h  |2 
 drivers/gpu/drm/i915/i915_reg.h  |   25 
 drivers/gpu/drm/i915/intel_display.c |  131 -
 drivers/gpu/drm/i915/intel_dp.c  |6 -
 drivers/gpu/drm/i915/intel_drv.h |2 
 drivers/gpu/drm/i915/intel_hdmi.c|3 
 drivers/gpu/drm/i915/intel_modes.c   |2 
 7 files changed, 169 insertions(+), 2 deletions(-)

--- linux-next.orig/drivers/gpu/drm/i915/intel_hdmi.c   2011-09-05 
14:01:48.0 +0800
+++ linux-next/drivers/gpu/drm/i915/intel_hdmi.c2011-09-05 
14:02:57.0 +0800
@@ -245,8 +245,11 @@ static void intel_hdmi_mode_set(struct d
sdvox |= HDMI_MODE_SELECT;
 
if (intel_hdmi-has_audio) {
+   DRM_DEBUG_DRIVER(Enabling HDMI audio on pipe %c\n,
+pipe_name(intel_crtc-pipe));
sdvox |= SDVO_AUDIO_ENABLE;
sdvox |= SDVO_NULL_PACKETS_DURING_VSYNC;
+   intel_write_eld(encoder, adjusted_mode);
}
 
if (intel_crtc-pipe == 1) {
--- linux-next.orig/drivers/gpu/drm/i915/intel_display.c2011-09-05 
14:01:48.0 +0800
+++ linux-next/drivers/gpu/drm/i915/intel_display.c 2011-09-05 
14:02:57.0 +0800
@@ -31,6 +31,7 @@
 #include linux/kernel.h
 #include linux/slab.h
 #include linux/vgaarb.h
+#include drm/drm_edid.h
 #include drmP.h
 #include intel_drv.h
 #include i915_drm.h
@@ -5667,6 +5668,131 @@ static int intel_crtc_mode_set(struct dr
return ret;
 }
 
+static void g4x_write_eld(struct drm_connector *connector,
+ struct drm_crtc *crtc)
+{
+   struct drm_i915_private *dev_priv = connector-dev-dev_private;
+   uint8_t *eld = connector-eld;
+   uint32_t eldv;
+   uint32_t len;
+   uint32_t i;
+
+   i = I915_READ(G4X_AUD_VID_DID);
+
+   if (i == INTEL_AUDIO_DEVBLC || i == INTEL_AUDIO_DEVCL)
+   eldv = G4X_ELDV_DEVCL_DEVBLC;
+   else
+   eldv = G4X_ELDV_DEVCTG;
+
+   i = I915_READ(G4X_AUD_CNTL_ST);
+   i = ~(eldv | G4X_ELD_ADDR);
+   len = (i  9)  0x1f;  /* ELD buffer size */
+   I915_WRITE(G4X_AUD_CNTL_ST, i);
+
+   if (!eld[0])
+   return;
+
+   len = min_t(uint8_t, eld[2], len);
+   DRM_DEBUG_DRIVER(ELD size %d\n, len);
+   for (i = 0; i  len; i++)
+   I915_WRITE(G4X_HDMIW_HDMIEDID, *((uint32_t *)eld + i));
+
+   i = I915_READ(G4X_AUD_CNTL_ST);
+   i |= eldv;
+   I915_WRITE(G4X_AUD_CNTL_ST, i);
+}
+
+static void ironlake_write_eld(struct drm_connector *connector,
+struct drm_crtc *crtc)
+{
+   struct drm_i915_private *dev_priv = connector-dev-dev_private;
+   uint8_t *eld = connector-eld;
+   uint32_t eldv;
+   uint32_t i;
+   int len;
+   int hdmiw_hdmiedid;
+   int aud_cntl_st;
+   int aud_cntrl_st2;
+
+   if (IS_IVYBRIDGE(connector-dev)) {
+   hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
+   aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
+   aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
+   } else {
+   hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
+   aud_cntl_st = GEN5_AUD_CNTL_ST_A;
+   aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
+   }
+
+   i = to_intel_crtc(crtc)-pipe;
+   hdmiw_hdmiedid += i * 0x100;
+   aud_cntl_st += i * 0x100;
+
+   DRM_DEBUG_DRIVER(ELD on pipe %c\n, pipe_name(i));
+
+   i = I915_READ(aud_cntl_st

Re: [Intel-gfx] [PATCH 2/2] drm/i915: pass ELD to HDMI/DP audio driver

2011-09-05 Thread Wu Fengguang
I'd like to do more cleanups:

 + int aud_cntl_st;
 + int aud_cntrl_st2;

s/aud_cntrl_st2/aud_cntl_st2/

 + if (IS_IVYBRIDGE(connector-dev)) {
 + hdmiw_hdmiedid = GEN7_HDMIW_HDMIEDID_A;
 + aud_cntl_st = GEN7_AUD_CNTRL_ST_A;
 + aud_cntrl_st2 = GEN7_AUD_CNTRL_ST2;
 + } else {
 + hdmiw_hdmiedid = GEN5_HDMIW_HDMIEDID_A;
 + aud_cntl_st = GEN5_AUD_CNTL_ST_A;
 + aud_cntrl_st2 = GEN5_AUD_CNTL_ST2;
 + }
 +
 + i = to_intel_crtc(crtc)-pipe;
 + hdmiw_hdmiedid += i * 0x100;
 + aud_cntl_st += i * 0x100;
 +
 + DRM_DEBUG_DRIVER(ELD on pipe %c\n, pipe_name(i));
[...]
 + len = min_t(uint8_t, eld[2], 21);   /* 84 bytes of hw ELD buffer */
 + DRM_DEBUG_DRIVER(ELD size %d\n, len);

Merge the above two DRM_DEBUG_DRIVER() calls into:

+   DRM_DEBUG_DRIVER(writing %d ELD dword(s) on pipe %c\n,
+len, pipe_name(to_intel_crtc(crtc)-pipe));

 + for (i = 0; i  len; i++)
 + I915_WRITE(hdmiw_hdmiedid, *((uint32_t *)eld + i));

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


  1   2   >