blob: 9fa2093e74ebd03ddf941ec729fa98b86f7321a5 [file] [log] [blame]
Richard Purdie808db4a2006-10-06 18:20:14 +02001/*
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 Morton4484bb22006-12-15 09:30:07 +010018#include <linux/workqueue.h>
Richard Purdie808db4a2006-10-06 18:20:14 +020019#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/control.h>
22#include <sound/ac97_codec.h>
23
Mark Brown0a22b872008-01-10 14:53:48 +010024#define SND_SOC_VERSION "0.13.2"
Richard Purdie808db4a2006-10-06 18:20:14 +020025
26/*
27 * Convenience kcontrol builders
28 */
Philipp Zabela7a4ac82008-01-10 14:37:42 +010029#define SOC_SINGLE_VALUE(reg, shift, max, invert) ((reg) | ((shift) << 8) |\
30 ((shift) << 12) | ((max) << 16) | ((invert) << 24))
31#define SOC_SINGLE_VALUE_EXT(reg, max, invert) ((reg) | ((max) << 16) |\
Richard Purdie808db4a2006-10-06 18:20:14 +020032 ((invert) << 31))
Philipp Zabela7a4ac82008-01-10 14:37:42 +010033#define SOC_SINGLE(xname, reg, shift, max, invert) \
Richard Purdie808db4a2006-10-06 18:20:14 +020034{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
35 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
36 .put = snd_soc_put_volsw, \
Philipp Zabela7a4ac82008-01-10 14:37:42 +010037 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
38#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
39{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
40 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
41 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
42 .tlv.p = (tlv_array), \
43 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
44 .put = snd_soc_put_volsw, \
45 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
46#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
Richard Purdie808db4a2006-10-06 18:20:14 +020047{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
48 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
49 .put = snd_soc_put_volsw, \
50 .private_value = (reg) | ((shift_left) << 8) | \
Philipp Zabela7a4ac82008-01-10 14:37:42 +010051 ((shift_right) << 12) | ((max) << 16) | ((invert) << 24) }
52#define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, max, invert) \
Richard Purdie808db4a2006-10-06 18:20:14 +020053{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
54 .info = snd_soc_info_volsw_2r, \
55 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
56 .private_value = (reg_left) | ((shift) << 8) | \
Philipp Zabela7a4ac82008-01-10 14:37:42 +010057 ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) }
58#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
59{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
60 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
61 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
62 .tlv.p = (tlv_array), \
63 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
64 .put = snd_soc_put_volsw, \
65 .private_value = (reg) | ((shift_left) << 8) | \
66 ((shift_right) << 12) | ((max) << 16) | ((invert) << 24) }
67#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, shift, max, invert, tlv_array) \
68{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
69 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
70 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
71 .tlv.p = (tlv_array), \
72 .info = snd_soc_info_volsw_2r, \
73 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
74 .private_value = (reg_left) | ((shift) << 8) | \
75 ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) }
Mark Browne13ac2e2008-05-28 17:58:05 +010076#define SOC_DOUBLE_S8_TLV(xname, reg, min, max, tlv_array) \
77{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
78 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
79 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
80 .tlv.p = (tlv_array), \
81 .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
82 .put = snd_soc_put_volsw_s8, \
83 .private_value = (reg) | (((signed char)max) << 16) | \
84 (((signed char)min) << 24) }
Richard Purdie808db4a2006-10-06 18:20:14 +020085#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
86{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
87 .mask = xmask, .texts = xtexts }
88#define SOC_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
89 SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
90#define SOC_ENUM_SINGLE_EXT(xmask, xtexts) \
91{ .mask = xmask, .texts = xtexts }
92#define SOC_ENUM(xname, xenum) \
93{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
94 .info = snd_soc_info_enum_double, \
95 .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
96 .private_value = (unsigned long)&xenum }
Graeme Gregory1c433fb2007-02-02 17:13:05 +010097#define SOC_SINGLE_EXT(xname, xreg, xshift, xmask, xinvert,\
Richard Purdie808db4a2006-10-06 18:20:14 +020098 xhandler_get, xhandler_put) \
99{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100100 .info = snd_soc_info_volsw, \
Richard Purdie808db4a2006-10-06 18:20:14 +0200101 .get = xhandler_get, .put = xhandler_put, \
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100102 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) }
Richard Purdie808db4a2006-10-06 18:20:14 +0200103#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
104{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
105 .info = snd_soc_info_bool_ext, \
106 .get = xhandler_get, .put = xhandler_put, \
107 .private_value = xdata }
108#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
109{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
110 .info = snd_soc_info_enum_ext, \
111 .get = xhandler_get, .put = xhandler_put, \
112 .private_value = (unsigned long)&xenum }
113
114/*
Mark Brown0be98982008-05-19 12:31:28 +0200115 * Bias levels
116 *
117 * @ON: Bias is fully on for audio playback and capture operations.
118 * @PREPARE: Prepare for audio operations. Called before DAPM switching for
119 * stream start and stop operations.
120 * @STANDBY: Low power standby state when no playback/capture operations are
121 * in progress. NOTE: The transition time between STANDBY and ON
122 * should be as fast as possible and no longer than 10ms.
123 * @OFF: Power Off. No restrictions on transition times.
124 */
125enum snd_soc_bias_level {
126 SND_SOC_BIAS_ON,
127 SND_SOC_BIAS_PREPARE,
128 SND_SOC_BIAS_STANDBY,
129 SND_SOC_BIAS_OFF,
130};
131
132/*
Richard Purdie808db4a2006-10-06 18:20:14 +0200133 * Digital Audio Interface (DAI) types
134 */
135#define SND_SOC_DAI_AC97 0x1
136#define SND_SOC_DAI_I2S 0x2
137#define SND_SOC_DAI_PCM 0x4
Liam Girdwooda68660e2007-05-10 19:27:27 +0200138#define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */
Richard Purdie808db4a2006-10-06 18:20:14 +0200139
140/*
141 * DAI hardware audio formats
142 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100143#define SND_SOC_DAIFMT_I2S 0 /* I2S mode */
144#define SND_SOC_DAIFMT_RIGHT_J 1 /* Right justified mode */
145#define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */
146#define SND_SOC_DAIFMT_DSP_A 3 /* L data msb after FRM or LRC */
147#define SND_SOC_DAIFMT_DSP_B 4 /* L data msb during FRM or LRC */
148#define SND_SOC_DAIFMT_AC97 5 /* AC97 */
149
150#define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J
151#define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J
152
153/*
154 * DAI Gating
155 */
156#define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */
157#define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */
Richard Purdie808db4a2006-10-06 18:20:14 +0200158
159/*
Philipp Zabela7a4ac82008-01-10 14:37:42 +0100160 * DAI Sync
161 * Synchronous LR (Left Right) clocks and Frame signals.
162 */
163#define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */
164#define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */
165
166/*
167 * TDM
168 */
169#define SND_SOC_DAIFMT_TDM (1 << 6)
170
171/*
Richard Purdie808db4a2006-10-06 18:20:14 +0200172 * DAI hardware signal inversions
173 */
Philipp Zabela7a4ac82008-01-10 14:37:42 +0100174#define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100175#define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */
176#define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */
177#define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */
Richard Purdie808db4a2006-10-06 18:20:14 +0200178
179/*
180 * DAI hardware clock masters
181 * This is wrt the codec, the inverse is true for the interface
182 * i.e. if the codec is clk and frm master then the interface is
183 * clk and frame slave.
184 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100185#define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */
186#define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */
187#define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */
188#define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */
Richard Purdie808db4a2006-10-06 18:20:14 +0200189
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100190#define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
191#define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
Richard Purdie808db4a2006-10-06 18:20:14 +0200192#define SND_SOC_DAIFMT_INV_MASK 0x0f00
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100193#define SND_SOC_DAIFMT_MASTER_MASK 0xf000
194
Richard Purdie808db4a2006-10-06 18:20:14 +0200195
196/*
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100197 * Master Clock Directions
Richard Purdie808db4a2006-10-06 18:20:14 +0200198 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100199#define SND_SOC_CLOCK_IN 0
200#define SND_SOC_CLOCK_OUT 1
Richard Purdie808db4a2006-10-06 18:20:14 +0200201
202/*
203 * AC97 codec ID's bitmask
204 */
205#define SND_SOC_DAI_AC97_ID0 (1 << 0)
206#define SND_SOC_DAI_AC97_ID1 (1 << 1)
207#define SND_SOC_DAI_AC97_ID2 (1 << 2)
208#define SND_SOC_DAI_AC97_ID3 (1 << 3)
209
210struct snd_soc_device;
211struct snd_soc_pcm_stream;
212struct snd_soc_ops;
213struct snd_soc_dai_mode;
214struct snd_soc_pcm_runtime;
215struct snd_soc_codec_dai;
216struct snd_soc_cpu_dai;
217struct snd_soc_codec;
218struct snd_soc_machine_config;
219struct soc_enum;
220struct snd_soc_ac97_ops;
221struct snd_soc_clock_info;
222
223typedef int (*hw_write_t)(void *,const char* ,int);
224typedef int (*hw_read_t)(void *,char* ,int);
225
226extern struct snd_ac97_bus_ops soc_ac97_ops;
227
228/* pcm <-> DAI connect */
229void snd_soc_free_pcms(struct snd_soc_device *socdev);
230int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
231int snd_soc_register_card(struct snd_soc_device *socdev);
232
233/* set runtime hw params */
234int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
235 const struct snd_pcm_hardware *hw);
Richard Purdie808db4a2006-10-06 18:20:14 +0200236
237/* codec IO */
238#define snd_soc_read(codec, reg) codec->read(codec, reg)
239#define snd_soc_write(codec, reg, value) codec->write(codec, reg, value)
240
241/* codec register bit access */
242int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
243 unsigned short mask, unsigned short value);
244int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
245 unsigned short mask, unsigned short value);
246
247int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
248 struct snd_ac97_bus_ops *ops, int num);
249void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
250
251/*
252 *Controls
253 */
254struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
255 void *data, char *long_name);
256int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
257 struct snd_ctl_elem_info *uinfo);
258int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
259 struct snd_ctl_elem_info *uinfo);
260int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
261 struct snd_ctl_elem_value *ucontrol);
262int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
263 struct snd_ctl_elem_value *ucontrol);
264int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
265 struct snd_ctl_elem_info *uinfo);
266int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
267 struct snd_ctl_elem_info *uinfo);
Philipp Zabel392abe92008-05-13 14:03:40 +0200268#define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
Richard Purdie808db4a2006-10-06 18:20:14 +0200269int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
270 struct snd_ctl_elem_value *ucontrol);
271int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
272 struct snd_ctl_elem_value *ucontrol);
273int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
274 struct snd_ctl_elem_info *uinfo);
275int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
276 struct snd_ctl_elem_value *ucontrol);
277int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
278 struct snd_ctl_elem_value *ucontrol);
Mark Browne13ac2e2008-05-28 17:58:05 +0100279int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
280 struct snd_ctl_elem_info *uinfo);
281int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
282 struct snd_ctl_elem_value *ucontrol);
283int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_value *ucontrol);
Richard Purdie808db4a2006-10-06 18:20:14 +0200285
286/* SoC PCM stream information */
287struct snd_soc_pcm_stream {
288 char *stream_name;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100289 u64 formats; /* SNDRV_PCM_FMTBIT_* */
290 unsigned int rates; /* SNDRV_PCM_RATE_* */
Richard Purdie808db4a2006-10-06 18:20:14 +0200291 unsigned int rate_min; /* min rate */
292 unsigned int rate_max; /* max rate */
293 unsigned int channels_min; /* min channels */
294 unsigned int channels_max; /* max channels */
295 unsigned int active:1; /* stream is in use */
296};
297
298/* SoC audio ops */
299struct snd_soc_ops {
300 int (*startup)(struct snd_pcm_substream *);
301 void (*shutdown)(struct snd_pcm_substream *);
302 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
303 int (*hw_free)(struct snd_pcm_substream *);
304 int (*prepare)(struct snd_pcm_substream *);
305 int (*trigger)(struct snd_pcm_substream *, int);
306};
307
Mark Brown1ef6ab72008-05-19 12:31:55 +0200308/* ASoC DAI ops */
309struct snd_soc_dai_ops {
310 /* DAI clocking configuration */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100311 int (*set_sysclk)(struct snd_soc_codec_dai *codec_dai,
312 int clk_id, unsigned int freq, int dir);
313 int (*set_pll)(struct snd_soc_codec_dai *codec_dai,
314 int pll_id, unsigned int freq_in, unsigned int freq_out);
315 int (*set_clkdiv)(struct snd_soc_codec_dai *codec_dai,
316 int div_id, int div);
317
Mark Brown1ef6ab72008-05-19 12:31:55 +0200318 /* DAI format configuration */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100319 int (*set_fmt)(struct snd_soc_codec_dai *codec_dai,
320 unsigned int fmt);
321 int (*set_tdm_slot)(struct snd_soc_codec_dai *codec_dai,
322 unsigned int mask, int slots);
323 int (*set_tristate)(struct snd_soc_codec_dai *, int tristate);
324
325 /* digital mute */
326 int (*digital_mute)(struct snd_soc_codec_dai *, int mute);
Richard Purdie808db4a2006-10-06 18:20:14 +0200327};
328
Richard Purdie808db4a2006-10-06 18:20:14 +0200329/* SoC Codec DAI */
330struct snd_soc_codec_dai {
331 char *name;
332 int id;
Liam Girdwooda68660e2007-05-10 19:27:27 +0200333 unsigned char type;
Richard Purdie808db4a2006-10-06 18:20:14 +0200334
335 /* DAI capabilities */
336 struct snd_soc_pcm_stream playback;
337 struct snd_soc_pcm_stream capture;
Richard Purdie808db4a2006-10-06 18:20:14 +0200338
339 /* DAI runtime info */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100340 struct snd_soc_codec *codec;
Richard Purdie808db4a2006-10-06 18:20:14 +0200341 unsigned int active;
342 unsigned char pop_wait:1;
343
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100344 /* ops */
345 struct snd_soc_ops ops;
Mark Brown1ef6ab72008-05-19 12:31:55 +0200346 struct snd_soc_dai_ops dai_ops;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100347
Richard Purdie808db4a2006-10-06 18:20:14 +0200348 /* DAI private data */
349 void *private_data;
350};
351
352/* SoC CPU DAI */
353struct snd_soc_cpu_dai {
354
355 /* DAI description */
356 char *name;
357 unsigned int id;
358 unsigned char type;
359
360 /* DAI callbacks */
361 int (*probe)(struct platform_device *pdev);
362 void (*remove)(struct platform_device *pdev);
363 int (*suspend)(struct platform_device *pdev,
364 struct snd_soc_cpu_dai *cpu_dai);
365 int (*resume)(struct platform_device *pdev,
366 struct snd_soc_cpu_dai *cpu_dai);
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100367
368 /* ops */
369 struct snd_soc_ops ops;
Mark Brown1ef6ab72008-05-19 12:31:55 +0200370 struct snd_soc_dai_ops dai_ops;
Richard Purdie808db4a2006-10-06 18:20:14 +0200371
372 /* DAI capabilities */
373 struct snd_soc_pcm_stream capture;
374 struct snd_soc_pcm_stream playback;
Richard Purdie808db4a2006-10-06 18:20:14 +0200375
376 /* DAI runtime info */
Richard Purdie808db4a2006-10-06 18:20:14 +0200377 struct snd_pcm_runtime *runtime;
378 unsigned char active:1;
Richard Purdie808db4a2006-10-06 18:20:14 +0200379 void *dma_data;
380
381 /* DAI private data */
382 void *private_data;
383};
384
385/* SoC Audio Codec */
386struct snd_soc_codec {
387 char *name;
388 struct module *owner;
389 struct mutex mutex;
390
391 /* callbacks */
Mark Brown0be98982008-05-19 12:31:28 +0200392 int (*set_bias_level)(struct snd_soc_codec *,
393 enum snd_soc_bias_level level);
Richard Purdie808db4a2006-10-06 18:20:14 +0200394
395 /* runtime */
396 struct snd_card *card;
397 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
398 unsigned int active;
399 unsigned int pcm_devs;
400 void *private_data;
401
402 /* codec IO */
403 void *control_data; /* codec control (i2c/3wire) data */
404 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
405 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
406 hw_write_t hw_write;
407 hw_read_t hw_read;
408 void *reg_cache;
409 short reg_cache_size;
410 short reg_cache_step;
411
412 /* dapm */
413 struct list_head dapm_widgets;
414 struct list_head dapm_paths;
Mark Brown0be98982008-05-19 12:31:28 +0200415 enum snd_soc_bias_level bias_level;
416 enum snd_soc_bias_level suspend_bias_level;
Takashi Iwai1321b162006-12-21 11:02:06 +0100417 struct delayed_work delayed_work;
Richard Purdie808db4a2006-10-06 18:20:14 +0200418
419 /* codec DAI's */
420 struct snd_soc_codec_dai *dai;
421 unsigned int num_dai;
422};
423
424/* codec device */
425struct snd_soc_codec_device {
426 int (*probe)(struct platform_device *pdev);
427 int (*remove)(struct platform_device *pdev);
428 int (*suspend)(struct platform_device *pdev, pm_message_t state);
429 int (*resume)(struct platform_device *pdev);
430};
431
432/* SoC platform interface */
433struct snd_soc_platform {
434 char *name;
435
436 int (*probe)(struct platform_device *pdev);
437 int (*remove)(struct platform_device *pdev);
438 int (*suspend)(struct platform_device *pdev,
439 struct snd_soc_cpu_dai *cpu_dai);
440 int (*resume)(struct platform_device *pdev,
441 struct snd_soc_cpu_dai *cpu_dai);
442
443 /* pcm creation and destruction */
444 int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *,
445 struct snd_pcm *);
446 void (*pcm_free)(struct snd_pcm *);
447
448 /* platform stream ops */
449 struct snd_pcm_ops *pcm_ops;
450};
451
452/* SoC machine DAI configuration, glues a codec and cpu DAI together */
453struct snd_soc_dai_link {
454 char *name; /* Codec name */
455 char *stream_name; /* Stream name */
456
457 /* DAI */
458 struct snd_soc_codec_dai *codec_dai;
459 struct snd_soc_cpu_dai *cpu_dai;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100460
461 /* machine stream operations */
462 struct snd_soc_ops *ops;
Richard Purdie808db4a2006-10-06 18:20:14 +0200463
464 /* codec/machine specific init - e.g. add machine controls */
465 int (*init)(struct snd_soc_codec *codec);
Liam Girdwood4ccab3e2008-01-10 14:39:01 +0100466
467 /* DAI pcm */
468 struct snd_pcm *pcm;
Richard Purdie808db4a2006-10-06 18:20:14 +0200469};
470
471/* SoC machine */
472struct snd_soc_machine {
473 char *name;
474
475 int (*probe)(struct platform_device *pdev);
476 int (*remove)(struct platform_device *pdev);
477
478 /* the pre and post PM functions are used to do any PM work before and
479 * after the codec and DAI's do any PM work. */
480 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
481 int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
482 int (*resume_pre)(struct platform_device *pdev);
483 int (*resume_post)(struct platform_device *pdev);
484
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100485 /* callbacks */
Mark Brown0be98982008-05-19 12:31:28 +0200486 int (*set_bias_level)(struct snd_soc_machine *,
487 enum snd_soc_bias_level level);
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100488
Richard Purdie808db4a2006-10-06 18:20:14 +0200489 /* CPU <--> Codec DAI links */
490 struct snd_soc_dai_link *dai_link;
491 int num_links;
492};
493
494/* SoC Device - the audio subsystem */
495struct snd_soc_device {
496 struct device *dev;
497 struct snd_soc_machine *machine;
498 struct snd_soc_platform *platform;
499 struct snd_soc_codec *codec;
500 struct snd_soc_codec_device *codec_dev;
Andrew Morton4484bb22006-12-15 09:30:07 +0100501 struct delayed_work delayed_work;
Richard Purdie808db4a2006-10-06 18:20:14 +0200502 void *codec_data;
503};
504
505/* runtime channel data */
506struct snd_soc_pcm_runtime {
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100507 struct snd_soc_dai_link *dai;
Richard Purdie808db4a2006-10-06 18:20:14 +0200508 struct snd_soc_device *socdev;
509};
510
511/* enumerated kcontrol */
512struct soc_enum {
513 unsigned short reg;
514 unsigned short reg2;
515 unsigned char shift_l;
516 unsigned char shift_r;
517 unsigned int mask;
518 const char **texts;
519 void *dapm;
520};
521
Richard Purdie808db4a2006-10-06 18:20:14 +0200522#endif