blob: 9d5a0362a055e1ea52b5e6f3302d413dd75aa463 [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
Richard Purdie808db4a2006-10-06 18:20:14 +020024/*
25 * Convenience kcontrol builders
26 */
Jon Smirl4eaa9812008-07-29 11:42:26 +010027#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
28 ((unsigned long)&(struct soc_mixer_control) \
Mark Brown762b8df2008-10-30 12:37:08 +000029 {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \
30 .invert = xinvert})
Jon Smirl4eaa9812008-07-29 11:42:26 +010031#define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
32 ((unsigned long)&(struct soc_mixer_control) \
33 {.reg = xreg, .max = xmax, .invert = xinvert})
Philipp Zabela7a4ac82008-01-10 14:37:42 +010034#define SOC_SINGLE(xname, reg, shift, max, invert) \
Richard Purdie808db4a2006-10-06 18:20:14 +020035{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
36 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
37 .put = snd_soc_put_volsw, \
Philipp Zabela7a4ac82008-01-10 14:37:42 +010038 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
39#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
40{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
41 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
42 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
43 .tlv.p = (tlv_array), \
44 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
45 .put = snd_soc_put_volsw, \
46 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
Jon Smirl4eaa9812008-07-29 11:42:26 +010047#define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \
Richard Purdie808db4a2006-10-06 18:20:14 +020048{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
49 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
50 .put = snd_soc_put_volsw, \
Jon Smirl4eaa9812008-07-29 11:42:26 +010051 .private_value = (unsigned long)&(struct soc_mixer_control) \
52 {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
53 .max = xmax, .invert = xinvert} }
54#define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
Richard Purdie808db4a2006-10-06 18:20:14 +020055{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
56 .info = snd_soc_info_volsw_2r, \
57 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
Jon Smirl4eaa9812008-07-29 11:42:26 +010058 .private_value = (unsigned long)&(struct soc_mixer_control) \
59 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
60 .max = xmax, .invert = xinvert} }
61#define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \
Philipp Zabela7a4ac82008-01-10 14:37:42 +010062{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
63 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
64 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
65 .tlv.p = (tlv_array), \
66 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
67 .put = snd_soc_put_volsw, \
Jon Smirl4eaa9812008-07-29 11:42:26 +010068 .private_value = (unsigned long)&(struct soc_mixer_control) \
69 {.reg = xreg, .shift = shift_left, .rshift = shift_right,\
70 .max = xmax, .invert = xinvert} }
71#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
Philipp Zabela7a4ac82008-01-10 14:37:42 +010072{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
73 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
74 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
75 .tlv.p = (tlv_array), \
76 .info = snd_soc_info_volsw_2r, \
77 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
Jon Smirl4eaa9812008-07-29 11:42:26 +010078 .private_value = (unsigned long)&(struct soc_mixer_control) \
79 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
80 .max = xmax, .invert = xinvert} }
81#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
Mark Browne13ac2e2008-05-28 17:58:05 +010082{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
83 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
84 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
85 .tlv.p = (tlv_array), \
86 .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
87 .put = snd_soc_put_volsw_s8, \
Jon Smirl4eaa9812008-07-29 11:42:26 +010088 .private_value = (unsigned long)&(struct soc_mixer_control) \
89 {.reg = xreg, .min = xmin, .max = xmax} }
Jon Smirlf8ba0b72008-07-29 11:42:27 +010090#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \
Richard Purdie808db4a2006-10-06 18:20:14 +020091{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
Jon Smirlf8ba0b72008-07-29 11:42:27 +010092 .max = xmax, .texts = xtexts }
93#define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \
94 SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts)
95#define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \
96{ .max = xmax, .texts = xtexts }
Peter Ujfalusi2e72f8e2009-01-05 09:54:57 +020097#define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xmax, xtexts, xvalues) \
98{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
99 .mask = xmask, .max = xmax, .texts = xtexts, .values = xvalues}
100#define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xmax, xtexts, xvalues) \
101 SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xmax, xtexts, xvalues)
Richard Purdie808db4a2006-10-06 18:20:14 +0200102#define SOC_ENUM(xname, xenum) \
103{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
104 .info = snd_soc_info_enum_double, \
105 .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
106 .private_value = (unsigned long)&xenum }
Peter Ujfalusi2e72f8e2009-01-05 09:54:57 +0200107#define SOC_VALUE_ENUM(xname, xenum) \
108{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
109 .info = snd_soc_info_value_enum_double, \
110 .get = snd_soc_get_value_enum_double, \
111 .put = snd_soc_put_value_enum_double, \
112 .private_value = (unsigned long)&xenum }
Jon Smirlf8ba0b72008-07-29 11:42:27 +0100113#define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
Richard Purdie808db4a2006-10-06 18:20:14 +0200114 xhandler_get, xhandler_put) \
115{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100116 .info = snd_soc_info_volsw, \
Richard Purdie808db4a2006-10-06 18:20:14 +0200117 .get = xhandler_get, .put = xhandler_put, \
Jon Smirlf8ba0b72008-07-29 11:42:27 +0100118 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
119#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
Mike Montour10144c02008-06-11 13:47:13 +0100120 xhandler_get, xhandler_put, tlv_array) \
121{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
122 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
123 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
124 .tlv.p = (tlv_array), \
125 .info = snd_soc_info_volsw, \
126 .get = xhandler_get, .put = xhandler_put, \
Jon Smirlf8ba0b72008-07-29 11:42:27 +0100127 .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
Richard Purdie808db4a2006-10-06 18:20:14 +0200128#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
129{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
130 .info = snd_soc_info_bool_ext, \
131 .get = xhandler_get, .put = xhandler_put, \
132 .private_value = xdata }
133#define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
134{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
135 .info = snd_soc_info_enum_ext, \
136 .get = xhandler_get, .put = xhandler_put, \
137 .private_value = (unsigned long)&xenum }
138
139/*
Mark Brown0be98982008-05-19 12:31:28 +0200140 * Bias levels
141 *
142 * @ON: Bias is fully on for audio playback and capture operations.
143 * @PREPARE: Prepare for audio operations. Called before DAPM switching for
144 * stream start and stop operations.
145 * @STANDBY: Low power standby state when no playback/capture operations are
146 * in progress. NOTE: The transition time between STANDBY and ON
147 * should be as fast as possible and no longer than 10ms.
148 * @OFF: Power Off. No restrictions on transition times.
149 */
150enum snd_soc_bias_level {
151 SND_SOC_BIAS_ON,
152 SND_SOC_BIAS_PREPARE,
153 SND_SOC_BIAS_STANDBY,
154 SND_SOC_BIAS_OFF,
155};
156
Mark Brown8a2cd612009-01-07 17:31:10 +0000157struct snd_jack;
158struct snd_soc_card;
Richard Purdie808db4a2006-10-06 18:20:14 +0200159struct snd_soc_device;
160struct snd_soc_pcm_stream;
161struct snd_soc_ops;
162struct snd_soc_dai_mode;
163struct snd_soc_pcm_runtime;
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100164struct snd_soc_dai;
Mark Brown12a48a8c2008-12-03 19:40:30 +0000165struct snd_soc_platform;
Richard Purdie808db4a2006-10-06 18:20:14 +0200166struct snd_soc_codec;
Richard Purdie808db4a2006-10-06 18:20:14 +0200167struct soc_enum;
168struct snd_soc_ac97_ops;
Mark Brown8a2cd612009-01-07 17:31:10 +0000169struct snd_soc_jack;
170struct snd_soc_jack_pin;
Richard Purdie808db4a2006-10-06 18:20:14 +0200171
172typedef int (*hw_write_t)(void *,const char* ,int);
173typedef int (*hw_read_t)(void *,char* ,int);
174
175extern struct snd_ac97_bus_ops soc_ac97_ops;
176
Mark Brown12a48a8c2008-12-03 19:40:30 +0000177int snd_soc_register_platform(struct snd_soc_platform *platform);
178void snd_soc_unregister_platform(struct snd_soc_platform *platform);
Mark Brown0d0cf002008-12-10 14:32:45 +0000179int snd_soc_register_codec(struct snd_soc_codec *codec);
180void snd_soc_unregister_codec(struct snd_soc_codec *codec);
Mark Brown12a48a8c2008-12-03 19:40:30 +0000181
Richard Purdie808db4a2006-10-06 18:20:14 +0200182/* pcm <-> DAI connect */
183void snd_soc_free_pcms(struct snd_soc_device *socdev);
184int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
Mark Brown968a6022008-11-28 11:49:07 +0000185int snd_soc_init_card(struct snd_soc_device *socdev);
Richard Purdie808db4a2006-10-06 18:20:14 +0200186
187/* set runtime hw params */
188int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
189 const struct snd_pcm_hardware *hw);
Richard Purdie808db4a2006-10-06 18:20:14 +0200190
Mark Brown8a2cd612009-01-07 17:31:10 +0000191/* Jack reporting */
192int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type,
193 struct snd_soc_jack *jack);
194void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
195int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
196 struct snd_soc_jack_pin *pins);
197
Richard Purdie808db4a2006-10-06 18:20:14 +0200198/* codec IO */
199#define snd_soc_read(codec, reg) codec->read(codec, reg)
200#define snd_soc_write(codec, reg, value) codec->write(codec, reg, value)
201
202/* codec register bit access */
203int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
204 unsigned short mask, unsigned short value);
205int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
206 unsigned short mask, unsigned short value);
207
208int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
209 struct snd_ac97_bus_ops *ops, int num);
210void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
211
212/*
213 *Controls
214 */
215struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
216 void *data, char *long_name);
Ian Molton3e8e1952009-01-09 00:23:21 +0000217int snd_soc_add_controls(struct snd_soc_codec *codec,
218 const struct snd_kcontrol_new *controls, int num_controls);
Richard Purdie808db4a2006-10-06 18:20:14 +0200219int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
220 struct snd_ctl_elem_info *uinfo);
221int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
222 struct snd_ctl_elem_info *uinfo);
223int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
224 struct snd_ctl_elem_value *ucontrol);
225int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
226 struct snd_ctl_elem_value *ucontrol);
Peter Ujfalusi2e72f8e2009-01-05 09:54:57 +0200227int snd_soc_info_value_enum_double(struct snd_kcontrol *kcontrol,
228 struct snd_ctl_elem_info *uinfo);
229int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
230 struct snd_ctl_elem_value *ucontrol);
231int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
232 struct snd_ctl_elem_value *ucontrol);
Richard Purdie808db4a2006-10-06 18:20:14 +0200233int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
234 struct snd_ctl_elem_info *uinfo);
235int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
236 struct snd_ctl_elem_info *uinfo);
Philipp Zabel392abe92008-05-13 14:03:40 +0200237#define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
Richard Purdie808db4a2006-10-06 18:20:14 +0200238int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
239 struct snd_ctl_elem_value *ucontrol);
240int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
241 struct snd_ctl_elem_value *ucontrol);
242int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
243 struct snd_ctl_elem_info *uinfo);
244int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
245 struct snd_ctl_elem_value *ucontrol);
246int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
247 struct snd_ctl_elem_value *ucontrol);
Mark Browne13ac2e2008-05-28 17:58:05 +0100248int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_info *uinfo);
250int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
251 struct snd_ctl_elem_value *ucontrol);
252int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
253 struct snd_ctl_elem_value *ucontrol);
Richard Purdie808db4a2006-10-06 18:20:14 +0200254
Mark Brown8a2cd612009-01-07 17:31:10 +0000255/**
256 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
257 *
258 * @pin: name of the pin to update
259 * @mask: bits to check for in reported jack status
260 * @invert: if non-zero then pin is enabled when status is not reported
261 */
262struct snd_soc_jack_pin {
263 struct list_head list;
264 const char *pin;
265 int mask;
266 bool invert;
267};
268
269struct snd_soc_jack {
270 struct snd_jack *jack;
271 struct snd_soc_card *card;
272 struct list_head pins;
273 int status;
274};
275
Richard Purdie808db4a2006-10-06 18:20:14 +0200276/* SoC PCM stream information */
277struct snd_soc_pcm_stream {
278 char *stream_name;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100279 u64 formats; /* SNDRV_PCM_FMTBIT_* */
280 unsigned int rates; /* SNDRV_PCM_RATE_* */
Richard Purdie808db4a2006-10-06 18:20:14 +0200281 unsigned int rate_min; /* min rate */
282 unsigned int rate_max; /* max rate */
283 unsigned int channels_min; /* min channels */
284 unsigned int channels_max; /* max channels */
285 unsigned int active:1; /* stream is in use */
286};
287
288/* SoC audio ops */
289struct snd_soc_ops {
290 int (*startup)(struct snd_pcm_substream *);
291 void (*shutdown)(struct snd_pcm_substream *);
292 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
293 int (*hw_free)(struct snd_pcm_substream *);
294 int (*prepare)(struct snd_pcm_substream *);
295 int (*trigger)(struct snd_pcm_substream *, int);
296};
297
Richard Purdie808db4a2006-10-06 18:20:14 +0200298/* SoC Audio Codec */
299struct snd_soc_codec {
300 char *name;
301 struct module *owner;
302 struct mutex mutex;
Mark Brown0d0cf002008-12-10 14:32:45 +0000303 struct device *dev;
304
305 struct list_head list;
Richard Purdie808db4a2006-10-06 18:20:14 +0200306
307 /* callbacks */
Mark Brown0be98982008-05-19 12:31:28 +0200308 int (*set_bias_level)(struct snd_soc_codec *,
309 enum snd_soc_bias_level level);
Richard Purdie808db4a2006-10-06 18:20:14 +0200310
311 /* runtime */
312 struct snd_card *card;
313 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
314 unsigned int active;
315 unsigned int pcm_devs;
316 void *private_data;
317
318 /* codec IO */
319 void *control_data; /* codec control (i2c/3wire) data */
320 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
321 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
Mark Brown58cd33c2008-07-29 11:42:25 +0100322 int (*display_register)(struct snd_soc_codec *, char *,
323 size_t, unsigned int);
Richard Purdie808db4a2006-10-06 18:20:14 +0200324 hw_write_t hw_write;
325 hw_read_t hw_read;
326 void *reg_cache;
327 short reg_cache_size;
328 short reg_cache_step;
329
330 /* dapm */
Troy Kisky12ef1932008-10-13 17:42:14 -0700331 u32 pop_time;
Richard Purdie808db4a2006-10-06 18:20:14 +0200332 struct list_head dapm_widgets;
333 struct list_head dapm_paths;
Mark Brown0be98982008-05-19 12:31:28 +0200334 enum snd_soc_bias_level bias_level;
335 enum snd_soc_bias_level suspend_bias_level;
Takashi Iwai1321b162006-12-21 11:02:06 +0100336 struct delayed_work delayed_work;
Richard Purdie808db4a2006-10-06 18:20:14 +0200337
338 /* codec DAI's */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100339 struct snd_soc_dai *dai;
Richard Purdie808db4a2006-10-06 18:20:14 +0200340 unsigned int num_dai;
Mark Brown384c89e2008-12-03 17:34:03 +0000341
342#ifdef CONFIG_DEBUG_FS
343 struct dentry *debugfs_reg;
344 struct dentry *debugfs_pop_time;
345#endif
Richard Purdie808db4a2006-10-06 18:20:14 +0200346};
347
348/* codec device */
349struct snd_soc_codec_device {
350 int (*probe)(struct platform_device *pdev);
351 int (*remove)(struct platform_device *pdev);
352 int (*suspend)(struct platform_device *pdev, pm_message_t state);
353 int (*resume)(struct platform_device *pdev);
354};
355
356/* SoC platform interface */
357struct snd_soc_platform {
358 char *name;
Mark Brown12a48a8c2008-12-03 19:40:30 +0000359 struct list_head list;
Richard Purdie808db4a2006-10-06 18:20:14 +0200360
361 int (*probe)(struct platform_device *pdev);
362 int (*remove)(struct platform_device *pdev);
Mark Brown07c84d02008-12-03 18:17:28 +0000363 int (*suspend)(struct snd_soc_dai *dai);
364 int (*resume)(struct snd_soc_dai *dai);
Richard Purdie808db4a2006-10-06 18:20:14 +0200365
366 /* pcm creation and destruction */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100367 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
Richard Purdie808db4a2006-10-06 18:20:14 +0200368 struct snd_pcm *);
369 void (*pcm_free)(struct snd_pcm *);
370
371 /* platform stream ops */
372 struct snd_pcm_ops *pcm_ops;
373};
374
375/* SoC machine DAI configuration, glues a codec and cpu DAI together */
376struct snd_soc_dai_link {
377 char *name; /* Codec name */
378 char *stream_name; /* Stream name */
379
380 /* DAI */
Liam Girdwood3c4b2662008-07-07 16:07:17 +0100381 struct snd_soc_dai *codec_dai;
382 struct snd_soc_dai *cpu_dai;
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100383
384 /* machine stream operations */
385 struct snd_soc_ops *ops;
Richard Purdie808db4a2006-10-06 18:20:14 +0200386
387 /* codec/machine specific init - e.g. add machine controls */
388 int (*init)(struct snd_soc_codec *codec);
Liam Girdwood4ccab3e2008-01-10 14:39:01 +0100389
390 /* DAI pcm */
391 struct snd_pcm *pcm;
Richard Purdie808db4a2006-10-06 18:20:14 +0200392};
393
Mark Brown87506542008-11-18 20:50:34 +0000394/* SoC card */
395struct snd_soc_card {
Richard Purdie808db4a2006-10-06 18:20:14 +0200396 char *name;
Mark Brownc5af3a22008-11-28 13:29:45 +0000397 struct device *dev;
398
399 struct list_head list;
400
401 int instantiated;
Richard Purdie808db4a2006-10-06 18:20:14 +0200402
403 int (*probe)(struct platform_device *pdev);
404 int (*remove)(struct platform_device *pdev);
405
406 /* the pre and post PM functions are used to do any PM work before and
407 * after the codec and DAI's do any PM work. */
408 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
409 int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
410 int (*resume_pre)(struct platform_device *pdev);
411 int (*resume_post)(struct platform_device *pdev);
412
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100413 /* callbacks */
Mark Brown87506542008-11-18 20:50:34 +0000414 int (*set_bias_level)(struct snd_soc_card *,
Mark Brown0be98982008-05-19 12:31:28 +0200415 enum snd_soc_bias_level level);
Liam Girdwood0b4d2212008-01-10 14:36:20 +0100416
Richard Purdie808db4a2006-10-06 18:20:14 +0200417 /* CPU <--> Codec DAI links */
418 struct snd_soc_dai_link *dai_link;
419 int num_links;
Mark Brown63084192008-12-02 15:08:03 +0000420
421 struct snd_soc_device *socdev;
422
Mark Brown87689d52008-12-02 16:01:14 +0000423 struct snd_soc_platform *platform;
Mark Brown63084192008-12-02 15:08:03 +0000424 struct delayed_work delayed_work;
425 struct work_struct deferred_resume_work;
Richard Purdie808db4a2006-10-06 18:20:14 +0200426};
427
428/* SoC Device - the audio subsystem */
429struct snd_soc_device {
430 struct device *dev;
Mark Brown87506542008-11-18 20:50:34 +0000431 struct snd_soc_card *card;
Richard Purdie808db4a2006-10-06 18:20:14 +0200432 struct snd_soc_codec *codec;
433 struct snd_soc_codec_device *codec_dev;
Richard Purdie808db4a2006-10-06 18:20:14 +0200434 void *codec_data;
435};
436
437/* runtime channel data */
438struct snd_soc_pcm_runtime {
Graeme Gregory1c433fb2007-02-02 17:13:05 +0100439 struct snd_soc_dai_link *dai;
Richard Purdie808db4a2006-10-06 18:20:14 +0200440 struct snd_soc_device *socdev;
441};
442
Jon Smirl4eaa9812008-07-29 11:42:26 +0100443/* mixer control */
444struct soc_mixer_control {
445 int min, max;
Jon Smirl815ecf8d2008-07-29 10:22:24 -0400446 unsigned int reg, rreg, shift, rshift, invert;
Jon Smirl4eaa9812008-07-29 11:42:26 +0100447};
448
Richard Purdie808db4a2006-10-06 18:20:14 +0200449/* enumerated kcontrol */
450struct soc_enum {
451 unsigned short reg;
452 unsigned short reg2;
453 unsigned char shift_l;
454 unsigned char shift_r;
Jon Smirlf8ba0b72008-07-29 11:42:27 +0100455 unsigned int max;
Richard Purdie808db4a2006-10-06 18:20:14 +0200456 const char **texts;
457 void *dapm;
458};
459
Peter Ujfalusi2e72f8e2009-01-05 09:54:57 +0200460/* semi enumerated kcontrol */
461struct soc_value_enum {
462 unsigned short reg;
463 unsigned short reg2;
464 unsigned char shift_l;
465 unsigned char shift_r;
466 unsigned int max;
467 unsigned int mask;
468 const char **texts;
469 const unsigned int *values;
470 void *dapm;
471};
472
Mark Browna47cbe72008-07-23 14:03:07 +0100473#include <sound/soc-dai.h>
474
Richard Purdie808db4a2006-10-06 18:20:14 +0200475#endif