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 | |
| 98 | /* path domain with event - event handler must return 0 for success */ |
| 99 | #define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \ |
| 100 | wncontrols, wevent, wflags) \ |
| 101 | { .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ |
| 102 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ |
| 103 | .event = wevent, .event_flags = wflags} |
| 104 | #define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \ |
| 105 | wncontrols, wevent, wflags) \ |
| 106 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ |
| 107 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ |
| 108 | .event = wevent, .event_flags = wflags} |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 109 | #define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \ |
| 110 | wcontrols, wncontrols, wevent, wflags) \ |
| 111 | { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ |
| 112 | .invert = winvert, .kcontrols = wcontrols, \ |
| 113 | .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags} |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 114 | #define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \ |
| 115 | { .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ |
| 116 | .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \ |
| 117 | .event = wevent, .event_flags = wflags} |
| 118 | #define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \ |
| 119 | wevent, wflags) \ |
| 120 | { .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ |
Peter Ujfalusi | 43d5080 | 2009-01-23 10:08:35 +0200 | [diff] [blame] | 121 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 122 | .event = wevent, .event_flags = wflags} |
| 123 | #define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \ |
| 124 | wevent, wflags) \ |
| 125 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ |
| 126 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ |
| 127 | .event = wevent, .event_flags = wflags} |
| 128 | |
| 129 | /* events that are pre and post DAPM */ |
| 130 | #define SND_SOC_DAPM_PRE(wname, wevent) \ |
| 131 | { .id = snd_soc_dapm_pre, .name = wname, .kcontrols = NULL, \ |
| 132 | .num_kcontrols = 0, .event = wevent, \ |
| 133 | .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD} |
| 134 | #define SND_SOC_DAPM_POST(wname, wevent) \ |
| 135 | { .id = snd_soc_dapm_post, .name = wname, .kcontrols = NULL, \ |
| 136 | .num_kcontrols = 0, .event = wevent, \ |
| 137 | .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD} |
| 138 | |
| 139 | /* stream domain */ |
| 140 | #define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \ |
| 141 | { .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \ |
| 142 | .shift = wshift, .invert = winvert} |
| 143 | #define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \ |
| 144 | { .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \ |
| 145 | .shift = wshift, .invert = winvert} |
| 146 | |
Jarkko Nikula | e2be2cc | 2008-06-25 14:42:07 +0300 | [diff] [blame] | 147 | /* generic register modifier widget */ |
| 148 | #define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \ |
| 149 | { .id = wid, .name = wname, .kcontrols = NULL, .num_kcontrols = 0, \ |
| 150 | .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \ |
| 151 | .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \ |
| 152 | .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} |
| 153 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 154 | /* dapm kcontrol types */ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 155 | #define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 156 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 157 | .info = snd_soc_info_volsw, \ |
| 158 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 159 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
| 160 | #define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, max, invert, \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 161 | power) \ |
| 162 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 163 | .info = snd_soc_info_volsw, \ |
| 164 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
| 165 | .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 166 | ((max) << 16) | ((invert) << 24) } |
| 167 | #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ |
| 168 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 169 | .info = snd_soc_info_volsw, \ |
| 170 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 171 | .tlv.p = (tlv_array), \ |
| 172 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
| 173 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
| 174 | #define SOC_DAPM_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, \ |
| 175 | power, tlv_array) \ |
| 176 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 177 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 178 | .tlv.p = (tlv_array), \ |
| 179 | .info = snd_soc_info_volsw, \ |
| 180 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
| 181 | .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\ |
| 182 | ((max) << 16) | ((invert) << 24) } |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 183 | #define SOC_DAPM_ENUM(xname, xenum) \ |
| 184 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 185 | .info = snd_soc_info_enum_double, \ |
| 186 | .get = snd_soc_dapm_get_enum_double, \ |
| 187 | .put = snd_soc_dapm_put_enum_double, \ |
| 188 | .private_value = (unsigned long)&xenum } |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 189 | #define SOC_DAPM_VALUE_ENUM(xname, xenum) \ |
| 190 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
Peter Ujfalusi | 7415555 | 2009-01-08 13:34:29 +0200 | [diff] [blame] | 191 | .info = snd_soc_info_enum_double, \ |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 192 | .get = snd_soc_dapm_get_value_enum_double, \ |
| 193 | .put = snd_soc_dapm_put_value_enum_double, \ |
| 194 | .private_value = (unsigned long)&xenum } |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 195 | #define SOC_DAPM_PIN_SWITCH(xname) \ |
| 196 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname " Switch", \ |
| 197 | .info = snd_soc_dapm_info_pin_switch, \ |
| 198 | .get = snd_soc_dapm_get_pin_switch, \ |
| 199 | .put = snd_soc_dapm_put_pin_switch, \ |
| 200 | .private_value = (unsigned long)xname } |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 201 | |
| 202 | /* dapm stream operations */ |
| 203 | #define SND_SOC_DAPM_STREAM_NOP 0x0 |
| 204 | #define SND_SOC_DAPM_STREAM_START 0x1 |
| 205 | #define SND_SOC_DAPM_STREAM_STOP 0x2 |
| 206 | #define SND_SOC_DAPM_STREAM_SUSPEND 0x4 |
| 207 | #define SND_SOC_DAPM_STREAM_RESUME 0x8 |
| 208 | #define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10 |
| 209 | #define SND_SOC_DAPM_STREAM_PAUSE_RELEASE 0x20 |
| 210 | |
| 211 | /* dapm event types */ |
| 212 | #define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */ |
| 213 | #define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */ |
| 214 | #define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */ |
| 215 | #define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */ |
| 216 | #define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */ |
| 217 | #define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */ |
| 218 | |
| 219 | /* convenience event type detection */ |
| 220 | #define SND_SOC_DAPM_EVENT_ON(e) \ |
| 221 | (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)) |
| 222 | #define SND_SOC_DAPM_EVENT_OFF(e) \ |
| 223 | (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)) |
| 224 | |
| 225 | struct snd_soc_dapm_widget; |
| 226 | enum snd_soc_dapm_type; |
| 227 | struct snd_soc_dapm_path; |
| 228 | struct snd_soc_dapm_pin; |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 229 | struct snd_soc_dapm_route; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 230 | |
Mark Brown | 1158941 | 2008-07-29 11:42:23 +0100 | [diff] [blame] | 231 | int dapm_reg_event(struct snd_soc_dapm_widget *w, |
| 232 | struct snd_kcontrol *kcontrol, int event); |
| 233 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 234 | /* dapm controls */ |
| 235 | int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, |
| 236 | struct snd_ctl_elem_value *ucontrol); |
| 237 | int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, |
| 238 | struct snd_ctl_elem_value *ucontrol); |
| 239 | int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, |
| 240 | struct snd_ctl_elem_value *ucontrol); |
| 241 | int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, |
| 242 | struct snd_ctl_elem_value *ucontrol); |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 243 | int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol, |
| 244 | struct snd_ctl_elem_value *ucontrol); |
| 245 | int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, |
| 246 | struct snd_ctl_elem_value *ucontrol); |
Mark Brown | 8b37dbd | 2009-02-28 21:14:20 +0000 | [diff] [blame] | 247 | int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, |
| 248 | struct snd_ctl_elem_info *uinfo); |
| 249 | int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, |
| 250 | struct snd_ctl_elem_value *uncontrol); |
| 251 | int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, |
| 252 | struct snd_ctl_elem_value *uncontrol); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 253 | int snd_soc_dapm_new_control(struct snd_soc_codec *codec, |
| 254 | const struct snd_soc_dapm_widget *widget); |
Mark Brown | 4ba1327 | 2008-05-13 14:51:19 +0200 | [diff] [blame] | 255 | int snd_soc_dapm_new_controls(struct snd_soc_codec *codec, |
| 256 | const struct snd_soc_dapm_widget *widget, |
| 257 | int num); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 258 | |
| 259 | /* dapm path setup */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 260 | int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec); |
| 261 | void snd_soc_dapm_free(struct snd_soc_device *socdev); |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 262 | int snd_soc_dapm_add_routes(struct snd_soc_codec *codec, |
| 263 | const struct snd_soc_dapm_route *route, int num); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 264 | |
| 265 | /* dapm events */ |
| 266 | int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream, |
| 267 | int event); |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 268 | int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev, |
| 269 | enum snd_soc_bias_level level); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 270 | |
| 271 | /* dapm sys fs - used by the core */ |
| 272 | int snd_soc_dapm_sys_add(struct device *dev); |
| 273 | |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 274 | /* dapm audio pin control and status */ |
Mark Brown | 1649923 | 2009-01-07 18:25:13 +0000 | [diff] [blame] | 275 | int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, const char *pin); |
| 276 | int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin); |
| 277 | int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, const char *pin); |
| 278 | 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] | 279 | int snd_soc_dapm_sync(struct snd_soc_codec *codec); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 280 | |
| 281 | /* dapm widget types */ |
| 282 | enum snd_soc_dapm_type { |
| 283 | snd_soc_dapm_input = 0, /* input pin */ |
| 284 | snd_soc_dapm_output, /* output pin */ |
| 285 | snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 286 | snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 287 | snd_soc_dapm_mixer, /* mixes several analog signals together */ |
Ian Molton | ca9c1aa | 2009-01-06 20:11:51 +0000 | [diff] [blame] | 288 | snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 289 | snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ |
| 290 | snd_soc_dapm_adc, /* analog to digital converter */ |
| 291 | snd_soc_dapm_dac, /* digital to analog converter */ |
| 292 | snd_soc_dapm_micbias, /* microphone bias (power) */ |
| 293 | snd_soc_dapm_mic, /* microphone */ |
| 294 | snd_soc_dapm_hp, /* headphones */ |
| 295 | snd_soc_dapm_spk, /* speaker */ |
| 296 | snd_soc_dapm_line, /* line input/output */ |
| 297 | snd_soc_dapm_switch, /* analog switch */ |
| 298 | snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */ |
| 299 | snd_soc_dapm_pre, /* machine specific pre widget - exec first */ |
| 300 | snd_soc_dapm_post, /* machine specific post widget - exec last */ |
| 301 | }; |
| 302 | |
Mark Brown | 105f1c2 | 2008-05-13 14:52:19 +0200 | [diff] [blame] | 303 | /* |
| 304 | * DAPM audio route definition. |
| 305 | * |
| 306 | * Defines an audio route originating at source via control and finishing |
| 307 | * at sink. |
| 308 | */ |
| 309 | struct snd_soc_dapm_route { |
| 310 | const char *sink; |
| 311 | const char *control; |
| 312 | const char *source; |
| 313 | }; |
| 314 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 315 | /* dapm audio path between two widgets */ |
| 316 | struct snd_soc_dapm_path { |
| 317 | char *name; |
| 318 | char *long_name; |
| 319 | |
| 320 | /* source (input) and sink (output) widgets */ |
| 321 | struct snd_soc_dapm_widget *source; |
| 322 | struct snd_soc_dapm_widget *sink; |
| 323 | struct snd_kcontrol *kcontrol; |
| 324 | |
| 325 | /* status */ |
| 326 | u32 connect:1; /* source and sink widgets are connected */ |
| 327 | u32 walked:1; /* path has been walked */ |
| 328 | |
| 329 | struct list_head list_source; |
| 330 | struct list_head list_sink; |
| 331 | struct list_head list; |
| 332 | }; |
| 333 | |
| 334 | /* dapm widget */ |
| 335 | struct snd_soc_dapm_widget { |
| 336 | enum snd_soc_dapm_type id; |
| 337 | char *name; /* widget name */ |
| 338 | char *sname; /* stream name */ |
| 339 | struct snd_soc_codec *codec; |
| 340 | struct list_head list; |
| 341 | |
| 342 | /* dapm control */ |
| 343 | short reg; /* negative reg = no direct dapm */ |
| 344 | unsigned char shift; /* bits to shift */ |
| 345 | unsigned int saved_value; /* widget saved value */ |
| 346 | unsigned int value; /* widget current value */ |
Jarkko Nikula | e2be2cc | 2008-06-25 14:42:07 +0300 | [diff] [blame] | 347 | unsigned int mask; /* non-shifted mask */ |
| 348 | unsigned int on_val; /* on state value */ |
| 349 | unsigned int off_val; /* off state value */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 350 | unsigned char power:1; /* block power status */ |
| 351 | unsigned char invert:1; /* invert the power bit */ |
| 352 | unsigned char active:1; /* active stream on DAC, ADC's */ |
| 353 | unsigned char connected:1; /* connected codec pin */ |
| 354 | unsigned char new:1; /* cnew complete */ |
| 355 | unsigned char ext:1; /* has external widgets */ |
| 356 | unsigned char muted:1; /* muted for pop reduction */ |
| 357 | unsigned char suspend:1; /* was active before suspend */ |
| 358 | unsigned char pmdown:1; /* waiting for timeout */ |
| 359 | |
| 360 | /* external events */ |
| 361 | unsigned short event_flags; /* flags to specify event types */ |
Laim Girdwood | 9af6d95 | 2008-01-10 14:41:02 +0100 | [diff] [blame] | 362 | int (*event)(struct snd_soc_dapm_widget*, struct snd_kcontrol *, int); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 363 | |
| 364 | /* kcontrols that relate to this widget */ |
| 365 | int num_kcontrols; |
| 366 | const struct snd_kcontrol_new *kcontrols; |
| 367 | |
| 368 | /* widget input and outputs */ |
| 369 | struct list_head sources; |
| 370 | struct list_head sinks; |
| 371 | }; |
| 372 | |
| 373 | #endif |