Allow setting codec register with debugfs filesystem
PATCH 1/1 Allow setting codec register with debugfs filesystem
i.e. echo 6 59 >/sys/kernel/debug/soc-audio.0/codec_reg will set register 0x06 to a value of 0x59.
Also, pop_time debugfs interface setup is moved so that it is setup in the same function as codec_reg
include/sound/soc.h +4 -0
@@ -425,6 +425,7 @@ struct snd_soc_codec {short reg_cache_step;/* dapm */ +u32 pop_time;struct list_head dapm_widgets;struct list_head dapm_paths;enum snd_soc_bias_level bias_level;
@@ -516,6 +517,9 @@ struct snd_soc_device {struct delayed_work delayed_work;struct work_struct deferred_resume_work;void *codec_data; +#ifdef CONFIG_DEBUG_FS +struct dentry *debugfs_root; +#endif };/* runtime channel data */
sound/soc/soc-core.c +113 -3
149 lines not on this page · raw message
sound/soc/soc-dapm.c +8 -29
@@ -38,7 +38,6 @@#include <linux/bitops.h> #include <linux/platform_device.h> #include <linux/jiffies.h> -#include <linux/debugfs.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h>
@@ -68,17 +67,13 @@ static int dapm_status = 1;module_param (dapm_status, int,0 );MODULE_PARM_DESC (dapm_status,"enable DPM sysfs entries" ); -static struct dentry *asoc_debugfs; - -static u32 pop_time; - -static void pop_wait (void ) +static void pop_wait (u32 pop_time) {if (pop_time)schedule_timeout_uninterruptible (msecs_to_jiffies (pop_time)); } -static void pop_dbg (const char *fmt, ...) +static void pop_dbg (u32 pop_time,const char *fmt, ...) {va_list args;
@@ -86,7 +81,7 @@ static void pop_dbg(const char *fmt, ...)if (pop_time) {vprintk (fmt, args); -pop_wait (); +pop_wait (pop_time); }va_end (args);
@@ -231,10 +226,11 @@ static int dapm_update_bits(struct snd_soc_dapm_widget *widget) change = old != new;if (change) { -pop_dbg ("pop test %s : %s in %d ms\n" , widget->name, - widget->power ?"on" :"off" , pop_time); +pop_dbg (codec->pop_time,"pop test %s : %s in %d ms\n" , + widget->name, widget->power ?"on" :"off" , + codec->pop_time);snd_soc_write (codec, widget->reg, new); -pop_wait (); +pop_wait (codec->pop_time); }pr_debug ("reg %x old %x new %x change %d\n" , widget->reg, old, new, change);
@@ -822,23 +818,9 @@ static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);int snd_soc_dapm_sys_add (struct device *dev) { -int ret =0 ; -if (!dapm_status)return 0 ; - - ret =device_create_file (dev, &dev_attr_dapm_widget); -if (ret !=0 ) -return ret; - - asoc_debugfs =debugfs_create_dir ("asoc" ,NULL ); -if (!IS_ERR (asoc_debugfs)) -debugfs_create_u32 ("dapm_pop_time" ,0744 , asoc_debugfs, - &pop_time); -else - asoc_debugfs =NULL ; - -return 0 ; +return device_create_file (dev, &dev_attr_dapm_widget); }static void snd_soc_dapm_sys_remove (struct device *dev)
@@ -846,9 +828,6 @@ static void snd_soc_dapm_sys_remove(struct device *dev)if (dapm_status) {device_remove_file (dev, &dev_attr_dapm_widget); } - -if (asoc_debugfs) -debugfs_remove_recursive (asoc_debugfs); }/* free all dapm widgets and resources */
Signature · 1 line
1.5.4.3
On Mon, Oct 13, 2008 at 05:42:14PM -0700, Troy Kisky wrote:
Thanks.
include/sound/soc.h struct snd_soc_codec { · line 429
Quoted 6 lines
include/sound/soc.h +1
-0@@ -425,6 +425,7 @@ struct snd_soc_codec {short reg_cache_step;/* dapm */ +u32 pop_time;struct list_head dapm_widgets;
Hrm. On the one hand this is deliberately a system-wide bit of configuration since the pop/click sequencing covers the whole system rather than just the codec. On the other hand the codec structure does, unfortunately, represent the entire sound device currently. I'll have a think and either push the patch as-is or push it together with a followup patch moving the pop time configuration out of the codec structure.
sound/soc/soc-core.c static ssize_t codec_reg_show(struct device *dev, · line 1011
Quoted 3 lines
sound/soc/soc-core.c +2
-0+} + static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
Extra blank line added here.
sound/soc/soc-core.c static ssize_t codec_reg_show(struct device *dev, · line 1089
Quoted 9 lines
sound/soc/soc-core.c +9
-0+ file =debugfs_create_file ("codec_reg" ,0644 , + root, socdev, &codec_reg_fops); +if (!file) + goto exit2; + + file =debugfs_create_u32 ("dapm_pop_time" ,0744 , + root, &codec->pop_time); +if (!file) + goto exit2;
There's no real need to handle these errors - if anything, it's probably better to half create the tree
sound/soc/soc-core.c static ssize_t codec_reg_show(struct device *dev, · line 1096
Quoted 3 lines
sound/soc/soc-core.c +3
-0+exit1: +dev_err (socdev->dev,"debugfs is not available\n" ); +}
This isn't actually an error...