@@ -48,6 +48,15 @@ static int sof_sdw_quirk_cb(const struct dmi_system_id *id)
4848}
4949
5050static const struct dmi_system_id sof_sdw_quirk_table [] = {
51+ {
52+ .callback = sof_sdw_quirk_cb ,
53+ .matches = {
54+ DMI_MATCH (DMI_SYS_VENDOR , "Dell Inc" ),
55+ DMI_EXACT_MATCH (DMI_PRODUCT_SKU , "0A3E" )
56+ },
57+ .driver_data = (void * )(SOF_RT711_JD_SRC_JD2 |
58+ SOF_RT715_DAI_ID_FIX ),
59+ },
5160 {
5261 .callback = sof_sdw_quirk_cb ,
5362 .matches = {
@@ -136,75 +145,6 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = {
136145 {}
137146};
138147
139- static struct snd_soc_codec_conf codec_conf [] = {
140- {
141- .dlc = COMP_CODEC_CONF ("sdw:0:25d:711:0" ),
142- .name_prefix = "rt711" ,
143- },
144- {
145- .dlc = COMP_CODEC_CONF ("sdw:0:25d:711:1" ),
146- .name_prefix = "rt711" ,
147- },
148- /* rt1308 w/ I2S connection */
149- {
150- .dlc = COMP_CODEC_CONF ("i2c-10EC1308:00" ),
151- .name_prefix = "rt1308-1" ,
152- },
153- /* rt1308 left on link 1 */
154- {
155- .dlc = COMP_CODEC_CONF ("sdw:1:25d:1308:0" ),
156- .name_prefix = "rt1308-1" ,
157- },
158- /* two 1308s on link1 with different unique id */
159- {
160- .dlc = COMP_CODEC_CONF ("sdw:1:25d:1308:0:0" ),
161- .name_prefix = "rt1308-1" ,
162- },
163- {
164- .dlc = COMP_CODEC_CONF ("sdw:1:25d:1308:0:2" ),
165- .name_prefix = "rt1308-2" ,
166- },
167- /* rt1308 right on link 2 */
168- {
169- .dlc = COMP_CODEC_CONF ("sdw:2:25d:1308:0" ),
170- .name_prefix = "rt1308-2" ,
171- },
172- {
173- .dlc = COMP_CODEC_CONF ("sdw:3:25d:715:0" ),
174- .name_prefix = "rt715" ,
175- },
176- /* two MAX98373s on link1 with different unique id */
177- {
178- .dlc = COMP_CODEC_CONF ("sdw:1:19f:8373:0:3" ),
179- .name_prefix = "Right" ,
180- },
181- {
182- .dlc = COMP_CODEC_CONF ("sdw:1:19f:8373:0:7" ),
183- .name_prefix = "Left" ,
184- },
185- {
186- .dlc = COMP_CODEC_CONF ("sdw:0:25d:5682:0" ),
187- .name_prefix = "rt5682" ,
188- },
189- /* rt5682 on link2 */
190- {
191- .dlc = COMP_CODEC_CONF ("sdw:2:25d:5682:0" ),
192- .name_prefix = "rt5682" ,
193- },
194- {
195- .dlc = COMP_CODEC_CONF ("sdw:1:25d:1316:1" ),
196- .name_prefix = "rt1316-1" ,
197- },
198- {
199- .dlc = COMP_CODEC_CONF ("sdw:2:25d:1316:1" ),
200- .name_prefix = "rt1316-2" ,
201- },
202- {
203- .dlc = COMP_CODEC_CONF ("sdw:3:25d:714:1" ),
204- .name_prefix = "rt714" ,
205- },
206- };
207-
208148static struct snd_soc_dai_link_component dmic_component [] = {
209149 {
210150 .name = "dmic-codec" ,
@@ -225,7 +165,7 @@ int sdw_startup(struct snd_pcm_substream *substream)
225165 return sdw_startup_stream (substream );
226166}
227167
228- static int sdw_prepare (struct snd_pcm_substream * substream )
168+ int sdw_prepare (struct snd_pcm_substream * substream )
229169{
230170 struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd (substream );
231171 struct sdw_stream_runtime * sdw_stream ;
@@ -244,7 +184,7 @@ static int sdw_prepare(struct snd_pcm_substream *substream)
244184 return sdw_prepare_stream (sdw_stream );
245185}
246186
247- static int sdw_trigger (struct snd_pcm_substream * substream , int cmd )
187+ int sdw_trigger (struct snd_pcm_substream * substream , int cmd )
248188{
249189 struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd (substream );
250190 struct sdw_stream_runtime * sdw_stream ;
@@ -284,7 +224,7 @@ static int sdw_trigger(struct snd_pcm_substream *substream, int cmd)
284224 return ret ;
285225}
286226
287- static int sdw_hw_free (struct snd_pcm_substream * substream )
227+ int sdw_hw_free (struct snd_pcm_substream * substream )
288228{
289229 struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd (substream );
290230 struct sdw_stream_runtime * sdw_stream ;
@@ -538,10 +478,19 @@ static bool is_unique_device(const struct snd_soc_acpi_link_adr *link,
538478static int create_codec_dai_name (struct device * dev ,
539479 const struct snd_soc_acpi_link_adr * link ,
540480 struct snd_soc_dai_link_component * codec ,
541- int offset )
481+ int offset ,
482+ struct snd_soc_codec_conf * codec_conf ,
483+ int codec_count ,
484+ int * codec_conf_index )
542485{
543486 int i ;
544487
488+ /* sanity check */
489+ if (* codec_conf_index + link -> num_adr > codec_count ) {
490+ dev_err (dev , "codec_conf: out-of-bounds access requested\n" );
491+ return - EINVAL ;
492+ }
493+
545494 for (i = 0 ; i < link -> num_adr ; i ++ ) {
546495 unsigned int sdw_version , unique_id , mfg_id ;
547496 unsigned int link_id , part_id , class_id ;
@@ -583,6 +532,11 @@ static int create_codec_dai_name(struct device *dev,
583532
584533 codec [comp_index ].dai_name =
585534 codec_info_list [codec_index ].dai_name ;
535+
536+ codec_conf [* codec_conf_index ].dlc = codec [comp_index ];
537+ codec_conf [* codec_conf_index ].name_prefix = link -> adr_d [i ].name_prefix ;
538+
539+ ++ * codec_conf_index ;
586540 }
587541
588542 return 0 ;
@@ -701,7 +655,10 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
701655 int sdw_be_num , int sdw_cpu_dai_num ,
702656 struct snd_soc_dai_link_component * cpus ,
703657 const struct snd_soc_acpi_link_adr * link ,
704- int * cpu_id , bool * group_generated )
658+ int * cpu_id , bool * group_generated ,
659+ struct snd_soc_codec_conf * codec_conf ,
660+ int codec_count ,
661+ int * codec_conf_index )
705662{
706663 const struct snd_soc_acpi_link_adr * link_next ;
707664 struct snd_soc_dai_link_component * codecs ;
@@ -739,7 +696,8 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
739696 if (cpu_dai_id [i ] != ffs (link_next -> mask ) - 1 )
740697 continue ;
741698
742- ret = create_codec_dai_name (dev , link_next , codecs , codec_idx );
699+ ret = create_codec_dai_name (dev , link_next , codecs , codec_idx ,
700+ codec_conf , codec_count , codec_conf_index );
743701 if (ret < 0 )
744702 return ret ;
745703
@@ -836,6 +794,42 @@ static inline int get_next_be_id(struct snd_soc_dai_link *links,
836794
837795#define IDISP_CODEC_MASK 0x4
838796
797+ static int sof_card_codec_conf_alloc (struct device * dev ,
798+ struct snd_soc_acpi_mach_params * mach_params ,
799+ struct snd_soc_codec_conf * * codec_conf ,
800+ int * codec_conf_count )
801+ {
802+ const struct snd_soc_acpi_link_adr * adr_link ;
803+ struct snd_soc_codec_conf * c_conf ;
804+ int num_codecs = 0 ;
805+ int i ;
806+
807+ adr_link = mach_params -> links ;
808+ if (!adr_link )
809+ return - EINVAL ;
810+
811+ /* generate DAI links by each sdw link */
812+ for (; adr_link -> num_adr ; adr_link ++ ) {
813+ for (i = 0 ; i < adr_link -> num_adr ; i ++ ) {
814+ if (!adr_link -> adr_d [i ].name_prefix ) {
815+ dev_err (dev , "codec 0x%llx does not have a name prefix\n" ,
816+ adr_link -> adr_d [i ].adr );
817+ return - EINVAL ;
818+ }
819+ }
820+ num_codecs += adr_link -> num_adr ;
821+ }
822+
823+ c_conf = devm_kzalloc (dev , num_codecs * sizeof (* c_conf ), GFP_KERNEL );
824+ if (!c_conf )
825+ return - ENOMEM ;
826+
827+ * codec_conf = c_conf ;
828+ * codec_conf_count = num_codecs ;
829+
830+ return 0 ;
831+ }
832+
839833static int sof_card_dai_links_create (struct device * dev ,
840834 struct snd_soc_acpi_mach * mach ,
841835 struct snd_soc_card * card )
@@ -847,6 +841,9 @@ static int sof_card_dai_links_create(struct device *dev,
847841 struct snd_soc_acpi_mach_params * mach_params ;
848842 const struct snd_soc_acpi_link_adr * adr_link ;
849843 struct snd_soc_dai_link_component * cpus ;
844+ struct snd_soc_codec_conf * codec_conf ;
845+ int codec_conf_count ;
846+ int codec_conf_index = 0 ;
850847 bool group_generated [SDW_MAX_GROUPS ];
851848 int ssp_codec_index , ssp_mask ;
852849 struct snd_soc_dai_link * links ;
@@ -859,12 +856,21 @@ static int sof_card_dai_links_create(struct device *dev,
859856 int comp_num ;
860857 int ret ;
861858
859+ mach_params = & mach -> mach_params ;
860+
861+ /* allocate codec conf, will be populated when dailinks are created */
862+ ret = sof_card_codec_conf_alloc (dev , mach_params , & codec_conf , & codec_conf_count );
863+ if (ret < 0 )
864+ return ret ;
865+
862866 /* reset amp_num to ensure amp_num++ starts from 0 in each probe */
863867 for (i = 0 ; i < ARRAY_SIZE (codec_info_list ); i ++ )
864868 codec_info_list [i ].amp_num = 0 ;
865869
866- hdmi_num = sof_sdw_quirk & SOF_SDW_TGL_HDMI ?
867- SOF_TGL_HDMI_COUNT : SOF_PRE_TGL_HDMI_COUNT ;
870+ if (sof_sdw_quirk & SOF_SDW_TGL_HDMI )
871+ hdmi_num = SOF_TGL_HDMI_COUNT ;
872+ else
873+ hdmi_num = SOF_PRE_TGL_HDMI_COUNT ;
868874
869875 ssp_mask = SOF_SSP_GET_PORT (sof_sdw_quirk );
870876 /*
@@ -877,7 +883,6 @@ static int sof_card_dai_links_create(struct device *dev,
877883 ssp_num = ssp_codec_index >= 0 ? hweight_long (ssp_mask ) : 0 ;
878884 comp_num = hdmi_num + ssp_num ;
879885
880- mach_params = & mach -> mach_params ;
881886 ret = get_sdw_dailink_info (mach_params -> links ,
882887 & sdw_be_num , & sdw_cpu_dai_num );
883888 if (ret < 0 ) {
@@ -941,7 +946,9 @@ static int sof_card_dai_links_create(struct device *dev,
941946
942947 ret = create_sdw_dailink (dev , & be_id , links , sdw_be_num ,
943948 sdw_cpu_dai_num , cpus , adr_link ,
944- & cpu_id , group_generated );
949+ & cpu_id , group_generated ,
950+ codec_conf , codec_conf_count ,
951+ & codec_conf_index );
945952 if (ret < 0 ) {
946953 dev_err (dev , "failed to create dai link %d" , be_id );
947954 return - ENOMEM ;
@@ -1072,6 +1079,9 @@ static int sof_card_dai_links_create(struct device *dev,
10721079 card -> dai_link = links ;
10731080 card -> num_links = num_links ;
10741081
1082+ card -> codec_conf = codec_conf ;
1083+ card -> num_configs = codec_conf_count ;
1084+
10751085 return 0 ;
10761086}
10771087
@@ -1098,8 +1108,6 @@ static struct snd_soc_card card_sof_sdw = {
10981108 .name = "soundwire" ,
10991109 .owner = THIS_MODULE ,
11001110 .late_probe = sof_sdw_card_late_probe ,
1101- .codec_conf = codec_conf ,
1102- .num_configs = ARRAY_SIZE (codec_conf ),
11031111};
11041112
11051113static int mc_probe (struct platform_device * pdev )
0 commit comments