Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: hdmi-codec: dump ELD through procfs

Use freshly added API and add eld#n files to procfs for the ASoC cards
utilizing HDMI codec. This simplifies debugging of the possible ASoC /
HDMI / DisplayPort audio issues.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250124-alsa-hdmi-codec-eld-v1-2-bad045cfaeac@linaro.org

authored by

Dmitry Baryshkov and committed by
Takashi Iwai
0ecd24a6 1b0e9d7f

+68
+68
sound/soc/codecs/hdmi-codec.c
··· 281 281 struct hdmi_codec_priv { 282 282 struct hdmi_codec_pdata hcd; 283 283 uint8_t eld[MAX_ELD_BYTES]; 284 + struct snd_parsed_hdmi_eld eld_parsed; 284 285 struct snd_pcm_chmap *chmap_info; 285 286 unsigned int chmap_idx; 286 287 struct mutex lock; ··· 289 288 struct snd_soc_jack *jack; 290 289 unsigned int jack_status; 291 290 u8 iec_status[AES_IEC958_STATUS_SIZE]; 291 + struct snd_info_entry *proc_entry; 292 292 }; 293 293 294 294 static const struct snd_soc_dapm_widget hdmi_widgets[] = { ··· 470 468 hcp->eld, sizeof(hcp->eld)); 471 469 if (ret) 472 470 goto err; 471 + 472 + snd_parse_eld(dai->dev, &hcp->eld_parsed, 473 + hcp->eld, sizeof(hcp->eld)); 473 474 474 475 ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld); 475 476 if (ret) ··· 830 825 return 0; 831 826 } 832 827 828 + #ifdef CONFIG_SND_PROC_FS 829 + static void print_eld_info(struct snd_info_entry *entry, 830 + struct snd_info_buffer *buffer) 831 + { 832 + struct hdmi_codec_priv *hcp = entry->private_data; 833 + 834 + snd_print_eld_info(&hcp->eld_parsed, buffer); 835 + } 836 + 837 + static int hdmi_dai_proc_new(struct hdmi_codec_priv *hcp, 838 + struct snd_soc_dai *dai) 839 + { 840 + struct snd_info_entry *entry; 841 + char name[32]; 842 + int err; 843 + 844 + snprintf(name, sizeof(name), "eld#%d", dai->id); 845 + err = snd_card_proc_new(dai->component->card->snd_card, name, &entry); 846 + if (err < 0) 847 + return err; 848 + 849 + snd_info_set_text_ops(entry, hcp, print_eld_info); 850 + hcp->proc_entry = entry; 851 + 852 + return 0; 853 + } 854 + 855 + static void hdmi_dai_proc_free(struct hdmi_codec_priv *hcp) 856 + { 857 + snd_info_free_entry(hcp->proc_entry); 858 + hcp->proc_entry = NULL; 859 + } 860 + #else 861 + static int hdmi_dai_proc_new(struct hdmi_codec_priv *hcp, 862 + struct snd_soc_dai *dai) 863 + { 864 + return 0; 865 + } 866 + 867 + static void hdmi_dai_proc_free(struct hdmi_codec_priv *hcp) 868 + { 869 + } 870 + #endif 871 + 833 872 static int hdmi_dai_probe(struct snd_soc_dai *dai) 834 873 { 874 + struct hdmi_codec_priv *hcp = 875 + snd_soc_component_get_drvdata(dai->component); 835 876 struct snd_soc_dapm_context *dapm; 836 877 struct hdmi_codec_daifmt *daifmt; 837 878 struct snd_soc_dapm_route route[] = { ··· 910 859 911 860 snd_soc_dai_dma_data_set_playback(dai, daifmt); 912 861 862 + return hdmi_dai_proc_new(hcp, dai); 863 + } 864 + 865 + static int hdmi_dai_remove(struct snd_soc_dai *dai) 866 + { 867 + struct hdmi_codec_priv *hcp = 868 + snd_soc_component_get_drvdata(dai->component); 869 + 870 + hdmi_dai_proc_free(hcp); 913 871 return 0; 914 872 } 915 873 ··· 935 875 static void plugged_cb(struct device *dev, bool plugged) 936 876 { 937 877 struct hdmi_codec_priv *hcp = dev_get_drvdata(dev); 878 + int ret; 938 879 939 880 if (plugged) { 940 881 if (hcp->hcd.ops->get_eld) { 941 882 hcp->hcd.ops->get_eld(dev->parent, hcp->hcd.data, 942 883 hcp->eld, sizeof(hcp->eld)); 884 + ret = snd_parse_eld(dev, &hcp->eld_parsed, 885 + hcp->eld, sizeof(hcp->eld)); 886 + if (ret < 0) 887 + dev_dbg(dev, "Failed to parse ELD: %d\n", ret); 888 + else 889 + snd_show_eld(dev, &hcp->eld_parsed); 943 890 } 944 891 hdmi_codec_jack_report(hcp, SND_JACK_LINEOUT); 945 892 } else { ··· 993 926 994 927 static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = { 995 928 .probe = hdmi_dai_probe, 929 + .remove = hdmi_dai_remove, 996 930 .startup = hdmi_codec_startup, 997 931 .shutdown = hdmi_codec_shutdown, 998 932 .hw_params = hdmi_codec_hw_params,