aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/soc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sound/soc.h')
-rw-r--r--include/sound/soc.h236
1 files changed, 66 insertions, 170 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5e0189876afd..9b930d342116 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -21,8 +21,6 @@
21#include <sound/control.h> 21#include <sound/control.h>
22#include <sound/ac97_codec.h> 22#include <sound/ac97_codec.h>
23 23
24#define SND_SOC_VERSION "0.13.2"
25
26/* 24/*
27 * Convenience kcontrol builders 25 * Convenience kcontrol builders
28 */ 26 */
@@ -96,11 +94,22 @@
96 SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts) 94 SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts)
97#define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \ 95#define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \
98{ .max = xmax, .texts = xtexts } 96{ .max = xmax, .texts = xtexts }
97#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)
99#define SOC_ENUM(xname, xenum) \ 102#define SOC_ENUM(xname, xenum) \
100{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\ 103{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
101 .info = snd_soc_info_enum_double, \ 104 .info = snd_soc_info_enum_double, \
102 .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ 105 .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
103 .private_value = (unsigned long)&xenum } 106 .private_value = (unsigned long)&xenum }
107#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 }
104#define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\ 113#define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
105 xhandler_get, xhandler_put) \ 114 xhandler_get, xhandler_put) \
106{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 115{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
@@ -145,105 +154,31 @@ enum snd_soc_bias_level {
145 SND_SOC_BIAS_OFF, 154 SND_SOC_BIAS_OFF,
146}; 155};
147 156
148/*
149 * Digital Audio Interface (DAI) types
150 */
151#define SND_SOC_DAI_AC97 0x1
152#define SND_SOC_DAI_I2S 0x2
153#define SND_SOC_DAI_PCM 0x4
154#define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */
155
156/*
157 * DAI hardware audio formats
158 */
159#define SND_SOC_DAIFMT_I2S 0 /* I2S mode */
160#define SND_SOC_DAIFMT_RIGHT_J 1 /* Right justified mode */
161#define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */
162#define SND_SOC_DAIFMT_DSP_A 3 /* L data msb after FRM or LRC */
163#define SND_SOC_DAIFMT_DSP_B 4 /* L data msb during FRM or LRC */
164#define SND_SOC_DAIFMT_AC97 5 /* AC97 */
165
166#define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J
167#define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J
168
169/*
170 * DAI Gating
171 */
172#define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */
173#define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */
174
175/*
176 * DAI Sync
177 * Synchronous LR (Left Right) clocks and Frame signals.
178 */
179#define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */
180#define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */
181
182/*
183 * TDM
184 */
185#define SND_SOC_DAIFMT_TDM (1 << 6)
186
187/*
188 * DAI hardware signal inversions
189 */
190#define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */
191#define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */
192#define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */
193#define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */
194
195/*
196 * DAI hardware clock masters
197 * This is wrt the codec, the inverse is true for the interface
198 * i.e. if the codec is clk and frm master then the interface is
199 * clk and frame slave.
200 */
201#define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */
202#define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */
203#define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */
204#define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */
205
206#define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
207#define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
208#define SND_SOC_DAIFMT_INV_MASK 0x0f00
209#define SND_SOC_DAIFMT_MASTER_MASK 0xf000
210
211
212/*
213 * Master Clock Directions
214 */
215#define SND_SOC_CLOCK_IN 0
216#define SND_SOC_CLOCK_OUT 1
217
218/*
219 * AC97 codec ID's bitmask
220 */
221#define SND_SOC_DAI_AC97_ID0 (1 << 0)
222#define SND_SOC_DAI_AC97_ID1 (1 << 1)
223#define SND_SOC_DAI_AC97_ID2 (1 << 2)
224#define SND_SOC_DAI_AC97_ID3 (1 << 3)
225
226struct snd_soc_device; 157struct snd_soc_device;
227struct snd_soc_pcm_stream; 158struct snd_soc_pcm_stream;
228struct snd_soc_ops; 159struct snd_soc_ops;
229struct snd_soc_dai_mode; 160struct snd_soc_dai_mode;
230struct snd_soc_pcm_runtime; 161struct snd_soc_pcm_runtime;
231struct snd_soc_dai; 162struct snd_soc_dai;
163struct snd_soc_platform;
232struct snd_soc_codec; 164struct snd_soc_codec;
233struct snd_soc_machine_config;
234struct soc_enum; 165struct soc_enum;
235struct snd_soc_ac97_ops; 166struct snd_soc_ac97_ops;
236struct snd_soc_clock_info;
237 167
238typedef int (*hw_write_t)(void *,const char* ,int); 168typedef int (*hw_write_t)(void *,const char* ,int);
239typedef int (*hw_read_t)(void *,char* ,int); 169typedef int (*hw_read_t)(void *,char* ,int);
240 170
241extern struct snd_ac97_bus_ops soc_ac97_ops; 171extern struct snd_ac97_bus_ops soc_ac97_ops;
242 172
173int snd_soc_register_platform(struct snd_soc_platform *platform);
174void snd_soc_unregister_platform(struct snd_soc_platform *platform);
175int snd_soc_register_codec(struct snd_soc_codec *codec);
176void snd_soc_unregister_codec(struct snd_soc_codec *codec);
177
243/* pcm <-> DAI connect */ 178/* pcm <-> DAI connect */
244void snd_soc_free_pcms(struct snd_soc_device *socdev); 179void snd_soc_free_pcms(struct snd_soc_device *socdev);
245int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); 180int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
246int snd_soc_register_card(struct snd_soc_device *socdev); 181int snd_soc_init_card(struct snd_soc_device *socdev);
247 182
248/* set runtime hw params */ 183/* set runtime hw params */
249int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, 184int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
@@ -263,27 +198,6 @@ int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
263 struct snd_ac97_bus_ops *ops, int num); 198 struct snd_ac97_bus_ops *ops, int num);
264void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); 199void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
265 200
266/* Digital Audio Interface clocking API.*/
267int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
268 unsigned int freq, int dir);
269
270int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
271 int div_id, int div);
272
273int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
274 int pll_id, unsigned int freq_in, unsigned int freq_out);
275
276/* Digital Audio interface formatting */
277int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
278
279int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
280 unsigned int mask, int slots);
281
282int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
283
284/* Digital Audio Interface mute */
285int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute);
286
287/* 201/*
288 *Controls 202 *Controls
289 */ 203 */
@@ -297,6 +211,12 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
297 struct snd_ctl_elem_value *ucontrol); 211 struct snd_ctl_elem_value *ucontrol);
298int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, 212int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
299 struct snd_ctl_elem_value *ucontrol); 213 struct snd_ctl_elem_value *ucontrol);
214int snd_soc_info_value_enum_double(struct snd_kcontrol *kcontrol,
215 struct snd_ctl_elem_info *uinfo);
216int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
217 struct snd_ctl_elem_value *ucontrol);
218int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
219 struct snd_ctl_elem_value *ucontrol);
300int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, 220int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
301 struct snd_ctl_elem_info *uinfo); 221 struct snd_ctl_elem_info *uinfo);
302int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, 222int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
@@ -341,66 +261,14 @@ struct snd_soc_ops {
341 int (*trigger)(struct snd_pcm_substream *, int); 261 int (*trigger)(struct snd_pcm_substream *, int);
342}; 262};
343 263
344/* ASoC DAI ops */
345struct snd_soc_dai_ops {
346 /* DAI clocking configuration */
347 int (*set_sysclk)(struct snd_soc_dai *dai,
348 int clk_id, unsigned int freq, int dir);
349 int (*set_pll)(struct snd_soc_dai *dai,
350 int pll_id, unsigned int freq_in, unsigned int freq_out);
351 int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
352
353 /* DAI format configuration */
354 int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
355 int (*set_tdm_slot)(struct snd_soc_dai *dai,
356 unsigned int mask, int slots);
357 int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
358
359 /* digital mute */
360 int (*digital_mute)(struct snd_soc_dai *dai, int mute);
361};
362
363/* SoC DAI (Digital Audio Interface) */
364struct snd_soc_dai {
365 /* DAI description */
366 char *name;
367 unsigned int id;
368 unsigned char type;
369
370 /* DAI callbacks */
371 int (*probe)(struct platform_device *pdev,
372 struct snd_soc_dai *dai);
373 void (*remove)(struct platform_device *pdev,
374 struct snd_soc_dai *dai);
375 int (*suspend)(struct platform_device *pdev,
376 struct snd_soc_dai *dai);
377 int (*resume)(struct platform_device *pdev,
378 struct snd_soc_dai *dai);
379
380 /* ops */
381 struct snd_soc_ops ops;
382 struct snd_soc_dai_ops dai_ops;
383
384 /* DAI capabilities */
385 struct snd_soc_pcm_stream capture;
386 struct snd_soc_pcm_stream playback;
387
388 /* DAI runtime info */
389 struct snd_pcm_runtime *runtime;
390 struct snd_soc_codec *codec;
391 unsigned int active;
392 unsigned char pop_wait:1;
393 void *dma_data;
394
395 /* DAI private data */
396 void *private_data;
397};
398
399/* SoC Audio Codec */ 264/* SoC Audio Codec */
400struct snd_soc_codec { 265struct snd_soc_codec {
401 char *name; 266 char *name;
402 struct module *owner; 267 struct module *owner;
403 struct mutex mutex; 268 struct mutex mutex;
269 struct device *dev;
270
271 struct list_head list;
404 272
405 /* callbacks */ 273 /* callbacks */
406 int (*set_bias_level)(struct snd_soc_codec *, 274 int (*set_bias_level)(struct snd_soc_codec *,
@@ -426,6 +294,7 @@ struct snd_soc_codec {
426 short reg_cache_step; 294 short reg_cache_step;
427 295
428 /* dapm */ 296 /* dapm */
297 u32 pop_time;
429 struct list_head dapm_widgets; 298 struct list_head dapm_widgets;
430 struct list_head dapm_paths; 299 struct list_head dapm_paths;
431 enum snd_soc_bias_level bias_level; 300 enum snd_soc_bias_level bias_level;
@@ -435,6 +304,11 @@ struct snd_soc_codec {
435 /* codec DAI's */ 304 /* codec DAI's */
436 struct snd_soc_dai *dai; 305 struct snd_soc_dai *dai;
437 unsigned int num_dai; 306 unsigned int num_dai;
307
308#ifdef CONFIG_DEBUG_FS
309 struct dentry *debugfs_reg;
310 struct dentry *debugfs_pop_time;
311#endif
438}; 312};
439 313
440/* codec device */ 314/* codec device */
@@ -448,13 +322,12 @@ struct snd_soc_codec_device {
448/* SoC platform interface */ 322/* SoC platform interface */
449struct snd_soc_platform { 323struct snd_soc_platform {
450 char *name; 324 char *name;
325 struct list_head list;
451 326
452 int (*probe)(struct platform_device *pdev); 327 int (*probe)(struct platform_device *pdev);
453 int (*remove)(struct platform_device *pdev); 328 int (*remove)(struct platform_device *pdev);
454 int (*suspend)(struct platform_device *pdev, 329 int (*suspend)(struct snd_soc_dai *dai);
455 struct snd_soc_dai *dai); 330 int (*resume)(struct snd_soc_dai *dai);
456 int (*resume)(struct platform_device *pdev,
457 struct snd_soc_dai *dai);
458 331
459 /* pcm creation and destruction */ 332 /* pcm creation and destruction */
460 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, 333 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
@@ -484,9 +357,14 @@ struct snd_soc_dai_link {
484 struct snd_pcm *pcm; 357 struct snd_pcm *pcm;
485}; 358};
486 359
487/* SoC machine */ 360/* SoC card */
488struct snd_soc_machine { 361struct snd_soc_card {
489 char *name; 362 char *name;
363 struct device *dev;
364
365 struct list_head list;
366
367 int instantiated;
490 368
491 int (*probe)(struct platform_device *pdev); 369 int (*probe)(struct platform_device *pdev);
492 int (*remove)(struct platform_device *pdev); 370 int (*remove)(struct platform_device *pdev);
@@ -499,23 +377,26 @@ struct snd_soc_machine {
499 int (*resume_post)(struct platform_device *pdev); 377 int (*resume_post)(struct platform_device *pdev);
500 378
501 /* callbacks */ 379 /* callbacks */
502 int (*set_bias_level)(struct snd_soc_machine *, 380 int (*set_bias_level)(struct snd_soc_card *,
503 enum snd_soc_bias_level level); 381 enum snd_soc_bias_level level);
504 382
505 /* CPU <--> Codec DAI links */ 383 /* CPU <--> Codec DAI links */
506 struct snd_soc_dai_link *dai_link; 384 struct snd_soc_dai_link *dai_link;
507 int num_links; 385 int num_links;
386
387 struct snd_soc_device *socdev;
388
389 struct snd_soc_platform *platform;
390 struct delayed_work delayed_work;
391 struct work_struct deferred_resume_work;
508}; 392};
509 393
510/* SoC Device - the audio subsystem */ 394/* SoC Device - the audio subsystem */
511struct snd_soc_device { 395struct snd_soc_device {
512 struct device *dev; 396 struct device *dev;
513 struct snd_soc_machine *machine; 397 struct snd_soc_card *card;
514 struct snd_soc_platform *platform;
515 struct snd_soc_codec *codec; 398 struct snd_soc_codec *codec;
516 struct snd_soc_codec_device *codec_dev; 399 struct snd_soc_codec_device *codec_dev;
517 struct delayed_work delayed_work;
518 struct work_struct deferred_resume_work;
519 void *codec_data; 400 void *codec_data;
520}; 401};
521 402
@@ -542,4 +423,19 @@ struct soc_enum {
542 void *dapm; 423 void *dapm;
543}; 424};
544 425
426/* semi enumerated kcontrol */
427struct soc_value_enum {
428 unsigned short reg;
429 unsigned short reg2;
430 unsigned char shift_l;
431 unsigned char shift_r;
432 unsigned int max;
433 unsigned int mask;
434 const char **texts;
435 const unsigned int *values;
436 void *dapm;
437};
438
439#include <sound/soc-dai.h>
440
545#endif 441#endif