Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/sound/soc-dapm.h -- ALSA SoC Dynamic Audio Power Management |
| 3 | * |
| 4 | * Author: Liam Girdwood |
| 5 | * Created: Aug 11th 2005 |
| 6 | * Copyright: Wolfson Microelectronics. PLC. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #ifndef __LINUX_SND_SOC_DAPM_H |
| 14 | #define __LINUX_SND_SOC_DAPM_H |
| 15 | |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/types.h> |
| 18 | #include <sound/control.h> |
| 19 | #include <sound/soc.h> |
| 20 | |
| 21 | /* widget has no PM register bit */ |
| 22 | #define SND_SOC_NOPM -1 |
| 23 | |
| 24 | /* |
Joe Perches | b7d2a80 | 2007-12-18 13:14:21 +0100 | [diff] [blame] | 25 | * SoC dynamic audio power management |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 26 | * |
| 27 | * We can have upto 4 power domains |
| 28 | * 1. Codec domain - VREF, VMID |
| 29 | * Usually controlled at codec probe/remove, although can be set |
| 30 | * at stream time if power is not needed for sidetone, etc. |
| 31 | * 2. Platform/Machine domain - physically connected inputs and outputs |
| 32 | * Is platform/machine and user action specific, is set in the machine |
| 33 | * driver and by userspace e.g when HP are inserted |
| 34 | * 3. Path domain - Internal codec path mixers |
| 35 | * Are automatically set when mixer and mux settings are |
| 36 | * changed by the user. |
| 37 | * 4. Stream domain - DAC's and ADC's. |
| 38 | * Enabled when stream playback/capture is started. |
| 39 | */ |
| 40 | |
| 41 | /* codec domain */ |
| 42 | #define SND_SOC_DAPM_VMID(wname) \ |
| 43 | { .id = snd_soc_dapm_vmid, .name = wname, .kcontrols = NULL, \ |
| 44 | .num_kcontrols = 0} |
| 45 | |
| 46 | /* platform domain */ |
| 47 | #define SND_SOC_DAPM_INPUT(wname) \ |
| 48 | { .id = snd_soc_dapm_input, .name = wname, .kcontrols = NULL, \ |
| 49 | .num_kcontrols = 0} |
| 50 | #define SND_SOC_DAPM_OUTPUT(wname) \ |
| 51 | { .id = snd_soc_dapm_output, .name = wname, .kcontrols = NULL, \ |
| 52 | .num_kcontrols = 0} |
| 53 | #define SND_SOC_DAPM_MIC(wname, wevent) \ |
| 54 | { .id = snd_soc_dapm_mic, .name = wname, .kcontrols = NULL, \ |
| 55 | .num_kcontrols = 0, .event = wevent, \ |
| 56 | .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} |
| 57 | #define SND_SOC_DAPM_HP(wname, wevent) \ |
| 58 | { .id = snd_soc_dapm_hp, .name = wname, .kcontrols = NULL, \ |
| 59 | .num_kcontrols = 0, .event = wevent, \ |
| 60 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} |
| 61 | #define SND_SOC_DAPM_SPK(wname, wevent) \ |
| 62 | { .id = snd_soc_dapm_spk, .name = wname, .kcontrols = NULL, \ |
| 63 | .num_kcontrols = 0, .event = wevent, \ |
| 64 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} |
| 65 | #define SND_SOC_DAPM_LINE(wname, wevent) \ |
| 66 | { .id = snd_soc_dapm_line, .name = wname, .kcontrols = NULL, \ |
| 67 | .num_kcontrols = 0, .event = wevent, \ |
| 68 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} |
| 69 | |
| 70 | /* path domain */ |
| 71 | #define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\ |
| 72 | wcontrols, wncontrols) \ |
| 73 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ |
| 74 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} |
| 75 | #define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \ |
| 76 | wcontrols, wncontrols)\ |
| 77 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ |
| 78 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 79 | #define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \ |
| 80 | wcontrols, wncontrols)\ |
| 81 | { .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \ |
| 82 | .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ |
| 83 | .num_kcontrols = wncontrols} |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 84 | #define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \ |
| 85 | { .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ |
| 86 | .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0} |
| 87 | #define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \ |
| 88 | { .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ |
| 89 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} |
| 90 | #define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \ |
| 91 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ |
| 92 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 93 | #define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \ |
| 94 | { .id = snd_soc_dapm_value_mux, .name = wname, .reg = wreg, \ |
| 95 | .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ |
| 96 | .num_kcontrols = 1} |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 97 | |
Guennadi Liakhovetski | 8484c63 | 2010-01-21 21:10:47 +0100 | [diff] [blame] | 98 | /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ |
| 99 | #define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\ |
| 100 | wcontrols) \ |
| 101 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ |
| 102 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} |
| 103 | #define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \ |
| 104 | wcontrols)\ |
| 105 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ |
| 106 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} |
| 107 | #define SOC_MIXER_NAMED_CTL_ARRAY(wname, wreg, wshift, winvert, \ |
| 108 | wcontrols)\ |
| 109 | { .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \ |
| 110 | .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ |
| 111 | .num_kcontrols = ARRAY_SIZE(wcontrols)} |
| 112 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 113 | /* path domain with event - event handler must return 0 for success */ |
| 114 | #define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \ |
| 115 | wncontrols, wevent, wflags) \ |
| 116 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ |
| 117 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ |
| 118 | .event = wevent, .event_flags = wflags} |
| 119 | #define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \ |
| 120 | wncontrols, wevent, wflags) \ |
| 121 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ |
| 122 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ |
| 123 | .event = wevent, .event_flags = wflags} |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 124 | #define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \ |
| 125 | wcontrols, wncontrols, wevent, wflags) \ |
| 126 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ |
| 127 | .invert = winvert, .kcontrols = wcontrols, \ |
| 128 | .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags} |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 129 | #define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \ |
| 130 | { .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ |
| 131 | .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \ |
| 132 | .event = wevent, .event_flags = wflags} |
| 133 | #define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \ |
| 134 | wevent, wflags) \ |
| 135 | { .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ |
Peter Ujfalusi | 43d5080 | 2009-01-23 10:08:35 +0200 | [diff] [blame] | 136 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 137 | .event = wevent, .event_flags = wflags} |
| 138 | #define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \ |
| 139 | wevent, wflags) \ |
| 140 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ |
| 141 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ |
| 142 | .event = wevent, .event_flags = wflags} |
| 143 | |
Guennadi Liakhovetski | 8484c63 | 2010-01-21 21:10:47 +0100 | [diff] [blame] | 144 | /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ |
| 145 | #define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ |
| 146 | wevent, wflags) \ |
| 147 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ |
| 148 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ |
| 149 | .event = wevent, .event_flags = wflags} |
| 150 | #define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ |
| 151 | wevent, wflags) \ |
| 152 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ |
| 153 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ |
| 154 | .event = wevent, .event_flags = wflags} |
| 155 | #define SOC_MIXER_NAMED_CTL_E_ARRAY(wname, wreg, wshift, winvert, \ |
| 156 | wcontrols, wevent, wflags) \ |
| 157 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ |
| 158 | .invert = winvert, .kcontrols = wcontrols, \ |
| 159 | .num_kcontrols = ARRAY_SIZE(wcontrols), .event = wevent, .event_flags = wflags} |
| 160 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 161 | /* events that are pre and post DAPM */ |
| 162 | #define SND_SOC_DAPM_PRE(wname, wevent) \ |
| 163 | { .id = snd_soc_dapm_pre, .name = wname, .kcontrols = NULL, \ |
| 164 | .num_kcontrols = 0, .event = wevent, \ |
| 165 | .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD} |
| 166 | #define SND_SOC_DAPM_POST(wname, wevent) \ |
| 167 | { .id = snd_soc_dapm_post, .name = wname, .kcontrols = NULL, \ |
| 168 | .num_kcontrols = 0, .event = wevent, \ |
| 169 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD} |
| 170 | |
| 171 | /* stream domain */ |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 172 | #define SND_SOC_DAPM_AIF_IN(wname, stname, wslot, wreg, wshift, winvert) \ |
| 173 | { .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \ |
| 174 | .reg = wreg, .shift = wshift, .invert = winvert } |
| 175 | #define SND_SOC_DAPM_AIF_OUT(wname, stname, wslot, wreg, wshift, winvert) \ |
| 176 | { .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \ |
| 177 | .reg = wreg, .shift = wshift, .invert = winvert } |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 178 | #define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \ |
| 179 | { .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \ |
| 180 | .shift = wshift, .invert = winvert} |
Mark Brown | f6d655a | 2009-04-13 11:27:03 +0100 | [diff] [blame] | 181 | #define SND_SOC_DAPM_DAC_E(wname, stname, wreg, wshift, winvert, \ |
| 182 | wevent, wflags) \ |
| 183 | { .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \ |
| 184 | .shift = wshift, .invert = winvert, \ |
| 185 | .event = wevent, .event_flags = wflags} |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 186 | #define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \ |
| 187 | { .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \ |
| 188 | .shift = wshift, .invert = winvert} |
Mark Brown | f6d655a | 2009-04-13 11:27:03 +0100 | [diff] [blame] | 189 | #define SND_SOC_DAPM_ADC_E(wname, stname, wreg, wshift, winvert, \ |
| 190 | wevent, wflags) \ |
| 191 | { .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \ |
| 192 | .shift = wshift, .invert = winvert, \ |
| 193 | .event = wevent, .event_flags = wflags} |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 194 | |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 195 | /* generic widgets */ |
Jarkko Nikula | e2be2cc | 2008-06-25 14:42:07 +0300 | [diff] [blame] | 196 | #define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \ |
| 197 | { .id = wid, .name = wname, .kcontrols = NULL, .num_kcontrols = 0, \ |
| 198 | .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \ |
| 199 | .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \ |
| 200 | .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 201 | #define SND_SOC_DAPM_SUPPLY(wname, wreg, wshift, winvert, wevent, wflags) \ |
| 202 | { .id = snd_soc_dapm_supply, .name = wname, .reg = wreg, \ |
| 203 | .shift = wshift, .invert = winvert, .event = wevent, \ |
| 204 | .event_flags = wflags} |
Jarkko Nikula | e2be2cc | 2008-06-25 14:42:07 +0300 | [diff] [blame] | 205 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 206 | /* dapm kcontrol types */ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 207 | #define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 208 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 209 | .info = snd_soc_info_volsw, \ |
| 210 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 211 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
| 212 | #define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, max, invert, \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 213 | power) \ |
| 214 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 215 | .info = snd_soc_info_volsw, \ |
| 216 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
| 217 | .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 218 | ((max) << 16) | ((invert) << 24) } |
| 219 | #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ |
| 220 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 221 | .info = snd_soc_info_volsw, \ |
| 222 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 223 | .tlv.p = (tlv_array), \ |
| 224 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
| 225 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
| 226 | #define SOC_DAPM_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, \ |
| 227 | power, tlv_array) \ |
| 228 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 229 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 230 | .tlv.p = (tlv_array), \ |
| 231 | .info = snd_soc_info_volsw, \ |
| 232 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
| 233 | .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\ |
| 234 | ((max) << 16) | ((invert) << 24) } |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 235 | #define SOC_DAPM_ENUM(xname, xenum) \ |
| 236 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 237 | .info = snd_soc_info_enum_double, \ |
| 238 | .get = snd_soc_dapm_get_enum_double, \ |
| 239 | .put = snd_soc_dapm_put_enum_double, \ |
| 240 | .private_value = (unsigned long)&xenum } |
Mark Brown | d2b247a | 2009-10-06 15:21:04 +0100 | [diff] [blame] | 241 | #define SOC_DAPM_ENUM_VIRT(xname, xenum) \ |
| 242 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 243 | .info = snd_soc_info_enum_double, \ |
| 244 | .get = snd_soc_dapm_get_enum_virt, \ |
| 245 | .put = snd_soc_dapm_put_enum_virt, \ |
| 246 | .private_value = (unsigned long)&xenum } |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 247 | #define SOC_DAPM_VALUE_ENUM(xname, xenum) \ |
| 248 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
Peter Ujfalusi | 7415555 | 2009-01-08 13:34:29 +0200 | [diff] [blame] | 249 | .info = snd_soc_info_enum_double, \ |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 250 | .get = snd_soc_dapm_get_value_enum_double, \ |
| 251 | .put = snd_soc_dapm_put_value_enum_double, \ |
| 252 | .private_value = (unsigned long)&xenum } |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 253 | #define SOC_DAPM_PIN_SWITCH(xname) \ |
| 254 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname " Switch", \ |
| 255 | .info = snd_soc_dapm_info_pin_switch, \ |
| 256 | .get = snd_soc_dapm_get_pin_switch, \ |
| 257 | .put = snd_soc_dapm_put_pin_switch, \ |
| 258 | .private_value = (unsigned long)xname } |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 259 | |
| 260 | /* dapm stream operations */ |
| 261 | #define SND_SOC_DAPM_STREAM_NOP 0x0 |
| 262 | #define SND_SOC_DAPM_STREAM_START 0x1 |
| 263 | #define SND_SOC_DAPM_STREAM_STOP 0x2 |
| 264 | #define SND_SOC_DAPM_STREAM_SUSPEND 0x4 |
| 265 | #define SND_SOC_DAPM_STREAM_RESUME 0x8 |
| 266 | #define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10 |
| 267 | #define SND_SOC_DAPM_STREAM_PAUSE_RELEASE 0x20 |
| 268 | |
| 269 | /* dapm event types */ |
| 270 | #define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */ |
| 271 | #define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */ |
| 272 | #define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */ |
| 273 | #define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */ |
| 274 | #define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */ |
| 275 | #define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */ |
apatard@mandriva.com | ea762b0 | 2010-05-27 14:57:40 +0200 | [diff] [blame] | 276 | #define SND_SOC_DAPM_PRE_POST_PMD \ |
| 277 | (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD) |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 278 | |
| 279 | /* convenience event type detection */ |
| 280 | #define SND_SOC_DAPM_EVENT_ON(e) \ |
| 281 | (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)) |
| 282 | #define SND_SOC_DAPM_EVENT_OFF(e) \ |
| 283 | (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)) |
| 284 | |
| 285 | struct snd_soc_dapm_widget; |
| 286 | enum snd_soc_dapm_type; |
| 287 | struct snd_soc_dapm_path; |
| 288 | struct snd_soc_dapm_pin; |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 289 | struct snd_soc_dapm_route; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 290 | |
Mark Brown | 1158941 | 2008-07-29 11:42:23 +0100 | [diff] [blame] | 291 | int dapm_reg_event(struct snd_soc_dapm_widget *w, |
| 292 | struct snd_kcontrol *kcontrol, int event); |
| 293 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 294 | /* dapm controls */ |
| 295 | int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, |
| 296 | struct snd_ctl_elem_value *ucontrol); |
| 297 | int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, |
| 298 | struct snd_ctl_elem_value *ucontrol); |
| 299 | int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, |
| 300 | struct snd_ctl_elem_value *ucontrol); |
| 301 | int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, |
| 302 | struct snd_ctl_elem_value *ucontrol); |
Mark Brown | d2b247a | 2009-10-06 15:21:04 +0100 | [diff] [blame] | 303 | int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol, |
| 304 | struct snd_ctl_elem_value *ucontrol); |
| 305 | int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol, |
| 306 | struct snd_ctl_elem_value *ucontrol); |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 307 | int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol, |
| 308 | struct snd_ctl_elem_value *ucontrol); |
| 309 | int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, |
| 310 | struct snd_ctl_elem_value *ucontrol); |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 311 | int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, |
| 312 | struct snd_ctl_elem_info *uinfo); |
| 313 | int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, |
| 314 | struct snd_ctl_elem_value *uncontrol); |
| 315 | int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, |
| 316 | struct snd_ctl_elem_value *uncontrol); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 317 | int snd_soc_dapm_new_control(struct snd_soc_codec *codec, |
| 318 | const struct snd_soc_dapm_widget *widget); |
Mark Brown | 4ba1327 | 2008-05-13 14:51:19 +0200 | [diff] [blame] | 319 | int snd_soc_dapm_new_controls(struct snd_soc_codec *codec, |
| 320 | const struct snd_soc_dapm_widget *widget, |
| 321 | int num); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 322 | |
| 323 | /* dapm path setup */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 324 | int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec); |
| 325 | void snd_soc_dapm_free(struct snd_soc_device *socdev); |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 326 | int snd_soc_dapm_add_routes(struct snd_soc_codec *codec, |
| 327 | const struct snd_soc_dapm_route *route, int num); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 328 | |
| 329 | /* dapm events */ |
| 330 | int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream, |
| 331 | int event); |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 332 | void snd_soc_dapm_shutdown(struct snd_soc_device *socdev); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 333 | |
| 334 | /* dapm sys fs - used by the core */ |
| 335 | int snd_soc_dapm_sys_add(struct device *dev); |
Mark Brown | 79fb938 | 2009-08-21 16:38:13 +0100 | [diff] [blame] | 336 | void snd_soc_dapm_debugfs_init(struct snd_soc_codec *codec); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 337 | |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 338 | /* dapm audio pin control and status */ |
Mark Brown | 1649923 | 2009-01-07 18:25:13 +0000 | [diff] [blame] | 339 | int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, const char *pin); |
| 340 | int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin); |
| 341 | int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, const char *pin); |
| 342 | int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, const char *pin); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 343 | int snd_soc_dapm_sync(struct snd_soc_codec *codec); |
Mark Brown | da34183 | 2010-03-15 19:23:37 +0000 | [diff] [blame] | 344 | int snd_soc_dapm_force_enable_pin(struct snd_soc_codec *codec, |
| 345 | const char *pin); |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 346 | int snd_soc_dapm_ignore_suspend(struct snd_soc_codec *codec, const char *pin); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 347 | |
| 348 | /* dapm widget types */ |
| 349 | enum snd_soc_dapm_type { |
| 350 | snd_soc_dapm_input = 0, /* input pin */ |
| 351 | snd_soc_dapm_output, /* output pin */ |
| 352 | snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 353 | snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 354 | snd_soc_dapm_mixer, /* mixes several analog signals together */ |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 355 | snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 356 | snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ |
| 357 | snd_soc_dapm_adc, /* analog to digital converter */ |
| 358 | snd_soc_dapm_dac, /* digital to analog converter */ |
| 359 | snd_soc_dapm_micbias, /* microphone bias (power) */ |
| 360 | snd_soc_dapm_mic, /* microphone */ |
| 361 | snd_soc_dapm_hp, /* headphones */ |
| 362 | snd_soc_dapm_spk, /* speaker */ |
| 363 | snd_soc_dapm_line, /* line input/output */ |
| 364 | snd_soc_dapm_switch, /* analog switch */ |
| 365 | snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */ |
| 366 | snd_soc_dapm_pre, /* machine specific pre widget - exec first */ |
| 367 | snd_soc_dapm_post, /* machine specific post widget - exec last */ |
Mark Brown | 246d0a1 | 2009-04-22 18:24:55 +0100 | [diff] [blame] | 368 | snd_soc_dapm_supply, /* power/clock supply */ |
Mark Brown | 010ff26 | 2009-08-17 17:39:22 +0100 | [diff] [blame] | 369 | snd_soc_dapm_aif_in, /* audio interface input */ |
| 370 | snd_soc_dapm_aif_out, /* audio interface output */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 371 | }; |
| 372 | |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 373 | /* |
| 374 | * DAPM audio route definition. |
| 375 | * |
| 376 | * Defines an audio route originating at source via control and finishing |
| 377 | * at sink. |
| 378 | */ |
| 379 | struct snd_soc_dapm_route { |
| 380 | const char *sink; |
| 381 | const char *control; |
| 382 | const char *source; |
Mark Brown | 215edda | 2009-09-08 18:59:05 +0100 | [diff] [blame] | 383 | |
| 384 | /* Note: currently only supported for links where source is a supply */ |
| 385 | int (*connected)(struct snd_soc_dapm_widget *source, |
| 386 | struct snd_soc_dapm_widget *sink); |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 387 | }; |
| 388 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 389 | /* dapm audio path between two widgets */ |
| 390 | struct snd_soc_dapm_path { |
| 391 | char *name; |
| 392 | char *long_name; |
| 393 | |
| 394 | /* source (input) and sink (output) widgets */ |
| 395 | struct snd_soc_dapm_widget *source; |
| 396 | struct snd_soc_dapm_widget *sink; |
| 397 | struct snd_kcontrol *kcontrol; |
| 398 | |
| 399 | /* status */ |
| 400 | u32 connect:1; /* source and sink widgets are connected */ |
| 401 | u32 walked:1; /* path has been walked */ |
| 402 | |
Mark Brown | 215edda | 2009-09-08 18:59:05 +0100 | [diff] [blame] | 403 | int (*connected)(struct snd_soc_dapm_widget *source, |
| 404 | struct snd_soc_dapm_widget *sink); |
| 405 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 406 | struct list_head list_source; |
| 407 | struct list_head list_sink; |
| 408 | struct list_head list; |
| 409 | }; |
| 410 | |
| 411 | /* dapm widget */ |
| 412 | struct snd_soc_dapm_widget { |
| 413 | enum snd_soc_dapm_type id; |
| 414 | char *name; /* widget name */ |
| 415 | char *sname; /* stream name */ |
| 416 | struct snd_soc_codec *codec; |
| 417 | struct list_head list; |
| 418 | |
| 419 | /* dapm control */ |
| 420 | short reg; /* negative reg = no direct dapm */ |
| 421 | unsigned char shift; /* bits to shift */ |
| 422 | unsigned int saved_value; /* widget saved value */ |
| 423 | unsigned int value; /* widget current value */ |
Jarkko Nikula | e2be2cc | 2008-06-25 14:42:07 +0300 | [diff] [blame] | 424 | unsigned int mask; /* non-shifted mask */ |
| 425 | unsigned int on_val; /* on state value */ |
| 426 | unsigned int off_val; /* off state value */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 427 | unsigned char power:1; /* block power status */ |
| 428 | unsigned char invert:1; /* invert the power bit */ |
| 429 | unsigned char active:1; /* active stream on DAC, ADC's */ |
| 430 | unsigned char connected:1; /* connected codec pin */ |
| 431 | unsigned char new:1; /* cnew complete */ |
| 432 | unsigned char ext:1; /* has external widgets */ |
Mark Brown | da34183 | 2010-03-15 19:23:37 +0000 | [diff] [blame] | 433 | unsigned char force:1; /* force state */ |
Mark Brown | 1547aba | 2010-05-07 21:11:40 +0100 | [diff] [blame] | 434 | unsigned char ignore_suspend:1; /* kept enabled over suspend */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 435 | |
Mark Brown | b75576d | 2009-04-20 17:56:13 +0100 | [diff] [blame] | 436 | int (*power_check)(struct snd_soc_dapm_widget *w); |
| 437 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 438 | /* external events */ |
| 439 | unsigned short event_flags; /* flags to specify event types */ |
Laim Girdwood | 9af6d95 | 2008-01-10 14:41:02 +0100 | [diff] [blame] | 440 | int (*event)(struct snd_soc_dapm_widget*, struct snd_kcontrol *, int); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 441 | |
| 442 | /* kcontrols that relate to this widget */ |
| 443 | int num_kcontrols; |
| 444 | const struct snd_kcontrol_new *kcontrols; |
| 445 | |
| 446 | /* widget input and outputs */ |
| 447 | struct list_head sources; |
| 448 | struct list_head sinks; |
Mark Brown | 6d3ddc8 | 2009-05-16 17:47:29 +0100 | [diff] [blame] | 449 | |
| 450 | /* used during DAPM updates */ |
| 451 | struct list_head power_list; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 452 | }; |
| 453 | |
| 454 | #endif |