From c6c61f86799bbaf7107642bce13fcd18369e1a6d Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Fri, 29 Apr 2022 22:36:03 +0800 Subject: [PATCH] ASoC: hdmi-codec: Add option for ELD bypass This patch allow users to enable "ELD Bypass" who don't care anything from EDID Link Data. Currently, this driver gets ELD(from EDID) to constraint channels and rates. Unfortunately, EDID is not always valid, maybe caused by the fragile HDMI port or cable, in this situation, the max features are limited to 48kHz stereo. So, add this option to allow user to select the manual way to output audio as expected. such as multi-channels LPCM(7.1), or HBR bitstream for these sink devices. Signed-off-by: Sugar Zhang Change-Id: Ic5ad66002d6f97b4585aaeb01620a53e08b7ed84 --- sound/soc/codecs/hdmi-codec.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 0e969297e787..e5673ccfd016 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -275,6 +275,7 @@ struct hdmi_codec_priv { unsigned int chmap_idx; struct mutex lock; bool busy; + bool eld_bypass; struct snd_soc_jack *jack; unsigned int jack_status; u8 iec_status[24]; @@ -428,6 +429,31 @@ static int hdmi_codec_iec958_mask_get(struct snd_kcontrol *kcontrol, return 0; } +static int hdmi_codec_eld_bypass_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = hcp->eld_bypass; + + return 0; +} + +static int hdmi_codec_eld_bypass_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + + if (hcp->eld_bypass == ucontrol->value.integer.value[0]) + return 0; + + hcp->eld_bypass = ucontrol->value.integer.value[0]; + + return 1; +} + static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -448,7 +474,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, goto err; } - if (tx && hcp->hcd.ops->get_eld) { + if (tx && !hcp->eld_bypass && hcp->hcd.ops->get_eld) { ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, hcp->eld, sizeof(hcp->eld)); if (ret) @@ -752,6 +778,8 @@ static struct snd_kcontrol_new hdmi_codec_controls[] = { .info = hdmi_eld_ctl_info, .get = hdmi_eld_ctl_get, }, + SOC_SINGLE_BOOL_EXT("ELD Bypass Switch", 0, + hdmi_codec_eld_bypass_get, hdmi_codec_eld_bypass_put), }; static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, @@ -836,7 +864,7 @@ static void plugged_cb(struct device *dev, bool plugged) struct hdmi_codec_priv *hcp = dev_get_drvdata(dev); if (plugged) { - if (hcp->hcd.ops->get_eld) { + if (!hcp->eld_bypass && hcp->hcd.ops->get_eld) { hcp->hcd.ops->get_eld(dev->parent, hcp->hcd.data, hcp->eld, sizeof(hcp->eld)); }