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