aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/soc-dapm.c67
1 files changed, 53 insertions, 14 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 25363829e605..7c2dd4ec8df1 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -54,16 +54,6 @@
54#define dbg(format, arg...) 54#define dbg(format, arg...)
55#endif 55#endif
56 56
57#define POP_DEBUG 0
58#if POP_DEBUG
59#define POP_TIME 500 /* 500 msecs - change if pop debug is too fast */
60#define pop_wait(time) schedule_timeout_uninterruptible(msecs_to_jiffies(time))
61#define pop_dbg(format, arg...) printk(format, ## arg); pop_wait(POP_TIME)
62#else
63#define pop_dbg(format, arg...)
64#define pop_wait(time)
65#endif
66
67/* dapm power sequences - make this per codec in the future */ 57/* dapm power sequences - make this per codec in the future */
68static int dapm_up_seq[] = { 58static int dapm_up_seq[] = {
69 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, 59 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic,
@@ -80,6 +70,28 @@ static int dapm_status = 1;
80module_param(dapm_status, int, 0); 70module_param(dapm_status, int, 0);
81MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries"); 71MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries");
82 72
73static unsigned int pop_time;
74
75static void pop_wait(void)
76{
77 if (pop_time)
78 schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
79}
80
81static void pop_dbg(const char *fmt, ...)
82{
83 va_list args;
84
85 va_start(args, fmt);
86
87 if (pop_time) {
88 vprintk(fmt, args);
89 pop_wait();
90 }
91
92 va_end(args);
93}
94
83/* create a new dapm widget */ 95/* create a new dapm widget */
84static inline struct snd_soc_dapm_widget *dapm_cnew_widget( 96static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
85 const struct snd_soc_dapm_widget *_widget) 97 const struct snd_soc_dapm_widget *_widget)
@@ -217,9 +229,9 @@ static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
217 change = old != new; 229 change = old != new;
218 if (change) { 230 if (change) {
219 pop_dbg("pop test %s : %s in %d ms\n", widget->name, 231 pop_dbg("pop test %s : %s in %d ms\n", widget->name,
220 widget->power ? "on" : "off", POP_TIME); 232 widget->power ? "on" : "off", pop_time);
221 snd_soc_write(codec, widget->reg, new); 233 snd_soc_write(codec, widget->reg, new);
222 pop_wait(POP_TIME); 234 pop_wait();
223 } 235 }
224 dbg("reg %x old %x new %x change %d\n", widget->reg, old, new, change); 236 dbg("reg %x old %x new %x change %d\n", widget->reg, old, new, change);
225 return change; 237 return change;
@@ -803,20 +815,47 @@ static ssize_t dapm_widget_show(struct device *dev,
803 815
804static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); 816static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
805 817
818/* pop/click delay times */
819static ssize_t dapm_pop_time_show(struct device *dev,
820 struct device_attribute *attr, char *buf)
821{
822 return sprintf(buf, "%d\n", pop_time);
823}
824
825static ssize_t dapm_pop_time_store(struct device *dev,
826 struct device_attribute *attr,
827 const char *buf, size_t count)
828
829{
830 if (strict_strtoul(buf, 10, &pop_time) < 0)
831 printk(KERN_ERR "Unable to parse pop_time setting\n");
832
833 return count;
834}
835
836static DEVICE_ATTR(dapm_pop_time, 0744, dapm_pop_time_show,
837 dapm_pop_time_store);
838
806int snd_soc_dapm_sys_add(struct device *dev) 839int snd_soc_dapm_sys_add(struct device *dev)
807{ 840{
808 int ret = 0; 841 int ret = 0;
809 842
810 if (dapm_status) 843 if (dapm_status) {
811 ret = device_create_file(dev, &dev_attr_dapm_widget); 844 ret = device_create_file(dev, &dev_attr_dapm_widget);
812 845
846 if (ret == 0)
847 ret = device_create_file(dev, &dev_attr_dapm_pop_time);
848 }
849
813 return ret; 850 return ret;
814} 851}
815 852
816static void snd_soc_dapm_sys_remove(struct device *dev) 853static void snd_soc_dapm_sys_remove(struct device *dev)
817{ 854{
818 if (dapm_status) 855 if (dapm_status) {
856 device_remove_file(dev, &dev_attr_dapm_pop_time);
819 device_remove_file(dev, &dev_attr_dapm_widget); 857 device_remove_file(dev, &dev_attr_dapm_widget);
858 }
820} 859}
821 860
822/* free all dapm widgets and resources */ 861/* free all dapm widgets and resources */