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