Skip to content

Commit bbd59df

Browse files
committed
Merge series "ASoC: Intel: sdw machine driver updates for 5.10" from Kai Vehmanen <kai.vehmanen@linux.intel.com>:
Series including fixes and improvements for Intel SoundWire machine drivers. Bard Liao (1): ASoC: Intel: add support for new SoundWire hardware layout on TGL Pierre-Louis Bossart (4): ASoC: Intel: sof_sdw: remove ternary operator ASoC: Intel: add codec name prefix to ACPI machine description ASoC: Intel: sof_sdw: remove hard-coded codec_conf table ASoC: Intel: sof_sdw_rt700: add codec prefix Rander Wang (1): ASOC: Intel: sof_sdw: restore playback functionality with max98373 amps include/sound/soc-acpi.h | 2 + sound/soc/intel/boards/sof_sdw.c | 170 +++++++++--------- sound/soc/intel/boards/sof_sdw_common.h | 3 + sound/soc/intel/boards/sof_sdw_max98373.c | 36 +++- sound/soc/intel/boards/sof_sdw_rt700.c | 6 +- .../intel/common/soc-acpi-intel-cml-match.c | 10 ++ .../intel/common/soc-acpi-intel-cnl-match.c | 1 + .../intel/common/soc-acpi-intel-icl-match.c | 6 + .../intel/common/soc-acpi-intel-tgl-match.c | 67 +++++++ 9 files changed, 216 insertions(+), 85 deletions(-) -- 2.27.0
2 parents 3121420 + 7cc3b56 commit bbd59df

9 files changed

Lines changed: 216 additions & 85 deletions

File tree

‎include/sound/soc-acpi.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ struct snd_soc_acpi_endpoint {
9393
* @adr: 64 bit ACPI _ADR value
9494
* @num_endpoints: number of endpoints for this device
9595
* @endpoints: array of endpoints
96+
* @name_prefix: string used for codec controls
9697
*/
9798
struct snd_soc_acpi_adr_device {
9899
const u64 adr;
99100
const u8 num_endpoints;
100101
const struct snd_soc_acpi_endpoint *endpoints;
102+
const char *name_prefix;
101103
};
102104

103105
/**

‎sound/soc/intel/boards/sof_sdw.c‎

Lines changed: 89 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ static int sof_sdw_quirk_cb(const struct dmi_system_id *id)
4848
}
4949

5050
static 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-
208148
static 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,
538478
static 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+
839833
static 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

11051113
static int mc_probe(struct platform_device *pdev)

‎sound/soc/intel/boards/sof_sdw_common.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ struct mc_private {
7979
extern unsigned long sof_sdw_quirk;
8080

8181
int sdw_startup(struct snd_pcm_substream *substream);
82+
int sdw_prepare(struct snd_pcm_substream *substream);
83+
int sdw_trigger(struct snd_pcm_substream *substream, int cmd);
84+
int sdw_hw_free(struct snd_pcm_substream *substream);
8285
void sdw_shutdown(struct snd_pcm_substream *substream);
8386

8487
/* generic HDMI support */

‎sound/soc/intel/boards/sof_sdw_max98373.c‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,43 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd)
5555
return ret;
5656
}
5757

58+
static int max98373_sdw_trigger(struct snd_pcm_substream *substream, int cmd)
59+
{
60+
int ret;
61+
62+
switch (cmd) {
63+
case SNDRV_PCM_TRIGGER_START:
64+
case SNDRV_PCM_TRIGGER_RESUME:
65+
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
66+
/* enable max98373 first */
67+
ret = max98373_trigger(substream, cmd);
68+
if (ret < 0)
69+
break;
70+
71+
ret = sdw_trigger(substream, cmd);
72+
break;
73+
case SNDRV_PCM_TRIGGER_STOP:
74+
case SNDRV_PCM_TRIGGER_SUSPEND:
75+
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
76+
ret = sdw_trigger(substream, cmd);
77+
if (ret < 0)
78+
break;
79+
80+
ret = max98373_trigger(substream, cmd);
81+
break;
82+
default:
83+
ret = -EINVAL;
84+
break;
85+
}
86+
87+
return ret;
88+
}
89+
5890
static const struct snd_soc_ops max_98373_sdw_ops = {
5991
.startup = sdw_startup,
60-
.trigger = max98373_trigger,
92+
.prepare = sdw_prepare,
93+
.trigger = max98373_sdw_trigger,
94+
.hw_free = sdw_hw_free,
6195
.shutdown = sdw_shutdown,
6296
};
6397

‎sound/soc/intel/boards/sof_sdw_rt700.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ static const struct snd_soc_dapm_widget rt700_widgets[] = {
2323

2424
static const struct snd_soc_dapm_route rt700_map[] = {
2525
/* Headphones */
26-
{ "Headphones", NULL, "HP" },
27-
{ "Speaker", NULL, "SPK" },
28-
{ "MIC2", NULL, "AMIC" },
26+
{ "Headphones", NULL, "rt700 HP" },
27+
{ "Speaker", NULL, "rt700 SPK" },
28+
{ "rt700 MIC2", NULL, "AMIC" },
2929
};
3030

3131
static const struct snd_kcontrol_new rt700_controls[] = {

0 commit comments

Comments
 (0)