summaryrefslogtreecommitdiff
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2023-06-26 16:38:02 +0300
committerTakashi Iwai <tiwai@suse.de>2023-06-26 16:38:02 +0300
commitd6048fdc870240e5020343f8af0c825829c232bd (patch)
treed83ca76eaac5f8bf1c4c16f003aad64baa8fae62 /sound/soc/soc-dapm.c
parenta15b51375684c2bfa6017bb185139477e7a3b96c (diff)
parent2d0cad0473bd1ffbc5842be0b9f2546265acb011 (diff)
downloadlinux-d6048fdc870240e5020343f8af0c825829c232bd.tar.xz
Merge tag 'asoc-v6.5' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Updates for v6.5 A fairly quiet release from a core and framework point of view, but a very big one from the point of view of new drivers: - More refectoring from Morimoto-san, this time mainly around DAI links and how we control the ordering of trigger() callbacks. - Convert a lot of drivers to use maple tree based caches. - Lots of work on the x86 driver stack. - Compressed audio support for Qualcomm. - Support for AMD SoundWire, Analog Devices SSM3515, Google Chameleon, Ingenic X1000, Intel systems with various CODECs, Longsoon platforms, Maxim MAX98388, Mediatek MT8188, Nuvoton NAU8825C, NXP platforms with NAU8822, Qualcomm WSA884x, StarFive JH7110, Texas Instruments TAS2781.
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c75
1 files changed, 40 insertions, 35 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f2f04ce693a1..3091e8160bad 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2216,6 +2216,16 @@ static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
&dapm_widget_power_fops);
}
+static void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w)
+{
+ struct snd_soc_dapm_context *dapm = w->dapm;
+
+ if (!dapm->debugfs_dapm || !w->name)
+ return;
+
+ debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm);
+}
+
static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
{
debugfs_remove_recursive(dapm->debugfs_dapm);
@@ -2232,6 +2242,10 @@ static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
{
}
+static inline void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w)
+{
+}
+
static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
{
}
@@ -2495,6 +2509,8 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)
dapm_free_path(p);
}
+ dapm_debugfs_free_widget(w);
+
kfree(w->kcontrols);
kfree_const(w->name);
kfree_const(w->sname);
@@ -4322,39 +4338,6 @@ static void dapm_connect_dai_routes(struct snd_soc_dapm_context *dapm,
snd_soc_dapm_add_path(dapm, src, sink, NULL, NULL);
}
-static int get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream)
-{
- /*
- * [Normal]
- *
- * Playback
- * CPU : SNDRV_PCM_STREAM_PLAYBACK
- * Codec: SNDRV_PCM_STREAM_PLAYBACK
- *
- * Playback
- * CPU : SNDRV_PCM_STREAM_CAPTURE
- * Codec: SNDRV_PCM_STREAM_CAPTURE
- */
- if (!dai_link->c2c_params)
- return stream;
-
- /*
- * [Codec2Codec]
- *
- * Playback
- * CPU : SNDRV_PCM_STREAM_CAPTURE
- * Codec: SNDRV_PCM_STREAM_PLAYBACK
- *
- * Capture
- * CPU : SNDRV_PCM_STREAM_PLAYBACK
- * Codec: SNDRV_PCM_STREAM_CAPTURE
- */
- if (stream == SNDRV_PCM_STREAM_CAPTURE)
- return SNDRV_PCM_STREAM_PLAYBACK;
-
- return SNDRV_PCM_STREAM_CAPTURE;
-}
-
static void dapm_connect_dai_pair(struct snd_soc_card *card,
struct snd_soc_pcm_runtime *rtd,
struct snd_soc_dai *codec_dai,
@@ -4372,7 +4355,7 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
for_each_pcm_streams(stream) {
int stream_cpu, stream_codec;
- stream_cpu = get_stream_cpu(dai_link, stream);
+ stream_cpu = snd_soc_get_stream_cpu(dai_link, stream);
stream_codec = stream;
/* connect BE DAI playback if widgets are valid */
@@ -4461,9 +4444,31 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
for_each_rtd_codec_dais(rtd, i, codec_dai)
dapm_connect_dai_pair(card, rtd, codec_dai,
asoc_rtd_to_cpu(rtd, i));
+ } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) {
+ int cpu_id;
+
+ if (!rtd->dai_link->codec_ch_maps) {
+ dev_err(card->dev, "%s: no codec channel mapping table provided\n",
+ __func__);
+ continue;
+ }
+
+ for_each_rtd_codec_dais(rtd, i, codec_dai) {
+ cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id;
+ if (cpu_id >= rtd->dai_link->num_cpus) {
+ dev_err(card->dev,
+ "%s: dai_link %s cpu_id %d too large, num_cpus is %d\n",
+ __func__, rtd->dai_link->name, cpu_id,
+ rtd->dai_link->num_cpus);
+ continue;
+ }
+ dapm_connect_dai_pair(card, rtd, codec_dai,
+ asoc_rtd_to_cpu(rtd, cpu_id));
+ }
} else {
dev_err(card->dev,
- "N cpus to M codecs link is not supported yet\n");
+ "%s: codec number %d < cpu number %d is not supported\n",
+ __func__, rtd->dai_link->num_codecs, rtd->dai_link->num_cpus);
}
}
}