Skip to content

Commit 45f1b12

Browse files
committed
ASoC: Intel: more machine driver updates for 6.7
Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>: Two nice cleanups from Brent Lu and Charles Keepax, and one RaptorLake update.
2 parents 897d8e8 + f6b415f commit 45f1b12

9 files changed

Lines changed: 232 additions & 278 deletions

File tree

sound/soc/intel/boards/sof_board_helpers.c

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,108 @@ int sof_intel_board_card_late_probe(struct snd_soc_card *card)
3636
}
3737
EXPORT_SYMBOL_NS(sof_intel_board_card_late_probe, SND_SOC_INTEL_SOF_BOARD_HELPERS);
3838

39+
/*
40+
* DMIC DAI Link
41+
*/
42+
static const struct snd_soc_dapm_widget dmic_widgets[] = {
43+
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
44+
};
45+
46+
static const struct snd_soc_dapm_route dmic_routes[] = {
47+
{"DMic", NULL, "SoC DMIC"},
48+
};
49+
50+
static int dmic_init(struct snd_soc_pcm_runtime *rtd)
51+
{
52+
struct snd_soc_card *card = rtd->card;
53+
int ret;
54+
55+
ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
56+
ARRAY_SIZE(dmic_widgets));
57+
if (ret) {
58+
dev_err(rtd->dev, "fail to add dmic widgets, ret %d\n", ret);
59+
return ret;
60+
}
61+
62+
ret = snd_soc_dapm_add_routes(&card->dapm, dmic_routes,
63+
ARRAY_SIZE(dmic_routes));
64+
if (ret) {
65+
dev_err(rtd->dev, "fail to add dmic routes, ret %d\n", ret);
66+
return ret;
67+
}
68+
69+
return 0;
70+
}
71+
3972
/*
4073
* DAI Link Helpers
4174
*/
75+
static struct snd_soc_dai_link_component dmic_component[] = {
76+
{
77+
.name = "dmic-codec",
78+
.dai_name = "dmic-hifi",
79+
}
80+
};
81+
4282
static struct snd_soc_dai_link_component platform_component[] = {
4383
{
4484
/* name might be overridden during probe */
4585
.name = "0000:00:1f.3"
4686
}
4787
};
4888

89+
int sof_intel_board_set_dmic_link(struct device *dev,
90+
struct snd_soc_dai_link *link, int be_id,
91+
enum sof_dmic_be_type be_type)
92+
{
93+
struct snd_soc_dai_link_component *cpus;
94+
95+
/* cpus */
96+
cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
97+
GFP_KERNEL);
98+
if (!cpus)
99+
return -ENOMEM;
100+
101+
switch (be_type) {
102+
case SOF_DMIC_01:
103+
dev_dbg(dev, "link %d: dmic01\n", be_id);
104+
105+
link->name = "dmic01";
106+
cpus->dai_name = "DMIC01 Pin";
107+
break;
108+
case SOF_DMIC_16K:
109+
dev_dbg(dev, "link %d: dmic16k\n", be_id);
110+
111+
link->name = "dmic16k";
112+
cpus->dai_name = "DMIC16k Pin";
113+
break;
114+
default:
115+
dev_err(dev, "invalid be type %d\n", be_type);
116+
return -EINVAL;
117+
}
118+
119+
link->cpus = cpus;
120+
link->num_cpus = 1;
121+
122+
/* codecs */
123+
link->codecs = dmic_component;
124+
link->num_codecs = ARRAY_SIZE(dmic_component);
125+
126+
/* platforms */
127+
link->platforms = platform_component;
128+
link->num_platforms = ARRAY_SIZE(platform_component);
129+
130+
link->id = be_id;
131+
if (be_type == SOF_DMIC_01)
132+
link->init = dmic_init;
133+
link->ignore_suspend = 1;
134+
link->no_pcm = 1;
135+
link->dpcm_capture = 1;
136+
137+
return 0;
138+
}
139+
EXPORT_SYMBOL_NS(sof_intel_board_set_dmic_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
140+
49141
int sof_intel_board_set_intel_hdmi_link(struct device *dev,
50142
struct snd_soc_dai_link *link, int be_id,
51143
int hdmi_id, bool idisp_codec)

sound/soc/intel/boards/sof_board_helpers.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct sof_rt5682_private {
2828
* @hdmi: init data for hdmi dai link
2929
* @codec_type: type of headset codec
3030
* @amp_type: type of speaker amplifier
31+
* @dmic_be_num: number of Intel PCH DMIC BE link
3132
* @hdmi_num: number of Intel HDMI BE link
3233
* @rt5682: private data for rt5682 machine driver
3334
*/
@@ -38,15 +39,24 @@ struct sof_card_private {
3839
enum sof_ssp_codec codec_type;
3940
enum sof_ssp_codec amp_type;
4041

42+
int dmic_be_num;
4143
int hdmi_num;
4244

4345
union {
4446
struct sof_rt5682_private rt5682;
4547
};
4648
};
4749

50+
enum sof_dmic_be_type {
51+
SOF_DMIC_01,
52+
SOF_DMIC_16K,
53+
};
54+
4855
int sof_intel_board_card_late_probe(struct snd_soc_card *card);
4956

57+
int sof_intel_board_set_dmic_link(struct device *dev,
58+
struct snd_soc_dai_link *link, int be_id,
59+
enum sof_dmic_be_type be_type);
5060
int sof_intel_board_set_intel_hdmi_link(struct device *dev,
5161
struct snd_soc_dai_link *link, int be_id,
5262
int hdmi_id, bool idisp_codec);

sound/soc/intel/boards/sof_cs42l42.c

Lines changed: 32 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = {
160160
SND_SOC_DAPM_MIC("Headset Mic", NULL),
161161
};
162162

163-
static const struct snd_soc_dapm_widget dmic_widgets[] = {
164-
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
165-
};
166-
167163
static const struct snd_soc_dapm_route sof_map[] = {
168164
/* HP jack connectors - unknown if we have jack detection */
169165
{"Headphone Jack", NULL, "HP"},
@@ -172,33 +168,6 @@ static const struct snd_soc_dapm_route sof_map[] = {
172168
{"HS", NULL, "Headset Mic"},
173169
};
174170

175-
static const struct snd_soc_dapm_route dmic_map[] = {
176-
/* digital mics */
177-
{"DMic", NULL, "SoC DMIC"},
178-
};
179-
180-
static int dmic_init(struct snd_soc_pcm_runtime *rtd)
181-
{
182-
struct snd_soc_card *card = rtd->card;
183-
int ret;
184-
185-
ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
186-
ARRAY_SIZE(dmic_widgets));
187-
if (ret) {
188-
dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
189-
/* Don't need to add routes if widget addition failed */
190-
return ret;
191-
}
192-
193-
ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
194-
ARRAY_SIZE(dmic_map));
195-
196-
if (ret)
197-
dev_err(card->dev, "DMic map addition failed: %d\n", ret);
198-
199-
return ret;
200-
}
201-
202171
/* sof audio machine driver for cs42l42 codec */
203172
static struct snd_soc_card sof_audio_card_cs42l42 = {
204173
.name = "cs42l42", /* the sof- prefix is added by the core */
@@ -220,13 +189,6 @@ static struct snd_soc_dai_link_component cs42l42_component[] = {
220189
}
221190
};
222191

223-
static struct snd_soc_dai_link_component dmic_component[] = {
224-
{
225-
.name = "dmic-codec",
226-
.dai_name = "dmic-hifi",
227-
}
228-
};
229-
230192
static int create_spk_amp_dai_links(struct device *dev,
231193
struct snd_soc_dai_link *links,
232194
struct snd_soc_dai_link_component *cpus,
@@ -322,47 +284,6 @@ static int create_hp_codec_dai_links(struct device *dev,
322284
return -ENOMEM;
323285
}
324286

325-
static int create_dmic_dai_links(struct device *dev,
326-
struct snd_soc_dai_link *links,
327-
struct snd_soc_dai_link_component *cpus,
328-
int *id, int dmic_be_num)
329-
{
330-
int i;
331-
332-
/* dmic */
333-
if (dmic_be_num <= 0)
334-
return 0;
335-
336-
/* at least we have dmic01 */
337-
links[*id].name = "dmic01";
338-
links[*id].cpus = &cpus[*id];
339-
links[*id].cpus->dai_name = "DMIC01 Pin";
340-
links[*id].init = dmic_init;
341-
if (dmic_be_num > 1) {
342-
/* set up 2 BE links at most */
343-
links[*id + 1].name = "dmic16k";
344-
links[*id + 1].cpus = &cpus[*id + 1];
345-
links[*id + 1].cpus->dai_name = "DMIC16k Pin";
346-
dmic_be_num = 2;
347-
}
348-
349-
for (i = 0; i < dmic_be_num; i++) {
350-
links[*id].id = *id;
351-
links[*id].num_cpus = 1;
352-
links[*id].codecs = dmic_component;
353-
links[*id].num_codecs = ARRAY_SIZE(dmic_component);
354-
links[*id].platforms = platform_component;
355-
links[*id].num_platforms = ARRAY_SIZE(platform_component);
356-
links[*id].ignore_suspend = 1;
357-
links[*id].dpcm_capture = 1;
358-
links[*id].no_pcm = 1;
359-
360-
(*id)++;
361-
}
362-
363-
return 0;
364-
}
365-
366287
static int create_bt_offload_dai_links(struct device *dev,
367288
struct snd_soc_dai_link *links,
368289
struct snd_soc_dai_link_component *cpus,
@@ -446,11 +367,34 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
446367
}
447368
break;
448369
case LINK_DMIC:
449-
ret = create_dmic_dai_links(dev, links, cpus, &id, dmic_be_num);
450-
if (ret < 0) {
451-
dev_err(dev, "fail to create dmic dai links, ret %d\n",
452-
ret);
453-
goto devm_err;
370+
if (dmic_be_num > 0) {
371+
/* at least we have dmic01 */
372+
ret = sof_intel_board_set_dmic_link(dev,
373+
&links[id],
374+
id,
375+
SOF_DMIC_01);
376+
if (ret) {
377+
dev_err(dev, "fail to create dmic01 link, ret %d\n",
378+
ret);
379+
goto devm_err;
380+
}
381+
382+
id++;
383+
}
384+
385+
if (dmic_be_num > 1) {
386+
/* set up 2 BE links at most */
387+
ret = sof_intel_board_set_dmic_link(dev,
388+
&links[id],
389+
id,
390+
SOF_DMIC_16K);
391+
if (ret) {
392+
dev_err(dev, "fail to create dmic16k link, ret %d\n",
393+
ret);
394+
goto devm_err;
395+
}
396+
397+
id++;
454398
}
455399
break;
456400
case LINK_HDMI:
@@ -496,7 +440,6 @@ static int sof_audio_probe(struct platform_device *pdev)
496440
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
497441
struct snd_soc_dai_link *dai_links;
498442
struct sof_card_private *ctx;
499-
int dmic_be_num;
500443
int ret, ssp_bt, ssp_amp, ssp_codec;
501444

502445
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -510,10 +453,10 @@ static int sof_audio_probe(struct platform_device *pdev)
510453
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev);
511454

512455
if (soc_intel_is_glk()) {
513-
dmic_be_num = 1;
456+
ctx->dmic_be_num = 1;
514457
ctx->hdmi_num = 3;
515458
} else {
516-
dmic_be_num = 2;
459+
ctx->dmic_be_num = 2;
517460
ctx->hdmi_num = (sof_cs42l42_quirk & SOF_CS42L42_NUM_HDMIDEV_MASK) >>
518461
SOF_CS42L42_NUM_HDMIDEV_SHIFT;
519462
/* default number of HDMI DAI's */
@@ -535,7 +478,7 @@ static int sof_audio_probe(struct platform_device *pdev)
535478
ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK;
536479

537480
/* compute number of dai links */
538-
sof_audio_card_cs42l42.num_links = 1 + dmic_be_num + ctx->hdmi_num;
481+
sof_audio_card_cs42l42.num_links = 1 + ctx->dmic_be_num + ctx->hdmi_num;
539482

540483
if (ctx->amp_type != CODEC_NONE)
541484
sof_audio_card_cs42l42.num_links++;
@@ -544,7 +487,7 @@ static int sof_audio_probe(struct platform_device *pdev)
544487

545488
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type,
546489
ssp_codec, ssp_amp, ssp_bt,
547-
dmic_be_num, ctx->hdmi_num,
490+
ctx->dmic_be_num, ctx->hdmi_num,
548491
ctx->hdmi.idisp_codec);
549492
if (!dai_links)
550493
return -ENOMEM;

0 commit comments

Comments
 (0)