intel-nhlt.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * intel-nhlt.h - Intel HDA Platform NHLT header
  4. *
  5. * Copyright (c) 2015-2019 Intel Corporation
  6. */
  7. #ifndef __INTEL_NHLT_H__
  8. #define __INTEL_NHLT_H__
  9. #include <linux/acpi.h>
  10. enum nhlt_link_type {
  11. NHLT_LINK_HDA = 0,
  12. NHLT_LINK_DSP = 1,
  13. NHLT_LINK_DMIC = 2,
  14. NHLT_LINK_SSP = 3,
  15. NHLT_LINK_INVALID
  16. };
  17. enum nhlt_device_type {
  18. NHLT_DEVICE_BT = 0,
  19. NHLT_DEVICE_DMIC = 1,
  20. NHLT_DEVICE_I2S = 4,
  21. NHLT_DEVICE_INVALID
  22. };
  23. struct wav_fmt {
  24. u16 fmt_tag;
  25. u16 channels;
  26. u32 samples_per_sec;
  27. u32 avg_bytes_per_sec;
  28. u16 block_align;
  29. u16 bits_per_sample;
  30. u16 cb_size;
  31. } __packed;
  32. struct wav_fmt_ext {
  33. struct wav_fmt fmt;
  34. union samples {
  35. u16 valid_bits_per_sample;
  36. u16 samples_per_block;
  37. u16 reserved;
  38. } sample;
  39. u32 channel_mask;
  40. u8 sub_fmt[16];
  41. } __packed;
  42. struct nhlt_specific_cfg {
  43. u32 size;
  44. u8 caps[];
  45. } __packed;
  46. struct nhlt_fmt_cfg {
  47. struct wav_fmt_ext fmt_ext;
  48. struct nhlt_specific_cfg config;
  49. } __packed;
  50. struct nhlt_fmt {
  51. u8 fmt_count;
  52. struct nhlt_fmt_cfg fmt_config[];
  53. } __packed;
  54. struct nhlt_endpoint {
  55. u32 length;
  56. u8 linktype;
  57. u8 instance_id;
  58. u16 vendor_id;
  59. u16 device_id;
  60. u16 revision_id;
  61. u32 subsystem_id;
  62. u8 device_type;
  63. u8 direction;
  64. u8 virtual_bus_id;
  65. struct nhlt_specific_cfg config;
  66. } __packed;
  67. struct nhlt_acpi_table {
  68. struct acpi_table_header header;
  69. u8 endpoint_count;
  70. struct nhlt_endpoint desc[];
  71. } __packed;
  72. struct nhlt_resource_desc {
  73. u32 extra;
  74. u16 flags;
  75. u64 addr_spc_gra;
  76. u64 min_addr;
  77. u64 max_addr;
  78. u64 addr_trans_offset;
  79. u64 length;
  80. } __packed;
  81. #define MIC_ARRAY_2CH 2
  82. #define MIC_ARRAY_4CH 4
  83. struct nhlt_device_specific_config {
  84. u8 virtual_slot;
  85. u8 config_type;
  86. } __packed;
  87. struct nhlt_dmic_array_config {
  88. struct nhlt_device_specific_config device_config;
  89. u8 array_type;
  90. } __packed;
  91. struct nhlt_vendor_dmic_array_config {
  92. struct nhlt_dmic_array_config dmic_config;
  93. u8 nb_mics;
  94. /* TODO add vendor mic config */
  95. } __packed;
  96. enum {
  97. NHLT_CONFIG_TYPE_GENERIC = 0,
  98. NHLT_CONFIG_TYPE_MIC_ARRAY = 1
  99. };
  100. enum {
  101. NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
  102. NHLT_MIC_ARRAY_2CH_BIG = 0xb,
  103. NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
  104. NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
  105. NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
  106. NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
  107. };
  108. #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT)
  109. struct nhlt_acpi_table *intel_nhlt_init(struct device *dev);
  110. void intel_nhlt_free(struct nhlt_acpi_table *addr);
  111. int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt);
  112. bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type);
  113. int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type);
  114. int intel_nhlt_ssp_mclk_mask(struct nhlt_acpi_table *nhlt, int ssp_num);
  115. struct nhlt_specific_cfg *
  116. intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
  117. u32 bus_id, u8 link_type, u8 vbps, u8 bps,
  118. u8 num_ch, u32 rate, u8 dir, u8 dev_type);
  119. #else
  120. static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
  121. {
  122. return NULL;
  123. }
  124. static inline void intel_nhlt_free(struct nhlt_acpi_table *addr)
  125. {
  126. }
  127. static inline int intel_nhlt_get_dmic_geo(struct device *dev,
  128. struct nhlt_acpi_table *nhlt)
  129. {
  130. return 0;
  131. }
  132. static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt,
  133. u8 link_type)
  134. {
  135. return false;
  136. }
  137. static inline int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type)
  138. {
  139. return 0;
  140. }
  141. static inline int intel_nhlt_ssp_mclk_mask(struct nhlt_acpi_table *nhlt, int ssp_num)
  142. {
  143. return 0;
  144. }
  145. static inline struct nhlt_specific_cfg *
  146. intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
  147. u32 bus_id, u8 link_type, u8 vbps, u8 bps,
  148. u8 num_ch, u32 rate, u8 dir, u8 dev_type)
  149. {
  150. return NULL;
  151. }
  152. #endif
  153. #endif