Skip to content

Commit 5b1047d

Browse files
lucaceresolibroonie
authored andcommitted
ASoC: dapm: debugfs: show the widget type
To make the widget debugfs files more informative, add a line showing the widget type string. Keeping backward compatibility is nice to have being debugfs, and ease of parsing by both humans and software is also good. To maximize both with a reasonable effort add a new line without thouching the already complex format of the first line. The syntax is meant to be a key/value pair. The existing vizdapm tool continues working after this change, ignoring the new line. The new format is: Left ADC: Off in 1 out 0 - R2(0x2) mask 0x2 stream Left HiFi Capture inactive widget-type adc out "static" "Capture" "cs42l51.0-004a" in "static" "Left PGA" "cs42l51.0-004a" Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20240416-vizdapm-ng-v1-2-5d33c0b57bc5@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent cbd9eed commit 5b1047d

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

sound/soc/soc-dapm.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,48 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
20942094
}
20952095

20962096
#ifdef CONFIG_DEBUG_FS
2097+
2098+
static const char * const snd_soc_dapm_type_name[] = {
2099+
[snd_soc_dapm_input] = "input",
2100+
[snd_soc_dapm_output] = "output",
2101+
[snd_soc_dapm_mux] = "mux",
2102+
[snd_soc_dapm_demux] = "demux",
2103+
[snd_soc_dapm_mixer] = "mixer",
2104+
[snd_soc_dapm_mixer_named_ctl] = "mixer_named_ctl",
2105+
[snd_soc_dapm_pga] = "pga",
2106+
[snd_soc_dapm_out_drv] = "out_drv",
2107+
[snd_soc_dapm_adc] = "adc",
2108+
[snd_soc_dapm_dac] = "dac",
2109+
[snd_soc_dapm_micbias] = "micbias",
2110+
[snd_soc_dapm_mic] = "mic",
2111+
[snd_soc_dapm_hp] = "hp",
2112+
[snd_soc_dapm_spk] = "spk",
2113+
[snd_soc_dapm_line] = "line",
2114+
[snd_soc_dapm_switch] = "switch",
2115+
[snd_soc_dapm_vmid] = "vmid",
2116+
[snd_soc_dapm_pre] = "pre",
2117+
[snd_soc_dapm_post] = "post",
2118+
[snd_soc_dapm_supply] = "supply",
2119+
[snd_soc_dapm_pinctrl] = "pinctrl",
2120+
[snd_soc_dapm_regulator_supply] = "regulator_supply",
2121+
[snd_soc_dapm_clock_supply] = "clock_supply",
2122+
[snd_soc_dapm_aif_in] = "aif_in",
2123+
[snd_soc_dapm_aif_out] = "aif_out",
2124+
[snd_soc_dapm_siggen] = "siggen",
2125+
[snd_soc_dapm_sink] = "sink",
2126+
[snd_soc_dapm_dai_in] = "dai_in",
2127+
[snd_soc_dapm_dai_out] = "dai_out",
2128+
[snd_soc_dapm_dai_link] = "dai_link",
2129+
[snd_soc_dapm_kcontrol] = "kcontrol",
2130+
[snd_soc_dapm_buffer] = "buffer",
2131+
[snd_soc_dapm_scheduler] = "scheduler",
2132+
[snd_soc_dapm_effect] = "effect",
2133+
[snd_soc_dapm_src] = "src",
2134+
[snd_soc_dapm_asrc] = "asrc",
2135+
[snd_soc_dapm_encoder] = "encoder",
2136+
[snd_soc_dapm_decoder] = "decoder",
2137+
};
2138+
20972139
static ssize_t dapm_widget_power_read_file(struct file *file,
20982140
char __user *user_buf,
20992141
size_t count, loff_t *ppos)
@@ -2106,6 +2148,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
21062148
struct snd_soc_dapm_path *p = NULL;
21072149
const char *c_name;
21082150

2151+
BUILD_BUG_ON(ARRAY_SIZE(snd_soc_dapm_type_name) != SND_SOC_DAPM_TYPE_COUNT);
2152+
21092153
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
21102154
if (!buf)
21112155
return -ENOMEM;
@@ -2137,6 +2181,9 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
21372181
w->sname,
21382182
w->active ? "active" : "inactive");
21392183

2184+
ret += scnprintf(buf + ret, PAGE_SIZE - ret, " widget-type %s\n",
2185+
snd_soc_dapm_type_name[w->id]);
2186+
21402187
snd_soc_dapm_for_each_direction(dir) {
21412188
rdir = SND_SOC_DAPM_DIR_REVERSE(dir);
21422189
snd_soc_dapm_widget_for_each_path(w, dir, p) {

0 commit comments

Comments
 (0)