@@ -281,13 +281,15 @@ static const struct hdmi_codec_cea_spk_alloc hdmi_codec_channel_alloc[] = {
281281struct hdmi_codec_priv {
282282 struct hdmi_codec_pdata hcd ;
283283 uint8_t eld [MAX_ELD_BYTES ];
284+ struct snd_parsed_hdmi_eld eld_parsed ;
284285 struct snd_pcm_chmap * chmap_info ;
285286 unsigned int chmap_idx ;
286287 struct mutex lock ;
287288 bool busy ;
288289 struct snd_soc_jack * jack ;
289290 unsigned int jack_status ;
290291 u8 iec_status [AES_IEC958_STATUS_SIZE ];
292+ struct snd_info_entry * proc_entry ;
291293};
292294
293295static const struct snd_soc_dapm_widget hdmi_widgets [] = {
@@ -469,6 +471,9 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
469471 if (ret )
470472 goto err ;
471473
474+ snd_parse_eld (dai -> dev , & hcp -> eld_parsed ,
475+ hcp -> eld , sizeof (hcp -> eld ));
476+
472477 ret = snd_pcm_hw_constraint_eld (substream -> runtime , hcp -> eld );
473478 if (ret )
474479 goto err ;
@@ -825,8 +830,54 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
825830 return 0 ;
826831}
827832
833+ #ifdef CONFIG_SND_PROC_FS
834+ static void print_eld_info (struct snd_info_entry * entry ,
835+ struct snd_info_buffer * buffer )
836+ {
837+ struct hdmi_codec_priv * hcp = entry -> private_data ;
838+
839+ snd_print_eld_info (& hcp -> eld_parsed , buffer );
840+ }
841+
842+ static int hdmi_dai_proc_new (struct hdmi_codec_priv * hcp ,
843+ struct snd_soc_dai * dai )
844+ {
845+ struct snd_info_entry * entry ;
846+ char name [32 ];
847+ int err ;
848+
849+ snprintf (name , sizeof (name ), "eld#%d" , dai -> id );
850+ err = snd_card_proc_new (dai -> component -> card -> snd_card , name , & entry );
851+ if (err < 0 )
852+ return err ;
853+
854+ snd_info_set_text_ops (entry , hcp , print_eld_info );
855+ hcp -> proc_entry = entry ;
856+
857+ return 0 ;
858+ }
859+
860+ static void hdmi_dai_proc_free (struct hdmi_codec_priv * hcp )
861+ {
862+ snd_info_free_entry (hcp -> proc_entry );
863+ hcp -> proc_entry = NULL ;
864+ }
865+ #else
866+ static int hdmi_dai_proc_new (struct hdmi_codec_priv * hcp ,
867+ struct snd_soc_dai * dai )
868+ {
869+ return 0 ;
870+ }
871+
872+ static void hdmi_dai_proc_free (struct hdmi_codec_priv * hcp )
873+ {
874+ }
875+ #endif
876+
828877static int hdmi_dai_probe (struct snd_soc_dai * dai )
829878{
879+ struct hdmi_codec_priv * hcp =
880+ snd_soc_component_get_drvdata (dai -> component );
830881 struct snd_soc_dapm_context * dapm ;
831882 struct hdmi_codec_daifmt * daifmt ;
832883 struct snd_soc_dapm_route route [] = {
@@ -859,6 +910,15 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai)
859910
860911 snd_soc_dai_dma_data_set_playback (dai , daifmt );
861912
913+ return hdmi_dai_proc_new (hcp , dai );
914+ }
915+
916+ static int hdmi_dai_remove (struct snd_soc_dai * dai )
917+ {
918+ struct hdmi_codec_priv * hcp =
919+ snd_soc_component_get_drvdata (dai -> component );
920+
921+ hdmi_dai_proc_free (hcp );
862922 return 0 ;
863923}
864924
@@ -875,11 +935,18 @@ static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp,
875935static void plugged_cb (struct device * dev , bool plugged )
876936{
877937 struct hdmi_codec_priv * hcp = dev_get_drvdata (dev );
938+ int ret ;
878939
879940 if (plugged ) {
880941 if (hcp -> hcd .ops -> get_eld ) {
881942 hcp -> hcd .ops -> get_eld (dev -> parent , hcp -> hcd .data ,
882943 hcp -> eld , sizeof (hcp -> eld ));
944+ ret = snd_parse_eld (dev , & hcp -> eld_parsed ,
945+ hcp -> eld , sizeof (hcp -> eld ));
946+ if (ret < 0 )
947+ dev_dbg (dev , "Failed to parse ELD: %d\n" , ret );
948+ else
949+ snd_show_eld (dev , & hcp -> eld_parsed );
883950 }
884951 hdmi_codec_jack_report (hcp , SND_JACK_LINEOUT );
885952 } else {
@@ -926,6 +993,7 @@ static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai)
926993
927994static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
928995 .probe = hdmi_dai_probe ,
996+ .remove = hdmi_dai_remove ,
929997 .startup = hdmi_codec_startup ,
930998 .shutdown = hdmi_codec_shutdown ,
931999 .hw_params = hdmi_codec_hw_params ,
0 commit comments