Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/sound/soc.h -- ALSA SoC Layer |
| 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_H |
| 14 | #define __LINUX_SND_SOC_H |
| 15 | |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/types.h> |
Andrew Morton | 4484bb2 | 2006-12-15 09:30:07 +0100 | [diff] [blame] | 18 | #include <linux/workqueue.h> |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 19 | #include <sound/core.h> |
| 20 | #include <sound/pcm.h> |
| 21 | #include <sound/control.h> |
| 22 | #include <sound/ac97_codec.h> |
| 23 | |
Mark Brown | 0a22b87 | 2008-01-10 14:53:48 +0100 | [diff] [blame] | 24 | #define SND_SOC_VERSION "0.13.2" |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * Convenience kcontrol builders |
| 28 | */ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 29 | #define SOC_SINGLE_VALUE(reg, shift, max, invert) ((reg) | ((shift) << 8) |\ |
| 30 | ((shift) << 12) | ((max) << 16) | ((invert) << 24)) |
| 31 | #define SOC_SINGLE_VALUE_EXT(reg, max, invert) ((reg) | ((max) << 16) |\ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 32 | ((invert) << 31)) |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 33 | #define SOC_SINGLE(xname, reg, shift, max, invert) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 34 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 35 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ |
| 36 | .put = snd_soc_put_volsw, \ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 37 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
| 38 | #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ |
| 39 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 40 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 41 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 42 | .tlv.p = (tlv_array), \ |
| 43 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ |
| 44 | .put = snd_soc_put_volsw, \ |
| 45 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
| 46 | #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 47 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
| 48 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ |
| 49 | .put = snd_soc_put_volsw, \ |
| 50 | .private_value = (reg) | ((shift_left) << 8) | \ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 51 | ((shift_right) << 12) | ((max) << 16) | ((invert) << 24) } |
| 52 | #define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, max, invert) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 53 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 54 | .info = snd_soc_info_volsw_2r, \ |
| 55 | .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ |
| 56 | .private_value = (reg_left) | ((shift) << 8) | \ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 57 | ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) } |
| 58 | #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \ |
| 59 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
| 60 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 61 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 62 | .tlv.p = (tlv_array), \ |
| 63 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ |
| 64 | .put = snd_soc_put_volsw, \ |
| 65 | .private_value = (reg) | ((shift_left) << 8) | \ |
| 66 | ((shift_right) << 12) | ((max) << 16) | ((invert) << 24) } |
| 67 | #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, shift, max, invert, tlv_array) \ |
| 68 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
| 69 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 70 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 71 | .tlv.p = (tlv_array), \ |
| 72 | .info = snd_soc_info_volsw_2r, \ |
| 73 | .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ |
| 74 | .private_value = (reg_left) | ((shift) << 8) | \ |
| 75 | ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) } |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 76 | #define SOC_DOUBLE_S8_TLV(xname, reg, min, max, tlv_array) \ |
| 77 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 78 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 79 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 80 | .tlv.p = (tlv_array), \ |
| 81 | .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \ |
| 82 | .put = snd_soc_put_volsw_s8, \ |
| 83 | .private_value = (reg) | (((signed char)max) << 16) | \ |
| 84 | (((signed char)min) << 24) } |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 85 | #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \ |
| 86 | { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ |
| 87 | .mask = xmask, .texts = xtexts } |
| 88 | #define SOC_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \ |
| 89 | SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts) |
| 90 | #define SOC_ENUM_SINGLE_EXT(xmask, xtexts) \ |
| 91 | { .mask = xmask, .texts = xtexts } |
| 92 | #define SOC_ENUM(xname, xenum) \ |
| 93 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ |
| 94 | .info = snd_soc_info_enum_double, \ |
| 95 | .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ |
| 96 | .private_value = (unsigned long)&xenum } |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 97 | #define SOC_SINGLE_EXT(xname, xreg, xshift, xmask, xinvert,\ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 98 | xhandler_get, xhandler_put) \ |
| 99 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 100 | .info = snd_soc_info_volsw, \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 101 | .get = xhandler_get, .put = xhandler_put, \ |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 102 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) } |
Mike Montour | 10144c0 | 2008-06-11 13:47:13 +0100 | [diff] [blame] | 103 | #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmask, xinvert,\ |
| 104 | xhandler_get, xhandler_put, tlv_array) \ |
| 105 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 106 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 107 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 108 | .tlv.p = (tlv_array), \ |
| 109 | .info = snd_soc_info_volsw, \ |
| 110 | .get = xhandler_get, .put = xhandler_put, \ |
| 111 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) } |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 112 | #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ |
| 113 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 114 | .info = snd_soc_info_bool_ext, \ |
| 115 | .get = xhandler_get, .put = xhandler_put, \ |
| 116 | .private_value = xdata } |
| 117 | #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \ |
| 118 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 119 | .info = snd_soc_info_enum_ext, \ |
| 120 | .get = xhandler_get, .put = xhandler_put, \ |
| 121 | .private_value = (unsigned long)&xenum } |
| 122 | |
| 123 | /* |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 124 | * Bias levels |
| 125 | * |
| 126 | * @ON: Bias is fully on for audio playback and capture operations. |
| 127 | * @PREPARE: Prepare for audio operations. Called before DAPM switching for |
| 128 | * stream start and stop operations. |
| 129 | * @STANDBY: Low power standby state when no playback/capture operations are |
| 130 | * in progress. NOTE: The transition time between STANDBY and ON |
| 131 | * should be as fast as possible and no longer than 10ms. |
| 132 | * @OFF: Power Off. No restrictions on transition times. |
| 133 | */ |
| 134 | enum snd_soc_bias_level { |
| 135 | SND_SOC_BIAS_ON, |
| 136 | SND_SOC_BIAS_PREPARE, |
| 137 | SND_SOC_BIAS_STANDBY, |
| 138 | SND_SOC_BIAS_OFF, |
| 139 | }; |
| 140 | |
| 141 | /* |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 142 | * Digital Audio Interface (DAI) types |
| 143 | */ |
| 144 | #define SND_SOC_DAI_AC97 0x1 |
| 145 | #define SND_SOC_DAI_I2S 0x2 |
| 146 | #define SND_SOC_DAI_PCM 0x4 |
Liam Girdwood | a68660e | 2007-05-10 19:27:27 +0200 | [diff] [blame] | 147 | #define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 148 | |
| 149 | /* |
| 150 | * DAI hardware audio formats |
| 151 | */ |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 152 | #define SND_SOC_DAIFMT_I2S 0 /* I2S mode */ |
| 153 | #define SND_SOC_DAIFMT_RIGHT_J 1 /* Right justified mode */ |
| 154 | #define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */ |
| 155 | #define SND_SOC_DAIFMT_DSP_A 3 /* L data msb after FRM or LRC */ |
| 156 | #define SND_SOC_DAIFMT_DSP_B 4 /* L data msb during FRM or LRC */ |
| 157 | #define SND_SOC_DAIFMT_AC97 5 /* AC97 */ |
| 158 | |
| 159 | #define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J |
| 160 | #define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J |
| 161 | |
| 162 | /* |
| 163 | * DAI Gating |
| 164 | */ |
| 165 | #define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */ |
| 166 | #define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 167 | |
| 168 | /* |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 169 | * DAI Sync |
| 170 | * Synchronous LR (Left Right) clocks and Frame signals. |
| 171 | */ |
| 172 | #define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */ |
| 173 | #define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */ |
| 174 | |
| 175 | /* |
| 176 | * TDM |
| 177 | */ |
| 178 | #define SND_SOC_DAIFMT_TDM (1 << 6) |
| 179 | |
| 180 | /* |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 181 | * DAI hardware signal inversions |
| 182 | */ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 183 | #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */ |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 184 | #define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */ |
| 185 | #define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */ |
| 186 | #define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 187 | |
| 188 | /* |
| 189 | * DAI hardware clock masters |
| 190 | * This is wrt the codec, the inverse is true for the interface |
| 191 | * i.e. if the codec is clk and frm master then the interface is |
| 192 | * clk and frame slave. |
| 193 | */ |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 194 | #define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */ |
| 195 | #define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */ |
| 196 | #define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */ |
| 197 | #define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 198 | |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 199 | #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f |
| 200 | #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0 |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 201 | #define SND_SOC_DAIFMT_INV_MASK 0x0f00 |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 202 | #define SND_SOC_DAIFMT_MASTER_MASK 0xf000 |
| 203 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 204 | |
| 205 | /* |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 206 | * Master Clock Directions |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 207 | */ |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 208 | #define SND_SOC_CLOCK_IN 0 |
| 209 | #define SND_SOC_CLOCK_OUT 1 |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 210 | |
| 211 | /* |
| 212 | * AC97 codec ID's bitmask |
| 213 | */ |
| 214 | #define SND_SOC_DAI_AC97_ID0 (1 << 0) |
| 215 | #define SND_SOC_DAI_AC97_ID1 (1 << 1) |
| 216 | #define SND_SOC_DAI_AC97_ID2 (1 << 2) |
| 217 | #define SND_SOC_DAI_AC97_ID3 (1 << 3) |
| 218 | |
| 219 | struct snd_soc_device; |
| 220 | struct snd_soc_pcm_stream; |
| 221 | struct snd_soc_ops; |
| 222 | struct snd_soc_dai_mode; |
| 223 | struct snd_soc_pcm_runtime; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 224 | struct snd_soc_dai; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 225 | struct snd_soc_codec; |
| 226 | struct snd_soc_machine_config; |
| 227 | struct soc_enum; |
| 228 | struct snd_soc_ac97_ops; |
| 229 | struct snd_soc_clock_info; |
| 230 | |
| 231 | typedef int (*hw_write_t)(void *,const char* ,int); |
| 232 | typedef int (*hw_read_t)(void *,char* ,int); |
| 233 | |
| 234 | extern struct snd_ac97_bus_ops soc_ac97_ops; |
| 235 | |
| 236 | /* pcm <-> DAI connect */ |
| 237 | void snd_soc_free_pcms(struct snd_soc_device *socdev); |
| 238 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); |
| 239 | int snd_soc_register_card(struct snd_soc_device *socdev); |
| 240 | |
| 241 | /* set runtime hw params */ |
| 242 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, |
| 243 | const struct snd_pcm_hardware *hw); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 244 | |
| 245 | /* codec IO */ |
| 246 | #define snd_soc_read(codec, reg) codec->read(codec, reg) |
| 247 | #define snd_soc_write(codec, reg, value) codec->write(codec, reg, value) |
| 248 | |
| 249 | /* codec register bit access */ |
| 250 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, |
| 251 | unsigned short mask, unsigned short value); |
| 252 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, |
| 253 | unsigned short mask, unsigned short value); |
| 254 | |
| 255 | int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, |
| 256 | struct snd_ac97_bus_ops *ops, int num); |
| 257 | void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); |
| 258 | |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 259 | /* Digital Audio Interface clocking API.*/ |
| 260 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, |
| 261 | unsigned int freq, int dir); |
| 262 | |
| 263 | int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, |
| 264 | int div_id, int div); |
| 265 | |
| 266 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, |
| 267 | int pll_id, unsigned int freq_in, unsigned int freq_out); |
| 268 | |
| 269 | /* Digital Audio interface formatting */ |
| 270 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt); |
| 271 | |
| 272 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, |
| 273 | unsigned int mask, int slots); |
| 274 | |
| 275 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); |
| 276 | |
| 277 | /* Digital Audio Interface mute */ |
| 278 | int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute); |
| 279 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 280 | /* |
| 281 | *Controls |
| 282 | */ |
| 283 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, |
| 284 | void *data, char *long_name); |
| 285 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, |
| 286 | struct snd_ctl_elem_info *uinfo); |
| 287 | int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, |
| 288 | struct snd_ctl_elem_info *uinfo); |
| 289 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, |
| 290 | struct snd_ctl_elem_value *ucontrol); |
| 291 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, |
| 292 | struct snd_ctl_elem_value *ucontrol); |
| 293 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, |
| 294 | struct snd_ctl_elem_info *uinfo); |
| 295 | int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, |
| 296 | struct snd_ctl_elem_info *uinfo); |
Philipp Zabel | 392abe9 | 2008-05-13 14:03:40 +0200 | [diff] [blame] | 297 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 298 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, |
| 299 | struct snd_ctl_elem_value *ucontrol); |
| 300 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, |
| 301 | struct snd_ctl_elem_value *ucontrol); |
| 302 | int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, |
| 303 | struct snd_ctl_elem_info *uinfo); |
| 304 | int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, |
| 305 | struct snd_ctl_elem_value *ucontrol); |
| 306 | int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, |
| 307 | struct snd_ctl_elem_value *ucontrol); |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 308 | int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, |
| 309 | struct snd_ctl_elem_info *uinfo); |
| 310 | int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, |
| 311 | struct snd_ctl_elem_value *ucontrol); |
| 312 | int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, |
| 313 | struct snd_ctl_elem_value *ucontrol); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 314 | |
| 315 | /* SoC PCM stream information */ |
| 316 | struct snd_soc_pcm_stream { |
| 317 | char *stream_name; |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 318 | u64 formats; /* SNDRV_PCM_FMTBIT_* */ |
| 319 | unsigned int rates; /* SNDRV_PCM_RATE_* */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 320 | unsigned int rate_min; /* min rate */ |
| 321 | unsigned int rate_max; /* max rate */ |
| 322 | unsigned int channels_min; /* min channels */ |
| 323 | unsigned int channels_max; /* max channels */ |
| 324 | unsigned int active:1; /* stream is in use */ |
| 325 | }; |
| 326 | |
| 327 | /* SoC audio ops */ |
| 328 | struct snd_soc_ops { |
| 329 | int (*startup)(struct snd_pcm_substream *); |
| 330 | void (*shutdown)(struct snd_pcm_substream *); |
| 331 | int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); |
| 332 | int (*hw_free)(struct snd_pcm_substream *); |
| 333 | int (*prepare)(struct snd_pcm_substream *); |
| 334 | int (*trigger)(struct snd_pcm_substream *, int); |
| 335 | }; |
| 336 | |
Mark Brown | 1ef6ab7 | 2008-05-19 12:31:55 +0200 | [diff] [blame] | 337 | /* ASoC DAI ops */ |
| 338 | struct snd_soc_dai_ops { |
| 339 | /* DAI clocking configuration */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 340 | int (*set_sysclk)(struct snd_soc_dai *dai, |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 341 | int clk_id, unsigned int freq, int dir); |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 342 | int (*set_pll)(struct snd_soc_dai *dai, |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 343 | int pll_id, unsigned int freq_in, unsigned int freq_out); |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 344 | int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div); |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 345 | |
Mark Brown | 1ef6ab7 | 2008-05-19 12:31:55 +0200 | [diff] [blame] | 346 | /* DAI format configuration */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 347 | int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt); |
| 348 | int (*set_tdm_slot)(struct snd_soc_dai *dai, |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 349 | unsigned int mask, int slots); |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 350 | int (*set_tristate)(struct snd_soc_dai *dai, int tristate); |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 351 | |
| 352 | /* digital mute */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 353 | int (*digital_mute)(struct snd_soc_dai *dai, int mute); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 354 | }; |
| 355 | |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 356 | /* SoC DAI (Digital Audio Interface) */ |
| 357 | struct snd_soc_dai { |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 358 | /* DAI description */ |
| 359 | char *name; |
| 360 | unsigned int id; |
| 361 | unsigned char type; |
| 362 | |
| 363 | /* DAI callbacks */ |
Mark Brown | bdb9287 | 2008-06-11 13:47:10 +0100 | [diff] [blame] | 364 | int (*probe)(struct platform_device *pdev, |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 365 | struct snd_soc_dai *dai); |
Mark Brown | bdb9287 | 2008-06-11 13:47:10 +0100 | [diff] [blame] | 366 | void (*remove)(struct platform_device *pdev, |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 367 | struct snd_soc_dai *dai); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 368 | int (*suspend)(struct platform_device *pdev, |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 369 | struct snd_soc_dai *dai); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 370 | int (*resume)(struct platform_device *pdev, |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 371 | struct snd_soc_dai *dai); |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 372 | |
| 373 | /* ops */ |
| 374 | struct snd_soc_ops ops; |
Mark Brown | 1ef6ab7 | 2008-05-19 12:31:55 +0200 | [diff] [blame] | 375 | struct snd_soc_dai_ops dai_ops; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 376 | |
| 377 | /* DAI capabilities */ |
| 378 | struct snd_soc_pcm_stream capture; |
| 379 | struct snd_soc_pcm_stream playback; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 380 | |
| 381 | /* DAI runtime info */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 382 | struct snd_pcm_runtime *runtime; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 383 | struct snd_soc_codec *codec; |
| 384 | unsigned int active; |
| 385 | unsigned char pop_wait:1; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 386 | void *dma_data; |
| 387 | |
| 388 | /* DAI private data */ |
| 389 | void *private_data; |
| 390 | }; |
| 391 | |
| 392 | /* SoC Audio Codec */ |
| 393 | struct snd_soc_codec { |
| 394 | char *name; |
| 395 | struct module *owner; |
| 396 | struct mutex mutex; |
| 397 | |
| 398 | /* callbacks */ |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 399 | int (*set_bias_level)(struct snd_soc_codec *, |
| 400 | enum snd_soc_bias_level level); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 401 | |
| 402 | /* runtime */ |
| 403 | struct snd_card *card; |
| 404 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ |
| 405 | unsigned int active; |
| 406 | unsigned int pcm_devs; |
| 407 | void *private_data; |
| 408 | |
| 409 | /* codec IO */ |
| 410 | void *control_data; /* codec control (i2c/3wire) data */ |
| 411 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); |
| 412 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); |
| 413 | hw_write_t hw_write; |
| 414 | hw_read_t hw_read; |
| 415 | void *reg_cache; |
| 416 | short reg_cache_size; |
| 417 | short reg_cache_step; |
| 418 | |
| 419 | /* dapm */ |
| 420 | struct list_head dapm_widgets; |
| 421 | struct list_head dapm_paths; |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 422 | enum snd_soc_bias_level bias_level; |
| 423 | enum snd_soc_bias_level suspend_bias_level; |
Takashi Iwai | 1321b16 | 2006-12-21 11:02:06 +0100 | [diff] [blame] | 424 | struct delayed_work delayed_work; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 425 | |
| 426 | /* codec DAI's */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 427 | struct snd_soc_dai *dai; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 428 | unsigned int num_dai; |
| 429 | }; |
| 430 | |
| 431 | /* codec device */ |
| 432 | struct snd_soc_codec_device { |
| 433 | int (*probe)(struct platform_device *pdev); |
| 434 | int (*remove)(struct platform_device *pdev); |
| 435 | int (*suspend)(struct platform_device *pdev, pm_message_t state); |
| 436 | int (*resume)(struct platform_device *pdev); |
| 437 | }; |
| 438 | |
| 439 | /* SoC platform interface */ |
| 440 | struct snd_soc_platform { |
| 441 | char *name; |
| 442 | |
| 443 | int (*probe)(struct platform_device *pdev); |
| 444 | int (*remove)(struct platform_device *pdev); |
| 445 | int (*suspend)(struct platform_device *pdev, |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 446 | struct snd_soc_dai *dai); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 447 | int (*resume)(struct platform_device *pdev, |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 448 | struct snd_soc_dai *dai); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 449 | |
| 450 | /* pcm creation and destruction */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 451 | int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 452 | struct snd_pcm *); |
| 453 | void (*pcm_free)(struct snd_pcm *); |
| 454 | |
| 455 | /* platform stream ops */ |
| 456 | struct snd_pcm_ops *pcm_ops; |
| 457 | }; |
| 458 | |
| 459 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ |
| 460 | struct snd_soc_dai_link { |
| 461 | char *name; /* Codec name */ |
| 462 | char *stream_name; /* Stream name */ |
| 463 | |
| 464 | /* DAI */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 465 | struct snd_soc_dai *codec_dai; |
| 466 | struct snd_soc_dai *cpu_dai; |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 467 | |
| 468 | /* machine stream operations */ |
| 469 | struct snd_soc_ops *ops; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 470 | |
| 471 | /* codec/machine specific init - e.g. add machine controls */ |
| 472 | int (*init)(struct snd_soc_codec *codec); |
Liam Girdwood | 4ccab3e | 2008-01-10 14:39:01 +0100 | [diff] [blame] | 473 | |
| 474 | /* DAI pcm */ |
| 475 | struct snd_pcm *pcm; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 476 | }; |
| 477 | |
| 478 | /* SoC machine */ |
| 479 | struct snd_soc_machine { |
| 480 | char *name; |
| 481 | |
| 482 | int (*probe)(struct platform_device *pdev); |
| 483 | int (*remove)(struct platform_device *pdev); |
| 484 | |
| 485 | /* the pre and post PM functions are used to do any PM work before and |
| 486 | * after the codec and DAI's do any PM work. */ |
| 487 | int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); |
| 488 | int (*suspend_post)(struct platform_device *pdev, pm_message_t state); |
| 489 | int (*resume_pre)(struct platform_device *pdev); |
| 490 | int (*resume_post)(struct platform_device *pdev); |
| 491 | |
Liam Girdwood | 0b4d221 | 2008-01-10 14:36:20 +0100 | [diff] [blame] | 492 | /* callbacks */ |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 493 | int (*set_bias_level)(struct snd_soc_machine *, |
| 494 | enum snd_soc_bias_level level); |
Liam Girdwood | 0b4d221 | 2008-01-10 14:36:20 +0100 | [diff] [blame] | 495 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 496 | /* CPU <--> Codec DAI links */ |
| 497 | struct snd_soc_dai_link *dai_link; |
| 498 | int num_links; |
| 499 | }; |
| 500 | |
| 501 | /* SoC Device - the audio subsystem */ |
| 502 | struct snd_soc_device { |
| 503 | struct device *dev; |
| 504 | struct snd_soc_machine *machine; |
| 505 | struct snd_soc_platform *platform; |
| 506 | struct snd_soc_codec *codec; |
| 507 | struct snd_soc_codec_device *codec_dev; |
Andrew Morton | 4484bb2 | 2006-12-15 09:30:07 +0100 | [diff] [blame] | 508 | struct delayed_work delayed_work; |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 509 | struct work_struct deferred_resume_work; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 510 | void *codec_data; |
| 511 | }; |
| 512 | |
| 513 | /* runtime channel data */ |
| 514 | struct snd_soc_pcm_runtime { |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 515 | struct snd_soc_dai_link *dai; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 516 | struct snd_soc_device *socdev; |
| 517 | }; |
| 518 | |
| 519 | /* enumerated kcontrol */ |
| 520 | struct soc_enum { |
| 521 | unsigned short reg; |
| 522 | unsigned short reg2; |
| 523 | unsigned char shift_l; |
| 524 | unsigned char shift_r; |
| 525 | unsigned int mask; |
| 526 | const char **texts; |
| 527 | void *dapm; |
| 528 | }; |
| 529 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 530 | #endif |