Parse the EDID looking for a CEA-extension block that details whether the connected monitor has audio support over HDMI.
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk> Cc: Dave Airlie <airl...@redhat.com> --- drivers/gpu/drm/drm_edid.c | 27 +++++++++++++++++++++++++++ include/drm/drm_crtc.h | 1 + 2 files changed, 28 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 96e9631..922b325 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1326,6 +1326,33 @@ end: EXPORT_SYMBOL(drm_detect_hdmi_monitor); /** + * drm_edid_supports_audio - detect whether monitor supports audio. + * @edid: monitor EDID information + * + * Parse the CEA extension according to CEA-861-B. + * Return true if a monitor is connected that supports basic audio, + * false if not or unknown. + */ +bool drm_edid_supports_audio(struct edid *edid) +{ + int i; + + /* No EDID or EDID extensions */ + if (edid == NULL || edid->extensions == 0) + return false; + + /* Find CEA extension */ + for (i = 0; i < edid->extensions; i++) { + const char *edid_ext = (char *)edid + EDID_LENGTH * (i + 1); + if (edid_ext[0] == 0x02) + return edid_ext[3] & (1 << 6); + } + + return false; +} +EXPORT_SYMBOL(drm_edid_supports_audio); + +/** * drm_add_edid_modes - add modes from EDID data, if available * @connector: connector we're probing * @edid: edid data diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index c9f3cc5..c817796 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -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_edid_supports_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, -- 1.7.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx