Thomas Gleixner | 8e8e69d | 2019-05-29 07:17:59 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 2 | /* |
Pierre-Louis Bossart | 303681f | 2019-07-29 10:51:48 -0500 | [diff] [blame] | 3 | * intel-nhlt.h - Intel HDA Platform NHLT header |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 4 | * |
Pierre-Louis Bossart | 303681f | 2019-07-29 10:51:48 -0500 | [diff] [blame] | 5 | * Copyright (c) 2015-2019 Intel Corporation |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 6 | */ |
Pierre-Louis Bossart | 303681f | 2019-07-29 10:51:48 -0500 | [diff] [blame] | 7 | |
| 8 | #ifndef __INTEL_NHLT_H__ |
| 9 | #define __INTEL_NHLT_H__ |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 10 | |
Jeeja KP | aba3dd5 | 2015-08-01 19:40:40 +0530 | [diff] [blame] | 11 | #include <linux/acpi.h> |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 12 | |
Amadeusz Sławiński | 15fa179 | 2021-11-26 15:03:53 +0100 | [diff] [blame] | 13 | enum nhlt_link_type { |
| 14 | NHLT_LINK_HDA = 0, |
| 15 | NHLT_LINK_DSP = 1, |
| 16 | NHLT_LINK_DMIC = 2, |
| 17 | NHLT_LINK_SSP = 3, |
| 18 | NHLT_LINK_INVALID |
| 19 | }; |
| 20 | |
Pierre-Louis Bossart | 303681f | 2019-07-29 10:51:48 -0500 | [diff] [blame] | 21 | #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT) |
| 22 | |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 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 | |
| 33 | struct wav_fmt_ext { |
| 34 | struct wav_fmt fmt; |
| 35 | union samples { |
| 36 | u16 valid_bits_per_sample; |
| 37 | u16 samples_per_block; |
| 38 | u16 reserved; |
| 39 | } sample; |
| 40 | u32 channel_mask; |
| 41 | u8 sub_fmt[16]; |
| 42 | } __packed; |
| 43 | |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 44 | enum nhlt_device_type { |
| 45 | NHLT_DEVICE_BT = 0, |
| 46 | NHLT_DEVICE_DMIC = 1, |
| 47 | NHLT_DEVICE_I2S = 4, |
| 48 | NHLT_DEVICE_INVALID |
| 49 | }; |
| 50 | |
| 51 | struct nhlt_specific_cfg { |
| 52 | u32 size; |
Gustavo A. R. Silva | 9ad06eb | 2020-05-07 14:22:23 -0500 | [diff] [blame] | 53 | u8 caps[]; |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 54 | } __packed; |
| 55 | |
| 56 | struct nhlt_fmt_cfg { |
| 57 | struct wav_fmt_ext fmt_ext; |
| 58 | struct nhlt_specific_cfg config; |
| 59 | } __packed; |
| 60 | |
| 61 | struct nhlt_fmt { |
| 62 | u8 fmt_count; |
Gustavo A. R. Silva | 9ad06eb | 2020-05-07 14:22:23 -0500 | [diff] [blame] | 63 | struct nhlt_fmt_cfg fmt_config[]; |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 64 | } __packed; |
| 65 | |
| 66 | struct nhlt_endpoint { |
| 67 | u32 length; |
| 68 | u8 linktype; |
| 69 | u8 instance_id; |
| 70 | u16 vendor_id; |
| 71 | u16 device_id; |
| 72 | u16 revision_id; |
| 73 | u32 subsystem_id; |
| 74 | u8 device_type; |
| 75 | u8 direction; |
| 76 | u8 virtual_bus_id; |
| 77 | struct nhlt_specific_cfg config; |
| 78 | } __packed; |
| 79 | |
| 80 | struct nhlt_acpi_table { |
Jeeja KP | aba3dd5 | 2015-08-01 19:40:40 +0530 | [diff] [blame] | 81 | struct acpi_table_header header; |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 82 | u8 endpoint_count; |
Gustavo A. R. Silva | 9ad06eb | 2020-05-07 14:22:23 -0500 | [diff] [blame] | 83 | struct nhlt_endpoint desc[]; |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 84 | } __packed; |
| 85 | |
| 86 | struct nhlt_resource_desc { |
| 87 | u32 extra; |
| 88 | u16 flags; |
| 89 | u64 addr_spc_gra; |
| 90 | u64 min_addr; |
| 91 | u64 max_addr; |
| 92 | u64 addr_trans_offset; |
| 93 | u64 length; |
| 94 | } __packed; |
| 95 | |
Yong Zhi | f65cf7d6 | 2016-05-26 21:30:15 -0700 | [diff] [blame] | 96 | #define MIC_ARRAY_2CH 2 |
| 97 | #define MIC_ARRAY_4CH 4 |
| 98 | |
Pierre-Louis Bossart | 7a33ea7 | 2019-07-29 10:51:49 -0500 | [diff] [blame] | 99 | struct nhlt_device_specific_config { |
Yong Zhi | f65cf7d6 | 2016-05-26 21:30:15 -0700 | [diff] [blame] | 100 | u8 virtual_slot; |
| 101 | u8 config_type; |
| 102 | } __packed; |
| 103 | |
| 104 | struct nhlt_dmic_array_config { |
Pierre-Louis Bossart | 7a33ea7 | 2019-07-29 10:51:49 -0500 | [diff] [blame] | 105 | struct nhlt_device_specific_config device_config; |
Yong Zhi | f65cf7d6 | 2016-05-26 21:30:15 -0700 | [diff] [blame] | 106 | u8 array_type; |
| 107 | } __packed; |
| 108 | |
Pierre-Louis Bossart | 7a33ea7 | 2019-07-29 10:51:49 -0500 | [diff] [blame] | 109 | struct nhlt_vendor_dmic_array_config { |
| 110 | struct nhlt_dmic_array_config dmic_config; |
| 111 | u8 nb_mics; |
| 112 | /* TODO add vendor mic config */ |
| 113 | } __packed; |
| 114 | |
Yong Zhi | f65cf7d6 | 2016-05-26 21:30:15 -0700 | [diff] [blame] | 115 | enum { |
Pierre-Louis Bossart | a864e8f | 2021-03-01 18:01:46 -0600 | [diff] [blame] | 116 | NHLT_CONFIG_TYPE_GENERIC = 0, |
| 117 | NHLT_CONFIG_TYPE_MIC_ARRAY = 1 |
| 118 | }; |
| 119 | |
| 120 | enum { |
Yong Zhi | f65cf7d6 | 2016-05-26 21:30:15 -0700 | [diff] [blame] | 121 | NHLT_MIC_ARRAY_2CH_SMALL = 0xa, |
| 122 | NHLT_MIC_ARRAY_2CH_BIG = 0xb, |
| 123 | NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc, |
| 124 | NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd, |
| 125 | NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe, |
| 126 | NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf, |
| 127 | }; |
| 128 | |
Pierre-Louis Bossart | 303681f | 2019-07-29 10:51:48 -0500 | [diff] [blame] | 129 | struct nhlt_acpi_table *intel_nhlt_init(struct device *dev); |
| 130 | |
| 131 | void intel_nhlt_free(struct nhlt_acpi_table *addr); |
| 132 | |
| 133 | int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt); |
| 134 | |
Amadeusz Sławiński | 15fa179 | 2021-11-26 15:03:53 +0100 | [diff] [blame] | 135 | bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type); |
| 136 | struct nhlt_specific_cfg * |
| 137 | intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, |
| 138 | u32 bus_id, u8 link_type, u8 vbps, u8 bps, |
| 139 | u8 num_ch, u32 rate, u8 dir, u8 dev_type); |
| 140 | |
Pierre-Louis Bossart | 303681f | 2019-07-29 10:51:48 -0500 | [diff] [blame] | 141 | #else |
| 142 | |
| 143 | struct nhlt_acpi_table; |
| 144 | |
| 145 | static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev) |
| 146 | { |
| 147 | return NULL; |
| 148 | } |
| 149 | |
| 150 | static inline void intel_nhlt_free(struct nhlt_acpi_table *addr) |
| 151 | { |
| 152 | } |
| 153 | |
| 154 | static inline int intel_nhlt_get_dmic_geo(struct device *dev, |
| 155 | struct nhlt_acpi_table *nhlt) |
| 156 | { |
| 157 | return 0; |
| 158 | } |
Amadeusz Sławiński | 15fa179 | 2021-11-26 15:03:53 +0100 | [diff] [blame] | 159 | |
| 160 | static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, |
| 161 | u8 link_type) |
| 162 | { |
| 163 | return false; |
| 164 | } |
| 165 | |
| 166 | static inline struct nhlt_specific_cfg * |
| 167 | intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, |
| 168 | u32 bus_id, u8 link_type, u8 vbps, u8 bps, |
| 169 | u8 num_ch, u32 rate, u8 dir, u8 dev_type) |
| 170 | { |
| 171 | return NULL; |
| 172 | } |
| 173 | |
Pierre-Louis Bossart | 303681f | 2019-07-29 10:51:48 -0500 | [diff] [blame] | 174 | #endif |
| 175 | |
Jeeja KP | 473eb87 | 2015-07-21 23:53:55 +0530 | [diff] [blame] | 176 | #endif |