Skip to content

Commit 4eb16a5

Browse files
committed
ASoC: sdw_utils: add rt1320 dmic dai in codec_info_list
Add 'rt1320-aif2' dai info for rt1320 dmic function. Signed-off-by: Derek Fang <derek.fang@realtek.com>
1 parent cd88bab commit 4eb16a5

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

sound/soc/sdw_utils/soc_sdw_rt_dmic.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
#include <sound/soc.h>
1313
#include <sound/soc-acpi.h>
1414
#include <sound/soc_sdw_utils.h>
15+
#include <sound/sdca_function.h>
1516

1617
int asoc_sdw_rt_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
1718
{
1819
struct snd_soc_card *card = rtd->card;
1920
struct snd_soc_component *component;
21+
struct sdw_slave *sdw_peripheral;
22+
struct asoc_sdw_codec_info *codec_info;
2023
char *mic_name;
24+
int rt1320_dmic_num = 0, part_id, i;
2125

2226
component = dai->component;
2327

@@ -27,14 +31,40 @@ int asoc_sdw_rt_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_da
2731
*/
2832
if (!strcmp(component->name_prefix, "rt714"))
2933
mic_name = devm_kasprintf(card->dev, GFP_KERNEL, "rt715-sdca");
30-
else
34+
/*
35+
* If there is any rt1320 DMIC belonging to this card, try to count the `cfg-mics` to be used in
36+
* card->components.
37+
*/
38+
else if (!strcmp(dai->name, "rt1320-aif2")) {
39+
codec_info = asoc_sdw_find_codec_info_dai(dai->name, &i);
40+
part_id = codec_info->part_id;
41+
mic_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s", codec_info->dais[i].component_name);
42+
43+
// count the rt1320 with SDCA function SmartMic type in this card
44+
for_each_card_components(card, component) {
45+
sdw_peripheral = dev_to_sdw_dev(component->dev);
46+
if (sdw_peripheral->id.part_id != part_id)
47+
continue;
48+
for (i = 0; i < sdw_peripheral->sdca_data.num_functions; i++) {
49+
if (sdw_peripheral->sdca_data.function[i].type == SDCA_FUNCTION_TYPE_SMART_MIC) {
50+
rt1320_dmic_num++;
51+
break;
52+
}
53+
}
54+
}
55+
} else
3156
mic_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s", component->name_prefix);
3257
if (!mic_name)
3358
return -ENOMEM;
3459

35-
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
36-
"%s mic:%s", card->components,
37-
mic_name);
60+
if (!strcmp(dai->name, "rt1320-aif2"))
61+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
62+
"%s mic:%s cfg-mics:%d", card->components,
63+
mic_name, rt1320_dmic_num);
64+
else
65+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
66+
"%s mic:%s", card->components,
67+
mic_name);
3868
if (!card->components)
3969
return -ENOMEM;
4070

sound/soc/sdw_utils/soc_sdw_utils.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
319319
{
320320
.part_id = 0x1320,
321321
.name_prefix = "rt1320",
322+
.is_amp = true,
322323
.dais = {
323324
{
324325
.direction = {true, false},
@@ -334,8 +335,18 @@ struct asoc_sdw_codec_info codec_info_list[] = {
334335
.widgets = generic_spk_widgets,
335336
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
336337
},
338+
{
339+
.direction = {false, true},
340+
.dai_name = "rt1320-aif2",
341+
.component_name = "rt1320",
342+
.dai_type = SOC_SDW_DAI_TYPE_MIC,
343+
.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID},
344+
.rtd_init = asoc_sdw_rt_dmic_rtd_init,
345+
.widgets = generic_dmic_widgets,
346+
.num_widgets = ARRAY_SIZE(generic_dmic_widgets),
347+
},
337348
},
338-
.dai_num = 1,
349+
.dai_num = 2,
339350
},
340351
{
341352
.part_id = 0x1321,

0 commit comments

Comments
 (0)