Haswell HDMI/DP audio enable
Subsystems (2)
v6 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.
I tested this patch on Sharkbay machine and i could hear clear sound from HDMI port.
V2 patches fixed one warning and some type errors.
V3 patches changes:
- change some registers definitions
- use macro for IBX/CPT/HSW to get registers
- remove some unused variable intended to use in TODO list.
v4 patches changes:
- remove alsa related hack patch
v5 patches changes:
- change comments stype
- split IBX/CTP registers patch into separate one
- remove unused register definition
v6 patches changes:
- fix some type errors
- add new haswell_write_eld
Here're some notes useful for you to test the patches on Sharkbay machine:
I> please make sure your branch include below three commits in Takashi's sound tree, otherwise there's no proper Haswell ID and HDMI ID.
For the upstream tree, please refer to sound git tree
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
You can just pull for-linus branch.
The all commits above are found in 3.6-rc1.
e926f2c850c472f813f9bab486c68a3fe0b03ae41c76684d2752b3a24bb7da183cc18e5d126dbcc9bdbe34dece4942f4d8df9865dba7785bb813366a
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 did not really make codec change,and we regard the GPU register as the right one. (see III explanation) 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.
III> HDA Codec dependency. When you found there's no sound from HDMI, please use intel_audio_dump to check Port enable/mute status in II and also check related Pipe/Transcoder/DDI port status. Sometimes the pipe and transcoder was disabled in dpms and will not work anymore, that results in the HDMI port no sound. HDA codec's three converters are somehow hardwired to audio Pipes and if you choose the pipe, that means the regarding Codec converter should be enabled too, and only one digital Pin's HDA verbs could work, that depends on whether your Pin select the converter as input. Here's one example about the Pipe/Transcoder/DDI port(Pipe B, DDI Port C):
DDI_BUF_CTL_A 0x00000080 DDI Buffer Controler A DDI_BUF_CTL_B 0x00000000 DDI Buffer Controler B DDI_BUF_CTL_C 0x80000000 DDI Buffer Controler C DDI_BUF_CTL_D 0x00000000 DDI Buffer Controler D DDI_BUF_CTL_E 0x80000002 DDI Buffer Controler E PIPE_CONF_A 0xc0000000 PIPE Configuration A PIPE_CONF_B 0xc0000000 PIPE Configuration B PIPE_CONF_C 0x00000000 PIPE Configuration C PIPE_CONF_EDP 0x00000000 PIPE Configuration EDP PIPE_DDI_FUNC_CTL_A 0xc4034002 PIPE DDI Function Control A PIPE_DDI_FUNC_CTL_B 0xa0035000 PIPE DDI Function Control B PIPE_DDI_FUNC_CTL_C 0x00030000 PIPE DDI Function Control C PIPE_DDI_FUNC_CTL_EDP 0x00030000 PIPE DDI Function Control EDP
Wang Xingchao (4):
drm/i915: HSW audio registers definition
drm/i915: write eld info for HDMI audio
drm/i915: Haswell HDMI audio initialization
drm/i915: ironlake_write_eld code cleanup
drivers/gpu/drm/i915/i915_reg.h | 72 +++++++++++++++++++++ drivers/gpu/drm/i915/intel_ddi.c | 6 +- drivers/gpu/drm/i915/intel_display.c | 116 ++++++++++++++++++++++++++++++---- 3 files changed, 179 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v6 1/4 drm/i915: HSW audio registers definition
Add hsw audio registers definition
--- drivers/gpu/drm/i915/i915_reg.h | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +47 -0
@@ -4269,6 +4269,53 @@#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) + +/* Audio Digital Converter */ +#define HSW_AUD_DIG_CNVT_1 0x65080/* Audio Converter 1 */ +#define HSW_AUD_DIG_CNVT_2 0x65180/* Audio Converter 1 */ +#define AUD_DIG_CNVT (pipe) _PIPE(pipe, \ + HSW_AUD_DIG_CNVT_1, \ + HSW_AUD_DIG_CNVT_2) + +#define HSW_AUD_EDID_DATA_A 0x65050 +#define HSW_AUD_EDID_DATA_B 0x65150 +#define HSW_AUD_EDID_DATA (pipe) _PIPE(pipe, \ + HSW_AUD_EDID_DATA_A, \ + HSW_AUD_EDID_DATA_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_A (1<<2) +#define AUDIO_OUTPUT_ENABLE_B (1<<6) +#define AUDIO_OUTPUT_ENABLE_C (1<<10) +#define AUDIO_ELD_VALID_A (1<<0) +#define AUDIO_ELD_VALID_B (1<<4) +#define AUDIO_ELD_VALID_C (1<<8) +#define AUDIO_CP_READY_A (1<<1) +#define AUDIO_CP_READY_B (1<<5) +#define AUDIO_CP_READY_C (1<<9) +/* HSW Power Wells */ #define HSW_PWR_WELL_CTL1 0x45400/* BIOS */ #define HSW_PWR_WELL_CTL2 0x45404/* Driver */
Signature · 1 line
1.7.9.5
PATCH v6 2/4 drm/i915: write eld info for HDMI audio
In reply to Wang XingchaoHDMI 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
@@ -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
PATCH v6 3/4 drm/i915: Haswell HDMI audio initialization
In reply to Wang XingchaoAdded new haswell_write_eld() to initialize Haswell HDMI audio registers to generate an unsolicited response to the audio controller driver to indicate that the controller sequence should start.
--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 94 +++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -4294,6 +4294,7 @@#define AUD_DIG_CNVT (pipe) _PIPE(pipe, \ HSW_AUD_DIG_CNVT_1, \ HSW_AUD_DIG_CNVT_2) +#define DIP_PORT_SEL_MASK 0x3#define HSW_AUD_EDID_DATA_A 0x65050#define HSW_AUD_EDID_DATA_B 0x65150
drivers/gpu/drm/i915/intel_display.c +93 -1
106 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v6 3/4] drm/i915: Haswell HDMI audio initialization
Hi,
couple of comments inlined:
Quoted 42 lines · Wang Xingchao
Added new
haswell_write_eld()to initialize Haswell HDMI audio registers to generate an unsolicited response to the audio controller driver to indicate that the controller sequence should start.Signed-off-by Wang Xingchao <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 94 +++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -4294,6 +4294,7 @@#define AUD_DIG_CNVT (pipe) _PIPE(pipe, \ HSW_AUD_DIG_CNVT_1, \ HSW_AUD_DIG_CNVT_2) +#define DIP_PORT_SEL_MASK 0x3#define HSW_AUD_EDID_DATA_A 0x65050#define HSW_AUD_EDID_DATA_B 0x65150drivers/gpu/drm/i915/intel_display.c +12
-0@@ -5067,6 +5067,98 @@ static void g4x_write_eld(struct drm_connector *connector,I915_WRITE (G4X_AUD_CNTL_ST , i); } +static void haswell_write_eld (struct drm_connector *connector, +struct drm_crtc *crtc) +{ +struct drm_i915_private *dev_priv = connector->dev->dev_private; +uint8_t *eld = connector->eld; +uint32_t eldv; +uint32_t i; +int len; +int pipe =to_intel_crtc (crtc)->pipe; +int tmp; + +int hdmiw_hdmiedid =HSW_AUD_EDID_DATA (pipe);
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector, · line 5091
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10
-0+int aud_cntl_st =HSW_AUD_DIP_ELD_CTRL (pipe); +int aud_config =HSW_AUD_CFG (pipe); +int aud_cntrl_st2 =HSW_AUD_PIN_ELD_CP_VLD ; + + +DRM_DEBUG_DRIVER ("HDMI: Haswell Audio initialize....\n" ); + +/* Audio output enable */ +DRM_DEBUG_DRIVER ("HDMI audio: enable codec\n" ); + tmp =I915_READ (aud_cntrl_st2);
uint32_t for tmp would be better, in case you happen to right shift tmp with bit31 set.
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector, · line 5093
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+ tmp |= (AUDIO_OUTPUT_ENABLE_A |AUDIO_OUTPUT_ENABLE_B |AUDIO_OUTPUT_ENABLE_C ); +I915_WRITE (aud_cntrl_st2, tmp);
I don't know much about HDMI, but according to the spec you'd need to wait for one vblank here. At least a comment why we don't do it would be nice.
Quoted 19 lines
drivers/gpu/drm/i915/intel_display.c +19
-0+ +/* Set ELD valid state */ + tmp =I915_READ (aud_cntrl_st2); +DRM_DEBUG_DRIVER ("HDMI audio: pin eld vld status=0x%8x\n" , tmp); + tmp |= (AUDIO_ELD_VALID_A |AUDIO_ELD_VALID_B |AUDIO_ELD_VALID_C ); +I915_WRITE (aud_cntrl_st2, tmp); + tmp =I915_READ (aud_cntrl_st2); +DRM_DEBUG_DRIVER ("HDMI audio: eld vld status=0x%8x\n" , tmp); + +/* Enable HDMI mode */ + tmp =I915_READ (aud_config); +DRM_DEBUG_DRIVER ("HDMI audio: audio conf: 0x%8x\n" , tmp); +/* clear N_programing_enable and N_value_index */ + tmp &= ~(AUD_CONFIG_N_VALUE_INDEX |AUD_CONFIG_N_PROG_ENABLE ); +I915_WRITE (aud_config, tmp); + +DRM_DEBUG_DRIVER ("ELD on pipe %c\n" ,pipe_name (pipe)); + + i =I915_READ (aud_cntl_st);
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector, · line 5122
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10
-0+ i = (i >>29 ) &DIP_PORT_SEL_MASK ;/* DIP_Port_Select, 0x1 = PortB */ +if (!i) { +DRM_DEBUG_DRIVER ("Audio directed to unknown port\n" ); +/* operate blindly on all ports */ + eldv =AUDIO_ELD_VALID_A ; + eldv |=AUDIO_ELD_VALID_B ; + eldv |=AUDIO_ELD_VALID_C ; + }else { +DRM_DEBUG_DRIVER ("ELD on port %c\n" ,'A' + i); + eldv =AUDIO_ELD_VALID_A << ((i -1 ) *4 );
This is confusing. Reading the spec I undersand i=1 means port B, but in that case we'll set eldv to AUDIO_ELD_VALID_A. Is it intentional?
Other than the above, for the patchset:
Re: [PATCH v6 3/4] drm/i915: Haswell HDMI audio initialization
HI Deak,
Quoted 62 lines
-----Original Message-----
From: Imre Deak [mailto:[email protected]]
Sent: Friday, August 10, 2012 9:15 PM
To: Wang, Xingchao
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-gfx] [PATCH v6 3/4] drm/i915: Haswell HDMI audio initializationHi,
couple of comments inlined:
Quoted 8 lines · Wang Xingchao
Added new
haswell_write_eld()to initialize Haswell HDMI audio registers to generate an unsolicited response to the audio controller driver to indicate that the controller sequence should start.Signed-off-by Wang Xingchao <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 94+++++++++++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector
Quoted 20 lines
2 files changed, 94 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 55aa10e..08f8b65 100644drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -4294,6 +4294,7 @@#define AUD_DIG_CNVT (pipe) _PIPE(pipe, \ HSW_AUD_DIG_CNVT_1, \ HSW_AUD_DIG_CNVT_2) +#define DIP_PORT_SEL_MASK 0x3#define HSW_AUD_EDID_DATA_A 0x65050#define HSW_AUD_EDID_DATA_B 0x65150drivers/gpu/drm/i915/intel_display.c +0
-0@@ -5067,6 +5067,98 @@ static void g4x_write_eld(struct drm_connector*connector,
Quoted 18 lines
drivers/gpu/drm/i915/intel_display.c +16
-0I915_WRITE (G4X_AUD_CNTL_ST , i); } +static void haswell_write_eld (struct drm_connector *connector, +struct drm_crtc *crtc) { +struct drm_i915_private *dev_priv = connector->dev->dev_private; +uint8_t *eld = connector->eld; +uint32_t eldv; +uint32_t i; +int len; +int pipe =to_intel_crtc (crtc)->pipe; +int tmp; + +int hdmiw_hdmiedid =HSW_AUD_EDID_DATA (pipe); +int aud_cntl_st =HSW_AUD_DIP_ELD_CTRL (pipe); +int aud_config =HSW_AUD_CFG (pipe); +int aud_cntrl_st2 =HSW_AUD_PIN_ELD_CP_VLD ; + +
Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector, · line 5091
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5
-0+DRM_DEBUG_DRIVER ("HDMI: Haswell Audio initialize....\n" ); + +/* Audio output enable */ +DRM_DEBUG_DRIVER ("HDMI audio: enable codec\n" ); + tmp =I915_READ (aud_cntrl_st2);
uint32_tfor tmp would be better, in case you happen to right shift tmp with bit31 set.
Agree, will change it to u32 type in next version.
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector · line 5090
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +1
-0+ tmp |= (AUDIO_OUTPUT_ENABLE_A | AUDIO_OUTPUT_ENABLE_B|
AUDIO_OUTPUT_ENABLE_C);drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector · line 5091
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +1
-0+I915_WRITE (aud_cntrl_st2, tmp);I don't know much about HDMI, but according to the spec you'd need to wait for one vblank here. At least a comment why we don't do it would be nice.
Yeah, according to audio programming sequence, wait 1 vertical blank here.
I left it empty here because I did not found the proper api and did not meet issue during test. Is intel_wait_for_vblank() the proper one I should call ?
Quoted 37 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ +/* Set ELD valid state */ + tmp =I915_READ (aud_cntrl_st2); + DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%8x\n",tmp);
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector · line 5096
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +1
-0+ tmp |= (AUDIO_ELD_VALID_A | AUDIO_ELD_VALID_B |
AUDIO_ELD_VALID_C);drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3
-0+I915_WRITE (aud_cntrl_st2, tmp); + tmp =I915_READ (aud_cntrl_st2); + DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%8x\n",tmp);
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +6
-0+ +/* Enable HDMI mode */ + tmp =I915_READ (aud_config); +DRM_DEBUG_DRIVER ("HDMI audio: audio conf: 0x%8x\n" , tmp); +/* clear N_programing_enable and N_value_index */ + tmp &= ~(AUD_CONFIG_N_VALUE_INDEX |
AUD_CONFIG_N_PROG_ENABLE);drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +6
-0+I915_WRITE (aud_config, tmp); + +DRM_DEBUG_DRIVER ("ELD on pipe %c\n" ,pipe_name (pipe)); + + i =I915_READ (aud_cntl_st); + i = (i >>29 ) &DIP_PORT_SEL_MASK ;/*
DIP_Port_Select,0x1= PortB */drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector · line 5113
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+if (!i) { + DRM_DEBUG_DRIVER("Audio directed to unknownport\n");
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector, · line 5122
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +7
-0+/* operate blindly on all ports */ + eldv =AUDIO_ELD_VALID_A ; + eldv |=AUDIO_ELD_VALID_B ; + eldv |=AUDIO_ELD_VALID_C ; + }else { +DRM_DEBUG_DRIVER ("ELD on port %c\n" ,'A' + i); + eldv =AUDIO_ELD_VALID_A << ((i -1 ) *4 );
Quoted 2 lines
This is confusing. Reading the spec I undersand i=1 means port B, but in that case we'll set eldv to
AUDIO_ELD_VALID_A. Is it intentional?
Bit 0 is for ELD Valid A in Project DevHSW and for ELD Valid B for HSW-X0, and HSW-X0 is old one which doesnot need to support it in new code.
Quoted 4 lines
Other than the above, for the patchset:
Reviewed-by [email protected]
Thanks your review. :)
--xingchao
Re: [PATCH v6 3/4] drm/i915: Haswell HDMI audio initialization
Quoted 78 lines · Xingchao
HI Deak,
Quoted 62 lines
-----Original Message-----
From: Imre Deak [mailto:[email protected]]
Sent: Friday, August 10, 2012 9:15 PM
To: Wang, Xingchao
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-gfx] [PATCH v6 3/4] drm/i915: Haswell HDMI audio initializationHi,
couple of comments inlined:
Quoted 8 lines · Wang Xingchao
Added new
haswell_write_eld()to initialize Haswell HDMI audio registers to generate an unsolicited response to the audio controller driver to indicate that the controller sequence should start.Signed-off-by Wang Xingchao <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 94+++++++++++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector
Quoted 20 lines
2 files changed, 94 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 55aa10e..08f8b65 100644drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -4294,6 +4294,7 @@#define AUD_DIG_CNVT (pipe) _PIPE(pipe, \ HSW_AUD_DIG_CNVT_1, \ HSW_AUD_DIG_CNVT_2) +#define DIP_PORT_SEL_MASK 0x3#define HSW_AUD_EDID_DATA_A 0x65050#define HSW_AUD_EDID_DATA_B 0x65150drivers/gpu/drm/i915/intel_display.c +0
-0@@ -5067,6 +5067,98 @@ static void g4x_write_eld(struct drm_connector*connector,
Quoted 18 lines
drivers/gpu/drm/i915/intel_display.c +16
-0I915_WRITE (G4X_AUD_CNTL_ST , i); } +static void haswell_write_eld (struct drm_connector *connector, +struct drm_crtc *crtc) { +struct drm_i915_private *dev_priv = connector->dev->dev_private; +uint8_t *eld = connector->eld; +uint32_t eldv; +uint32_t i; +int len; +int pipe =to_intel_crtc (crtc)->pipe; +int tmp; + +int hdmiw_hdmiedid =HSW_AUD_EDID_DATA (pipe); +int aud_cntl_st =HSW_AUD_DIP_ELD_CTRL (pipe); +int aud_config =HSW_AUD_CFG (pipe); +int aud_cntrl_st2 =HSW_AUD_PIN_ELD_CP_VLD ; + +Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector, · line 5091
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +5
-0+DRM_DEBUG_DRIVER ("HDMI: Haswell Audio initialize....\n" ); + +/* Audio output enable */ +DRM_DEBUG_DRIVER ("HDMI audio: enable codec\n" ); + tmp =I915_READ (aud_cntrl_st2);
uint32_tfor tmp would be better, in case you happen to right shift tmp with bit31 set.Agree, will change it to u32 type in next version.
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector · line 5090
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +1
-0+ tmp |= (AUDIO_OUTPUT_ENABLE_A | AUDIO_OUTPUT_ENABLE_B|
AUDIO_OUTPUT_ENABLE_C);
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector · line 5091
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +1
-0+I915_WRITE (aud_cntrl_st2, tmp);I don't know much about HDMI, but according to the spec you'd need to wait for one vblank here. At least a comment why we don't do it would be nice.
Yeah, according to audio programming sequence, wait 1 vertical blank here.
I left it empty here because I did not found the proper api and did not meet issue during test. Isintel_wait_for_vblank()the proper one I should call ?
Yes, although it will work only in non-atomic context. Also the relevant pipe needs to be enabled
otherwise you'll get a timeout.
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ +/* Set ELD valid state */ + tmp =I915_READ (aud_cntrl_st2); + DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%8x\n",tmp);
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector · line 5096
Quoted 1 line
drivers/gpu/drm/i915/intel_display.c +1
-0+ tmp |= (AUDIO_ELD_VALID_A | AUDIO_ELD_VALID_B |
AUDIO_ELD_VALID_C);drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3
-0+I915_WRITE (aud_cntrl_st2, tmp); + tmp =I915_READ (aud_cntrl_st2); + DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%8x\n",tmp);
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +6
-0+ +/* Enable HDMI mode */ + tmp =I915_READ (aud_config); +DRM_DEBUG_DRIVER ("HDMI audio: audio conf: 0x%8x\n" , tmp); +/* clear N_programing_enable and N_value_index */ + tmp &= ~(AUD_CONFIG_N_VALUE_INDEX |
AUD_CONFIG_N_PROG_ENABLE);drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +6
-0+I915_WRITE (aud_config, tmp); + +DRM_DEBUG_DRIVER ("ELD on pipe %c\n" ,pipe_name (pipe)); + + i =I915_READ (aud_cntl_st); + i = (i >>29 ) &DIP_PORT_SEL_MASK ;/*
DIP_Port_Select,0x1= PortB */drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector · line 5113
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+if (!i) { + DRM_DEBUG_DRIVER("Audio directed to unknownport\n");
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +7
-0+/* operate blindly on all ports */ + eldv =AUDIO_ELD_VALID_A ; + eldv |=AUDIO_ELD_VALID_B ; + eldv |=AUDIO_ELD_VALID_C ; + }else { +DRM_DEBUG_DRIVER ("ELD on port %c\n" ,'A' + i); + eldv =AUDIO_ELD_VALID_A << ((i -1 ) *4 );
Quoted 5 lines
Quoted 2 lines
This is confusing. Reading the spec I undersand i=1 means port B, but in that case we'll set eldv to
AUDIO_ELD_VALID_A. Is it intentional?Bit 0 is for ELD Valid A in Project DevHSW and for ELD Valid B for HSW-X0, and HSW-X0 is old one which doesnot need to support it in new code.
Yes, I noticed this bit field renaming through HW versions, but I still don't see how the above code works.
So according to the devHSW register definition the above code will select one of the following values forAUD_PIN_ELD_CP_VLD valid bits based on AUD_DIP_ELD_CTRL_ST[DIP port select]:
0 [Reserved]: AUDIO_ELD_VALID_A | AUDIO_ELD_VALID_B | AUDIO_ELD_VALID_C
1 [Port B]: AUDIO_ELD_VALID_A 2 [Port C]: AUDIO_ELD_VALID_B 3 [Port D]: AUDIO_ELD_VALID_C
Could you explain why the code uses AUDIO_ELD_VALID_A for 'Port B' for instance.
--Imre
Re: [PATCH v6 3/4] drm/i915: Haswell HDMI audio initialization
Quoted 104 lines
-----Original Message-----
From: Imre Deak [mailto:[email protected]]
Sent: Tuesday, August 14, 2012 8:36 PM
To: Wang, Xingchao
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-gfx] [PATCH v6 3/4] drm/i915: Haswell HDMI audio initializationQuoted 29 lines · Xingchao
HI Deak,
Quoted 27 lines
-----Original Message-----
From: Imre Deak [mailto:[email protected]]
Sent: Friday, August 10, 2012 9:15 PM
To: Wang, Xingchao
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-gfx] [PATCH v6 3/4] drm/i915: Haswell HDMI audio initializationHi,
couple of comments inlined:
Quoted 8 lines · Wang Xingchao
Added new
haswell_write_eld()to initialize Haswell HDMI audio registers to generate an unsolicited response to the audio controller driver to indicate that the controller sequence should start.Signed-off-by Wang Xingchao <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 94+++++++++++++++++++++++++++++++++-
Quoted 2 lines
2 files changed, 94 insertions(+), 1 deletion(-)Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h line 4295
Quoted 7 lines
(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 55aa10e..08f8b65 100644drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -4294,6 +4294,7 @@#define AUD_DIG_CNVT (pipe) _PIPE(pipe, \
HSW_AUD_DIG_CNVT_1, \Quoted 1 line
Quoted 1 line
Quoted 1 line
HSW_AUD_DIG_CNVT_2)Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/i915/i915_reg.h +1
-0+#define DIP_PORT_SEL_MASK 0x3#define HSW_AUD_EDID_DATA_A 0x65050#define HSW_AUD_EDID_DATA_B 0x65150drivers/gpu/drm/i915/intel_display.c +0
-0@@ -5067,6 +5067,98 @@ static void g4x_write_eld(struct
drm_connector*connector,
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c
Quoted 5 lines
I915_WRITE(G4X_AUD_CNTL_ST, i); }drivers/gpu/drm/i915/intel_display.c +3
-0+static void haswell_write_eld (struct drm_connector *connector, +struct drm_crtc *crtc) { + struct drm_i915_private *dev_priv =
connector->dev->dev_private;Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/i915/intel_display.c +14
-0+uint8_t *eld = connector->eld; +uint32_t eldv; +uint32_t i; +int len; +int pipe =to_intel_crtc (crtc)->pipe; +int tmp; + +int hdmiw_hdmiedid =HSW_AUD_EDID_DATA (pipe); +int aud_cntl_st =HSW_AUD_DIP_ELD_CTRL (pipe); +int aud_config =HSW_AUD_CFG (pipe); +int aud_cntrl_st2 =HSW_AUD_PIN_ELD_CP_VLD ; + + +DRM_DEBUG_DRIVER ("HDMI: Haswell Audio initialize....\n" );Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector, · line 5091
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ +/* Audio output enable */ +DRM_DEBUG_DRIVER ("HDMI audio: enable codec\n" ); + tmp =I915_READ (aud_cntrl_st2);
uint32_tfor tmp would be better, in case you happen to right shift tmp with
bit31 set.Quoted 4 lines
Agree, will change it to u32 type in next version.
Quoted 2 lines
Quoted 2 lines
+ tmp |= (
AUDIO_OUTPUT_ENABLE_A|
AUDIO_OUTPUT_ENABLE_BQuoted 5 lines
Quoted 5 lines
|
AUDIO_OUTPUT_ENABLE_C);Quoted 1 line
+
I915_WRITE(aud_cntrl_st2, tmp);I don't know much about HDMI, but according to the spec you'd need to wait for one vblank here. At least a comment why we don't do it would be
nice.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Yeah, according to audio programming sequence, wait 1 vertical blank here. I left it empty here because I did not found the proper api and did not meet
issue during test.
Quoted 1 line
Is
intel_wait_for_vblank()the proper one I should call ?Yes, although it will work only in non-atomic context. Also the relevant pipe needs to be enabled otherwise you'll get a timeout.
Okay, I made the change. Haswell_write_eld() is called after ironlake_crtc_enable() which pipe was enabled there, so I think it's safe.
Quoted 52 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ +/* Set ELD valid state */ + tmp =I915_READ (aud_cntrl_st2); + DRM_DEBUG_DRIVER("HDMI audio: pin eld vldstatus=0x%8x\n",
Quoted 11 lines
Quoted 11 lines
tmp);
Quoted 1 line
+ tmp |= (
AUDIO_ELD_VALID_A|AUDIO_ELD_VALID_B|
AUDIO_ELD_VALID_C);drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3
-0+I915_WRITE (aud_cntrl_st2, tmp); + tmp =I915_READ (aud_cntrl_st2); + DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%8x\n",tmp);
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +4
-0+ +/* Enable HDMI mode */ + tmp =I915_READ (aud_config); + DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%8x\n",tmp);
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/i915/intel_display.c
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+/* clear N_programing_enable and N_value_index */ + tmp &= ~(AUD_CONFIG_N_VALUE_INDEX |
AUD_CONFIG_N_PROG_ENABLE);drivers/gpu/drm/i915/intel_display.c static void g4x_write_eld(struct drm_connector *connector,
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +6
-0+I915_WRITE (aud_config, tmp); + +DRM_DEBUG_DRIVER ("ELD on pipe %c\n" ,pipe_name (pipe)); + + i =I915_READ (aud_cntl_st); + i = (i >>29 ) &DIP_PORT_SEL_MASK ;/*
DIP_Port_Select,0x1= PortB */drivers/gpu/drm/i915/intel_display.c
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+if (!i) { + DRM_DEBUG_DRIVER("Audio directed to unknownport\n");
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +7
-0+/* operate blindly on all ports */ + eldv =AUDIO_ELD_VALID_A ; + eldv |=AUDIO_ELD_VALID_B ; + eldv |=AUDIO_ELD_VALID_C ; + }else { +DRM_DEBUG_DRIVER ("ELD on port %c\n" ,'A' + i); + eldv =AUDIO_ELD_VALID_A << ((i -1 ) *4 );Quoted 5 lines
Quoted 2 lines
This is confusing. Reading the spec I undersand i=1 means port B, but in that case we'll set eldv to
AUDIO_ELD_VALID_A. Is it intentional?Bit 0 is for ELD Valid A in Project DevHSW and for ELD Valid B for HSW-X0, and HSW-X0 is old one which doesnot need to support it in new
code.
Yes, I noticed this bit field renaming through HW versions, but I still don't see how the above code works.
So according to the devHSW register definition the above code will select one of the following values forAUD_PIN_ELD_CP_VLDvalid bits based on AUD_DIP_ELD_CTRL_ST[DIP port select]:
Quoted 8 lines
0 [Reserved]:
AUDIO_ELD_VALID_A|AUDIO_ELD_VALID_B|AUDIO_ELD_VALID_C1 [Port B]: AUDIO_ELD_VALID_A 2 [Port C]: AUDIO_ELD_VALID_B 3 [Port D]: AUDIO_ELD_VALID_CCould you explain why the code uses
AUDIO_ELD_VALID_Afor 'Port B' for instance.
For DevHSW-X0(old), ELD and CP ready bit are port based, which match your above description.
((TranscoderA was portB, TranscoderB was portC and TranscoderC was portD)
But for DevHSW-A0+: "Display software sets these bits as part of enabling the respective audio-enabled digital device/transcoder. To support DP MST, these bits are transcoder based and harfware will use it appropriately to send the status to the audio driver using device widgets." So we use AUDIO_ELD_VALID_A just means it's for Transcoder A, not 'Port B'.
In the code, I just operate blindly on all ports because there's a bug to read out current selected DIP port from AUD_DIP_ELD_CTRL_ST(bits 29:30), it's the same issue as Ivybridge, these bits are always 00b(reserved). As a workround I could enable pipe related transcoder and set the right ELD/CP accordingly.
Thanks your review, Imre.
--xingchao
PATCH v6 4/4 drm/i915: ironlake_write_eld code cleanup
In reply to Wang XingchaoUse _PIPE macro to get correct register definition for IBX/CPT, discard old variable "i" way.
--- drivers/gpu/drm/i915/i915_reg.h | 24 ++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_display.c | 22 +++++++++------------- 2 files changed, 33 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +24 -0
@@ -4239,7 +4239,15 @@#define G4X_HDMIW_HDMIEDID 0x6210C#define IBX_HDMIW_HDMIEDID_A 0xE2050 +#define IBX_HDMIW_HDMIEDID_B 0xE2150 +#define IBX_HDMIW_HDMIEDID (pipe) _PIPE(pipe, \ + IBX_HDMIW_HDMIEDID_A, \ + IBX_HDMIW_HDMIEDID_B)#define IBX_AUD_CNTL_ST_A 0xE20B4 +#define IBX_AUD_CNTL_ST_B 0xE21B4 +#define IBX_AUD_CNTL_ST (pipe) _PIPE(pipe, \ + IBX_AUD_CNTL_ST_A, \ + IBX_AUD_CNTL_ST_B)#define IBX_ELD_BUFFER_SIZE (0x1f << 10)#define IBX_ELD_ADDRESS (0x1f << 5)#define IBX_ELD_ACK (1 << 4)
@@ -4248,7 +4256,15 @@#define IBX_CP_READYB (1 << 1)#define CPT_HDMIW_HDMIEDID_A 0xE5050 +#define CPT_HDMIW_HDMIEDID_B 0xE5150 +#define CPT_HDMIW_HDMIEDID (pipe) _PIPE(pipe, \ + CPT_HDMIW_HDMIEDID_A, \ + CPT_HDMIW_HDMIEDID_B)#define CPT_AUD_CNTL_ST_A 0xE50B4 +#define CPT_AUD_CNTL_ST_B 0xE51B4 +#define CPT_AUD_CNTL_ST (pipe) _PIPE(pipe, \ + CPT_AUD_CNTL_ST_A, \ + CPT_AUD_CNTL_ST_B)#define CPT_AUD_CNTRL_ST2 0xE50C0/* These are the 4 32-bit write offset registers for each stream
@@ -4258,7 +4274,15 @@#define GEN7_SO_WRITE_OFFSET (n) (0x5280 + (n) * 4)#define IBX_AUD_CONFIG_A 0xe2000 +#define IBX_AUD_CONFIG_B 0xe2100 +#define IBX_AUD_CFG (pipe) _PIPE(pipe, \ + IBX_AUD_CONFIG_A, \ + IBX_AUD_CONFIG_B)#define CPT_AUD_CONFIG_A 0xe5000 +#define CPT_AUD_CONFIG_B 0xe5100 +#define CPT_AUD_CFG (pipe) _PIPE(pipe, \ + CPT_AUD_CONFIG_A, \ + CPT_AUD_CONFIG_B)#define AUD_CONFIG_N_VALUE_INDEX (1 << 29)#define AUD_CONFIG_N_PROG_ENABLE (1 << 28)#define AUD_CONFIG_UPPER_N_SHIFT 20
drivers/gpu/drm/i915/intel_display.c +9 -13
@@ -5171,28 +5171,24 @@ static void ironlake_write_eld(struct drm_connector *connector,int aud_config;int aud_cntl_st;int aud_cntrl_st2; +int pipe =to_intel_crtc (crtc)->pipe;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 ; + hdmiw_hdmiedid =IBX_HDMIW_HDMIEDID (pipe); + aud_config =IBX_AUD_CFG (pipe); + aud_cntl_st =IBX_AUD_CNTL_ST (pipe); 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 ; + hdmiw_hdmiedid =CPT_HDMIW_HDMIEDID (pipe); + aud_config =CPT_AUD_CFG (pipe); + aud_cntl_st =CPT_AUD_CNTL_ST (pipe); aud_cntrl_st2 =CPT_AUD_CNTRL_ST2 ; } - 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)); +DRM_DEBUG_DRIVER ("ELD on pipe %c\n" ,pipe_name (pipe)); i =I915_READ (aud_cntl_st); - i = (i >>29 ) &0x3 ;/* DIP_Port_Select, 0x1 = PortB */ + i = (i >>29 ) &DIP_PORT_SEL_MASK ;/* DIP_Port_Select, 0x1 = PortB */ if (!i) {DRM_DEBUG_DRIVER ("Audio directed to unknown port\n" );/* operate blindly on all ports */
Signature · 1 line
1.7.9.5
Re: [PATCH v6 4/4] drm/i915: ironlake_write_eld code cleanup
Quoted 4 lines · Wang Xingchao
Use
_PIPEmacro to get correct register definition for IBX/CPT, discard old variable "i" way.Signed-off-by Wang Xingchao <[email protected]>
Ok, I've slurped in patches 1,2&4 for -next (with a bit of frobbing since one of the #defines used in patch 4 is introduced in patch 3). I'll pick up patch 3 as soon as the revised version is posted&reviewed.
Thanks for the patches&review.
-Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Re: [PATCH v6 4/4] drm/i915: ironlake_write_eld code cleanup
Quoted 10 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, August 14, 2012 7:49 PM
To: Wang, Xingchao
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 4/4] drm/i915:ironlake_write_eldcode cleanupOn Thu, Aug 09, 2012 at 04:52:18PM +0800, Wang Xingchao wrote:
Quoted 9 lines
Quoted 4 lines
Use
_PIPEmacro to get correct register definition for IBX/CPT, discard old variable "i" way.Signed-off-by Wang Xingchao <[email protected]>Ok, I've slurped in patches 1,2&4 for -next (with a bit of frobbing since one of the #defines used in patch 4 is introduced in patch 3). I'll pick up patch 3 as soon as the revised version is posted&reviewed.
Thanks, Daniel. For patch 3 at version 7 , I had send it out separately.
Thanks
--xingchao