From: KaiChieh Chuang <kaichieh.chuang@mediatek.com>
To: broonie@kernel.org
Cc: alsa-devel@alsa-project.org, garlic.tseng@mediatek.com,
linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com,
kaichieh.chuang@mediatek.com
Subject: [PATCH 3/3] ASoC: mt6797: combine DAI to register component
Date: Fri, 25 May 2018 11:17:54 +0800 [thread overview]
Message-ID: <1527218274-27699-3-git-send-email-kaichieh.chuang@mediatek.com> (raw)
In-Reply-To: <1527218274-27699-1-git-send-email-kaichieh.chuang@mediatek.com>
Signed-off-by: KaiChieh Chuang <kaichieh.chuang@mediatek.com>
---
.../soc/mediatek/common/mtk-afe-platform-driver.c | 6 +--
.../soc/mediatek/common/mtk-afe-platform-driver.h | 6 +++
sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 53 ++++++++++++++++++----
3 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
index c449188..0061858 100644
--- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c
+++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
@@ -126,12 +126,12 @@ int mtk_afe_add_sub_dai_control(struct snd_soc_component *component)
return bytes_to_frames(substream->runtime, pcm_ptr_bytes);
}
-static const struct snd_pcm_ops mtk_afe_pcm_ops = {
+const struct snd_pcm_ops mtk_afe_pcm_ops = {
.ioctl = snd_pcm_lib_ioctl,
.pointer = mtk_afe_pcm_pointer,
};
-static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
+int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
size_t size;
struct snd_pcm *pcm = rtd->pcm;
@@ -144,7 +144,7 @@ static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
size, size);
}
-static void mtk_afe_pcm_free(struct snd_pcm *pcm)
+void mtk_afe_pcm_free(struct snd_pcm *pcm)
{
snd_pcm_lib_preallocate_free_for_all(pcm);
}
diff --git a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c
index c892b7f..1286c6e 100644
--- a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c
+++ b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c
@@ -172,7 +172,7 @@ static int mt6797_irq_fs(struct snd_pcm_substream *substream, unsigned int rate)
SNDRV_PCM_FMTBIT_S24_LE |\
SNDRV_PCM_FMTBIT_S32_LE)
-static struct snd_soc_dai_driver mt6797_afe_pcm_dais[] = {
+static struct snd_soc_dai_driver mt6797_memif_dai_driver[] = {
/* FE DAIs: memory intefaces to CPU */
{
.name = "DL1",
@@ -329,7 +329,7 @@ static int mt6797_irq_fs(struct snd_pcm_substream *substream, unsigned int rate)
I_ADDA_UL_CH2, 1, 0),
};
-static const struct snd_soc_dapm_widget mt6797_afe_pcm_widgets[] = {
+static const struct snd_soc_dapm_widget mt6797_memif_widgets[] = {
/* memif */
SND_SOC_DAPM_MIXER("UL1_CH1", SND_SOC_NOPM, 0, 0,
memif_ul1_ch1_mix, ARRAY_SIZE(memif_ul1_ch1_mix)),
@@ -355,7 +355,7 @@ static int mt6797_irq_fs(struct snd_pcm_substream *substream, unsigned int rate)
ARRAY_SIZE(memif_ul_mono_2_mix)),
};
-static const struct snd_soc_dapm_route mt6797_afe_pcm_routes[] = {
+static const struct snd_soc_dapm_route mt6797_memif_routes[] = {
/* capture */
{"UL1", NULL, "UL1_CH1"},
{"UL1", NULL, "UL1_CH2"},
@@ -383,10 +383,6 @@ static int mt6797_irq_fs(struct snd_pcm_substream *substream, unsigned int rate)
static const struct snd_soc_component_driver mt6797_afe_pcm_dai_component = {
.name = "mt6797-afe-pcm-dai",
- .dapm_widgets = mt6797_afe_pcm_widgets,
- .num_dapm_widgets = ARRAY_SIZE(mt6797_afe_pcm_widgets),
- .dapm_routes = mt6797_afe_pcm_routes,
- .num_dapm_routes = ARRAY_SIZE(mt6797_afe_pcm_routes),
};
static const struct mtk_base_memif_data memif_data[MT6797_MEMIF_NUM] = {
@@ -724,6 +720,19 @@ static int mt6797_afe_runtime_resume(struct device *dev)
return 0;
}
+static int mt6797_afe_component_probe(struct snd_soc_component *component)
+{
+ return mtk_afe_add_sub_dai_control(component);
+}
+
+static const struct snd_soc_component_driver mt6797_afe_component = {
+ .name = AFE_PCM_NAME,
+ .ops = &mtk_afe_pcm_ops,
+ .pcm_new = mtk_afe_pcm_new,
+ .pcm_free = mtk_afe_pcm_free,
+ .probe = mt6797_afe_component_probe,
+};
+
static int mt6797_afe_pcm_dev_probe(struct platform_device *pdev)
{
struct mtk_base_afe *afe;
@@ -801,6 +810,29 @@ static int mt6797_afe_pcm_dev_probe(struct platform_device *pdev)
return ret;
}
+ /* init sub_dais */
+ afe->num_sub_dais = MT6797_DAI_NUM;
+ afe->sub_dais = devm_kcalloc(dev, afe->num_sub_dais,
+ sizeof(*afe->sub_dais),
+ GFP_KERNEL);
+ if (!afe->sub_dais)
+ return -ENOMEM;
+
+ mt6797_dai_adda_register(afe);
+
+ afe->sub_dais[MT6797_MEMIF_DL1].dai_drivers = mt6797_memif_dai_driver;
+ afe->sub_dais[MT6797_MEMIF_DL1].num_dai_drivers =
+ ARRAY_SIZE(mt6797_memif_dai_driver);
+ afe->sub_dais[MT6797_MEMIF_DL1].dapm_widgets = mt6797_memif_widgets;
+ afe->sub_dais[MT6797_MEMIF_DL1].num_dapm_widgets =
+ ARRAY_SIZE(mt6797_memif_widgets);
+ afe->sub_dais[MT6797_MEMIF_DL1].dapm_routes = mt6797_memif_routes;
+ afe->sub_dais[MT6797_MEMIF_DL1].num_dapm_routes =
+ ARRAY_SIZE(mt6797_memif_routes);
+
+ /* init dai_driver and component_driver */
+ mtk_afe_combine_sub_dai(afe);
+
afe->mtk_afe_hardware = &mt6797_afe_hardware;
afe->memif_fs = mt6797_memif_fs;
afe->irq_fs = mt6797_irq_fs;
@@ -815,7 +847,8 @@ static int mt6797_afe_pcm_dev_probe(struct platform_device *pdev)
goto err_pm_disable;
pm_runtime_get_sync(&pdev->dev);
- ret = devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform,
+ /* register component */
+ ret = devm_snd_soc_register_component(dev, &mt6797_afe_component,
NULL, 0);
if (ret) {
dev_warn(dev, "err_platform\n");
@@ -824,8 +857,8 @@ static int mt6797_afe_pcm_dev_probe(struct platform_device *pdev)
ret = devm_snd_soc_register_component(afe->dev,
&mt6797_afe_pcm_dai_component,
- mt6797_afe_pcm_dais,
- ARRAY_SIZE(mt6797_afe_pcm_dais));
+ afe->dai_drivers,
+ afe->num_dai_drivers);
if (ret) {
dev_warn(dev, "err_dai_component\n");
goto err_pm_disable;
--
1.9.1
next prev parent reply other threads:[~2018-05-25 3:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-25 3:17 [PATCH 1/3] ASoC: mediatek: add sub dai to mtk_base_afe KaiChieh Chuang
2018-05-25 3:17 ` [PATCH 2/3] ASoC: mt6797: extract DAI adda in separate file KaiChieh Chuang
2018-05-25 17:36 ` Applied "ASoC: mt6797: extract DAI adda in separate file" to the asoc tree Mark Brown
2018-05-25 3:17 ` KaiChieh Chuang [this message]
2018-05-25 11:51 ` [PATCH 3/3] ASoC: mt6797: combine DAI to register component kbuild test robot
2018-05-25 17:36 ` Applied "ASoC: mediatek: add sub dai to mtk_base_afe" to the asoc tree Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1527218274-27699-3-git-send-email-kaichieh.chuang@mediatek.com \
--to=kaichieh.chuang@mediatek.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=garlic.tseng@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=wsd_upstream@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).