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