提交 ef49e4fa 编写于 作者: M Mark Brown

ASoC: Add bias level data to DAPM context debugfs

This is also in the old sysfs diagnostics but it's nice to have everything
in one place.
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 34bad69c
...@@ -1304,6 +1304,47 @@ static const struct file_operations dapm_widget_power_fops = { ...@@ -1304,6 +1304,47 @@ static const struct file_operations dapm_widget_power_fops = {
.llseek = default_llseek, .llseek = default_llseek,
}; };
static int dapm_bias_open_file(struct inode *inode, struct file *file)
{
file->private_data = inode->i_private;
return 0;
}
static ssize_t dapm_bias_read_file(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct snd_soc_dapm_context *dapm = file->private_data;
char *level;
switch (dapm->bias_level) {
case SND_SOC_BIAS_ON:
level = "On\n";
break;
case SND_SOC_BIAS_PREPARE:
level = "Prepare\n";
break;
case SND_SOC_BIAS_STANDBY:
level = "Standby\n";
break;
case SND_SOC_BIAS_OFF:
level = "Off\n";
break;
default:
BUG();
level = "Unknown\n";
break;
}
return simple_read_from_buffer(user_buf, count, ppos, level,
strlen(level));
}
static const struct file_operations dapm_bias_fops = {
.open = dapm_bias_open_file,
.read = dapm_bias_read_file,
.llseek = default_llseek,
};
void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm) void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
...@@ -1312,6 +1353,13 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm) ...@@ -1312,6 +1353,13 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm)
if (!dapm->debugfs_dapm) if (!dapm->debugfs_dapm)
return; return;
d = debugfs_create_file("bias_level", 0444,
dapm->debugfs_dapm, dapm,
&dapm_bias_fops);
if (!d)
dev_warn(dapm->dev,
"ASoC: Failed to create bias level debugfs file\n");
list_for_each_entry(w, &dapm->card->widgets, list) { list_for_each_entry(w, &dapm->card->widgets, list) {
if (!w->name || w->dapm != dapm) if (!w->name || w->dapm != dapm)
continue; continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册