]>
Commit | Line | Data |
---|---|---|
808db4a4 RP |
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> | |
4484bb2e | 18 | #include <linux/workqueue.h> |
808db4a4 RP |
19 | #include <sound/core.h> |
20 | #include <sound/pcm.h> | |
21 | #include <sound/control.h> | |
22 | #include <sound/ac97_codec.h> | |
23 | ||
0a22b87d | 24 | #define SND_SOC_VERSION "0.13.2" |
808db4a4 RP |
25 | |
26 | /* | |
27 | * Convenience kcontrol builders | |
28 | */ | |
4eaa9819 JS |
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}) | |
a7a4ac86 | 35 | #define SOC_SINGLE(xname, reg, shift, max, invert) \ |
808db4a4 RP |
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, \ | |
a7a4ac86 PZ |
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) } | |
4eaa9819 | 48 | #define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \ |
808db4a4 RP |
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, \ | |
4eaa9819 JS |
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) \ | |
808db4a4 RP |
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, \ | |
4eaa9819 JS |
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) \ | |
a7a4ac86 PZ |
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, \ | |
4eaa9819 JS |
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) \ | |
a7a4ac86 PZ |
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, \ | |
4eaa9819 JS |
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) \ | |
e13ac2e9 MB |
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, \ | |
4eaa9819 JS |
89 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
90 | {.reg = xreg, .min = xmin, .max = xmax} } | |
f8ba0b7b | 91 | #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \ |
808db4a4 | 92 | { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ |
f8ba0b7b JS |
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 } | |
808db4a4 RP |
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 } | |
f8ba0b7b | 103 | #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\ |
808db4a4 RP |
104 | xhandler_get, xhandler_put) \ |
105 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
1c433fbd | 106 | .info = snd_soc_info_volsw, \ |
808db4a4 | 107 | .get = xhandler_get, .put = xhandler_put, \ |
f8ba0b7b JS |
108 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } |
109 | #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ | |
10144c09 MM |
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, \ | |
f8ba0b7b | 117 | .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } |
808db4a4 RP |
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 | ||
0be9898a MB |
129 | /* |
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 | ||
808db4a4 RP |
147 | /* |
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 | |
a68660e0 | 153 | #define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */ |
808db4a4 RP |
154 | |
155 | /* | |
156 | * DAI hardware audio formats | |
157 | */ | |
1c433fbd GG |
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 */ | |
808db4a4 | 173 | |
a7a4ac86 PZ |
174 | /* |
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 | ||
808db4a4 RP |
186 | /* |
187 | * DAI hardware signal inversions | |
188 | */ | |
a7a4ac86 | 189 | #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */ |
1c433fbd GG |
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 */ | |
808db4a4 RP |
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 | */ | |
1c433fbd GG |
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 */ | |
808db4a4 | 204 | |
1c433fbd GG |
205 | #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f |
206 | #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0 | |
808db4a4 | 207 | #define SND_SOC_DAIFMT_INV_MASK 0x0f00 |
1c433fbd | 208 | #define SND_SOC_DAIFMT_MASTER_MASK 0xf000 |
808db4a4 | 209 | |
808db4a4 RP |
210 | |
211 | /* | |
1c433fbd | 212 | * Master Clock Directions |
808db4a4 | 213 | */ |
1c433fbd GG |
214 | #define SND_SOC_CLOCK_IN 0 |
215 | #define SND_SOC_CLOCK_OUT 1 | |
808db4a4 RP |
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; | |
3c4b266f | 230 | struct snd_soc_dai; |
808db4a4 RP |
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); | |
808db4a4 RP |
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 | ||
8c6529db LG |
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 | ||
808db4a4 RP |
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); | |
392abe9c | 303 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info |
808db4a4 RP |
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); | |
e13ac2e9 MB |
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); | |
808db4a4 RP |
320 | |
321 | /* SoC PCM stream information */ | |
322 | struct snd_soc_pcm_stream { | |
323 | char *stream_name; | |
1c433fbd GG |
324 | u64 formats; /* SNDRV_PCM_FMTBIT_* */ |
325 | unsigned int rates; /* SNDRV_PCM_RATE_* */ | |
808db4a4 RP |
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 | ||
1ef6ab75 MB |
343 | /* ASoC DAI ops */ |
344 | struct snd_soc_dai_ops { | |
345 | /* DAI clocking configuration */ | |
3c4b266f | 346 | int (*set_sysclk)(struct snd_soc_dai *dai, |
1c433fbd | 347 | int clk_id, unsigned int freq, int dir); |
3c4b266f | 348 | int (*set_pll)(struct snd_soc_dai *dai, |
1c433fbd | 349 | int pll_id, unsigned int freq_in, unsigned int freq_out); |
3c4b266f | 350 | int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div); |
1c433fbd | 351 | |
1ef6ab75 | 352 | /* DAI format configuration */ |
3c4b266f LG |
353 | int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt); |
354 | int (*set_tdm_slot)(struct snd_soc_dai *dai, | |
1c433fbd | 355 | unsigned int mask, int slots); |
3c4b266f | 356 | int (*set_tristate)(struct snd_soc_dai *dai, int tristate); |
1c433fbd GG |
357 | |
358 | /* digital mute */ | |
3c4b266f | 359 | int (*digital_mute)(struct snd_soc_dai *dai, int mute); |
808db4a4 RP |
360 | }; |
361 | ||
3c4b266f LG |
362 | /* SoC DAI (Digital Audio Interface) */ |
363 | struct snd_soc_dai { | |
808db4a4 RP |
364 | /* DAI description */ |
365 | char *name; | |
366 | unsigned int id; | |
367 | unsigned char type; | |
368 | ||
369 | /* DAI callbacks */ | |
bdb92876 | 370 | int (*probe)(struct platform_device *pdev, |
3c4b266f | 371 | struct snd_soc_dai *dai); |
bdb92876 | 372 | void (*remove)(struct platform_device *pdev, |
3c4b266f | 373 | struct snd_soc_dai *dai); |
808db4a4 | 374 | int (*suspend)(struct platform_device *pdev, |
3c4b266f | 375 | struct snd_soc_dai *dai); |
808db4a4 | 376 | int (*resume)(struct platform_device *pdev, |
3c4b266f | 377 | struct snd_soc_dai *dai); |
1c433fbd GG |
378 | |
379 | /* ops */ | |
380 | struct snd_soc_ops ops; | |
1ef6ab75 | 381 | struct snd_soc_dai_ops dai_ops; |
808db4a4 RP |
382 | |
383 | /* DAI capabilities */ | |
384 | struct snd_soc_pcm_stream capture; | |
385 | struct snd_soc_pcm_stream playback; | |
808db4a4 RP |
386 | |
387 | /* DAI runtime info */ | |
808db4a4 | 388 | struct snd_pcm_runtime *runtime; |
3c4b266f LG |
389 | struct snd_soc_codec *codec; |
390 | unsigned int active; | |
391 | unsigned char pop_wait:1; | |
808db4a4 RP |
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 */ | |
0be9898a MB |
405 | int (*set_bias_level)(struct snd_soc_codec *, |
406 | enum snd_soc_bias_level level); | |
808db4a4 RP |
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); | |
58cd33c0 MB |
419 | int (*display_register)(struct snd_soc_codec *, char *, |
420 | size_t, unsigned int); | |
808db4a4 RP |
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; | |
0be9898a MB |
430 | enum snd_soc_bias_level bias_level; |
431 | enum snd_soc_bias_level suspend_bias_level; | |
1321b160 | 432 | struct delayed_work delayed_work; |
808db4a4 RP |
433 | |
434 | /* codec DAI's */ | |
3c4b266f | 435 | struct snd_soc_dai *dai; |
808db4a4 RP |
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, | |
3c4b266f | 454 | struct snd_soc_dai *dai); |
808db4a4 | 455 | int (*resume)(struct platform_device *pdev, |
3c4b266f | 456 | struct snd_soc_dai *dai); |
808db4a4 RP |
457 | |
458 | /* pcm creation and destruction */ | |
3c4b266f | 459 | int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, |
808db4a4 RP |
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 */ | |
3c4b266f LG |
473 | struct snd_soc_dai *codec_dai; |
474 | struct snd_soc_dai *cpu_dai; | |
1c433fbd GG |
475 | |
476 | /* machine stream operations */ | |
477 | struct snd_soc_ops *ops; | |
808db4a4 RP |
478 | |
479 | /* codec/machine specific init - e.g. add machine controls */ | |
480 | int (*init)(struct snd_soc_codec *codec); | |
4ccab3e7 LG |
481 | |
482 | /* DAI pcm */ | |
483 | struct snd_pcm *pcm; | |
808db4a4 RP |
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 | ||
0b4d221b | 500 | /* callbacks */ |
0be9898a MB |
501 | int (*set_bias_level)(struct snd_soc_machine *, |
502 | enum snd_soc_bias_level level); | |
0b4d221b | 503 | |
808db4a4 RP |
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; | |
4484bb2e | 516 | struct delayed_work delayed_work; |
6ed25978 | 517 | struct work_struct deferred_resume_work; |
808db4a4 RP |
518 | void *codec_data; |
519 | }; | |
520 | ||
521 | /* runtime channel data */ | |
522 | struct snd_soc_pcm_runtime { | |
1c433fbd | 523 | struct snd_soc_dai_link *dai; |
808db4a4 RP |
524 | struct snd_soc_device *socdev; |
525 | }; | |
526 | ||
4eaa9819 JS |
527 | /* mixer control */ |
528 | struct soc_mixer_control { | |
529 | int min, max; | |
815ecf8d | 530 | unsigned int reg, rreg, shift, rshift, invert; |
4eaa9819 JS |
531 | }; |
532 | ||
808db4a4 RP |
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; | |
f8ba0b7b | 539 | unsigned int max; |
808db4a4 RP |
540 | const char **texts; |
541 | void *dapm; | |
542 | }; | |
543 | ||
808db4a4 | 544 | #endif |