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