Skip to contentSkip to conversation

Haswell HDMI/DP audio enable

PATCH Superseded Wang Xingchao 4 participants 11 messages Jul 31, 2012 – Aug 6, 2012

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover Haswell HDMI/DP audio enable

This patch series enable HDMI audio on Haswell platform, not DP audio. The DP enablement will come after the DP patches are upstream.

V2 patches fixed one warning and some type errors.

Here're some notes useful for you to test the patches on Sharkbay machine:
I> please make sure your branch include below three patches in Takashi's sound tree, othersiwe there's no proper Haswell ID and HDMI ID.
http://git.alsa-project.org/?p=alsa-kmirror.git;a=commitdiff;h=79fc901301d6115b11457e8240ed6abc4b3f5c65
http://git.alsa-project.org/?p=alsa-kmirror.git;a=commitdiff;h=e269cee227a2b2297b79bfc71094c709b9387061
http://git.alsa-project.org/?p=alsa-kmirror.git;a=commitdiff;h=cb192625233496ac3d96cce667ebf4e322dab678

II> No sound from HDMI/DP.
we found it's not stable in current stage, sometimes you may not heard sound from HDMI or DP port, but most of the time you can heard clear sound. After some investigation, we suspect the HDA verb didnot really make codec change,and we regard the GPU register as the right one.
the easy way is to use intel_audio_dump to compare related registers, and make sure the port is enabled and unmute, otherwise there's no sound. intel_audio_tools has no support on Haswell yet, i wrote patches to make that happen, if you need the patches, please feel free to let me know. Here's part of the snapshot about port enable and mute status from intel_audio_dump:

AUD_PORT_EN_HD_CFG  Port_B_Out_Enable			1
AUD_PORT_EN_HD_CFG  Port_C_Out_Enable			1
AUD_PORT_EN_HD_CFG  Port_D_Out_Enable			1
AUD_PORT_EN_HD_CFG  Port_B_Amp_Mute_Status		1
AUD_PORT_EN_HD_CFG  Port_C_Amp_Mute_Status		0
AUD_PORT_EN_HD_CFG  Port_D_Amp_Mute_Status		1

you can see from above message, the Port C is enabled and unmute, that's what we expect.

Wang Xingchao (4):
drm/i915: HSW audio registers definition
drm/i915: write eld info for HDMI audio
drm/i915: Haswell HDMI audio enable
ALSA HDA: Force HDMI pins enabled

 drivers/gpu/drm/i915/i915_reg.h      |   46 +++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ddi.c     |    6 +++-
 drivers/gpu/drm/i915/intel_display.c |   58 ++++++++++++++++++++++++++++++++++
 sound/pci/hda/patch_hdmi.c           |   15 +++++----
 4 files changed, 117 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/4 drm/i915: HSW audio registers definition

Add hsw audio registers definition

---
 drivers/gpu/drm/i915/i915_reg.h |   46 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +46 -0
index 1310caa..00b0182 100644
@@ -4277,6 +4277,52 @@
 #define   AUD_CONFIG_PIXEL_CLOCK_HDMI		(0xf << 16)
 #define   AUD_CONFIG_DISABLE_NCTS		(1 << 3)
 
+/* HSW Audio */
+#define   HSW_AUD_CONFIG_A			0x65000 /*Audio Configuration Transcoder A*/
+#define   HSW_AUD_CONFIG_B			0x65100 /*Audio Configuration Transcoder B*/
+#define   HSW_AUD_CFG(pipe) _PIPE(pipe, \
+					HSW_AUD_CONFIG_A, \
+					HSW_AUD_CONFIG_B)
+#define   HSW_AUD_MISC_CTRL_A			0x65010 /*Audio Misc Control Convert 1*/
+#define   HSW_AUD_MISC_CTRL_B			0x65110 /*Audio Misc Control Convert 2*/
+#define   HSW_AUD_MISC_CTRL(pipe) _PIPE(pipe, \
+					HSW_AUD_MISC_CTRL_A, \
+					HSW_AUD_MISC_CTRL_B)
+
+#define   HSW_AUD_DIP_ELD_CTRL_ST_A		0x650b4 /*Audio DIP and ELD Control State Transcoder A*/
+#define   HSW_AUD_DIP_ELD_CTRL_ST_B		0x651b4 /*Audio DIP and ELD Control State Transcoder B*/
+#define   HSW_AUD_DIP_ELD_CTRL(pipe) _PIPE(pipe, \
+					HSW_AUD_DIP_ELD_CTRL_ST_A, \
+					HSW_AUD_DIP_ELD_CTRL_ST_B)
+
+#define   HSW_AUD_PIPE_CONV_CFG			0x6507c /*Audio pipe and converter configs*/
+#define   HSW_AUD_PIN_ELD_CP_VLD		0x650c0 /*Audio ELD and CP Ready Status*/
+#define   AUDIO_INACTIVE_C			(1<<11)
+#define   AUDIO_INACTIVE_B			(1<<7)
+#define   AUDIO_INACTIVE_A			(1<<3)
+#define   AUDIO_OUTPUT_ENABLE_AB		(1<<2)
+#define   AUDIO_OUTPUT_ENABLE_BC		(1<<6)
+#define   AUDIO_OUTPUT_ENABLE_CD		(1<<10)
+#define   AUDIO_ELD_VALID_AB			(1<<0)
+#define   AUDIO_ELD_VALID_BC			(1<<4)
+#define   AUDIO_ELD_VALID_CD			(1<<8)
+#define   AUDIO_CP_READY_AB			(1<<1)
+#define   AUDIO_CP_READY_BC			(1<<5)
+#define   AUDIO_CP_READY_CD			(1<<9)
+
+/* Audio Digital Converter*/
+#define   HSW_AUD_DIG_CNVT_1			0x65080 /*Audio Converter 1*/
+#define   HSW_AUD_DIG_CNVT_2			0x65180 /*Audio Converter 1*/
+#define   HSW_AUD_DIG_CNVT_3			0x65280 /*Audio Converter 1*/
+
+#define   HSW_AUD_EDID_DATA			0x65050
+
+#define   TRANS_CONF_A				0xf0008
+#define   AUD_PB_UNSL_DEV_CP			0x65fb0
+#define   AUD_PC_UNSL_DEV_CP			0x65fb4
+#define   AUD_PD_UNSL_DEV_CP			0x65fb8
+
+
 /* HSW Power Wells */
 #define HSW_PWR_WELL_CTL1		0x45400		/* BIOS */
 #define HSW_PWR_WELL_CTL2		0x45404		/* Driver */
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 2/4 drm/i915: write eld info for HDMI audio

In reply to Wang Xingchao

HDMI audio related registers will be configured in write_eld callback.

---
 drivers/gpu/drm/i915/intel_ddi.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +5 -1
index 32604ac..4c12371 100644
@@ -718,8 +718,12 @@ void intel_ddi_mode_set(struct drm_encoder *encoder,
 		/* Proper support for digital audio needs a new logic and a new set
 		 * of registers, so we leave it for future patch bombing.
 		 */
-		DRM_DEBUG_DRIVER("HDMI audio on pipe %c not yet supported on DDI\n",
+		DRM_DEBUG_DRIVER("HDMI audio on pipe %c on DDI\n",
 				 pipe_name(intel_crtc->pipe));
+
+		/* write eld */
+		DRM_DEBUG_DRIVER("HDMI audio: write eld information\n");
+		intel_write_eld(encoder, adjusted_mode);
 	}
 
 	/* Enable PIPE_DDI_FUNC_CTL for the pipe to work in HDMI mode */
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v2 3/4 drm/i915: Haswell HDMI audio enable

In reply to Wang Xingchao

Configure the related HDMI audio register to generate an unsolicited response to the audio controller driver to indicate that the controller sequence should start.

---
 drivers/gpu/drm/i915/intel_display.c |   58 ++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
drivers/gpu/drm/i915/intel_display.c +58 -0
index 17020cd..7ddc446 100644
@@ -1649,6 +1649,7 @@ static void intel_enable_transcoder(struct drm_i915_private *dev_priv,
 	u32 val, pipeconf_val;
 	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
 
+	DRM_DEBUG_DRIVER("Enable transcoder %c\n", pipe_name(pipe));
 	/* PCH only available on ILK+ */
 	BUG_ON(dev_priv->info->gen < 5);
 
@@ -5071,6 +5072,7 @@ static void ironlake_write_eld(struct drm_connector *connector,
 				     struct drm_crtc *crtc)
 {
 	struct drm_i915_private *dev_priv = connector->dev->dev_private;
+	struct drm_device *dev = crtc->dev;
 	uint8_t *eld = connector->eld;
 	uint32_t eldv;
 	uint32_t i;
@@ -5085,6 +5087,11 @@ static void ironlake_write_eld(struct drm_connector *connector,
 		aud_config = IBX_AUD_CONFIG_A;
 		aud_cntl_st = IBX_AUD_CNTL_ST_A;
 		aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
+	} else if (IS_HASWELL(dev)) {
+		hdmiw_hdmiedid = HSW_AUD_EDID_DATA;
+		aud_cntl_st = HSW_AUD_DIP_ELD_CTRL_ST_A;
+		aud_config = HSW_AUD_CONFIG_A;
+		aud_cntrl_st2 = HSW_AUD_PIN_ELD_CP_VLD;
 	} else {
 		hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
 		aud_config = CPT_AUD_CONFIG_A;
@@ -5092,6 +5099,55 @@ static void ironlake_write_eld(struct drm_connector *connector,
 		aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
 	}
 
+	if (IS_HASWELL(dev)) {
+		int tmp;
+		int aud_cfg;
+		int aud_vld;
+		int eld_ctr_st;
+		int audio_misc;
+		int transf_a;
+		int pipe;
+
+		pipe = to_intel_crtc(crtc)->pipe;
+
+		DRM_DEBUG_DRIVER("HDMI: Haswell Audio initialize....\n");
+
+		/* Need first enable transcoder and port */
+		aud_cfg = HSW_AUD_CFG(pipe);
+		eld_ctr_st = HSW_AUD_DIP_ELD_CTRL(pipe);
+		aud_vld = HSW_AUD_PIN_ELD_CP_VLD;
+		audio_misc = HSW_AUD_MISC_CTRL(pipe);
+
+		transf_a = TRANS_CONF_A;
+
+		/* Audio output enable */
+		DRM_DEBUG_DRIVER("HDMI audio: enable codec\n");
+		tmp = I915_READ(aud_vld);
+		tmp |= (AUDIO_OUTPUT_ENABLE_AB | AUDIO_OUTPUT_ENABLE_BC | AUDIO_OUTPUT_ENABLE_CD);
+		I915_WRITE(aud_vld, tmp);
+
+		/* Set ELD valid state */
+		tmp = I915_READ(aud_vld);
+		DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%8x\n", tmp);
+		tmp |= (AUDIO_ELD_VALID_AB | AUDIO_ELD_VALID_BC | AUDIO_ELD_VALID_CD);
+		I915_WRITE(aud_vld, tmp);
+		tmp = I915_READ(aud_vld);
+		DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%8x\n", tmp);
+
+		/* Enable HDMI mode */
+		tmp = I915_READ(aud_cfg);
+		DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%8x\n", tmp);
+		/* clear N_programing_enable and N_value_index */
+		tmp &= ~(0x3<<29);
+		I915_WRITE(aud_cfg, tmp);
+
+		/*TODO:
+		 * 1.enable sample fabrication
+		 * 2.set Upper_N_value(27:20) and Lower_N_value(15:4)
+		 * 3.enable timestamps
+		 * */
+	}
+
 	i = to_intel_crtc(crtc)->pipe;
 	hdmiw_hdmiedid += i * 0x100;
 	aud_cntl_st += i * 0x100;
@@ -5135,6 +5191,8 @@ static void ironlake_write_eld(struct drm_connector *connector,
 	i = I915_READ(aud_cntl_st);
 	i &= ~IBX_ELD_ADDRESS;
 	I915_WRITE(aud_cntl_st, i);
+	i = (i >> 29) & 0x3;		/* DIP_Port_Select, 0x1 = PortB */
+	DRM_DEBUG_DRIVER("port num:%d\n", i);
 
 	len = min_t(uint8_t, eld[2], 21);	/* 84 bytes of hw ELD buffer */
 	DRM_DEBUG_DRIVER("ELD size %d\n", len);
Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH V2 3/4] drm/i915: Haswell HDMI audio enable

Hi

Comments inline.

2012/7/30 Wang Xingchao <[email protected]>:

Quoted 14 lines

Configure the related HDMI audio register to generate an unsolicited response to the audio controller driver to indicate that the controller sequence should start.

---
 drivers/gpu/drm/i915/intel_display.c |   58 ++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 17020cd..7ddc446 100644

drivers/gpu/drm/i915/intel_display.c static void intel_enable_transcoder(struct drm_i915_private *dev_priv, · line 1652

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -1649,6 +1649,7 @@ static void intel_enable_transcoder(struct drm_i915_private *dev_priv,
        u32 val, pipeconf_val;
        struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
 
+       DRM_DEBUG_DRIVER("Enable transcoder %c\n", pipe_name(pipe));

Do we really want this?

Quoted 25 lines
drivers/gpu/drm/i915/intel_display.c +6 -0
        /* PCH only available on ILK+ */
        BUG_ON(dev_priv->info->gen < 5);
 
@@ -5071,6 +5072,7 @@ static void ironlake_write_eld(struct drm_connector *connector,
                                     struct drm_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = connector->dev->dev_private;
+       struct drm_device *dev = crtc->dev;
        uint8_t *eld = connector->eld;
        uint32_t eldv;
        uint32_t i;
@@ -5085,6 +5087,11 @@ static void ironlake_write_eld(struct drm_connector *connector,
                aud_config = IBX_AUD_CONFIG_A;
                aud_cntl_st = IBX_AUD_CNTL_ST_A;
                aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
+       } else if (IS_HASWELL(dev)) {
+               hdmiw_hdmiedid = HSW_AUD_EDID_DATA;
+               aud_cntl_st = HSW_AUD_DIP_ELD_CTRL_ST_A;
+               aud_config = HSW_AUD_CONFIG_A;
+               aud_cntrl_st2 = HSW_AUD_PIN_ELD_CP_VLD;
        } else {
                hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
                aud_config = CPT_AUD_CONFIG_A;
@@ -5092,6 +5099,55 @@ static void ironlake_write_eld(struct drm_connector *connector,
                aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5109

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
        }
 
+       if (IS_HASWELL(dev)) {
+               int tmp;
+               int aud_cfg;
+               int aud_vld;
+               int eld_ctr_st;
+               int audio_misc;
+               int transf_a;
+               int pipe;

Since the initialization is very simple, can't we just define the variables and initialize them at the same time?

Example:
int tmp;
int aud_cfg = HSW_AUD_CFG(pipe);
int aud_vld = HSW_AUD_PIN_ELD_CP_VLD;
int eld_ctr_st = HSW_AUD_DIP_ELD_CTRL(pipe);
int auido_misc = HSW_AUD_MISC_CTRL(pipe);
int transf_a = TRANS_CONF_A
int pipe = to_intel_crtc(crtc)->pipe;

Also, after a quick look, these variables seem unused and maybe should be removed: eld_ctr_st, audio_misc, transf_a.

Also, we have aud_cfg (defined by you) and aud_config (defined earlier on the same function) which seem to have the same purpose. You should probably use the already-defined aud_config, but then you'll have to move your "if (IS_HASWELL())" statement a few lines down...

You should also move the "int pipe" definition to the beginning of the function and use it instead of reusing the "i" variable for everything.

Quoted 22 lines
drivers/gpu/drm/i915/intel_display.c +22 -0
+
+               pipe = to_intel_crtc(crtc)->pipe;
+
+               DRM_DEBUG_DRIVER("HDMI: Haswell Audio initialize....\n");
+
+               /* Need first enable transcoder and port */
+               aud_cfg = HSW_AUD_CFG(pipe);
+               eld_ctr_st = HSW_AUD_DIP_ELD_CTRL(pipe);
+               aud_vld = HSW_AUD_PIN_ELD_CP_VLD;
+               audio_misc = HSW_AUD_MISC_CTRL(pipe);
+
+               transf_a = TRANS_CONF_A;
+
+               /* Audio output enable */
+               DRM_DEBUG_DRIVER("HDMI audio: enable codec\n");
+               tmp = I915_READ(aud_vld);
+               tmp |= (AUDIO_OUTPUT_ENABLE_AB | AUDIO_OUTPUT_ENABLE_BC | AUDIO_OUTPUT_ENABLE_CD);
+               I915_WRITE(aud_vld, tmp);
+
+               /* Set ELD valid state */
+               tmp = I915_READ(aud_vld);
+               DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%8x\n", tmp);

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5141

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+               tmp |= (AUDIO_ELD_VALID_AB | AUDIO_ELD_VALID_BC | AUDIO_ELD_VALID_CD);
+               I915_WRITE(aud_vld, tmp);
+               tmp = I915_READ(aud_vld);
+               DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%8x\n", tmp);
+
+               /* Enable HDMI mode */
+               tmp = I915_READ(aud_cfg);
+               DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%8x\n", tmp);
+               /* clear N_programing_enable and N_value_index */
+               tmp &= ~(0x3<<29);

If you use #define instead of the magic "0x3 << 29" (just like we do in the rest of our code), you will probably be able to remove these comments.

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5153

Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +9 -0
+               I915_WRITE(aud_cfg, tmp);
+
+               /*TODO:
+                * 1.enable sample fabrication
+                * 2.set Upper_N_value(27:20) and Lower_N_value(15:4)
+                * 3.enable timestamps
+                * */
+       }
+
        i = to_intel_crtc(crtc)->pipe;
        hdmiw_hdmiedid += i * 0x100;
        aud_cntl_st += i * 0x100;

I know this is not part of your commit, but can't we just use the PIPE macro instead of this "var += i * 0x100" ?

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5198

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
@@ -5135,6 +5191,8 @@ static void ironlake_write_eld(struct drm_connector *connector,
        i = I915_READ(aud_cntl_st);
        i &= ~IBX_ELD_ADDRESS;
        I915_WRITE(aud_cntl_st, i);
+       i = (i >> 29) & 0x3;            /* DIP_Port_Select, 0x1 = PortB */
+       DRM_DEBUG_DRIVER("port num:%d\n", i);
 
        len = min_t(uint8_t, eld[2], 21);       /* 84 bytes of hw ELD buffer */
        DRM_DEBUG_DRIVER("ELD size %d\n", len);

ironlake_write_eld looks scary...

Thanks,
Paulo

Signature · 1 line
Paulo Zanoni
#5 lore raw

Re: [PATCH V2 3/4] drm/i915: Haswell HDMI audio enable

Quoted 22 lines · Paulo Zanoni

Hi

Comments inline.

2012/7/30 Wang Xingchao <[email protected]>:

Quoted 17 lines

Configure the related HDMI audio register to generate an unsolicited response to the audio controller driver to indicate that the controller sequence should start.

---
 drivers/gpu/drm/i915/intel_display.c |   58 ++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
drivers/gpu/drm/i915/intel_display.c +0 -0
index 17020cd..7ddc446 100644
@@ -1649,6 +1649,7 @@ static void intel_enable_transcoder(struct drm_i915_private *dev_priv,
        u32 val, pipeconf_val;
        struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
 
Quoted 3 lines

drivers/gpu/drm/i915/intel_display.c static void intel_enable_transcoder(struct drm_i915_private *dev_priv, · line 1652

Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +1 -0
+       DRM_DEBUG_DRIVER("Enable transcoder %c\n", pipe_name(pipe));

Do we really want this?

... and in kms code we use DRM_DEBUG_KMS.

Quoted 97 lines
Quoted 25 lines
drivers/gpu/drm/i915/intel_display.c +6 -0
        /* PCH only available on ILK+ */
        BUG_ON(dev_priv->info->gen < 5);
 
@@ -5071,6 +5072,7 @@ static void ironlake_write_eld(struct drm_connector *connector,
                                     struct drm_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = connector->dev->dev_private;
+       struct drm_device *dev = crtc->dev;
        uint8_t *eld = connector->eld;
        uint32_t eldv;
        uint32_t i;
@@ -5085,6 +5087,11 @@ static void ironlake_write_eld(struct drm_connector *connector,
                aud_config = IBX_AUD_CONFIG_A;
                aud_cntl_st = IBX_AUD_CNTL_ST_A;
                aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
+       } else if (IS_HASWELL(dev)) {
+               hdmiw_hdmiedid = HSW_AUD_EDID_DATA;
+               aud_cntl_st = HSW_AUD_DIP_ELD_CTRL_ST_A;
+               aud_config = HSW_AUD_CONFIG_A;
+               aud_cntrl_st2 = HSW_AUD_PIN_ELD_CP_VLD;
        } else {
                hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID_A;
                aud_config = CPT_AUD_CONFIG_A;
@@ -5092,6 +5099,55 @@ static void ironlake_write_eld(struct drm_connector *connector,
                aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5109

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
        }
 
+       if (IS_HASWELL(dev)) {
+               int tmp;
+               int aud_cfg;
+               int aud_vld;
+               int eld_ctr_st;
+               int audio_misc;
+               int transf_a;
+               int pipe;

Since the initialization is very simple, can't we just define the variables and initialize them at the same time?

Example:
int tmp;
int aud_cfg = HSW_AUD_CFG(pipe);
int aud_vld = HSW_AUD_PIN_ELD_CP_VLD;
int eld_ctr_st = HSW_AUD_DIP_ELD_CTRL(pipe);
int auido_misc = HSW_AUD_MISC_CTRL(pipe);
int transf_a = TRANS_CONF_A
int pipe = to_intel_crtc(crtc)->pipe;

Also, after a quick look, these variables seem unused and maybe should be removed: eld_ctr_st, audio_misc, transf_a.

Also, we have aud_cfg (defined by you) and aud_config (defined earlier on the same function) which seem to have the same purpose. You should probably use the already-defined aud_config, but then you'll have to move your "if (IS_HASWELL())" statement a few lines down...

You should also move the "int pipe" definition to the beginning of the function and use it instead of reusing the "i" variable for everything.

Quoted 22 lines
drivers/gpu/drm/i915/intel_display.c +22 -0
+
+               pipe = to_intel_crtc(crtc)->pipe;
+
+               DRM_DEBUG_DRIVER("HDMI: Haswell Audio initialize....\n");
+
+               /* Need first enable transcoder and port */
+               aud_cfg = HSW_AUD_CFG(pipe);
+               eld_ctr_st = HSW_AUD_DIP_ELD_CTRL(pipe);
+               aud_vld = HSW_AUD_PIN_ELD_CP_VLD;
+               audio_misc = HSW_AUD_MISC_CTRL(pipe);
+
+               transf_a = TRANS_CONF_A;
+
+               /* Audio output enable */
+               DRM_DEBUG_DRIVER("HDMI audio: enable codec\n");
+               tmp = I915_READ(aud_vld);
+               tmp |= (AUDIO_OUTPUT_ENABLE_AB | AUDIO_OUTPUT_ENABLE_BC | AUDIO_OUTPUT_ENABLE_CD);
+               I915_WRITE(aud_vld, tmp);
+
+               /* Set ELD valid state */
+               tmp = I915_READ(aud_vld);
+               DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%8x\n", tmp);

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5141

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+               tmp |= (AUDIO_ELD_VALID_AB | AUDIO_ELD_VALID_BC | AUDIO_ELD_VALID_CD);
+               I915_WRITE(aud_vld, tmp);
+               tmp = I915_READ(aud_vld);
+               DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%8x\n", tmp);
+
+               /* Enable HDMI mode */
+               tmp = I915_READ(aud_cfg);
+               DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%8x\n", tmp);
+               /* clear N_programing_enable and N_value_index */
+               tmp &= ~(0x3<<29);

If you use #define instead of the magic "0x3 << 29" (just like we do in the rest of our code), you will probably be able to remove these comments.

Quoted 15 lines

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5153

Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +9 -0
+               I915_WRITE(aud_cfg, tmp);
+
+               /*TODO:
+                * 1.enable sample fabrication
+                * 2.set Upper_N_value(27:20) and Lower_N_value(15:4)
+                * 3.enable timestamps
+                * */
+       }
+
        i = to_intel_crtc(crtc)->pipe;
        hdmiw_hdmiedid += i * 0x100;
        aud_cntl_st += i * 0x100;

I know this is not part of your commit, but can't we just use the PIPE macro instead of this "var += i * 0x100" ?

Yeah, and there are a few other places in the eld code that would welcome some similar love. Renaming the temporary var i to tmp or reg would also look a bit better. But such cleanups would need to happen in a separate patch.

Quoted 11 lines

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5198

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
@@ -5135,6 +5191,8 @@ static void ironlake_write_eld(struct drm_connector *connector,
        i = I915_READ(aud_cntl_st);
        i &= ~IBX_ELD_ADDRESS;
        I915_WRITE(aud_cntl_st, i);
+       i = (i >> 29) & 0x3;            /* DIP_Port_Select, 0x1 = PortB */
+       DRM_DEBUG_DRIVER("port num:%d\n", i);
 
        len = min_t(uint8_t, eld[2], 21);       /* 84 bytes of hw ELD buffer */
        DRM_DEBUG_DRIVER("ELD size %d\n", len);

ironlake_write_eld looks scary...

Imo the hsw code is sufficiently different to varant a haswell_write_eld. -Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#6 lore raw

Re: [PATCH V2 3/4] drm/i915: Haswell HDMI audio enable

Hey Daniel,

I had v3 patches under review and will send them out later.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

dev_priv->pipe_to_crtc_mapping[pipe];

+ DRM_DEBUG_DRIVER("Enable transcoder %c\n",

pipe_name(pipe));

Quoted 2 lines

Do we really want this?

... and in kms code we use DRM_DEBUG_KMS.

I'd removed this debug message in v3.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
        /* PCH only available on I

I know this is not part of your commit, but can't we just use the PIPE macro instead of this "var += i * 0x100" ?

Yeah, and there are a few other places in the eld code that would welcome some similar love. Renaming the temporary var i to tmp or reg would also look a bit better. But such cleanups would need to happen in a separate patch.

They are replaced with macro in v3 too.

Quoted 10 lines
Quoted 2 lines

Review static void ironlake_write_eld(struct

Quoted 2 lines
(quoted diff) +0 -0
@@ -5135,6 +5191,8 @@ static void ironlake_write_eld(struct

drm_connector *connector,

Quoted 4 lines

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector,

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
        i = I915_READ(aud_cntl_st);
        i &= ~IBX_ELD_ADDRESS;
        I915_WRITE(aud_cntl_st, i);
+       i = (i >> 29) & 0x3;            /* DIP_Port_Select, 0x1 = PortB

*/

Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
+       DRM_DEBUG_DRIVER("port num:%d\n", i);
 
Quoted 7 lines
Quoted 1 line

Review static void ironlake_write_eld(struct · line 5197

Quoted 1 line
(quoted diff) +0 -0
        len = min_t(uint8_t, eld[2], 21);       /* 84 bytes of hw ELD

buffer */

Quoted 3 lines

drivers/gpu/drm/i915/intel_display.c static void ironlake_write_eld(struct drm_connector *connector, · line 5198

Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +0 -0
        DRM_DEBUG_DRIVER("ELD size %d\n", len);

ironlake_write_eld looks scary...

Imo the hsw code is sufficiently different to varant a haswell_write_eld.

Hmm, I think I need write a separate patch to place the haswell_write_eld.

Thanks
--xingchao

#7 lore raw

PATCH v2 4/4 ALSA HDA: Force HDMI pins enabled

In reply to Wang Xingchao

There's one issue for HDMI pins, even the related pin will be enabled when the stream is active but the GPU registers show the PIN is not in active state, so we force all pins in active state and donot close it when the stream is closed.

---
 sound/pci/hda/patch_hdmi.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
sound/pci/hda/patch_hdmi.c +8 -7
index ad319d4..64cc9e0 100644
@@ -421,13 +421,17 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
 
 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
 {
+	/* Force all output Pins enabled */
+	snd_printk(KERN_DEBUG "HDMI: enable all output\n");
+	snd_hda_codec_write(codec, pin_nid, 0,
+			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40);
+
 	/* Unmute */
-	if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
+	if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) {
+		snd_printk(KERN_DEBUG "HDMI: unmute pin %d\n", pin_nid);
 		snd_hda_codec_write(codec, pin_nid, 0,
 				AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
-	/* Disable pin out until stream is active*/
-	snd_hda_codec_write(codec, pin_nid, 0,
-			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+	}
 }
 
 static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t cvt_nid)
@@ -1190,9 +1194,6 @@ static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
 
 		pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
 					    AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
-		snd_hda_codec_write(codec, per_pin->pin_nid, 0,
-				    AC_VERB_SET_PIN_WIDGET_CONTROL,
-				    pinctl & ~PIN_OUT);
 		snd_hda_spdif_ctls_unassign(codec, pin_idx);
 	}
 
Signature · 1 line
1.7.9.5
#8 lore raw

Re: [PATCH V2 4/4] ALSA HDA: Force HDMI pins enabled

At Tue, 31 Jul 2012 10:47:05 +0800,

Quoted 7 lines · Wang Xingchao

There's one issue for HDMI pins, even the related pin will be enabled when the stream is active but the GPU registers show the PIN is not in active state, so we force all pins in active state and donot close it when the stream is closed.

Oh no, this is a bad workaround.

Please be more exact at which timing the pin must be set. Setting all the time is just a wrong approach.

Also, at the next time, please Cc to alsa-devel and other developers. I don't want that such a patch is merged secretly through drm tree :)

Quoted 9 lines
---
 sound/pci/hda/patch_hdmi.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
sound/pci/hda/patch_hdmi.c +0 -0
index ad319d4..64cc9e0 100644

sound/pci/hda/patch_hdmi.c static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, · line 427

Quoted 7 lines
sound/pci/hda/patch_hdmi.c +4 -0
@@ -421,13 +421,17 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
 
 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
 {
+	/* Force all output Pins enabled */
+	snd_printk(KERN_DEBUG "HDMI: enable all output\n");
+	snd_hda_codec_write(codec, pin_nid, 0,
+			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40);

Don't put debug prints unconditionally.

sound/pci/hda/patch_hdmi.c static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, · line 431

Quoted 5 lines
sound/pci/hda/patch_hdmi.c +3 -1
+
 	/* Unmute */
-	if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
+	if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) {
+		snd_printk(KERN_DEBUG "HDMI: unmute pin %d\n", pin_nid);

Ditto.

thanks,

Takashi

Quoted 27 lines
sound/pci/hda/patch_hdmi.c +1 -6
 		snd_hda_codec_write(codec, pin_nid, 0,
 				AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
-	/* Disable pin out until stream is active*/
-	snd_hda_codec_write(codec, pin_nid, 0,
-			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+	}
 }
 
 static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t cvt_nid)
@@ -1190,9 +1194,6 @@ static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
 
 		pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
 					    AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
-		snd_hda_codec_write(codec, per_pin->pin_nid, 0,
-				    AC_VERB_SET_PIN_WIDGET_CONTROL,
-				    pinctl & ~PIN_OUT);
 		snd_hda_spdif_ctls_unassign(codec, pin_idx);
 	}
 
Signature · 6 lines
1.7.9.5

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

Re: [PATCH V2 4/4] ALSA HDA: Force HDMI pins enabled

Hi Takashi,

Quoted 15 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, July 31, 2012 7:18 PM
To: Wang, Xingchao
Cc: [email protected]; Zanoni, Paulo R
Subject: Re: [Intel-gfx] [PATCH V2 4/4] ALSA HDA: Force HDMI pins enabled

At Tue, 31 Jul 2012 10:47:05 +0800,

Quoted 6 lines · Wang Xingchao

There's one issue for HDMI pins, even the related pin will be enabled when the stream is active but the GPU registers show the PIN is not in active state, so we force all pins in active state and donot close it when the stream is closed.

Quoted 6 lines
Quoted 1 line

Oh no, this is a bad workaround.

Please be more exact at which timing the pin must be set. Setting all the time is just a wrong approach.

Sorry for that, I am still trying to find out the root cause and the patch was intended for test only. Basically the HDA verb made the change but GPU side does not reflect the correct state, did you ever meet same phenomenon? There's one similar bug:
HBR sound passthrough (DTS-HS-MA, Dolby-Turuhd) not working on Intel Sandy Bridge
https://bugs.freedesktop.org/show_bug.cgi?id=49055

Quoted 3 lines

Also, at the next time, please Cc to alsa-devel and other developers. I don't want that such a patch is merged secretly through drm tree :)

Hmm, sure. i will cc to alsa-devel when send out the final version for review.

Thanks your clarification. I will take more care when send out alsa patches. :)

--xingchao

Quoted 63 lines
Quoted 10 lines
---
 sound/pci/hda/patch_hdmi.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
sound/pci/hda/patch_hdmi.c +0 -0
index ad319d4..64cc9e0 100644

sound/pci/hda/patch_hdmi.c static void hdmi_write_dip_byte(struct hda_codec · line 428

Quoted 8 lines
sound/pci/hda/patch_hdmi.c +4 -0
@@ -421,13 +421,17 @@ static void hdmi_write_dip_byte(struct hda_codec
 *codec, hda_nid_t pin_nid,
 
 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
 {
+	/* Force all output Pins enabled */
+	snd_printk(KERN_DEBUG "HDMI: enable all output\n");
+	snd_hda_codec_write(codec, pin_nid, 0,
+			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40);

Don't put debug prints unconditionally.

sound/pci/hda/patch_hdmi.c static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, · line 431

Quoted 5 lines
sound/pci/hda/patch_hdmi.c +3 -1
+
 	/* Unmute */
-	if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
+	if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) {
+		snd_printk(KERN_DEBUG "HDMI: unmute pin %d\n", pin_nid);

Ditto.

thanks,

Takashi

Quoted 28 lines
sound/pci/hda/patch_hdmi.c +1 -3
 		snd_hda_codec_write(codec, pin_nid, 0,
 				AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
-	/* Disable pin out until stream is active*/
-	snd_hda_codec_write(codec, pin_nid, 0,
-			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+	}
 }
 

static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t
cvt_nid) @@ -1190,9 +1194,6 @@ static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,

sound/pci/hda/patch_hdmi.c +0 -4
 		pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
 					    AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
-		snd_hda_codec_write(codec, per_pin->pin_nid, 0,
-				    AC_VERB_SET_PIN_WIDGET_CONTROL,
-				    pinctl & ~PIN_OUT);
 		snd_hda_spdif_ctls_unassign(codec, pin_idx);
 	}
 
--

1.7.9.5

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

#10 lore raw

Re: [PATCH V2 4/4] ALSA HDA: Force HDMI pins enabled

At Wed, 1 Aug 2012 00:27:02 +0000,

Quoted 18 lines · Xingchao

Hi Takashi,

Quoted 15 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, July 31, 2012 7:18 PM
To: Wang, Xingchao
Cc: [email protected]; Zanoni, Paulo R
Subject: Re: [Intel-gfx] [PATCH V2 4/4] ALSA HDA: Force HDMI pins enabled

At Tue, 31 Jul 2012 10:47:05 +0800,

Quoted 6 lines · Wang Xingchao

There's one issue for HDMI pins, even the related pin will be enabled when the stream is active but the GPU registers show the PIN is not in active state, so we force all pins in active state and donot close it when the stream is closed.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Oh no, this is a bad workaround.

Please be more exact at which timing the pin must be set. Setting all the time is just a wrong approach.

Sorry for that, I am still trying to find out the root cause and the patch was intended for test only.

I see.

Quoted 4 lines

Basically the HDA verb made the change but GPU side does not reflect the correct state, did you ever meet same phenomenon? There's one similar bug:
HBR sound passthrough (DTS-HS-MA, Dolby-Turuhd) not working on Intel Sandy Bridge
https://bugs.freedesktop.org/show_bug.cgi?id=49055

Well, I myself can't check it due to lack of a test device. But if any, this should be applied to only Intel codecs, as Nvidia (and likely AMD) apparently works as is now.

And another more interesting thing is to know _when_ you need to set the pin at all. There must be some timing that GPU checks the codec pin state. If it's just once before sending ELD, then yes, the pin has to be set persistently.

thanks,

Takashi

Quoted 73 lines
Quoted 2 lines

Also, at the next time, please Cc to alsa-devel and other developers. I don't want that such a patch is merged secretly through drm tree :)

Hmm, sure. i will cc to alsa-devel when send out the final version for review.

Thanks your clarification. I will take more care when send out alsa patches. :)

--xingchao

Quoted 63 lines
Quoted 10 lines
---
 sound/pci/hda/patch_hdmi.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
sound/pci/hda/patch_hdmi.c +0 -0
index ad319d4..64cc9e0 100644

sound/pci/hda/patch_hdmi.c static void hdmi_write_dip_byte(struct hda_codec · line 428

Quoted 8 lines
sound/pci/hda/patch_hdmi.c +4 -0
@@ -421,13 +421,17 @@ static void hdmi_write_dip_byte(struct hda_codec
 *codec, hda_nid_t pin_nid,
 
 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
 {
+	/* Force all output Pins enabled */
+	snd_printk(KERN_DEBUG "HDMI: enable all output\n");
+	snd_hda_codec_write(codec, pin_nid, 0,
+			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40);

Don't put debug prints unconditionally.

sound/pci/hda/patch_hdmi.c static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, · line 431

Quoted 5 lines
sound/pci/hda/patch_hdmi.c +3 -1
+
 	/* Unmute */
-	if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
+	if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) {
+		snd_printk(KERN_DEBUG "HDMI: unmute pin %d\n", pin_nid);

Ditto.

thanks,

Takashi

Quoted 28 lines
sound/pci/hda/patch_hdmi.c +1 -3
 		snd_hda_codec_write(codec, pin_nid, 0,
 				AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
-	/* Disable pin out until stream is active*/
-	snd_hda_codec_write(codec, pin_nid, 0,
-			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+	}
 }
 

static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t
cvt_nid) @@ -1190,9 +1194,6 @@ static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,

sound/pci/hda/patch_hdmi.c +0 -4
 		pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
 					    AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
-		snd_hda_codec_write(codec, per_pin->pin_nid, 0,
-				    AC_VERB_SET_PIN_WIDGET_CONTROL,
-				    pinctl & ~PIN_OUT);
 		snd_hda_spdif_ctls_unassign(codec, pin_idx);
 	}
 
--

1.7.9.5

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