dai.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_H__
  9. #define __INCLUDE_SOUND_SOF_DAI_H__
  10. #include <sound/sof/header.h>
  11. #include <sound/sof/dai-intel.h>
  12. #include <sound/sof/dai-imx.h>
  13. #include <sound/sof/dai-amd.h>
  14. #include <sound/sof/dai-mediatek.h>
  15. /*
  16. * DAI Configuration.
  17. *
  18. * Each different DAI type will have it's own structure and IPC cmd.
  19. */
  20. #define SOF_DAI_FMT_I2S 1 /**< I2S mode */
  21. #define SOF_DAI_FMT_RIGHT_J 2 /**< Right Justified mode */
  22. #define SOF_DAI_FMT_LEFT_J 3 /**< Left Justified mode */
  23. #define SOF_DAI_FMT_DSP_A 4 /**< L data MSB after FRM LRC */
  24. #define SOF_DAI_FMT_DSP_B 5 /**< L data MSB during FRM LRC */
  25. #define SOF_DAI_FMT_PDM 6 /**< Pulse density modulation */
  26. #define SOF_DAI_FMT_CONT (1 << 4) /**< continuous clock */
  27. #define SOF_DAI_FMT_GATED (0 << 4) /**< clock is gated */
  28. #define SOF_DAI_FMT_NB_NF (0 << 8) /**< normal bit clock + frame */
  29. #define SOF_DAI_FMT_NB_IF (2 << 8) /**< normal BCLK + inv FRM */
  30. #define SOF_DAI_FMT_IB_NF (3 << 8) /**< invert BCLK + nor FRM */
  31. #define SOF_DAI_FMT_IB_IF (4 << 8) /**< invert BCLK + FRM */
  32. #define SOF_DAI_FMT_CBP_CFP (0 << 12) /**< codec bclk provider & frame provider */
  33. #define SOF_DAI_FMT_CBC_CFP (2 << 12) /**< codec bclk consumer & frame provider */
  34. #define SOF_DAI_FMT_CBP_CFC (3 << 12) /**< codec bclk provider & frame consumer */
  35. #define SOF_DAI_FMT_CBC_CFC (4 << 12) /**< codec bclk consumer & frame consumer */
  36. /* keep old definitions for backwards compatibility */
  37. #define SOF_DAI_FMT_CBM_CFM SOF_DAI_FMT_CBP_CFP
  38. #define SOF_DAI_FMT_CBS_CFM SOF_DAI_FMT_CBC_CFP
  39. #define SOF_DAI_FMT_CBM_CFS SOF_DAI_FMT_CBP_CFC
  40. #define SOF_DAI_FMT_CBS_CFS SOF_DAI_FMT_CBC_CFC
  41. #define SOF_DAI_FMT_FORMAT_MASK 0x000f
  42. #define SOF_DAI_FMT_CLOCK_MASK 0x00f0
  43. #define SOF_DAI_FMT_INV_MASK 0x0f00
  44. #define SOF_DAI_FMT_CLOCK_PROVIDER_MASK 0xf000
  45. /*
  46. * DAI_CONFIG flags. The 4 LSB bits are used for the commands, HW_PARAMS, HW_FREE and PAUSE
  47. * representing when the IPC is sent. The 4 MSB bits are used to add quirks along with the above
  48. * commands.
  49. */
  50. #define SOF_DAI_CONFIG_FLAGS_CMD_MASK 0xF
  51. #define SOF_DAI_CONFIG_FLAGS_NONE 0 /**< DAI_CONFIG sent without stage information */
  52. #define SOF_DAI_CONFIG_FLAGS_HW_PARAMS BIT(0) /**< DAI_CONFIG sent during hw_params stage */
  53. #define SOF_DAI_CONFIG_FLAGS_HW_FREE BIT(1) /**< DAI_CONFIG sent during hw_free stage */
  54. /**< DAI_CONFIG sent during pause trigger. Only available ABI 3.20 onwards */
  55. #define SOF_DAI_CONFIG_FLAGS_PAUSE BIT(2)
  56. #define SOF_DAI_CONFIG_FLAGS_QUIRK_SHIFT 4
  57. #define SOF_DAI_CONFIG_FLAGS_QUIRK_MASK (0xF << SOF_DAI_CONFIG_FLAGS_QUIRK_SHIFT)
  58. /*
  59. * This should be used along with the SOF_DAI_CONFIG_FLAGS_HW_PARAMS to indicate that pipeline
  60. * stop/pause and DAI DMA stop/pause should happen in two steps. This change is only available
  61. * ABI 3.20 onwards.
  62. */
  63. #define SOF_DAI_CONFIG_FLAGS_2_STEP_STOP BIT(0)
  64. /** \brief Types of DAI */
  65. enum sof_ipc_dai_type {
  66. SOF_DAI_INTEL_NONE = 0, /**< None */
  67. SOF_DAI_INTEL_SSP, /**< Intel SSP */
  68. SOF_DAI_INTEL_DMIC, /**< Intel DMIC */
  69. SOF_DAI_INTEL_HDA, /**< Intel HD/A */
  70. SOF_DAI_INTEL_ALH, /**< Intel ALH */
  71. SOF_DAI_IMX_SAI, /**< i.MX SAI */
  72. SOF_DAI_IMX_ESAI, /**< i.MX ESAI */
  73. SOF_DAI_AMD_BT, /**< AMD ACP BT*/
  74. SOF_DAI_AMD_SP, /**< AMD ACP SP */
  75. SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */
  76. SOF_DAI_MEDIATEK_AFE, /**< Mediatek AFE */
  77. SOF_DAI_AMD_HS, /**< Amd HS */
  78. SOF_DAI_AMD_SP_VIRTUAL, /**< AMD ACP SP VIRTUAL */
  79. SOF_DAI_AMD_HS_VIRTUAL, /**< AMD ACP HS VIRTUAL */
  80. SOF_DAI_IMX_MICFIL, /** < i.MX MICFIL PDM */
  81. SOF_DAI_AMD_SDW, /**< AMD ACP SDW */
  82. };
  83. /* general purpose DAI configuration */
  84. struct sof_ipc_dai_config {
  85. struct sof_ipc_cmd_hdr hdr;
  86. uint32_t type; /**< DAI type - enum sof_ipc_dai_type */
  87. uint32_t dai_index; /**< index of this type dai */
  88. /* physical protocol and clocking */
  89. uint16_t format; /**< SOF_DAI_FMT_ */
  90. uint8_t group_id; /**< group ID, 0 means no group (ABI 3.17) */
  91. uint8_t flags; /**< SOF_DAI_CONFIG_FLAGS_ (ABI 3.19) */
  92. /* reserved for future use */
  93. uint32_t reserved[8];
  94. /* HW specific data */
  95. union {
  96. struct sof_ipc_dai_ssp_params ssp;
  97. struct sof_ipc_dai_dmic_params dmic;
  98. struct sof_ipc_dai_hda_params hda;
  99. struct sof_ipc_dai_alh_params alh;
  100. struct sof_ipc_dai_esai_params esai;
  101. struct sof_ipc_dai_sai_params sai;
  102. struct sof_ipc_dai_acp_params acpbt;
  103. struct sof_ipc_dai_acp_params acpsp;
  104. struct sof_ipc_dai_acpdmic_params acpdmic;
  105. struct sof_ipc_dai_acp_params acphs;
  106. struct sof_ipc_dai_mtk_afe_params afe;
  107. struct sof_ipc_dai_micfil_params micfil;
  108. struct sof_ipc_dai_acp_sdw_params acp_sdw;
  109. };
  110. } __packed;
  111. struct sof_dai_private_data {
  112. struct sof_ipc_comp_dai *comp_dai;
  113. struct sof_ipc_dai_config *dai_config;
  114. };
  115. #endif