blob: 778e57e74dc8fc1d00093e2ddba3d90486458a4b [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) }
Mike Montour10144c02008-06-11 13:47:13 +0100103#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmask, xinvert,\
104 xhandler_get, xhandler_put, tlv_array) \
105{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
106 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
107 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
108 .tlv.p = (tlv_array), \
109 .info = snd_soc_info_volsw, \
110 .get = xhandler_get, .put = xhandler_put, \
111 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmask, xinvert) }
Richard Purdie808db4a2006-10-06 18:20:14 +0200112#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
113{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
114 .info = snd_soc_info_bool_ext, \
115 .get = xhandler_get, .put = xhandler_put, \
116 .private_value = xdata }
117#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
118{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
119 .info = snd_soc_info_enum_ext, \
120 .get = xhandler_get, .put = xhandler_put, \
121 .private_value = (unsigned long)&xenum }
122
123/*
Mark Brown0be98982008-05-19 12:31:28 +0200124 * Bias levels
125 *
126 * @ON: Bias is fully on for audio playback and capture operations.
127 * @PREPARE: Prepare for audio operations. Called before DAPM switching for
128 * stream start and stop operations.
129 * @STANDBY: Low power standby state when no playback/capture operations are
130 * in progress. NOTE: The transition time between STANDBY and ON
131 * should be as fast as possible and no longer than 10ms.
132 * @OFF: Power Off. No restrictions on transition times.
133 */
134enum snd_soc_bias_level {
135 SND_SOC_BIAS_ON,
136 SND_SOC_BIAS_PREPARE,
137 SND_SOC_BIAS_STANDBY,
138 SND_SOC_BIAS_OFF,
139};
140
141/*
Richard Purdie808db4a2006-10-06 18:20:14 +0200142 * Digital Audio Interface (DAI) types
143 */
144#define SND_SOC_DAI_AC97 0x1
145#define SND_SOC_DAI_I2S 0x2
146#define SND_SOC_DAI_PCM 0x4
Liam Girdwooda68660e2007-05-10 19:27:27 +0200147#define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */
Richard Purdie808db4a2006-10-06 18:20:14 +0200148
149/*
150 * DAI hardware audio formats
151 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100152#define SND_SOC_DAIFMT_I2S 0 /* I2S mode */
153#define SND_SOC_DAIFMT_RIGHT_J 1 /* Right justified mode */
154#define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */
155#define SND_SOC_DAIFMT_DSP_A 3 /* L data msb after FRM or LRC */
156#define SND_SOC_DAIFMT_DSP_B 4 /* L data msb during FRM or LRC */
157#define SND_SOC_DAIFMT_AC97 5 /* AC97 */
158
159#define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J
160#define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J
161
162/*
163 * DAI Gating
164 */
165#define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */
166#define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */
Richard Purdie808db4a2006-10-06 18:20:14 +0200167
168/*
Philipp Zabela7a4ac82008-01-10 14:37:42 +0100169 * DAI Sync
170 * Synchronous LR (Left Right) clocks and Frame signals.
171 */
172#define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */
173#define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */
174
175/*
176 * TDM
177 */
178#define SND_SOC_DAIFMT_TDM (1 << 6)
179
180/*
Richard Purdie808db4a2006-10-06 18:20:14 +0200181 * DAI hardware signal inversions
182 */
Philipp Zabela7a4ac82008-01-10 14:37:42 +0100183#define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100184#define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */
185#define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */
186#define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */
Richard Purdie808db4a2006-10-06 18:20:14 +0200187
188/*
189 * DAI hardware clock masters
190 * This is wrt the codec, the inverse is true for the interface
191 * i.e. if the codec is clk and frm master then the interface is
192 * clk and frame slave.
193 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100194#define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */
195#define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */
196#define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */
197#define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */
Richard Purdie808db4a2006-10-06 18:20:14 +0200198
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100199#define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
200#define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
Richard Purdie808db4a2006-10-06 18:20:14 +0200201#define SND_SOC_DAIFMT_INV_MASK 0x0f00
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100202#define SND_SOC_DAIFMT_MASTER_MASK 0xf000
203
Richard Purdie808db4a2006-10-06 18:20:14 +0200204
205/*
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100206 * Master Clock Directions
Richard Purdie808db4a2006-10-06 18:20:14 +0200207 */
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100208#define SND_SOC_CLOCK_IN 0
209#define SND_SOC_CLOCK_OUT 1
Richard Purdie808db4a2006-10-06 18:20:14 +0200210
211/*
212 * AC97 codec ID's bitmask
213 */
214#define SND_SOC_DAI_AC97_ID0 (1 << 0)
215#define SND_SOC_DAI_AC97_ID1 (1 << 1)
216#define SND_SOC_DAI_AC97_ID2 (1 << 2)
217#define SND_SOC_DAI_AC97_ID3 (1 << 3)
218
219struct snd_soc_device;
220struct snd_soc_pcm_stream;
221struct snd_soc_ops;
222struct snd_soc_dai_mode;
223struct snd_soc_pcm_runtime;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100224struct snd_soc_dai;
Richard Purdie808db4a2006-10-06 18:20:14 +0200225struct snd_soc_codec;
226struct snd_soc_machine_config;
227struct soc_enum;
228struct snd_soc_ac97_ops;
229struct snd_soc_clock_info;
230
231typedef int (*hw_write_t)(void *,const char* ,int);
232typedef int (*hw_read_t)(void *,char* ,int);
233
234extern struct snd_ac97_bus_ops soc_ac97_ops;
235
236/* pcm <-> DAI connect */
237void snd_soc_free_pcms(struct snd_soc_device *socdev);
238int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
239int snd_soc_register_card(struct snd_soc_device *socdev);
240
241/* set runtime hw params */
242int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
243 const struct snd_pcm_hardware *hw);
Richard Purdie808db4a2006-10-06 18:20:14 +0200244
245/* codec IO */
246#define snd_soc_read(codec, reg) codec->read(codec, reg)
247#define snd_soc_write(codec, reg, value) codec->write(codec, reg, value)
248
249/* codec register bit access */
250int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
251 unsigned short mask, unsigned short value);
252int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
253 unsigned short mask, unsigned short value);
254
255int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
256 struct snd_ac97_bus_ops *ops, int num);
257void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
258
259/*
260 *Controls
261 */
262struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
263 void *data, char *long_name);
264int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
265 struct snd_ctl_elem_info *uinfo);
266int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
267 struct snd_ctl_elem_info *uinfo);
268int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
269 struct snd_ctl_elem_value *ucontrol);
270int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
271 struct snd_ctl_elem_value *ucontrol);
272int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
273 struct snd_ctl_elem_info *uinfo);
274int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
275 struct snd_ctl_elem_info *uinfo);
Philipp Zabel392abe92008-05-13 14:03:40 +0200276#define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
Richard Purdie808db4a2006-10-06 18:20:14 +0200277int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
278 struct snd_ctl_elem_value *ucontrol);
279int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
280 struct snd_ctl_elem_value *ucontrol);
281int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
282 struct snd_ctl_elem_info *uinfo);
283int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_value *ucontrol);
285int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
286 struct snd_ctl_elem_value *ucontrol);
Mark Browne13ac2e2008-05-28 17:58:05 +0100287int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
288 struct snd_ctl_elem_info *uinfo);
289int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
290 struct snd_ctl_elem_value *ucontrol);
291int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
292 struct snd_ctl_elem_value *ucontrol);
Richard Purdie808db4a2006-10-06 18:20:14 +0200293
294/* SoC PCM stream information */
295struct snd_soc_pcm_stream {
296 char *stream_name;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100297 u64 formats; /* SNDRV_PCM_FMTBIT_* */
298 unsigned int rates; /* SNDRV_PCM_RATE_* */
Richard Purdie808db4a2006-10-06 18:20:14 +0200299 unsigned int rate_min; /* min rate */
300 unsigned int rate_max; /* max rate */
301 unsigned int channels_min; /* min channels */
302 unsigned int channels_max; /* max channels */
303 unsigned int active:1; /* stream is in use */
304};
305
306/* SoC audio ops */
307struct snd_soc_ops {
308 int (*startup)(struct snd_pcm_substream *);
309 void (*shutdown)(struct snd_pcm_substream *);
310 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
311 int (*hw_free)(struct snd_pcm_substream *);
312 int (*prepare)(struct snd_pcm_substream *);
313 int (*trigger)(struct snd_pcm_substream *, int);
314};
315
Mark Brown1ef6ab72008-05-19 12:31:55 +0200316/* ASoC DAI ops */
317struct snd_soc_dai_ops {
318 /* DAI clocking configuration */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100319 int (*set_sysclk)(struct snd_soc_dai *dai,
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100320 int clk_id, unsigned int freq, int dir);
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100321 int (*set_pll)(struct snd_soc_dai *dai,
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100322 int pll_id, unsigned int freq_in, unsigned int freq_out);
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100323 int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100324
Mark Brown1ef6ab72008-05-19 12:31:55 +0200325 /* DAI format configuration */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100326 int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
327 int (*set_tdm_slot)(struct snd_soc_dai *dai,
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100328 unsigned int mask, int slots);
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100329 int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100330
331 /* digital mute */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100332 int (*digital_mute)(struct snd_soc_dai *dai, int mute);
Richard Purdie808db4a2006-10-06 18:20:14 +0200333};
334
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100335/* SoC DAI (Digital Audio Interface) */
336struct snd_soc_dai {
Richard Purdie808db4a2006-10-06 18:20:14 +0200337 /* DAI description */
338 char *name;
339 unsigned int id;
340 unsigned char type;
341
342 /* DAI callbacks */
Mark Brownbdb92872008-06-11 13:47:10 +0100343 int (*probe)(struct platform_device *pdev,
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100344 struct snd_soc_dai *dai);
Mark Brownbdb92872008-06-11 13:47:10 +0100345 void (*remove)(struct platform_device *pdev,
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100346 struct snd_soc_dai *dai);
Richard Purdie808db4a2006-10-06 18:20:14 +0200347 int (*suspend)(struct platform_device *pdev,
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100348 struct snd_soc_dai *dai);
Richard Purdie808db4a2006-10-06 18:20:14 +0200349 int (*resume)(struct platform_device *pdev,
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100350 struct snd_soc_dai *dai);
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100351
352 /* ops */
353 struct snd_soc_ops ops;
Mark Brown1ef6ab72008-05-19 12:31:55 +0200354 struct snd_soc_dai_ops dai_ops;
Richard Purdie808db4a2006-10-06 18:20:14 +0200355
356 /* DAI capabilities */
357 struct snd_soc_pcm_stream capture;
358 struct snd_soc_pcm_stream playback;
Richard Purdie808db4a2006-10-06 18:20:14 +0200359
360 /* DAI runtime info */
Richard Purdie808db4a2006-10-06 18:20:14 +0200361 struct snd_pcm_runtime *runtime;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100362 struct snd_soc_codec *codec;
363 unsigned int active;
364 unsigned char pop_wait:1;
Richard Purdie808db4a2006-10-06 18:20:14 +0200365 void *dma_data;
366
367 /* DAI private data */
368 void *private_data;
369};
370
371/* SoC Audio Codec */
372struct snd_soc_codec {
373 char *name;
374 struct module *owner;
375 struct mutex mutex;
376
377 /* callbacks */
Mark Brown0be98982008-05-19 12:31:28 +0200378 int (*set_bias_level)(struct snd_soc_codec *,
379 enum snd_soc_bias_level level);
Richard Purdie808db4a2006-10-06 18:20:14 +0200380
381 /* runtime */
382 struct snd_card *card;
383 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
384 unsigned int active;
385 unsigned int pcm_devs;
386 void *private_data;
387
388 /* codec IO */
389 void *control_data; /* codec control (i2c/3wire) data */
390 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
391 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
392 hw_write_t hw_write;
393 hw_read_t hw_read;
394 void *reg_cache;
395 short reg_cache_size;
396 short reg_cache_step;
397
398 /* dapm */
399 struct list_head dapm_widgets;
400 struct list_head dapm_paths;
Mark Brown0be98982008-05-19 12:31:28 +0200401 enum snd_soc_bias_level bias_level;
402 enum snd_soc_bias_level suspend_bias_level;
Takashi Iwai1321b162006-12-21 11:02:06 +0100403 struct delayed_work delayed_work;
Richard Purdie808db4a2006-10-06 18:20:14 +0200404
405 /* codec DAI's */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100406 struct snd_soc_dai *dai;
Richard Purdie808db4a2006-10-06 18:20:14 +0200407 unsigned int num_dai;
408};
409
410/* codec device */
411struct snd_soc_codec_device {
412 int (*probe)(struct platform_device *pdev);
413 int (*remove)(struct platform_device *pdev);
414 int (*suspend)(struct platform_device *pdev, pm_message_t state);
415 int (*resume)(struct platform_device *pdev);
416};
417
418/* SoC platform interface */
419struct snd_soc_platform {
420 char *name;
421
422 int (*probe)(struct platform_device *pdev);
423 int (*remove)(struct platform_device *pdev);
424 int (*suspend)(struct platform_device *pdev,
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100425 struct snd_soc_dai *dai);
Richard Purdie808db4a2006-10-06 18:20:14 +0200426 int (*resume)(struct platform_device *pdev,
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100427 struct snd_soc_dai *dai);
Richard Purdie808db4a2006-10-06 18:20:14 +0200428
429 /* pcm creation and destruction */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100430 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
Richard Purdie808db4a2006-10-06 18:20:14 +0200431 struct snd_pcm *);
432 void (*pcm_free)(struct snd_pcm *);
433
434 /* platform stream ops */
435 struct snd_pcm_ops *pcm_ops;
436};
437
438/* SoC machine DAI configuration, glues a codec and cpu DAI together */
439struct snd_soc_dai_link {
440 char *name; /* Codec name */
441 char *stream_name; /* Stream name */
442
443 /* DAI */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100444 struct snd_soc_dai *codec_dai;
445 struct snd_soc_dai *cpu_dai;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100446
447 /* machine stream operations */
448 struct snd_soc_ops *ops;
Richard Purdie808db4a2006-10-06 18:20:14 +0200449
450 /* codec/machine specific init - e.g. add machine controls */
451 int (*init)(struct snd_soc_codec *codec);
Liam Girdwood4ccab3e2008-01-10 14:39:01 +0100452
453 /* DAI pcm */
454 struct snd_pcm *pcm;
Richard Purdie808db4a2006-10-06 18:20:14 +0200455};
456
457/* SoC machine */
458struct snd_soc_machine {
459 char *name;
460
461 int (*probe)(struct platform_device *pdev);
462 int (*remove)(struct platform_device *pdev);
463
464 /* the pre and post PM functions are used to do any PM work before and
465 * after the codec and DAI's do any PM work. */
466 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
467 int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
468 int (*resume_pre)(struct platform_device *pdev);
469 int (*resume_post)(struct platform_device *pdev);
470
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100471 /* callbacks */
Mark Brown0be98982008-05-19 12:31:28 +0200472 int (*set_bias_level)(struct snd_soc_machine *,
473 enum snd_soc_bias_level level);
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100474
Richard Purdie808db4a2006-10-06 18:20:14 +0200475 /* CPU <--> Codec DAI links */
476 struct snd_soc_dai_link *dai_link;
477 int num_links;
478};
479
480/* SoC Device - the audio subsystem */
481struct snd_soc_device {
482 struct device *dev;
483 struct snd_soc_machine *machine;
484 struct snd_soc_platform *platform;
485 struct snd_soc_codec *codec;
486 struct snd_soc_codec_device *codec_dev;
Andrew Morton4484bb22006-12-15 09:30:07 +0100487 struct delayed_work delayed_work;
Andy Green6ed25972008-06-13 16:24:05 +0100488 struct work_struct deferred_resume_work;
Richard Purdie808db4a2006-10-06 18:20:14 +0200489 void *codec_data;
490};
491
492/* runtime channel data */
493struct snd_soc_pcm_runtime {
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100494 struct snd_soc_dai_link *dai;
Richard Purdie808db4a2006-10-06 18:20:14 +0200495 struct snd_soc_device *socdev;
496};
497
498/* enumerated kcontrol */
499struct soc_enum {
500 unsigned short reg;
501 unsigned short reg2;
502 unsigned char shift_l;
503 unsigned char shift_r;
504 unsigned int mask;
505 const char **texts;
506 void *dapm;
507};
508
Richard Purdie808db4a2006-10-06 18:20:14 +0200509#endif