Skip to content

Commit 1d2a6b3

Browse files
AngeloGioacchino Del Regnobroonie
authored andcommitted
ASoC: mediatek: Use common mtk_afe_pcm_platform with common probe cb
Since the mtk-afe-platform-driver generic mtk_afe_pcm_platform now has a common .probe() callback, there is no reason to keep duplicating this function over and over in the SoC specific AFE-PCM drivers: switch over to register with the common bits instead. Note that MT8186 was left out of this because it is registering some extra sinegen controls in the AFE-PCM probe callback and needs extra cleanups to be able to use the common bits. Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20240416071410.75620-13-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 9d9b182 commit 1d2a6b3

6 files changed

Lines changed: 7 additions & 102 deletions

File tree

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -704,18 +704,6 @@ static int mt6797_afe_runtime_resume(struct device *dev)
704704
return 0;
705705
}
706706

707-
static int mt6797_afe_component_probe(struct snd_soc_component *component)
708-
{
709-
return mtk_afe_add_sub_dai_control(component);
710-
}
711-
712-
static const struct snd_soc_component_driver mt6797_afe_component = {
713-
.name = AFE_PCM_NAME,
714-
.probe = mt6797_afe_component_probe,
715-
.pointer = mtk_afe_pcm_pointer,
716-
.pcm_construct = mtk_afe_pcm_new,
717-
};
718-
719707
static int mt6797_dai_memif_register(struct mtk_base_afe *afe)
720708
{
721709
struct mtk_base_afe_dai *dai;
@@ -852,7 +840,7 @@ static int mt6797_afe_pcm_dev_probe(struct platform_device *pdev)
852840
pm_runtime_get_sync(&pdev->dev);
853841

854842
/* register component */
855-
ret = devm_snd_soc_register_component(dev, &mt6797_afe_component,
843+
ret = devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform,
856844
NULL, 0);
857845
if (ret) {
858846
dev_warn(dev, "err_platform\n");

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,18 +429,6 @@ static int mt7986_afe_runtime_resume(struct device *dev)
429429
return 0;
430430
}
431431

432-
static int mt7986_afe_component_probe(struct snd_soc_component *component)
433-
{
434-
return mtk_afe_add_sub_dai_control(component);
435-
}
436-
437-
static const struct snd_soc_component_driver mt7986_afe_component = {
438-
.name = AFE_PCM_NAME,
439-
.probe = mt7986_afe_component_probe,
440-
.pointer = mtk_afe_pcm_pointer,
441-
.pcm_construct = mtk_afe_pcm_new,
442-
};
443-
444432
static int mt7986_dai_memif_register(struct mtk_base_afe *afe)
445433
{
446434
struct mtk_base_afe_dai *dai;
@@ -573,7 +561,7 @@ static int mt7986_afe_pcm_dev_probe(struct platform_device *pdev)
573561

574562
/* register component */
575563
ret = devm_snd_soc_register_component(&pdev->dev,
576-
&mt7986_afe_component,
564+
&mtk_afe_pcm_platform,
577565
NULL, 0);
578566
if (ret)
579567
return dev_err_probe(dev, ret, "Cannot register AFE component\n");

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,18 +1042,6 @@ static int mt8183_afe_runtime_resume(struct device *dev)
10421042
return 0;
10431043
}
10441044

1045-
static int mt8183_afe_component_probe(struct snd_soc_component *component)
1046-
{
1047-
return mtk_afe_add_sub_dai_control(component);
1048-
}
1049-
1050-
static const struct snd_soc_component_driver mt8183_afe_component = {
1051-
.name = AFE_PCM_NAME,
1052-
.probe = mt8183_afe_component_probe,
1053-
.pointer = mtk_afe_pcm_pointer,
1054-
.pcm_construct = mtk_afe_pcm_new,
1055-
};
1056-
10571045
static int mt8183_dai_memif_register(struct mtk_base_afe *afe)
10581046
{
10591047
struct mtk_base_afe_dai *dai;
@@ -1232,7 +1220,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
12321220

12331221
/* register component */
12341222
ret = devm_snd_soc_register_component(&pdev->dev,
1235-
&mt8183_afe_component,
1223+
&mtk_afe_pcm_platform,
12361224
NULL, 0);
12371225
if (ret) {
12381226
dev_warn(dev, "err_platform\n");

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,25 +3030,6 @@ static int mt8188_afe_runtime_resume(struct device *dev)
30303030
return 0;
30313031
}
30323032

3033-
static int mt8188_afe_component_probe(struct snd_soc_component *component)
3034-
{
3035-
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
3036-
int ret;
3037-
3038-
snd_soc_component_init_regmap(component, afe->regmap);
3039-
3040-
ret = mtk_afe_add_sub_dai_control(component);
3041-
3042-
return ret;
3043-
}
3044-
3045-
static const struct snd_soc_component_driver mt8188_afe_component = {
3046-
.name = AFE_PCM_NAME,
3047-
.pointer = mtk_afe_pcm_pointer,
3048-
.pcm_construct = mtk_afe_pcm_new,
3049-
.probe = mt8188_afe_component_probe,
3050-
};
3051-
30523033
static int init_memif_priv_data(struct mtk_base_afe *afe)
30533034
{
30543035
struct mt8188_afe_private *afe_priv = afe->platform_priv;
@@ -3350,7 +3331,7 @@ static int mt8188_afe_pcm_dev_probe(struct platform_device *pdev)
33503331
}
33513332

33523333
/* register component */
3353-
ret = devm_snd_soc_register_component(dev, &mt8188_afe_component,
3334+
ret = devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform,
33543335
afe->dai_drivers, afe->num_dai_drivers);
33553336
if (ret) {
33563337
dev_warn(dev, "err_platform\n");

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,22 +2125,6 @@ static int mt8192_afe_runtime_resume(struct device *dev)
21252125
return 0;
21262126
}
21272127

2128-
static int mt8192_afe_component_probe(struct snd_soc_component *component)
2129-
{
2130-
return mtk_afe_add_sub_dai_control(component);
2131-
}
2132-
2133-
static const struct snd_soc_component_driver mt8192_afe_component = {
2134-
.name = AFE_PCM_NAME,
2135-
.probe = mt8192_afe_component_probe,
2136-
.pointer = mtk_afe_pcm_pointer,
2137-
.pcm_construct = mtk_afe_pcm_new,
2138-
};
2139-
2140-
static const struct snd_soc_component_driver mt8192_afe_pcm_component = {
2141-
.name = "mt8192-afe-pcm-dai",
2142-
};
2143-
21442128
static int mt8192_dai_memif_register(struct mtk_base_afe *afe)
21452129
{
21462130
struct mtk_base_afe_dai *dai;
@@ -2302,16 +2286,11 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)
23022286

23032287
/* register platform */
23042288
ret = devm_snd_soc_register_component(&pdev->dev,
2305-
&mt8192_afe_component, NULL, 0);
2306-
if (ret)
2307-
return dev_err_probe(dev, ret, "Couldn't register AFE component\n");
2308-
2309-
ret = devm_snd_soc_register_component(&pdev->dev,
2310-
&mt8192_afe_pcm_component,
2289+
&mtk_afe_pcm_platform,
23112290
afe->dai_drivers,
23122291
afe->num_dai_drivers);
23132292
if (ret)
2314-
return dev_err_probe(dev, ret, "Couldn't register AFE-PCM component\n");
2293+
return dev_err_probe(dev, ret, "Couldn't register AFE component\n");
23152294

23162295
return 0;
23172296
}

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2944,25 +2944,6 @@ static int mt8195_afe_runtime_resume(struct device *dev)
29442944
return 0;
29452945
}
29462946

2947-
static int mt8195_afe_component_probe(struct snd_soc_component *component)
2948-
{
2949-
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
2950-
int ret = 0;
2951-
2952-
snd_soc_component_init_regmap(component, afe->regmap);
2953-
2954-
ret = mtk_afe_add_sub_dai_control(component);
2955-
2956-
return ret;
2957-
}
2958-
2959-
static const struct snd_soc_component_driver mt8195_afe_component = {
2960-
.name = AFE_PCM_NAME,
2961-
.pointer = mtk_afe_pcm_pointer,
2962-
.pcm_construct = mtk_afe_pcm_new,
2963-
.probe = mt8195_afe_component_probe,
2964-
};
2965-
29662947
static int init_memif_priv_data(struct mtk_base_afe *afe)
29672948
{
29682949
struct mt8195_afe_private *afe_priv = afe->platform_priv;
@@ -3164,7 +3145,7 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
31643145
}
31653146

31663147
/* register component */
3167-
ret = devm_snd_soc_register_component(dev, &mt8195_afe_component,
3148+
ret = devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform,
31683149
afe->dai_drivers, afe->num_dai_drivers);
31693150
if (ret) {
31703151
dev_warn(dev, "err_platform\n");

0 commit comments

Comments
 (0)