aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c82
1 files changed, 24 insertions, 58 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 7351db9606e4..8863eddbac02 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -37,7 +37,6 @@
37#include <linux/bitops.h> 37#include <linux/bitops.h>
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/jiffies.h> 39#include <linux/jiffies.h>
40#include <linux/debugfs.h>
41#include <sound/core.h> 40#include <sound/core.h>
42#include <sound/pcm.h> 41#include <sound/pcm.h>
43#include <sound/pcm_params.h> 42#include <sound/pcm_params.h>
@@ -67,17 +66,13 @@ static int dapm_status = 1;
67module_param(dapm_status, int, 0); 66module_param(dapm_status, int, 0);
68MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries"); 67MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries");
69 68
70static struct dentry *asoc_debugfs; 69static void pop_wait(u32 pop_time)
71
72static u32 pop_time;
73
74static void pop_wait(void)
75{ 70{
76 if (pop_time) 71 if (pop_time)
77 schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time)); 72 schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
78} 73}
79 74
80static void pop_dbg(const char *fmt, ...) 75static void pop_dbg(u32 pop_time, const char *fmt, ...)
81{ 76{
82 va_list args; 77 va_list args;
83 78
@@ -85,7 +80,7 @@ static void pop_dbg(const char *fmt, ...)
85 80
86 if (pop_time) { 81 if (pop_time) {
87 vprintk(fmt, args); 82 vprintk(fmt, args);
88 pop_wait(); 83 pop_wait(pop_time);
89 } 84 }
90 85
91 va_end(args); 86 va_end(args);
@@ -230,10 +225,11 @@ static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
230 225
231 change = old != new; 226 change = old != new;
232 if (change) { 227 if (change) {
233 pop_dbg("pop test %s : %s in %d ms\n", widget->name, 228 pop_dbg(codec->pop_time, "pop test %s : %s in %d ms\n",
234 widget->power ? "on" : "off", pop_time); 229 widget->name, widget->power ? "on" : "off",
230 codec->pop_time);
235 snd_soc_write(codec, widget->reg, new); 231 snd_soc_write(codec, widget->reg, new);
236 pop_wait(); 232 pop_wait(codec->pop_time);
237 } 233 }
238 pr_debug("reg %x old %x new %x change %d\n", widget->reg, 234 pr_debug("reg %x old %x new %x change %d\n", widget->reg,
239 old, new, change); 235 old, new, change);
@@ -293,7 +289,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
293 struct snd_soc_dapm_widget *w) 289 struct snd_soc_dapm_widget *w)
294{ 290{
295 int i, ret = 0; 291 int i, ret = 0;
296 char name[32]; 292 size_t name_len;
297 struct snd_soc_dapm_path *path; 293 struct snd_soc_dapm_path *path;
298 294
299 /* add kcontrol */ 295 /* add kcontrol */
@@ -307,11 +303,16 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
307 continue; 303 continue;
308 304
309 /* add dapm control with long name */ 305 /* add dapm control with long name */
310 snprintf(name, 32, "%s %s", w->name, w->kcontrols[i].name); 306 name_len = 2 + strlen(w->name)
311 path->long_name = kstrdup (name, GFP_KERNEL); 307 + strlen(w->kcontrols[i].name);
308 path->long_name = kmalloc(name_len, GFP_KERNEL);
312 if (path->long_name == NULL) 309 if (path->long_name == NULL)
313 return -ENOMEM; 310 return -ENOMEM;
314 311
312 snprintf(path->long_name, name_len, "%s %s",
313 w->name, w->kcontrols[i].name);
314 path->long_name[name_len - 1] = '\0';
315
315 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w, 316 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
316 path->long_name); 317 path->long_name);
317 ret = snd_ctl_add(codec->card, path->kcontrol); 318 ret = snd_ctl_add(codec->card, path->kcontrol);
@@ -821,23 +822,9 @@ static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
821 822
822int snd_soc_dapm_sys_add(struct device *dev) 823int snd_soc_dapm_sys_add(struct device *dev)
823{ 824{
824 int ret = 0;
825
826 if (!dapm_status) 825 if (!dapm_status)
827 return 0; 826 return 0;
828 827 return device_create_file(dev, &dev_attr_dapm_widget);
829 ret = device_create_file(dev, &dev_attr_dapm_widget);
830 if (ret != 0)
831 return ret;
832
833 asoc_debugfs = debugfs_create_dir("asoc", NULL);
834 if (!IS_ERR(asoc_debugfs) && asoc_debugfs)
835 debugfs_create_u32("dapm_pop_time", 0744, asoc_debugfs,
836 &pop_time);
837 else
838 asoc_debugfs = NULL;
839
840 return 0;
841} 828}
842 829
843static void snd_soc_dapm_sys_remove(struct device *dev) 830static void snd_soc_dapm_sys_remove(struct device *dev)
@@ -845,9 +832,6 @@ static void snd_soc_dapm_sys_remove(struct device *dev)
845 if (dapm_status) { 832 if (dapm_status) {
846 device_remove_file(dev, &dev_attr_dapm_widget); 833 device_remove_file(dev, &dev_attr_dapm_widget);
847 } 834 }
848
849 if (asoc_debugfs)
850 debugfs_remove_recursive(asoc_debugfs);
851} 835}
852 836
853/* free all dapm widgets and resources */ 837/* free all dapm widgets and resources */
@@ -1007,28 +991,6 @@ err:
1007} 991}
1008 992
1009/** 993/**
1010 * snd_soc_dapm_connect_input - connect dapm widgets
1011 * @codec: audio codec
1012 * @sink: name of target widget
1013 * @control: mixer control name
1014 * @source: name of source name
1015 *
1016 * Connects 2 dapm widgets together via a named audio path. The sink is
1017 * the widget receiving the audio signal, whilst the source is the sender
1018 * of the audio signal.
1019 *
1020 * This function has been deprecated in favour of snd_soc_dapm_add_routes().
1021 *
1022 * Returns 0 for success else error.
1023 */
1024int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink,
1025 const char *control, const char *source)
1026{
1027 return snd_soc_dapm_add_route(codec, sink, control, source);
1028}
1029EXPORT_SYMBOL_GPL(snd_soc_dapm_connect_input);
1030
1031/**
1032 * snd_soc_dapm_add_routes - Add routes between DAPM widgets 994 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
1033 * @codec: codec 995 * @codec: codec
1034 * @route: audio routes 996 * @route: audio routes
@@ -1358,8 +1320,12 @@ int snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
1358 1320
1359 for (i = 0; i < num; i++) { 1321 for (i = 0; i < num; i++) {
1360 ret = snd_soc_dapm_new_control(codec, widget); 1322 ret = snd_soc_dapm_new_control(codec, widget);
1361 if (ret < 0) 1323 if (ret < 0) {
1324 printk(KERN_ERR
1325 "ASoC: Failed to create DAPM control %s: %d\n",
1326 widget->name, ret);
1362 return ret; 1327 return ret;
1328 }
1363 widget++; 1329 widget++;
1364 } 1330 }
1365 return 0; 1331 return 0;
@@ -1440,11 +1406,11 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
1440 enum snd_soc_bias_level level) 1406 enum snd_soc_bias_level level)
1441{ 1407{
1442 struct snd_soc_codec *codec = socdev->codec; 1408 struct snd_soc_codec *codec = socdev->codec;
1443 struct snd_soc_machine *machine = socdev->machine; 1409 struct snd_soc_card *card = socdev->card;
1444 int ret = 0; 1410 int ret = 0;
1445 1411
1446 if (machine->set_bias_level) 1412 if (card->set_bias_level)
1447 ret = machine->set_bias_level(machine, level); 1413 ret = card->set_bias_level(card, level);
1448 if (ret == 0 && codec->set_bias_level) 1414 if (ret == 0 && codec->set_bias_level)
1449 ret = codec->set_bias_level(codec, level); 1415 ret = codec->set_bias_level(codec, level);
1450 1416