Skip to content

Commit e70b8dd

Browse files
AngeloGioacchino Del Regnobroonie
authored andcommitted
ASoC: mediatek: mt8195: Remove afe-dai component and rework codec link
Remove the extra 'mt8195-afe-pcm-dai' component, register the DAI drivers to the main AFE component, and rework the DAI linking between the headset codec (RT5682/RT5682S) and the TDM interface in the probe function to stop assigning name, relying on the of_node of the codec. Also replace the COMP_DUMMY codec entry with a COMP_EMPTY for the ETDM2_IN and remove it entirely from ETDM1_OUT to fix the registration flow for this sound card. While at it, since we also need to swap the codec init function from ETDM2_IN to ETDM1_OUT, remove the static assignment of both `ops` and `init` for both, as we now assign these dynamically during probe. Fixes: 13f5826 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()") Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4d4e1b6 commit e70b8dd

File tree

2 files changed

+29
-45
lines changed

2 files changed

+29
-45
lines changed

sound/soc/mediatek/mt8195/mt8195-afe-pcm.c

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,10 +1795,6 @@ static const struct snd_kcontrol_new mt8195_memif_controls[] = {
17951795
MT8195_AFE_IRQ_28),
17961796
};
17971797

1798-
static const struct snd_soc_component_driver mt8195_afe_pcm_dai_component = {
1799-
.name = "mt8195-afe-pcm-dai",
1800-
};
1801-
18021798
static const struct mtk_base_memif_data memif_data[MT8195_AFE_MEMIF_NUM] = {
18031799
[MT8195_AFE_MEMIF_DL2] = {
18041800
.name = "DL2",
@@ -3037,7 +3033,6 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
30373033
struct device *dev = &pdev->dev;
30383034
struct reset_control *rstc;
30393035
int i, irq_id, ret;
3040-
struct snd_soc_component *component;
30413036

30423037
ret = of_reserved_mem_device_init(dev);
30433038
if (ret)
@@ -3170,36 +3165,12 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
31703165

31713166
/* register component */
31723167
ret = devm_snd_soc_register_component(dev, &mt8195_afe_component,
3173-
NULL, 0);
3168+
afe->dai_drivers, afe->num_dai_drivers);
31743169
if (ret) {
31753170
dev_warn(dev, "err_platform\n");
31763171
goto err_pm_put;
31773172
}
31783173

3179-
component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL);
3180-
if (!component) {
3181-
ret = -ENOMEM;
3182-
goto err_pm_put;
3183-
}
3184-
3185-
ret = snd_soc_component_initialize(component,
3186-
&mt8195_afe_pcm_dai_component,
3187-
dev);
3188-
if (ret)
3189-
goto err_pm_put;
3190-
3191-
#ifdef CONFIG_DEBUG_FS
3192-
component->debugfs_prefix = "pcm";
3193-
#endif
3194-
3195-
ret = snd_soc_add_component(component,
3196-
afe->dai_drivers,
3197-
afe->num_dai_drivers);
3198-
if (ret) {
3199-
dev_warn(dev, "err_dai_component\n");
3200-
goto err_pm_put;
3201-
}
3202-
32033174
ret = regmap_multi_reg_write(afe->regmap, mt8195_afe_reg_defaults,
32043175
ARRAY_SIZE(mt8195_afe_reg_defaults));
32053176
if (ret)
@@ -3224,8 +3195,6 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
32243195

32253196
static void mt8195_afe_pcm_dev_remove(struct platform_device *pdev)
32263197
{
3227-
snd_soc_unregister_component(&pdev->dev);
3228-
32293198
pm_runtime_disable(&pdev->dev);
32303199
if (!pm_runtime_status_suspended(&pdev->dev))
32313200
mt8195_afe_runtime_suspend(&pdev->dev);

sound/soc/mediatek/mt8195/mt8195-mt6359.c

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -934,12 +934,11 @@ SND_SOC_DAILINK_DEFS(ETDM1_IN_BE,
934934

935935
SND_SOC_DAILINK_DEFS(ETDM2_IN_BE,
936936
DAILINK_COMP_ARRAY(COMP_CPU("ETDM2_IN")),
937-
DAILINK_COMP_ARRAY(COMP_DUMMY()),
937+
DAILINK_COMP_ARRAY(COMP_EMPTY()),
938938
DAILINK_COMP_ARRAY(COMP_EMPTY()));
939939

940940
SND_SOC_DAILINK_DEFS(ETDM1_OUT_BE,
941941
DAILINK_COMP_ARRAY(COMP_CPU("ETDM1_OUT")),
942-
DAILINK_COMP_ARRAY(COMP_DUMMY()),
943942
DAILINK_COMP_ARRAY(COMP_EMPTY()));
944943

945944
SND_SOC_DAILINK_DEFS(ETDM2_OUT_BE,
@@ -1237,8 +1236,6 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
12371236
SND_SOC_DAIFMT_NB_NF |
12381237
SND_SOC_DAIFMT_CBS_CFS,
12391238
.dpcm_capture = 1,
1240-
.init = mt8195_rt5682_init,
1241-
.ops = &mt8195_rt5682_etdm_ops,
12421239
.be_hw_params_fixup = mt8195_etdm_hw_params_fixup,
12431240
SND_SOC_DAILINK_REG(ETDM2_IN_BE),
12441241
},
@@ -1249,7 +1246,6 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
12491246
SND_SOC_DAIFMT_NB_NF |
12501247
SND_SOC_DAIFMT_CBS_CFS,
12511248
.dpcm_playback = 1,
1252-
.ops = &mt8195_rt5682_etdm_ops,
12531249
.be_hw_params_fixup = mt8195_etdm_hw_params_fixup,
12541250
SND_SOC_DAILINK_REG(ETDM1_OUT_BE),
12551251
},
@@ -1381,7 +1377,7 @@ static int mt8195_mt6359_dev_probe(struct platform_device *pdev)
13811377
struct snd_soc_dai_link *dai_link;
13821378
struct mtk_soc_card_data *soc_card_data;
13831379
struct mt8195_mt6359_priv *mach_priv;
1384-
struct device_node *platform_node, *adsp_node, *dp_node, *hdmi_node;
1380+
struct device_node *platform_node, *adsp_node, *codec_node, *dp_node, *hdmi_node;
13851381
struct mt8195_card_data *card_data;
13861382
int is5682s = 0;
13871383
int init6359 = 0;
@@ -1401,8 +1397,12 @@ static int mt8195_mt6359_dev_probe(struct platform_device *pdev)
14011397
if (!card->name)
14021398
card->name = card_data->name;
14031399

1404-
if (strstr(card->name, "_5682s"))
1400+
if (strstr(card->name, "_5682s")) {
1401+
codec_node = of_find_compatible_node(NULL, NULL, "realtek,rt5682s");
14051402
is5682s = 1;
1403+
} else
1404+
codec_node = of_find_compatible_node(NULL, NULL, "realtek,rt5682i");
1405+
14061406
soc_card_data = devm_kzalloc(&pdev->dev, sizeof(*card_data), GFP_KERNEL);
14071407
if (!soc_card_data)
14081408
return -ENOMEM;
@@ -1488,12 +1488,27 @@ static int mt8195_mt6359_dev_probe(struct platform_device *pdev)
14881488
dai_link->codecs->dai_name = "i2s-hifi";
14891489
dai_link->init = mt8195_hdmi_codec_init;
14901490
}
1491-
} else if (strcmp(dai_link->name, "ETDM1_OUT_BE") == 0 ||
1492-
strcmp(dai_link->name, "ETDM2_IN_BE") == 0) {
1493-
dai_link->codecs->name =
1494-
is5682s ? RT5682S_DEV0_NAME : RT5682_DEV0_NAME;
1495-
dai_link->codecs->dai_name =
1496-
is5682s ? RT5682S_CODEC_DAI : RT5682_CODEC_DAI;
1491+
} else if (strcmp(dai_link->name, "ETDM1_OUT_BE") == 0) {
1492+
if (!codec_node) {
1493+
dev_err(&pdev->dev, "Codec not found!\n");
1494+
} else {
1495+
dai_link->codecs->of_node = codec_node;
1496+
dai_link->codecs->name = NULL;
1497+
dai_link->codecs->dai_name =
1498+
is5682s ? RT5682S_CODEC_DAI : RT5682_CODEC_DAI;
1499+
dai_link->init = mt8195_rt5682_init;
1500+
dai_link->ops = &mt8195_rt5682_etdm_ops;
1501+
}
1502+
} else if (strcmp(dai_link->name, "ETDM2_IN_BE") == 0) {
1503+
if (!codec_node) {
1504+
dev_err(&pdev->dev, "Codec not found!\n");
1505+
} else {
1506+
dai_link->codecs->of_node = codec_node;
1507+
dai_link->codecs->name = NULL;
1508+
dai_link->codecs->dai_name =
1509+
is5682s ? RT5682S_CODEC_DAI : RT5682_CODEC_DAI;
1510+
dai_link->ops = &mt8195_rt5682_etdm_ops;
1511+
}
14971512
} else if (strcmp(dai_link->name, "DL_SRC_BE") == 0 ||
14981513
strcmp(dai_link->name, "UL_SRC1_BE") == 0 ||
14991514
strcmp(dai_link->name, "UL_SRC2_BE") == 0) {

0 commit comments

Comments
 (0)