Re: [PATCH for vm-scalability] usemem: Output a message after punch holes done

2021-04-17 Thread Wu Fengguang

Applied, thanks!



Re: [PATCH for vm-scalability] usemem: Add code for touch-alloc

2021-04-09 Thread Wu Fengguang

Applied, thanks!

On Thu, Apr 08, 2021 at 09:42:55PM +0800, Hui Zhu wrote:

Add code for touch-alloc.
And Change read memory to write memory to avoid use the zero-page for
reads in do_anonymous_page.

Signed-off-by: Hui Zhu 
---
usemem.c | 34 ++
1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/usemem.c b/usemem.c
index e2c46ec..5b90aae 100644
--- a/usemem.c
+++ b/usemem.c
@@ -329,6 +329,18 @@ void detach(void)
}
}

+unsigned long do_access(unsigned long *p, unsigned long idx, int read)
+{
+   volatile unsigned long *vp = p;
+
+   if (read)
+   return vp[idx]; /* read data */
+   else {
+   vp[idx] = idx;  /* write data */
+   return 0;
+   }
+}
+
unsigned long * allocate(unsigned long bytes)
{
unsigned long *p;
@@ -355,6 +367,14 @@ unsigned long * allocate(unsigned long bytes)
p = (unsigned long *)ALIGN((unsigned long)p, pagesize - 1);
}

+   if (opt_touch_alloc) {
+   unsigned long i;
+   unsigned long m = bytes / sizeof(*p);
+
+   for (i = 0; i < m; i += 1)
+   do_access(p, i, 0);
+   }
+
return p;
}

@@ -436,18 +456,6 @@ void shm_unlock(int seg_id)
shmctl(seg_id, SHM_UNLOCK, NULL);
}

-unsigned long do_access(unsigned long *p, unsigned long idx, int read)
-{
-   volatile unsigned long *vp = p;
-
-   if (read)
-   return vp[idx]; /* read data */
-   else {
-   vp[idx] = idx;  /* write data */
-   return 0;
-   }
-}
-
#define NSEC_PER_SEC  (1UL * 1000 * 1000 * 1000)

long nsec_sub(long nsec1, long nsec2)
@@ -953,6 +961,8 @@ int main(int argc, char *argv[])
opt_punch_holes = 1;
} else if (strcmp(opts[opt_index].name, "init-time") == 
0) {
opt_init_time = 1;
+   } else if (strcmp(opts[opt_index].name, "touch-alloc") 
== 0) {
+   opt_touch_alloc = 1;
} else
usage(1);
break;
--
2.17.1





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 
> Signed-Off-by: Daniel Vetter 

Reviewed-by: Wu Fengguang 

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 
> > Signed-off-by: Wu Fengguang 
> 
> 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 
Signed-off-by: Wu Fengguang 
---
 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 *
  

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

2012-02-07 Thread Wu Fengguang
commit b3f33cbf7ace8fc149993ee35e0d0fd57f41d6d8 upstream.

SandyBridge should be using the same register addresses as IvyBridge.

Signed-off-by: Wu Fengguang 
Signed-off-by: Keith Packard 
---
 drivers/gpu/drm/i915/intel_display.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index d809b03..8a61b81 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5876,14 +5876,14 @@ static void ironlake_write_eld(struct drm_connector 
*connector,
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;
-- 
1.7.7.3

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


[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 
Signed-off-by: Wu Fengguang 
---
 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 
Signed-off-by: Wu Fengguang 
---
 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 
Signed-off-by: Wu Fengguang 
---
 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


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

2012-01-16 Thread Wu Fengguang

Signed-off-by: Wu Fengguang 
---
 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


[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 
---
 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


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  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 
Signed-off-by: Wu Fengguang 
---
 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


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  
> 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: 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  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 
> > > Signed-off-by: Wu Fengguang 
> > > ---
> > 
> > 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 HDMI<>DVI 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


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  
> 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 
Signed-off-by: Wu Fengguang 
---
 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


[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 
---
 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: 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


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  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 
> > Signed-off-by: Wu Fengguang 
> > ---
> 
> 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


[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 
Signed-off-by: Wu Fengguang 
---
 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 
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 
Reviewed-by: Keith Packard 
Signed-off-by: Keith Packard 

commit 55b7d6e8c4690047ac001026cb75a47f747db816
Author: Chris Wilson 
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 

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_

[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/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 
---
 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] [PATCH 5/5] 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".

Tested OK for both hot plug/remove and DPMS on/off.

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

--- 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 4/5] drm/i915: HDMI hot remove notification to audio driver

2011-12-09 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 
Signed-off-by: Wu Fengguang 
---
 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 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 
Signed-off-by: Wu Fengguang 
---
 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 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 
Signed-off-by: Wu Fengguang 
---
 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 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] 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 
---
 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 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 
Signed-off-by: Wu Fengguang 
---
 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 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 
---
 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


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 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 
Signed-off-by: Wu Fengguang 
---
 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


[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 
Signed-off-by: Wu Fengguang 
---
 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 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 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 
Signed-off-by: Wu Fengguang 
---
 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/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 
---
 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


[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  
> 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 
Signed-off-by: Wu Fengguang 
---
 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);


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  
> 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 
Signed-off-by: Wu Fengguang 
---
 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: [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  
> 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 
Signed-off-by: Wu Fengguang 
---
 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);
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[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  
> 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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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) {
-   

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  
> 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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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) {
-   

Re: [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  
> 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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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) {
-   

[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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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_ge

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

2011-11-22 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  
> 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


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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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_ge

Re: [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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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_ge

Re: [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  
> 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
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


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  
> 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


[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  > > 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


[PATCH 3/3 v3] drm/i915: hot plug/unplug notification to HDMI audio driver

2011-11-21 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 
Signed-off-by: Wu Fengguang 
---
 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(-)

Changes since v2:

Fix "kernel NULL pointer dereference" due to calling NULL ->hotplug.

--- 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 
 #include 
 #include 
+#include 
 #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_au

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

2011-11-21 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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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);
}
  

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

2011-11-21 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  
> 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_ge

Re: [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  
> > > 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
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


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  
> > > 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


[PATCH 3/3 v3] drm/i915: hot plug/unplug notification to HDMI audio driver

2011-11-21 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 
Signed-off-by: Wu Fengguang 
---
 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(-)

Changes since v2:

Fix "kernel NULL pointer dereference" due to calling NULL ->hotplug.

--- 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 
 #include 
 #include 
+#include 
 #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_au

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

2011-11-21 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 
Signed-off-by: Wu Fengguang 
---
 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(-)

Changes since v2:

Fix "kernel NULL pointer dereference" due to calling NULL ->hotplug.

--- 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 
 #include 
 #include 
+#include 
 #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_au

[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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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);
  

[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 
Signed-off-by: Wu Fengguang 
---
 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 
 #include 
 #include 
+#include 
 #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);
  

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  
> 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_ge

Re: [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  
> 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_ge

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

2011-11-19 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  
> 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


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  
> 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


Re: [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  
> 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
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[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__ */


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: [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__ */
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[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 
Signed-off-by: Wu Fengguang 
---
 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);
 };


[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__ */


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

2011-11-16 Thread Wu Fengguang
An embedded and charset-unspecified text was scrubbed...
Name: eld-hot-removal
URL: 



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

2011-11-16 Thread Wu Fengguang
An embedded and charset-unspecified text was scrubbed...
Name: no-extra-eld-passing
URL: 



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

2011-11-16 Thread Wu Fengguang
An embedded and charset-unspecified text was scrubbed...
Name: sandybridge-eld-fix
URL: 



[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



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


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
> > [  

[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 
Signed-off-by: Wu Fengguang 
---
 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


[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 
Signed-off-by: Wu Fengguang 
---
 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);
 };
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


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


Re: [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__ */
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[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 
Signed-off-by: Wu Fengguang 
---
 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_heigh

[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 
Signed-off-by: Wu Fengguang 
---
 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_heigh

[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 
---
 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;


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[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 
---
 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


[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 
Signed-off-by: Wu Fengguang 
---
 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);


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[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 
Signed-off-by: Wu Fengguang 
---
 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 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


[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

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


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 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 
---
 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(co

[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 
---
 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_pro

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


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 
> > > 
> > > 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 1/2] hda - fix ELD memory leak

2011-11-15 Thread Wu Fengguang
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 
> 
> 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.

Thanks,
Fengguang

> > ---
> >  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 
---
 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_pro

[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 
---
 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


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 
> > ---
> >  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

[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 
---
 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


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

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang 
---
 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 15/18] intel_audio_dump: show VIDEO_DIP_CTL_* for CPT

2011-11-11 Thread Wu Fengguang

Signed-off-by: Wu Fengguang 
---
 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


  1   2   3   4   >