soc-dai.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 Left/Right Clocks.
  41. *
  42. * Specifies whether the DAI can support different samples for similtanious
  43. * playback and capture. This usually requires a seperate physical frame
  44. * clock for playback and capture.
  45. */
  46. #define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */
  47. #define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */
  48. /*
  49. * TDM
  50. *
  51. * Time Division Multiplexing. Allows PCM data to be multplexed with other
  52. * data on the DAI.
  53. */
  54. #define SND_SOC_DAIFMT_TDM (1 << 6)
  55. /*
  56. * DAI hardware signal inversions.
  57. *
  58. * Specifies whether the DAI can also support inverted clocks for the specified
  59. * format.
  60. */
  61. #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bit clock + frame */
  62. #define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */
  63. #define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */
  64. #define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */
  65. /*
  66. * DAI hardware clock masters.
  67. *
  68. * This is wrt the codec, the inverse is true for the interface
  69. * i.e. if the codec is clk and frm master then the interface is
  70. * clk and frame slave.
  71. */
  72. #define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */
  73. #define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */
  74. #define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */
  75. #define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */
  76. #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
  77. #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
  78. #define SND_SOC_DAIFMT_INV_MASK 0x0f00
  79. #define SND_SOC_DAIFMT_MASTER_MASK 0xf000
  80. /*
  81. * Master Clock Directions
  82. */
  83. #define SND_SOC_CLOCK_IN 0
  84. #define SND_SOC_CLOCK_OUT 1
  85. struct snd_soc_dai_ops;
  86. struct snd_soc_dai;
  87. struct snd_ac97_bus_ops;
  88. /* Digital Audio Interface clocking API.*/
  89. int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
  90. unsigned int freq, int dir);
  91. int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
  92. int div_id, int div);
  93. int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
  94. int pll_id, unsigned int freq_in, unsigned int freq_out);
  95. /* Digital Audio interface formatting */
  96. int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
  97. int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
  98. unsigned int mask, int slots);
  99. int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
  100. /* Digital Audio Interface mute */
  101. int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute);
  102. /*
  103. * Digital Audio Interface.
  104. *
  105. * Describes the Digital Audio Interface in terms of it's ALSA, DAI and AC97
  106. * operations an capabilities. Codec and platfom drivers will register a this
  107. * structure for every DAI they have.
  108. *
  109. * This structure covers the clocking, formating and ALSA operations for each
  110. * interface a
  111. */
  112. struct snd_soc_dai_ops {
  113. /*
  114. * DAI clocking configuration, all optional.
  115. * Called by soc_card drivers, normally in their hw_params.
  116. */
  117. int (*set_sysclk)(struct snd_soc_dai *dai,
  118. int clk_id, unsigned int freq, int dir);
  119. int (*set_pll)(struct snd_soc_dai *dai,
  120. int pll_id, unsigned int freq_in, unsigned int freq_out);
  121. int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
  122. /*
  123. * DAI format configuration
  124. * Called by soc_card drivers, normally in their hw_params.
  125. */
  126. int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
  127. int (*set_tdm_slot)(struct snd_soc_dai *dai,
  128. unsigned int mask, int slots);
  129. int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
  130. /*
  131. * DAI digital mute - optional.
  132. * Called by soc-core to minimise any pops.
  133. */
  134. int (*digital_mute)(struct snd_soc_dai *dai, int mute);
  135. /*
  136. * ALSA PCM audio operations - all optional.
  137. * Called by soc-core during audio PCM operations.
  138. */
  139. int (*startup)(struct snd_pcm_substream *,
  140. struct snd_soc_dai *);
  141. void (*shutdown)(struct snd_pcm_substream *,
  142. struct snd_soc_dai *);
  143. int (*hw_params)(struct snd_pcm_substream *,
  144. struct snd_pcm_hw_params *, struct snd_soc_dai *);
  145. int (*hw_free)(struct snd_pcm_substream *,
  146. struct snd_soc_dai *);
  147. int (*prepare)(struct snd_pcm_substream *,
  148. struct snd_soc_dai *);
  149. int (*trigger)(struct snd_pcm_substream *, int,
  150. struct snd_soc_dai *);
  151. };
  152. /*
  153. * Digital Audio Interface runtime data.
  154. *
  155. * Holds runtime data for a DAI.
  156. */
  157. struct snd_soc_dai {
  158. /* DAI description */
  159. char *name;
  160. unsigned int id;
  161. int ac97_control;
  162. /* DAI callbacks */
  163. int (*probe)(struct platform_device *pdev,
  164. struct snd_soc_dai *dai);
  165. void (*remove)(struct platform_device *pdev,
  166. struct snd_soc_dai *dai);
  167. int (*suspend)(struct platform_device *pdev,
  168. struct snd_soc_dai *dai);
  169. int (*resume)(struct platform_device *pdev,
  170. struct snd_soc_dai *dai);
  171. /* ops */
  172. struct snd_soc_dai_ops ops;
  173. /* DAI capabilities */
  174. struct snd_soc_pcm_stream capture;
  175. struct snd_soc_pcm_stream playback;
  176. /* DAI runtime info */
  177. struct snd_pcm_runtime *runtime;
  178. struct snd_soc_codec *codec;
  179. unsigned int active;
  180. unsigned char pop_wait:1;
  181. void *dma_data;
  182. /* DAI private data */
  183. void *private_data;
  184. /* parent codec/platform */
  185. union {
  186. struct snd_soc_codec *codec;
  187. struct snd_soc_platform *platform;
  188. };
  189. struct list_head list;
  190. };
  191. #endif