ASoC: mediatek: use helper function
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 31 Jan 2023 02:00:49 +0000 (02:00 +0000)
committerMark Brown <broonie@kernel.org>
Tue, 31 Jan 2023 11:05:02 +0000 (11:05 +0000)
Current ASoC has many helper function.
This patch use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/87sffrea3z.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/mediatek/common/mtk-dsp-sof-common.c
sound/soc/mediatek/mt6797/mt6797-dai-pcm.c
sound/soc/mediatek/mt8183/mt8183-dai-pcm.c
sound/soc/mediatek/mt8186/mt8186-dai-pcm.c
sound/soc/mediatek/mt8188/mt8188-dai-pcm.c
sound/soc/mediatek/mt8192/mt8192-dai-pcm.c
sound/soc/mediatek/mt8195/mt8195-dai-pcm.c

index 8b1b623..6fef163 100644 (file)
@@ -32,7 +32,7 @@ int mtk_sof_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
                                continue;
 
                        for_each_rtd_cpu_dais(runtime, j, cpu_dai) {
-                               if (cpu_dai->stream_active[conn->stream_dir] > 0) {
+                               if (snd_soc_dai_stream_active(cpu_dai, conn->stream_dir) > 0) {
                                        sof_dai_link = runtime->dai_link;
                                        break;
                                }
@@ -111,21 +111,17 @@ int mtk_sof_card_late_probe(struct snd_soc_card *card)
                        for_each_rtd_cpu_dais(sof_rtd, j, cpu_dai) {
                                struct snd_soc_dapm_route route;
                                struct snd_soc_dapm_path *p = NULL;
-                               struct snd_soc_dapm_widget *play_widget =
-                                       cpu_dai->playback_widget;
-                               struct snd_soc_dapm_widget *cap_widget =
-                                       cpu_dai->capture_widget;
+                               struct snd_soc_dapm_widget *widget = snd_soc_dai_get_widget(cpu_dai, conn->stream_dir);
+
                                memset(&route, 0, sizeof(route));
-                               if (conn->stream_dir == SNDRV_PCM_STREAM_CAPTURE &&
-                                   cap_widget) {
-                                       snd_soc_dapm_widget_for_each_sink_path(cap_widget, p) {
+                               if (conn->stream_dir == SNDRV_PCM_STREAM_CAPTURE && widget) {
+                                       snd_soc_dapm_widget_for_each_sink_path(widget, p) {
                                                route.source = conn->sof_dma;
                                                route.sink = p->sink->name;
                                                snd_soc_dapm_add_routes(&card->dapm, &route, 1);
                                        }
-                               } else if (conn->stream_dir == SNDRV_PCM_STREAM_PLAYBACK &&
-                                               play_widget) {
-                                       snd_soc_dapm_widget_for_each_source_path(play_widget, p) {
+                               } else if (conn->stream_dir == SNDRV_PCM_STREAM_PLAYBACK && widget) {
+                                       snd_soc_dapm_widget_for_each_source_path(widget, p) {
                                                route.source = p->source->name;
                                                route.sink = conn->sof_dma;
                                                snd_soc_dapm_add_routes(&card->dapm, &route, 1);
index 51f736f..8a309b0 100644 (file)
@@ -183,6 +183,8 @@ static int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
                                 struct snd_soc_dai *dai)
 {
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+       struct snd_soc_dapm_widget *p = snd_soc_dai_get_widget_playback(dai);
+       struct snd_soc_dapm_widget *c = snd_soc_dai_get_widget_capture(dai);
        unsigned int rate = params_rate(params);
        unsigned int rate_reg = mt6797_rate_transform(afe->dev, rate, dai->id);
        unsigned int pcm_con = 0;
@@ -193,10 +195,10 @@ static int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
                substream->stream,
                rate,
                rate_reg,
-               dai->playback_widget->active,
-               dai->capture_widget->active);
+               p->active,
+               c->active);
 
-       if (dai->playback_widget->active || dai->capture_widget->active)
+       if (p->active || c->active)
                return 0;
 
        switch (dai->id) {
index 38ce0e3..4e25287 100644 (file)
@@ -183,6 +183,8 @@ static int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
                                 struct snd_soc_dai *dai)
 {
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+       struct snd_soc_dapm_widget *p = snd_soc_dai_get_widget_playback(dai);
+       struct snd_soc_dapm_widget *c = snd_soc_dai_get_widget_capture(dai);
        unsigned int rate = params_rate(params);
        unsigned int rate_reg = mt8183_rate_transform(afe->dev, rate, dai->id);
        unsigned int pcm_con = 0;
@@ -193,10 +195,9 @@ static int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
                substream->stream,
                rate,
                rate_reg,
-               dai->playback_widget->active,
-               dai->capture_widget->active);
+               p->active, c->active);
 
-       if (dai->playback_widget->active || dai->capture_widget->active)
+       if (p->active || c->active)
                return 0;
 
        switch (dai->id) {
index 41221a6..a50aa29 100644 (file)
@@ -218,6 +218,8 @@ static int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
 {
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
        struct mt8186_afe_private *afe_priv = afe->platform_priv;
+       struct snd_soc_dapm_widget *p = snd_soc_dai_get_widget_playback(dai);
+       struct snd_soc_dapm_widget *c = snd_soc_dai_get_widget_capture(dai);
        int pcm_id = dai->id;
        struct mtk_afe_pcm_priv *pcm_priv = afe_priv->dai_priv[pcm_id];
        unsigned int rate = params_rate(params);
@@ -230,12 +232,11 @@ static int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
        unsigned int pcm_con = 0;
 
        dev_dbg(afe->dev, "%s(), id %d, stream %d, widget active p %d, c %d\n",
-               __func__, dai->id, substream->stream, dai->playback_widget->active,
-               dai->capture_widget->active);
+               __func__, dai->id, substream->stream, p->active, c->active);
        dev_dbg(afe->dev, "%s(), rate %d, rate_reg %d, data_width %d, wlen_width %d\n",
                __func__, rate, rate_reg, data_width, wlen_width);
 
-       if (dai->playback_widget->active || dai->capture_widget->active)
+       if (p->active || c->active)
                return 0;
 
        switch (dai->id) {
index 3f1696d..5bc854a 100644 (file)
@@ -227,7 +227,8 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
 static int mtk_dai_pcm_prepare(struct snd_pcm_substream *substream,
                               struct snd_soc_dai *dai)
 {
-       if (dai->playback_widget->active || dai->capture_widget->active)
+       if (snd_soc_dai_get_widget_playback(dai)->active ||
+           snd_soc_dai_get_widget_capture(dai)->active)
                return 0;
 
        return mtk_dai_pcm_configure(substream, dai);
index 239e3f5..2847a2e 100644 (file)
@@ -273,6 +273,8 @@ static int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
                                 struct snd_soc_dai *dai)
 {
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+       struct snd_soc_dapm_widget *p = snd_soc_dai_get_widget_playback(dai);
+       struct snd_soc_dapm_widget *c = snd_soc_dai_get_widget_capture(dai);
        unsigned int rate = params_rate(params);
        unsigned int rate_reg = mt8192_rate_transform(afe->dev, rate, dai->id);
        unsigned int pcm_con = 0;
@@ -283,10 +285,10 @@ static int mtk_dai_pcm_hw_params(struct snd_pcm_substream *substream,
                 substream->stream,
                 rate,
                 rate_reg,
-                dai->playback_widget->active,
-                dai->capture_widget->active);
+                p->active,
+                c->active);
 
-       if (dai->playback_widget->active || dai->capture_widget->active)
+       if (p->active || c->active)
                return 0;
 
        switch (dai->id) {
index caceb0d..0514336 100644 (file)
@@ -213,11 +213,14 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
 static int mtk_dai_pcm_prepare(struct snd_pcm_substream *substream,
                               struct snd_soc_dai *dai)
 {
+       struct snd_soc_dapm_widget *p = snd_soc_dai_get_widget_playback(dai);
+       struct snd_soc_dapm_widget *c = snd_soc_dai_get_widget_capture(dai);
+
        dev_dbg(dai->dev, "%s(), id %d, stream %d, widget active p %d, c %d\n",
                __func__, dai->id, substream->stream,
-               dai->playback_widget->active, dai->capture_widget->active);
+               p->active, c->active);
 
-       if (dai->playback_widget->active || dai->capture_widget->active)
+       if (p->active || c->active)
                return 0;
 
        return mtk_dai_pcm_configure(substream, dai);