blob: e6ea6f7509414566c2327a841e206b7249cbaa2c [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) }
Richard Purdie808db4a2006-10-06 18:20:14 +020076#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 }
Graeme Gregory1c433fb2007-02-02 17:13:05 +010088#define SOC_SINGLE_EXT(xname, xreg, xshift, xmask, xinvert,\
Richard Purdie808db4a2006-10-06 18:20:14 +020089 xhandler_get, xhandler_put) \
90{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
Graeme Gregory1c433fb2007-02-02 17:13:05 +010091 .info = snd_soc_info_volsw, \
Richard Purdie808db4a2006-10-06 18:20:14 +020092 .get = xhandler_get, .put = xhandler_put, \
Graeme Gregory1c433fb2007-02-02 17:13:05 +010093 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) }
Richard Purdie808db4a2006-10-06 18:20:14 +020094#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
105/*
106 * Digital Audio Interface (DAI) types
107 */
108#define SND_SOC_DAI_AC97 0x1
109#define SND_SOC_DAI_I2S 0x2
110#define SND_SOC_DAI_PCM 0x4
Liam Girdwooda68660e2007-05-10 19:27:27 +0200111#define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */
Richard Purdie808db4a2006-10-06 18:20:14 +0200112
113/*
114 * DAI hardware audio formats
115 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100116#define SND_SOC_DAIFMT_I2S 0 /* I2S mode */
117#define SND_SOC_DAIFMT_RIGHT_J 1 /* Right justified mode */
118#define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */
119#define SND_SOC_DAIFMT_DSP_A 3 /* L data msb after FRM or LRC */
120#define SND_SOC_DAIFMT_DSP_B 4 /* L data msb during FRM or LRC */
121#define SND_SOC_DAIFMT_AC97 5 /* AC97 */
122
123#define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J
124#define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J
125
126/*
127 * DAI Gating
128 */
129#define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */
130#define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */
Richard Purdie808db4a2006-10-06 18:20:14 +0200131
132/*
Philipp Zabela7a4ac82008-01-10 14:37:42 +0100133 * DAI Sync
134 * Synchronous LR (Left Right) clocks and Frame signals.
135 */
136#define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */
137#define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */
138
139/*
140 * TDM
141 */
142#define SND_SOC_DAIFMT_TDM (1 << 6)
143
144/*
Richard Purdie808db4a2006-10-06 18:20:14 +0200145 * DAI hardware signal inversions
146 */
Philipp Zabela7a4ac82008-01-10 14:37:42 +0100147#define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100148#define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */
149#define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */
150#define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */
Richard Purdie808db4a2006-10-06 18:20:14 +0200151
152/*
153 * DAI hardware clock masters
154 * This is wrt the codec, the inverse is true for the interface
155 * i.e. if the codec is clk and frm master then the interface is
156 * clk and frame slave.
157 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100158#define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */
159#define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */
160#define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */
161#define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */
Richard Purdie808db4a2006-10-06 18:20:14 +0200162
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100163#define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
164#define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
Richard Purdie808db4a2006-10-06 18:20:14 +0200165#define SND_SOC_DAIFMT_INV_MASK 0x0f00
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100166#define SND_SOC_DAIFMT_MASTER_MASK 0xf000
167
Richard Purdie808db4a2006-10-06 18:20:14 +0200168
169/*
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100170 * Master Clock Directions
Richard Purdie808db4a2006-10-06 18:20:14 +0200171 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100172#define SND_SOC_CLOCK_IN 0
173#define SND_SOC_CLOCK_OUT 1
Richard Purdie808db4a2006-10-06 18:20:14 +0200174
175/*
176 * AC97 codec ID's bitmask
177 */
178#define SND_SOC_DAI_AC97_ID0 (1 << 0)
179#define SND_SOC_DAI_AC97_ID1 (1 << 1)
180#define SND_SOC_DAI_AC97_ID2 (1 << 2)
181#define SND_SOC_DAI_AC97_ID3 (1 << 3)
182
183struct snd_soc_device;
184struct snd_soc_pcm_stream;
185struct snd_soc_ops;
186struct snd_soc_dai_mode;
187struct snd_soc_pcm_runtime;
188struct snd_soc_codec_dai;
189struct snd_soc_cpu_dai;
190struct snd_soc_codec;
191struct snd_soc_machine_config;
192struct soc_enum;
193struct snd_soc_ac97_ops;
194struct snd_soc_clock_info;
195
196typedef int (*hw_write_t)(void *,const char* ,int);
197typedef int (*hw_read_t)(void *,char* ,int);
198
199extern struct snd_ac97_bus_ops soc_ac97_ops;
200
201/* pcm <-> DAI connect */
202void snd_soc_free_pcms(struct snd_soc_device *socdev);
203int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
204int snd_soc_register_card(struct snd_soc_device *socdev);
205
206/* set runtime hw params */
207int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
208 const struct snd_pcm_hardware *hw);
Richard Purdie808db4a2006-10-06 18:20:14 +0200209
210/* codec IO */
211#define snd_soc_read(codec, reg) codec->read(codec, reg)
212#define snd_soc_write(codec, reg, value) codec->write(codec, reg, value)
213
214/* codec register bit access */
215int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
216 unsigned short mask, unsigned short value);
217int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
218 unsigned short mask, unsigned short value);
219
220int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
221 struct snd_ac97_bus_ops *ops, int num);
222void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
223
224/*
225 *Controls
226 */
227struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
228 void *data, char *long_name);
229int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
230 struct snd_ctl_elem_info *uinfo);
231int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
232 struct snd_ctl_elem_info *uinfo);
233int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
234 struct snd_ctl_elem_value *ucontrol);
235int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
236 struct snd_ctl_elem_value *ucontrol);
237int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
238 struct snd_ctl_elem_info *uinfo);
239int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
240 struct snd_ctl_elem_info *uinfo);
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200241#define snd_soc_info_bool_ext snd_ctl_boolean_mono
Richard Purdie808db4a2006-10-06 18:20:14 +0200242int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
243 struct snd_ctl_elem_value *ucontrol);
244int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
245 struct snd_ctl_elem_value *ucontrol);
246int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
247 struct snd_ctl_elem_info *uinfo);
248int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_value *ucontrol);
250int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
251 struct snd_ctl_elem_value *ucontrol);
252
253/* SoC PCM stream information */
254struct snd_soc_pcm_stream {
255 char *stream_name;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100256 u64 formats; /* SNDRV_PCM_FMTBIT_* */
257 unsigned int rates; /* SNDRV_PCM_RATE_* */
Richard Purdie808db4a2006-10-06 18:20:14 +0200258 unsigned int rate_min; /* min rate */
259 unsigned int rate_max; /* max rate */
260 unsigned int channels_min; /* min channels */
261 unsigned int channels_max; /* max channels */
262 unsigned int active:1; /* stream is in use */
263};
264
265/* SoC audio ops */
266struct snd_soc_ops {
267 int (*startup)(struct snd_pcm_substream *);
268 void (*shutdown)(struct snd_pcm_substream *);
269 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
270 int (*hw_free)(struct snd_pcm_substream *);
271 int (*prepare)(struct snd_pcm_substream *);
272 int (*trigger)(struct snd_pcm_substream *, int);
273};
274
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100275/* ASoC codec DAI ops */
276struct snd_soc_codec_ops {
277 /* codec DAI clocking configuration */
278 int (*set_sysclk)(struct snd_soc_codec_dai *codec_dai,
279 int clk_id, unsigned int freq, int dir);
280 int (*set_pll)(struct snd_soc_codec_dai *codec_dai,
281 int pll_id, unsigned int freq_in, unsigned int freq_out);
282 int (*set_clkdiv)(struct snd_soc_codec_dai *codec_dai,
283 int div_id, int div);
284
285 /* CPU DAI format configuration */
286 int (*set_fmt)(struct snd_soc_codec_dai *codec_dai,
287 unsigned int fmt);
288 int (*set_tdm_slot)(struct snd_soc_codec_dai *codec_dai,
289 unsigned int mask, int slots);
290 int (*set_tristate)(struct snd_soc_codec_dai *, int tristate);
291
292 /* digital mute */
293 int (*digital_mute)(struct snd_soc_codec_dai *, int mute);
Richard Purdie808db4a2006-10-06 18:20:14 +0200294};
295
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100296/* ASoC cpu DAI ops */
297struct snd_soc_cpu_ops {
298 /* CPU DAI clocking configuration */
299 int (*set_sysclk)(struct snd_soc_cpu_dai *cpu_dai,
300 int clk_id, unsigned int freq, int dir);
301 int (*set_clkdiv)(struct snd_soc_cpu_dai *cpu_dai,
302 int div_id, int div);
303 int (*set_pll)(struct snd_soc_cpu_dai *cpu_dai,
304 int pll_id, unsigned int freq_in, unsigned int freq_out);
305
306 /* CPU DAI format configuration */
307 int (*set_fmt)(struct snd_soc_cpu_dai *cpu_dai,
308 unsigned int fmt);
309 int (*set_tdm_slot)(struct snd_soc_cpu_dai *cpu_dai,
310 unsigned int mask, int slots);
311 int (*set_tristate)(struct snd_soc_cpu_dai *, int tristate);
Richard Purdie808db4a2006-10-06 18:20:14 +0200312};
313
314/* SoC Codec DAI */
315struct snd_soc_codec_dai {
316 char *name;
317 int id;
Liam Girdwooda68660e2007-05-10 19:27:27 +0200318 unsigned char type;
Richard Purdie808db4a2006-10-06 18:20:14 +0200319
320 /* DAI capabilities */
321 struct snd_soc_pcm_stream playback;
322 struct snd_soc_pcm_stream capture;
Richard Purdie808db4a2006-10-06 18:20:14 +0200323
324 /* DAI runtime info */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100325 struct snd_soc_codec *codec;
Richard Purdie808db4a2006-10-06 18:20:14 +0200326 unsigned int active;
327 unsigned char pop_wait:1;
328
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100329 /* ops */
330 struct snd_soc_ops ops;
331 struct snd_soc_codec_ops dai_ops;
332
Richard Purdie808db4a2006-10-06 18:20:14 +0200333 /* DAI private data */
334 void *private_data;
335};
336
337/* SoC CPU DAI */
338struct 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);
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100352
353 /* ops */
354 struct snd_soc_ops ops;
355 struct snd_soc_cpu_ops dai_ops;
Richard Purdie808db4a2006-10-06 18:20:14 +0200356
357 /* DAI capabilities */
358 struct snd_soc_pcm_stream capture;
359 struct snd_soc_pcm_stream playback;
Richard Purdie808db4a2006-10-06 18:20:14 +0200360
361 /* DAI runtime info */
Richard Purdie808db4a2006-10-06 18:20:14 +0200362 struct snd_pcm_runtime *runtime;
363 unsigned char active:1;
Richard Purdie808db4a2006-10-06 18:20:14 +0200364 void *dma_data;
365
366 /* DAI private data */
367 void *private_data;
368};
369
370/* SoC Audio Codec */
371struct snd_soc_codec {
372 char *name;
373 struct module *owner;
374 struct mutex mutex;
375
376 /* callbacks */
377 int (*dapm_event)(struct snd_soc_codec *codec, int event);
378
379 /* runtime */
380 struct snd_card *card;
381 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
382 unsigned int active;
383 unsigned int pcm_devs;
384 void *private_data;
385
386 /* codec IO */
387 void *control_data; /* codec control (i2c/3wire) data */
388 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
389 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
390 hw_write_t hw_write;
391 hw_read_t hw_read;
392 void *reg_cache;
393 short reg_cache_size;
394 short reg_cache_step;
395
396 /* dapm */
397 struct list_head dapm_widgets;
398 struct list_head dapm_paths;
399 unsigned int dapm_state;
400 unsigned int suspend_dapm_state;
Takashi Iwai1321b162006-12-21 11:02:06 +0100401 struct delayed_work delayed_work;
Richard Purdie808db4a2006-10-06 18:20:14 +0200402
403 /* codec DAI's */
404 struct snd_soc_codec_dai *dai;
405 unsigned int num_dai;
406};
407
408/* codec device */
409struct snd_soc_codec_device {
410 int (*probe)(struct platform_device *pdev);
411 int (*remove)(struct platform_device *pdev);
412 int (*suspend)(struct platform_device *pdev, pm_message_t state);
413 int (*resume)(struct platform_device *pdev);
414};
415
416/* SoC platform interface */
417struct snd_soc_platform {
418 char *name;
419
420 int (*probe)(struct platform_device *pdev);
421 int (*remove)(struct platform_device *pdev);
422 int (*suspend)(struct platform_device *pdev,
423 struct snd_soc_cpu_dai *cpu_dai);
424 int (*resume)(struct platform_device *pdev,
425 struct snd_soc_cpu_dai *cpu_dai);
426
427 /* pcm creation and destruction */
428 int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *,
429 struct snd_pcm *);
430 void (*pcm_free)(struct snd_pcm *);
431
432 /* platform stream ops */
433 struct snd_pcm_ops *pcm_ops;
434};
435
436/* SoC machine DAI configuration, glues a codec and cpu DAI together */
437struct snd_soc_dai_link {
438 char *name; /* Codec name */
439 char *stream_name; /* Stream name */
440
441 /* DAI */
442 struct snd_soc_codec_dai *codec_dai;
443 struct snd_soc_cpu_dai *cpu_dai;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100444
445 /* machine stream operations */
446 struct snd_soc_ops *ops;
Richard Purdie808db4a2006-10-06 18:20:14 +0200447
448 /* codec/machine specific init - e.g. add machine controls */
449 int (*init)(struct snd_soc_codec *codec);
Liam Girdwood4ccab3e2008-01-10 14:39:01 +0100450
451 /* DAI pcm */
452 struct snd_pcm *pcm;
Richard Purdie808db4a2006-10-06 18:20:14 +0200453};
454
455/* SoC machine */
456struct snd_soc_machine {
457 char *name;
458
459 int (*probe)(struct platform_device *pdev);
460 int (*remove)(struct platform_device *pdev);
461
462 /* the pre and post PM functions are used to do any PM work before and
463 * after the codec and DAI's do any PM work. */
464 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
465 int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
466 int (*resume_pre)(struct platform_device *pdev);
467 int (*resume_post)(struct platform_device *pdev);
468
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100469 /* callbacks */
470 int (*dapm_event)(struct snd_soc_machine *, int event);
471
Richard Purdie808db4a2006-10-06 18:20:14 +0200472 /* CPU <--> Codec DAI links */
473 struct snd_soc_dai_link *dai_link;
474 int num_links;
475};
476
477/* SoC Device - the audio subsystem */
478struct snd_soc_device {
479 struct device *dev;
480 struct snd_soc_machine *machine;
481 struct snd_soc_platform *platform;
482 struct snd_soc_codec *codec;
483 struct snd_soc_codec_device *codec_dev;
Andrew Morton4484bb22006-12-15 09:30:07 +0100484 struct delayed_work delayed_work;
Richard Purdie808db4a2006-10-06 18:20:14 +0200485 void *codec_data;
486};
487
488/* runtime channel data */
489struct snd_soc_pcm_runtime {
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100490 struct snd_soc_dai_link *dai;
Richard Purdie808db4a2006-10-06 18:20:14 +0200491 struct snd_soc_device *socdev;
492};
493
494/* enumerated kcontrol */
495struct soc_enum {
496 unsigned short reg;
497 unsigned short reg2;
498 unsigned char shift_l;
499 unsigned char shift_r;
500 unsigned int mask;
501 const char **texts;
502 void *dapm;
503};
504
Richard Purdie808db4a2006-10-06 18:20:14 +0200505#endif