@@ -281,13 +281,15 @@ static const struct hdmi_codec_cea_spk_alloc hdmi_codec_channel_alloc[] = {
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 ;
287
288
bool busy ;
288
289
struct snd_soc_jack * jack ;
289
290
unsigned int jack_status ;
290
291
u8 iec_status [AES_IEC958_STATUS_SIZE ];
292
+ struct snd_info_entry * proc_entry ;
291
293
};
292
294
293
295
static const struct snd_soc_dapm_widget hdmi_widgets [] = {
@@ -469,6 +471,9 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
469
471
if (ret )
470
472
goto err ;
471
473
474
+ snd_parse_eld (dai -> dev , & hcp -> eld_parsed ,
475
+ hcp -> eld , sizeof (hcp -> eld ));
476
+
472
477
ret = snd_pcm_hw_constraint_eld (substream -> runtime , hcp -> eld );
473
478
if (ret )
474
479
goto err ;
@@ -825,8 +830,54 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
825
830
return 0 ;
826
831
}
827
832
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
+
828
877
static int hdmi_dai_probe (struct snd_soc_dai * dai )
829
878
{
879
+ struct hdmi_codec_priv * hcp =
880
+ snd_soc_component_get_drvdata (dai -> component );
830
881
struct snd_soc_dapm_context * dapm ;
831
882
struct hdmi_codec_daifmt * daifmt ;
832
883
struct snd_soc_dapm_route route [] = {
@@ -859,6 +910,15 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai)
859
910
860
911
snd_soc_dai_dma_data_set_playback (dai , daifmt );
861
912
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 );
862
922
return 0 ;
863
923
}
864
924
@@ -875,11 +935,18 @@ static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp,
875
935
static void plugged_cb (struct device * dev , bool plugged )
876
936
{
877
937
struct hdmi_codec_priv * hcp = dev_get_drvdata (dev );
938
+ int ret ;
878
939
879
940
if (plugged ) {
880
941
if (hcp -> hcd .ops -> get_eld ) {
881
942
hcp -> hcd .ops -> get_eld (dev -> parent , hcp -> hcd .data ,
882
943
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 );
883
950
}
884
951
hdmi_codec_jack_report (hcp , SND_JACK_LINEOUT );
885
952
} else {
@@ -926,6 +993,7 @@ static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai)
926
993
927
994
static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
928
995
.probe = hdmi_dai_probe ,
996
+ .remove = hdmi_dai_remove ,
929
997
.startup = hdmi_codec_startup ,
930
998
.shutdown = hdmi_codec_shutdown ,
931
999
.hw_params = hdmi_codec_hw_params ,
0 commit comments