soc-dai.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * linux/sound/soc-dai.h -- ALSA SoC Layer
  3. *
  4. * Copyright: 2005-2008 Wolfson Microelectronics. PLC.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Digital Audio Interface (DAI) API.
  11. */
  12. #ifndef __LINUX_SND_SOC_DAI_H
  13. #define __LINUX_SND_SOC_DAI_H
  14. #include <linux/list.h>
  15. struct snd_pcm_substream;
  16. /*
  17. * DAI hardware audio formats.
  18. *
  19. * Describes the physical PCM data formating and clocking. Add new formats
  20. * to the end.
  21. */
  22. #define SND_SOC_DAIFMT_I2S 0 /* I2S mode */
  23. #define SND_SOC_DAIFMT_RIGHT_J 1 /* Right Justified mode */
  24. #define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */
  25. #define SND_SOC_DAIFMT_DSP_A 3 /* L data msb after FRM LRC */
  26. #define SND_SOC_DAIFMT_DSP_B 4 /* L data msb during FRM LRC */
  27. #define SND_SOC_DAIFMT_AC97 5 /* AC97 */
  28. /* left and right justified also known as MSB and LSB respectively */
  29. #define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J
  30. #define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J
  31. /*
  32. * DAI Clock gating.
  33. *
  34. * DAI bit clocks can be be gated (disabled) when not the DAI is not
  35. * sending or receiving PCM data in a frame. This can be used to save power.
  36. */
  37. #define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */
  38. #define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated */
  39. /*
  40. * DAI hardware signal inversions.
  41. *
  42. * Specifies whether the DAI can also support inverted clocks for the specified
  43. * format.
  44. */
  45. #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bit clock + frame */
  46. #define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */
  47. #define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */
  48. #define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */
  49. /*
  50. * DAI hardware clock masters.
  51. *
  52. * This is wrt the codec, the inverse is true for the interface
  53. * i.e. if the codec is clk and frm master then the interface is
  54. * clk and frame slave.
  55. */
  56. #define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */
  57. #define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */
  58. #define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */
  59. #define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */
  60. #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
  61. #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
  62. #define SND_SOC_DAIFMT_INV_MASK 0x0f00
  63. #define SND_SOC_DAIFMT_MASTER_MASK 0xf000
  64. /*
  65. * Master Clock Directions
  66. */
  67. #define SND_SOC_CLOCK_IN 0
  68. #define SND_SOC_CLOCK_OUT 1
  69. #define SND_SOC_STD_AC97_FMTS (SNDRV_PCM_FMTBIT_S16_LE |\
  70. SNDRV_PCM_FMTBIT_S32_LE |\
  71. SNDRV_PCM_FMTBIT_S32_BE)
  72. struct snd_soc_dai_ops;
  73. struct snd_soc_dai;
  74. struct snd_ac97_bus_ops;
  75. /* Digital Audio Interface registration */
  76. int snd_soc_register_dai(struct snd_soc_dai *dai);
  77. void snd_soc_unregister_dai(struct snd_soc_dai *dai);
  78. int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count);
  79. void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count);
  80. /* Digital Audio Interface clocking API.*/
  81. int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
  82. unsigned int freq, int dir);
  83. int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
  84. int div_id, int div);
  85. int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
  86. int pll_id, unsigned int freq_in, unsigned int freq_out);
  87. /* Digital Audio interface formatting */
  88. int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
  89. int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
  90. unsigned int mask, int slots);
  91. int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
  92. /* Digital Audio Interface mute */
  93. int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute);
  94. /*
  95. * Digital Audio Interface.
  96. *
  97. * Describes the Digital Audio Interface in terms of it's ALSA, DAI and AC97
  98. * operations an capabilities. Codec and platfom drivers will register a this
  99. * structure for every DAI they have.
  100. *
  101. * This structure covers the clocking, formating and ALSA operations for each
  102. * interface a
  103. */
  104. struct snd_soc_dai_ops {
  105. /*
  106. * DAI clocking configuration, all optional.
  107. * Called by soc_card drivers, normally in their hw_params.
  108. */
  109. int (*set_sysclk)(struct snd_soc_dai *dai,
  110. int clk_id, unsigned int freq, int dir);
  111. int (*set_pll)(struct snd_soc_dai *dai,
  112. int pll_id, unsigned int freq_in, unsigned int freq_out);
  113. int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
  114. /*
  115. * DAI format configuration
  116. * Called by soc_card drivers, normally in their hw_params.
  117. */
  118. int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
  119. int (*set_tdm_slot)(struct snd_soc_dai *dai,
  120. unsigned int mask, int slots);
  121. int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
  122. /*
  123. * DAI digital mute - optional.
  124. * Called by soc-core to minimise any pops.
  125. */
  126. int (*digital_mute)(struct snd_soc_dai *dai, int mute);
  127. /*
  128. * ALSA PCM audio operations - all optional.
  129. * Called by soc-core during audio PCM operations.
  130. */
  131. int (*startup)(struct snd_pcm_substream *,
  132. struct snd_soc_dai *);
  133. void (*shutdown)(struct snd_pcm_substream *,
  134. struct snd_soc_dai *);
  135. int (*hw_params)(struct snd_pcm_substream *,
  136. struct snd_pcm_hw_params *, struct snd_soc_dai *);
  137. int (*hw_free)(struct snd_pcm_substream *,
  138. struct snd_soc_dai *);
  139. int (*prepare)(struct snd_pcm_substream *,
  140. struct snd_soc_dai *);
  141. int (*trigger)(struct snd_pcm_substream *, int,
  142. struct snd_soc_dai *);
  143. };
  144. /*
  145. * Digital Audio Interface runtime data.
  146. *
  147. * Holds runtime data for a DAI.
  148. */
  149. struct snd_soc_dai {
  150. /* DAI description */
  151. char *name;
  152. unsigned int id;
  153. int ac97_control;
  154. struct device *dev;
  155. /* DAI callbacks */
  156. int (*probe)(struct platform_device *pdev,
  157. struct snd_soc_dai *dai);
  158. void (*remove)(struct platform_device *pdev,
  159. struct snd_soc_dai *dai);
  160. int (*suspend)(struct snd_soc_dai *dai);
  161. int (*resume)(struct snd_soc_dai *dai);
  162. /* ops */
  163. struct snd_soc_dai_ops *ops;
  164. /* DAI capabilities */
  165. struct snd_soc_pcm_stream capture;
  166. struct snd_soc_pcm_stream playback;
  167. unsigned int symmetric_rates:1;
  168. /* DAI runtime info */
  169. struct snd_pcm_runtime *runtime;
  170. struct snd_soc_codec *codec;
  171. unsigned int active;
  172. unsigned char pop_wait:1;
  173. void *dma_data;
  174. /* DAI private data */
  175. void *private_data;
  176. /* parent platform */
  177. struct snd_soc_platform *platform;
  178. struct list_head list;
  179. };
  180. #endif