Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1 | /* |
| 2 | * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management |
| 3 | * |
| 4 | * Copyright 2005 Wolfson Microelectronics PLC. |
Liam Girdwood | d331124 | 2008-10-12 13:17:36 +0100 | [diff] [blame] | 5 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 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 |
| 9 | * Free Software Foundation; either version 2 of the License, or (at your |
| 10 | * option) any later version. |
| 11 | * |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 12 | * Features: |
| 13 | * o Changes power status of internal codec blocks depending on the |
| 14 | * dynamic configuration of codec internal audio paths and active |
Mark Brown | 74b8f95 | 2009-06-06 11:26:15 +0100 | [diff] [blame] | 15 | * DACs/ADCs. |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 16 | * o Platform power domain - can support external components i.e. amps and |
| 17 | * mic/meadphone insertion events. |
| 18 | * o Automatic Mic Bias support |
| 19 | * o Jack insertion power event initiation - e.g. hp insertion will enable |
| 20 | * sinks, dacs, etc |
Robert P. J. Day | 3a4fa0a | 2007-10-19 23:10:43 +0200 | [diff] [blame] | 21 | * o Delayed powerdown of audio susbsystem to reduce pops between a quick |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 22 | * device reopen. |
| 23 | * |
| 24 | * Todo: |
| 25 | * o DAPM power change sequencing - allow for configurable per |
| 26 | * codec sequences. |
| 27 | * o Support for analogue bias optimisation. |
| 28 | * o Support for reduced codec oversampling rates. |
| 29 | * o Support for reduced codec bias currents. |
| 30 | */ |
| 31 | |
| 32 | #include <linux/module.h> |
| 33 | #include <linux/moduleparam.h> |
| 34 | #include <linux/init.h> |
Mark Brown | 9d0624a | 2011-02-18 11:49:43 -0800 | [diff] [blame^] | 35 | #include <linux/async.h> |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 36 | #include <linux/delay.h> |
| 37 | #include <linux/pm.h> |
| 38 | #include <linux/bitops.h> |
| 39 | #include <linux/platform_device.h> |
| 40 | #include <linux/jiffies.h> |
Takashi Iwai | 20496ff | 2009-08-24 09:40:34 +0200 | [diff] [blame] | 41 | #include <linux/debugfs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 42 | #include <linux/slab.h> |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 43 | #include <sound/core.h> |
| 44 | #include <sound/pcm.h> |
| 45 | #include <sound/pcm_params.h> |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 46 | #include <sound/soc.h> |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 47 | #include <sound/initval.h> |
| 48 | |
Mark Brown | 84e9093 | 2010-11-04 00:07:02 -0400 | [diff] [blame] | 49 | #include <trace/events/asoc.h> |
| 50 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 51 | /* dapm power sequences - make this per codec in the future */ |
| 52 | static int dapm_up_seq[] = { |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 53 | [snd_soc_dapm_pre] = 0, |
| 54 | [snd_soc_dapm_supply] = 1, |
| 55 | [snd_soc_dapm_micbias] = 2, |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 56 | [snd_soc_dapm_aif_in] = 3, |
| 57 | [snd_soc_dapm_aif_out] = 3, |
| 58 | [snd_soc_dapm_mic] = 4, |
| 59 | [snd_soc_dapm_mux] = 5, |
Dimitris Papastamos | 24ff33a | 2010-12-16 15:53:39 +0000 | [diff] [blame] | 60 | [snd_soc_dapm_virt_mux] = 5, |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 61 | [snd_soc_dapm_value_mux] = 5, |
| 62 | [snd_soc_dapm_dac] = 6, |
| 63 | [snd_soc_dapm_mixer] = 7, |
| 64 | [snd_soc_dapm_mixer_named_ctl] = 7, |
| 65 | [snd_soc_dapm_pga] = 8, |
| 66 | [snd_soc_dapm_adc] = 9, |
Olaya, Margarita | d88429a | 2010-12-10 21:11:44 -0600 | [diff] [blame] | 67 | [snd_soc_dapm_out_drv] = 10, |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 68 | [snd_soc_dapm_hp] = 10, |
| 69 | [snd_soc_dapm_spk] = 10, |
| 70 | [snd_soc_dapm_post] = 11, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 71 | }; |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 72 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 73 | static int dapm_down_seq[] = { |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 74 | [snd_soc_dapm_pre] = 0, |
| 75 | [snd_soc_dapm_adc] = 1, |
| 76 | [snd_soc_dapm_hp] = 2, |
Mark Brown | 1ca0406 | 2009-08-17 16:26:59 +0100 | [diff] [blame] | 77 | [snd_soc_dapm_spk] = 2, |
Olaya, Margarita | d88429a | 2010-12-10 21:11:44 -0600 | [diff] [blame] | 78 | [snd_soc_dapm_out_drv] = 2, |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 79 | [snd_soc_dapm_pga] = 4, |
| 80 | [snd_soc_dapm_mixer_named_ctl] = 5, |
Mark Brown | e3d4dab | 2009-06-07 13:08:45 +0100 | [diff] [blame] | 81 | [snd_soc_dapm_mixer] = 5, |
| 82 | [snd_soc_dapm_dac] = 6, |
| 83 | [snd_soc_dapm_mic] = 7, |
| 84 | [snd_soc_dapm_micbias] = 8, |
| 85 | [snd_soc_dapm_mux] = 9, |
Dimitris Papastamos | 24ff33a | 2010-12-16 15:53:39 +0000 | [diff] [blame] | 86 | [snd_soc_dapm_virt_mux] = 9, |
Mark Brown | e3d4dab | 2009-06-07 13:08:45 +0100 | [diff] [blame] | 87 | [snd_soc_dapm_value_mux] = 9, |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 88 | [snd_soc_dapm_aif_in] = 10, |
| 89 | [snd_soc_dapm_aif_out] = 10, |
| 90 | [snd_soc_dapm_supply] = 11, |
| 91 | [snd_soc_dapm_post] = 12, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 92 | }; |
| 93 | |
Troy Kisky | 12ef193 | 2008-10-13 17:42:14 -0700 | [diff] [blame] | 94 | static void pop_wait(u32 pop_time) |
Mark Brown | 15e4c72f | 2008-07-02 11:51:20 +0100 | [diff] [blame] | 95 | { |
| 96 | if (pop_time) |
| 97 | schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time)); |
| 98 | } |
| 99 | |
Jarkko Nikula | fd8d3bc | 2010-11-09 14:40:28 +0200 | [diff] [blame] | 100 | static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...) |
Mark Brown | 15e4c72f | 2008-07-02 11:51:20 +0100 | [diff] [blame] | 101 | { |
| 102 | va_list args; |
Jarkko Nikula | fd8d3bc | 2010-11-09 14:40:28 +0200 | [diff] [blame] | 103 | char *buf; |
| 104 | |
| 105 | if (!pop_time) |
| 106 | return; |
| 107 | |
| 108 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 109 | if (buf == NULL) |
| 110 | return; |
Mark Brown | 15e4c72f | 2008-07-02 11:51:20 +0100 | [diff] [blame] | 111 | |
| 112 | va_start(args, fmt); |
Jarkko Nikula | fd8d3bc | 2010-11-09 14:40:28 +0200 | [diff] [blame] | 113 | vsnprintf(buf, PAGE_SIZE, fmt, args); |
Takashi Iwai | 9d01df0 | 2010-12-22 14:08:40 +0100 | [diff] [blame] | 114 | dev_info(dev, "%s", buf); |
Mark Brown | 15e4c72f | 2008-07-02 11:51:20 +0100 | [diff] [blame] | 115 | va_end(args); |
Jarkko Nikula | fd8d3bc | 2010-11-09 14:40:28 +0200 | [diff] [blame] | 116 | |
| 117 | kfree(buf); |
Mark Brown | 15e4c72f | 2008-07-02 11:51:20 +0100 | [diff] [blame] | 118 | } |
| 119 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 120 | /* create a new dapm widget */ |
Takashi Iwai | 88cb429 | 2007-02-05 14:56:20 +0100 | [diff] [blame] | 121 | static inline struct snd_soc_dapm_widget *dapm_cnew_widget( |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 122 | const struct snd_soc_dapm_widget *_widget) |
| 123 | { |
Takashi Iwai | 88cb429 | 2007-02-05 14:56:20 +0100 | [diff] [blame] | 124 | return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 125 | } |
| 126 | |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 127 | /** |
| 128 | * snd_soc_dapm_set_bias_level - set the bias level for the system |
Mark Brown | ed5a4c4 | 2011-02-18 11:12:42 -0800 | [diff] [blame] | 129 | * @dapm: DAPM context |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 130 | * @level: level to configure |
| 131 | * |
| 132 | * Configure the bias (power) levels for the SoC audio device. |
| 133 | * |
| 134 | * Returns 0 for success else error. |
| 135 | */ |
Mark Brown | ed5a4c4 | 2011-02-18 11:12:42 -0800 | [diff] [blame] | 136 | static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm, |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 137 | enum snd_soc_bias_level level) |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 138 | { |
Mark Brown | ed5a4c4 | 2011-02-18 11:12:42 -0800 | [diff] [blame] | 139 | struct snd_soc_card *card = dapm->card; |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 140 | int ret = 0; |
| 141 | |
Mark Brown | f83fba8 | 2009-05-18 15:44:43 +0100 | [diff] [blame] | 142 | switch (level) { |
| 143 | case SND_SOC_BIAS_ON: |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 144 | dev_dbg(dapm->dev, "Setting full bias\n"); |
Mark Brown | f83fba8 | 2009-05-18 15:44:43 +0100 | [diff] [blame] | 145 | break; |
| 146 | case SND_SOC_BIAS_PREPARE: |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 147 | dev_dbg(dapm->dev, "Setting bias prepare\n"); |
Mark Brown | f83fba8 | 2009-05-18 15:44:43 +0100 | [diff] [blame] | 148 | break; |
| 149 | case SND_SOC_BIAS_STANDBY: |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 150 | dev_dbg(dapm->dev, "Setting standby bias\n"); |
Mark Brown | f83fba8 | 2009-05-18 15:44:43 +0100 | [diff] [blame] | 151 | break; |
| 152 | case SND_SOC_BIAS_OFF: |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 153 | dev_dbg(dapm->dev, "Setting bias off\n"); |
Mark Brown | f83fba8 | 2009-05-18 15:44:43 +0100 | [diff] [blame] | 154 | break; |
| 155 | default: |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 156 | dev_err(dapm->dev, "Setting invalid bias %d\n", level); |
Mark Brown | f83fba8 | 2009-05-18 15:44:43 +0100 | [diff] [blame] | 157 | return -EINVAL; |
| 158 | } |
| 159 | |
Mark Brown | 84e9093 | 2010-11-04 00:07:02 -0400 | [diff] [blame] | 160 | trace_snd_soc_bias_level_start(card, level); |
| 161 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 162 | if (card && card->set_bias_level) |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 163 | ret = card->set_bias_level(card, level); |
Mark Brown | 474e09c | 2009-08-19 14:18:53 +0100 | [diff] [blame] | 164 | if (ret == 0) { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 165 | if (dapm->codec && dapm->codec->driver->set_bias_level) |
| 166 | ret = dapm->codec->driver->set_bias_level(dapm->codec, level); |
Mark Brown | 474e09c | 2009-08-19 14:18:53 +0100 | [diff] [blame] | 167 | else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 168 | dapm->bias_level = level; |
Mark Brown | 474e09c | 2009-08-19 14:18:53 +0100 | [diff] [blame] | 169 | } |
Mark Brown | 1badabd | 2010-12-04 12:41:04 +0000 | [diff] [blame] | 170 | if (ret == 0) { |
| 171 | if (card && card->set_bias_level_post) |
| 172 | ret = card->set_bias_level_post(card, level); |
| 173 | } |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 174 | |
Mark Brown | 84e9093 | 2010-11-04 00:07:02 -0400 | [diff] [blame] | 175 | trace_snd_soc_bias_level_done(card, level); |
| 176 | |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 177 | return ret; |
| 178 | } |
| 179 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 180 | /* set up initial codec paths */ |
| 181 | static void dapm_set_path_status(struct snd_soc_dapm_widget *w, |
| 182 | struct snd_soc_dapm_path *p, int i) |
| 183 | { |
| 184 | switch (w->id) { |
| 185 | case snd_soc_dapm_switch: |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 186 | case snd_soc_dapm_mixer: |
| 187 | case snd_soc_dapm_mixer_named_ctl: { |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 188 | int val; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 189 | struct soc_mixer_control *mc = (struct soc_mixer_control *) |
| 190 | w->kcontrols[i].private_value; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 191 | unsigned int reg = mc->reg; |
| 192 | unsigned int shift = mc->shift; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 193 | int max = mc->max; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 194 | unsigned int mask = (1 << fls(max)) - 1; |
| 195 | unsigned int invert = mc->invert; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 196 | |
| 197 | val = snd_soc_read(w->codec, reg); |
| 198 | val = (val >> shift) & mask; |
| 199 | |
| 200 | if ((invert && !val) || (!invert && val)) |
| 201 | p->connect = 1; |
| 202 | else |
| 203 | p->connect = 0; |
| 204 | } |
| 205 | break; |
| 206 | case snd_soc_dapm_mux: { |
| 207 | struct soc_enum *e = (struct soc_enum *)w->kcontrols[i].private_value; |
| 208 | int val, item, bitmask; |
| 209 | |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 210 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 211 | ; |
| 212 | val = snd_soc_read(w->codec, e->reg); |
| 213 | item = (val >> e->shift_l) & (bitmask - 1); |
| 214 | |
| 215 | p->connect = 0; |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 216 | for (i = 0; i < e->max; i++) { |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 217 | if (!(strcmp(p->name, e->texts[i])) && item == i) |
| 218 | p->connect = 1; |
| 219 | } |
| 220 | } |
| 221 | break; |
Dimitris Papastamos | 24ff33a | 2010-12-16 15:53:39 +0000 | [diff] [blame] | 222 | case snd_soc_dapm_virt_mux: { |
| 223 | struct soc_enum *e = (struct soc_enum *)w->kcontrols[i].private_value; |
| 224 | |
| 225 | p->connect = 0; |
| 226 | /* since a virtual mux has no backing registers to |
| 227 | * decide which path to connect, it will try to match |
| 228 | * with the first enumeration. This is to ensure |
| 229 | * that the default mux choice (the first) will be |
| 230 | * correctly powered up during initialization. |
| 231 | */ |
| 232 | if (!strcmp(p->name, e->texts[0])) |
| 233 | p->connect = 1; |
| 234 | } |
| 235 | break; |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 236 | case snd_soc_dapm_value_mux: { |
Peter Ujfalusi | 7415555 | 2009-01-08 13:34:29 +0200 | [diff] [blame] | 237 | struct soc_enum *e = (struct soc_enum *) |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 238 | w->kcontrols[i].private_value; |
| 239 | int val, item; |
| 240 | |
| 241 | val = snd_soc_read(w->codec, e->reg); |
| 242 | val = (val >> e->shift_l) & e->mask; |
| 243 | for (item = 0; item < e->max; item++) { |
| 244 | if (val == e->values[item]) |
| 245 | break; |
| 246 | } |
| 247 | |
| 248 | p->connect = 0; |
| 249 | for (i = 0; i < e->max; i++) { |
| 250 | if (!(strcmp(p->name, e->texts[i])) && item == i) |
| 251 | p->connect = 1; |
| 252 | } |
| 253 | } |
| 254 | break; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 255 | /* does not effect routing - always connected */ |
| 256 | case snd_soc_dapm_pga: |
Olaya, Margarita | d88429a | 2010-12-10 21:11:44 -0600 | [diff] [blame] | 257 | case snd_soc_dapm_out_drv: |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 258 | case snd_soc_dapm_output: |
| 259 | case snd_soc_dapm_adc: |
| 260 | case snd_soc_dapm_input: |
| 261 | case snd_soc_dapm_dac: |
| 262 | case snd_soc_dapm_micbias: |
| 263 | case snd_soc_dapm_vmid: |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 264 | case snd_soc_dapm_supply: |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 265 | case snd_soc_dapm_aif_in: |
| 266 | case snd_soc_dapm_aif_out: |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 267 | p->connect = 1; |
| 268 | break; |
| 269 | /* does effect routing - dynamically connected */ |
| 270 | case snd_soc_dapm_hp: |
| 271 | case snd_soc_dapm_mic: |
| 272 | case snd_soc_dapm_spk: |
| 273 | case snd_soc_dapm_line: |
| 274 | case snd_soc_dapm_pre: |
| 275 | case snd_soc_dapm_post: |
| 276 | p->connect = 0; |
| 277 | break; |
| 278 | } |
| 279 | } |
| 280 | |
Mark Brown | 74b8f95 | 2009-06-06 11:26:15 +0100 | [diff] [blame] | 281 | /* connect mux widget to its interconnecting audio paths */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 282 | static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 283 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, |
| 284 | struct snd_soc_dapm_path *path, const char *control_name, |
| 285 | const struct snd_kcontrol_new *kcontrol) |
| 286 | { |
| 287 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
| 288 | int i; |
| 289 | |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 290 | for (i = 0; i < e->max; i++) { |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 291 | if (!(strcmp(control_name, e->texts[i]))) { |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 292 | list_add(&path->list, &dapm->card->paths); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 293 | list_add(&path->list_sink, &dest->sources); |
| 294 | list_add(&path->list_source, &src->sinks); |
| 295 | path->name = (char*)e->texts[i]; |
| 296 | dapm_set_path_status(dest, path, 0); |
| 297 | return 0; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | return -ENODEV; |
| 302 | } |
| 303 | |
Mark Brown | 74b8f95 | 2009-06-06 11:26:15 +0100 | [diff] [blame] | 304 | /* connect mixer widget to its interconnecting audio paths */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 305 | static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 306 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, |
| 307 | struct snd_soc_dapm_path *path, const char *control_name) |
| 308 | { |
| 309 | int i; |
| 310 | |
| 311 | /* search for mixer kcontrol */ |
| 312 | for (i = 0; i < dest->num_kcontrols; i++) { |
| 313 | if (!strcmp(control_name, dest->kcontrols[i].name)) { |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 314 | list_add(&path->list, &dapm->card->paths); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 315 | list_add(&path->list_sink, &dest->sources); |
| 316 | list_add(&path->list_source, &src->sinks); |
| 317 | path->name = dest->kcontrols[i].name; |
| 318 | dapm_set_path_status(dest, path, i); |
| 319 | return 0; |
| 320 | } |
| 321 | } |
| 322 | return -ENODEV; |
| 323 | } |
| 324 | |
| 325 | /* update dapm codec register bits */ |
| 326 | static int dapm_update_bits(struct snd_soc_dapm_widget *widget) |
| 327 | { |
| 328 | int change, power; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 329 | unsigned int old, new; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 330 | struct snd_soc_codec *codec = widget->codec; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 331 | struct snd_soc_dapm_context *dapm = widget->dapm; |
Jarkko Nikula | 3a45b86 | 2010-11-05 20:35:21 +0200 | [diff] [blame] | 332 | struct snd_soc_card *card = dapm->card; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 333 | |
| 334 | /* check for valid widgets */ |
| 335 | if (widget->reg < 0 || widget->id == snd_soc_dapm_input || |
| 336 | widget->id == snd_soc_dapm_output || |
| 337 | widget->id == snd_soc_dapm_hp || |
| 338 | widget->id == snd_soc_dapm_mic || |
| 339 | widget->id == snd_soc_dapm_line || |
| 340 | widget->id == snd_soc_dapm_spk) |
| 341 | return 0; |
| 342 | |
| 343 | power = widget->power; |
| 344 | if (widget->invert) |
| 345 | power = (power ? 0:1); |
| 346 | |
| 347 | old = snd_soc_read(codec, widget->reg); |
| 348 | new = (old & ~(0x1 << widget->shift)) | (power << widget->shift); |
| 349 | |
| 350 | change = old != new; |
| 351 | if (change) { |
Jarkko Nikula | fd8d3bc | 2010-11-09 14:40:28 +0200 | [diff] [blame] | 352 | pop_dbg(dapm->dev, card->pop_time, |
| 353 | "pop test %s : %s in %d ms\n", |
Troy Kisky | 12ef193 | 2008-10-13 17:42:14 -0700 | [diff] [blame] | 354 | widget->name, widget->power ? "on" : "off", |
Jarkko Nikula | 3a45b86 | 2010-11-05 20:35:21 +0200 | [diff] [blame] | 355 | card->pop_time); |
| 356 | pop_wait(card->pop_time); |
Mark Brown | 6922471 | 2010-03-03 14:57:09 +0000 | [diff] [blame] | 357 | snd_soc_write(codec, widget->reg, new); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 358 | } |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 359 | dev_dbg(dapm->dev, "reg %x old %x new %x change %d\n", widget->reg, |
| 360 | old, new, change); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 361 | return change; |
| 362 | } |
| 363 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 364 | /* create new dapm mixer control */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 365 | static int dapm_new_mixer(struct snd_soc_dapm_context *dapm, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 366 | struct snd_soc_dapm_widget *w) |
| 367 | { |
| 368 | int i, ret = 0; |
Mark Brown | 219b93f | 2008-10-28 13:02:31 +0000 | [diff] [blame] | 369 | size_t name_len; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 370 | struct snd_soc_dapm_path *path; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 371 | struct snd_card *card = dapm->codec->card->snd_card; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 372 | |
| 373 | /* add kcontrol */ |
| 374 | for (i = 0; i < w->num_kcontrols; i++) { |
| 375 | |
| 376 | /* match name */ |
| 377 | list_for_each_entry(path, &w->sources, list_sink) { |
| 378 | |
| 379 | /* mixer/mux paths name must match control name */ |
| 380 | if (path->name != (char*)w->kcontrols[i].name) |
| 381 | continue; |
| 382 | |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 383 | /* add dapm control with long name. |
| 384 | * for dapm_mixer this is the concatenation of the |
| 385 | * mixer and kcontrol name. |
| 386 | * for dapm_mixer_named_ctl this is simply the |
| 387 | * kcontrol name. |
| 388 | */ |
| 389 | name_len = strlen(w->kcontrols[i].name) + 1; |
Mark Brown | 07495f3 | 2009-03-05 17:06:23 +0000 | [diff] [blame] | 390 | if (w->id != snd_soc_dapm_mixer_named_ctl) |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 391 | name_len += 1 + strlen(w->name); |
| 392 | |
Mark Brown | 219b93f | 2008-10-28 13:02:31 +0000 | [diff] [blame] | 393 | path->long_name = kmalloc(name_len, GFP_KERNEL); |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 394 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 395 | if (path->long_name == NULL) |
| 396 | return -ENOMEM; |
| 397 | |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 398 | switch (w->id) { |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 399 | default: |
| 400 | snprintf(path->long_name, name_len, "%s %s", |
| 401 | w->name, w->kcontrols[i].name); |
Mark Brown | 07495f3 | 2009-03-05 17:06:23 +0000 | [diff] [blame] | 402 | break; |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 403 | case snd_soc_dapm_mixer_named_ctl: |
| 404 | snprintf(path->long_name, name_len, "%s", |
| 405 | w->kcontrols[i].name); |
Mark Brown | 07495f3 | 2009-03-05 17:06:23 +0000 | [diff] [blame] | 406 | break; |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Mark Brown | 219b93f | 2008-10-28 13:02:31 +0000 | [diff] [blame] | 409 | path->long_name[name_len - 1] = '\0'; |
| 410 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 411 | path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w, |
| 412 | path->long_name); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 413 | ret = snd_ctl_add(card, path->kcontrol); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 414 | if (ret < 0) { |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 415 | dev_err(dapm->dev, |
| 416 | "asoc: failed to add dapm kcontrol %s: %d\n", |
| 417 | path->long_name, ret); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 418 | kfree(path->long_name); |
| 419 | path->long_name = NULL; |
| 420 | return ret; |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | return ret; |
| 425 | } |
| 426 | |
| 427 | /* create new dapm mux control */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 428 | static int dapm_new_mux(struct snd_soc_dapm_context *dapm, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 429 | struct snd_soc_dapm_widget *w) |
| 430 | { |
| 431 | struct snd_soc_dapm_path *path = NULL; |
| 432 | struct snd_kcontrol *kcontrol; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 433 | struct snd_card *card = dapm->codec->card->snd_card; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 434 | int ret = 0; |
| 435 | |
| 436 | if (!w->num_kcontrols) { |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 437 | dev_err(dapm->dev, "asoc: mux %s has no controls\n", w->name); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 438 | return -EINVAL; |
| 439 | } |
| 440 | |
| 441 | kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 442 | ret = snd_ctl_add(card, kcontrol); |
| 443 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 444 | if (ret < 0) |
| 445 | goto err; |
| 446 | |
| 447 | list_for_each_entry(path, &w->sources, list_sink) |
| 448 | path->kcontrol = kcontrol; |
| 449 | |
| 450 | return ret; |
| 451 | |
| 452 | err: |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 453 | dev_err(dapm->dev, "asoc: failed to add kcontrol %s\n", w->name); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 454 | return ret; |
| 455 | } |
| 456 | |
| 457 | /* create new dapm volume control */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 458 | static int dapm_new_pga(struct snd_soc_dapm_context *dapm, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 459 | struct snd_soc_dapm_widget *w) |
| 460 | { |
Mark Brown | a6c6573 | 2010-03-03 17:45:21 +0000 | [diff] [blame] | 461 | if (w->num_kcontrols) |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 462 | dev_err(w->dapm->dev, |
| 463 | "asoc: PGA controls not supported: '%s'\n", w->name); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 464 | |
Mark Brown | a6c6573 | 2010-03-03 17:45:21 +0000 | [diff] [blame] | 465 | return 0; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | /* reset 'walked' bit for each dapm path */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 469 | static inline void dapm_clear_walk(struct snd_soc_dapm_context *dapm) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 470 | { |
| 471 | struct snd_soc_dapm_path *p; |
| 472 | |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 473 | list_for_each_entry(p, &dapm->card->paths, list) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 474 | p->walked = 0; |
| 475 | } |
| 476 | |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 477 | /* We implement power down on suspend by checking the power state of |
| 478 | * the ALSA card - when we are suspending the ALSA state for the card |
| 479 | * is set to D3. |
| 480 | */ |
| 481 | static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget) |
| 482 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 483 | int level = snd_power_get_state(widget->dapm->codec->card->snd_card); |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 484 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 485 | switch (level) { |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 486 | case SNDRV_CTL_POWER_D3hot: |
| 487 | case SNDRV_CTL_POWER_D3cold: |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 488 | if (widget->ignore_suspend) |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 489 | dev_dbg(widget->dapm->dev, "%s ignoring suspend\n", |
| 490 | widget->name); |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 491 | return widget->ignore_suspend; |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 492 | default: |
| 493 | return 1; |
| 494 | } |
| 495 | } |
| 496 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 497 | /* |
| 498 | * Recursively check for a completed path to an active or physically connected |
| 499 | * output widget. Returns number of complete paths. |
| 500 | */ |
| 501 | static int is_connected_output_ep(struct snd_soc_dapm_widget *widget) |
| 502 | { |
| 503 | struct snd_soc_dapm_path *path; |
| 504 | int con = 0; |
| 505 | |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 506 | if (widget->id == snd_soc_dapm_supply) |
| 507 | return 0; |
| 508 | |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 509 | switch (widget->id) { |
| 510 | case snd_soc_dapm_adc: |
| 511 | case snd_soc_dapm_aif_out: |
| 512 | if (widget->active) |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 513 | return snd_soc_dapm_suspend_check(widget); |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 514 | default: |
| 515 | break; |
| 516 | } |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 517 | |
| 518 | if (widget->connected) { |
| 519 | /* connected pin ? */ |
| 520 | if (widget->id == snd_soc_dapm_output && !widget->ext) |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 521 | return snd_soc_dapm_suspend_check(widget); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 522 | |
| 523 | /* connected jack or spk ? */ |
| 524 | if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk || |
Peter Ujfalusi | eaeae5d | 2009-09-30 09:27:24 +0300 | [diff] [blame] | 525 | (widget->id == snd_soc_dapm_line && !list_empty(&widget->sources))) |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 526 | return snd_soc_dapm_suspend_check(widget); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | list_for_each_entry(path, &widget->sinks, list_source) { |
| 530 | if (path->walked) |
| 531 | continue; |
| 532 | |
| 533 | if (path->sink && path->connect) { |
| 534 | path->walked = 1; |
| 535 | con += is_connected_output_ep(path->sink); |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | return con; |
| 540 | } |
| 541 | |
| 542 | /* |
| 543 | * Recursively check for a completed path to an active or physically connected |
| 544 | * input widget. Returns number of complete paths. |
| 545 | */ |
| 546 | static int is_connected_input_ep(struct snd_soc_dapm_widget *widget) |
| 547 | { |
| 548 | struct snd_soc_dapm_path *path; |
| 549 | int con = 0; |
| 550 | |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 551 | if (widget->id == snd_soc_dapm_supply) |
| 552 | return 0; |
| 553 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 554 | /* active stream ? */ |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 555 | switch (widget->id) { |
| 556 | case snd_soc_dapm_dac: |
| 557 | case snd_soc_dapm_aif_in: |
| 558 | if (widget->active) |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 559 | return snd_soc_dapm_suspend_check(widget); |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 560 | default: |
| 561 | break; |
| 562 | } |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 563 | |
| 564 | if (widget->connected) { |
| 565 | /* connected pin ? */ |
| 566 | if (widget->id == snd_soc_dapm_input && !widget->ext) |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 567 | return snd_soc_dapm_suspend_check(widget); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 568 | |
| 569 | /* connected VMID/Bias for lower pops */ |
| 570 | if (widget->id == snd_soc_dapm_vmid) |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 571 | return snd_soc_dapm_suspend_check(widget); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 572 | |
| 573 | /* connected jack ? */ |
Peter Ujfalusi | eaeae5d | 2009-09-30 09:27:24 +0300 | [diff] [blame] | 574 | if (widget->id == snd_soc_dapm_mic || |
| 575 | (widget->id == snd_soc_dapm_line && !list_empty(&widget->sinks))) |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 576 | return snd_soc_dapm_suspend_check(widget); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | list_for_each_entry(path, &widget->sources, list_sink) { |
| 580 | if (path->walked) |
| 581 | continue; |
| 582 | |
| 583 | if (path->source && path->connect) { |
| 584 | path->walked = 1; |
| 585 | con += is_connected_input_ep(path->source); |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | return con; |
| 590 | } |
| 591 | |
| 592 | /* |
Jarkko Nikula | e2be2cc | 2008-06-25 14:42:07 +0300 | [diff] [blame] | 593 | * Handler for generic register modifier widget. |
| 594 | */ |
| 595 | int dapm_reg_event(struct snd_soc_dapm_widget *w, |
| 596 | struct snd_kcontrol *kcontrol, int event) |
| 597 | { |
| 598 | unsigned int val; |
| 599 | |
| 600 | if (SND_SOC_DAPM_EVENT_ON(event)) |
| 601 | val = w->on_val; |
| 602 | else |
| 603 | val = w->off_val; |
| 604 | |
| 605 | snd_soc_update_bits(w->codec, -(w->reg + 1), |
| 606 | w->mask << w->shift, val << w->shift); |
| 607 | |
| 608 | return 0; |
| 609 | } |
Mark Brown | 1158941 | 2008-07-29 11:42:23 +0100 | [diff] [blame] | 610 | EXPORT_SYMBOL_GPL(dapm_reg_event); |
Jarkko Nikula | e2be2cc | 2008-06-25 14:42:07 +0300 | [diff] [blame] | 611 | |
Mark Brown | 025756ec | 2009-04-13 11:09:18 +0100 | [diff] [blame] | 612 | /* Standard power change method, used to apply power changes to most |
| 613 | * widgets. |
| 614 | */ |
| 615 | static int dapm_generic_apply_power(struct snd_soc_dapm_widget *w) |
| 616 | { |
| 617 | int ret; |
| 618 | |
| 619 | /* call any power change event handlers */ |
| 620 | if (w->event) |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 621 | dev_dbg(w->dapm->dev, "power %s event for %s flags %x\n", |
Mark Brown | 025756ec | 2009-04-13 11:09:18 +0100 | [diff] [blame] | 622 | w->power ? "on" : "off", |
| 623 | w->name, w->event_flags); |
| 624 | |
| 625 | /* power up pre event */ |
| 626 | if (w->power && w->event && |
| 627 | (w->event_flags & SND_SOC_DAPM_PRE_PMU)) { |
| 628 | ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU); |
| 629 | if (ret < 0) |
| 630 | return ret; |
| 631 | } |
| 632 | |
| 633 | /* power down pre event */ |
| 634 | if (!w->power && w->event && |
| 635 | (w->event_flags & SND_SOC_DAPM_PRE_PMD)) { |
| 636 | ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD); |
| 637 | if (ret < 0) |
| 638 | return ret; |
| 639 | } |
| 640 | |
Mark Brown | 025756ec | 2009-04-13 11:09:18 +0100 | [diff] [blame] | 641 | dapm_update_bits(w); |
| 642 | |
Mark Brown | 025756ec | 2009-04-13 11:09:18 +0100 | [diff] [blame] | 643 | /* power up post event */ |
| 644 | if (w->power && w->event && |
| 645 | (w->event_flags & SND_SOC_DAPM_POST_PMU)) { |
| 646 | ret = w->event(w, |
| 647 | NULL, SND_SOC_DAPM_POST_PMU); |
| 648 | if (ret < 0) |
| 649 | return ret; |
| 650 | } |
| 651 | |
| 652 | /* power down post event */ |
| 653 | if (!w->power && w->event && |
| 654 | (w->event_flags & SND_SOC_DAPM_POST_PMD)) { |
| 655 | ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD); |
| 656 | if (ret < 0) |
| 657 | return ret; |
| 658 | } |
| 659 | |
| 660 | return 0; |
| 661 | } |
| 662 | |
Mark Brown | cd0f2d4 | 2009-04-20 16:56:59 +0100 | [diff] [blame] | 663 | /* Generic check to see if a widget should be powered. |
| 664 | */ |
| 665 | static int dapm_generic_check_power(struct snd_soc_dapm_widget *w) |
| 666 | { |
| 667 | int in, out; |
| 668 | |
| 669 | in = is_connected_input_ep(w); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 670 | dapm_clear_walk(w->dapm); |
Mark Brown | cd0f2d4 | 2009-04-20 16:56:59 +0100 | [diff] [blame] | 671 | out = is_connected_output_ep(w); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 672 | dapm_clear_walk(w->dapm); |
Mark Brown | cd0f2d4 | 2009-04-20 16:56:59 +0100 | [diff] [blame] | 673 | return out != 0 && in != 0; |
| 674 | } |
| 675 | |
Mark Brown | 6ea31b9 | 2009-04-20 17:15:41 +0100 | [diff] [blame] | 676 | /* Check to see if an ADC has power */ |
| 677 | static int dapm_adc_check_power(struct snd_soc_dapm_widget *w) |
| 678 | { |
| 679 | int in; |
| 680 | |
| 681 | if (w->active) { |
| 682 | in = is_connected_input_ep(w); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 683 | dapm_clear_walk(w->dapm); |
Mark Brown | 6ea31b9 | 2009-04-20 17:15:41 +0100 | [diff] [blame] | 684 | return in != 0; |
| 685 | } else { |
| 686 | return dapm_generic_check_power(w); |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | /* Check to see if a DAC has power */ |
| 691 | static int dapm_dac_check_power(struct snd_soc_dapm_widget *w) |
| 692 | { |
| 693 | int out; |
| 694 | |
| 695 | if (w->active) { |
| 696 | out = is_connected_output_ep(w); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 697 | dapm_clear_walk(w->dapm); |
Mark Brown | 6ea31b9 | 2009-04-20 17:15:41 +0100 | [diff] [blame] | 698 | return out != 0; |
| 699 | } else { |
| 700 | return dapm_generic_check_power(w); |
| 701 | } |
| 702 | } |
| 703 | |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 704 | /* Check to see if a power supply is needed */ |
| 705 | static int dapm_supply_check_power(struct snd_soc_dapm_widget *w) |
| 706 | { |
| 707 | struct snd_soc_dapm_path *path; |
| 708 | int power = 0; |
| 709 | |
| 710 | /* Check if one of our outputs is connected */ |
| 711 | list_for_each_entry(path, &w->sinks, list_source) { |
Mark Brown | 215edda | 2009-09-08 18:59:05 +0100 | [diff] [blame] | 712 | if (path->connected && |
| 713 | !path->connected(path->source, path->sink)) |
| 714 | continue; |
| 715 | |
Mark Brown | 3017358 | 2011-02-11 11:42:19 +0000 | [diff] [blame] | 716 | if (!path->sink) |
| 717 | continue; |
| 718 | |
| 719 | if (path->sink->force) { |
| 720 | power = 1; |
| 721 | break; |
| 722 | } |
| 723 | |
| 724 | if (path->sink->power_check && |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 725 | path->sink->power_check(path->sink)) { |
| 726 | power = 1; |
| 727 | break; |
| 728 | } |
| 729 | } |
| 730 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 731 | dapm_clear_walk(w->dapm); |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 732 | |
| 733 | return power; |
| 734 | } |
| 735 | |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 736 | static int dapm_seq_compare(struct snd_soc_dapm_widget *a, |
| 737 | struct snd_soc_dapm_widget *b, |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 738 | bool power_up) |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 739 | { |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 740 | int *sort; |
| 741 | |
| 742 | if (power_up) |
| 743 | sort = dapm_up_seq; |
| 744 | else |
| 745 | sort = dapm_down_seq; |
| 746 | |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 747 | if (sort[a->id] != sort[b->id]) |
| 748 | return sort[a->id] - sort[b->id]; |
Mark Brown | 20e4859 | 2011-01-15 13:40:50 +0000 | [diff] [blame] | 749 | if (a->subseq != b->subseq) { |
| 750 | if (power_up) |
| 751 | return a->subseq - b->subseq; |
| 752 | else |
| 753 | return b->subseq - a->subseq; |
| 754 | } |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 755 | if (a->reg != b->reg) |
| 756 | return a->reg - b->reg; |
Mark Brown | 84dab56 | 2010-11-12 15:28:42 +0000 | [diff] [blame] | 757 | if (a->dapm != b->dapm) |
| 758 | return (unsigned long)a->dapm - (unsigned long)b->dapm; |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 759 | |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 760 | return 0; |
| 761 | } |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 762 | |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 763 | /* Insert a widget in order into a DAPM power sequence. */ |
| 764 | static void dapm_seq_insert(struct snd_soc_dapm_widget *new_widget, |
| 765 | struct list_head *list, |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 766 | bool power_up) |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 767 | { |
| 768 | struct snd_soc_dapm_widget *w; |
| 769 | |
| 770 | list_for_each_entry(w, list, power_list) |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 771 | if (dapm_seq_compare(new_widget, w, power_up) < 0) { |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 772 | list_add_tail(&new_widget->power_list, &w->power_list); |
| 773 | return; |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 774 | } |
Mark Brown | 6ea31b9 | 2009-04-20 17:15:41 +0100 | [diff] [blame] | 775 | |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 776 | list_add_tail(&new_widget->power_list, list); |
| 777 | } |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 778 | |
Mark Brown | 68f89ad | 2010-11-03 23:51:49 -0400 | [diff] [blame] | 779 | static void dapm_seq_check_event(struct snd_soc_dapm_context *dapm, |
| 780 | struct snd_soc_dapm_widget *w, int event) |
| 781 | { |
| 782 | struct snd_soc_card *card = dapm->card; |
| 783 | const char *ev_name; |
| 784 | int power, ret; |
| 785 | |
| 786 | switch (event) { |
| 787 | case SND_SOC_DAPM_PRE_PMU: |
| 788 | ev_name = "PRE_PMU"; |
| 789 | power = 1; |
| 790 | break; |
| 791 | case SND_SOC_DAPM_POST_PMU: |
| 792 | ev_name = "POST_PMU"; |
| 793 | power = 1; |
| 794 | break; |
| 795 | case SND_SOC_DAPM_PRE_PMD: |
| 796 | ev_name = "PRE_PMD"; |
| 797 | power = 0; |
| 798 | break; |
| 799 | case SND_SOC_DAPM_POST_PMD: |
| 800 | ev_name = "POST_PMD"; |
| 801 | power = 0; |
| 802 | break; |
| 803 | default: |
| 804 | BUG(); |
| 805 | return; |
| 806 | } |
| 807 | |
| 808 | if (w->power != power) |
| 809 | return; |
| 810 | |
| 811 | if (w->event && (w->event_flags & event)) { |
| 812 | pop_dbg(dapm->dev, card->pop_time, "pop test : %s %s\n", |
| 813 | w->name, ev_name); |
Mark Brown | 84e9093 | 2010-11-04 00:07:02 -0400 | [diff] [blame] | 814 | trace_snd_soc_dapm_widget_event_start(w, event); |
Mark Brown | 68f89ad | 2010-11-03 23:51:49 -0400 | [diff] [blame] | 815 | ret = w->event(w, NULL, event); |
Mark Brown | 84e9093 | 2010-11-04 00:07:02 -0400 | [diff] [blame] | 816 | trace_snd_soc_dapm_widget_event_done(w, event); |
Mark Brown | 68f89ad | 2010-11-03 23:51:49 -0400 | [diff] [blame] | 817 | if (ret < 0) |
| 818 | pr_err("%s: %s event failed: %d\n", |
| 819 | ev_name, w->name, ret); |
| 820 | } |
| 821 | } |
| 822 | |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 823 | /* Apply the coalesced changes from a DAPM sequence */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 824 | static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm, |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 825 | struct list_head *pending) |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 826 | { |
Jarkko Nikula | 3a45b86 | 2010-11-05 20:35:21 +0200 | [diff] [blame] | 827 | struct snd_soc_card *card = dapm->card; |
Mark Brown | 68f89ad | 2010-11-03 23:51:49 -0400 | [diff] [blame] | 828 | struct snd_soc_dapm_widget *w; |
| 829 | int reg, power; |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 830 | unsigned int value = 0; |
| 831 | unsigned int mask = 0; |
| 832 | unsigned int cur_mask; |
| 833 | |
| 834 | reg = list_first_entry(pending, struct snd_soc_dapm_widget, |
| 835 | power_list)->reg; |
| 836 | |
| 837 | list_for_each_entry(w, pending, power_list) { |
| 838 | cur_mask = 1 << w->shift; |
| 839 | BUG_ON(reg != w->reg); |
| 840 | |
| 841 | if (w->invert) |
| 842 | power = !w->power; |
| 843 | else |
| 844 | power = w->power; |
| 845 | |
| 846 | mask |= cur_mask; |
| 847 | if (power) |
| 848 | value |= cur_mask; |
| 849 | |
Jarkko Nikula | fd8d3bc | 2010-11-09 14:40:28 +0200 | [diff] [blame] | 850 | pop_dbg(dapm->dev, card->pop_time, |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 851 | "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n", |
| 852 | w->name, reg, value, mask); |
Mark Brown | 8162810 | 2009-06-07 13:21:24 +0100 | [diff] [blame] | 853 | |
Mark Brown | 68f89ad | 2010-11-03 23:51:49 -0400 | [diff] [blame] | 854 | /* Check for events */ |
| 855 | dapm_seq_check_event(dapm, w, SND_SOC_DAPM_PRE_PMU); |
| 856 | dapm_seq_check_event(dapm, w, SND_SOC_DAPM_PRE_PMD); |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 857 | } |
| 858 | |
Mark Brown | 8162810 | 2009-06-07 13:21:24 +0100 | [diff] [blame] | 859 | if (reg >= 0) { |
Jarkko Nikula | fd8d3bc | 2010-11-09 14:40:28 +0200 | [diff] [blame] | 860 | pop_dbg(dapm->dev, card->pop_time, |
Mark Brown | 8162810 | 2009-06-07 13:21:24 +0100 | [diff] [blame] | 861 | "pop test : Applying 0x%x/0x%x to %x in %dms\n", |
Jarkko Nikula | 3a45b86 | 2010-11-05 20:35:21 +0200 | [diff] [blame] | 862 | value, mask, reg, card->pop_time); |
| 863 | pop_wait(card->pop_time); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 864 | snd_soc_update_bits(dapm->codec, reg, mask, value); |
Mark Brown | 8162810 | 2009-06-07 13:21:24 +0100 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | list_for_each_entry(w, pending, power_list) { |
Mark Brown | 68f89ad | 2010-11-03 23:51:49 -0400 | [diff] [blame] | 868 | dapm_seq_check_event(dapm, w, SND_SOC_DAPM_POST_PMU); |
| 869 | dapm_seq_check_event(dapm, w, SND_SOC_DAPM_POST_PMD); |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 870 | } |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 871 | } |
| 872 | |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 873 | /* Apply a DAPM power sequence. |
| 874 | * |
| 875 | * We walk over a pre-sorted list of widgets to apply power to. In |
| 876 | * order to minimise the number of writes to the device required |
| 877 | * multiple widgets will be updated in a single write where possible. |
| 878 | * Currently anything that requires more than a single write is not |
| 879 | * handled. |
| 880 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 881 | static void dapm_seq_run(struct snd_soc_dapm_context *dapm, |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 882 | struct list_head *list, int event, bool power_up) |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 883 | { |
| 884 | struct snd_soc_dapm_widget *w, *n; |
| 885 | LIST_HEAD(pending); |
| 886 | int cur_sort = -1; |
Mark Brown | 20e4859 | 2011-01-15 13:40:50 +0000 | [diff] [blame] | 887 | int cur_subseq = -1; |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 888 | int cur_reg = SND_SOC_NOPM; |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 889 | struct snd_soc_dapm_context *cur_dapm = NULL; |
Mark Brown | 474b62d | 2011-01-18 16:14:44 +0000 | [diff] [blame] | 890 | int ret, i; |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 891 | int *sort; |
| 892 | |
| 893 | if (power_up) |
| 894 | sort = dapm_up_seq; |
| 895 | else |
| 896 | sort = dapm_down_seq; |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 897 | |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 898 | list_for_each_entry_safe(w, n, list, power_list) { |
| 899 | ret = 0; |
| 900 | |
| 901 | /* Do we need to apply any queued changes? */ |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 902 | if (sort[w->id] != cur_sort || w->reg != cur_reg || |
Mark Brown | 20e4859 | 2011-01-15 13:40:50 +0000 | [diff] [blame] | 903 | w->dapm != cur_dapm || w->subseq != cur_subseq) { |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 904 | if (!list_empty(&pending)) |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 905 | dapm_seq_run_coalesced(cur_dapm, &pending); |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 906 | |
Mark Brown | 474b62d | 2011-01-18 16:14:44 +0000 | [diff] [blame] | 907 | if (cur_dapm && cur_dapm->seq_notifier) { |
| 908 | for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++) |
| 909 | if (sort[i] == cur_sort) |
| 910 | cur_dapm->seq_notifier(cur_dapm, |
Mark Brown | f85a9e0 | 2011-01-26 21:41:28 +0000 | [diff] [blame] | 911 | i, |
| 912 | cur_subseq); |
Mark Brown | 474b62d | 2011-01-18 16:14:44 +0000 | [diff] [blame] | 913 | } |
| 914 | |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 915 | INIT_LIST_HEAD(&pending); |
| 916 | cur_sort = -1; |
Mark Brown | 20e4859 | 2011-01-15 13:40:50 +0000 | [diff] [blame] | 917 | cur_subseq = -1; |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 918 | cur_reg = SND_SOC_NOPM; |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 919 | cur_dapm = NULL; |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 920 | } |
| 921 | |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 922 | switch (w->id) { |
| 923 | case snd_soc_dapm_pre: |
| 924 | if (!w->event) |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 925 | list_for_each_entry_safe_continue(w, n, list, |
| 926 | power_list); |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 927 | |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 928 | if (event == SND_SOC_DAPM_STREAM_START) |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 929 | ret = w->event(w, |
| 930 | NULL, SND_SOC_DAPM_PRE_PMU); |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 931 | else if (event == SND_SOC_DAPM_STREAM_STOP) |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 932 | ret = w->event(w, |
| 933 | NULL, SND_SOC_DAPM_PRE_PMD); |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 934 | break; |
| 935 | |
| 936 | case snd_soc_dapm_post: |
| 937 | if (!w->event) |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 938 | list_for_each_entry_safe_continue(w, n, list, |
| 939 | power_list); |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 940 | |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 941 | if (event == SND_SOC_DAPM_STREAM_START) |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 942 | ret = w->event(w, |
| 943 | NULL, SND_SOC_DAPM_POST_PMU); |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 944 | else if (event == SND_SOC_DAPM_STREAM_STOP) |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 945 | ret = w->event(w, |
| 946 | NULL, SND_SOC_DAPM_POST_PMD); |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 947 | break; |
| 948 | |
| 949 | case snd_soc_dapm_input: |
| 950 | case snd_soc_dapm_output: |
| 951 | case snd_soc_dapm_hp: |
| 952 | case snd_soc_dapm_mic: |
| 953 | case snd_soc_dapm_line: |
| 954 | case snd_soc_dapm_spk: |
| 955 | /* No register support currently */ |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 956 | ret = dapm_generic_apply_power(w); |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 957 | break; |
| 958 | |
| 959 | default: |
Mark Brown | 8162810 | 2009-06-07 13:21:24 +0100 | [diff] [blame] | 960 | /* Queue it up for application */ |
| 961 | cur_sort = sort[w->id]; |
Mark Brown | 20e4859 | 2011-01-15 13:40:50 +0000 | [diff] [blame] | 962 | cur_subseq = w->subseq; |
Mark Brown | 8162810 | 2009-06-07 13:21:24 +0100 | [diff] [blame] | 963 | cur_reg = w->reg; |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 964 | cur_dapm = w->dapm; |
Mark Brown | 8162810 | 2009-06-07 13:21:24 +0100 | [diff] [blame] | 965 | list_move(&w->power_list, &pending); |
| 966 | break; |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 967 | } |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 968 | |
| 969 | if (ret < 0) |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 970 | dev_err(w->dapm->dev, |
| 971 | "Failed to apply widget power: %d\n", ret); |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 972 | } |
Mark Brown | b22ead2 | 2009-06-07 12:51:26 +0100 | [diff] [blame] | 973 | |
| 974 | if (!list_empty(&pending)) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 975 | dapm_seq_run_coalesced(dapm, &pending); |
Mark Brown | 474b62d | 2011-01-18 16:14:44 +0000 | [diff] [blame] | 976 | |
| 977 | if (cur_dapm && cur_dapm->seq_notifier) { |
| 978 | for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++) |
| 979 | if (sort[i] == cur_sort) |
| 980 | cur_dapm->seq_notifier(cur_dapm, |
Mark Brown | f85a9e0 | 2011-01-26 21:41:28 +0000 | [diff] [blame] | 981 | i, cur_subseq); |
Mark Brown | 474b62d | 2011-01-18 16:14:44 +0000 | [diff] [blame] | 982 | } |
Mark Brown | 163cac0 | 2009-06-07 10:12:52 +0100 | [diff] [blame] | 983 | } |
| 984 | |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 985 | static void dapm_widget_update(struct snd_soc_dapm_context *dapm) |
| 986 | { |
| 987 | struct snd_soc_dapm_update *update = dapm->update; |
| 988 | struct snd_soc_dapm_widget *w; |
| 989 | int ret; |
| 990 | |
| 991 | if (!update) |
| 992 | return; |
| 993 | |
| 994 | w = update->widget; |
| 995 | |
| 996 | if (w->event && |
| 997 | (w->event_flags & SND_SOC_DAPM_PRE_REG)) { |
| 998 | ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG); |
| 999 | if (ret != 0) |
| 1000 | pr_err("%s DAPM pre-event failed: %d\n", |
| 1001 | w->name, ret); |
| 1002 | } |
| 1003 | |
| 1004 | ret = snd_soc_update_bits(w->codec, update->reg, update->mask, |
| 1005 | update->val); |
| 1006 | if (ret < 0) |
| 1007 | pr_err("%s DAPM update failed: %d\n", w->name, ret); |
| 1008 | |
| 1009 | if (w->event && |
| 1010 | (w->event_flags & SND_SOC_DAPM_POST_REG)) { |
| 1011 | ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG); |
| 1012 | if (ret != 0) |
| 1013 | pr_err("%s DAPM post-event failed: %d\n", |
| 1014 | w->name, ret); |
| 1015 | } |
| 1016 | } |
| 1017 | |
Mark Brown | 9d0624a | 2011-02-18 11:49:43 -0800 | [diff] [blame^] | 1018 | /* Async callback run prior to DAPM sequences - brings to _PREPARE if |
| 1019 | * they're changing state. |
| 1020 | */ |
| 1021 | static void dapm_pre_sequence_async(void *data, async_cookie_t cookie) |
| 1022 | { |
| 1023 | struct snd_soc_dapm_context *d = data; |
| 1024 | int ret; |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1025 | |
Mark Brown | 9d0624a | 2011-02-18 11:49:43 -0800 | [diff] [blame^] | 1026 | if (d->dev_power && d->bias_level == SND_SOC_BIAS_OFF) { |
| 1027 | ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY); |
| 1028 | if (ret != 0) |
| 1029 | dev_err(d->dev, |
| 1030 | "Failed to turn on bias: %d\n", ret); |
| 1031 | } |
| 1032 | |
| 1033 | /* If we're changing to all on or all off then prepare */ |
| 1034 | if ((d->dev_power && d->bias_level == SND_SOC_BIAS_STANDBY) || |
| 1035 | (!d->dev_power && d->bias_level == SND_SOC_BIAS_ON)) { |
| 1036 | ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_PREPARE); |
| 1037 | if (ret != 0) |
| 1038 | dev_err(d->dev, |
| 1039 | "Failed to prepare bias: %d\n", ret); |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | /* Async callback run prior to DAPM sequences - brings to their final |
| 1044 | * state. |
| 1045 | */ |
| 1046 | static void dapm_post_sequence_async(void *data, async_cookie_t cookie) |
| 1047 | { |
| 1048 | struct snd_soc_dapm_context *d = data; |
| 1049 | int ret; |
| 1050 | |
| 1051 | /* If we just powered the last thing off drop to standby bias */ |
| 1052 | if (d->bias_level == SND_SOC_BIAS_PREPARE && !d->dev_power) { |
| 1053 | ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY); |
| 1054 | if (ret != 0) |
| 1055 | dev_err(d->dev, "Failed to apply standby bias: %d\n", |
| 1056 | ret); |
| 1057 | } |
| 1058 | |
| 1059 | /* If we're in standby and can support bias off then do that */ |
| 1060 | if (d->bias_level == SND_SOC_BIAS_STANDBY && d->idle_bias_off) { |
| 1061 | ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_OFF); |
| 1062 | if (ret != 0) |
| 1063 | dev_err(d->dev, "Failed to turn off bias: %d\n", ret); |
| 1064 | } |
| 1065 | |
| 1066 | /* If we just powered up then move to active bias */ |
| 1067 | if (d->bias_level == SND_SOC_BIAS_PREPARE && d->dev_power) { |
| 1068 | ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_ON); |
| 1069 | if (ret != 0) |
| 1070 | dev_err(d->dev, "Failed to apply active bias: %d\n", |
| 1071 | ret); |
| 1072 | } |
| 1073 | } |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1074 | |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 1075 | /* |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1076 | * Scan each dapm widget for complete audio path. |
| 1077 | * A complete path is a route that has valid endpoints i.e.:- |
| 1078 | * |
| 1079 | * o DAC to output pin. |
| 1080 | * o Input Pin to ADC. |
| 1081 | * o Input pin to Output pin (bypass, sidetone) |
| 1082 | * o DAC to ADC (loopback). |
| 1083 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1084 | static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1085 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1086 | struct snd_soc_card *card = dapm->codec->card; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1087 | struct snd_soc_dapm_widget *w; |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 1088 | struct snd_soc_dapm_context *d; |
Mark Brown | 291f3bb | 2009-06-07 13:57:17 +0100 | [diff] [blame] | 1089 | LIST_HEAD(up_list); |
| 1090 | LIST_HEAD(down_list); |
Mark Brown | 9d0624a | 2011-02-18 11:49:43 -0800 | [diff] [blame^] | 1091 | LIST_HEAD(async_domain); |
Mark Brown | 38357ab | 2009-06-06 19:03:23 +0100 | [diff] [blame] | 1092 | int power; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1093 | |
Mark Brown | 84e9093 | 2010-11-04 00:07:02 -0400 | [diff] [blame] | 1094 | trace_snd_soc_dapm_start(card); |
| 1095 | |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 1096 | list_for_each_entry(d, &card->dapm_list, list) |
| 1097 | if (d->n_widgets) |
| 1098 | d->dev_power = 0; |
| 1099 | |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1100 | /* Check which widgets we need to power and store them in |
| 1101 | * lists indicating if they should be powered up or down. |
| 1102 | */ |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1103 | list_for_each_entry(w, &card->widgets, list) { |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1104 | switch (w->id) { |
| 1105 | case snd_soc_dapm_pre: |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 1106 | dapm_seq_insert(w, &down_list, false); |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1107 | break; |
| 1108 | case snd_soc_dapm_post: |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 1109 | dapm_seq_insert(w, &up_list, true); |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1110 | break; |
| 1111 | |
| 1112 | default: |
| 1113 | if (!w->power_check) |
| 1114 | continue; |
| 1115 | |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 1116 | if (!w->force) |
Mark Brown | 50b6bce | 2009-11-23 13:11:53 +0000 | [diff] [blame] | 1117 | power = w->power_check(w); |
Mark Brown | 9949788b | 2010-05-07 20:24:05 +0100 | [diff] [blame] | 1118 | else |
| 1119 | power = 1; |
| 1120 | if (power) |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 1121 | w->dapm->dev_power = 1; |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 1122 | |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1123 | if (w->power == power) |
| 1124 | continue; |
| 1125 | |
Mark Brown | 84e9093 | 2010-11-04 00:07:02 -0400 | [diff] [blame] | 1126 | trace_snd_soc_dapm_widget_power(w, power); |
| 1127 | |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1128 | if (power) |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 1129 | dapm_seq_insert(w, &up_list, true); |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1130 | else |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 1131 | dapm_seq_insert(w, &down_list, false); |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1132 | |
| 1133 | w->power = power; |
| 1134 | break; |
| 1135 | } |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1136 | } |
| 1137 | |
Mark Brown | b14b76a5 | 2009-08-17 11:55:38 +0100 | [diff] [blame] | 1138 | /* If there are no DAPM widgets then try to figure out power from the |
| 1139 | * event type. |
| 1140 | */ |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1141 | if (!dapm->n_widgets) { |
Mark Brown | b14b76a5 | 2009-08-17 11:55:38 +0100 | [diff] [blame] | 1142 | switch (event) { |
| 1143 | case SND_SOC_DAPM_STREAM_START: |
| 1144 | case SND_SOC_DAPM_STREAM_RESUME: |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 1145 | dapm->dev_power = 1; |
Mark Brown | b14b76a5 | 2009-08-17 11:55:38 +0100 | [diff] [blame] | 1146 | break; |
Jarkko Nikula | 862af8a | 2010-12-10 20:53:55 +0200 | [diff] [blame] | 1147 | case SND_SOC_DAPM_STREAM_STOP: |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 1148 | dapm->dev_power = !!dapm->codec->active; |
Jarkko Nikula | 862af8a | 2010-12-10 20:53:55 +0200 | [diff] [blame] | 1149 | break; |
Mark Brown | 50b6bce | 2009-11-23 13:11:53 +0000 | [diff] [blame] | 1150 | case SND_SOC_DAPM_STREAM_SUSPEND: |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 1151 | dapm->dev_power = 0; |
Mark Brown | 50b6bce | 2009-11-23 13:11:53 +0000 | [diff] [blame] | 1152 | break; |
Mark Brown | b14b76a5 | 2009-08-17 11:55:38 +0100 | [diff] [blame] | 1153 | case SND_SOC_DAPM_STREAM_NOP: |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1154 | switch (dapm->bias_level) { |
Mark Brown | a96ca33 | 2010-01-19 22:49:43 +0000 | [diff] [blame] | 1155 | case SND_SOC_BIAS_STANDBY: |
| 1156 | case SND_SOC_BIAS_OFF: |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 1157 | dapm->dev_power = 0; |
Mark Brown | a96ca33 | 2010-01-19 22:49:43 +0000 | [diff] [blame] | 1158 | break; |
| 1159 | default: |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 1160 | dapm->dev_power = 1; |
Mark Brown | a96ca33 | 2010-01-19 22:49:43 +0000 | [diff] [blame] | 1161 | break; |
| 1162 | } |
Mark Brown | 50b6bce | 2009-11-23 13:11:53 +0000 | [diff] [blame] | 1163 | break; |
Mark Brown | b14b76a5 | 2009-08-17 11:55:38 +0100 | [diff] [blame] | 1164 | default: |
| 1165 | break; |
| 1166 | } |
| 1167 | } |
| 1168 | |
Mark Brown | 9d0624a | 2011-02-18 11:49:43 -0800 | [diff] [blame^] | 1169 | /* Run all the bias changes in parallel */ |
| 1170 | list_for_each_entry(d, &dapm->card->dapm_list, list) |
| 1171 | async_schedule_domain(dapm_pre_sequence_async, d, |
| 1172 | &async_domain); |
| 1173 | async_synchronize_full_domain(&async_domain); |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 1174 | |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1175 | /* Power down widgets first; try to avoid amplifying pops. */ |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 1176 | dapm_seq_run(dapm, &down_list, event, false); |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1177 | |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1178 | dapm_widget_update(dapm); |
| 1179 | |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 1180 | /* Now power up. */ |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 1181 | dapm_seq_run(dapm, &up_list, event, true); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1182 | |
Mark Brown | 9d0624a | 2011-02-18 11:49:43 -0800 | [diff] [blame^] | 1183 | /* Run all the bias changes in parallel */ |
| 1184 | list_for_each_entry(d, &dapm->card->dapm_list, list) |
| 1185 | async_schedule_domain(dapm_post_sequence_async, d, |
| 1186 | &async_domain); |
| 1187 | async_synchronize_full_domain(&async_domain); |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 1188 | |
Jarkko Nikula | fd8d3bc | 2010-11-09 14:40:28 +0200 | [diff] [blame] | 1189 | pop_dbg(dapm->dev, card->pop_time, |
| 1190 | "DAPM sequencing finished, waiting %dms\n", card->pop_time); |
Jarkko Nikula | 3a45b86 | 2010-11-05 20:35:21 +0200 | [diff] [blame] | 1191 | pop_wait(card->pop_time); |
Mark Brown | cb507e7 | 2009-07-08 18:54:57 +0100 | [diff] [blame] | 1192 | |
Mark Brown | 84e9093 | 2010-11-04 00:07:02 -0400 | [diff] [blame] | 1193 | trace_snd_soc_dapm_done(card); |
| 1194 | |
Mark Brown | 42aa341 | 2009-03-01 19:21:10 +0000 | [diff] [blame] | 1195 | return 0; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1196 | } |
| 1197 | |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1198 | #ifdef CONFIG_DEBUG_FS |
| 1199 | static int dapm_widget_power_open_file(struct inode *inode, struct file *file) |
| 1200 | { |
| 1201 | file->private_data = inode->i_private; |
| 1202 | return 0; |
| 1203 | } |
| 1204 | |
| 1205 | static ssize_t dapm_widget_power_read_file(struct file *file, |
| 1206 | char __user *user_buf, |
| 1207 | size_t count, loff_t *ppos) |
| 1208 | { |
| 1209 | struct snd_soc_dapm_widget *w = file->private_data; |
| 1210 | char *buf; |
| 1211 | int in, out; |
| 1212 | ssize_t ret; |
| 1213 | struct snd_soc_dapm_path *p = NULL; |
| 1214 | |
| 1215 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 1216 | if (!buf) |
| 1217 | return -ENOMEM; |
| 1218 | |
| 1219 | in = is_connected_input_ep(w); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1220 | dapm_clear_walk(w->dapm); |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1221 | out = is_connected_output_ep(w); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1222 | dapm_clear_walk(w->dapm); |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1223 | |
Mark Brown | d033c36 | 2009-12-04 15:25:56 +0000 | [diff] [blame] | 1224 | ret = snprintf(buf, PAGE_SIZE, "%s: %s in %d out %d", |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1225 | w->name, w->power ? "On" : "Off", in, out); |
| 1226 | |
Mark Brown | d033c36 | 2009-12-04 15:25:56 +0000 | [diff] [blame] | 1227 | if (w->reg >= 0) |
| 1228 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 1229 | " - R%d(0x%x) bit %d", |
| 1230 | w->reg, w->reg, w->shift); |
| 1231 | |
| 1232 | ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n"); |
| 1233 | |
Mark Brown | 3eef08b | 2009-09-14 16:49:00 +0100 | [diff] [blame] | 1234 | if (w->sname) |
| 1235 | ret += snprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n", |
| 1236 | w->sname, |
| 1237 | w->active ? "active" : "inactive"); |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1238 | |
| 1239 | list_for_each_entry(p, &w->sources, list_sink) { |
Mark Brown | 215edda | 2009-09-08 18:59:05 +0100 | [diff] [blame] | 1240 | if (p->connected && !p->connected(w, p->sink)) |
| 1241 | continue; |
| 1242 | |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1243 | if (p->connect) |
| 1244 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 1245 | " in %s %s\n", |
| 1246 | p->name ? p->name : "static", |
| 1247 | p->source->name); |
| 1248 | } |
| 1249 | list_for_each_entry(p, &w->sinks, list_source) { |
Mark Brown | 215edda | 2009-09-08 18:59:05 +0100 | [diff] [blame] | 1250 | if (p->connected && !p->connected(w, p->sink)) |
| 1251 | continue; |
| 1252 | |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1253 | if (p->connect) |
| 1254 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 1255 | " out %s %s\n", |
| 1256 | p->name ? p->name : "static", |
| 1257 | p->sink->name); |
| 1258 | } |
| 1259 | |
| 1260 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); |
| 1261 | |
| 1262 | kfree(buf); |
| 1263 | return ret; |
| 1264 | } |
| 1265 | |
| 1266 | static const struct file_operations dapm_widget_power_fops = { |
| 1267 | .open = dapm_widget_power_open_file, |
| 1268 | .read = dapm_widget_power_read_file, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1269 | .llseek = default_llseek, |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1270 | }; |
| 1271 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1272 | void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm) |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1273 | { |
| 1274 | struct snd_soc_dapm_widget *w; |
| 1275 | struct dentry *d; |
| 1276 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1277 | if (!dapm->debugfs_dapm) |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1278 | return; |
| 1279 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1280 | list_for_each_entry(w, &dapm->card->widgets, list) { |
| 1281 | if (!w->name || w->dapm != dapm) |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1282 | continue; |
| 1283 | |
| 1284 | d = debugfs_create_file(w->name, 0444, |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1285 | dapm->debugfs_dapm, w, |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1286 | &dapm_widget_power_fops); |
| 1287 | if (!d) |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 1288 | dev_warn(w->dapm->dev, |
| 1289 | "ASoC: Failed to create %s debugfs file\n", |
| 1290 | w->name); |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1291 | } |
| 1292 | } |
| 1293 | #else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1294 | void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm) |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 1295 | { |
| 1296 | } |
| 1297 | #endif |
| 1298 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1299 | /* test and update the power status of a mux widget */ |
Adrian Bunk | d9c96cf | 2006-11-28 12:10:09 +0100 | [diff] [blame] | 1300 | static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget, |
Mark Brown | 3a65577 | 2009-10-05 17:23:30 +0100 | [diff] [blame] | 1301 | struct snd_kcontrol *kcontrol, int change, |
| 1302 | int mux, struct soc_enum *e) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1303 | { |
| 1304 | struct snd_soc_dapm_path *path; |
| 1305 | int found = 0; |
| 1306 | |
Peter Ujfalusi | eff317d | 2009-01-15 14:40:47 +0200 | [diff] [blame] | 1307 | if (widget->id != snd_soc_dapm_mux && |
Dimitris Papastamos | 24ff33a | 2010-12-16 15:53:39 +0000 | [diff] [blame] | 1308 | widget->id != snd_soc_dapm_virt_mux && |
Peter Ujfalusi | eff317d | 2009-01-15 14:40:47 +0200 | [diff] [blame] | 1309 | widget->id != snd_soc_dapm_value_mux) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1310 | return -ENODEV; |
| 1311 | |
Mark Brown | 3a65577 | 2009-10-05 17:23:30 +0100 | [diff] [blame] | 1312 | if (!change) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1313 | return 0; |
| 1314 | |
| 1315 | /* find dapm widget path assoc with kcontrol */ |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 1316 | list_for_each_entry(path, &widget->dapm->card->paths, list) { |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1317 | if (path->kcontrol != kcontrol) |
| 1318 | continue; |
| 1319 | |
Richard Zhao | cb01e2b | 2008-10-07 08:05:20 +0800 | [diff] [blame] | 1320 | if (!path->name || !e->texts[mux]) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1321 | continue; |
| 1322 | |
| 1323 | found = 1; |
| 1324 | /* we now need to match the string in the enum to the path */ |
Richard Zhao | cb01e2b | 2008-10-07 08:05:20 +0800 | [diff] [blame] | 1325 | if (!(strcmp(path->name, e->texts[mux]))) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1326 | path->connect = 1; /* new connection */ |
| 1327 | else |
| 1328 | path->connect = 0; /* old connection must be powered down */ |
| 1329 | } |
| 1330 | |
Mark Brown | b91b8fa | 2010-01-20 18:18:35 +0000 | [diff] [blame] | 1331 | if (found) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1332 | dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1333 | |
| 1334 | return 0; |
| 1335 | } |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1336 | |
Milan plzik | 1b075e3 | 2008-01-10 14:39:46 +0100 | [diff] [blame] | 1337 | /* test and update the power status of a mixer or switch widget */ |
Adrian Bunk | d9c96cf | 2006-11-28 12:10:09 +0100 | [diff] [blame] | 1338 | static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, |
Mark Brown | 283375c | 2009-12-07 18:09:03 +0000 | [diff] [blame] | 1339 | struct snd_kcontrol *kcontrol, int connect) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1340 | { |
| 1341 | struct snd_soc_dapm_path *path; |
| 1342 | int found = 0; |
| 1343 | |
Milan plzik | 1b075e3 | 2008-01-10 14:39:46 +0100 | [diff] [blame] | 1344 | if (widget->id != snd_soc_dapm_mixer && |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 1345 | widget->id != snd_soc_dapm_mixer_named_ctl && |
Milan plzik | 1b075e3 | 2008-01-10 14:39:46 +0100 | [diff] [blame] | 1346 | widget->id != snd_soc_dapm_switch) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1347 | return -ENODEV; |
| 1348 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1349 | /* find dapm widget path assoc with kcontrol */ |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 1350 | list_for_each_entry(path, &widget->dapm->card->paths, list) { |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1351 | if (path->kcontrol != kcontrol) |
| 1352 | continue; |
| 1353 | |
| 1354 | /* found, now check type */ |
| 1355 | found = 1; |
Mark Brown | 283375c | 2009-12-07 18:09:03 +0000 | [diff] [blame] | 1356 | path->connect = connect; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1357 | break; |
| 1358 | } |
| 1359 | |
Mark Brown | b91b8fa | 2010-01-20 18:18:35 +0000 | [diff] [blame] | 1360 | if (found) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1361 | dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1362 | |
| 1363 | return 0; |
| 1364 | } |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1365 | |
| 1366 | /* show dapm widget status in sys fs */ |
| 1367 | static ssize_t dapm_widget_show(struct device *dev, |
| 1368 | struct device_attribute *attr, char *buf) |
| 1369 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 1370 | struct snd_soc_pcm_runtime *rtd = |
| 1371 | container_of(dev, struct snd_soc_pcm_runtime, dev); |
| 1372 | struct snd_soc_codec *codec =rtd->codec; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1373 | struct snd_soc_dapm_widget *w; |
| 1374 | int count = 0; |
| 1375 | char *state = "not set"; |
| 1376 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1377 | list_for_each_entry(w, &codec->card->widgets, list) { |
| 1378 | if (w->dapm != &codec->dapm) |
| 1379 | continue; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1380 | |
| 1381 | /* only display widgets that burnm power */ |
| 1382 | switch (w->id) { |
| 1383 | case snd_soc_dapm_hp: |
| 1384 | case snd_soc_dapm_mic: |
| 1385 | case snd_soc_dapm_spk: |
| 1386 | case snd_soc_dapm_line: |
| 1387 | case snd_soc_dapm_micbias: |
| 1388 | case snd_soc_dapm_dac: |
| 1389 | case snd_soc_dapm_adc: |
| 1390 | case snd_soc_dapm_pga: |
Olaya, Margarita | d88429a | 2010-12-10 21:11:44 -0600 | [diff] [blame] | 1391 | case snd_soc_dapm_out_drv: |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1392 | case snd_soc_dapm_mixer: |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 1393 | case snd_soc_dapm_mixer_named_ctl: |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 1394 | case snd_soc_dapm_supply: |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1395 | if (w->name) |
| 1396 | count += sprintf(buf + count, "%s: %s\n", |
| 1397 | w->name, w->power ? "On":"Off"); |
| 1398 | break; |
| 1399 | default: |
| 1400 | break; |
| 1401 | } |
| 1402 | } |
| 1403 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1404 | switch (codec->dapm.bias_level) { |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 1405 | case SND_SOC_BIAS_ON: |
| 1406 | state = "On"; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1407 | break; |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 1408 | case SND_SOC_BIAS_PREPARE: |
| 1409 | state = "Prepare"; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1410 | break; |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 1411 | case SND_SOC_BIAS_STANDBY: |
| 1412 | state = "Standby"; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1413 | break; |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 1414 | case SND_SOC_BIAS_OFF: |
| 1415 | state = "Off"; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1416 | break; |
| 1417 | } |
| 1418 | count += sprintf(buf + count, "PM State: %s\n", state); |
| 1419 | |
| 1420 | return count; |
| 1421 | } |
| 1422 | |
| 1423 | static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); |
| 1424 | |
| 1425 | int snd_soc_dapm_sys_add(struct device *dev) |
| 1426 | { |
Troy Kisky | 12ef193 | 2008-10-13 17:42:14 -0700 | [diff] [blame] | 1427 | return device_create_file(dev, &dev_attr_dapm_widget); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1428 | } |
| 1429 | |
| 1430 | static void snd_soc_dapm_sys_remove(struct device *dev) |
| 1431 | { |
Mark Brown | aef9084 | 2009-05-16 17:53:16 +0100 | [diff] [blame] | 1432 | device_remove_file(dev, &dev_attr_dapm_widget); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | /* free all dapm widgets and resources */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1436 | static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1437 | { |
| 1438 | struct snd_soc_dapm_widget *w, *next_w; |
| 1439 | struct snd_soc_dapm_path *p, *next_p; |
| 1440 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1441 | list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) { |
| 1442 | if (w->dapm != dapm) |
| 1443 | continue; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1444 | list_del(&w->list); |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 1445 | /* |
| 1446 | * remove source and sink paths associated to this widget. |
| 1447 | * While removing the path, remove reference to it from both |
| 1448 | * source and sink widgets so that path is removed only once. |
| 1449 | */ |
| 1450 | list_for_each_entry_safe(p, next_p, &w->sources, list_sink) { |
| 1451 | list_del(&p->list_sink); |
| 1452 | list_del(&p->list_source); |
| 1453 | list_del(&p->list); |
| 1454 | kfree(p->long_name); |
| 1455 | kfree(p); |
| 1456 | } |
| 1457 | list_for_each_entry_safe(p, next_p, &w->sinks, list_source) { |
| 1458 | list_del(&p->list_sink); |
| 1459 | list_del(&p->list_source); |
| 1460 | list_del(&p->list); |
| 1461 | kfree(p->long_name); |
| 1462 | kfree(p); |
| 1463 | } |
Jarkko Nikula | ead9b91 | 2010-11-13 20:40:44 +0200 | [diff] [blame] | 1464 | kfree(w->name); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1465 | kfree(w); |
| 1466 | } |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1467 | } |
| 1468 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1469 | static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, |
Mark Brown | 1649923 | 2009-01-07 18:25:13 +0000 | [diff] [blame] | 1470 | const char *pin, int status) |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 1471 | { |
| 1472 | struct snd_soc_dapm_widget *w; |
| 1473 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1474 | list_for_each_entry(w, &dapm->card->widgets, list) { |
| 1475 | if (w->dapm != dapm) |
| 1476 | continue; |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 1477 | if (!strcmp(w->name, pin)) { |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 1478 | dev_dbg(w->dapm->dev, "dapm: pin %s = %d\n", |
| 1479 | pin, status); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 1480 | w->connected = status; |
Mark Brown | 5b9e87c | 2010-03-22 13:36:13 +0000 | [diff] [blame] | 1481 | /* Allow disabling of forced pins */ |
| 1482 | if (status == 0) |
| 1483 | w->force = 0; |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 1484 | return 0; |
| 1485 | } |
| 1486 | } |
| 1487 | |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 1488 | dev_err(dapm->dev, "dapm: unknown pin %s\n", pin); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 1489 | return -EINVAL; |
| 1490 | } |
| 1491 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1492 | /** |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 1493 | * snd_soc_dapm_sync - scan and power dapm paths |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1494 | * @dapm: DAPM context |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1495 | * |
| 1496 | * Walks all dapm audio paths and powers widgets according to their |
| 1497 | * stream or path usage. |
| 1498 | * |
| 1499 | * Returns 0 for success. |
| 1500 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1501 | int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1502 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1503 | return dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1504 | } |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 1505 | EXPORT_SYMBOL_GPL(snd_soc_dapm_sync); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1506 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1507 | static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, |
Mark Brown | 215edda | 2009-09-08 18:59:05 +0100 | [diff] [blame] | 1508 | const struct snd_soc_dapm_route *route) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1509 | { |
| 1510 | struct snd_soc_dapm_path *path; |
| 1511 | struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w; |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1512 | struct snd_soc_dapm_widget *wtsource = NULL, *wtsink = NULL; |
Jarkko Nikula | ead9b91 | 2010-11-13 20:40:44 +0200 | [diff] [blame] | 1513 | const char *sink; |
Mark Brown | 215edda | 2009-09-08 18:59:05 +0100 | [diff] [blame] | 1514 | const char *control = route->control; |
Jarkko Nikula | ead9b91 | 2010-11-13 20:40:44 +0200 | [diff] [blame] | 1515 | const char *source; |
| 1516 | char prefixed_sink[80]; |
| 1517 | char prefixed_source[80]; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1518 | int ret = 0; |
| 1519 | |
Jarkko Nikula | ead9b91 | 2010-11-13 20:40:44 +0200 | [diff] [blame] | 1520 | if (dapm->codec->name_prefix) { |
| 1521 | snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", |
| 1522 | dapm->codec->name_prefix, route->sink); |
| 1523 | sink = prefixed_sink; |
| 1524 | snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", |
| 1525 | dapm->codec->name_prefix, route->source); |
| 1526 | source = prefixed_source; |
| 1527 | } else { |
| 1528 | sink = route->sink; |
| 1529 | source = route->source; |
| 1530 | } |
| 1531 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1532 | /* |
| 1533 | * find src and dest widgets over all widgets but favor a widget from |
| 1534 | * current DAPM context |
| 1535 | */ |
| 1536 | list_for_each_entry(w, &dapm->card->widgets, list) { |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1537 | if (!wsink && !(strcmp(w->name, sink))) { |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1538 | wtsink = w; |
| 1539 | if (w->dapm == dapm) |
| 1540 | wsink = w; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1541 | continue; |
| 1542 | } |
| 1543 | if (!wsource && !(strcmp(w->name, source))) { |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1544 | wtsource = w; |
| 1545 | if (w->dapm == dapm) |
| 1546 | wsource = w; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1547 | } |
| 1548 | } |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1549 | /* use widget from another DAPM context if not found from this */ |
| 1550 | if (!wsink) |
| 1551 | wsink = wtsink; |
| 1552 | if (!wsource) |
| 1553 | wsource = wtsource; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1554 | |
| 1555 | if (wsource == NULL || wsink == NULL) |
| 1556 | return -ENODEV; |
| 1557 | |
| 1558 | path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL); |
| 1559 | if (!path) |
| 1560 | return -ENOMEM; |
| 1561 | |
| 1562 | path->source = wsource; |
| 1563 | path->sink = wsink; |
Mark Brown | 215edda | 2009-09-08 18:59:05 +0100 | [diff] [blame] | 1564 | path->connected = route->connected; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1565 | INIT_LIST_HEAD(&path->list); |
| 1566 | INIT_LIST_HEAD(&path->list_source); |
| 1567 | INIT_LIST_HEAD(&path->list_sink); |
| 1568 | |
| 1569 | /* check for external widgets */ |
| 1570 | if (wsink->id == snd_soc_dapm_input) { |
| 1571 | if (wsource->id == snd_soc_dapm_micbias || |
| 1572 | wsource->id == snd_soc_dapm_mic || |
Rongrong Cao | 087d53a | 2009-07-10 20:13:30 +0100 | [diff] [blame] | 1573 | wsource->id == snd_soc_dapm_line || |
| 1574 | wsource->id == snd_soc_dapm_output) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1575 | wsink->ext = 1; |
| 1576 | } |
| 1577 | if (wsource->id == snd_soc_dapm_output) { |
| 1578 | if (wsink->id == snd_soc_dapm_spk || |
| 1579 | wsink->id == snd_soc_dapm_hp || |
Seth Forshee | 1e39221 | 2007-04-16 15:36:42 +0200 | [diff] [blame] | 1580 | wsink->id == snd_soc_dapm_line || |
| 1581 | wsink->id == snd_soc_dapm_input) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1582 | wsource->ext = 1; |
| 1583 | } |
| 1584 | |
| 1585 | /* connect static paths */ |
| 1586 | if (control == NULL) { |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 1587 | list_add(&path->list, &dapm->card->paths); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1588 | list_add(&path->list_sink, &wsink->sources); |
| 1589 | list_add(&path->list_source, &wsource->sinks); |
| 1590 | path->connect = 1; |
| 1591 | return 0; |
| 1592 | } |
| 1593 | |
| 1594 | /* connect dynamic paths */ |
| 1595 | switch(wsink->id) { |
| 1596 | case snd_soc_dapm_adc: |
| 1597 | case snd_soc_dapm_dac: |
| 1598 | case snd_soc_dapm_pga: |
Olaya, Margarita | d88429a | 2010-12-10 21:11:44 -0600 | [diff] [blame] | 1599 | case snd_soc_dapm_out_drv: |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1600 | case snd_soc_dapm_input: |
| 1601 | case snd_soc_dapm_output: |
| 1602 | case snd_soc_dapm_micbias: |
| 1603 | case snd_soc_dapm_vmid: |
| 1604 | case snd_soc_dapm_pre: |
| 1605 | case snd_soc_dapm_post: |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 1606 | case snd_soc_dapm_supply: |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 1607 | case snd_soc_dapm_aif_in: |
| 1608 | case snd_soc_dapm_aif_out: |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 1609 | list_add(&path->list, &dapm->card->paths); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1610 | list_add(&path->list_sink, &wsink->sources); |
| 1611 | list_add(&path->list_source, &wsource->sinks); |
| 1612 | path->connect = 1; |
| 1613 | return 0; |
| 1614 | case snd_soc_dapm_mux: |
Dimitris Papastamos | 24ff33a | 2010-12-16 15:53:39 +0000 | [diff] [blame] | 1615 | case snd_soc_dapm_virt_mux: |
Peter Ujfalusi | 7415555 | 2009-01-08 13:34:29 +0200 | [diff] [blame] | 1616 | case snd_soc_dapm_value_mux: |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1617 | ret = dapm_connect_mux(dapm, wsource, wsink, path, control, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1618 | &wsink->kcontrols[0]); |
| 1619 | if (ret != 0) |
| 1620 | goto err; |
| 1621 | break; |
| 1622 | case snd_soc_dapm_switch: |
| 1623 | case snd_soc_dapm_mixer: |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 1624 | case snd_soc_dapm_mixer_named_ctl: |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1625 | ret = dapm_connect_mixer(dapm, wsource, wsink, path, control); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1626 | if (ret != 0) |
| 1627 | goto err; |
| 1628 | break; |
| 1629 | case snd_soc_dapm_hp: |
| 1630 | case snd_soc_dapm_mic: |
| 1631 | case snd_soc_dapm_line: |
| 1632 | case snd_soc_dapm_spk: |
Jarkko Nikula | 8ddab3f | 2010-12-14 12:18:30 +0200 | [diff] [blame] | 1633 | list_add(&path->list, &dapm->card->paths); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1634 | list_add(&path->list_sink, &wsink->sources); |
| 1635 | list_add(&path->list_source, &wsource->sinks); |
| 1636 | path->connect = 0; |
| 1637 | return 0; |
| 1638 | } |
| 1639 | return 0; |
| 1640 | |
| 1641 | err: |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 1642 | dev_warn(dapm->dev, "asoc: no dapm match for %s --> %s --> %s\n", |
| 1643 | source, control, sink); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1644 | kfree(path); |
| 1645 | return ret; |
| 1646 | } |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 1647 | |
| 1648 | /** |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 1649 | * snd_soc_dapm_add_routes - Add routes between DAPM widgets |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1650 | * @dapm: DAPM context |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 1651 | * @route: audio routes |
| 1652 | * @num: number of routes |
| 1653 | * |
| 1654 | * Connects 2 dapm widgets together via a named audio path. The sink is |
| 1655 | * the widget receiving the audio signal, whilst the source is the sender |
| 1656 | * of the audio signal. |
| 1657 | * |
| 1658 | * Returns 0 for success else error. On error all resources can be freed |
| 1659 | * with a call to snd_soc_card_free(). |
| 1660 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1661 | int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 1662 | const struct snd_soc_dapm_route *route, int num) |
| 1663 | { |
| 1664 | int i, ret; |
| 1665 | |
| 1666 | for (i = 0; i < num; i++) { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1667 | ret = snd_soc_dapm_add_route(dapm, route); |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 1668 | if (ret < 0) { |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 1669 | dev_err(dapm->dev, "Failed to add route %s->%s\n", |
| 1670 | route->source, route->sink); |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 1671 | return ret; |
| 1672 | } |
| 1673 | route++; |
| 1674 | } |
| 1675 | |
| 1676 | return 0; |
| 1677 | } |
| 1678 | EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes); |
| 1679 | |
| 1680 | /** |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1681 | * snd_soc_dapm_new_widgets - add new dapm widgets |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1682 | * @dapm: DAPM context |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1683 | * |
| 1684 | * Checks the codec for any new dapm widgets and creates them if found. |
| 1685 | * |
| 1686 | * Returns 0 for success. |
| 1687 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1688 | int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1689 | { |
| 1690 | struct snd_soc_dapm_widget *w; |
Mark Brown | b66a70d | 2011-02-09 18:04:11 +0000 | [diff] [blame] | 1691 | unsigned int val; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1692 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 1693 | list_for_each_entry(w, &dapm->card->widgets, list) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1694 | { |
| 1695 | if (w->new) |
| 1696 | continue; |
| 1697 | |
| 1698 | switch(w->id) { |
| 1699 | case snd_soc_dapm_switch: |
| 1700 | case snd_soc_dapm_mixer: |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 1701 | case snd_soc_dapm_mixer_named_ctl: |
Mark Brown | b75576d | 2009-04-20 17:56:13 +0100 | [diff] [blame] | 1702 | w->power_check = dapm_generic_check_power; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1703 | dapm_new_mixer(dapm, w); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1704 | break; |
| 1705 | case snd_soc_dapm_mux: |
Dimitris Papastamos | 24ff33a | 2010-12-16 15:53:39 +0000 | [diff] [blame] | 1706 | case snd_soc_dapm_virt_mux: |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 1707 | case snd_soc_dapm_value_mux: |
Mark Brown | b75576d | 2009-04-20 17:56:13 +0100 | [diff] [blame] | 1708 | w->power_check = dapm_generic_check_power; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1709 | dapm_new_mux(dapm, w); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1710 | break; |
| 1711 | case snd_soc_dapm_adc: |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 1712 | case snd_soc_dapm_aif_out: |
Mark Brown | b75576d | 2009-04-20 17:56:13 +0100 | [diff] [blame] | 1713 | w->power_check = dapm_adc_check_power; |
| 1714 | break; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1715 | case snd_soc_dapm_dac: |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 1716 | case snd_soc_dapm_aif_in: |
Mark Brown | b75576d | 2009-04-20 17:56:13 +0100 | [diff] [blame] | 1717 | w->power_check = dapm_dac_check_power; |
| 1718 | break; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1719 | case snd_soc_dapm_pga: |
Olaya, Margarita | d88429a | 2010-12-10 21:11:44 -0600 | [diff] [blame] | 1720 | case snd_soc_dapm_out_drv: |
Mark Brown | b75576d | 2009-04-20 17:56:13 +0100 | [diff] [blame] | 1721 | w->power_check = dapm_generic_check_power; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1722 | dapm_new_pga(dapm, w); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1723 | break; |
| 1724 | case snd_soc_dapm_input: |
| 1725 | case snd_soc_dapm_output: |
| 1726 | case snd_soc_dapm_micbias: |
| 1727 | case snd_soc_dapm_spk: |
| 1728 | case snd_soc_dapm_hp: |
| 1729 | case snd_soc_dapm_mic: |
| 1730 | case snd_soc_dapm_line: |
Mark Brown | b75576d | 2009-04-20 17:56:13 +0100 | [diff] [blame] | 1731 | w->power_check = dapm_generic_check_power; |
| 1732 | break; |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 1733 | case snd_soc_dapm_supply: |
| 1734 | w->power_check = dapm_supply_check_power; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1735 | case snd_soc_dapm_vmid: |
| 1736 | case snd_soc_dapm_pre: |
| 1737 | case snd_soc_dapm_post: |
| 1738 | break; |
| 1739 | } |
Mark Brown | b66a70d | 2011-02-09 18:04:11 +0000 | [diff] [blame] | 1740 | |
| 1741 | /* Read the initial power state from the device */ |
| 1742 | if (w->reg >= 0) { |
| 1743 | val = snd_soc_read(w->codec, w->reg); |
| 1744 | val &= 1 << w->shift; |
| 1745 | if (w->invert) |
| 1746 | val = !val; |
| 1747 | |
| 1748 | if (val) |
| 1749 | w->power = 1; |
| 1750 | } |
| 1751 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1752 | w->new = 1; |
| 1753 | } |
| 1754 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 1755 | dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1756 | return 0; |
| 1757 | } |
| 1758 | EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); |
| 1759 | |
| 1760 | /** |
| 1761 | * snd_soc_dapm_get_volsw - dapm mixer get callback |
| 1762 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1763 | * @ucontrol: control element information |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1764 | * |
| 1765 | * Callback to get the value of a dapm mixer control. |
| 1766 | * |
| 1767 | * Returns 0 for success. |
| 1768 | */ |
| 1769 | int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, |
| 1770 | struct snd_ctl_elem_value *ucontrol) |
| 1771 | { |
| 1772 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 1773 | struct soc_mixer_control *mc = |
| 1774 | (struct soc_mixer_control *)kcontrol->private_value; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 1775 | unsigned int reg = mc->reg; |
| 1776 | unsigned int shift = mc->shift; |
| 1777 | unsigned int rshift = mc->rshift; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 1778 | int max = mc->max; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 1779 | unsigned int invert = mc->invert; |
| 1780 | unsigned int mask = (1 << fls(max)) - 1; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1781 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1782 | ucontrol->value.integer.value[0] = |
| 1783 | (snd_soc_read(widget->codec, reg) >> shift) & mask; |
| 1784 | if (shift != rshift) |
| 1785 | ucontrol->value.integer.value[1] = |
| 1786 | (snd_soc_read(widget->codec, reg) >> rshift) & mask; |
| 1787 | if (invert) { |
| 1788 | ucontrol->value.integer.value[0] = |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1789 | max - ucontrol->value.integer.value[0]; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1790 | if (shift != rshift) |
| 1791 | ucontrol->value.integer.value[1] = |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1792 | max - ucontrol->value.integer.value[1]; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1793 | } |
| 1794 | |
| 1795 | return 0; |
| 1796 | } |
| 1797 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); |
| 1798 | |
| 1799 | /** |
| 1800 | * snd_soc_dapm_put_volsw - dapm mixer set callback |
| 1801 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1802 | * @ucontrol: control element information |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1803 | * |
| 1804 | * Callback to set the value of a dapm mixer control. |
| 1805 | * |
| 1806 | * Returns 0 for success. |
| 1807 | */ |
| 1808 | int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, |
| 1809 | struct snd_ctl_elem_value *ucontrol) |
| 1810 | { |
| 1811 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 1812 | struct soc_mixer_control *mc = |
| 1813 | (struct soc_mixer_control *)kcontrol->private_value; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 1814 | unsigned int reg = mc->reg; |
| 1815 | unsigned int shift = mc->shift; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 1816 | int max = mc->max; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 1817 | unsigned int mask = (1 << fls(max)) - 1; |
| 1818 | unsigned int invert = mc->invert; |
Stephen Warren | e9cf704 | 2011-01-27 14:54:05 -0700 | [diff] [blame] | 1819 | unsigned int val; |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1820 | int connect, change; |
| 1821 | struct snd_soc_dapm_update update; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1822 | |
| 1823 | val = (ucontrol->value.integer.value[0] & mask); |
| 1824 | |
| 1825 | if (invert) |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1826 | val = max - val; |
Stephen Warren | e9cf704 | 2011-01-27 14:54:05 -0700 | [diff] [blame] | 1827 | mask = mask << shift; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1828 | val = val << shift; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1829 | |
| 1830 | mutex_lock(&widget->codec->mutex); |
| 1831 | widget->value = val; |
| 1832 | |
Stephen Warren | e9cf704 | 2011-01-27 14:54:05 -0700 | [diff] [blame] | 1833 | change = snd_soc_test_bits(widget->codec, reg, mask, val); |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1834 | if (change) { |
Mark Brown | 283375c | 2009-12-07 18:09:03 +0000 | [diff] [blame] | 1835 | if (val) |
| 1836 | /* new connection */ |
| 1837 | connect = invert ? 0:1; |
| 1838 | else |
| 1839 | /* old connection must be powered down */ |
| 1840 | connect = invert ? 1:0; |
| 1841 | |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1842 | update.kcontrol = kcontrol; |
| 1843 | update.widget = widget; |
| 1844 | update.reg = reg; |
| 1845 | update.mask = mask; |
| 1846 | update.val = val; |
| 1847 | widget->dapm->update = &update; |
| 1848 | |
Mark Brown | 283375c | 2009-12-07 18:09:03 +0000 | [diff] [blame] | 1849 | dapm_mixer_update_power(widget, kcontrol, connect); |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1850 | |
| 1851 | widget->dapm->update = NULL; |
Mark Brown | 283375c | 2009-12-07 18:09:03 +0000 | [diff] [blame] | 1852 | } |
| 1853 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1854 | mutex_unlock(&widget->codec->mutex); |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1855 | return 0; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1856 | } |
| 1857 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw); |
| 1858 | |
| 1859 | /** |
| 1860 | * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback |
| 1861 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1862 | * @ucontrol: control element information |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1863 | * |
| 1864 | * Callback to get the value of a dapm enumerated double mixer control. |
| 1865 | * |
| 1866 | * Returns 0 for success. |
| 1867 | */ |
| 1868 | int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, |
| 1869 | struct snd_ctl_elem_value *ucontrol) |
| 1870 | { |
| 1871 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
| 1872 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1873 | unsigned int val, bitmask; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1874 | |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1875 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1876 | ; |
| 1877 | val = snd_soc_read(widget->codec, e->reg); |
| 1878 | ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1); |
| 1879 | if (e->shift_l != e->shift_r) |
| 1880 | ucontrol->value.enumerated.item[1] = |
| 1881 | (val >> e->shift_r) & (bitmask - 1); |
| 1882 | |
| 1883 | return 0; |
| 1884 | } |
| 1885 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); |
| 1886 | |
| 1887 | /** |
| 1888 | * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback |
| 1889 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1890 | * @ucontrol: control element information |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1891 | * |
| 1892 | * Callback to set the value of a dapm enumerated double mixer control. |
| 1893 | * |
| 1894 | * Returns 0 for success. |
| 1895 | */ |
| 1896 | int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, |
| 1897 | struct snd_ctl_elem_value *ucontrol) |
| 1898 | { |
| 1899 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
| 1900 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Mark Brown | 3a65577 | 2009-10-05 17:23:30 +0100 | [diff] [blame] | 1901 | unsigned int val, mux, change; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1902 | unsigned int mask, bitmask; |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1903 | struct snd_soc_dapm_update update; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1904 | |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1905 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1906 | ; |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1907 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1908 | return -EINVAL; |
| 1909 | mux = ucontrol->value.enumerated.item[0]; |
| 1910 | val = mux << e->shift_l; |
| 1911 | mask = (bitmask - 1) << e->shift_l; |
| 1912 | if (e->shift_l != e->shift_r) { |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1913 | if (ucontrol->value.enumerated.item[1] > e->max - 1) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1914 | return -EINVAL; |
| 1915 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; |
| 1916 | mask |= (bitmask - 1) << e->shift_r; |
| 1917 | } |
| 1918 | |
| 1919 | mutex_lock(&widget->codec->mutex); |
| 1920 | widget->value = val; |
Mark Brown | 3a65577 | 2009-10-05 17:23:30 +0100 | [diff] [blame] | 1921 | change = snd_soc_test_bits(widget->codec, e->reg, mask, val); |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1922 | |
| 1923 | update.kcontrol = kcontrol; |
| 1924 | update.widget = widget; |
| 1925 | update.reg = e->reg; |
| 1926 | update.mask = mask; |
| 1927 | update.val = val; |
| 1928 | widget->dapm->update = &update; |
| 1929 | |
Mark Brown | 3a65577 | 2009-10-05 17:23:30 +0100 | [diff] [blame] | 1930 | dapm_mux_update_power(widget, kcontrol, change, mux, e); |
Mark Brown | 1642e3d | 2009-10-05 16:24:26 +0100 | [diff] [blame] | 1931 | |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1932 | widget->dapm->update = NULL; |
Mark Brown | 1642e3d | 2009-10-05 16:24:26 +0100 | [diff] [blame] | 1933 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1934 | mutex_unlock(&widget->codec->mutex); |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 1935 | return change; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 1936 | } |
| 1937 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double); |
| 1938 | |
| 1939 | /** |
Mark Brown | d2b247a | 2009-10-06 15:21:04 +0100 | [diff] [blame] | 1940 | * snd_soc_dapm_get_enum_virt - Get virtual DAPM mux |
| 1941 | * @kcontrol: mixer control |
| 1942 | * @ucontrol: control element information |
| 1943 | * |
| 1944 | * Returns 0 for success. |
| 1945 | */ |
| 1946 | int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol, |
| 1947 | struct snd_ctl_elem_value *ucontrol) |
| 1948 | { |
| 1949 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
| 1950 | |
| 1951 | ucontrol->value.enumerated.item[0] = widget->value; |
| 1952 | |
| 1953 | return 0; |
| 1954 | } |
| 1955 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt); |
| 1956 | |
| 1957 | /** |
| 1958 | * snd_soc_dapm_put_enum_virt - Set virtual DAPM mux |
| 1959 | * @kcontrol: mixer control |
| 1960 | * @ucontrol: control element information |
| 1961 | * |
| 1962 | * Returns 0 for success. |
| 1963 | */ |
| 1964 | int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol, |
| 1965 | struct snd_ctl_elem_value *ucontrol) |
| 1966 | { |
| 1967 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
| 1968 | struct soc_enum *e = |
| 1969 | (struct soc_enum *)kcontrol->private_value; |
| 1970 | int change; |
| 1971 | int ret = 0; |
| 1972 | |
| 1973 | if (ucontrol->value.enumerated.item[0] >= e->max) |
| 1974 | return -EINVAL; |
| 1975 | |
| 1976 | mutex_lock(&widget->codec->mutex); |
| 1977 | |
| 1978 | change = widget->value != ucontrol->value.enumerated.item[0]; |
| 1979 | widget->value = ucontrol->value.enumerated.item[0]; |
| 1980 | dapm_mux_update_power(widget, kcontrol, change, widget->value, e); |
| 1981 | |
| 1982 | mutex_unlock(&widget->codec->mutex); |
| 1983 | return ret; |
| 1984 | } |
| 1985 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt); |
| 1986 | |
| 1987 | /** |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 1988 | * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get |
| 1989 | * callback |
| 1990 | * @kcontrol: mixer control |
| 1991 | * @ucontrol: control element information |
| 1992 | * |
| 1993 | * Callback to get the value of a dapm semi enumerated double mixer control. |
| 1994 | * |
| 1995 | * Semi enumerated mixer: the enumerated items are referred as values. Can be |
| 1996 | * used for handling bitfield coded enumeration for example. |
| 1997 | * |
| 1998 | * Returns 0 for success. |
| 1999 | */ |
| 2000 | int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol, |
| 2001 | struct snd_ctl_elem_value *ucontrol) |
| 2002 | { |
| 2003 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
Peter Ujfalusi | 7415555 | 2009-01-08 13:34:29 +0200 | [diff] [blame] | 2004 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 2005 | unsigned int reg_val, val, mux; |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 2006 | |
| 2007 | reg_val = snd_soc_read(widget->codec, e->reg); |
| 2008 | val = (reg_val >> e->shift_l) & e->mask; |
| 2009 | for (mux = 0; mux < e->max; mux++) { |
| 2010 | if (val == e->values[mux]) |
| 2011 | break; |
| 2012 | } |
| 2013 | ucontrol->value.enumerated.item[0] = mux; |
| 2014 | if (e->shift_l != e->shift_r) { |
| 2015 | val = (reg_val >> e->shift_r) & e->mask; |
| 2016 | for (mux = 0; mux < e->max; mux++) { |
| 2017 | if (val == e->values[mux]) |
| 2018 | break; |
| 2019 | } |
| 2020 | ucontrol->value.enumerated.item[1] = mux; |
| 2021 | } |
| 2022 | |
| 2023 | return 0; |
| 2024 | } |
| 2025 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_value_enum_double); |
| 2026 | |
| 2027 | /** |
| 2028 | * snd_soc_dapm_put_value_enum_double - dapm semi enumerated double mixer set |
| 2029 | * callback |
| 2030 | * @kcontrol: mixer control |
| 2031 | * @ucontrol: control element information |
| 2032 | * |
| 2033 | * Callback to set the value of a dapm semi enumerated double mixer control. |
| 2034 | * |
| 2035 | * Semi enumerated mixer: the enumerated items are referred as values. Can be |
| 2036 | * used for handling bitfield coded enumeration for example. |
| 2037 | * |
| 2038 | * Returns 0 for success. |
| 2039 | */ |
| 2040 | int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, |
| 2041 | struct snd_ctl_elem_value *ucontrol) |
| 2042 | { |
| 2043 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
Peter Ujfalusi | 7415555 | 2009-01-08 13:34:29 +0200 | [diff] [blame] | 2044 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Mark Brown | 3a65577 | 2009-10-05 17:23:30 +0100 | [diff] [blame] | 2045 | unsigned int val, mux, change; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 2046 | unsigned int mask; |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 2047 | struct snd_soc_dapm_update update; |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 2048 | |
| 2049 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
| 2050 | return -EINVAL; |
| 2051 | mux = ucontrol->value.enumerated.item[0]; |
| 2052 | val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l; |
| 2053 | mask = e->mask << e->shift_l; |
| 2054 | if (e->shift_l != e->shift_r) { |
| 2055 | if (ucontrol->value.enumerated.item[1] > e->max - 1) |
| 2056 | return -EINVAL; |
| 2057 | val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r; |
| 2058 | mask |= e->mask << e->shift_r; |
| 2059 | } |
| 2060 | |
| 2061 | mutex_lock(&widget->codec->mutex); |
| 2062 | widget->value = val; |
Mark Brown | 3a65577 | 2009-10-05 17:23:30 +0100 | [diff] [blame] | 2063 | change = snd_soc_test_bits(widget->codec, e->reg, mask, val); |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 2064 | |
| 2065 | update.kcontrol = kcontrol; |
| 2066 | update.widget = widget; |
| 2067 | update.reg = e->reg; |
| 2068 | update.mask = mask; |
| 2069 | update.val = val; |
| 2070 | widget->dapm->update = &update; |
| 2071 | |
Mark Brown | 3a65577 | 2009-10-05 17:23:30 +0100 | [diff] [blame] | 2072 | dapm_mux_update_power(widget, kcontrol, change, mux, e); |
Mark Brown | 1642e3d | 2009-10-05 16:24:26 +0100 | [diff] [blame] | 2073 | |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 2074 | widget->dapm->update = NULL; |
Mark Brown | 1642e3d | 2009-10-05 16:24:26 +0100 | [diff] [blame] | 2075 | |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 2076 | mutex_unlock(&widget->codec->mutex); |
Mark Brown | 97404f2 | 2010-12-14 16:13:57 +0000 | [diff] [blame] | 2077 | return change; |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 2078 | } |
| 2079 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double); |
| 2080 | |
| 2081 | /** |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 2082 | * snd_soc_dapm_info_pin_switch - Info for a pin switch |
| 2083 | * |
| 2084 | * @kcontrol: mixer control |
| 2085 | * @uinfo: control element information |
| 2086 | * |
| 2087 | * Callback to provide information about a pin switch control. |
| 2088 | */ |
| 2089 | int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, |
| 2090 | struct snd_ctl_elem_info *uinfo) |
| 2091 | { |
| 2092 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 2093 | uinfo->count = 1; |
| 2094 | uinfo->value.integer.min = 0; |
| 2095 | uinfo->value.integer.max = 1; |
| 2096 | |
| 2097 | return 0; |
| 2098 | } |
| 2099 | EXPORT_SYMBOL_GPL(snd_soc_dapm_info_pin_switch); |
| 2100 | |
| 2101 | /** |
| 2102 | * snd_soc_dapm_get_pin_switch - Get information for a pin switch |
| 2103 | * |
| 2104 | * @kcontrol: mixer control |
| 2105 | * @ucontrol: Value |
| 2106 | */ |
| 2107 | int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, |
| 2108 | struct snd_ctl_elem_value *ucontrol) |
| 2109 | { |
| 2110 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2111 | const char *pin = (const char *)kcontrol->private_value; |
| 2112 | |
| 2113 | mutex_lock(&codec->mutex); |
| 2114 | |
| 2115 | ucontrol->value.integer.value[0] = |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2116 | snd_soc_dapm_get_pin_status(&codec->dapm, pin); |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 2117 | |
| 2118 | mutex_unlock(&codec->mutex); |
| 2119 | |
| 2120 | return 0; |
| 2121 | } |
| 2122 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_switch); |
| 2123 | |
| 2124 | /** |
| 2125 | * snd_soc_dapm_put_pin_switch - Set information for a pin switch |
| 2126 | * |
| 2127 | * @kcontrol: mixer control |
| 2128 | * @ucontrol: Value |
| 2129 | */ |
| 2130 | int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, |
| 2131 | struct snd_ctl_elem_value *ucontrol) |
| 2132 | { |
| 2133 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2134 | const char *pin = (const char *)kcontrol->private_value; |
| 2135 | |
| 2136 | mutex_lock(&codec->mutex); |
| 2137 | |
| 2138 | if (ucontrol->value.integer.value[0]) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2139 | snd_soc_dapm_enable_pin(&codec->dapm, pin); |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 2140 | else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2141 | snd_soc_dapm_disable_pin(&codec->dapm, pin); |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 2142 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2143 | snd_soc_dapm_sync(&codec->dapm); |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 2144 | |
| 2145 | mutex_unlock(&codec->mutex); |
| 2146 | |
| 2147 | return 0; |
| 2148 | } |
| 2149 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch); |
| 2150 | |
| 2151 | /** |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2152 | * snd_soc_dapm_new_control - create new dapm control |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2153 | * @dapm: DAPM context |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2154 | * @widget: widget template |
| 2155 | * |
| 2156 | * Creates a new dapm control based upon the template. |
| 2157 | * |
| 2158 | * Returns 0 for success else error. |
| 2159 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2160 | int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2161 | const struct snd_soc_dapm_widget *widget) |
| 2162 | { |
| 2163 | struct snd_soc_dapm_widget *w; |
Jarkko Nikula | ead9b91 | 2010-11-13 20:40:44 +0200 | [diff] [blame] | 2164 | size_t name_len; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2165 | |
| 2166 | if ((w = dapm_cnew_widget(widget)) == NULL) |
| 2167 | return -ENOMEM; |
| 2168 | |
Jarkko Nikula | ead9b91 | 2010-11-13 20:40:44 +0200 | [diff] [blame] | 2169 | name_len = strlen(widget->name) + 1; |
| 2170 | if (dapm->codec->name_prefix) |
| 2171 | name_len += 1 + strlen(dapm->codec->name_prefix); |
| 2172 | w->name = kmalloc(name_len, GFP_KERNEL); |
| 2173 | if (w->name == NULL) { |
| 2174 | kfree(w); |
| 2175 | return -ENOMEM; |
| 2176 | } |
| 2177 | if (dapm->codec->name_prefix) |
| 2178 | snprintf(w->name, name_len, "%s %s", |
| 2179 | dapm->codec->name_prefix, widget->name); |
| 2180 | else |
| 2181 | snprintf(w->name, name_len, "%s", widget->name); |
| 2182 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 2183 | dapm->n_widgets++; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2184 | w->dapm = dapm; |
| 2185 | w->codec = dapm->codec; |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2186 | INIT_LIST_HEAD(&w->sources); |
| 2187 | INIT_LIST_HEAD(&w->sinks); |
| 2188 | INIT_LIST_HEAD(&w->list); |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 2189 | list_add(&w->list, &dapm->card->widgets); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2190 | |
| 2191 | /* machine layer set ups unconnected pins and insertions */ |
| 2192 | w->connected = 1; |
| 2193 | return 0; |
| 2194 | } |
| 2195 | EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control); |
| 2196 | |
| 2197 | /** |
Mark Brown | 4ba1327 | 2008-05-13 14:51:19 +0200 | [diff] [blame] | 2198 | * snd_soc_dapm_new_controls - create new dapm controls |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2199 | * @dapm: DAPM context |
Mark Brown | 4ba1327 | 2008-05-13 14:51:19 +0200 | [diff] [blame] | 2200 | * @widget: widget array |
| 2201 | * @num: number of widgets |
| 2202 | * |
| 2203 | * Creates new DAPM controls based upon the templates. |
| 2204 | * |
| 2205 | * Returns 0 for success else error. |
| 2206 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2207 | int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, |
Mark Brown | 4ba1327 | 2008-05-13 14:51:19 +0200 | [diff] [blame] | 2208 | const struct snd_soc_dapm_widget *widget, |
| 2209 | int num) |
| 2210 | { |
| 2211 | int i, ret; |
| 2212 | |
| 2213 | for (i = 0; i < num; i++) { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2214 | ret = snd_soc_dapm_new_control(dapm, widget); |
Mark Brown | b8b33cb | 2008-12-18 11:19:30 +0000 | [diff] [blame] | 2215 | if (ret < 0) { |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 2216 | dev_err(dapm->dev, |
| 2217 | "ASoC: Failed to create DAPM control %s: %d\n", |
| 2218 | widget->name, ret); |
Mark Brown | 4ba1327 | 2008-05-13 14:51:19 +0200 | [diff] [blame] | 2219 | return ret; |
Mark Brown | b8b33cb | 2008-12-18 11:19:30 +0000 | [diff] [blame] | 2220 | } |
Mark Brown | 4ba1327 | 2008-05-13 14:51:19 +0200 | [diff] [blame] | 2221 | widget++; |
| 2222 | } |
| 2223 | return 0; |
| 2224 | } |
| 2225 | EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls); |
| 2226 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2227 | static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 2228 | const char *stream, int event) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2229 | { |
| 2230 | struct snd_soc_dapm_widget *w; |
| 2231 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 2232 | list_for_each_entry(w, &dapm->card->widgets, list) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2233 | { |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 2234 | if (!w->sname || w->dapm != dapm) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2235 | continue; |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 2236 | dev_dbg(w->dapm->dev, "widget %s\n %s stream %s event %d\n", |
| 2237 | w->name, w->sname, stream, event); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2238 | if (strstr(w->sname, stream)) { |
| 2239 | switch(event) { |
| 2240 | case SND_SOC_DAPM_STREAM_START: |
| 2241 | w->active = 1; |
| 2242 | break; |
| 2243 | case SND_SOC_DAPM_STREAM_STOP: |
| 2244 | w->active = 0; |
| 2245 | break; |
| 2246 | case SND_SOC_DAPM_STREAM_SUSPEND: |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2247 | case SND_SOC_DAPM_STREAM_RESUME: |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2248 | case SND_SOC_DAPM_STREAM_PAUSE_PUSH: |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2249 | case SND_SOC_DAPM_STREAM_PAUSE_RELEASE: |
| 2250 | break; |
| 2251 | } |
| 2252 | } |
| 2253 | } |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2254 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2255 | dapm_power_widgets(dapm, event); |
| 2256 | } |
| 2257 | |
| 2258 | /** |
| 2259 | * snd_soc_dapm_stream_event - send a stream event to the dapm core |
| 2260 | * @rtd: PCM runtime data |
| 2261 | * @stream: stream name |
| 2262 | * @event: stream event |
| 2263 | * |
| 2264 | * Sends a stream event to the dapm core. The core then makes any |
| 2265 | * necessary widget power changes. |
| 2266 | * |
| 2267 | * Returns 0 for success else error. |
| 2268 | */ |
| 2269 | int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, |
| 2270 | const char *stream, int event) |
| 2271 | { |
| 2272 | struct snd_soc_codec *codec = rtd->codec; |
| 2273 | |
| 2274 | if (stream == NULL) |
| 2275 | return 0; |
| 2276 | |
| 2277 | mutex_lock(&codec->mutex); |
| 2278 | soc_dapm_stream_event(&codec->dapm, stream, event); |
Eero Nurkkala | 8e8b2d6 | 2009-10-12 08:41:59 +0300 | [diff] [blame] | 2279 | mutex_unlock(&codec->mutex); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2280 | return 0; |
| 2281 | } |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2282 | |
| 2283 | /** |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2284 | * snd_soc_dapm_enable_pin - enable pin. |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2285 | * @dapm: DAPM context |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2286 | * @pin: pin name |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2287 | * |
Mark Brown | 74b8f95 | 2009-06-06 11:26:15 +0100 | [diff] [blame] | 2288 | * Enables input/output pin and its parents or children widgets iff there is |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2289 | * a valid audio route and active audio stream. |
| 2290 | * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to |
| 2291 | * do any widget power switching. |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2292 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2293 | int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2294 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2295 | return snd_soc_dapm_set_pin(dapm, pin, 1); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2296 | } |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2297 | EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2298 | |
| 2299 | /** |
Mark Brown | da34183 | 2010-03-15 19:23:37 +0000 | [diff] [blame] | 2300 | * snd_soc_dapm_force_enable_pin - force a pin to be enabled |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2301 | * @dapm: DAPM context |
Mark Brown | da34183 | 2010-03-15 19:23:37 +0000 | [diff] [blame] | 2302 | * @pin: pin name |
| 2303 | * |
| 2304 | * Enables input/output pin regardless of any other state. This is |
| 2305 | * intended for use with microphone bias supplies used in microphone |
| 2306 | * jack detection. |
| 2307 | * |
| 2308 | * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to |
| 2309 | * do any widget power switching. |
| 2310 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2311 | int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, |
| 2312 | const char *pin) |
Mark Brown | da34183 | 2010-03-15 19:23:37 +0000 | [diff] [blame] | 2313 | { |
| 2314 | struct snd_soc_dapm_widget *w; |
| 2315 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 2316 | list_for_each_entry(w, &dapm->card->widgets, list) { |
| 2317 | if (w->dapm != dapm) |
| 2318 | continue; |
Mark Brown | da34183 | 2010-03-15 19:23:37 +0000 | [diff] [blame] | 2319 | if (!strcmp(w->name, pin)) { |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 2320 | dev_dbg(w->dapm->dev, |
| 2321 | "dapm: force enable pin %s\n", pin); |
Mark Brown | da34183 | 2010-03-15 19:23:37 +0000 | [diff] [blame] | 2322 | w->connected = 1; |
| 2323 | w->force = 1; |
| 2324 | return 0; |
| 2325 | } |
| 2326 | } |
| 2327 | |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 2328 | dev_err(dapm->dev, "dapm: unknown pin %s\n", pin); |
Mark Brown | da34183 | 2010-03-15 19:23:37 +0000 | [diff] [blame] | 2329 | return -EINVAL; |
| 2330 | } |
| 2331 | EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin); |
| 2332 | |
| 2333 | /** |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2334 | * snd_soc_dapm_disable_pin - disable pin. |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2335 | * @dapm: DAPM context |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2336 | * @pin: pin name |
Graeme Gregory | eeec12b | 2008-04-30 19:27:40 +0200 | [diff] [blame] | 2337 | * |
Mark Brown | 74b8f95 | 2009-06-06 11:26:15 +0100 | [diff] [blame] | 2338 | * Disables input/output pin and its parents or children widgets. |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2339 | * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to |
| 2340 | * do any widget power switching. |
Graeme Gregory | eeec12b | 2008-04-30 19:27:40 +0200 | [diff] [blame] | 2341 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2342 | int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, |
| 2343 | const char *pin) |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2344 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2345 | return snd_soc_dapm_set_pin(dapm, pin, 0); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2346 | } |
| 2347 | EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin); |
| 2348 | |
| 2349 | /** |
Mark Brown | 5817b52 | 2008-09-24 11:23:11 +0100 | [diff] [blame] | 2350 | * snd_soc_dapm_nc_pin - permanently disable pin. |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2351 | * @dapm: DAPM context |
Mark Brown | 5817b52 | 2008-09-24 11:23:11 +0100 | [diff] [blame] | 2352 | * @pin: pin name |
| 2353 | * |
| 2354 | * Marks the specified pin as being not connected, disabling it along |
| 2355 | * any parent or child widgets. At present this is identical to |
| 2356 | * snd_soc_dapm_disable_pin() but in future it will be extended to do |
| 2357 | * additional things such as disabling controls which only affect |
| 2358 | * paths through the pin. |
| 2359 | * |
| 2360 | * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to |
| 2361 | * do any widget power switching. |
| 2362 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2363 | int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) |
Mark Brown | 5817b52 | 2008-09-24 11:23:11 +0100 | [diff] [blame] | 2364 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2365 | return snd_soc_dapm_set_pin(dapm, pin, 0); |
Mark Brown | 5817b52 | 2008-09-24 11:23:11 +0100 | [diff] [blame] | 2366 | } |
| 2367 | EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin); |
| 2368 | |
| 2369 | /** |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2370 | * snd_soc_dapm_get_pin_status - get audio pin status |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2371 | * @dapm: DAPM context |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2372 | * @pin: audio signal pin endpoint (or start point) |
| 2373 | * |
| 2374 | * Get audio pin status - connected or disconnected. |
| 2375 | * |
| 2376 | * Returns 1 for connected otherwise 0. |
| 2377 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2378 | int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, |
| 2379 | const char *pin) |
Graeme Gregory | eeec12b | 2008-04-30 19:27:40 +0200 | [diff] [blame] | 2380 | { |
| 2381 | struct snd_soc_dapm_widget *w; |
| 2382 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 2383 | list_for_each_entry(w, &dapm->card->widgets, list) { |
| 2384 | if (w->dapm != dapm) |
| 2385 | continue; |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2386 | if (!strcmp(w->name, pin)) |
Graeme Gregory | eeec12b | 2008-04-30 19:27:40 +0200 | [diff] [blame] | 2387 | return w->connected; |
| 2388 | } |
| 2389 | |
| 2390 | return 0; |
| 2391 | } |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 2392 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status); |
Graeme Gregory | eeec12b | 2008-04-30 19:27:40 +0200 | [diff] [blame] | 2393 | |
| 2394 | /** |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 2395 | * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2396 | * @dapm: DAPM context |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 2397 | * @pin: audio signal pin endpoint (or start point) |
| 2398 | * |
| 2399 | * Mark the given endpoint or pin as ignoring suspend. When the |
| 2400 | * system is disabled a path between two endpoints flagged as ignoring |
| 2401 | * suspend will not be disabled. The path must already be enabled via |
| 2402 | * normal means at suspend time, it will not be turned on if it was not |
| 2403 | * already enabled. |
| 2404 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2405 | int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, |
| 2406 | const char *pin) |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 2407 | { |
| 2408 | struct snd_soc_dapm_widget *w; |
| 2409 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 2410 | list_for_each_entry(w, &dapm->card->widgets, list) { |
| 2411 | if (w->dapm != dapm) |
| 2412 | continue; |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 2413 | if (!strcmp(w->name, pin)) { |
| 2414 | w->ignore_suspend = 1; |
| 2415 | return 0; |
| 2416 | } |
| 2417 | } |
| 2418 | |
Jarkko Nikula | f7d41ae | 2010-11-09 14:40:27 +0200 | [diff] [blame] | 2419 | dev_err(dapm->dev, "dapm: unknown pin %s\n", pin); |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 2420 | return -EINVAL; |
| 2421 | } |
| 2422 | EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend); |
| 2423 | |
| 2424 | /** |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2425 | * snd_soc_dapm_free - free dapm resources |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 2426 | * @card: SoC device |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2427 | * |
| 2428 | * Free all dapm widgets and resources. |
| 2429 | */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2430 | void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm) |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2431 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2432 | snd_soc_dapm_sys_remove(dapm->dev); |
| 2433 | dapm_free_widgets(dapm); |
Jarkko Nikula | 7be31be8 | 2010-12-14 12:18:32 +0200 | [diff] [blame] | 2434 | list_del(&dapm->list); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2435 | } |
| 2436 | EXPORT_SYMBOL_GPL(snd_soc_dapm_free); |
| 2437 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2438 | static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm) |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 2439 | { |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 2440 | struct snd_soc_dapm_widget *w; |
| 2441 | LIST_HEAD(down_list); |
| 2442 | int powerdown = 0; |
| 2443 | |
Jarkko Nikula | 97c866d | 2010-12-14 12:18:31 +0200 | [diff] [blame] | 2444 | list_for_each_entry(w, &dapm->card->widgets, list) { |
| 2445 | if (w->dapm != dapm) |
| 2446 | continue; |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 2447 | if (w->power) { |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 2448 | dapm_seq_insert(w, &down_list, false); |
Mark Brown | c2caa4d | 2009-06-26 15:36:56 +0100 | [diff] [blame] | 2449 | w->power = 0; |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 2450 | powerdown = 1; |
| 2451 | } |
| 2452 | } |
| 2453 | |
| 2454 | /* If there were no widgets to power down we're already in |
| 2455 | * standby. |
| 2456 | */ |
| 2457 | if (powerdown) { |
Mark Brown | ed5a4c4 | 2011-02-18 11:12:42 -0800 | [diff] [blame] | 2458 | snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_PREPARE); |
Mark Brown | 828a842 | 2011-01-15 13:14:30 +0000 | [diff] [blame] | 2459 | dapm_seq_run(dapm, &down_list, 0, false); |
Mark Brown | ed5a4c4 | 2011-02-18 11:12:42 -0800 | [diff] [blame] | 2460 | snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_STANDBY); |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 2461 | } |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 2462 | } |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 2463 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 2464 | /* |
| 2465 | * snd_soc_dapm_shutdown - callback for system shutdown |
| 2466 | */ |
| 2467 | void snd_soc_dapm_shutdown(struct snd_soc_card *card) |
| 2468 | { |
| 2469 | struct snd_soc_codec *codec; |
| 2470 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2471 | list_for_each_entry(codec, &card->codec_dev_list, list) { |
| 2472 | soc_dapm_shutdown_codec(&codec->dapm); |
Mark Brown | ed5a4c4 | 2011-02-18 11:12:42 -0800 | [diff] [blame] | 2473 | snd_soc_dapm_set_bias_level(&codec->dapm, SND_SOC_BIAS_OFF); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 2474 | } |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 2475 | } |
| 2476 | |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2477 | /* Module information */ |
Liam Girdwood | d331124 | 2008-10-12 13:17:36 +0100 | [diff] [blame] | 2478 | MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk"); |
Richard Purdie | 2b97eab | 2006-10-06 18:32:18 +0200 | [diff] [blame] | 2479 | MODULE_DESCRIPTION("Dynamic Audio Power Management core for ALSA SoC"); |
| 2480 | MODULE_LICENSE("GPL"); |