summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-09-09 16:42:41 +0100
committerMark Brown <broonie@kernel.org>2026-09-09 16:42:41 +0100
commit18d4051964614782fa46789a219e4eae12850c12 (patch)
treeb5e0581f60f1492659cff719f4667c9558bb7742
parent9c343445b349422bddebb4cb9668c246bc6f08de (diff)
parentd9ed2b5a7b2a6195557158db953e4bce39d029b5 (diff)
downloadlinux-next-18d4051964614782fa46789a219e4eae12850c12.tar.gz
linux-next-18d4051964614782fa46789a219e4eae12850c12.zip
ASoC: soc-dai: move snd_soc_xx() to soc-dai.c
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> says: This patch-set moves soc-dai related functions from soc-core.c to soc-dai.c. We should have snd_soc_dai_xxx() functions on soc-dai.c. No functional changes. We have 2 type of function defines in include/sound/xx.h A is for ASoC drivers B is for ASoC framwork I think include/sound/xx.h is only for drivers (A). In other words, ASoC framework function (B) is not needed for drivers, or *shouldn't* indicate to drivers. This patch adds new sound/soc/soc-internal.h, and the functions for ASoC framework will be moved to here. Link: https://patch.msgid.link/8733vuu75t.wl-kuninori.morimoto.gx@renesas.com
-rw-r--r--include/sound/soc-dai.h166
-rw-r--r--include/sound/soc.h16
-rw-r--r--sound/soc/generic/simple-card-utils.c2
-rw-r--r--sound/soc/generic/simple-card.c2
-rw-r--r--sound/soc/soc-compress.c5
-rw-r--r--sound/soc/soc-core.c173
-rw-r--r--sound/soc/soc-dai.c342
-rw-r--r--sound/soc/soc-internal.h36
-rw-r--r--sound/soc/soc-pcm.c123
9 files changed, 487 insertions, 378 deletions
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index ba3ae56c6b06..7e64e049d71d 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -213,7 +213,8 @@ int snd_soc_dai_get_channel_map(const struct snd_soc_dai *dai,
unsigned int *rx_num, unsigned int *rx_slot);
int snd_soc_dai_is_dummy(const struct snd_soc_dai *dai);
-
+int snd_soc_dai_add_controls(struct snd_soc_dai *dai,
+ const struct snd_kcontrol_new *controls, int num_controls);
int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params);
@@ -277,7 +278,11 @@ int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata);
-const char *snd_soc_dai_name_get(const struct snd_soc_dai *dai);
+int snd_soc_dai_matches_args(const struct snd_soc_dai *dai,
+ const struct of_phandle_args *args2);
+int snd_soc_dai_matches_dlc(struct snd_soc_dai *dai,
+ const struct snd_soc_dai_link_component *dlc);
+const char *snd_soc_dai_name(const struct snd_soc_dai *dai);
struct snd_soc_dai_ops {
/* DAI driver callbacks */
@@ -489,69 +494,51 @@ struct snd_soc_dai {
void *priv;
};
+const struct snd_soc_pcm_stream *
+snd_soc_dai_pcm_stream_get_i(const struct snd_soc_dai *dai, int stream);
static inline const struct snd_soc_pcm_stream *
-snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream)
+snd_soc_dai_pcm_stream_get_s(const struct snd_soc_dai *dai, struct snd_pcm_substream *substream)
{
- return (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
- &dai->driver->playback : &dai->driver->capture;
+ return snd_soc_dai_pcm_stream_get_i(dai, substream->stream);
}
-
-#define snd_soc_dai_get_widget_playback(dai) snd_soc_dai_get_widget(dai, SNDRV_PCM_STREAM_PLAYBACK)
-#define snd_soc_dai_get_widget_capture(dai) snd_soc_dai_get_widget(dai, SNDRV_PCM_STREAM_CAPTURE)
-static inline
-struct snd_soc_dapm_widget *snd_soc_dai_get_widget(struct snd_soc_dai *dai, int stream)
+#define snd_soc_dai_pcm_stream_get(dai, x) _Generic((x), \
+ int : snd_soc_dai_pcm_stream_get_i, \
+ struct snd_pcm_substream * : snd_soc_dai_pcm_stream_get_s)(dai, x)
+
+#define snd_soc_dai_stream_widget_get_playback(dai) snd_soc_dai_stream_widget_get(dai, SNDRV_PCM_STREAM_PLAYBACK)
+#define snd_soc_dai_stream_widget_get_capture(dai) snd_soc_dai_stream_widget_get(dai, SNDRV_PCM_STREAM_CAPTURE)
+struct snd_soc_dapm_widget *snd_soc_dai_stream_widget_get(struct snd_soc_dai *dai, int stream);
+
+#define snd_soc_dai_stream_widget_set_playback(dai, widget) snd_soc_dai_stream_widget_set(dai, SNDRV_PCM_STREAM_PLAYBACK, widget)
+#define snd_soc_dai_stream_widget_set_capture(dai, widget) snd_soc_dai_stream_widget_set(dai, SNDRV_PCM_STREAM_CAPTURE, widget)
+void snd_soc_dai_stream_widget_set(struct snd_soc_dai *dai, int stream, struct snd_soc_dapm_widget *widget);
+
+#define snd_soc_dai_stream_dma_data_get_playback(dai) snd_soc_dai_stream_dma_data_get(dai, SNDRV_PCM_STREAM_PLAYBACK)
+#define snd_soc_dai_stream_dma_data_get_capture(dai) snd_soc_dai_stream_dma_data_get(dai, SNDRV_PCM_STREAM_CAPTURE)
+void *snd_soc_dai_stream_dma_data_get_i(const struct snd_soc_dai *dai, int stream);
+static inline void *snd_soc_dai_stream_dma_data_get_s(const struct snd_soc_dai *dai, struct snd_pcm_substream *substream)
{
- return dai->stream[stream].widget;
+ return snd_soc_dai_stream_dma_data_get_i(dai, substream->stream);
}
-
-#define snd_soc_dai_set_widget_playback(dai, widget) snd_soc_dai_set_widget(dai, SNDRV_PCM_STREAM_PLAYBACK, widget)
-#define snd_soc_dai_set_widget_capture(dai, widget) snd_soc_dai_set_widget(dai, SNDRV_PCM_STREAM_CAPTURE, widget)
-static inline
-void snd_soc_dai_set_widget(struct snd_soc_dai *dai, int stream, struct snd_soc_dapm_widget *widget)
+#define snd_soc_dai_stream_dma_data_get(dai, x) _Generic((x), \
+ int : snd_soc_dai_stream_dma_data_get_i, \
+ struct snd_pcm_substream * : snd_soc_dai_stream_dma_data_get_s)(dai, x)
+
+#define snd_soc_dai_stream_dma_data_set_playback(dai, data) snd_soc_dai_stream_dma_data_set(dai, SNDRV_PCM_STREAM_PLAYBACK, data)
+#define snd_soc_dai_stream_dma_data_set_capture(dai, data) snd_soc_dai_stream_dma_data_set(dai, SNDRV_PCM_STREAM_CAPTURE, data)
+void snd_soc_dai_stream_dma_data_set_i(struct snd_soc_dai *dai, int stream, void *data);
+static inline void snd_soc_dai_stream_dma_data_set_s(struct snd_soc_dai *dai, struct snd_pcm_substream *substream, void *data)
{
- dai->stream[stream].widget = widget;
+ snd_soc_dai_stream_dma_data_set_i(dai, substream->stream, data);
}
+#define snd_soc_dai_stream_dma_data_set(dai, x, data) _Generic((x), \
+ int : snd_soc_dai_stream_dma_data_set_i, \
+ struct snd_pcm_substream * : snd_soc_dai_stream_dma_data_set_s)(dai, x, data)
-#define snd_soc_dai_dma_data_get_playback(dai) snd_soc_dai_dma_data_get(dai, SNDRV_PCM_STREAM_PLAYBACK)
-#define snd_soc_dai_dma_data_get_capture(dai) snd_soc_dai_dma_data_get(dai, SNDRV_PCM_STREAM_CAPTURE)
-#define snd_soc_dai_get_dma_data(dai, ss) snd_soc_dai_dma_data_get(dai, ss->stream)
-static inline void *snd_soc_dai_dma_data_get(const struct snd_soc_dai *dai, int stream)
-{
- return dai->stream[stream].dma_data;
-}
+unsigned int snd_soc_dai_stream_tdm_mask_get(const struct snd_soc_dai *dai, int stream);
+void snd_soc_dai_stream_tdm_mask_set(struct snd_soc_dai *dai, int stream, unsigned int tdm_mask);
-#define snd_soc_dai_dma_data_set_playback(dai, data) snd_soc_dai_dma_data_set(dai, SNDRV_PCM_STREAM_PLAYBACK, data)
-#define snd_soc_dai_dma_data_set_capture(dai, data) snd_soc_dai_dma_data_set(dai, SNDRV_PCM_STREAM_CAPTURE, data)
-#define snd_soc_dai_set_dma_data(dai, ss, data) snd_soc_dai_dma_data_set(dai, ss->stream, data)
-static inline void snd_soc_dai_dma_data_set(struct snd_soc_dai *dai, int stream, void *data)
-{
- dai->stream[stream].dma_data = data;
-}
-
-static inline void snd_soc_dai_init_dma_data(struct snd_soc_dai *dai, void *playback, void *capture)
-{
- snd_soc_dai_dma_data_set_playback(dai, playback);
- snd_soc_dai_dma_data_set_capture(dai, capture);
-}
-
-static inline unsigned int snd_soc_dai_tdm_mask_get(const struct snd_soc_dai *dai,
- int stream)
-{
- return dai->stream[stream].tdm_mask;
-}
-
-static inline void snd_soc_dai_tdm_mask_set(struct snd_soc_dai *dai, int stream,
- unsigned int tdm_mask)
-{
- dai->stream[stream].tdm_mask = tdm_mask;
-}
-
-static inline unsigned int snd_soc_dai_stream_active(const struct snd_soc_dai *dai,
- int stream)
-{
- /* see snd_soc_dai_action() for setup */
- return dai->stream[stream].active;
-}
+unsigned int snd_soc_dai_stream_active(const struct snd_soc_dai *dai, int stream);
static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai,
void *data)
@@ -564,45 +551,36 @@ static inline void *snd_soc_dai_get_drvdata(struct snd_soc_dai *dai)
return dev_get_drvdata(dai->dev);
}
-/**
- * snd_soc_dai_set_stream() - Configures a DAI for stream operation
- * @dai: DAI
- * @stream: STREAM (opaque structure depending on DAI type)
- * @direction: Stream direction(Playback/Capture)
- * Some subsystems, such as SoundWire, don't have a notion of direction and we reuse
- * the ASoC stream direction to configure sink/source ports.
- * Playback maps to source ports and Capture for sink ports.
- *
- * This should be invoked with NULL to clear the stream set previously.
- * Returns 0 on success, a negative error code otherwise.
- */
-static inline int snd_soc_dai_set_stream(struct snd_soc_dai *dai,
- void *stream, int direction)
-{
- if (dai->driver->ops->set_stream)
- return dai->driver->ops->set_stream(dai, stream, direction);
- else
- return -ENOTSUPP;
-}
-
-/**
- * snd_soc_dai_get_stream() - Retrieves stream from DAI
- * @dai: DAI
- * @direction: Stream direction(Playback/Capture)
- *
- * This routine only retrieves that was previously configured
- * with snd_soc_dai_get_stream()
- *
- * Returns pointer to stream or an ERR_PTR value, e.g.
- * ERR_PTR(-ENOTSUPP) if callback is not supported;
- */
-static inline void *snd_soc_dai_get_stream(struct snd_soc_dai *dai,
- int direction)
+int snd_soc_dai_set_stream(struct snd_soc_dai *dai, void *stream, int direction);
+void *snd_soc_dai_get_stream(struct snd_soc_dai *dai, int direction);
+
+struct snd_soc_dai *snd_soc_dai_register(struct snd_soc_component *component,
+ struct snd_soc_dai_driver *dai_drv,
+ bool legacy_dai_naming);
+void snd_soc_dai_unregister(struct snd_soc_dai *dai);
+
+/* REMOVE ME */
+#define snd_soc_dai_get_pcm_stream snd_soc_dai_pcm_stream_get
+#define snd_soc_dai_get_widget_playback(dai) snd_soc_dai_stream_widget_get(dai, SNDRV_PCM_STREAM_PLAYBACK)
+#define snd_soc_dai_get_widget_capture(dai) snd_soc_dai_stream_widget_get(dai, SNDRV_PCM_STREAM_CAPTURE)
+#define snd_soc_dai_get_widget snd_soc_dai_stream_widget_get
+#define snd_soc_dai_set_widget_playback(dai, widget) snd_soc_dai_stream_widget_set(dai, SNDRV_PCM_STREAM_PLAYBACK, widget)
+#define snd_soc_dai_set_widget_capture(dai, widget) snd_soc_dai_stream_widget_set(dai, SNDRV_PCM_STREAM_CAPTURE, widget)
+#define snd_soc_dai_set_widget snd_soc_dai_stream_widget_set
+#define snd_soc_dai_dma_data_get_playback(dai) snd_soc_dai_stream_dma_data_get(dai, SNDRV_PCM_STREAM_PLAYBACK)
+#define snd_soc_dai_dma_data_get_capture(dai) snd_soc_dai_stream_dma_data_get(dai, SNDRV_PCM_STREAM_CAPTURE)
+#define snd_soc_dai_get_dma_data snd_soc_dai_stream_dma_data_get
+#define snd_soc_dai_dma_data_get snd_soc_dai_stream_dma_data_get
+#define snd_soc_dai_dma_data_set_playback(dai, data) snd_soc_dai_stream_dma_data_set(dai, SNDRV_PCM_STREAM_PLAYBACK, data)
+#define snd_soc_dai_dma_data_set_capture(dai, data) snd_soc_dai_stream_dma_data_set(dai, SNDRV_PCM_STREAM_CAPTURE, data)
+#define snd_soc_dai_set_dma_data snd_soc_dai_stream_dma_data_set
+#define snd_soc_dai_dma_data_set snd_soc_dai_stream_dma_data_set
+#define snd_soc_dai_tdm_mask_get snd_soc_dai_stream_tdm_mask_get
+#define snd_soc_dai_tdm_mask_set snd_soc_dai_stream_tdm_mask_set
+static inline void snd_soc_dai_init_dma_data(struct snd_soc_dai *dai, void *playback, void *capture)
{
- if (dai->driver->ops->get_stream)
- return dai->driver->ops->get_stream(dai, direction);
- else
- return ERR_PTR(-ENOTSUPP);
+ snd_soc_dai_stream_dma_data_set_playback(dai, playback);
+ snd_soc_dai_stream_dma_data_set_capture(dai, capture);
}
#endif
diff --git a/include/sound/soc.h b/include/sound/soc.h
index f46b2bc2a022..25fecbe50d99 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -555,8 +555,6 @@ int snd_soc_add_component_controls(struct snd_soc_component *component,
const struct snd_kcontrol_new *controls, unsigned int num_controls);
int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
const struct snd_kcontrol_new *controls, int num_controls);
-int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
- const struct snd_kcontrol_new *controls, int num_controls);
int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo);
int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
@@ -1388,19 +1386,12 @@ void snd_soc_dlc_use_cpu_as_platform(struct snd_soc_dai_link_component *platform
struct of_phandle_args *snd_soc_copy_dai_args(struct device *dev,
const struct of_phandle_args *args);
struct snd_soc_dai *snd_soc_get_dai_via_args(const struct of_phandle_args *dai_args);
-struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
- struct snd_soc_dai_driver *dai_drv,
- bool legacy_dai_naming);
-void snd_soc_unregister_dai(struct snd_soc_dai *dai);
struct snd_soc_dai *snd_soc_find_dai(
const struct snd_soc_dai_link_component *dlc);
struct snd_soc_dai *snd_soc_find_dai_with_mutex(
const struct snd_soc_dai_link_component *dlc);
-void soc_pcm_set_dai_params(struct snd_soc_dai *dai,
- struct snd_pcm_hw_params *params);
-
#include <sound/soc-dai.h>
static inline
@@ -1550,4 +1541,11 @@ static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime
#include <sound/soc-card.h>
#include <sound/soc-jack.h>
+/*
+ * REMOVE ME
+ */
+#define snd_soc_add_dai_controls snd_soc_dai_add_controls
+#define snd_soc_register_dai snd_soc_dai_register
+#define snd_soc_unregister_dai snd_soc_dai_unregister
+
#endif
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 5f3423129b13..7df5253499cd 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -1116,7 +1116,7 @@ int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep,
args.np = ep;
dai = snd_soc_get_dai_via_args(&args);
if (dai) {
- const char *dai_name = snd_soc_dai_name_get(dai);
+ const char *dai_name = snd_soc_dai_name(dai);
const struct of_phandle_args *dai_args = snd_soc_copy_dai_args(dev, &args);
ret = -ENOMEM;
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index e7ad7af04714..0a769c177149 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -92,7 +92,7 @@ static int simple_parse_dai(struct simple_util_priv *priv,
dai = snd_soc_get_dai_via_args(&args);
if (dai) {
ret = -ENOMEM;
- dlc->dai_name = snd_soc_dai_name_get(dai);
+ dlc->dai_name = snd_soc_dai_name(dai);
dlc->dai_args = snd_soc_copy_dai_args(dev, &args);
if (!dlc->dai_args)
goto end;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index b8402802ae78..093a70a93d2b 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -20,6 +20,7 @@
#include <sound/initval.h>
#include <sound/soc-dpcm.h>
#include <sound/soc-link.h>
+#include "soc-internal.h"
static int snd_soc_compr_components_open(struct snd_compr_stream *cstream)
{
@@ -69,10 +70,10 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
snd_soc_dai_digital_mute(codec_dai, 1, stream);
if (!snd_soc_dai_active(cpu_dai))
- soc_pcm_set_dai_params(cpu_dai, NULL);
+ snd_soc_dai_symmetric_set_params(cpu_dai, NULL);
if (!snd_soc_dai_active(codec_dai))
- soc_pcm_set_dai_params(codec_dai, NULL);
+ snd_soc_dai_symmetric_set_params(codec_dai, NULL);
snd_soc_link_compr_shutdown(cstream, rollback);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8149981f0dc2..06167a198591 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -41,11 +41,13 @@
#include <sound/soc-topology.h>
#include <sound/soc-link.h>
#include <sound/initval.h>
+#include "soc-internal.h"
#define CREATE_TRACE_POINTS
#include <trace/events/asoc.h>
-static DEFINE_MUTEX(client_mutex);
+DEFINE_MUTEX(client_mutex);
+
static LIST_HEAD(component_list);
static LIST_HEAD(unbind_card_list);
@@ -232,22 +234,6 @@ static inline void snd_soc_debugfs_exit(void) { }
#endif
-static int snd_soc_is_match_dai_args(const struct of_phandle_args *args1,
- const struct of_phandle_args *args2)
-{
- if (!args1 || !args2)
- return 0;
-
- if (args1->np != args2->np)
- return 0;
-
- for (int i = 0; i < args1->args_count; i++)
- if (args1->args[i] != args2->args[i])
- return 0;
-
- return 1;
-}
-
static inline int snd_soc_dlc_component_is_empty(struct snd_soc_dai_link_component *dlc)
{
return !(dlc->dai_args || dlc->name || dlc->of_node);
@@ -263,50 +249,6 @@ static inline int snd_soc_dlc_dai_is_empty(struct snd_soc_dai_link_component *dl
return !(dlc->dai_args || dlc->dai_name);
}
-static int snd_soc_is_matching_dai(const struct snd_soc_dai_link_component *dlc,
- struct snd_soc_dai *dai)
-{
- if (!dlc)
- return 0;
-
- if (dlc->dai_args)
- return snd_soc_is_match_dai_args(dai->driver->dai_args, dlc->dai_args);
-
- if (!dlc->dai_name)
- return 1;
-
- /* see snd_soc_dai_name_get() */
-
- if (dai->driver->name &&
- strcmp(dlc->dai_name, dai->driver->name) == 0)
- return 1;
-
- if (strcmp(dlc->dai_name, dai->name) == 0)
- return 1;
-
- if (dai->component->name &&
- strcmp(dlc->dai_name, dai->component->name) == 0)
- return 1;
-
- return 0;
-}
-
-const char *snd_soc_dai_name_get(const struct snd_soc_dai *dai)
-{
- /* see snd_soc_is_matching_dai() */
- if (dai->driver->name)
- return dai->driver->name;
-
- if (dai->name)
- return dai->name;
-
- if (dai->component->name)
- return dai->component->name;
-
- return NULL;
-}
-EXPORT_SYMBOL_GPL(snd_soc_dai_name_get);
-
static int snd_soc_rtd_add_component(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_component *component)
{
@@ -868,7 +810,7 @@ static int snd_soc_is_matching_component(
struct snd_soc_dai *dai;
for_each_component_dais(component, dai)
- if (snd_soc_is_matching_dai(dlc, dai))
+ if (snd_soc_dai_matches_dlc(dai, dlc))
return 1;
return 0;
}
@@ -928,7 +870,7 @@ struct snd_soc_dai *snd_soc_find_dai(
for_each_component(component)
if (snd_soc_is_matching_component(dlc, component))
for_each_component_dais(component, dai)
- if (snd_soc_is_matching_dai(dlc, dai))
+ if (snd_soc_dai_matches_dlc(dai, dlc))
return dai;
return NULL;
@@ -2343,9 +2285,9 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
}
EXPORT_SYMBOL_GPL(snd_soc_cnew);
-static int snd_soc_add_controls(struct snd_card *card, struct device *dev,
- const struct snd_kcontrol_new *controls, int num_controls,
- const char *prefix, void *data)
+int snd_soc_add_controls(struct snd_card *card, struct device *dev,
+ const struct snd_kcontrol_new *controls, int num_controls,
+ const char *prefix, void *data)
{
int i;
@@ -2403,26 +2345,6 @@ int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
EXPORT_SYMBOL_GPL(snd_soc_add_card_controls);
/**
- * snd_soc_add_dai_controls - add an array of controls to a DAI.
- * Convenience function to add a list of controls.
- *
- * @dai: DAI to add controls to
- * @controls: array of controls to add
- * @num_controls: number of elements in the array
- *
- * Return 0 for success, else error.
- */
-int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
- const struct snd_kcontrol_new *controls, int num_controls)
-{
- struct snd_card *card = dai->component->card->snd_card;
-
- return snd_soc_add_controls(card, dai->dev, controls, num_controls,
- NULL, dai);
-}
-EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
-
-/**
* snd_soc_register_card - Register a card with the ASoC core
*
* @card: Card to register
@@ -2480,7 +2402,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_card);
* Simplify DAI link configuration by removing ".-1" from device names
* and sanitizing names.
*/
-static char *fmt_single_name(struct device *dev, int *id)
+char *snd_soc_fmt_single_name(struct device *dev, int *id)
{
const char *devname = dev_name(dev);
char *found, *name;
@@ -2529,8 +2451,7 @@ static char *fmt_single_name(struct device *dev, int *id)
* Simplify DAI link naming for single devices with multiple DAIs by removing
* any ".-1" and using the DAI name (instead of device name).
*/
-static inline char *fmt_multiple_name(struct device *dev,
- struct snd_soc_dai_driver *dai_drv)
+char *snd_soc_fmt_multiple_name(struct device *dev, struct snd_soc_dai_driver *dai_drv)
{
if (dai_drv->name == NULL) {
dev_err(dev,
@@ -2542,74 +2463,6 @@ static inline char *fmt_multiple_name(struct device *dev,
return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL);
}
-void snd_soc_unregister_dai(struct snd_soc_dai *dai)
-{
- lockdep_assert_held(&client_mutex);
-
- dev_dbg(dai->dev, "ASoC: Unregistered DAI '%s'\n", dai->name);
- list_del(&dai->list);
-}
-EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
-
-/**
- * snd_soc_register_dai - Register a DAI dynamically & create its widgets
- *
- * @component: The component the DAIs are registered for
- * @dai_drv: DAI driver to use for the DAI
- * @legacy_dai_naming: if %true, use legacy single-name format;
- * if %false, use multiple-name format;
- *
- * Topology can use this API to register DAIs when probing a component.
- * These DAIs's widgets will be freed in the card cleanup and the DAIs
- * will be freed in the component cleanup.
- */
-struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
- struct snd_soc_dai_driver *dai_drv,
- bool legacy_dai_naming)
-{
- struct device *dev = component->dev;
- struct snd_soc_dai *dai;
-
- lockdep_assert_held(&client_mutex);
-
- dai = devm_kzalloc(dev, sizeof(*dai), GFP_KERNEL);
- if (dai == NULL)
- return NULL;
-
- /*
- * Back in the old days when we still had component-less DAIs,
- * instead of having a static name, component-less DAIs would
- * inherit the name of the parent device so it is possible to
- * register multiple instances of the DAI. We still need to keep
- * the same naming style even though those DAIs are not
- * component-less anymore.
- */
- if (legacy_dai_naming &&
- (dai_drv->id == 0 || dai_drv->name == NULL)) {
- dai->name = fmt_single_name(dev, &dai->id);
- } else {
- dai->name = fmt_multiple_name(dev, dai_drv);
- if (dai_drv->id)
- dai->id = dai_drv->id;
- else
- dai->id = component->num_dai;
- }
- if (!dai->name)
- return NULL;
-
- dai->component = component;
- dai->dev = dev;
- dai->driver = dai_drv;
-
- /* see for_each_component_dais */
- list_add_tail(&dai->list, &component->dai_list);
- component->num_dai++;
-
- dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name);
- return dai;
-}
-EXPORT_SYMBOL_GPL(snd_soc_register_dai);
-
/**
* snd_soc_unregister_dais - Unregister DAIs from the ASoC core
*
@@ -2724,7 +2577,7 @@ static int soc_component_initialize(struct snd_soc_component *component,
mutex_init(&component->io_mutex);
if (!component->name) {
- component->name = fmt_single_name(dev, NULL);
+ component->name = snd_soc_fmt_single_name(dev, NULL);
if (!component->name) {
dev_err(dev, "ASoC: Failed to allocate name\n");
return -ENOMEM;
@@ -3477,7 +3330,7 @@ int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_
id--;
}
- dlc->dai_name = snd_soc_dai_name_get(dai);
+ dlc->dai_name = snd_soc_dai_name(dai);
} else if (ret) {
/*
* if another error than ENOTSUPP is returned go on and
@@ -3552,7 +3405,7 @@ struct snd_soc_dai *snd_soc_get_dai_via_args(const struct of_phandle_args *dai_a
for_each_component(component) {
for_each_component_dais(component, dai)
- if (snd_soc_is_match_dai_args(dai->driver->dai_args, dai_args))
+ if (snd_soc_dai_matches_args(dai, dai_args))
return dai;
}
return NULL;
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index b098d1100b4b..83d030e14bb0 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -6,9 +6,11 @@
// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
//
+#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dai.h>
#include <sound/soc-link.h>
+#include "soc-internal.h"
#define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret)
static inline int _soc_dai_ret(const struct snd_soc_dai *dai,
@@ -989,3 +991,343 @@ int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
return soc_dai_ret(dai, ret);
}
EXPORT_SYMBOL_GPL(snd_soc_dai_compr_get_metadata);
+
+/**
+ * snd_soc_dai_add_controls - add an array of controls to a DAI.
+ * Convenience function to add a list of controls.
+ *
+ * @dai: DAI to add controls to
+ * @controls: array of controls to add
+ * @num_controls: number of elements in the array
+ *
+ * Return 0 for success, else error.
+ */
+int snd_soc_dai_add_controls(struct snd_soc_dai *dai,
+ const struct snd_kcontrol_new *controls, int num_controls)
+{
+ struct snd_card *card = dai->component->card->snd_card;
+
+ return snd_soc_add_controls(card, dai->dev, controls, num_controls, NULL, dai);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_add_controls);
+
+int snd_soc_dai_matches_args(const struct snd_soc_dai *dai,
+ const struct of_phandle_args *args2)
+{
+ const struct of_phandle_args *args1 = dai->driver->dai_args;
+
+ if (!args1 || !args2)
+ return 0;
+
+ if (args1->np != args2->np)
+ return 0;
+
+ for (int i = 0; i < args1->args_count; i++)
+ if (args1->args[i] != args2->args[i])
+ return 0;
+
+ return 1;
+}
+
+int snd_soc_dai_matches_dlc(struct snd_soc_dai *dai,
+ const struct snd_soc_dai_link_component *dlc)
+{
+ if (!dlc)
+ return 0;
+
+ if (dlc->dai_args)
+ return snd_soc_dai_matches_args(dai, dlc->dai_args);
+
+ if (!dlc->dai_name)
+ return 1;
+
+ /* see snd_soc_dai_name() */
+
+ if (dai->driver->name &&
+ strcmp(dlc->dai_name, dai->driver->name) == 0)
+ return 1;
+
+ if (strcmp(dlc->dai_name, dai->name) == 0)
+ return 1;
+
+ if (dai->component->name &&
+ strcmp(dlc->dai_name, dai->component->name) == 0)
+ return 1;
+
+ return 0;
+}
+
+const char *snd_soc_dai_name(const struct snd_soc_dai *dai)
+{
+ /* see snd_soc_dai_matches_dlc() */
+ if (dai->driver->name)
+ return dai->driver->name;
+
+ if (dai->name)
+ return dai->name;
+
+ if (dai->component->name)
+ return dai->component->name;
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_name);
+
+const struct snd_soc_pcm_stream *
+snd_soc_dai_pcm_stream_get_i(const struct snd_soc_dai *dai, int stream)
+{
+ return (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+ &dai->driver->playback : &dai->driver->capture;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_pcm_stream_get_i);
+
+struct snd_soc_dapm_widget *snd_soc_dai_stream_widget_get(struct snd_soc_dai *dai, int stream)
+{
+ return dai->stream[stream].widget;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_stream_widget_get);
+
+void snd_soc_dai_stream_widget_set(struct snd_soc_dai *dai, int stream, struct snd_soc_dapm_widget *widget)
+{
+ dai->stream[stream].widget = widget;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_stream_widget_set);
+
+void *snd_soc_dai_stream_dma_data_get_i(const struct snd_soc_dai *dai, int stream)
+{
+ return dai->stream[stream].dma_data;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_stream_dma_data_get_i);
+
+void snd_soc_dai_stream_dma_data_set_i(struct snd_soc_dai *dai, int stream, void *data)
+{
+ dai->stream[stream].dma_data = data;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_stream_dma_data_set_i);
+
+unsigned int snd_soc_dai_stream_tdm_mask_get(const struct snd_soc_dai *dai, int stream)
+{
+ return dai->stream[stream].tdm_mask;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_stream_tdm_mask_get);
+
+void snd_soc_dai_stream_tdm_mask_set(struct snd_soc_dai *dai, int stream, unsigned int tdm_mask)
+{
+ dai->stream[stream].tdm_mask = tdm_mask;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_stream_tdm_mask_set);
+
+unsigned int snd_soc_dai_stream_active(const struct snd_soc_dai *dai, int stream)
+{
+ /* see snd_soc_dai_action() for setup */
+ return dai->stream[stream].active;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_stream_active);
+
+/**
+ * snd_soc_dai_set_stream() - Configures a DAI for stream operation
+ * @dai: DAI
+ * @stream: STREAM (opaque structure depending on DAI type)
+ * @direction: Stream direction(Playback/Capture)
+ * Some subsystems, such as SoundWire, don't have a notion of direction and we reuse
+ * the ASoC stream direction to configure sink/source ports.
+ * Playback maps to source ports and Capture for sink ports.
+ *
+ * This should be invoked with NULL to clear the stream set previously.
+ * Returns 0 on success, a negative error code otherwise.
+ */
+int snd_soc_dai_set_stream(struct snd_soc_dai *dai, void *stream, int direction)
+{
+ if (dai->driver->ops->set_stream)
+ return dai->driver->ops->set_stream(dai, stream, direction);
+ else
+ return -ENOTSUPP;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_set_stream);
+
+/**
+ * snd_soc_dai_get_stream() - Retrieves stream from DAI
+ * @dai: DAI
+ * @direction: Stream direction(Playback/Capture)
+ *
+ * This routine only retrieves that was previously configured
+ * with snd_soc_dai_get_stream()
+ *
+ * Returns pointer to stream or an ERR_PTR value, e.g.
+ * ERR_PTR(-ENOTSUPP) if callback is not supported;
+ */
+void *snd_soc_dai_get_stream(struct snd_soc_dai *dai, int direction)
+{
+ if (dai->driver->ops->get_stream)
+ return dai->driver->ops->get_stream(dai, direction);
+ else
+ return ERR_PTR(-ENOTSUPP);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_get_stream);
+
+void snd_soc_dai_unregister(struct snd_soc_dai *dai)
+{
+ lockdep_assert_held(&client_mutex);
+
+ dev_dbg(dai->dev, "ASoC: Unregistered DAI '%s'\n", dai->name);
+ list_del(&dai->list);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_unregister);
+
+/**
+ * snd_soc_dai_register - Register a DAI dynamically & create its widgets
+ *
+ * @component: The component the DAIs are registered for
+ * @dai_drv: DAI driver to use for the DAI
+ * @legacy_dai_naming: if %true, use legacy single-name format;
+ * if %false, use multiple-name format;
+ *
+ * Topology can use this API to register DAIs when probing a component.
+ * These DAIs's widgets will be freed in the card cleanup and the DAIs
+ * will be freed in the component cleanup.
+ */
+struct snd_soc_dai *snd_soc_dai_register(struct snd_soc_component *component,
+ struct snd_soc_dai_driver *dai_drv,
+ bool legacy_dai_naming)
+{
+ struct device *dev = component->dev;
+ struct snd_soc_dai *dai;
+
+ lockdep_assert_held(&client_mutex);
+
+ dai = devm_kzalloc(dev, sizeof(*dai), GFP_KERNEL);
+ if (dai == NULL)
+ return NULL;
+
+ /*
+ * Back in the old days when we still had component-less DAIs,
+ * instead of having a static name, component-less DAIs would
+ * inherit the name of the parent device so it is possible to
+ * register multiple instances of the DAI. We still need to keep
+ * the same naming style even though those DAIs are not
+ * component-less anymore.
+ */
+ if (legacy_dai_naming &&
+ (dai_drv->id == 0 || dai_drv->name == NULL)) {
+ dai->name = snd_soc_fmt_single_name(dev, &dai->id);
+ } else {
+ dai->name = snd_soc_fmt_multiple_name(dev, dai_drv);
+ if (dai_drv->id)
+ dai->id = dai_drv->id;
+ else
+ dai->id = component->num_dai;
+ }
+ if (!dai->name)
+ return NULL;
+
+ dai->component = component;
+ dai->dev = dev;
+ dai->driver = dai_drv;
+
+ /* see for_each_component_dais */
+ list_add_tail(&dai->list, &component->dai_list);
+ component->num_dai++;
+
+ dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name);
+ return dai;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_register);
+
+void snd_soc_dai_symmetric_set_params(struct snd_soc_dai *dai,
+ struct snd_pcm_hw_params *params)
+{
+ if (params) {
+ dai->symmetric_rate = params_rate(params);
+ dai->symmetric_channels = params_channels(params);
+ dai->symmetric_sample_bits = snd_pcm_format_physical_width(params_format(params));
+ } else {
+ dai->symmetric_rate = 0;
+ dai->symmetric_channels = 0;
+ dai->symmetric_sample_bits = 0;
+ }
+}
+
+int snd_soc_dai_symmetric_apply(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
+{
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
+ int ret;
+
+ if (!snd_soc_dai_active(dai))
+ return 0;
+
+#define __symmetric_apply(name, NAME) \
+ if (dai->symmetric_##name && \
+ (dai->driver->symmetric_##name || rtd->dai_link->symmetric_##name)) { \
+ dev_dbg(dai->dev, "ASoC: Symmetry forces %s to %d\n", \
+ #name, dai->symmetric_##name); \
+ \
+ ret = snd_pcm_hw_constraint_single(substream->runtime, \
+ SNDRV_PCM_HW_PARAM_##NAME, \
+ dai->symmetric_##name); \
+ if (ret < 0) \
+ return snd_soc_ret(dai->dev, ret, \
+ "Unable to apply %s constraint\n", #name); \
+ }
+
+ __symmetric_apply(rate, RATE);
+ __symmetric_apply(channels, CHANNELS);
+ __symmetric_apply(sample_bits, SAMPLE_BITS);
+
+ return 0;
+}
+
+int snd_soc_dai_symmetric_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
+ struct snd_soc_dai d;
+ struct snd_soc_dai *dai;
+ struct snd_soc_dai *cpu_dai;
+ unsigned int symmetry, i;
+
+ d.name = __func__;
+ snd_soc_dai_symmetric_set_params(&d, params);
+
+#define __symmetric_params(xxx) \
+ symmetry = rtd->dai_link->symmetric_##xxx; \
+ for_each_rtd_dais(rtd, i, dai) \
+ symmetry |= dai->driver->symmetric_##xxx; \
+ \
+ if (symmetry) \
+ for_each_rtd_cpu_dais(rtd, i, cpu_dai) \
+ if (!snd_soc_dai_is_dummy(cpu_dai) && \
+ cpu_dai->symmetric_##xxx && \
+ cpu_dai->symmetric_##xxx != d.symmetric_##xxx) \
+ return snd_soc_ret(rtd->dev, -EINVAL, \
+ "unmatched %s symmetry: %s:%d - %s:%d\n", \
+ #xxx, cpu_dai->name, cpu_dai->symmetric_##xxx, \
+ d.name, d.symmetric_##xxx);
+
+ /* reject unmatched parameters when applying symmetry */
+ __symmetric_params(rate);
+ __symmetric_params(channels);
+ __symmetric_params(sample_bits);
+
+ return 0;
+}
+
+void snd_soc_dai_symmetric_update(struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
+ struct snd_soc_dai_link *link = rtd->dai_link;
+ struct snd_soc_dai *dai;
+ unsigned int symmetry, i;
+
+ symmetry = link->symmetric_rate ||
+ link->symmetric_channels ||
+ link->symmetric_sample_bits;
+
+ for_each_rtd_dais(rtd, i, dai)
+ symmetry = symmetry ||
+ dai->driver->symmetric_rate ||
+ dai->driver->symmetric_channels ||
+ dai->driver->symmetric_sample_bits;
+
+ if (symmetry)
+ substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
+}
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
new file mode 100644
index 000000000000..3afc50d5760e
--- /dev/null
+++ b/sound/soc/soc-internal.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ *
+ * soc-internal.h
+ *
+ * Copyright (c) 2026 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ */
+#ifndef __SOC_INTERNAL_H
+#define __SOC_INTERNAL_H
+
+/*
+ * This header is for ALSA SoC Framework internal, not for Vender drivers.
+ * The ALSA SoC functions for Vender drivers are defined in linux/include/sound/xxx.h
+ * as snd_soc_xxx();
+ */
+
+/*
+ * In soc-core
+ */
+extern struct mutex client_mutex;
+
+char *snd_soc_fmt_single_name(struct device *dev, int *id);
+char *snd_soc_fmt_multiple_name(struct device *dev, struct snd_soc_dai_driver *dai_drv);
+int snd_soc_add_controls(struct snd_card *card, struct device *dev,
+ const struct snd_kcontrol_new *controls, int num_controls,
+ const char *prefix, void *data);
+
+/*
+ * In soc-dai
+ */
+void snd_soc_dai_symmetric_set_params(struct snd_soc_dai *dai,
+ struct snd_pcm_hw_params *params);
+int snd_soc_dai_symmetric_apply(struct snd_pcm_substream *substream, struct snd_soc_dai *dai);
+int snd_soc_dai_symmetric_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);
+void snd_soc_dai_symmetric_update(struct snd_pcm_substream *substream);
+
+#endif /* __SOC_INTERNAL_H */
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 0e49290a8c90..a446e9c1c988 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -26,6 +26,7 @@
#include <sound/soc-dpcm.h>
#include <sound/soc-link.h>
#include <sound/initval.h>
+#include "soc-internal.h"
DEFINE_GUARD(snd_soc_card_mutex, struct snd_soc_card *,
@@ -427,50 +428,6 @@ void dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, int event)
snd_soc_dapm_stream_event(fe, dir, event);
}
-void soc_pcm_set_dai_params(struct snd_soc_dai *dai,
- struct snd_pcm_hw_params *params)
-{
- if (params) {
- dai->symmetric_rate = params_rate(params);
- dai->symmetric_channels = params_channels(params);
- dai->symmetric_sample_bits = snd_pcm_format_physical_width(params_format(params));
- } else {
- dai->symmetric_rate = 0;
- dai->symmetric_channels = 0;
- dai->symmetric_sample_bits = 0;
- }
-}
-
-static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,
- struct snd_soc_dai *soc_dai)
-{
- struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- int ret;
-
- if (!snd_soc_dai_active(soc_dai))
- return 0;
-
-#define __soc_pcm_apply_symmetry(name, NAME) \
- if (soc_dai->symmetric_##name && \
- (soc_dai->driver->symmetric_##name || rtd->dai_link->symmetric_##name)) { \
- dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %s to %d\n",\
- #name, soc_dai->symmetric_##name); \
- \
- ret = snd_pcm_hw_constraint_single(substream->runtime, \
- SNDRV_PCM_HW_PARAM_##NAME,\
- soc_dai->symmetric_##name); \
- if (ret < 0) \
- return snd_soc_ret(soc_dai->dev, ret, \
- "Unable to apply %s constraint\n", #name); \
- }
-
- __soc_pcm_apply_symmetry(rate, RATE);
- __soc_pcm_apply_symmetry(channels, CHANNELS);
- __soc_pcm_apply_symmetry(sample_bits, SAMPLE_BITS);
-
- return 0;
-}
-
/*
* Shared BCLK constraint: when multiple DAIs share the same physical BCLK,
* constrain hw_params so that the BCLK rate (rate * channels * sample_bits,
@@ -579,62 +536,6 @@ static int soc_pcm_apply_shared_bclk(struct snd_pcm_substream *substream,
-1);
}
-static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
-{
- struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- struct snd_soc_dai d;
- struct snd_soc_dai *dai;
- struct snd_soc_dai *cpu_dai;
- unsigned int symmetry, i;
-
- d.name = __func__;
- soc_pcm_set_dai_params(&d, params);
-
-#define __soc_pcm_params_symmetry(xxx) \
- symmetry = rtd->dai_link->symmetric_##xxx; \
- for_each_rtd_dais(rtd, i, dai) \
- symmetry |= dai->driver->symmetric_##xxx; \
- \
- if (symmetry) \
- for_each_rtd_cpu_dais(rtd, i, cpu_dai) \
- if (!snd_soc_dai_is_dummy(cpu_dai) && \
- cpu_dai->symmetric_##xxx && \
- cpu_dai->symmetric_##xxx != d.symmetric_##xxx) \
- return snd_soc_ret(rtd->dev, -EINVAL, \
- "unmatched %s symmetry: %s:%d - %s:%d\n", \
- #xxx, cpu_dai->name, cpu_dai->symmetric_##xxx, \
- d.name, d.symmetric_##xxx);
-
- /* reject unmatched parameters when applying symmetry */
- __soc_pcm_params_symmetry(rate);
- __soc_pcm_params_symmetry(channels);
- __soc_pcm_params_symmetry(sample_bits);
-
- return 0;
-}
-
-static void soc_pcm_update_symmetry(struct snd_pcm_substream *substream)
-{
- struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- struct snd_soc_dai_link *link = rtd->dai_link;
- struct snd_soc_dai *dai;
- unsigned int symmetry, i;
-
- symmetry = link->symmetric_rate ||
- link->symmetric_channels ||
- link->symmetric_sample_bits;
-
- for_each_rtd_dais(rtd, i, dai)
- symmetry = symmetry ||
- dai->driver->symmetric_rate ||
- dai->driver->symmetric_channels ||
- dai->driver->symmetric_sample_bits;
-
- if (symmetry)
- substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
-}
-
static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
@@ -879,7 +780,7 @@ static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
/* Make sure DAI parameters cleared if the DAI becomes inactive */
for_each_rtd_dais(rtd, i, dai) {
if (snd_soc_dai_active(dai) == 0)
- soc_pcm_set_dai_params(dai, NULL);
+ snd_soc_dai_symmetric_set_params(dai, NULL);
}
}
@@ -1001,7 +902,7 @@ static int __soc_pcm_open(struct snd_soc_pcm_runtime *rtd,
/* Check that the codec and cpu DAIs are compatible */
soc_pcm_init_runtime_hw(substream);
- soc_pcm_update_symmetry(substream);
+ snd_soc_dai_symmetric_update(substream);
ret = soc_hw_sanity_check(substream);
if (ret < 0)
@@ -1011,7 +912,7 @@ static int __soc_pcm_open(struct snd_soc_pcm_runtime *rtd,
/* Symmetry only applies if we've already got an active stream. */
for_each_rtd_dais(rtd, i, dai) {
- ret = soc_pcm_apply_symmetry(substream, dai);
+ ret = snd_soc_dai_symmetric_apply(substream, dai);
if (ret != 0)
goto err;
}
@@ -1135,7 +1036,7 @@ static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd,
/* clear the corresponding DAIs parameters when going to be inactive */
for_each_rtd_dais(rtd, i, dai) {
if (snd_soc_dai_active(dai) == 1)
- soc_pcm_set_dai_params(dai, NULL);
+ snd_soc_dai_symmetric_set_params(dai, NULL);
if (snd_soc_dai_stream_active(dai, substream->stream) == 1) {
if (!snd_soc_dai_mute_is_ctrled_at_trigger(dai))
@@ -1197,7 +1098,7 @@ static int __soc_pcm_hw_params(struct snd_pcm_substream *substream,
snd_soc_dpcm_mutex_assert_held(rtd);
- ret = soc_pcm_params_symmetry(substream, params);
+ ret = snd_soc_dai_symmetric_params(substream, params);
if (ret)
goto out;
@@ -1237,7 +1138,7 @@ static int __soc_pcm_hw_params(struct snd_pcm_substream *substream,
if(ret < 0)
goto out;
- soc_pcm_set_dai_params(codec_dai, &tmp_params);
+ snd_soc_dai_symmetric_set_params(codec_dai, &tmp_params);
snd_soc_dapm_update_dai(substream, &tmp_params, codec_dai);
}
@@ -1275,7 +1176,7 @@ static int __soc_pcm_hw_params(struct snd_pcm_substream *substream,
goto out;
/* store the parameters for each DAI */
- soc_pcm_set_dai_params(cpu_dai, &tmp_params);
+ snd_soc_dai_symmetric_set_params(cpu_dai, &tmp_params);
snd_soc_dapm_update_dai(substream, &tmp_params, cpu_dai);
}
@@ -2024,11 +1925,11 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
int i;
/* apply symmetry for FE */
- soc_pcm_update_symmetry(fe_substream);
+ snd_soc_dai_symmetric_update(fe_substream);
for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) {
/* Symmetry only applies if we've got an active stream. */
- err = soc_pcm_apply_symmetry(fe_substream, fe_cpu_dai);
+ err = snd_soc_dai_symmetric_apply(fe_substream, fe_cpu_dai);
if (err < 0)
goto error;
}
@@ -2049,11 +1950,11 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
if (rtd->dai_link->be_hw_params_fixup)
continue;
- soc_pcm_update_symmetry(be_substream);
+ snd_soc_dai_symmetric_update(be_substream);
/* Symmetry only applies if we've got an active stream. */
for_each_rtd_dais(rtd, i, dai) {
- err = soc_pcm_apply_symmetry(fe_substream, dai);
+ err = snd_soc_dai_symmetric_apply(fe_substream, dai);
if (err < 0)
goto error;
}