diff options
author | Jani Nikula | 2022-05-09 15:03:19 +0300 |
---|---|---|
committer | Jani Nikula | 2022-05-13 18:54:56 +0300 |
commit | 0c057877cbdf261efa7874474f48c715cd6401ba (patch) | |
tree | a5be2e4b05e54a2171094737411f43ad8b8e22d8 | |
parent | 3176d0925027727ec37e388e9363f124c2c52ae9 (diff) |
drm/edid: add drm_edid helper for drm_detect_monitor_audio()
We'll need to propagate drm_edid everywhere.
v2: Handle NULL EDID pointer (Ville, CI)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/ea33244c473ace1bc72a7e87f97580f00705a683.1652097712.git.jani.nikula@intel.com
-rw-r--r-- | drivers/gpu/drm/drm_edid.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index ad5e372f046b..f3f31534b78b 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -5154,19 +5154,7 @@ bool drm_detect_hdmi_monitor(const struct edid *edid) } EXPORT_SYMBOL(drm_detect_hdmi_monitor); -/** - * drm_detect_monitor_audio - check monitor audio capability - * @edid: EDID block to scan - * - * 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. - * - * Return: True if the monitor supports audio, false otherwise. - */ -bool drm_detect_monitor_audio(const struct edid *edid) +static bool _drm_detect_monitor_audio(const struct drm_edid *drm_edid) { struct drm_edid_iter edid_iter; const struct cea_db *db; @@ -5174,7 +5162,7 @@ bool drm_detect_monitor_audio(const struct edid *edid) const u8 *edid_ext; bool has_audio = false; - drm_edid_iter_begin(edid, &edid_iter); + drm_edid_iter_begin(drm_edid ? drm_edid->edid : NULL, &edid_iter); drm_edid_iter_for_each(edid_ext, &edid_iter) { if (edid_ext[0] == CEA_EXT) { has_audio = edid_ext[3] & EDID_BASIC_AUDIO; @@ -5189,7 +5177,7 @@ bool drm_detect_monitor_audio(const struct edid *edid) goto end; } - cea_db_iter_edid_begin(edid, &iter); + cea_db_iter_edid_begin(drm_edid ? drm_edid->edid : NULL, &iter); cea_db_iter_for_each(db, &iter) { if (cea_db_tag(db) == CTA_DB_AUDIO) { const u8 *data = cea_db_data(db); @@ -5207,6 +5195,25 @@ bool drm_detect_monitor_audio(const struct edid *edid) end: return has_audio; } + +/** + * drm_detect_monitor_audio - check monitor audio capability + * @edid: EDID block to scan + * + * 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. + * + * Return: True if the monitor supports audio, false otherwise. + */ +bool drm_detect_monitor_audio(const struct edid *edid) +{ + struct drm_edid drm_edid; + + return _drm_detect_monitor_audio(drm_edid_legacy_init(&drm_edid, edid)); +} EXPORT_SYMBOL(drm_detect_monitor_audio); |