From 5edcc0842ae58ba4e460efefabe074bf3e78c4a1 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Thu, 6 May 2010 23:28:34 +0800 Subject: [PATCH] drm/i915: check whether Audio is supported on HDMI sink Signed-off-by: Zhao Yakui --- drivers/gpu/drm/drm_edid.c | 32 ++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 1 + 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index bfd0e4a..607061e 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1322,6 +1322,38 @@ end: } EXPORT_SYMBOL(drm_detect_hdmi_monitor); +bool drm_audio_is_supported(struct edid *edid) +{ +#define HDMI_BASIC_AUDIO (1<<6) + char *edid_ext = NULL; + int i, hdmi_id, edid_ext_num; + bool audio_is_supported = false; + + if (!drm_detect_hdmi_monitor(edid)) + goto end; + + /* Chose real EDID extension number */ + edid_ext_num = edid->extensions > MAX_EDID_EXT_NUM ? + MAX_EDID_EXT_NUM : edid->extensions; + + /* Find CEA extension */ + for (i = 0; i < edid_ext_num; i++) { + edid_ext = (char *)edid + EDID_LENGTH * (i + 1); + /* This block is CEA extension */ + if (edid_ext[0] == 0x02) + break; + } + + if (i == edid_ext_num) + goto end; + + if (edid_ext[3] & HDMI_BASIC_AUDIO) + audio_is_supported = true; + +end: + return audio_is_supported; +} +EXPORT_SYMBOL(drm_audio_is_supported); /** * drm_add_edid_modes - add modes from EDID data, if available * @connector: connector we're probing diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index fdf43ab..0e3face 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -791,6 +791,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_audio_is_supported(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.5.4.5