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 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 24 | /* |
| 25 | * Convenience kcontrol builders |
| 26 | */ |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 27 | #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \ |
| 28 | ((unsigned long)&(struct soc_mixer_control) \ |
Mark Brown | 762b8df | 2008-10-30 12:37:08 +0000 | [diff] [blame] | 29 | {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \ |
| 30 | .invert = xinvert}) |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 31 | #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \ |
| 32 | ((unsigned long)&(struct soc_mixer_control) \ |
| 33 | {.reg = xreg, .max = xmax, .invert = xinvert}) |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 34 | #define SOC_SINGLE(xname, reg, shift, max, invert) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 35 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 36 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ |
| 37 | .put = snd_soc_put_volsw, \ |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 38 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
| 39 | #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ |
| 40 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 41 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 42 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 43 | .tlv.p = (tlv_array), \ |
| 44 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ |
| 45 | .put = snd_soc_put_volsw, \ |
| 46 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 47 | #define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 48 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
| 49 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ |
| 50 | .put = snd_soc_put_volsw, \ |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 51 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
| 52 | {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ |
| 53 | .max = xmax, .invert = xinvert} } |
| 54 | #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 55 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 56 | .info = snd_soc_info_volsw_2r, \ |
| 57 | .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 58 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
| 59 | {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ |
| 60 | .max = xmax, .invert = xinvert} } |
| 61 | #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] | 62 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
| 63 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 64 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 65 | .tlv.p = (tlv_array), \ |
| 66 | .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ |
| 67 | .put = snd_soc_put_volsw, \ |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 68 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
| 69 | {.reg = xreg, .shift = shift_left, .rshift = shift_right,\ |
| 70 | .max = xmax, .invert = xinvert} } |
| 71 | #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] | 72 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ |
| 73 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 74 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 75 | .tlv.p = (tlv_array), \ |
| 76 | .info = snd_soc_info_volsw_2r, \ |
| 77 | .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 78 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
| 79 | {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ |
| 80 | .max = xmax, .invert = xinvert} } |
| 81 | #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 82 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 83 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 84 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 85 | .tlv.p = (tlv_array), \ |
| 86 | .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \ |
| 87 | .put = snd_soc_put_volsw_s8, \ |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 88 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
| 89 | {.reg = xreg, .min = xmin, .max = xmax} } |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 90 | #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 91 | { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 92 | .max = xmax, .texts = xtexts } |
| 93 | #define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \ |
| 94 | SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts) |
| 95 | #define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \ |
| 96 | { .max = xmax, .texts = xtexts } |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 97 | #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xmax, xtexts, xvalues) \ |
| 98 | { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ |
| 99 | .mask = xmask, .max = xmax, .texts = xtexts, .values = xvalues} |
| 100 | #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xmax, xtexts, xvalues) \ |
| 101 | SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xmax, xtexts, xvalues) |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 102 | #define SOC_ENUM(xname, xenum) \ |
| 103 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ |
| 104 | .info = snd_soc_info_enum_double, \ |
| 105 | .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ |
| 106 | .private_value = (unsigned long)&xenum } |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 107 | #define SOC_VALUE_ENUM(xname, xenum) \ |
| 108 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ |
| 109 | .info = snd_soc_info_value_enum_double, \ |
| 110 | .get = snd_soc_get_value_enum_double, \ |
| 111 | .put = snd_soc_put_value_enum_double, \ |
| 112 | .private_value = (unsigned long)&xenum } |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 113 | #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 114 | xhandler_get, xhandler_put) \ |
| 115 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 116 | .info = snd_soc_info_volsw, \ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 117 | .get = xhandler_get, .put = xhandler_put, \ |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 118 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } |
| 119 | #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ |
Mike Montour | 10144c0 | 2008-06-11 13:47:13 +0100 | [diff] [blame] | 120 | xhandler_get, xhandler_put, tlv_array) \ |
| 121 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 122 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 123 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 124 | .tlv.p = (tlv_array), \ |
| 125 | .info = snd_soc_info_volsw, \ |
| 126 | .get = xhandler_get, .put = xhandler_put, \ |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 127 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 128 | #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ |
| 129 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 130 | .info = snd_soc_info_bool_ext, \ |
| 131 | .get = xhandler_get, .put = xhandler_put, \ |
| 132 | .private_value = xdata } |
| 133 | #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \ |
| 134 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 135 | .info = snd_soc_info_enum_ext, \ |
| 136 | .get = xhandler_get, .put = xhandler_put, \ |
| 137 | .private_value = (unsigned long)&xenum } |
| 138 | |
| 139 | /* |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 140 | * Bias levels |
| 141 | * |
| 142 | * @ON: Bias is fully on for audio playback and capture operations. |
| 143 | * @PREPARE: Prepare for audio operations. Called before DAPM switching for |
| 144 | * stream start and stop operations. |
| 145 | * @STANDBY: Low power standby state when no playback/capture operations are |
| 146 | * in progress. NOTE: The transition time between STANDBY and ON |
| 147 | * should be as fast as possible and no longer than 10ms. |
| 148 | * @OFF: Power Off. No restrictions on transition times. |
| 149 | */ |
| 150 | enum snd_soc_bias_level { |
| 151 | SND_SOC_BIAS_ON, |
| 152 | SND_SOC_BIAS_PREPARE, |
| 153 | SND_SOC_BIAS_STANDBY, |
| 154 | SND_SOC_BIAS_OFF, |
| 155 | }; |
| 156 | |
Mark Brown | 8a2cd61 | 2009-01-07 17:31:10 +0000 | [diff] [blame] | 157 | struct snd_jack; |
| 158 | struct snd_soc_card; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 159 | struct snd_soc_device; |
| 160 | struct snd_soc_pcm_stream; |
| 161 | struct snd_soc_ops; |
| 162 | struct snd_soc_dai_mode; |
| 163 | struct snd_soc_pcm_runtime; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 164 | struct snd_soc_dai; |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 165 | struct snd_soc_platform; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 166 | struct snd_soc_codec; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 167 | struct soc_enum; |
| 168 | struct snd_soc_ac97_ops; |
Mark Brown | 8a2cd61 | 2009-01-07 17:31:10 +0000 | [diff] [blame] | 169 | struct snd_soc_jack; |
| 170 | struct snd_soc_jack_pin; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 171 | |
| 172 | typedef int (*hw_write_t)(void *,const char* ,int); |
| 173 | typedef int (*hw_read_t)(void *,char* ,int); |
| 174 | |
| 175 | extern struct snd_ac97_bus_ops soc_ac97_ops; |
| 176 | |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 177 | int snd_soc_register_platform(struct snd_soc_platform *platform); |
| 178 | void snd_soc_unregister_platform(struct snd_soc_platform *platform); |
Mark Brown | 0d0cf00 | 2008-12-10 14:32:45 +0000 | [diff] [blame] | 179 | int snd_soc_register_codec(struct snd_soc_codec *codec); |
| 180 | void snd_soc_unregister_codec(struct snd_soc_codec *codec); |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 181 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 182 | /* pcm <-> DAI connect */ |
| 183 | void snd_soc_free_pcms(struct snd_soc_device *socdev); |
| 184 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); |
Mark Brown | 968a602 | 2008-11-28 11:49:07 +0000 | [diff] [blame] | 185 | int snd_soc_init_card(struct snd_soc_device *socdev); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 186 | |
| 187 | /* set runtime hw params */ |
| 188 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, |
| 189 | const struct snd_pcm_hardware *hw); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 190 | |
Mark Brown | 8a2cd61 | 2009-01-07 17:31:10 +0000 | [diff] [blame] | 191 | /* Jack reporting */ |
| 192 | int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type, |
| 193 | struct snd_soc_jack *jack); |
| 194 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); |
| 195 | int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, |
| 196 | struct snd_soc_jack_pin *pins); |
| 197 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 198 | /* codec IO */ |
| 199 | #define snd_soc_read(codec, reg) codec->read(codec, reg) |
| 200 | #define snd_soc_write(codec, reg, value) codec->write(codec, reg, value) |
| 201 | |
| 202 | /* codec register bit access */ |
| 203 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, |
| 204 | unsigned short mask, unsigned short value); |
| 205 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, |
| 206 | unsigned short mask, unsigned short value); |
| 207 | |
| 208 | int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, |
| 209 | struct snd_ac97_bus_ops *ops, int num); |
| 210 | void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); |
| 211 | |
| 212 | /* |
| 213 | *Controls |
| 214 | */ |
| 215 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, |
| 216 | void *data, char *long_name); |
| 217 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, |
| 218 | struct snd_ctl_elem_info *uinfo); |
| 219 | int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, |
| 220 | struct snd_ctl_elem_info *uinfo); |
| 221 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, |
| 222 | struct snd_ctl_elem_value *ucontrol); |
| 223 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, |
| 224 | struct snd_ctl_elem_value *ucontrol); |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 225 | int snd_soc_info_value_enum_double(struct snd_kcontrol *kcontrol, |
| 226 | struct snd_ctl_elem_info *uinfo); |
| 227 | int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol, |
| 228 | struct snd_ctl_elem_value *ucontrol); |
| 229 | int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol, |
| 230 | struct snd_ctl_elem_value *ucontrol); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 231 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, |
| 232 | struct snd_ctl_elem_info *uinfo); |
| 233 | int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, |
| 234 | struct snd_ctl_elem_info *uinfo); |
Philipp Zabel | 392abe9 | 2008-05-13 14:03:40 +0200 | [diff] [blame] | 235 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 236 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, |
| 237 | struct snd_ctl_elem_value *ucontrol); |
| 238 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, |
| 239 | struct snd_ctl_elem_value *ucontrol); |
| 240 | int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, |
| 241 | struct snd_ctl_elem_info *uinfo); |
| 242 | int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, |
| 243 | struct snd_ctl_elem_value *ucontrol); |
| 244 | int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, |
| 245 | struct snd_ctl_elem_value *ucontrol); |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 246 | int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, |
| 247 | struct snd_ctl_elem_info *uinfo); |
| 248 | int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, |
| 249 | struct snd_ctl_elem_value *ucontrol); |
| 250 | int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, |
| 251 | struct snd_ctl_elem_value *ucontrol); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 252 | |
Mark Brown | 8a2cd61 | 2009-01-07 17:31:10 +0000 | [diff] [blame] | 253 | /** |
| 254 | * struct snd_soc_jack_pin - Describes a pin to update based on jack detection |
| 255 | * |
| 256 | * @pin: name of the pin to update |
| 257 | * @mask: bits to check for in reported jack status |
| 258 | * @invert: if non-zero then pin is enabled when status is not reported |
| 259 | */ |
| 260 | struct snd_soc_jack_pin { |
| 261 | struct list_head list; |
| 262 | const char *pin; |
| 263 | int mask; |
| 264 | bool invert; |
| 265 | }; |
| 266 | |
| 267 | struct snd_soc_jack { |
| 268 | struct snd_jack *jack; |
| 269 | struct snd_soc_card *card; |
| 270 | struct list_head pins; |
| 271 | int status; |
| 272 | }; |
| 273 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 274 | /* SoC PCM stream information */ |
| 275 | struct snd_soc_pcm_stream { |
| 276 | char *stream_name; |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 277 | u64 formats; /* SNDRV_PCM_FMTBIT_* */ |
| 278 | unsigned int rates; /* SNDRV_PCM_RATE_* */ |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 279 | unsigned int rate_min; /* min rate */ |
| 280 | unsigned int rate_max; /* max rate */ |
| 281 | unsigned int channels_min; /* min channels */ |
| 282 | unsigned int channels_max; /* max channels */ |
| 283 | unsigned int active:1; /* stream is in use */ |
| 284 | }; |
| 285 | |
| 286 | /* SoC audio ops */ |
| 287 | struct snd_soc_ops { |
| 288 | int (*startup)(struct snd_pcm_substream *); |
| 289 | void (*shutdown)(struct snd_pcm_substream *); |
| 290 | int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *); |
| 291 | int (*hw_free)(struct snd_pcm_substream *); |
| 292 | int (*prepare)(struct snd_pcm_substream *); |
| 293 | int (*trigger)(struct snd_pcm_substream *, int); |
| 294 | }; |
| 295 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 296 | /* SoC Audio Codec */ |
| 297 | struct snd_soc_codec { |
| 298 | char *name; |
| 299 | struct module *owner; |
| 300 | struct mutex mutex; |
Mark Brown | 0d0cf00 | 2008-12-10 14:32:45 +0000 | [diff] [blame] | 301 | struct device *dev; |
| 302 | |
| 303 | struct list_head list; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 304 | |
| 305 | /* callbacks */ |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 306 | int (*set_bias_level)(struct snd_soc_codec *, |
| 307 | enum snd_soc_bias_level level); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 308 | |
| 309 | /* runtime */ |
| 310 | struct snd_card *card; |
| 311 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ |
| 312 | unsigned int active; |
| 313 | unsigned int pcm_devs; |
| 314 | void *private_data; |
| 315 | |
| 316 | /* codec IO */ |
| 317 | void *control_data; /* codec control (i2c/3wire) data */ |
| 318 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); |
| 319 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); |
Mark Brown | 58cd33c | 2008-07-29 11:42:25 +0100 | [diff] [blame] | 320 | int (*display_register)(struct snd_soc_codec *, char *, |
| 321 | size_t, unsigned int); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 322 | hw_write_t hw_write; |
| 323 | hw_read_t hw_read; |
| 324 | void *reg_cache; |
| 325 | short reg_cache_size; |
| 326 | short reg_cache_step; |
| 327 | |
| 328 | /* dapm */ |
Troy Kisky | 12ef193 | 2008-10-13 17:42:14 -0700 | [diff] [blame] | 329 | u32 pop_time; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 330 | struct list_head dapm_widgets; |
| 331 | struct list_head dapm_paths; |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 332 | enum snd_soc_bias_level bias_level; |
| 333 | enum snd_soc_bias_level suspend_bias_level; |
Takashi Iwai | 1321b16 | 2006-12-21 11:02:06 +0100 | [diff] [blame] | 334 | struct delayed_work delayed_work; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 335 | |
| 336 | /* codec DAI's */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 337 | struct snd_soc_dai *dai; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 338 | unsigned int num_dai; |
Mark Brown | 384c89e | 2008-12-03 17:34:03 +0000 | [diff] [blame] | 339 | |
| 340 | #ifdef CONFIG_DEBUG_FS |
| 341 | struct dentry *debugfs_reg; |
| 342 | struct dentry *debugfs_pop_time; |
| 343 | #endif |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 344 | }; |
| 345 | |
| 346 | /* codec device */ |
| 347 | struct snd_soc_codec_device { |
| 348 | int (*probe)(struct platform_device *pdev); |
| 349 | int (*remove)(struct platform_device *pdev); |
| 350 | int (*suspend)(struct platform_device *pdev, pm_message_t state); |
| 351 | int (*resume)(struct platform_device *pdev); |
| 352 | }; |
| 353 | |
| 354 | /* SoC platform interface */ |
| 355 | struct snd_soc_platform { |
| 356 | char *name; |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 357 | struct list_head list; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 358 | |
| 359 | int (*probe)(struct platform_device *pdev); |
| 360 | int (*remove)(struct platform_device *pdev); |
Mark Brown | 07c84d0 | 2008-12-03 18:17:28 +0000 | [diff] [blame] | 361 | int (*suspend)(struct snd_soc_dai *dai); |
| 362 | int (*resume)(struct snd_soc_dai *dai); |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 363 | |
| 364 | /* pcm creation and destruction */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 365 | int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 366 | struct snd_pcm *); |
| 367 | void (*pcm_free)(struct snd_pcm *); |
| 368 | |
| 369 | /* platform stream ops */ |
| 370 | struct snd_pcm_ops *pcm_ops; |
| 371 | }; |
| 372 | |
| 373 | /* SoC machine DAI configuration, glues a codec and cpu DAI together */ |
| 374 | struct snd_soc_dai_link { |
| 375 | char *name; /* Codec name */ |
| 376 | char *stream_name; /* Stream name */ |
| 377 | |
| 378 | /* DAI */ |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 379 | struct snd_soc_dai *codec_dai; |
| 380 | struct snd_soc_dai *cpu_dai; |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 381 | |
| 382 | /* machine stream operations */ |
| 383 | struct snd_soc_ops *ops; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 384 | |
| 385 | /* codec/machine specific init - e.g. add machine controls */ |
| 386 | int (*init)(struct snd_soc_codec *codec); |
Liam Girdwood | 4ccab3e | 2008-01-10 14:39:01 +0100 | [diff] [blame] | 387 | |
| 388 | /* DAI pcm */ |
| 389 | struct snd_pcm *pcm; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 390 | }; |
| 391 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 392 | /* SoC card */ |
| 393 | struct snd_soc_card { |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 394 | char *name; |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 395 | struct device *dev; |
| 396 | |
| 397 | struct list_head list; |
| 398 | |
| 399 | int instantiated; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 400 | |
| 401 | int (*probe)(struct platform_device *pdev); |
| 402 | int (*remove)(struct platform_device *pdev); |
| 403 | |
| 404 | /* the pre and post PM functions are used to do any PM work before and |
| 405 | * after the codec and DAI's do any PM work. */ |
| 406 | int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); |
| 407 | int (*suspend_post)(struct platform_device *pdev, pm_message_t state); |
| 408 | int (*resume_pre)(struct platform_device *pdev); |
| 409 | int (*resume_post)(struct platform_device *pdev); |
| 410 | |
Liam Girdwood | 0b4d221 | 2008-01-10 14:36:20 +0100 | [diff] [blame] | 411 | /* callbacks */ |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 412 | int (*set_bias_level)(struct snd_soc_card *, |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 413 | enum snd_soc_bias_level level); |
Liam Girdwood | 0b4d221 | 2008-01-10 14:36:20 +0100 | [diff] [blame] | 414 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 415 | /* CPU <--> Codec DAI links */ |
| 416 | struct snd_soc_dai_link *dai_link; |
| 417 | int num_links; |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 418 | |
| 419 | struct snd_soc_device *socdev; |
| 420 | |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 421 | struct snd_soc_platform *platform; |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 422 | struct delayed_work delayed_work; |
| 423 | struct work_struct deferred_resume_work; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 424 | }; |
| 425 | |
| 426 | /* SoC Device - the audio subsystem */ |
| 427 | struct snd_soc_device { |
| 428 | struct device *dev; |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 429 | struct snd_soc_card *card; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 430 | struct snd_soc_codec *codec; |
| 431 | struct snd_soc_codec_device *codec_dev; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 432 | void *codec_data; |
| 433 | }; |
| 434 | |
| 435 | /* runtime channel data */ |
| 436 | struct snd_soc_pcm_runtime { |
Graeme Gregory | 1c433fb | 2007-02-02 17:13:05 +0100 | [diff] [blame] | 437 | struct snd_soc_dai_link *dai; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 438 | struct snd_soc_device *socdev; |
| 439 | }; |
| 440 | |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 441 | /* mixer control */ |
| 442 | struct soc_mixer_control { |
| 443 | int min, max; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 444 | unsigned int reg, rreg, shift, rshift, invert; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 445 | }; |
| 446 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 447 | /* enumerated kcontrol */ |
| 448 | struct soc_enum { |
| 449 | unsigned short reg; |
| 450 | unsigned short reg2; |
| 451 | unsigned char shift_l; |
| 452 | unsigned char shift_r; |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 453 | unsigned int max; |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 454 | const char **texts; |
| 455 | void *dapm; |
| 456 | }; |
| 457 | |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 458 | /* semi enumerated kcontrol */ |
| 459 | struct soc_value_enum { |
| 460 | unsigned short reg; |
| 461 | unsigned short reg2; |
| 462 | unsigned char shift_l; |
| 463 | unsigned char shift_r; |
| 464 | unsigned int max; |
| 465 | unsigned int mask; |
| 466 | const char **texts; |
| 467 | const unsigned int *values; |
| 468 | void *dapm; |
| 469 | }; |
| 470 | |
Mark Brown | a47cbe7 | 2008-07-23 14:03:07 +0100 | [diff] [blame] | 471 | #include <sound/soc-dai.h> |
| 472 | |
Richard Purdie | 808db4a | 2006-10-06 18:20:14 +0200 | [diff] [blame] | 473 | #endif |