* [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c
@ 2026-10-28 2:42 Kuninori Morimoto
2026-10-28 3:02 ` [PATCH 01/15] ASoC: soc-core: fixup snd_soc_dai_compress_new() return Kuninori Morimoto
` (15 more replies)
0 siblings, 16 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 2:42 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
Hi Mark
I'm now posting ASoC Capsuling patches.
Current status, and this patch-set postion is below.
This patch-set moves Card related functions to soc-card.c
x: done
o: This patch-set
[x] move DAI functions
[x] add new DAI functions
[x] move Component functions
[o] move Card functions
[ ] add new Component functions
[ ] rename DAI/Component list
[ ] move Card functions v2
[ ] add new Card functions
[ ] adjust Test
[ ] use new Card register
[ ] use new functions on all drivers
[ ] Capsule DAI/Component/Card
Kuninori Morimoto (15):
ASoC: soc-core: fixup snd_soc_dai_compress_new() return
ASoC: soc-card: move snd_soc_add_card_controls()
ASoC: soc-card: move snd_soc_card_debugfs_xxx()
ASoC: soc-card: move snd_soc_card_resume_init()
ASoC: soc-card: move snd_soc_card_fill_dummy_dai()
ASoC: soc-card: move snd_soc_card_init_pcm_runtime()
ASoC: soc-card: move snd_soc_card_link_dais_xxx()
ASoC: soc-card: move snd_soc_card_link_components_xxx()
ASoC: soc-card: move snd_soc_card_aux_[un]bind()
ASoC: soc-card: move snd_soc_card_aux_{remove/probe}()
ASoC: soc-card: move snd_soc_card_set_dmi_name()
ASoC: soc-card: move snd_soc_card_bind_call()
ASoC: soc-card: add snd_soc_card_rebind()
ASoC: soc-card: make unbind_card_list static
ASoC: soc-internal: remove temporary funciton defines
include/sound/soc-card.h | 2 +
include/sound/soc.h | 3 +-
sound/soc/soc-card.c | 890 +++++++++++++++++++++++++++++++++++++-
sound/soc/soc-core.c | 900 +--------------------------------------
sound/soc/soc-internal.h | 13 +
5 files changed, 919 insertions(+), 889 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 01/15] ASoC: soc-core: fixup snd_soc_dai_compress_new() return
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
@ 2026-10-28 3:02 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 02/15] ASoC: soc-card: move snd_soc_add_card_controls() Kuninori Morimoto
` (14 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:02 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound, Amadeusz Sławiński
Original snd_soc_dai_compress_new() return was below.
Here, snd_soc_dai_compress_new() will return -ENOTSUPP if driver doesn't
support .compress_new() callback. Will return handled value if
callback was supported.
ret = snd_soc_dai_compress_new(...);
if (ret != -ENOTSUPP) {
if (ret < 0)
dev_err(...);
return ret;
}
So this means, it will return here anyway if driver supports
the callback even though it was success/failed.
This was updated by commit 62462e018220 ("ASoC: don't indicate error
message for snd_soc_[pcm_]dai_xxx()") like below
ret = snd_soc_dai_compress_new(...);
if (ret != -ENOTSUPP)
return ret;
It still return here if driver supports callback.
But commit dd9f9cc1e6b9 ("ASoC: core: Do not call link_exit() on
uninitialized rtd objects") updated to like below to call
snd_soc_link_exit() if error case.
ret = snd_soc_dai_compress_new(...);
if (ret != -ENOTSUPP)
=> goto err;
But this looks like error, but is not.
This is very confusable. Let's tidyup them.
Fixes: dd9f9cc1e6b9 ("ASoC: core: Do not call link_exit() on uninitialized rtd objects")
Cc: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reported-by: Sashiko <sashiko-bot@kernel.org>
---
sound/soc/soc-core.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 97269b4ee4ca5..1c3ed2975cac7 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1184,10 +1184,13 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
/* add DPCM sysfs entries */
soc_dpcm_debugfs_add(rtd);
- /* create compress_device if possible */
+ /* create compress_device if driver is supporting */
ret = snd_soc_dai_compress_new(cpu_dai, rtd);
- if (ret != -ENOTSUPP)
- goto err;
+ if (ret != -ENOTSUPP) { /* driver is supporting */
+ if (ret < 0)
+ goto err;
+ goto end;
+ }
/* create the pcm */
ret = soc_new_pcm(rtd);
@@ -1200,12 +1203,13 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
ret = snd_soc_pcm_dai_new(rtd);
if (ret < 0)
goto err;
-
+end:
rtd->initialized = true;
return 0;
err:
snd_soc_link_exit(rtd);
+
return ret;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 02/15] ASoC: soc-card: move snd_soc_add_card_controls()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
2026-10-28 3:02 ` [PATCH 01/15] ASoC: soc-core: fixup snd_soc_dai_compress_new() return Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 03/15] ASoC: soc-card: move snd_soc_card_debugfs_xxx() Kuninori Morimoto
` (13 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It renames function name
- snd_soc_add_card_controls()
+ snd_soc_card_add_controls()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
include/sound/soc-card.h | 2 ++
include/sound/soc.h | 3 +--
sound/soc/soc-card.c | 20 ++++++++++++++++++++
sound/soc/soc-core.c | 20 --------------------
4 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h
index 1f1e7d45f5533..ce2b8653f67d3 100644
--- a/include/sound/soc-card.h
+++ b/include/sound/soc-card.h
@@ -28,6 +28,8 @@ static inline void snd_soc_card_mutex_unlock(struct snd_soc_card *card)
mutex_unlock(&card->mutex);
}
+int snd_soc_card_add_controls(struct snd_soc_card *soc_card,
+ const struct snd_kcontrol_new *controls, int num_controls);
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name);
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
diff --git a/include/sound/soc.h b/include/sound/soc.h
index f6b98324f3464..338662645b42f 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -540,8 +540,6 @@ static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
void *data, const char *long_name,
const char *prefix);
-int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
- 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,
@@ -1539,5 +1537,6 @@ static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime
#define snd_soc_register_dai snd_soc_dai_register
#define snd_soc_unregister_dai snd_soc_dai_unregister
#define snd_soc_add_component_controls snd_soc_component_add_controls
+#define snd_soc_add_card_controls snd_soc_card_add_controls
#endif
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 282d666dae9ec..7dafe22d8a789 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -10,6 +10,7 @@
#include <linux/rwsem.h>
#include <sound/soc.h>
#include <sound/jack.h>
+#include "soc-internal.h"
#define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret)
static inline int _soc_card_ret(struct snd_soc_card *card,
@@ -259,3 +260,22 @@ void snd_soc_card_set_topology_name(struct snd_soc_card *card, const char *prefi
card->name = card->topology_shortname;
}
EXPORT_SYMBOL_GPL(snd_soc_card_set_topology_name);
+
+/**
+ * snd_soc_card_add_controls - add an array of controls to a SoC card.
+ * Convenience function to add a list of controls.
+ *
+ * @soc_card: SoC card 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_card_add_controls(struct snd_soc_card *soc_card,
+ const struct snd_kcontrol_new *controls, int num_controls)
+{
+ struct snd_card *card = soc_card->snd_card;
+
+ return snd_soc_add_controls(card, soc_card->dev, controls, num_controls, NULL, soc_card);
+}
+EXPORT_SYMBOL_GPL(snd_soc_card_add_controls);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1c3ed2975cac7..de6d9746aac6e 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2045,26 +2045,6 @@ int snd_soc_add_controls(struct snd_card *card, struct device *dev,
return 0;
}
-/**
- * snd_soc_add_card_controls - add an array of controls to a SoC card.
- * Convenience function to add a list of controls.
- *
- * @soc_card: SoC card 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_card_controls(struct snd_soc_card *soc_card,
- const struct snd_kcontrol_new *controls, int num_controls)
-{
- struct snd_card *card = soc_card->snd_card;
-
- return snd_soc_add_controls(card, soc_card->dev, controls, num_controls,
- NULL, soc_card);
-}
-EXPORT_SYMBOL_GPL(snd_soc_add_card_controls);
-
/**
* snd_soc_register_card - Register a card with the ASoC core
*
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 03/15] ASoC: soc-card: move snd_soc_card_debugfs_xxx()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
2026-10-28 3:02 ` [PATCH 01/15] ASoC: soc-core: fixup snd_soc_dai_compress_new() return Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 02/15] ASoC: soc-card: move snd_soc_add_card_controls() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 04/15] ASoC: soc-card: move snd_soc_card_resume_init() Kuninori Morimoto
` (12 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- soc_init_card_debugfs()
- soc_cleanup_card_debugfs()
+ snd_soc_card_debugfs_init()
+ snd_soc_card_debugfs_cleanup()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 20 ++++++++++++++++++++
sound/soc/soc-core.c | 20 ++------------------
sound/soc/soc-internal.h | 7 +++++++
3 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 7dafe22d8a789..58aa75163045d 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -6,6 +6,7 @@
// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
//
+#include <linux/debugfs.h>
#include <linux/lockdep.h>
#include <linux/rwsem.h>
#include <sound/soc.h>
@@ -20,6 +21,25 @@ static inline int _soc_card_ret(struct snd_soc_card *card,
"at %s() on %s\n", func, card->name);
}
+#ifdef CONFIG_DEBUG_FS
+void snd_soc_card_debugfs_init(struct snd_soc_card *card)
+{
+ card->debugfs_card_root = debugfs_create_dir(card->name,
+ snd_soc_debugfs_root);
+
+ snd_soc_dapm_debugfs_init(snd_soc_card_to_dapm(card), card->debugfs_card_root);
+}
+
+void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card)
+{
+ debugfs_remove_recursive(card->debugfs_card_root);
+ card->debugfs_card_root = NULL;
+}
+#else
+void snd_soc_card_debugfs_init(struct snd_soc_card *card) { }
+void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card) { }
+#endif /* CONFIG_DEBUG_FS */
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index de6d9746aac6e..91e2eea30cb34 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -154,20 +154,6 @@ static int component_list_show(struct seq_file *m, void *v)
}
DEFINE_SHOW_ATTRIBUTE(component_list);
-static void soc_init_card_debugfs(struct snd_soc_card *card)
-{
- card->debugfs_card_root = debugfs_create_dir(card->name,
- snd_soc_debugfs_root);
-
- snd_soc_dapm_debugfs_init(snd_soc_card_to_dapm(card), card->debugfs_card_root);
-}
-
-static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
-{
- debugfs_remove_recursive(card->debugfs_card_root);
- card->debugfs_card_root = NULL;
-}
-
static void snd_soc_debugfs_init(void)
{
snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL);
@@ -188,8 +174,6 @@ static void snd_soc_debugfs_exit(void)
#else
-static inline void soc_init_card_debugfs(struct snd_soc_card *card) { }
-static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card) { }
static inline void snd_soc_debugfs_init(void) { }
static inline void snd_soc_debugfs_exit(void) { }
@@ -1651,7 +1635,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
soc_unbind_aux_dev(card);
snd_soc_dapm_free(snd_soc_card_to_dapm(card));
- soc_cleanup_card_debugfs(card);
+ snd_soc_card_debugfs_cleanup(card);
/* remove the card */
snd_soc_card_remove(card);
@@ -1722,7 +1706,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
goto probe_end;
}
- soc_init_card_debugfs(card);
+ snd_soc_card_debugfs_init(card);
soc_resume_init(card);
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index b844b27574c8a..550fc1c7ef05f 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -13,6 +13,13 @@
* as snd_soc_xxx();
*/
+/*
+ * REMOVE ME
+ * Temporary definition
+ */
+void snd_soc_card_debugfs_init(struct snd_soc_card *card);
+void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card);
+
/*
* In soc-core
*/
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 04/15] ASoC: soc-card: move snd_soc_card_resume_init()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (2 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 03/15] ASoC: soc-card: move snd_soc_card_debugfs_xxx() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 05/15] ASoC: soc-card: move snd_soc_card_fill_dummy_dai() Kuninori Morimoto
` (11 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- void soc_resume_deferred
- void soc_card_resume_init()
+ void snd_soc_card_resume_deferred
+ void snd_soc_card_resume_init()
Below functions are used on above functions. Add them at soc-internal.h
- void soc_playback_digital_mute()
- void soc_dapm_suspend_resume()
+ void snd_soc_playback_digital_mute()
+ void snd_soc_dapm_suspend_resume()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 55 ++++++++++++++++++++++++++++++++++++
sound/soc/soc-core.c | 61 ++++------------------------------------
sound/soc/soc-internal.h | 5 ++++
3 files changed, 65 insertions(+), 56 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 58aa75163045d..bccd47cc136e6 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -40,6 +40,61 @@ void snd_soc_card_debugfs_init(struct snd_soc_card *card) { }
void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card) { }
#endif /* CONFIG_DEBUG_FS */
+#ifdef CONFIG_PM_SLEEP
+/*
+ * deferred resume work, so resume can complete before we finished
+ * setting our codec back up, which can be very slow on I2C
+ */
+static void snd_soc_card_resume_deferred(struct work_struct *work)
+{
+ struct snd_soc_card *card =
+ container_of(work, struct snd_soc_card,
+ deferred_resume_work);
+ struct snd_soc_component *component;
+
+ /*
+ * our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
+ * so userspace apps are blocked from touching us
+ */
+
+ dev_dbg(card->dev, "ASoC: starting resume work\n");
+
+ /* Bring us up into D2 so that DAPM starts enabling things */
+ snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2);
+
+ snd_soc_card_resume_pre(card);
+
+ for_each_card_components(card, component) {
+ if (snd_soc_component_is_suspended(component))
+ snd_soc_component_resume(component);
+ }
+
+ snd_soc_dapm_suspend_resume(card, SND_SOC_DAPM_STREAM_RESUME);
+
+ /* unmute any active DACs */
+ snd_soc_playback_digital_mute(card, 0);
+
+ snd_soc_card_resume_post(card);
+
+ dev_dbg(card->dev, "ASoC: resume work completed\n");
+
+ /* Recheck all endpoints too, their state is affected by suspend */
+ snd_soc_dapm_mark_endpoints_dirty(card);
+ snd_soc_dapm_sync(snd_soc_card_to_dapm(card));
+
+ /* userspace can access us now we are back as we were before */
+ snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);
+}
+
+void snd_soc_card_resume_init(struct snd_soc_card *card)
+{
+ /* deferred resume work */
+ INIT_WORK(&card->deferred_resume_work, snd_soc_card_resume_deferred);
+}
+#else
+void snd_soc_card_resume_init(struct snd_soc_card *card) { }
+#endif /* CONFIG_PM_SLEEP */
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 91e2eea30cb34..901fddbbe25e8 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -457,7 +457,7 @@ static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card)
}
#ifdef CONFIG_PM_SLEEP
-static void soc_playback_digital_mute(struct snd_soc_card *card, int mute)
+void snd_soc_playback_digital_mute(struct snd_soc_card *card, int mute)
{
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_dai *dai;
@@ -476,7 +476,7 @@ static void soc_playback_digital_mute(struct snd_soc_card *card, int mute)
}
}
-static void soc_dapm_suspend_resume(struct snd_soc_card *card, int event)
+void snd_soc_dapm_suspend_resume(struct snd_soc_card *card, int event)
{
struct snd_soc_pcm_runtime *rtd;
int stream;
@@ -513,7 +513,7 @@ int snd_soc_suspend(struct device *dev)
snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot);
/* mute any active DACs */
- soc_playback_digital_mute(card, 1);
+ snd_soc_playback_digital_mute(card, 1);
/* suspend all pcms */
for_each_card_rtds(card, rtd) {
@@ -528,7 +528,7 @@ int snd_soc_suspend(struct device *dev)
/* close any waiting streams */
snd_soc_flush_all_delayed_work(card);
- soc_dapm_suspend_resume(card, SND_SOC_DAPM_STREAM_SUSPEND);
+ snd_soc_dapm_suspend_resume(card, SND_SOC_DAPM_STREAM_SUSPEND);
/* Recheck all endpoints too, their state is affected by suspend */
snd_soc_dapm_mark_endpoints_dirty(card);
@@ -589,51 +589,6 @@ int snd_soc_suspend(struct device *dev)
}
EXPORT_SYMBOL_GPL(snd_soc_suspend);
-/*
- * deferred resume work, so resume can complete before we finished
- * setting our codec back up, which can be very slow on I2C
- */
-static void soc_resume_deferred(struct work_struct *work)
-{
- struct snd_soc_card *card =
- container_of(work, struct snd_soc_card,
- deferred_resume_work);
- struct snd_soc_component *component;
-
- /*
- * our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
- * so userspace apps are blocked from touching us
- */
-
- dev_dbg(card->dev, "ASoC: starting resume work\n");
-
- /* Bring us up into D2 so that DAPM starts enabling things */
- snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2);
-
- snd_soc_card_resume_pre(card);
-
- for_each_card_components(card, component) {
- if (snd_soc_component_is_suspended(component))
- snd_soc_component_resume(component);
- }
-
- soc_dapm_suspend_resume(card, SND_SOC_DAPM_STREAM_RESUME);
-
- /* unmute any active DACs */
- soc_playback_digital_mute(card, 0);
-
- snd_soc_card_resume_post(card);
-
- dev_dbg(card->dev, "ASoC: resume work completed\n");
-
- /* Recheck all endpoints too, their state is affected by suspend */
- snd_soc_dapm_mark_endpoints_dirty(card);
- snd_soc_dapm_sync(snd_soc_card_to_dapm(card));
-
- /* userspace can access us now we are back as we were before */
- snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);
-}
-
/* powers up audio subsystem after a suspend */
int snd_soc_resume(struct device *dev)
{
@@ -657,15 +612,9 @@ int snd_soc_resume(struct device *dev)
}
EXPORT_SYMBOL_GPL(snd_soc_resume);
-static void soc_resume_init(struct snd_soc_card *card)
-{
- /* deferred resume work */
- INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
-}
#else
#define snd_soc_suspend NULL
#define snd_soc_resume NULL
-static inline void soc_resume_init(struct snd_soc_card *card) { }
#endif
struct of_phandle_args *snd_soc_copy_dai_args(struct device *dev,
@@ -1708,7 +1657,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
snd_soc_card_debugfs_init(card);
- soc_resume_init(card);
+ snd_soc_card_resume_init(card);
ret = snd_soc_dapm_new_controls(dapm, card->dapm_widgets,
card->num_dapm_widgets);
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index 550fc1c7ef05f..3d3703e58711d 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -19,6 +19,7 @@
*/
void snd_soc_card_debugfs_init(struct snd_soc_card *card);
void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card);
+void snd_soc_card_resume_init(struct snd_soc_card *card);
/*
* In soc-core
@@ -30,6 +31,10 @@ char *snd_soc_fmt_multiple_name(struct device *dev, struct snd_soc_dai_driver *d
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);
+#ifdef CONFIG_PM_SLEEP
+void snd_soc_playback_digital_mute(struct snd_soc_card *card, int mute);
+void snd_soc_dapm_suspend_resume(struct snd_soc_card *card, int event);
+#endif
/*
* In soc-dai
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 05/15] ASoC: soc-card: move snd_soc_card_fill_dummy_dai()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (3 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 04/15] ASoC: soc-card: move snd_soc_card_resume_init() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 06/15] ASoC: soc-card: move snd_soc_card_init_pcm_runtime() Kuninori Morimoto
` (10 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- snd_soc_fill_dummy_dai()
+ snd_soc_card_fill_dummy_dai()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 22 ++++++++++++++++++++++
sound/soc/soc-core.c | 24 +-----------------------
sound/soc/soc-internal.h | 1 +
3 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index bccd47cc136e6..6e2b8a86f4587 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -95,6 +95,28 @@ void snd_soc_card_resume_init(struct snd_soc_card *card)
void snd_soc_card_resume_init(struct snd_soc_card *card) { }
#endif /* CONFIG_PM_SLEEP */
+void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card)
+{
+ struct snd_soc_dai_link *dai_link;
+ int i;
+
+ /*
+ * COMP_DUMMY() creates size 0 array on dai_link.
+ * Fill it as dummy DAI in case of CPU/Codec here.
+ * Do nothing for Platform.
+ */
+ for_each_card_prelinks(card, i, dai_link) {
+ if (dai_link->num_cpus == 0 && dai_link->cpus) {
+ dai_link->num_cpus = 1;
+ dai_link->cpus = &snd_soc_dummy_dlc;
+ }
+ if (dai_link->num_codecs == 0 && dai_link->codecs) {
+ dai_link->num_codecs = 1;
+ dai_link->codecs = &snd_soc_dummy_dlc;
+ }
+ }
+}
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 901fddbbe25e8..9a0e058f34271 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -426,28 +426,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
return NULL;
}
-static void snd_soc_fill_dummy_dai(struct snd_soc_card *card)
-{
- struct snd_soc_dai_link *dai_link;
- int i;
-
- /*
- * COMP_DUMMY() creates size 0 array on dai_link.
- * Fill it as dummy DAI in case of CPU/Codec here.
- * Do nothing for Platform.
- */
- for_each_card_prelinks(card, i, dai_link) {
- if (dai_link->num_cpus == 0 && dai_link->cpus) {
- dai_link->num_cpus = 1;
- dai_link->cpus = &snd_soc_dummy_dlc;
- }
- if (dai_link->num_codecs == 0 && dai_link->codecs) {
- dai_link->num_codecs = 1;
- dai_link->codecs = &snd_soc_dummy_dlc;
- }
- }
-}
-
static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
@@ -1626,7 +1604,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
int ret;
snd_soc_card_mutex_lock_root(card);
- snd_soc_fill_dummy_dai(card);
+ snd_soc_card_fill_dummy_dai(card);
snd_soc_dapm_init(dapm, card, NULL);
list_del_init(&card->list);
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index 3d3703e58711d..1ec7aec68cb9c 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -20,6 +20,7 @@
void snd_soc_card_debugfs_init(struct snd_soc_card *card);
void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card);
void snd_soc_card_resume_init(struct snd_soc_card *card);
+void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card);
/*
* In soc-core
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 06/15] ASoC: soc-card: move snd_soc_card_init_pcm_runtime()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (4 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 05/15] ASoC: soc-card: move snd_soc_card_fill_dummy_dai() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 07/15] ASoC: soc-card: move snd_soc_card_link_dais_xxx() Kuninori Morimoto
` (9 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- soc_init_pcm_runtime()
+ snd_soc_card_init_pcm_runtime()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 49 +++++++++++++++++++++++++++++++++++++++
sound/soc/soc-core.c | 50 +---------------------------------------
sound/soc/soc-internal.h | 2 ++
3 files changed, 52 insertions(+), 49 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 6e2b8a86f4587..405d88e57fcbc 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -10,6 +10,7 @@
#include <linux/lockdep.h>
#include <linux/rwsem.h>
#include <sound/soc.h>
+#include <sound/soc-link.h>
#include <sound/jack.h>
#include "soc-internal.h"
@@ -117,6 +118,54 @@ void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card)
}
}
+int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
+ struct snd_soc_pcm_runtime *rtd)
+{
+ struct snd_soc_dai_link *dai_link = rtd->dai_link;
+ struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
+ int ret;
+
+ /* do machine specific initialization */
+ ret = snd_soc_link_init(rtd);
+ if (ret < 0)
+ return ret;
+
+ ret = snd_soc_runtime_set_dai_fmt(rtd, snd_soc_dai_auto_select_format(rtd));
+ if (ret)
+ goto err;
+
+ /* add DPCM sysfs entries */
+ soc_dpcm_debugfs_add(rtd);
+
+ /* create compress_device if driver is supporting */
+ ret = snd_soc_dai_compress_new(cpu_dai, rtd);
+ if (ret != -ENOTSUPP) { /* driver is supporting */
+ if (ret < 0)
+ goto err;
+ goto end;
+ }
+
+ /* create the pcm */
+ ret = soc_new_pcm(rtd);
+ if (ret < 0) {
+ dev_err(card->dev, "ASoC: can't create pcm %s :%d\n",
+ dai_link->stream_name, ret);
+ goto err;
+ }
+
+ ret = snd_soc_pcm_dai_new(rtd);
+ if (ret < 0)
+ goto err;
+end:
+ rtd->initialized = true;
+
+ return 0;
+err:
+ snd_soc_link_exit(rtd);
+
+ return ret;
+}
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9a0e058f34271..c1d64892f3876 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1076,54 +1076,6 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
}
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
-static int soc_init_pcm_runtime(struct snd_soc_card *card,
- struct snd_soc_pcm_runtime *rtd)
-{
- struct snd_soc_dai_link *dai_link = rtd->dai_link;
- struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
- int ret;
-
- /* do machine specific initialization */
- ret = snd_soc_link_init(rtd);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_runtime_set_dai_fmt(rtd, snd_soc_dai_auto_select_format(rtd));
- if (ret)
- goto err;
-
- /* add DPCM sysfs entries */
- soc_dpcm_debugfs_add(rtd);
-
- /* create compress_device if driver is supporting */
- ret = snd_soc_dai_compress_new(cpu_dai, rtd);
- if (ret != -ENOTSUPP) { /* driver is supporting */
- if (ret < 0)
- goto err;
- goto end;
- }
-
- /* create the pcm */
- ret = soc_new_pcm(rtd);
- if (ret < 0) {
- dev_err(card->dev, "ASoC: can't create pcm %s :%d\n",
- dai_link->stream_name, ret);
- goto err;
- }
-
- ret = snd_soc_pcm_dai_new(rtd);
- if (ret < 0)
- goto err;
-end:
- rtd->initialized = true;
-
- return 0;
-err:
- snd_soc_link_exit(rtd);
-
- return ret;
-}
-
static void soc_remove_link_dais(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
@@ -1679,7 +1631,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
}
for_each_card_rtds(card, rtd) {
- ret = soc_init_pcm_runtime(card, rtd);
+ ret = snd_soc_card_init_pcm_runtime(card, rtd);
if (ret < 0)
goto probe_end;
}
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index 1ec7aec68cb9c..2b4beca5f9e5b 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -21,6 +21,8 @@ void snd_soc_card_debugfs_init(struct snd_soc_card *card);
void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card);
void snd_soc_card_resume_init(struct snd_soc_card *card);
void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card);
+int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
+ struct snd_soc_pcm_runtime *rtd);
/*
* In soc-core
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 07/15] ASoC: soc-card: move snd_soc_card_link_dais_xxx()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (5 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 06/15] ASoC: soc-card: move snd_soc_card_init_pcm_runtime() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 08/15] ASoC: soc-card: move snd_soc_card_link_components_xxx() Kuninori Morimoto
` (8 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- soc_remove_link_dais()
- soc_probe_link_dais()
+ snd_soc_card_link_dais_remove()
+ snd_soc_card_link_dais_probe()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 30 ++++++++++++++++++++++++++++++
sound/soc/soc-core.c | 34 ++--------------------------------
sound/soc/soc-internal.h | 2 ++
3 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 405d88e57fcbc..1d16cd74eee90 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -166,6 +166,36 @@ int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
return ret;
}
+void snd_soc_card_link_dais_remove(struct snd_soc_card *card)
+{
+ struct snd_soc_pcm_runtime *rtd;
+ int order;
+
+ for_each_comp_order(order) {
+ for_each_card_rtds(card, rtd) {
+ /* remove all rtd connected DAIs in good order */
+ snd_soc_pcm_dai_remove(rtd, order);
+ }
+ }
+}
+
+int snd_soc_card_link_dais_probe(struct snd_soc_card *card)
+{
+ struct snd_soc_pcm_runtime *rtd;
+ int order, ret;
+
+ for_each_comp_order(order) {
+ for_each_card_rtds(card, rtd) {
+ /* probe all rtd connected DAIs in good order */
+ ret = snd_soc_pcm_dai_probe(rtd, order);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c1d64892f3876..e3664cbe67059 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1076,36 +1076,6 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
}
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
-static void soc_remove_link_dais(struct snd_soc_card *card)
-{
- struct snd_soc_pcm_runtime *rtd;
- int order;
-
- for_each_comp_order(order) {
- for_each_card_rtds(card, rtd) {
- /* remove all rtd connected DAIs in good order */
- snd_soc_pcm_dai_remove(rtd, order);
- }
- }
-}
-
-static int soc_probe_link_dais(struct snd_soc_card *card)
-{
- struct snd_soc_pcm_runtime *rtd;
- int order, ret;
-
- for_each_comp_order(order) {
- for_each_card_rtds(card, rtd) {
- /* probe all rtd connected DAIs in good order */
- ret = snd_soc_pcm_dai_probe(rtd, order);
- if (ret)
- return ret;
- }
- }
-
- return 0;
-}
-
static void soc_remove_link_components(struct snd_soc_card *card)
{
struct snd_soc_component *component;
@@ -1503,7 +1473,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
snd_soc_flush_all_delayed_work(card);
/* remove and free each DAI */
- soc_remove_link_dais(card);
+ snd_soc_card_link_dais_remove(card);
soc_remove_link_components(card);
for_each_card_rtds_safe(card, rtd, n)
@@ -1623,7 +1593,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
}
/* probe all DAI links on this card */
- ret = soc_probe_link_dais(card);
+ ret = snd_soc_card_link_dais_probe(card);
if (ret < 0) {
dev_err(card->dev,
"ASoC: failed to instantiate card %d\n", ret);
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index 2b4beca5f9e5b..e95b34a7869b4 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -23,6 +23,8 @@ void snd_soc_card_resume_init(struct snd_soc_card *card);
void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card);
int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
struct snd_soc_pcm_runtime *rtd);
+void snd_soc_card_link_dais_remove(struct snd_soc_card *card);
+int snd_soc_card_link_dais_probe(struct snd_soc_card *card);
/*
* In soc-core
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 08/15] ASoC: soc-card: move snd_soc_card_link_components_xxx()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (6 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 07/15] ASoC: soc-card: move snd_soc_card_link_dais_xxx() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 09/15] ASoC: soc-card: move snd_soc_card_aux_[un]bind() Kuninori Morimoto
` (7 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- soc_remove_link_components()
- soc_probe_link_components()
+ snd_soc_card_link_components_remove()
+ snd_soc_card_link_components_probe()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 40 ++++++++++++++++++++++++++++++++++++
sound/soc/soc-core.c | 44 ++--------------------------------------
sound/soc/soc-internal.h | 2 ++
3 files changed, 44 insertions(+), 42 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 1d16cd74eee90..65217ac4f699f 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -196,6 +196,46 @@ int snd_soc_card_link_dais_probe(struct snd_soc_card *card)
return 0;
}
+void snd_soc_card_link_components_remove(struct snd_soc_card *card)
+{
+ struct snd_soc_component *component;
+ struct snd_soc_pcm_runtime *rtd;
+ int i, order;
+
+ for_each_comp_order(order) {
+ for_each_card_rtds(card, rtd) {
+ for_each_rtd_components(rtd, i, component) {
+ if (component->driver->remove_order != order)
+ continue;
+
+ snd_soc_component_remove(component, 1);
+ }
+ }
+ }
+}
+
+int snd_soc_card_link_components_probe(struct snd_soc_card *card)
+{
+ struct snd_soc_component *component;
+ struct snd_soc_pcm_runtime *rtd;
+ int i, ret, order;
+
+ for_each_comp_order(order) {
+ for_each_card_rtds(card, rtd) {
+ for_each_rtd_components(rtd, i, component) {
+ if (component->driver->probe_order != order)
+ continue;
+
+ ret = snd_soc_component_probe(component, card);
+ if (ret < 0)
+ return ret;
+ }
+ }
+ }
+
+ return 0;
+}
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index e3664cbe67059..e1779b2b91476 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1076,46 +1076,6 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
}
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
-static void soc_remove_link_components(struct snd_soc_card *card)
-{
- struct snd_soc_component *component;
- struct snd_soc_pcm_runtime *rtd;
- int i, order;
-
- for_each_comp_order(order) {
- for_each_card_rtds(card, rtd) {
- for_each_rtd_components(rtd, i, component) {
- if (component->driver->remove_order != order)
- continue;
-
- snd_soc_component_remove(component, 1);
- }
- }
- }
-}
-
-static int soc_probe_link_components(struct snd_soc_card *card)
-{
- struct snd_soc_component *component;
- struct snd_soc_pcm_runtime *rtd;
- int i, ret, order;
-
- for_each_comp_order(order) {
- for_each_card_rtds(card, rtd) {
- for_each_rtd_components(rtd, i, component) {
- if (component->driver->probe_order != order)
- continue;
-
- ret = snd_soc_component_probe(component, card);
- if (ret < 0)
- return ret;
- }
- }
- }
-
- return 0;
-}
-
static void soc_unbind_aux_dev(struct snd_soc_card *card)
{
struct snd_soc_component *component, *_component;
@@ -1474,7 +1434,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
/* remove and free each DAI */
snd_soc_card_link_dais_remove(card);
- soc_remove_link_components(card);
+ snd_soc_card_link_components_remove(card);
for_each_card_rtds_safe(card, rtd, n)
snd_soc_remove_pcm_runtime(card, rtd);
@@ -1575,7 +1535,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
goto probe_end;
/* probe all components used by DAI links on this card */
- ret = soc_probe_link_components(card);
+ ret = snd_soc_card_link_components_probe(card);
if (ret < 0) {
if (ret != -EPROBE_DEFER) {
dev_err(card->dev,
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index e95b34a7869b4..c441268fb848d 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -25,6 +25,8 @@ int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
struct snd_soc_pcm_runtime *rtd);
void snd_soc_card_link_dais_remove(struct snd_soc_card *card);
int snd_soc_card_link_dais_probe(struct snd_soc_card *card);
+void snd_soc_card_link_components_remove(struct snd_soc_card *card);
+int snd_soc_card_link_components_probe(struct snd_soc_card *card);
/*
* In soc-core
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 09/15] ASoC: soc-card: move snd_soc_card_aux_[un]bind()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (7 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 08/15] ASoC: soc-card: move snd_soc_card_link_components_xxx() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 10/15] ASoC: soc-card: move snd_soc_card_aux_{remove/probe}() Kuninori Morimoto
` (6 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- soc_unbind_aux_dev()
- soc_bind_aux_dev()
+ snd_soc_card_aux_unbind()
+ snd_soc_card_aux_bind()
Below function is used on above functions. Add them at soc-internal.h
Align with existing snd_soc_find_dai()
- soc_find_component()
+ snd_soc_find_component()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 31 +++++++++++++++++++++++++++
sound/soc/soc-core.c | 46 ++++++----------------------------------
sound/soc/soc-internal.h | 3 +++
3 files changed, 41 insertions(+), 39 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 65217ac4f699f..dcfecec486570 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -236,6 +236,37 @@ int snd_soc_card_link_components_probe(struct snd_soc_card *card)
return 0;
}
+void snd_soc_card_aux_unbind(struct snd_soc_card *card)
+{
+ struct snd_soc_component *component, *_component;
+
+ for_each_card_auxs_safe(card, component, _component) {
+ /* for snd_soc_component_init() */
+ snd_soc_component_set_aux(component, NULL);
+ list_del(&component->card_aux_list);
+ }
+}
+
+int snd_soc_card_aux_bind(struct snd_soc_card *card)
+{
+ struct snd_soc_component *component;
+ struct snd_soc_aux_dev *aux;
+ int i;
+
+ for_each_card_pre_auxs(card, i, aux) {
+ /* codecs, usually analog devices */
+ component = snd_soc_find_component(&aux->dlc);
+ if (!component)
+ return -EPROBE_DEFER;
+
+ /* for snd_soc_component_init() */
+ snd_soc_component_set_aux(component, aux);
+ /* see for_each_card_auxs */
+ list_add(&component->card_aux_list, &card->aux_comp_list);
+ }
+ return 0;
+}
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index e1779b2b91476..0e25700688696 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -609,8 +609,7 @@ struct of_phandle_args *snd_soc_copy_dai_args(struct device *dev,
}
EXPORT_SYMBOL_GPL(snd_soc_copy_dai_args);
-static struct snd_soc_component *soc_find_component(
- const struct snd_soc_dai_link_component *dlc)
+struct snd_soc_component *snd_soc_find_component(const struct snd_soc_dai_link_component *dlc)
{
struct snd_soc_component *component;
@@ -696,7 +695,7 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card,
* Defer card registration if codec component is not added to
* component list.
*/
- if (!soc_find_component(dlc))
+ if (!snd_soc_find_component(dlc))
goto component_not_found;
}
@@ -717,7 +716,7 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card,
* Defer card registration if platform component is not added to
* component list.
*/
- if (!soc_find_component(dlc))
+ if (!snd_soc_find_component(dlc))
goto component_not_found;
}
@@ -742,7 +741,7 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card,
/*
* Defer card registration if Component is not added
*/
- if (!soc_find_component(dlc))
+ if (!snd_soc_find_component(dlc))
goto component_not_found;
}
}
@@ -1076,37 +1075,6 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
}
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
-static void soc_unbind_aux_dev(struct snd_soc_card *card)
-{
- struct snd_soc_component *component, *_component;
-
- for_each_card_auxs_safe(card, component, _component) {
- /* for snd_soc_component_init() */
- snd_soc_component_set_aux(component, NULL);
- list_del(&component->card_aux_list);
- }
-}
-
-static int soc_bind_aux_dev(struct snd_soc_card *card)
-{
- struct snd_soc_component *component;
- struct snd_soc_aux_dev *aux;
- int i;
-
- for_each_card_pre_auxs(card, i, aux) {
- /* codecs, usually analog devices */
- component = soc_find_component(&aux->dlc);
- if (!component)
- return -EPROBE_DEFER;
-
- /* for snd_soc_component_init() */
- snd_soc_component_set_aux(component, aux);
- /* see for_each_card_auxs */
- list_add(&component->card_aux_list, &card->aux_comp_list);
- }
- return 0;
-}
-
static int soc_probe_aux_devices(struct snd_soc_card *card)
{
struct snd_soc_component *component;
@@ -1441,7 +1409,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
/* remove auxiliary devices */
soc_remove_aux_devices(card);
- soc_unbind_aux_dev(card);
+ snd_soc_card_aux_unbind(card);
snd_soc_dapm_free(snd_soc_card_to_dapm(card));
snd_soc_card_debugfs_cleanup(card);
@@ -1495,7 +1463,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
soc_check_tplg_fes(card);
/* bind aux_devs too */
- ret = soc_bind_aux_dev(card);
+ ret = snd_soc_card_aux_bind(card);
if (ret < 0)
goto probe_end;
@@ -2795,7 +2763,7 @@ int snd_soc_get_dai_id(struct device_node *ep)
ret = -ENOTSUPP;
scoped_guard(mutex, &client_mutex) {
- struct snd_soc_component *component = soc_find_component(&dlc);
+ struct snd_soc_component *component = snd_soc_find_component(&dlc);
if (component)
ret = snd_soc_component_of_xlate_dai_id(component, ep);
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index c441268fb848d..df3c3cb783fde 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -27,6 +27,8 @@ void snd_soc_card_link_dais_remove(struct snd_soc_card *card);
int snd_soc_card_link_dais_probe(struct snd_soc_card *card);
void snd_soc_card_link_components_remove(struct snd_soc_card *card);
int snd_soc_card_link_components_probe(struct snd_soc_card *card);
+void snd_soc_card_aux_unbind(struct snd_soc_card *card);
+int snd_soc_card_aux_bind(struct snd_soc_card *card);
/*
* In soc-core
@@ -38,6 +40,7 @@ char *snd_soc_fmt_multiple_name(struct device *dev, struct snd_soc_dai_driver *d
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);
+struct snd_soc_component *snd_soc_find_component(const struct snd_soc_dai_link_component *dlc);
#ifdef CONFIG_PM_SLEEP
void snd_soc_playback_digital_mute(struct snd_soc_card *card, int mute);
void snd_soc_dapm_suspend_resume(struct snd_soc_card *card, int event);
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 10/15] ASoC: soc-card: move snd_soc_card_aux_{remove/probe}()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (8 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 09/15] ASoC: soc-card: move snd_soc_card_aux_[un]bind() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 11/15] ASoC: soc-card: move snd_soc_card_set_dmi_name() Kuninori Morimoto
` (5 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- soc_remove_aux_devices()
- soc_probe_aux_devices()
+ snd_soc_card_aux_remove()
+ snd_soc_card_aux_probe()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 33 +++++++++++++++++++++++++++++++++
sound/soc/soc-core.c | 37 ++-----------------------------------
sound/soc/soc-internal.h | 2 ++
3 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index dcfecec486570..432882471537c 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -267,6 +267,39 @@ int snd_soc_card_aux_bind(struct snd_soc_card *card)
return 0;
}
+int snd_soc_card_aux_probe(struct snd_soc_card *card)
+{
+ struct snd_soc_component *component;
+ int order;
+ int ret;
+
+ for_each_comp_order(order) {
+ for_each_card_auxs(card, component) {
+ if (component->driver->probe_order != order)
+ continue;
+
+ ret = snd_soc_component_probe(component, card);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+void snd_soc_card_aux_remove(struct snd_soc_card *card)
+{
+ struct snd_soc_component *comp, *_comp;
+ int order;
+
+ for_each_comp_order(order) {
+ for_each_card_auxs_safe(card, comp, _comp) {
+ if (comp->driver->remove_order == order)
+ snd_soc_component_remove(comp, 1);
+ }
+ }
+}
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 0e25700688696..2b47186640a1b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1075,39 +1075,6 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
}
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
-static int soc_probe_aux_devices(struct snd_soc_card *card)
-{
- struct snd_soc_component *component;
- int order;
- int ret;
-
- for_each_comp_order(order) {
- for_each_card_auxs(card, component) {
- if (component->driver->probe_order != order)
- continue;
-
- ret = snd_soc_component_probe(component, card);
- if (ret < 0)
- return ret;
- }
- }
-
- return 0;
-}
-
-static void soc_remove_aux_devices(struct snd_soc_card *card)
-{
- struct snd_soc_component *comp, *_comp;
- int order;
-
- for_each_comp_order(order) {
- for_each_card_auxs_safe(card, comp, _comp) {
- if (comp->driver->remove_order == order)
- snd_soc_component_remove(comp, 1);
- }
- }
-}
-
#ifdef CONFIG_DMI
/*
* If a DMI filed contain strings in this blacklist (e.g.
@@ -1408,7 +1375,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
snd_soc_remove_pcm_runtime(card, rtd);
/* remove auxiliary devices */
- soc_remove_aux_devices(card);
+ snd_soc_card_aux_remove(card);
snd_soc_card_aux_unbind(card);
snd_soc_dapm_free(snd_soc_card_to_dapm(card));
@@ -1513,7 +1480,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
}
/* probe auxiliary components */
- ret = soc_probe_aux_devices(card);
+ ret = snd_soc_card_aux_probe(card);
if (ret < 0) {
dev_err(card->dev,
"ASoC: failed to probe aux component %d\n", ret);
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index df3c3cb783fde..ffe055e1b2de2 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -29,6 +29,8 @@ void snd_soc_card_link_components_remove(struct snd_soc_card *card);
int snd_soc_card_link_components_probe(struct snd_soc_card *card);
void snd_soc_card_aux_unbind(struct snd_soc_card *card);
int snd_soc_card_aux_bind(struct snd_soc_card *card);
+int snd_soc_card_aux_probe(struct snd_soc_card *card);
+void snd_soc_card_aux_remove(struct snd_soc_card *card);
/*
* In soc-core
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 11/15] ASoC: soc-card: move snd_soc_card_set_dmi_name()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (9 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 10/15] ASoC: soc-card: move snd_soc_card_aux_{remove/probe}() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 12/15] ASoC: soc-card: move snd_soc_card_bind_call() Kuninori Morimoto
` (4 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- snd_soc_set_dmi_name()
+ snd_soc_card_set_dmi_name()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 165 ++++++++++++++++++++++++++++++++++++++
sound/soc/soc-core.c | 167 +--------------------------------------
sound/soc/soc-internal.h | 1 +
3 files changed, 167 insertions(+), 166 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 432882471537c..c64c9d425bcf9 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -7,6 +7,7 @@
//
#include <linux/debugfs.h>
+#include <linux/dmi.h>
#include <linux/lockdep.h>
#include <linux/rwsem.h>
#include <sound/soc.h>
@@ -300,6 +301,170 @@ void snd_soc_card_aux_remove(struct snd_soc_card *card)
}
}
+#ifdef CONFIG_DMI
+/*
+ * If a DMI filed contain strings in this blacklist (e.g.
+ * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken
+ * as invalid and dropped when setting the card long name from DMI info.
+ */
+static const char * const dmi_blacklist[] = {
+ "To be filled by OEM",
+ "TBD by OEM",
+ "Default String",
+ "Board Manufacturer",
+ "Board Vendor Name",
+ "Board Product Name",
+ NULL, /* terminator */
+};
+
+/*
+ * Trim special characters, and replace '-' with '_' since '-' is used to
+ * separate different DMI fields in the card long name. Only number and
+ * alphabet characters and a few separator characters are kept.
+ */
+static void cleanup_dmi_name(char *name)
+{
+ int i, j = 0;
+
+ for (i = 0; name[i]; i++) {
+ if (isalnum(name[i]) || (name[i] == '.')
+ || (name[i] == '_'))
+ name[j++] = name[i];
+ else if (name[i] == '-')
+ name[j++] = '_';
+ }
+
+ name[j] = '\0';
+}
+
+/*
+ * Check if a DMI field is valid, i.e. not containing any string
+ * in the black list and not the empty string.
+ */
+static int is_dmi_valid(const char *field)
+{
+ int i = 0;
+
+ if (!field[0])
+ return 0;
+
+ while (dmi_blacklist[i]) {
+ if (strstr(field, dmi_blacklist[i]))
+ return 0;
+ i++;
+ }
+
+ return 1;
+}
+
+/*
+ * Append a string to dmi_longname with character cleanups.
+ */
+#define DMI_LONGNAME_LEN 80
+static void append_dmi_string(char *dst, const char *str)
+{
+ size_t dst_len = DMI_LONGNAME_LEN;
+ size_t len;
+
+ len = strlen(dst);
+ snprintf(dst + len, dst_len - len, "-%s", str);
+
+ len++; /* skip the separator "-" */
+ if (len < dst_len)
+ cleanup_dmi_name(dst + len);
+}
+
+/**
+ * snd_soc_card_set_dmi_name() - Register DMI names to card
+ * @card: The card to register DMI names
+ *
+ * An Intel machine driver may be used by many different devices but are
+ * difficult for userspace to differentiate, since machine drivers usually
+ * use their own name as the card short name and leave the card long name
+ * blank. To differentiate such devices and fix bugs due to lack of
+ * device-specific configurations, this function allows DMI info to be used
+ * as the sound card long name, in the format of
+ * "vendor-product-version-board"
+ * (Character '-' is used to separate different DMI fields here).
+ * This will help the user space to load the device-specific Use Case Manager
+ * (UCM) configurations for the card.
+ *
+ * Possible card long names may be:
+ * DellInc.-XPS139343-01-0310JH
+ * ASUSTeKCOMPUTERINC.-T100TA-1.0-T100TA
+ * Circuitco-MinnowboardMaxD0PLATFORM-D0-MinnowBoardMAX
+ *
+ * This function also supports flavoring the card longname to provide
+ * the extra differentiation, like "vendor-product-version-board-flavor".
+ *
+ * We only keep number and alphabet characters and a few separator characters
+ * in the card long name since UCM in the user space uses the card long names
+ * as card configuration directory names and AudoConf cannot support special
+ * characters like SPACE.
+ *
+ * Returns 0 on success, otherwise a negative error code.
+ */
+int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
+{
+ const char *vendor, *product, *board;
+ char *dmi_longname;
+
+ if (card->long_name)
+ return 0; /* long name already set by driver or from DMI */
+
+ if (!dmi_available)
+ return 0;
+
+ /* make up dmi long name as: vendor-product-version-board */
+ vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+ if (!vendor || !is_dmi_valid(vendor)) {
+ dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
+ return 0;
+ }
+
+ dmi_longname = devm_kzalloc(card->dev, DMI_LONGNAME_LEN, GFP_KERNEL);
+ if (!dmi_longname)
+ return -ENOMEM;
+
+ snprintf(dmi_longname, DMI_LONGNAME_LEN, "%s", vendor);
+ cleanup_dmi_name(dmi_longname);
+
+ product = dmi_get_system_info(DMI_PRODUCT_NAME);
+ if (product && is_dmi_valid(product)) {
+ const char *product_version = dmi_get_system_info(DMI_PRODUCT_VERSION);
+
+ append_dmi_string(dmi_longname, product);
+
+ /*
+ * some vendors like Lenovo may only put a self-explanatory
+ * name in the product version field
+ */
+ if (product_version && is_dmi_valid(product_version))
+ append_dmi_string(dmi_longname, product_version);
+ }
+
+ board = dmi_get_system_info(DMI_BOARD_NAME);
+ if (board && is_dmi_valid(board)) {
+ if (!product || strcasecmp(board, product))
+ append_dmi_string(dmi_longname, board);
+ } else if (!product) {
+ /* fall back to using legacy name */
+ dev_warn(card->dev, "ASoC: no DMI board/product name!\n");
+ return 0;
+ }
+
+ /* set the card long name */
+ card->long_name = dmi_longname;
+
+ return 0;
+}
+#else
+int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
+{
+ return 0;
+}
+#endif /* CONFIG_DMI */
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2b47186640a1b..12b8bcb93ceeb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -30,7 +30,6 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_graph.h>
-#include <linux/dmi.h>
#include <linux/acpi.h>
#include <linux/string_choices.h>
#include <sound/core.h>
@@ -1075,170 +1074,6 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
}
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
-#ifdef CONFIG_DMI
-/*
- * If a DMI filed contain strings in this blacklist (e.g.
- * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken
- * as invalid and dropped when setting the card long name from DMI info.
- */
-static const char * const dmi_blacklist[] = {
- "To be filled by OEM",
- "TBD by OEM",
- "Default String",
- "Board Manufacturer",
- "Board Vendor Name",
- "Board Product Name",
- NULL, /* terminator */
-};
-
-/*
- * Trim special characters, and replace '-' with '_' since '-' is used to
- * separate different DMI fields in the card long name. Only number and
- * alphabet characters and a few separator characters are kept.
- */
-static void cleanup_dmi_name(char *name)
-{
- int i, j = 0;
-
- for (i = 0; name[i]; i++) {
- if (isalnum(name[i]) || (name[i] == '.')
- || (name[i] == '_'))
- name[j++] = name[i];
- else if (name[i] == '-')
- name[j++] = '_';
- }
-
- name[j] = '\0';
-}
-
-/*
- * Check if a DMI field is valid, i.e. not containing any string
- * in the black list and not the empty string.
- */
-static int is_dmi_valid(const char *field)
-{
- int i = 0;
-
- if (!field[0])
- return 0;
-
- while (dmi_blacklist[i]) {
- if (strstr(field, dmi_blacklist[i]))
- return 0;
- i++;
- }
-
- return 1;
-}
-
-/*
- * Append a string to dmi_longname with character cleanups.
- */
-#define DMI_LONGNAME_LEN 80
-static void append_dmi_string(char *dst, const char *str)
-{
- size_t dst_len = DMI_LONGNAME_LEN;
- size_t len;
-
- len = strlen(dst);
- snprintf(dst + len, dst_len - len, "-%s", str);
-
- len++; /* skip the separator "-" */
- if (len < dst_len)
- cleanup_dmi_name(dst + len);
-}
-
-/**
- * snd_soc_set_dmi_name() - Register DMI names to card
- * @card: The card to register DMI names
- *
- * An Intel machine driver may be used by many different devices but are
- * difficult for userspace to differentiate, since machine drivers usually
- * use their own name as the card short name and leave the card long name
- * blank. To differentiate such devices and fix bugs due to lack of
- * device-specific configurations, this function allows DMI info to be used
- * as the sound card long name, in the format of
- * "vendor-product-version-board"
- * (Character '-' is used to separate different DMI fields here).
- * This will help the user space to load the device-specific Use Case Manager
- * (UCM) configurations for the card.
- *
- * Possible card long names may be:
- * DellInc.-XPS139343-01-0310JH
- * ASUSTeKCOMPUTERINC.-T100TA-1.0-T100TA
- * Circuitco-MinnowboardMaxD0PLATFORM-D0-MinnowBoardMAX
- *
- * This function also supports flavoring the card longname to provide
- * the extra differentiation, like "vendor-product-version-board-flavor".
- *
- * We only keep number and alphabet characters and a few separator characters
- * in the card long name since UCM in the user space uses the card long names
- * as card configuration directory names and AudoConf cannot support special
- * characters like SPACE.
- *
- * Returns 0 on success, otherwise a negative error code.
- */
-static int snd_soc_set_dmi_name(struct snd_soc_card *card)
-{
- const char *vendor, *product, *board;
- char *dmi_longname;
-
- if (card->long_name)
- return 0; /* long name already set by driver or from DMI */
-
- if (!dmi_available)
- return 0;
-
- /* make up dmi long name as: vendor-product-version-board */
- vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
- if (!vendor || !is_dmi_valid(vendor)) {
- dev_warn(card->dev, "ASoC: no DMI vendor name!\n");
- return 0;
- }
-
- dmi_longname = devm_kzalloc(card->dev, DMI_LONGNAME_LEN, GFP_KERNEL);
- if (!dmi_longname)
- return -ENOMEM;
-
- snprintf(dmi_longname, DMI_LONGNAME_LEN, "%s", vendor);
- cleanup_dmi_name(dmi_longname);
-
- product = dmi_get_system_info(DMI_PRODUCT_NAME);
- if (product && is_dmi_valid(product)) {
- const char *product_version = dmi_get_system_info(DMI_PRODUCT_VERSION);
-
- append_dmi_string(dmi_longname, product);
-
- /*
- * some vendors like Lenovo may only put a self-explanatory
- * name in the product version field
- */
- if (product_version && is_dmi_valid(product_version))
- append_dmi_string(dmi_longname, product_version);
- }
-
- board = dmi_get_system_info(DMI_BOARD_NAME);
- if (board && is_dmi_valid(board)) {
- if (!product || strcasecmp(board, product))
- append_dmi_string(dmi_longname, board);
- } else if (!product) {
- /* fall back to using legacy name */
- dev_warn(card->dev, "ASoC: no DMI board/product name!\n");
- return 0;
- }
-
- /* set the card long name */
- card->long_name = dmi_longname;
-
- return 0;
-}
-#else
-static inline int snd_soc_set_dmi_name(struct snd_soc_card *card)
-{
- return 0;
-}
-#endif /* CONFIG_DMI */
-
static void soc_check_tplg_fes(struct snd_soc_card *card)
{
struct snd_soc_component *component;
@@ -1520,7 +1355,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
goto probe_end;
/* try to set some sane longname if DMI is available */
- snd_soc_set_dmi_name(card);
+ snd_soc_card_set_dmi_name(card);
soc_setup_card_name(card, card->snd_card->shortname,
card->name, NULL);
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index ffe055e1b2de2..e1f456e222b63 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -31,6 +31,7 @@ void snd_soc_card_aux_unbind(struct snd_soc_card *card);
int snd_soc_card_aux_bind(struct snd_soc_card *card);
int snd_soc_card_aux_probe(struct snd_soc_card *card);
void snd_soc_card_aux_remove(struct snd_soc_card *card);
+int snd_soc_card_set_dmi_name(struct snd_soc_card *card);
/*
* In soc-core
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 12/15] ASoC: soc-card: move snd_soc_card_bind_call()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (10 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 11/15] ASoC: soc-card: move snd_soc_card_set_dmi_name() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 9:41 ` Alvin Šipraga
2026-10-28 3:03 ` [PATCH 13/15] ASoC: soc-card: add snd_soc_card_rebind() Kuninori Morimoto
` (3 subsequent siblings)
15 siblings, 1 reply; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
It has too many local function dependencies.
This patch uses temporary funciton define at soc-internal.h. It will be
removed all funciton were moved.
It renames function name
- call_soc_bind_card()
- snd_soc_bind_card()
- snd_soc_unbind_card()
+ snd_soc_card_bind_call()
+ snd_soc_card_bind()
+ snd_soc_card_unbind()
Below function is used on above functions. Add them at soc-internal.h
+ snd_soc_flush_all_delayed_work()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 411 +++++++++++++++++++++++++++++++++++++-
sound/soc/soc-core.c | 419 +--------------------------------------
sound/soc/soc-internal.h | 8 +
3 files changed, 422 insertions(+), 416 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index c64c9d425bcf9..72b40f842bd43 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -9,12 +9,16 @@
#include <linux/debugfs.h>
#include <linux/dmi.h>
#include <linux/lockdep.h>
+#include <linux/pinctrl/consumer.h>
#include <linux/rwsem.h>
+#include <sound/initval.h>
#include <sound/soc.h>
#include <sound/soc-link.h>
#include <sound/jack.h>
#include "soc-internal.h"
+LIST_HEAD(unbind_card_list);
+
#define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret)
static inline int _soc_card_ret(struct snd_soc_card *card,
const char *func, int ret)
@@ -465,6 +469,157 @@ int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
}
#endif /* CONFIG_DMI */
+static void soc_card_check_tplg_fes(struct snd_soc_card *card)
+{
+ struct snd_soc_component *component;
+ struct snd_soc_dai_link *dai_link;
+ int i;
+
+ for_each_component(component) {
+
+ /* does this component override BEs ? */
+ if (!component->driver->ignore_machine)
+ continue;
+
+ /* for this machine ? */
+ if (!strcmp(component->driver->ignore_machine,
+ card->dev->driver->name))
+ goto match;
+ if (strcmp(component->driver->ignore_machine,
+ dev_name(card->dev)))
+ continue;
+match:
+ /* machine matches, so override the rtd data */
+ for_each_card_prelinks(card, i, dai_link) {
+
+ /* ignore this FE */
+ if (dai_link->dynamic) {
+ dai_link->ignore = true;
+ continue;
+ }
+
+ dev_dbg(card->dev, "info: override BE DAI link %s\n",
+ dai_link->name);
+
+ /* override platform component */
+ if (!dai_link->platforms) {
+ dev_err(card->dev, "init platform error");
+ continue;
+ }
+
+ if (component->dev->of_node)
+ dai_link->platforms->of_node = component->dev->of_node;
+ else
+ dai_link->platforms->name = component->name;
+
+ /* convert non BE into BE */
+ dai_link->no_pcm = 1;
+
+ /*
+ * override any BE fixups
+ * see
+ * snd_soc_link_be_hw_params_fixup()
+ */
+ dai_link->be_hw_params_fixup =
+ component->driver->be_hw_params_fixup;
+
+ /*
+ * most BE links don't set stream name, so set it to
+ * dai link name if it's NULL to help bind widgets.
+ */
+ if (!dai_link->stream_name)
+ dai_link->stream_name = dai_link->name;
+ }
+
+ /* Inform userspace we are using alternate topology */
+ snd_soc_card_set_topology_name(card, component->driver->topology_name_prefix);
+ }
+}
+
+#define soc_card_setup_name(card, name, name1, name2) \
+ __soc_card_setup_name(card, name, sizeof(name), name1, name2)
+static void __soc_card_setup_name(struct snd_soc_card *card,
+ char *name, int len,
+ const char *name1, const char *name2)
+{
+ const char *src = name1 ? name1 : name2;
+ int i;
+
+ snprintf(name, len, "%s", src);
+
+ if (name != card->snd_card->driver)
+ return;
+
+ /*
+ * Name normalization (driver field)
+ *
+ * The driver name is somewhat special, as it's used as a key for
+ * searches in the user-space.
+ *
+ * ex)
+ * "abcd??efg" -> "abcd__efg"
+ */
+ for (i = 0; i < len; i++) {
+ switch (name[i]) {
+ case '_':
+ case '-':
+ case '\0':
+ break;
+ default:
+ if (!isalnum(name[i]))
+ name[i] = '_';
+ break;
+ }
+ }
+
+ /*
+ * The driver field should contain a valid string from the user view.
+ * The wrapping usually does not work so well here. Set a smaller string
+ * in the specific ASoC driver.
+ */
+ if (strlen(src) > len - 1)
+ dev_err(card->dev, "ASoC: driver name too long '%s' -> '%s'\n", src, name);
+}
+
+static void snd_soc_card_cleanup_resources(struct snd_soc_card *card)
+{
+ struct snd_soc_pcm_runtime *rtd, *n;
+
+ if (card->snd_card)
+ snd_card_disconnect_sync(card->snd_card);
+
+ snd_soc_dapm_shutdown(card);
+
+ /* release machine specific resources */
+ for_each_card_rtds(card, rtd)
+ if (rtd->initialized)
+ snd_soc_link_exit(rtd);
+ /* flush delayed work before removing DAIs and DAPM widgets */
+ snd_soc_flush_all_delayed_work(card);
+
+ /* remove and free each DAI */
+ snd_soc_card_link_dais_remove(card);
+ snd_soc_card_link_components_remove(card);
+
+ for_each_card_rtds_safe(card, rtd, n)
+ snd_soc_remove_pcm_runtime(card, rtd);
+
+ /* remove auxiliary devices */
+ snd_soc_card_aux_remove(card);
+ snd_soc_card_aux_unbind(card);
+
+ snd_soc_dapm_free(snd_soc_card_to_dapm(card));
+ snd_soc_card_debugfs_cleanup(card);
+
+ /* remove the card */
+ snd_soc_card_remove(card);
+
+ if (card->snd_card) {
+ snd_card_free(card->snd_card);
+ card->snd_card = NULL;
+ }
+}
+
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
@@ -597,7 +752,7 @@ int snd_soc_card_probe(struct snd_soc_card *card)
* about "late_probe".
*
* see
- * snd_soc_bind_card()
+ * snd_soc_card_bind()
* snd_soc_card_late_probe()
*/
card->probed = 1;
@@ -622,7 +777,7 @@ int snd_soc_card_late_probe(struct snd_soc_card *card)
* for all cases.
*
* see
- * snd_soc_bind_card()
+ * snd_soc_card_bind()
* snd_soc_card_probe()
*/
card->probed = 1;
@@ -724,3 +879,255 @@ int snd_soc_card_add_controls(struct snd_soc_card *soc_card,
return snd_soc_add_controls(card, soc_card->dev, controls, num_controls, NULL, soc_card);
}
EXPORT_SYMBOL_GPL(snd_soc_card_add_controls);
+
+static void snd_soc_remove_device_links(struct snd_soc_card *card)
+{
+ struct snd_soc_component *component;
+
+ for_each_card_components(card, component) {
+ if (component->card_device_link) {
+ device_link_del(component->card_device_link);
+ component->card_device_link = NULL;
+ }
+ }
+}
+
+void snd_soc_card_unbind(struct snd_soc_card *card)
+{
+ if (snd_soc_card_is_instantiated(card)) {
+ card->instantiated = false;
+
+ snd_soc_remove_device_links(card);
+
+ snd_soc_card_cleanup_resources(card);
+ }
+}
+
+static int snd_soc_card_bind(struct snd_soc_card *card)
+{
+ struct snd_soc_pcm_runtime *rtd;
+ struct snd_soc_component *component;
+ struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
+ int ret;
+
+ snd_soc_card_mutex_lock_root(card);
+ snd_soc_card_fill_dummy_dai(card);
+
+ snd_soc_dapm_init(dapm, card, NULL);
+ list_del_init(&card->list);
+
+ /* check whether any platform is ignore machine FE and using topology */
+ soc_card_check_tplg_fes(card);
+
+ /* bind aux_devs too */
+ ret = snd_soc_card_aux_bind(card);
+ if (ret < 0)
+ goto probe_end;
+
+ /* add predefined DAI links to the list */
+ card->num_rtd = 0;
+ ret = snd_soc_add_pcm_runtimes(card, card->dai_link, card->num_links);
+ if (ret < 0)
+ goto probe_end;
+
+ /* card bind complete so register a sound card */
+ ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+ card->owner, 0, &card->snd_card);
+ if (ret < 0) {
+ dev_err(card->dev,
+ "ASoC: can't create sound card for card %s: %d\n",
+ card->name, ret);
+ goto probe_end;
+ }
+
+ snd_soc_card_debugfs_init(card);
+
+ snd_soc_card_resume_init(card);
+
+ ret = snd_soc_dapm_new_controls(dapm, card->dapm_widgets,
+ card->num_dapm_widgets);
+ if (ret < 0)
+ goto probe_end;
+
+ ret = snd_soc_dapm_new_controls(dapm, card->of_dapm_widgets,
+ card->num_of_dapm_widgets);
+ if (ret < 0)
+ goto probe_end;
+
+ /* initialise the sound card only once */
+ ret = snd_soc_card_probe(card);
+ if (ret < 0)
+ goto probe_end;
+
+ /* probe all components used by DAI links on this card */
+ ret = snd_soc_card_link_components_probe(card);
+ if (ret < 0) {
+ if (ret != -EPROBE_DEFER) {
+ dev_err(card->dev,
+ "ASoC: failed to instantiate card %d\n", ret);
+ }
+ goto probe_end;
+ }
+
+ /* probe auxiliary components */
+ ret = snd_soc_card_aux_probe(card);
+ if (ret < 0) {
+ dev_err(card->dev,
+ "ASoC: failed to probe aux component %d\n", ret);
+ goto probe_end;
+ }
+
+ /* probe all DAI links on this card */
+ ret = snd_soc_card_link_dais_probe(card);
+ if (ret < 0) {
+ dev_err(card->dev,
+ "ASoC: failed to instantiate card %d\n", ret);
+ goto probe_end;
+ }
+
+ for_each_card_rtds(card, rtd) {
+ ret = snd_soc_card_init_pcm_runtime(card, rtd);
+ if (ret < 0)
+ goto probe_end;
+ }
+
+ snd_soc_dapm_link_dai_widgets(card);
+ snd_soc_dapm_connect_dai_link_widgets(card);
+
+ ret = snd_soc_add_card_controls(card, card->controls,
+ card->num_controls);
+ if (ret < 0)
+ goto probe_end;
+
+ ret = snd_soc_dapm_add_routes(dapm, card->dapm_routes,
+ card->num_dapm_routes);
+ if (ret < 0)
+ goto probe_end;
+
+ ret = snd_soc_dapm_add_routes(dapm, card->of_dapm_routes,
+ card->num_of_dapm_routes);
+ if (ret < 0)
+ goto probe_end;
+
+ /* try to set some sane longname if DMI is available */
+ snd_soc_card_set_dmi_name(card);
+
+ soc_card_setup_name(card, card->snd_card->shortname, card->name, NULL);
+ soc_card_setup_name(card, card->snd_card->longname, card->long_name, card->name);
+ soc_card_setup_name(card, card->snd_card->driver, card->driver_name, card->name);
+
+ if (card->components) {
+ /* the current implementation of snd_component_add() accepts */
+ /* multiple components in the string separated by space, */
+ /* but the string collision (identical string) check might */
+ /* not work correctly */
+ ret = snd_component_add(card->snd_card, card->components);
+ if (ret < 0) {
+ dev_err(card->dev, "ASoC: %s snd_component_add() failed: %d\n",
+ card->name, ret);
+ goto probe_end;
+ }
+ }
+
+ /*
+ * Add device_link from card to component so that system_suspend
+ * will be done in the correct order. The card must suspend first
+ * to stop audio activity before the components suspend.
+ *
+ * If a driver pair already have a link in the opposite direction
+ * they must manage their own suspend order.
+ */
+ for_each_card_components(card, component) {
+ if (card->dev == component->dev)
+ continue;
+
+ component->card_device_link = device_link_add(card->dev,
+ component->dev,
+ DL_FLAG_STATELESS);
+ if (!component->card_device_link) {
+ dev_warn(card->dev, "Could not create device link to %s\n",
+ dev_name(component->dev));
+ }
+ }
+
+ ret = snd_soc_card_late_probe(card);
+ if (ret < 0)
+ goto probe_end;
+
+ ret = snd_soc_dapm_ignore_suspend_widgets(card);
+ if (ret < 0)
+ goto probe_end;
+
+ snd_soc_dapm_new_widgets(card);
+ for_each_card_components(card, component) {
+ ret = snd_soc_component_fixup_controls(component);
+ if (ret < 0)
+ goto probe_end;
+ }
+ snd_soc_card_fixup_controls(card);
+
+ ret = snd_card_register(card->snd_card);
+ if (ret < 0) {
+ dev_err(card->dev, "ASoC: failed to register soundcard %d\n",
+ ret);
+ goto probe_end;
+ }
+
+ card->instantiated = 1;
+ snd_soc_dapm_mark_endpoints_dirty(card);
+ snd_soc_dapm_sync(dapm);
+
+ /* deactivate pins to sleep state */
+ for_each_card_components(card, component)
+ if (!snd_soc_component_active(component))
+ pinctrl_pm_select_sleep_state(component->dev);
+
+probe_end:
+ if (ret < 0) {
+ snd_soc_remove_device_links(card);
+ snd_soc_card_cleanup_resources(card);
+ }
+
+ if (ret == -EPROBE_DEFER) {
+ list_add(&card->list, &unbind_card_list);
+ ret = 0;
+ }
+ snd_soc_card_mutex_unlock(card);
+
+ return ret;
+}
+
+static void devm_snd_soc_card_bind_release(struct device *dev, void *res)
+{
+ snd_soc_unregister_card(*(struct snd_soc_card **)res);
+}
+
+static int devm_snd_soc_card_bind(struct device *dev, struct snd_soc_card *card)
+{
+ struct snd_soc_card **ptr;
+ int ret;
+
+ /* The procedure may be called many times during the lifetime of the card. */
+ devres_destroy(dev, devm_snd_soc_card_bind_release, NULL, NULL);
+
+ ptr = devres_alloc(devm_snd_soc_card_bind_release, sizeof(*ptr), GFP_KERNEL);
+ if (!ptr)
+ return -ENOMEM;
+
+ ret = snd_soc_card_bind(card);
+ if (ret == 0) {
+ *ptr = card;
+ devres_add(dev, ptr);
+ } else {
+ devres_free(ptr);
+ }
+
+ return ret;
+}
+
+int snd_soc_card_bind_call(struct snd_soc_card *card)
+{
+ if (card->devres_dev)
+ return devm_snd_soc_card_bind(card->devres_dev, card);
+ return snd_soc_card_bind(card);
+}
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 12b8bcb93ceeb..301089259a8d4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -38,15 +38,12 @@
#include <sound/soc.h>
#include <sound/soc-dpcm.h>
#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>
DEFINE_MUTEX(client_mutex);
-static LIST_HEAD(unbind_card_list);
/*
* This is used if driver don't need to have CPU/Codec/Platform
@@ -425,7 +422,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
return NULL;
}
-static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card)
+void snd_soc_flush_all_delayed_work(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
@@ -1074,412 +1071,6 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
}
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
-static void soc_check_tplg_fes(struct snd_soc_card *card)
-{
- struct snd_soc_component *component;
- struct snd_soc_dai_link *dai_link;
- int i;
-
- for_each_component(component) {
-
- /* does this component override BEs ? */
- if (!component->driver->ignore_machine)
- continue;
-
- /* for this machine ? */
- if (!strcmp(component->driver->ignore_machine,
- card->dev->driver->name))
- goto match;
- if (strcmp(component->driver->ignore_machine,
- dev_name(card->dev)))
- continue;
-match:
- /* machine matches, so override the rtd data */
- for_each_card_prelinks(card, i, dai_link) {
-
- /* ignore this FE */
- if (dai_link->dynamic) {
- dai_link->ignore = true;
- continue;
- }
-
- dev_dbg(card->dev, "info: override BE DAI link %s\n",
- dai_link->name);
-
- /* override platform component */
- if (!dai_link->platforms) {
- dev_err(card->dev, "init platform error");
- continue;
- }
-
- if (component->dev->of_node)
- dai_link->platforms->of_node = component->dev->of_node;
- else
- dai_link->platforms->name = component->name;
-
- /* convert non BE into BE */
- dai_link->no_pcm = 1;
-
- /*
- * override any BE fixups
- * see
- * snd_soc_link_be_hw_params_fixup()
- */
- dai_link->be_hw_params_fixup =
- component->driver->be_hw_params_fixup;
-
- /*
- * most BE links don't set stream name, so set it to
- * dai link name if it's NULL to help bind widgets.
- */
- if (!dai_link->stream_name)
- dai_link->stream_name = dai_link->name;
- }
-
- /* Inform userspace we are using alternate topology */
- snd_soc_card_set_topology_name(card, component->driver->topology_name_prefix);
- }
-}
-
-#define soc_setup_card_name(card, name, name1, name2) \
- __soc_setup_card_name(card, name, sizeof(name), name1, name2)
-static void __soc_setup_card_name(struct snd_soc_card *card,
- char *name, int len,
- const char *name1, const char *name2)
-{
- const char *src = name1 ? name1 : name2;
- int i;
-
- snprintf(name, len, "%s", src);
-
- if (name != card->snd_card->driver)
- return;
-
- /*
- * Name normalization (driver field)
- *
- * The driver name is somewhat special, as it's used as a key for
- * searches in the user-space.
- *
- * ex)
- * "abcd??efg" -> "abcd__efg"
- */
- for (i = 0; i < len; i++) {
- switch (name[i]) {
- case '_':
- case '-':
- case '\0':
- break;
- default:
- if (!isalnum(name[i]))
- name[i] = '_';
- break;
- }
- }
-
- /*
- * The driver field should contain a valid string from the user view.
- * The wrapping usually does not work so well here. Set a smaller string
- * in the specific ASoC driver.
- */
- if (strlen(src) > len - 1)
- dev_err(card->dev, "ASoC: driver name too long '%s' -> '%s'\n", src, name);
-}
-
-static void soc_cleanup_card_resources(struct snd_soc_card *card)
-{
- struct snd_soc_pcm_runtime *rtd, *n;
-
- if (card->snd_card)
- snd_card_disconnect_sync(card->snd_card);
-
- snd_soc_dapm_shutdown(card);
-
- /* release machine specific resources */
- for_each_card_rtds(card, rtd)
- if (rtd->initialized)
- snd_soc_link_exit(rtd);
- /* flush delayed work before removing DAIs and DAPM widgets */
- snd_soc_flush_all_delayed_work(card);
-
- /* remove and free each DAI */
- snd_soc_card_link_dais_remove(card);
- snd_soc_card_link_components_remove(card);
-
- for_each_card_rtds_safe(card, rtd, n)
- snd_soc_remove_pcm_runtime(card, rtd);
-
- /* remove auxiliary devices */
- snd_soc_card_aux_remove(card);
- snd_soc_card_aux_unbind(card);
-
- snd_soc_dapm_free(snd_soc_card_to_dapm(card));
- snd_soc_card_debugfs_cleanup(card);
-
- /* remove the card */
- snd_soc_card_remove(card);
-
- if (card->snd_card) {
- snd_card_free(card->snd_card);
- card->snd_card = NULL;
- }
-}
-
-static void snd_soc_remove_device_links(struct snd_soc_card *card)
-{
- struct snd_soc_component *component;
-
- for_each_card_components(card, component) {
- if (component->card_device_link) {
- device_link_del(component->card_device_link);
- component->card_device_link = NULL;
- }
- }
-}
-
-static void snd_soc_unbind_card(struct snd_soc_card *card)
-{
- if (snd_soc_card_is_instantiated(card)) {
- card->instantiated = false;
-
- snd_soc_remove_device_links(card);
-
- soc_cleanup_card_resources(card);
- }
-}
-
-static int snd_soc_bind_card(struct snd_soc_card *card)
-{
- struct snd_soc_pcm_runtime *rtd;
- struct snd_soc_component *component;
- struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
- int ret;
-
- snd_soc_card_mutex_lock_root(card);
- snd_soc_card_fill_dummy_dai(card);
-
- snd_soc_dapm_init(dapm, card, NULL);
- list_del_init(&card->list);
-
- /* check whether any platform is ignore machine FE and using topology */
- soc_check_tplg_fes(card);
-
- /* bind aux_devs too */
- ret = snd_soc_card_aux_bind(card);
- if (ret < 0)
- goto probe_end;
-
- /* add predefined DAI links to the list */
- card->num_rtd = 0;
- ret = snd_soc_add_pcm_runtimes(card, card->dai_link, card->num_links);
- if (ret < 0)
- goto probe_end;
-
- /* card bind complete so register a sound card */
- ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
- card->owner, 0, &card->snd_card);
- if (ret < 0) {
- dev_err(card->dev,
- "ASoC: can't create sound card for card %s: %d\n",
- card->name, ret);
- goto probe_end;
- }
-
- snd_soc_card_debugfs_init(card);
-
- snd_soc_card_resume_init(card);
-
- ret = snd_soc_dapm_new_controls(dapm, card->dapm_widgets,
- card->num_dapm_widgets);
- if (ret < 0)
- goto probe_end;
-
- ret = snd_soc_dapm_new_controls(dapm, card->of_dapm_widgets,
- card->num_of_dapm_widgets);
- if (ret < 0)
- goto probe_end;
-
- /* initialise the sound card only once */
- ret = snd_soc_card_probe(card);
- if (ret < 0)
- goto probe_end;
-
- /* probe all components used by DAI links on this card */
- ret = snd_soc_card_link_components_probe(card);
- if (ret < 0) {
- if (ret != -EPROBE_DEFER) {
- dev_err(card->dev,
- "ASoC: failed to instantiate card %d\n", ret);
- }
- goto probe_end;
- }
-
- /* probe auxiliary components */
- ret = snd_soc_card_aux_probe(card);
- if (ret < 0) {
- dev_err(card->dev,
- "ASoC: failed to probe aux component %d\n", ret);
- goto probe_end;
- }
-
- /* probe all DAI links on this card */
- ret = snd_soc_card_link_dais_probe(card);
- if (ret < 0) {
- dev_err(card->dev,
- "ASoC: failed to instantiate card %d\n", ret);
- goto probe_end;
- }
-
- for_each_card_rtds(card, rtd) {
- ret = snd_soc_card_init_pcm_runtime(card, rtd);
- if (ret < 0)
- goto probe_end;
- }
-
- snd_soc_dapm_link_dai_widgets(card);
- snd_soc_dapm_connect_dai_link_widgets(card);
-
- ret = snd_soc_add_card_controls(card, card->controls,
- card->num_controls);
- if (ret < 0)
- goto probe_end;
-
- ret = snd_soc_dapm_add_routes(dapm, card->dapm_routes,
- card->num_dapm_routes);
- if (ret < 0)
- goto probe_end;
-
- ret = snd_soc_dapm_add_routes(dapm, card->of_dapm_routes,
- card->num_of_dapm_routes);
- if (ret < 0)
- goto probe_end;
-
- /* try to set some sane longname if DMI is available */
- snd_soc_card_set_dmi_name(card);
-
- soc_setup_card_name(card, card->snd_card->shortname,
- card->name, NULL);
- soc_setup_card_name(card, card->snd_card->longname,
- card->long_name, card->name);
- soc_setup_card_name(card, card->snd_card->driver,
- card->driver_name, card->name);
-
- if (card->components) {
- /* the current implementation of snd_component_add() accepts */
- /* multiple components in the string separated by space, */
- /* but the string collision (identical string) check might */
- /* not work correctly */
- ret = snd_component_add(card->snd_card, card->components);
- if (ret < 0) {
- dev_err(card->dev, "ASoC: %s snd_component_add() failed: %d\n",
- card->name, ret);
- goto probe_end;
- }
- }
-
- /*
- * Add device_link from card to component so that system_suspend
- * will be done in the correct order. The card must suspend first
- * to stop audio activity before the components suspend.
- *
- * If a driver pair already have a link in the opposite direction
- * they must manage their own suspend order.
- */
- for_each_card_components(card, component) {
- if (card->dev == component->dev)
- continue;
-
- component->card_device_link = device_link_add(card->dev,
- component->dev,
- DL_FLAG_STATELESS);
- if (!component->card_device_link) {
- dev_warn(card->dev, "Could not create device link to %s\n",
- dev_name(component->dev));
- }
- }
-
- ret = snd_soc_card_late_probe(card);
- if (ret < 0)
- goto probe_end;
-
- ret = snd_soc_dapm_ignore_suspend_widgets(card);
- if (ret < 0)
- goto probe_end;
-
- snd_soc_dapm_new_widgets(card);
- for_each_card_components(card, component) {
- ret = snd_soc_component_fixup_controls(component);
- if (ret < 0)
- goto probe_end;
- }
- snd_soc_card_fixup_controls(card);
-
- ret = snd_card_register(card->snd_card);
- if (ret < 0) {
- dev_err(card->dev, "ASoC: failed to register soundcard %d\n",
- ret);
- goto probe_end;
- }
-
- card->instantiated = 1;
- snd_soc_dapm_mark_endpoints_dirty(card);
- snd_soc_dapm_sync(dapm);
-
- /* deactivate pins to sleep state */
- for_each_card_components(card, component)
- if (!snd_soc_component_active(component))
- pinctrl_pm_select_sleep_state(component->dev);
-
-probe_end:
- if (ret < 0) {
- snd_soc_remove_device_links(card);
- soc_cleanup_card_resources(card);
- }
-
- if (ret == -EPROBE_DEFER) {
- list_add(&card->list, &unbind_card_list);
- ret = 0;
- }
- snd_soc_card_mutex_unlock(card);
-
- return ret;
-}
-
-static void devm_card_bind_release(struct device *dev, void *res)
-{
- snd_soc_unregister_card(*(struct snd_soc_card **)res);
-}
-
-static int devm_snd_soc_bind_card(struct device *dev, struct snd_soc_card *card)
-{
- struct snd_soc_card **ptr;
- int ret;
-
- /* The procedure may be called many times during the lifetime of the card. */
- devres_destroy(dev, devm_card_bind_release, NULL, NULL);
-
- ptr = devres_alloc(devm_card_bind_release, sizeof(*ptr), GFP_KERNEL);
- if (!ptr)
- return -ENOMEM;
-
- ret = snd_soc_bind_card(card);
- if (ret == 0) {
- *ptr = card;
- devres_add(dev, ptr);
- } else {
- devres_free(ptr);
- }
-
- return ret;
-}
-
-static int call_soc_bind_card(struct snd_soc_card *card)
-{
- if (card->devres_dev)
- return devm_snd_soc_bind_card(card->devres_dev, card);
- return snd_soc_bind_card(card);
-}
-
/* probes a new socdev */
static int soc_probe(struct platform_device *pdev)
{
@@ -1641,7 +1232,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
guard(mutex)(&client_mutex);
- return call_soc_bind_card(card);
+ return snd_soc_card_bind_call(card);
}
EXPORT_SYMBOL_GPL(snd_soc_register_card);
@@ -1655,7 +1246,7 @@ void snd_soc_unregister_card(struct snd_soc_card *card)
{
guard(mutex)(&client_mutex);
- snd_soc_unbind_card(card);
+ snd_soc_card_unbind(card);
list_del(&card->list);
dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
@@ -1816,7 +1407,7 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
if (card) {
instantiated = card->instantiated;
- snd_soc_unbind_card(card);
+ snd_soc_card_unbind(card);
if (instantiated)
list_add(&card->list, &unbind_card_list);
}
@@ -1893,7 +1484,7 @@ int snd_soc_component_register(struct snd_soc_component *component,
list_add(&component->list, snd_soc_component_get_list_head());
list_for_each_entry_safe(card, c, &unbind_card_list, list)
- call_soc_bind_card(card);
+ snd_soc_card_bind_call(card);
err_cleanup:
if (ret < 0)
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index e1f456e222b63..97891bf68b882 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -17,6 +17,7 @@
* REMOVE ME
* Temporary definition
*/
+extern struct list_head unbind_card_list;
void snd_soc_card_debugfs_init(struct snd_soc_card *card);
void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card);
void snd_soc_card_resume_init(struct snd_soc_card *card);
@@ -43,12 +44,19 @@ char *snd_soc_fmt_multiple_name(struct device *dev, struct snd_soc_dai_driver *d
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);
+void snd_soc_flush_all_delayed_work(struct snd_soc_card *card);
struct snd_soc_component *snd_soc_find_component(const struct snd_soc_dai_link_component *dlc);
#ifdef CONFIG_PM_SLEEP
void snd_soc_playback_digital_mute(struct snd_soc_card *card, int mute);
void snd_soc_dapm_suspend_resume(struct snd_soc_card *card, int event);
#endif
+/*
+ * In soc-card
+ */
+void snd_soc_card_unbind(struct snd_soc_card *card);
+int snd_soc_card_bind_call(struct snd_soc_card *card);
+
/*
* In soc-dai
*/
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 13/15] ASoC: soc-card: add snd_soc_card_rebind()
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (11 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 12/15] ASoC: soc-card: move snd_soc_card_bind_call() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 14/15] ASoC: soc-card: make unbind_card_list static Kuninori Morimoto
` (2 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
add snd_soc_card_rebind() and capsuled card relarted operation
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 8 ++++++++
sound/soc/soc-core.c | 4 +---
sound/soc/soc-internal.h | 1 +
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 72b40f842bd43..f6ff99bf8a601 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -1097,6 +1097,14 @@ static int snd_soc_card_bind(struct snd_soc_card *card)
return ret;
}
+void snd_soc_card_rebind(void)
+{
+ struct snd_soc_card *card, *c;
+
+ list_for_each_entry_safe(card, c, &unbind_card_list, list)
+ snd_soc_card_bind_call(card);
+}
+
static void devm_snd_soc_card_bind_release(struct device *dev, void *res)
{
snd_soc_unregister_card(*(struct snd_soc_card **)res);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 301089259a8d4..fd46906cbca96 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1455,7 +1455,6 @@ int snd_soc_component_register(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv,
int num_dai)
{
- struct snd_soc_card *card, *c;
int ret;
int i;
guard(mutex)(&client_mutex);
@@ -1483,8 +1482,7 @@ int snd_soc_component_register(struct snd_soc_component *component,
/* see for_each_component */
list_add(&component->list, snd_soc_component_get_list_head());
- list_for_each_entry_safe(card, c, &unbind_card_list, list)
- snd_soc_card_bind_call(card);
+ snd_soc_card_rebind();
err_cleanup:
if (ret < 0)
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index 97891bf68b882..ccd6a7baa4f3f 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -55,6 +55,7 @@ void snd_soc_dapm_suspend_resume(struct snd_soc_card *card, int event);
* In soc-card
*/
void snd_soc_card_unbind(struct snd_soc_card *card);
+void snd_soc_card_rebind(void);
int snd_soc_card_bind_call(struct snd_soc_card *card);
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 14/15] ASoC: soc-card: make unbind_card_list static
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (12 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 13/15] ASoC: soc-card: add snd_soc_card_rebind() Kuninori Morimoto
@ 2026-10-28 3:03 ` Kuninori Morimoto
2026-10-28 9:59 ` Alvin Šipraga
2026-10-28 3:04 ` [PATCH 15/15] ASoC: soc-internal: remove temporary funciton defines Kuninori Morimoto
2026-10-28 10:00 ` [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Alvin Šipraga
15 siblings, 1 reply; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:03 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
struct snd_soc_card will be capsuled soon, its member will not be
able to access from non soc-card.c.
Update snd_soc_card_unbind() and makes unbind_card_list static in
soc-card.c
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 10 ++++++++--
sound/soc/soc-core.c | 12 +++---------
sound/soc/soc-internal.h | 3 +--
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index f6ff99bf8a601..959b56be0eedf 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -17,7 +17,7 @@
#include <sound/jack.h>
#include "soc-internal.h"
-LIST_HEAD(unbind_card_list);
+static LIST_HEAD(unbind_card_list);
#define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret)
static inline int _soc_card_ret(struct snd_soc_card *card,
@@ -892,7 +892,7 @@ static void snd_soc_remove_device_links(struct snd_soc_card *card)
}
}
-void snd_soc_card_unbind(struct snd_soc_card *card)
+void snd_soc_card_unbind(struct snd_soc_card *card, bool reuse)
{
if (snd_soc_card_is_instantiated(card)) {
card->instantiated = false;
@@ -900,7 +900,13 @@ void snd_soc_card_unbind(struct snd_soc_card *card)
snd_soc_remove_device_links(card);
snd_soc_card_cleanup_resources(card);
+
+ if (reuse)
+ list_add(&card->list, &unbind_card_list);
}
+
+ if (!reuse)
+ list_del(&card->list);
}
static int snd_soc_card_bind(struct snd_soc_card *card)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fd46906cbca96..ba02f244f7954 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1246,8 +1246,7 @@ void snd_soc_unregister_card(struct snd_soc_card *card)
{
guard(mutex)(&client_mutex);
- snd_soc_card_unbind(card);
- list_del(&card->list);
+ snd_soc_card_unbind(card, false);
dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
}
@@ -1401,16 +1400,11 @@ static void convert_endianness_formats(struct snd_soc_pcm_stream *stream)
static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
{
struct snd_soc_card *card = component->card;
- bool instantiated;
snd_soc_unregister_dais(component);
- if (card) {
- instantiated = card->instantiated;
- snd_soc_card_unbind(card);
- if (instantiated)
- list_add(&card->list, &unbind_card_list);
- }
+ if (card)
+ snd_soc_card_unbind(card, true);
list_del(&component->list);
}
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index ccd6a7baa4f3f..255e06466e925 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -17,7 +17,6 @@
* REMOVE ME
* Temporary definition
*/
-extern struct list_head unbind_card_list;
void snd_soc_card_debugfs_init(struct snd_soc_card *card);
void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card);
void snd_soc_card_resume_init(struct snd_soc_card *card);
@@ -54,7 +53,7 @@ void snd_soc_dapm_suspend_resume(struct snd_soc_card *card, int event);
/*
* In soc-card
*/
-void snd_soc_card_unbind(struct snd_soc_card *card);
+void snd_soc_card_unbind(struct snd_soc_card *card, bool reuse);
void snd_soc_card_rebind(void);
int snd_soc_card_bind_call(struct snd_soc_card *card);
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 15/15] ASoC: soc-internal: remove temporary funciton defines
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (13 preceding siblings ...)
2026-10-28 3:03 ` [PATCH 14/15] ASoC: soc-card: make unbind_card_list static Kuninori Morimoto
@ 2026-10-28 3:04 ` Kuninori Morimoto
2026-10-28 10:00 ` [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Alvin Šipraga
15 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 3:04 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
There were too many local function dependencies to move Card related
function from soc-core.c to soc-card.c.
Now, all functions were moved, let's remove temporary funciton defines.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-card.c | 38 +++++++++++++++++++-------------------
sound/soc/soc-internal.h | 20 --------------------
2 files changed, 19 insertions(+), 39 deletions(-)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 959b56be0eedf..6544dbf2ee260 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -28,7 +28,7 @@ static inline int _soc_card_ret(struct snd_soc_card *card,
}
#ifdef CONFIG_DEBUG_FS
-void snd_soc_card_debugfs_init(struct snd_soc_card *card)
+static void snd_soc_card_debugfs_init(struct snd_soc_card *card)
{
card->debugfs_card_root = debugfs_create_dir(card->name,
snd_soc_debugfs_root);
@@ -36,14 +36,14 @@ void snd_soc_card_debugfs_init(struct snd_soc_card *card)
snd_soc_dapm_debugfs_init(snd_soc_card_to_dapm(card), card->debugfs_card_root);
}
-void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card)
+static void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card)
{
debugfs_remove_recursive(card->debugfs_card_root);
card->debugfs_card_root = NULL;
}
#else
-void snd_soc_card_debugfs_init(struct snd_soc_card *card) { }
-void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card) { }
+static inline void snd_soc_card_debugfs_init(struct snd_soc_card *card) { }
+static inline void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card) { }
#endif /* CONFIG_DEBUG_FS */
#ifdef CONFIG_PM_SLEEP
@@ -92,16 +92,16 @@ static void snd_soc_card_resume_deferred(struct work_struct *work)
snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);
}
-void snd_soc_card_resume_init(struct snd_soc_card *card)
+static void snd_soc_card_resume_init(struct snd_soc_card *card)
{
/* deferred resume work */
INIT_WORK(&card->deferred_resume_work, snd_soc_card_resume_deferred);
}
#else
-void snd_soc_card_resume_init(struct snd_soc_card *card) { }
+static inline void snd_soc_card_resume_init(struct snd_soc_card *card) { }
#endif /* CONFIG_PM_SLEEP */
-void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card)
+static void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card)
{
struct snd_soc_dai_link *dai_link;
int i;
@@ -123,8 +123,8 @@ void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card)
}
}
-int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
- struct snd_soc_pcm_runtime *rtd)
+static int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
+ struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_dai_link *dai_link = rtd->dai_link;
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
@@ -171,7 +171,7 @@ int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
return ret;
}
-void snd_soc_card_link_dais_remove(struct snd_soc_card *card)
+static void snd_soc_card_link_dais_remove(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
int order;
@@ -184,7 +184,7 @@ void snd_soc_card_link_dais_remove(struct snd_soc_card *card)
}
}
-int snd_soc_card_link_dais_probe(struct snd_soc_card *card)
+static int snd_soc_card_link_dais_probe(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
int order, ret;
@@ -201,7 +201,7 @@ int snd_soc_card_link_dais_probe(struct snd_soc_card *card)
return 0;
}
-void snd_soc_card_link_components_remove(struct snd_soc_card *card)
+static void snd_soc_card_link_components_remove(struct snd_soc_card *card)
{
struct snd_soc_component *component;
struct snd_soc_pcm_runtime *rtd;
@@ -219,7 +219,7 @@ void snd_soc_card_link_components_remove(struct snd_soc_card *card)
}
}
-int snd_soc_card_link_components_probe(struct snd_soc_card *card)
+static int snd_soc_card_link_components_probe(struct snd_soc_card *card)
{
struct snd_soc_component *component;
struct snd_soc_pcm_runtime *rtd;
@@ -241,7 +241,7 @@ int snd_soc_card_link_components_probe(struct snd_soc_card *card)
return 0;
}
-void snd_soc_card_aux_unbind(struct snd_soc_card *card)
+static void snd_soc_card_aux_unbind(struct snd_soc_card *card)
{
struct snd_soc_component *component, *_component;
@@ -252,7 +252,7 @@ void snd_soc_card_aux_unbind(struct snd_soc_card *card)
}
}
-int snd_soc_card_aux_bind(struct snd_soc_card *card)
+static int snd_soc_card_aux_bind(struct snd_soc_card *card)
{
struct snd_soc_component *component;
struct snd_soc_aux_dev *aux;
@@ -272,7 +272,7 @@ int snd_soc_card_aux_bind(struct snd_soc_card *card)
return 0;
}
-int snd_soc_card_aux_probe(struct snd_soc_card *card)
+static int snd_soc_card_aux_probe(struct snd_soc_card *card)
{
struct snd_soc_component *component;
int order;
@@ -292,7 +292,7 @@ int snd_soc_card_aux_probe(struct snd_soc_card *card)
return 0;
}
-void snd_soc_card_aux_remove(struct snd_soc_card *card)
+static void snd_soc_card_aux_remove(struct snd_soc_card *card)
{
struct snd_soc_component *comp, *_comp;
int order;
@@ -408,7 +408,7 @@ static void append_dmi_string(char *dst, const char *str)
*
* Returns 0 on success, otherwise a negative error code.
*/
-int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
+static int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
{
const char *vendor, *product, *board;
char *dmi_longname;
@@ -463,7 +463,7 @@ int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
return 0;
}
#else
-int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
+static inline int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
{
return 0;
}
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index 255e06466e925..858a071798d0f 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -13,26 +13,6 @@
* as snd_soc_xxx();
*/
-/*
- * REMOVE ME
- * Temporary definition
- */
-void snd_soc_card_debugfs_init(struct snd_soc_card *card);
-void snd_soc_card_debugfs_cleanup(struct snd_soc_card *card);
-void snd_soc_card_resume_init(struct snd_soc_card *card);
-void snd_soc_card_fill_dummy_dai(struct snd_soc_card *card);
-int snd_soc_card_init_pcm_runtime(struct snd_soc_card *card,
- struct snd_soc_pcm_runtime *rtd);
-void snd_soc_card_link_dais_remove(struct snd_soc_card *card);
-int snd_soc_card_link_dais_probe(struct snd_soc_card *card);
-void snd_soc_card_link_components_remove(struct snd_soc_card *card);
-int snd_soc_card_link_components_probe(struct snd_soc_card *card);
-void snd_soc_card_aux_unbind(struct snd_soc_card *card);
-int snd_soc_card_aux_bind(struct snd_soc_card *card);
-int snd_soc_card_aux_probe(struct snd_soc_card *card);
-void snd_soc_card_aux_remove(struct snd_soc_card *card);
-int snd_soc_card_set_dmi_name(struct snd_soc_card *card);
-
/*
* In soc-core
*/
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 12/15] ASoC: soc-card: move snd_soc_card_bind_call()
2026-10-28 3:03 ` [PATCH 12/15] ASoC: soc-card: move snd_soc_card_bind_call() Kuninori Morimoto
@ 2026-10-28 9:41 ` Alvin Šipraga
2026-10-28 23:49 ` Kuninori Morimoto
0 siblings, 1 reply; 20+ messages in thread
From: Alvin Šipraga @ 2026-10-28 9:41 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound
On Wed, Oct 28, 2026 at 03:03:50AM +0000, Kuninori Morimoto wrote:
> struct snd_soc_card will be capsuled soon, its member will not be
> able to access from non soc-card.c.
>
> It has too many local function dependencies.
> This patch uses temporary funciton define at soc-internal.h. It will be
> removed all funciton were moved.
>
> It renames function name
> - call_soc_bind_card()
> - snd_soc_bind_card()
> - snd_soc_unbind_card()
> + snd_soc_card_bind_call()
> + snd_soc_card_bind()
> + snd_soc_card_unbind()
>
> Below function is used on above functions. Add them at soc-internal.h
> + snd_soc_flush_all_delayed_work()
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> sound/soc/soc-card.c | 411 +++++++++++++++++++++++++++++++++++++-
> sound/soc/soc-core.c | 419 +--------------------------------------
> sound/soc/soc-internal.h | 8 +
> 3 files changed, 422 insertions(+), 416 deletions(-)
>
> diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
> index c64c9d425bcf9..72b40f842bd43 100644
> --- a/sound/soc/soc-card.c
> +++ b/sound/soc/soc-card.c
> @@ -9,12 +9,16 @@
> #include <linux/debugfs.h>
> #include <linux/dmi.h>
> #include <linux/lockdep.h>
> +#include <linux/pinctrl/consumer.h>
> #include <linux/rwsem.h>
> +#include <sound/initval.h>
> #include <sound/soc.h>
> #include <sound/soc-link.h>
> #include <sound/jack.h>
> #include "soc-internal.h"
>
> +LIST_HEAD(unbind_card_list);
> +
> #define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret)
> static inline int _soc_card_ret(struct snd_soc_card *card,
> const char *func, int ret)
> @@ -465,6 +469,157 @@ int snd_soc_card_set_dmi_name(struct snd_soc_card *card)
> }
> #endif /* CONFIG_DMI */
>
> +static void soc_card_check_tplg_fes(struct snd_soc_card *card)
Don't you want the snd_ prefix here too, since you're renaming anyway?
> +{
> + struct snd_soc_component *component;
> + struct snd_soc_dai_link *dai_link;
> + int i;
> +
> + for_each_component(component) {
[...]
> +
> +#define soc_card_setup_name(card, name, name1, name2) \
> + __soc_card_setup_name(card, name, sizeof(name), name1, name2)
> +static void __soc_card_setup_name(struct snd_soc_card *card,
> + char *name, int len,
> + const char *name1, const char *name2)
snd_ prefix here too?
> +{
> + const char *src = name1 ? name1 : name2;
> + int i;
> +
> + snprintf(name, len, "%s", src);
> +
> + if (name != card->snd_card->driver)
> + return;
> +
[...]
Kind regards,
Alvin
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 14/15] ASoC: soc-card: make unbind_card_list static
2026-10-28 3:03 ` [PATCH 14/15] ASoC: soc-card: make unbind_card_list static Kuninori Morimoto
@ 2026-10-28 9:59 ` Alvin Šipraga
0 siblings, 0 replies; 20+ messages in thread
From: Alvin Šipraga @ 2026-10-28 9:59 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound
On Wed, Oct 28, 2026 at 03:03:57AM +0000, Kuninori Morimoto wrote:
> struct snd_soc_card will be capsuled soon, its member will not be
> able to access from non soc-card.c.
>
> Update snd_soc_card_unbind() and makes unbind_card_list static in
> soc-card.c
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> sound/soc/soc-card.c | 10 ++++++++--
> sound/soc/soc-core.c | 12 +++---------
> sound/soc/soc-internal.h | 3 +--
> 3 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
> index f6ff99bf8a601..959b56be0eedf 100644
> --- a/sound/soc/soc-card.c
> +++ b/sound/soc/soc-card.c
> @@ -17,7 +17,7 @@
> #include <sound/jack.h>
> #include "soc-internal.h"
>
> -LIST_HEAD(unbind_card_list);
> +static LIST_HEAD(unbind_card_list);
A bit irrelevant to capsuling, but I think it would make more sense for
the list to be called unbound_card_list. It would make this part more
understandable:
int snd_soc_component_register(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv,
int num_dai)
{
struct snd_soc_card *card, *c;
...
/* Alvin's comment: retry binding any unbound cards in case this
* component completes them
*/
list_for_each_entry_safe(card, c, &unbind_card_list, list)
snd_soc_card_bind_call(card);
...
}
But feel free to ignore :)
Kind regards,
Alvin
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
` (14 preceding siblings ...)
2026-10-28 3:04 ` [PATCH 15/15] ASoC: soc-internal: remove temporary funciton defines Kuninori Morimoto
@ 2026-10-28 10:00 ` Alvin Šipraga
15 siblings, 0 replies; 20+ messages in thread
From: Alvin Šipraga @ 2026-10-28 10:00 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound
On Wed, Oct 28, 2026 at 02:42:55AM +0000, Kuninori Morimoto wrote:
> Hi Mark
>
> I'm now posting ASoC Capsuling patches.
> Current status, and this patch-set postion is below.
> This patch-set moves Card related functions to soc-card.c
>
> x: done
> o: This patch-set
>
> [x] move DAI functions
> [x] add new DAI functions
> [x] move Component functions
> [o] move Card functions
I left some minor comments you may want to address, but either way, for
the series:
Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>
> [ ] add new Component functions
> [ ] rename DAI/Component list
> [ ] move Card functions v2
> [ ] add new Card functions
> [ ] adjust Test
> [ ] use new Card register
> [ ] use new functions on all drivers
> [ ] Capsule DAI/Component/Card
>
> Kuninori Morimoto (15):
> ASoC: soc-core: fixup snd_soc_dai_compress_new() return
> ASoC: soc-card: move snd_soc_add_card_controls()
> ASoC: soc-card: move snd_soc_card_debugfs_xxx()
> ASoC: soc-card: move snd_soc_card_resume_init()
> ASoC: soc-card: move snd_soc_card_fill_dummy_dai()
> ASoC: soc-card: move snd_soc_card_init_pcm_runtime()
> ASoC: soc-card: move snd_soc_card_link_dais_xxx()
> ASoC: soc-card: move snd_soc_card_link_components_xxx()
> ASoC: soc-card: move snd_soc_card_aux_[un]bind()
> ASoC: soc-card: move snd_soc_card_aux_{remove/probe}()
> ASoC: soc-card: move snd_soc_card_set_dmi_name()
> ASoC: soc-card: move snd_soc_card_bind_call()
> ASoC: soc-card: add snd_soc_card_rebind()
> ASoC: soc-card: make unbind_card_list static
> ASoC: soc-internal: remove temporary funciton defines
>
> include/sound/soc-card.h | 2 +
> include/sound/soc.h | 3 +-
> sound/soc/soc-card.c | 890 +++++++++++++++++++++++++++++++++++++-
> sound/soc/soc-core.c | 900 +--------------------------------------
> sound/soc/soc-internal.h | 13 +
> 5 files changed, 919 insertions(+), 889 deletions(-)
>
> --
> 2.53.0
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 12/15] ASoC: soc-card: move snd_soc_card_bind_call()
2026-10-28 9:41 ` Alvin Šipraga
@ 2026-10-28 23:49 ` Kuninori Morimoto
0 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2026-10-28 23:49 UTC (permalink / raw)
To: Alvin Šipraga; +Cc: Mark Brown, linux-sound
Hi Alvin
Thank you for your review
> > +static void soc_card_check_tplg_fes(...)
(snip)
> > +static void __soc_card_setup_name(...)
(snip)
> Don't you want the snd_ prefix here too, since you're renaming anyway?
I'm doing it mainly for global functions.
Not so much for local/static functions, for now.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2026-10-28 23:49 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28 2:42 [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Kuninori Morimoto
2026-10-28 3:02 ` [PATCH 01/15] ASoC: soc-core: fixup snd_soc_dai_compress_new() return Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 02/15] ASoC: soc-card: move snd_soc_add_card_controls() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 03/15] ASoC: soc-card: move snd_soc_card_debugfs_xxx() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 04/15] ASoC: soc-card: move snd_soc_card_resume_init() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 05/15] ASoC: soc-card: move snd_soc_card_fill_dummy_dai() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 06/15] ASoC: soc-card: move snd_soc_card_init_pcm_runtime() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 07/15] ASoC: soc-card: move snd_soc_card_link_dais_xxx() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 08/15] ASoC: soc-card: move snd_soc_card_link_components_xxx() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 09/15] ASoC: soc-card: move snd_soc_card_aux_[un]bind() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 10/15] ASoC: soc-card: move snd_soc_card_aux_{remove/probe}() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 11/15] ASoC: soc-card: move snd_soc_card_set_dmi_name() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 12/15] ASoC: soc-card: move snd_soc_card_bind_call() Kuninori Morimoto
2026-10-28 9:41 ` Alvin Šipraga
2026-10-28 23:49 ` Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 13/15] ASoC: soc-card: add snd_soc_card_rebind() Kuninori Morimoto
2026-10-28 3:03 ` [PATCH 14/15] ASoC: soc-card: make unbind_card_list static Kuninori Morimoto
2026-10-28 9:59 ` Alvin Šipraga
2026-10-28 3:04 ` [PATCH 15/15] ASoC: soc-internal: remove temporary funciton defines Kuninori Morimoto
2026-10-28 10:00 ` [PATCH 00/15] ASoC: soc-card: move snd_soc_card_xxx() to soc-card.c Alvin Šipraga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox