* [RFC][PATCH 1/2] ASoC: ti: ams-delta: Stop (ab)using card->pop_time
2026-04-22 2:55 [RFC][PATCH 0/2] ASoC: move card->pop_time to soc-dapm Kuninori Morimoto
@ 2026-04-22 2:55 ` Kuninori Morimoto
2026-04-22 12:31 ` Mark Brown
2026-04-22 2:56 ` [PATCH 2/2] ASoC: soc-dapm: move card->pop_time to soc-dapm.c Kuninori Morimoto
1 sibling, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2026-04-22 2:55 UTC (permalink / raw)
To: Janusz Krzysztofik, Jaroslav Kysela, Liam Girdwood, Mark Brown,
Peter Ujfalusi, Takashi Iwai, linux-sound
From: Janusz Krzysztofik <jmkrzyszt@gmail.com>
A flag is needed that tells the card driver if the codec has been
initialized successfully over the modem's line discipline. Initially,
codec->hw_write was used as the flag, but it was then dropped and the
flag function associated with card->pop_time, already managed by the
codec driver for diagnostic purposes. Since now the card->pop_time is
going to be killed, stop abusing foreign fields in favor of an own one.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/codecs/cx20442.c | 8 ++++++--
sound/soc/codecs/cx20442.h | 5 +++++
sound/soc/ti/ams-delta.c | 16 ++++++++--------
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c
index c0dc69ce4d0e7..3a1455b79cd32 100644
--- a/sound/soc/codecs/cx20442.c
+++ b/sound/soc/codecs/cx20442.c
@@ -236,7 +236,8 @@ static int v253_open(struct tty_struct *tty)
/* Line discipline .close() */
static void v253_close(struct tty_struct *tty)
{
- struct snd_soc_component *component = tty->disc_data;
+ struct cx20442_codec *codec = tty->disc_data;
+ struct snd_soc_component *component = codec->component;
struct cx20442_priv *cx20442;
tty->disc_data = NULL;
@@ -248,6 +249,7 @@ static void v253_close(struct tty_struct *tty)
/* Prevent the codec driver from further accessing the modem */
cx20442->tty = NULL;
+ codec->ready = false;
component->card->pop_time = 0;
}
@@ -261,7 +263,8 @@ static void v253_hangup(struct tty_struct *tty)
static void v253_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp,
size_t count)
{
- struct snd_soc_component *component = tty->disc_data;
+ struct cx20442_codec *codec = tty->disc_data;
+ struct snd_soc_component *component = codec->component;
struct cx20442_priv *cx20442;
if (!component)
@@ -274,6 +277,7 @@ static void v253_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp,
/* Set up codec driver access to modem controls */
cx20442->tty = tty;
+ codec->ready = true;
component->card->pop_time = 1;
}
}
diff --git a/sound/soc/codecs/cx20442.h b/sound/soc/codecs/cx20442.h
index bb897bcb24869..78ab1eab083e7 100644
--- a/sound/soc/codecs/cx20442.h
+++ b/sound/soc/codecs/cx20442.h
@@ -8,6 +8,11 @@
#ifndef _CX20442_CODEC_H
#define _CX20442_CODEC_H
+struct cx20442_codec {
+ struct snd_soc_component *component;
+ bool ready;
+};
+
extern struct tty_ldisc_ops v253_ops;
#endif
diff --git a/sound/soc/ti/ams-delta.c b/sound/soc/ti/ams-delta.c
index ba173d9fcba91..2a6fa75ededec 100644
--- a/sound/soc/ti/ams-delta.c
+++ b/sound/soc/ti/ams-delta.c
@@ -93,7 +93,7 @@ static unsigned short ams_delta_audio_agc;
* Used for passing a codec structure pointer
* from the board initialization code to the tty line discipline.
*/
-static struct snd_soc_component *cx20442_codec;
+static struct cx20442_codec cx20442_codec;
static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
@@ -105,7 +105,7 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
int pin, changed = 0;
/* Refuse any mode changes if we are not able to control the codec. */
- if (!cx20442_codec->card->pop_time)
+ if (!cx20442_codec.ready)
return -EUNATCH;
if (ucontrol->value.enumerated.item[0] >= control->items)
@@ -280,14 +280,14 @@ static int cx81801_open(struct tty_struct *tty)
{
int ret;
- if (!cx20442_codec)
+ if (!cx20442_codec.component)
return -ENODEV;
/*
* Pass the codec structure pointer for use by other ldisc callbacks,
* both the card and the codec specific parts.
*/
- tty->disc_data = cx20442_codec;
+ tty->disc_data = &cx20442_codec;
ret = v253_ops.open(tty);
@@ -339,14 +339,14 @@ static void cx81801_hangup(struct tty_struct *tty)
static void cx81801_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp,
size_t count)
{
- struct snd_soc_component *component = tty->disc_data;
+ struct snd_soc_component *component = cx20442_codec.component;
const unsigned char *c;
int apply, ret;
- if (!component)
+ if (tty->disc_data != &cx20442_codec)
return;
- if (!component->card->pop_time) {
+ if (!cx20442_codec.ready) {
/* First modem response, complete setup procedure */
/* Initialize timer used for config pulse generation */
@@ -467,7 +467,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
/* Codec is ready, now add/activate board specific controls */
/* Store a pointer to the codec structure for tty ldisc use */
- cx20442_codec = snd_soc_rtd_to_codec(rtd, 0)->component;
+ cx20442_codec.component = snd_soc_rtd_to_codec(rtd, 0)->component;
/* Add hook switch - can be used to control the codec from userspace
* even if line discipline fails */
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/2] ASoC: soc-dapm: move card->pop_time to soc-dapm.c
2026-04-22 2:55 [RFC][PATCH 0/2] ASoC: move card->pop_time to soc-dapm Kuninori Morimoto
2026-04-22 2:55 ` [RFC][PATCH 1/2] ASoC: ti: ams-delta: Stop (ab)using card->pop_time Kuninori Morimoto
@ 2026-04-22 2:56 ` Kuninori Morimoto
2026-04-22 12:35 ` Mark Brown
1 sibling, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2026-04-22 2:56 UTC (permalink / raw)
To: Janusz Krzysztofik, Jaroslav Kysela, Liam Girdwood, Mark Brown,
Peter Ujfalusi, Takashi Iwai, linux-sound
Card has pop_time which is have used only from TI, and it is now stop
using. This pop_time is used for debug, and can be access from debugfs.
Let's move it from Card to soc-dapm.c local.
This patch moves it from Card to soc-dapm.c, tidyup soc-dapm.c
accordingly, and remove card->pop_time from cx20442.c which is no longer
needed.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
include/sound/soc-dapm.h | 1 +
include/sound/soc.h | 2 --
sound/soc/codecs/cx20442.c | 3 ---
sound/soc/soc-core.c | 4 +---
sound/soc/soc-dapm.c | 30 ++++++++++++++++++------------
5 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 4f8fb7622a139..f24eafefbdff2 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -673,6 +673,7 @@ int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
/* dapm sys fs - used by the core */
extern struct attribute *snd_soc_dapm_dev_attrs[];
void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, struct dentry *parent);
+void snd_soc_dapm_debugfs_pop_time(struct dentry *parent);
/* dapm audio pin control and status */
int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin);
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5e3eb617d8323..453548988d381 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1081,8 +1081,6 @@ struct snd_soc_card {
#ifdef CONFIG_PM_SLEEP
struct work_struct deferred_resume_work;
#endif
- u32 pop_time;
-
/* bit field */
unsigned int instantiated:1;
unsigned int topology_shortname_created:1;
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c
index 3a1455b79cd32..0dea84cd8ef2d 100644
--- a/sound/soc/codecs/cx20442.c
+++ b/sound/soc/codecs/cx20442.c
@@ -250,7 +250,6 @@ static void v253_close(struct tty_struct *tty)
/* Prevent the codec driver from further accessing the modem */
cx20442->tty = NULL;
codec->ready = false;
- component->card->pop_time = 0;
}
/* Line discipline .hangup() */
@@ -278,7 +277,6 @@ static void v253_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp,
/* Set up codec driver access to modem controls */
cx20442->tty = tty;
codec->ready = true;
- component->card->pop_time = 1;
}
}
@@ -379,7 +377,6 @@ static int cx20442_component_probe(struct snd_soc_component *component)
cx20442->tty = NULL;
snd_soc_component_set_drvdata(component, cx20442);
- component->card->pop_time = 0;
return 0;
}
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 3fecf9fc903c0..13e933d2883e8 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -194,9 +194,7 @@ static void soc_init_card_debugfs(struct snd_soc_card *card)
card->debugfs_card_root = debugfs_create_dir(card->name,
snd_soc_debugfs_root);
- debugfs_create_u32("dapm_pop_time", 0644, card->debugfs_card_root,
- &card->pop_time);
-
+ snd_soc_dapm_debugfs_pop_time(card->debugfs_card_root);
snd_soc_dapm_debugfs_init(snd_soc_card_to_dapm(card), card->debugfs_card_root);
}
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d6192204e613d..10f5fb771e301 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -40,6 +40,8 @@
#include <trace/events/asoc.h>
+static u32 pop_time;
+
/* DAPM context */
struct snd_soc_dapm_context {
enum snd_soc_bias_level bias_level;
@@ -161,14 +163,14 @@ static void dapm_assert_locked(struct snd_soc_dapm_context *dapm)
snd_soc_dapm_mutex_assert_held(dapm);
}
-static void dapm_pop_wait(u32 pop_time)
+static void dapm_pop_wait(void)
{
if (pop_time)
schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
}
-__printf(3, 4)
-static void dapm_pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...)
+__printf(2, 3)
+static void dapm_pop_dbg(struct device *dev, const char *fmt, ...)
{
va_list args;
char *buf;
@@ -1872,8 +1874,7 @@ static void dapm_seq_check_event(struct snd_soc_card *card,
if (w->event && (w->event_flags & event)) {
int ret;
- dapm_pop_dbg(dev, card->pop_time, "pop test : %s %s\n",
- w->name, ev_name);
+ dapm_pop_dbg(dev, "pop test : %s %s\n", w->name, ev_name);
dapm_async_complete(w->dapm);
trace_snd_soc_dapm_widget_event_start(w, event);
ret = w->event(w, NULL, event);
@@ -1909,7 +1910,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card,
else
value |= w->off_val << w->shift;
- dapm_pop_dbg(dev, card->pop_time,
+ dapm_pop_dbg(dev,
"pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n",
w->name, reg, value, mask);
@@ -1923,10 +1924,10 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card,
* same register.
*/
- dapm_pop_dbg(dev, card->pop_time,
+ dapm_pop_dbg(dev,
"pop test : Applying 0x%x/0x%x to %x in %dms\n",
- value, mask, reg, card->pop_time);
- dapm_pop_wait(card->pop_time);
+ value, mask, reg, pop_time);
+ dapm_pop_wait();
dapm_update_bits(dapm, reg, mask, value);
}
@@ -2392,9 +2393,9 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event,
return ret;
}
- dapm_pop_dbg(card->dev, card->pop_time,
- "DAPM sequencing finished, waiting %dms\n", card->pop_time);
- dapm_pop_wait(card->pop_time);
+ dapm_pop_dbg(card->dev,
+ "DAPM sequencing finished, waiting %dms\n", pop_time);
+ dapm_pop_wait();
trace_snd_soc_dapm_done(card, event);
@@ -2561,6 +2562,11 @@ static const struct file_operations dapm_bias_fops = {
.llseek = default_llseek,
};
+void snd_soc_dapm_debugfs_pop_time(struct dentry *parent)
+{
+ debugfs_create_u32("dapm_pop_time", 0644, parent, &pop_time);
+}
+
void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
struct dentry *parent)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread