soc-dapm.c (d1a76187a5be4f89c6cb19d800cb5fb7aac735c5) soc-dapm.c (12ef193d5817504621e503e78d641265f6a86ac4)
1/*
2 * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
3 *
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 23 unchanged lines hidden (view full) ---

32#include <linux/module.h>
33#include <linux/moduleparam.h>
34#include <linux/init.h>
35#include <linux/delay.h>
36#include <linux/pm.h>
37#include <linux/bitops.h>
38#include <linux/platform_device.h>
39#include <linux/jiffies.h>
1/*
2 * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
3 *
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 23 unchanged lines hidden (view full) ---

32#include <linux/module.h>
33#include <linux/moduleparam.h>
34#include <linux/init.h>
35#include <linux/delay.h>
36#include <linux/pm.h>
37#include <linux/bitops.h>
38#include <linux/platform_device.h>
39#include <linux/jiffies.h>
40#include <linux/debugfs.h>
41#include <sound/core.h>
42#include <sound/pcm.h>
43#include <sound/pcm_params.h>
44#include <sound/soc-dapm.h>
45#include <sound/initval.h>
46
47/* debug */
48#ifdef DEBUG

--- 13 unchanged lines hidden (view full) ---

62 snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic,
63 snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_post
64};
65
66static int dapm_status = 1;
67module_param(dapm_status, int, 0);
68MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries");
69
40#include <sound/core.h>
41#include <sound/pcm.h>
42#include <sound/pcm_params.h>
43#include <sound/soc-dapm.h>
44#include <sound/initval.h>
45
46/* debug */
47#ifdef DEBUG

--- 13 unchanged lines hidden (view full) ---

61 snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic,
62 snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_post
63};
64
65static int dapm_status = 1;
66module_param(dapm_status, int, 0);
67MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries");
68
70static struct dentry *asoc_debugfs;
71
72static u32 pop_time;
73
74static void pop_wait(void)
69static void pop_wait(u32 pop_time)
75{
76 if (pop_time)
77 schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
78}
79
70{
71 if (pop_time)
72 schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
73}
74
80static void pop_dbg(const char *fmt, ...)
75static void pop_dbg(u32 pop_time, const char *fmt, ...)
81{
82 va_list args;
83
84 va_start(args, fmt);
85
86 if (pop_time) {
87 vprintk(fmt, args);
76{
77 va_list args;
78
79 va_start(args, fmt);
80
81 if (pop_time) {
82 vprintk(fmt, args);
88 pop_wait();
83 pop_wait(pop_time);
89 }
90
91 va_end(args);
92}
93
94/* create a new dapm widget */
95static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
96 const struct snd_soc_dapm_widget *_widget)

--- 128 unchanged lines hidden (view full) ---

225 if (widget->invert)
226 power = (power ? 0:1);
227
228 old = snd_soc_read(codec, widget->reg);
229 new = (old & ~(0x1 << widget->shift)) | (power << widget->shift);
230
231 change = old != new;
232 if (change) {
84 }
85
86 va_end(args);
87}
88
89/* create a new dapm widget */
90static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
91 const struct snd_soc_dapm_widget *_widget)

--- 128 unchanged lines hidden (view full) ---

220 if (widget->invert)
221 power = (power ? 0:1);
222
223 old = snd_soc_read(codec, widget->reg);
224 new = (old & ~(0x1 << widget->shift)) | (power << widget->shift);
225
226 change = old != new;
227 if (change) {
233 pop_dbg("pop test %s : %s in %d ms\n", widget->name,
234 widget->power ? "on" : "off", pop_time);
228 pop_dbg(codec->pop_time, "pop test %s : %s in %d ms\n",
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 }
238 pr_debug("reg %x old %x new %x change %d\n", widget->reg,
239 old, new, change);
240 return change;
241}
242
243/* ramps the volume up or down to minimise pops before or after a
244 * DAPM power event */

--- 571 unchanged lines hidden (view full) ---

816
817 return count;
818}
819
820static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
821
822int snd_soc_dapm_sys_add(struct device *dev)
823{
233 }
234 pr_debug("reg %x old %x new %x change %d\n", widget->reg,
235 old, new, change);
236 return change;
237}
238
239/* ramps the volume up or down to minimise pops before or after a
240 * DAPM power event */

--- 571 unchanged lines hidden (view full) ---

812
813 return count;
814}
815
816static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
817
818int snd_soc_dapm_sys_add(struct device *dev)
819{
824 int ret = 0;
825
826 if (!dapm_status)
827 return 0;
828
829 ret = device_create_file(dev, &dev_attr_dapm_widget);
830 if (ret != 0)
831 return ret;
820 if (!dapm_status)
821 return 0;
822
823 ret = device_create_file(dev, &dev_attr_dapm_widget);
824 if (ret != 0)
825 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;
826 return device_create_file(dev, &dev_attr_dapm_widget);
841}
842
843static void snd_soc_dapm_sys_remove(struct device *dev)
844{
845 if (dapm_status) {
846 device_remove_file(dev, &dev_attr_dapm_widget);
847 }
827}
828
829static void snd_soc_dapm_sys_remove(struct device *dev)
830{
831 if (dapm_status) {
832 device_remove_file(dev, &dev_attr_dapm_widget);
833 }
848
849 if (asoc_debugfs)
850 debugfs_remove_recursive(asoc_debugfs);
851}
852
853/* free all dapm widgets and resources */
854static void dapm_free_widgets(struct snd_soc_codec *codec)
855{
856 struct snd_soc_dapm_widget *w, *next_w;
857 struct snd_soc_dapm_path *p, *next_p;
858

--- 143 unchanged lines hidden (view full) ---

1002err:
1003 printk(KERN_WARNING "asoc: no dapm match for %s --> %s --> %s\n", source,
1004 control, sink);
1005 kfree(path);
1006 return ret;
1007}
1008
1009/**
834}
835
836/* free all dapm widgets and resources */
837static void dapm_free_widgets(struct snd_soc_codec *codec)
838{
839 struct snd_soc_dapm_widget *w, *next_w;
840 struct snd_soc_dapm_path *p, *next_p;
841

--- 143 unchanged lines hidden (view full) ---

985err:
986 printk(KERN_WARNING "asoc: no dapm match for %s --> %s --> %s\n", source,
987 control, sink);
988 kfree(path);
989 return ret;
990}
991
992/**
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
1033 * @codec: codec
1034 * @route: audio routes
1035 * @num: number of routes
1036 *
1037 * Connects 2 dapm widgets together via a named audio path. The sink is
1038 * the widget receiving the audio signal, whilst the source is the sender
1039 * of the audio signal.

--- 506 unchanged lines hidden ---
993 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
994 * @codec: codec
995 * @route: audio routes
996 * @num: number of routes
997 *
998 * Connects 2 dapm widgets together via a named audio path. The sink is
999 * the widget receiving the audio signal, whilst the source is the sender
1000 * of the audio signal.

--- 506 unchanged lines hidden ---