dai-intel.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
  2. /*
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * Copyright(c) 2018 Intel Corporation
  7. */
  8. #ifndef __INCLUDE_SOUND_SOF_DAI_INTEL_H__
  9. #define __INCLUDE_SOUND_SOF_DAI_INTEL_H__
  10. #include <sound/sof/header.h>
  11. /* ssc1: TINTE */
  12. #define SOF_DAI_INTEL_SSP_QUIRK_TINTE (1 << 0)
  13. /* ssc1: PINTE */
  14. #define SOF_DAI_INTEL_SSP_QUIRK_PINTE (1 << 1)
  15. /* ssc2: SMTATF */
  16. #define SOF_DAI_INTEL_SSP_QUIRK_SMTATF (1 << 2)
  17. /* ssc2: MMRATF */
  18. #define SOF_DAI_INTEL_SSP_QUIRK_MMRATF (1 << 3)
  19. /* ssc2: PSPSTWFDFD */
  20. #define SOF_DAI_INTEL_SSP_QUIRK_PSPSTWFDFD (1 << 4)
  21. /* ssc2: PSPSRWFDFD */
  22. #define SOF_DAI_INTEL_SSP_QUIRK_PSPSRWFDFD (1 << 5)
  23. /* ssc1: LBM */
  24. #define SOF_DAI_INTEL_SSP_QUIRK_LBM (1 << 6)
  25. /* here is the possibility to define others aux macros */
  26. #define SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX 38
  27. #define SOF_DAI_INTEL_SSP_SLOT_PADDING_MAX 31
  28. /* SSP clocks control settings
  29. *
  30. * Macros for clks_control field in sof_ipc_dai_ssp_params struct.
  31. */
  32. /* mclk 0 disable */
  33. #define SOF_DAI_INTEL_SSP_MCLK_0_DISABLE BIT(0)
  34. /* mclk 1 disable */
  35. #define SOF_DAI_INTEL_SSP_MCLK_1_DISABLE BIT(1)
  36. /* mclk keep active */
  37. #define SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_KA BIT(2)
  38. /* bclk keep active */
  39. #define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_KA BIT(3)
  40. /* fs keep active */
  41. #define SOF_DAI_INTEL_SSP_CLKCTRL_FS_KA BIT(4)
  42. /* bclk idle */
  43. #define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_IDLE_HIGH BIT(5)
  44. /* mclk early start */
  45. #define SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_ES BIT(6)
  46. /* bclk early start */
  47. #define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES BIT(7)
  48. /* mclk always on */
  49. #define SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_AON BIT(8)
  50. /* DMIC max. four controllers for eight microphone channels */
  51. #define SOF_DAI_INTEL_DMIC_NUM_CTRL 4
  52. /* SSP Configuration Request - SOF_IPC_DAI_SSP_CONFIG */
  53. struct sof_ipc_dai_ssp_params {
  54. struct sof_ipc_hdr hdr;
  55. uint16_t reserved1;
  56. uint16_t mclk_id;
  57. uint32_t mclk_rate; /* mclk frequency in Hz */
  58. uint32_t fsync_rate; /* fsync frequency in Hz */
  59. uint32_t bclk_rate; /* bclk frequency in Hz */
  60. /* TDM */
  61. uint32_t tdm_slots;
  62. uint32_t rx_slots;
  63. uint32_t tx_slots;
  64. /* data */
  65. uint32_t sample_valid_bits;
  66. uint16_t tdm_slot_width;
  67. uint16_t reserved2; /* alignment */
  68. /* MCLK */
  69. uint32_t mclk_direction;
  70. uint16_t frame_pulse_width;
  71. uint16_t tdm_per_slot_padding_flag;
  72. uint32_t clks_control;
  73. uint32_t quirks;
  74. uint32_t bclk_delay; /* guaranteed time (ms) for which BCLK
  75. * will be driven, before sending data
  76. */
  77. } __packed;
  78. /* HDA Configuration Request - SOF_IPC_DAI_HDA_CONFIG */
  79. struct sof_ipc_dai_hda_params {
  80. struct sof_ipc_hdr hdr;
  81. uint32_t link_dma_ch;
  82. uint32_t rate;
  83. uint32_t channels;
  84. } __packed;
  85. /* ALH Configuration Request - SOF_IPC_DAI_ALH_CONFIG */
  86. struct sof_ipc_dai_alh_params {
  87. struct sof_ipc_hdr hdr;
  88. uint32_t stream_id;
  89. uint32_t rate;
  90. uint32_t channels;
  91. /* reserved for future use */
  92. uint32_t reserved[13];
  93. } __packed;
  94. /* DMIC Configuration Request - SOF_IPC_DAI_DMIC_CONFIG */
  95. /* This struct is defined per 2ch PDM controller available in the platform.
  96. * Normally it is sufficient to set the used microphone specific enables to 1
  97. * and keep other parameters as zero. The customizations are:
  98. *
  99. * 1. If a device mixes different microphones types with different polarity
  100. * and/or the absolute polarity matters the PCM signal from a microphone
  101. * can be inverted with the controls.
  102. *
  103. * 2. If the microphones in a stereo pair do not appear in captured stream
  104. * in desired order due to board schematics choises they can be swapped with
  105. * the clk_edge parameter.
  106. *
  107. * 3. If PDM bit errors are seen in capture (poor quality) the skew parameter
  108. * that delays the sampling time of data by half cycles of DMIC source clock
  109. * can be tried for improvement. However there is no guarantee for this to fix
  110. * data integrity problems.
  111. */
  112. struct sof_ipc_dai_dmic_pdm_ctrl {
  113. struct sof_ipc_hdr hdr;
  114. uint16_t id; /**< PDM controller ID */
  115. uint16_t enable_mic_a; /**< Use A (left) channel mic (0 or 1)*/
  116. uint16_t enable_mic_b; /**< Use B (right) channel mic (0 or 1)*/
  117. uint16_t polarity_mic_a; /**< Optionally invert mic A signal (0 or 1) */
  118. uint16_t polarity_mic_b; /**< Optionally invert mic B signal (0 or 1) */
  119. uint16_t clk_edge; /**< Optionally swap data clock edge (0 or 1) */
  120. uint16_t skew; /**< Adjust PDM data sampling vs. clock (0..15) */
  121. uint16_t reserved[3]; /**< Make sure the total size is 4 bytes aligned */
  122. } __packed;
  123. /* This struct contains the global settings for all 2ch PDM controllers. The
  124. * version number used in configuration data is checked vs. version used by
  125. * device driver src/drivers/dmic.c need to match. It is incremented from
  126. * initial value 1 if updates done for the to driver would alter the operation
  127. * of the microphone.
  128. *
  129. * Note: The microphone clock (pdmclk_min, pdmclk_max, duty_min, duty_max)
  130. * parameters need to be set as defined in microphone data sheet. E.g. clock
  131. * range 1.0 - 3.2 MHz is usually supported microphones. Some microphones are
  132. * multi-mode capable and there may be denied mic clock frequencies between
  133. * the modes. In such case set the clock range limits of the desired mode to
  134. * avoid the driver to set clock to an illegal rate.
  135. *
  136. * The duty cycle could be set to 48-52% if not known. Generally these
  137. * parameters can be altered within data sheet specified limits to match
  138. * required audio application performance power.
  139. *
  140. * The microphone clock needs to be usually about 50-80 times the used audio
  141. * sample rate. With highest sample rates above 48 kHz this can relaxed
  142. * somewhat.
  143. *
  144. * The parameter wake_up_time describes how long time the microphone needs
  145. * for the data line to produce valid output from mic clock start. The driver
  146. * will mute the captured audio for the given time. The min_clock_on_time
  147. * parameter is used to prevent too short clock bursts to happen. The driver
  148. * will keep the clock active after capture stop if this time is not yet
  149. * met. The unit for both is microseconds (us). Exceed of 100 ms will be
  150. * treated as an error.
  151. */
  152. struct sof_ipc_dai_dmic_params {
  153. struct sof_ipc_hdr hdr;
  154. uint32_t driver_ipc_version; /**< Version (1..N) */
  155. uint32_t pdmclk_min; /**< Minimum microphone clock in Hz (100000..N) */
  156. uint32_t pdmclk_max; /**< Maximum microphone clock in Hz (min...N) */
  157. uint32_t fifo_fs; /**< FIFO sample rate in Hz (8000..96000) */
  158. uint32_t reserved_1; /**< Reserved */
  159. uint16_t fifo_bits; /**< FIFO word length (16 or 32) */
  160. uint16_t fifo_bits_b; /**< Deprecated since firmware ABI 3.0.1 */
  161. uint16_t duty_min; /**< Min. mic clock duty cycle in % (20..80) */
  162. uint16_t duty_max; /**< Max. mic clock duty cycle in % (min..80) */
  163. uint32_t num_pdm_active; /**< Number of active pdm controllers. */
  164. /**< Range is 1..SOF_DAI_INTEL_DMIC_NUM_CTRL */
  165. uint32_t wake_up_time; /**< Time from clock start to data (us) */
  166. uint32_t min_clock_on_time; /**< Min. time that clk is kept on (us) */
  167. uint32_t unmute_ramp_time; /**< Length of logarithmic gain ramp (ms) */
  168. /* reserved for future use */
  169. uint32_t reserved[5];
  170. /**< PDM controllers configuration */
  171. struct sof_ipc_dai_dmic_pdm_ctrl pdm[SOF_DAI_INTEL_DMIC_NUM_CTRL];
  172. } __packed;
  173. #endif