updated patches for KMS audio
Subsystems (3)
cover updated patches for KMS audio
I found my check for audio capability within CEA extension might has some conflict with Adam's patch to add more detailed mode from CEA ext block. But I haven't found Adam's patch in next tree, so I just kept my current change.
This fixed incorrect probe for DP monitor's audio. Fengguang helped to test this set. We got correct DP sound on Eizo EV2333W, and HDMI audio also worked with no regression found.
Patch is against Chris's drm-intel-next branch.
thanks.
Zhenyu Wang (4):
drm/edid: add helper function to detect monitor audio capability drm/i915: Enable DisplayPort audio
drm/i915: Enable HDMI audio for monitor with audio support drm/i915: add new param to force audio on or off for HDMI/DP port
drivers/gpu/drm/drm_edid.c | 92 +++++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/i915_drv.c | 3 + drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_dp.c | 64 +++++++++++++++---------- drivers/gpu/drm/i915/intel_hdmi.c | 13 ++++-- include/drm/drm_crtc.h | 1 + 6 files changed, 130 insertions(+), 44 deletions(-)
PATCH 1/4 drm/edid: add helper function to detect monitor audio capability
To help to determine if digital display port needs to enable audio output or not. This one adds a helper to get monitor's audio capability via EDID CEA extension block.
--- drivers/gpu/drm/drm_edid.c | 92 +++++++++++++++++++++++++++++++++++++------- include/drm/drm_crtc.h | 1 + 2 files changed, 79 insertions(+), 14 deletions(-)
drivers/gpu/drm/drm_edid.c +78 -14
@@ -1268,34 +1268,51 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid, }#define HDMI_IDENTIFIER 0x000C03 +#define AUDIO_BLOCK 0x01#define VENDOR_BLOCK 0x03 +#define EDID_BASIC_AUDIO (1 << 6) +/** -* drm_detect_hdmi_monitor - detect whether monitor is hdmi. -* @edid: monitor EDID information -* -* Parse the CEA extension according to CEA-861-B. -* Return true if HDMI, false if not or unknown. +* Search EDID for CEA extension block. */ -bool drm_detect_hdmi_monitor (struct edid *edid) +static u8 *drm_find_cea_extension (struct edid *edid) { -char *edid_ext =NULL ; -int i, hdmi_id; -int start_offset, end_offset; -bool is_hdmi = false; +u8 *edid_ext =NULL ; +int i;/* No EDID or EDID extensions */ if (edid ==NULL || edid->extensions ==0 ) - goto end; +return NULL ;/* Find CEA extension */ for (i =0 ; i < edid->extensions; i++) { - edid_ext = (char *)edid +EDID_LENGTH * (i +1 ); -/* This block is CEA extension */ -if (edid_ext[0 ] ==0x02 ) + edid_ext = (u8 *)edid +EDID_LENGTH * (i +1 ); +if (edid_ext[0 ] ==CEA_EXT )break ; }if (i == edid->extensions) +return NULL ; + +return edid_ext; +} + +/** +* drm_detect_hdmi_monitor - detect whether monitor is hdmi. +* @edid: monitor EDID information +* +* Parse the CEA extension according to CEA-861-B. +* Return true if HDMI, false if not or unknown. +*/ +bool drm_detect_hdmi_monitor (struct edid *edid) +{ +u8 *edid_ext; +int i, hdmi_id; +int start_offset, end_offset; +bool is_hdmi = false; + + edid_ext =drm_find_cea_extension (edid); +if (!edid_ext) goto end;/* Data block offset in CEA extension block */
@@ -1326,6 +1343,53 @@ end:EXPORT_SYMBOL (drm_detect_hdmi_monitor);/** +* drm_detect_monitor_audio - check monitor audio capability +* +* Monitor should have CEA extension block. +* If monitor has 'basic audio', but no CEA audio blocks, it's 'basic +* audio' only. If there is any audio extension block and supported +* audio format, assume at least 'basic audio' support, even if 'basic +* audio' is not defined in EDID. +* +*/ +bool drm_detect_monitor_audio (struct edid *edid) +{ +u8 *edid_ext; +int i, j; +bool has_audio = false; +int start_offset, end_offset; + + edid_ext =drm_find_cea_extension (edid); +if (!edid_ext) + goto end; + + has_audio = ((edid_ext[3 ] &EDID_BASIC_AUDIO ) !=0 ); + +if (has_audio) { +DRM_DEBUG_KMS ("Monitor has basic audio support\n" ); + goto end; + } + +/* Data block offset in CEA extension block */ + start_offset =4 ; + end_offset = edid_ext[2 ]; + +for (i = start_offset; i < end_offset; + i += ((edid_ext[i] &0x1f ) +1 )) { +if ((edid_ext[i] >>5 ) ==AUDIO_BLOCK ) { + has_audio = true; +for (j =1 ; j < (edid_ext[i] &0x1f ); j +=3 ) +DRM_DEBUG_KMS ("CEA audio format %d\n" , + (edid_ext[i + j] >>3 ) &0xf ); + goto end; + } + } +end: +return has_audio; +} +EXPORT_SYMBOL (drm_detect_monitor_audio); + +/** * drm_add_edid_modes - add modes from EDID data, if available * @connector: connector we're probing * @edid: edid data
include/drm/drm_crtc.h +1 -0
@@ -754,6 +754,7 @@ extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,extern int drm_mode_gamma_set_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv);extern bool drm_detect_hdmi_monitor (struct edid *edid); +extern bool drm_detect_monitor_audio (struct edid *edid);extern int drm_mode_page_flip_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
Signature · 1 line
1.7.1
Re: [Intel-gfx] [PATCH 1/4] drm/edid: add helper function to detect monitor audio capability
[Lets see if I have a working vpn connection today...]
Quoted 6 lines · Zhenyu Wang
To help to determine if digital display port needs to enable audio output or not. This one adds a helper to get monitor's audio capability via EDID CEA extension block.
Tested-by Wu Fengguang <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>
This should be cc'ed for Adam Jackson's attention as well.
Quoted 18 lines
--- drivers/gpu/drm/drm_edid.c | 92 +++++++++++++++++++++++++++++++++++++------- include/drm/drm_crtc.h | 1 + 2 files changed, 79 insertions(+), 14 deletions(-)drivers/gpu/drm/drm_edid.c +3
-0@@ -1268,34 +1268,51 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid, }#define HDMI_IDENTIFIER 0x000C03 +#define AUDIO_BLOCK 0x01#define VENDOR_BLOCK 0x03 +#define EDID_BASIC_AUDIO (1 << 6) +/**
drivers/gpu/drm/drm_edid.c add_detailed_modes(struct drm_connector *connector, struct edid *edid, · line 1285
Quoted 10 lines
drivers/gpu/drm/drm_edid.c +10
-0+* drm_detect_monitor_audio - check monitor audio capability +* +* Monitor should have CEA extension block. +* If monitor has 'basic audio', but no CEA audio blocks, it's 'basic +* audio' only. If there is any audio extension block and supported +* audio format, assume at least 'basic audio' support, even if 'basic +* audio' is not defined in EDID. +* +*/ +bool drm_detect_monitor_audio (struct edid *edid)
drm_edid_has_monitor_audio()? That is a little more self-descriptive. (I also think drm_detect_hdmi_monitor is poorly named.)
drivers/gpu/drm/drm_edid.c end: · line 1366
Quoted 11 lines
drivers/gpu/drm/drm_edid.c +11
-0+{ +u8 *edid_ext; +int i, j; +bool has_audio = false; +int start_offset, end_offset; + + edid_ext =drm_find_cea_extension (edid); +if (!edid_ext) + goto end; + + has_audio = ((edid_ext[3 ] &EDID_BASIC_AUDIO ) !=0 );
Too many brackets do not lead to code clarity. ;-)
drivers/gpu/drm/drm_edid.c add_detailed_modes(struct drm_connector *connector, struct edid *edid, · line 1298
Quoted 2 lines
drivers/gpu/drm/drm_edid.c +2
-0+ +if (has_audio) {
The last time Adam had a chance to comment on this EDID check, he suggested that we cannot rely on has_audio being a reliable indicator of the sink's properties. If the EDID has no audio support, then return early, otherwise perform the secondary check that extension block contains audio data.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [Intel-gfx] [PATCH 1/4] drm/edid: add helper function to detect monitor audio capability
Quoted 2 lines · Chris Wilson
This should be cc'ed for Adam Jackson's attention as well.
yep, I think I cc-ed ajax in git-send-mail command line...I'll amend the commit.
Quoted 4 lines
Quoted 1 line
+bool
drm_detect_monitor_audio(struct edid *edid)
drm_edid_has_monitor_audio()? That is a little more self-descriptive. (I also thinkdrm_detect_hdmi_monitoris poorly named.)
yeah, that looks better. thanks.
Quoted 5 lines
The last time Adam had a chance to comment on this EDID check, he suggested that we cannot rely on
has_audiobeing a reliable indicator of the sink's properties. If the EDID has no audio support, then return early, otherwise perform the secondary check that extension block contains audio data.
That's also the problem we stuck for quite some time, and until recently we got reply on this issue. Adam is right, 'basic audio' bit might not be reliable, so we try to search audio block too, if there's any existence, we will accept 'basic audio' support as well.
Thanks for the review!
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH 1/4] drm/edid: add helper function to detect monitor audio capability
Quoted 19 lines · Zhenyu Wang
Quoted 2 lines · Chris Wilson
This should be cc'ed for Adam Jackson's attention as well.
yep, I think I cc-ed ajax in git-send-mail command line...I'll amend the commit.
Quoted 4 lines
Quoted 1 line
+bool
drm_detect_monitor_audio(struct edid *edid)
drm_edid_has_monitor_audio()? That is a little more self-descriptive. (I also thinkdrm_detect_hdmi_monitoris poorly named.)yeah, that looks better. thanks.
Quoted 5 lines
The last time Adam had a chance to comment on this EDID check, he suggested that we cannot rely on
has_audiobeing a reliable indicator of the sink's properties. If the EDID has no audio support, then return early, otherwise perform the secondary check that extension block contains audio data.
Quoted 4 lines
That's also the problem we stuck for quite some time, and until recently we got reply on this issue. Adam is right, 'basic audio' bit might not be reliable, so we try to search audio block too, if there's any existence, we will accept 'basic audio' support as well.
Also, would you be able to export drm_find_cea_extension(), I have pending nouveau patches that will require this symbol (to build a HDA ELD from the EDID data for HDMI/DP audio).
With that, you can add my Reviewed-by :)
Thanks,
Ben.
Quoted 7 lines
Thanks for the review!
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/4 drm/i915: Enable DisplayPort audio
In reply to Zhenyu WangThis will turn on DP audio output by checking monitor's audio capability.
--- drivers/gpu/drm/i915/intel_dp.c | 61 +++++++++++++++++++++++---------------- 1 files changed, 36 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +36 -25
@@ -1444,39 +1444,50 @@ intel_dp_detect(struct drm_connector *connector)struct drm_i915_private *dev_priv = dev->dev_private;uint32_t temp, bit;enum drm_connector_status status; +struct edid *edid =NULL ; intel_dp->has_audio = false; -if (HAS_PCH_SPLIT (dev)) -return ironlake_dp_detect (connector); +if (HAS_PCH_SPLIT (dev)) { + status =ironlake_dp_detect (connector); + }else { +switch (intel_dp->output_reg) { +case DP_B : + bit =DPB_HOTPLUG_INT_STATUS ; +break ; +case DP_C : + bit =DPC_HOTPLUG_INT_STATUS ; +break ; +case DP_D : + bit =DPD_HOTPLUG_INT_STATUS ; +break ; +default : +return connector_status_unknown; + } -switch (intel_dp->output_reg) { -case DP_B : - bit =DPB_HOTPLUG_INT_STATUS ; -break ; -case DP_C : - bit =DPC_HOTPLUG_INT_STATUS ; -break ; -case DP_D : - bit =DPD_HOTPLUG_INT_STATUS ; -break ; -default : -return connector_status_unknown; - } + temp =I915_READ (PORT_HOTPLUG_STAT ); - temp =I915_READ (PORT_HOTPLUG_STAT ); +if ((temp & bit) ==0 ) +return connector_status_disconnected; -if ((temp & bit) ==0 ) -return connector_status_disconnected; + status = connector_status_disconnected; +if (intel_dp_aux_native_read (intel_dp,0x000 , intel_dp->dpcd, +sizeof (intel_dp->dpcd)) ==sizeof (intel_dp->dpcd)) + { +if (intel_dp->dpcd[0 ] !=0 ) + status = connector_status_connected; + } + } - status = connector_status_disconnected; -if (intel_dp_aux_native_read (intel_dp, -0x000 , intel_dp->dpcd, -sizeof (intel_dp->dpcd)) ==sizeof (intel_dp->dpcd)) - { -if (intel_dp->dpcd[0 ] !=0 ) - status = connector_status_connected; +if (status == connector_status_connected) { + edid =drm_get_edid (connector, intel_dp->base.ddc_bus); +if (edid) { + intel_dp->has_audio =drm_detect_monitor_audio (edid); + connector->display_info.raw_edid =NULL ; +kfree (edid); + } } +return status; }
Signature · 1 line
1.7.1
Re: [PATCH 2/4] drm/i915: Enable DisplayPort audio
Quoted 29 lines · Zhenyu Wang
This will turn on DP audio output by checking monitor's audio capability.
Tested-by Wu Fengguang <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>--- drivers/gpu/drm/i915/intel_dp.c | 61 +++++++++++++++++++++++---------------- 1 files changed, 36 insertions(+), 25 deletions(-)drivers/gpu/drm/i915/intel_dp.c +7
-2@@ -1444,39 +1444,50 @@ intel_dp_detect(struct drm_connector *connector)struct drm_i915_private *dev_priv = dev->dev_private;uint32_t temp, bit;enum drm_connector_status status; +struct edid *edid =NULL ; intel_dp->has_audio = false; -if (HAS_PCH_SPLIT (dev)) -return ironlake_dp_detect (connector); +if (HAS_PCH_SPLIT (dev)) { + status =ironlake_dp_detect (connector); + }else { +switch (intel_dp->output_reg) { +case DP_B : + bit =DPB_HOTPLUG_INT_STATUS ;
drivers/gpu/drm/i915/intel_dp.c intel_dp_detect(struct drm_connector *connector) · line 1466
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +10
-0+break ; +case DP_C : + bit =DPC_HOTPLUG_INT_STATUS ; +break ; +case DP_D : + bit =DPD_HOTPLUG_INT_STATUS ; +break ; +default : +return connector_status_unknown; + }
Move the switch and register check into a separate function, so the main detect body becomes:
if (HAS_PCH_SPLIT(dev))
status = ironlake_dp_detect(connector);
else
status = g4x_dp_detect(connector);
if (status != connector_status_connected)
return status;Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH 2/4] drm/i915: Enable DisplayPort audio
Quoted 9 lines · Chris Wilson
Move the switch and register check into a separate function, so the main detect body becomes:
if (HAS_PCH_SPLIT(dev))status = ironlake_dp_detect(connector); else status = g4x_dp_detect(connector); if (status != connector_status_connected) return status;
ok, will do that.
thanks.
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: Enable HDMI audio for monitor with audio support
In reply to Zhenyu WangRely on monitor's audio capability to turn on audio output for HDMI.
--- drivers/gpu/drm/i915/intel_hdmi.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_hdmi.c +8 -4
@@ -41,6 +41,7 @@ struct intel_hdmi {struct intel_encoder base;u32 sdvox_reg;bool has_hdmi_sink; +bool has_audio; };static struct intel_hdmi *enc_to_intel_hdmi (struct drm_encoder *encoder)
@@ -71,11 +72,12 @@ static void intel_hdmi_mode_set(struct drm_encoder *encoder,if (adjusted_mode->flags &DRM_MODE_FLAG_PHSYNC ) sdvox |=SDVO_HSYNC_ACTIVE_HIGH ; -if (intel_hdmi->has_hdmi_sink) { +/* Required on CPT */ +if (intel_hdmi->has_hdmi_sink &&HAS_PCH_CPT (dev)) + sdvox |=HDMI_MODE_SELECT ; + +if (intel_hdmi->has_audio) sdvox |=SDVO_AUDIO_ENABLE ; -if (HAS_PCH_CPT (dev)) - sdvox |=HDMI_MODE_SELECT ; - }if (intel_crtc->pipe ==1 ) {if (HAS_PCH_CPT (dev))
@@ -152,12 +154,14 @@ intel_hdmi_detect(struct drm_connector *connector)enum drm_connector_status status = connector_status_disconnected; intel_hdmi->has_hdmi_sink = false; + intel_hdmi->has_audio = false; edid =drm_get_edid (connector, intel_hdmi->base.ddc_bus);if (edid) {if (edid->input &DRM_EDID_INPUT_DIGITAL ) { status = connector_status_connected; 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 ;kfree (edid);
Signature · 1 line
1.7.1
PATCH 4/4 drm/i915: add new param to force audio on or off for HDMI/DP port
In reply to Zhenyu WangTwo reasons to add this param, one is for some AV device requiring HDMI input for audio, but some device might not have sane EDID info to enable audio on HDMI port. Another is for testing purpose.
--- drivers/gpu/drm/i915/i915_drv.c | 3 +++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_dp.c | 3 ++- drivers/gpu/drm/i915/intel_hdmi.c | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +3 -0
@@ -48,6 +48,9 @@ module_param_named(powersave, i915_powersave, int, 0400);unsigned int i915_lvds_downclock =0 ;module_param_named (lvds_downclock, i915_lvds_downclock, int,0400 ); +unsigned int i915_force_audio =-1 ; +module_param_named (force_audio, i915_force_audio, int,0400 ); +static struct drm_driver driver;extern int intel_agp_enabled;
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -844,6 +844,7 @@ extern int i915_max_ioctl;extern unsigned int i915_fbpercrtc;extern unsigned int i915_powersave;extern unsigned int i915_lvds_downclock; +extern unsigned int i915_force_audio;extern int i915_suspend (struct drm_device *dev,pm_message_t state);extern int i915_resume (struct drm_device *dev);
drivers/gpu/drm/i915/intel_dp.c +2 -1
@@ -736,7 +736,8 @@ intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, intel_dp->DP |=DP_PORT_WIDTH_4 ;break ; } -if (intel_dp->has_audio) +if (i915_force_audio ==1 || + (i915_force_audio !=0 && intel_dp->has_audio)) intel_dp->DP |=DP_AUDIO_OUTPUT_ENABLE ;memset (intel_dp->link_configuration,0 ,DP_LINK_CONFIGURATION_SIZE );
drivers/gpu/drm/i915/intel_hdmi.c +2 -1
@@ -76,7 +76,8 @@ static void intel_hdmi_mode_set(struct drm_encoder *encoder,if (intel_hdmi->has_hdmi_sink &&HAS_PCH_CPT (dev)) sdvox |=HDMI_MODE_SELECT ; -if (intel_hdmi->has_audio) +if (i915_force_audio ==1 || + (i915_force_audio !=0 && intel_hdmi->has_audio)) sdvox |=SDVO_AUDIO_ENABLE ;if (intel_crtc->pipe ==1 ) {
Signature · 1 line
1.7.1
Re: [PATCH 4/4] drm/i915: add new param to force audio on or off for HDMI/DP port
Quoted 3 lines · Zhenyu Wang
Two reasons to add this param, one is for some AV device requiring HDMI input for audio, but some device might not have sane EDID info to enable audio on HDMI port. Another is for testing purpose.
I was thinking along the lines of a connector property for force_audio. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH 4/4] drm/i915: add new param to force audio on or off for HDMI/DP port
Quoted 6 lines · Chris Wilson
Quoted 3 lines · Zhenyu Wang
Two reasons to add this param, one is for some AV device requiring HDMI input for audio, but some device might not have sane EDID info to enable audio on HDMI port. Another is for testing purpose.
I was thinking along the lines of a connector property for
force_audio.
oh, right, that's much better. sorry, I forgot about it completely. ;)
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/4] drm/i915: add new param to force audio on or off for HDMI/DP port
Quoted 9 lines · Zhenyu Wang
Quoted 6 lines · Chris Wilson
Quoted 3 lines · Zhenyu Wang
Two reasons to add this param, one is for some AV device requiring HDMI input for audio, but some device might not have sane EDID info to enable audio on HDMI port. Another is for testing purpose.
I was thinking along the lines of a connector property for
force_audio.oh, right, that's much better. sorry, I forgot about it completely. ;)
No worries, I've written up a couple of patches to add the connector properties on top of your series. So just a couple of minor tweaks and getting Adam's seal of approval for the core changes and I'll apply the series to next. Thanks!
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 10 lines · Zhenyu Wang
I found my check for audio capability within CEA extension might has some conflict with Adam's patch to add more detailed mode from CEA ext block. But I haven't found Adam's patch in next tree, so I just kept my current change.
This fixed incorrect probe for DP monitor's audio. Fengguang helped to test this set. We got correct DP sound on Eizo EV2333W, and HDMI audio also worked with no regression found.
Patch is against Chris's drm-intel-next branch.
Ignore my previous r-b.
- ajax
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Chris Wilson
AppliedQuoted 8 lines · Zhenyu Wang
I found my check for audio capability within CEA extension might has some conflict with Adam's patch to add more detailed mode from CEA ext block. But I haven't found Adam's patch in next tree, so I just kept my current change.
This fixed incorrect probe for DP monitor's audio. Fengguang helped to test this set. We got correct DP sound on Eizo EV2333W, and HDMI audio also worked with no regression found.
Applied. Thanks for the reminder, Zhenyu.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre