Commit | Line | Data |
---|---|---|
8e8e69d6 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
473eb87a | 2 | /* |
303681f4 | 3 | * intel-nhlt.h - Intel HDA Platform NHLT header |
473eb87a | 4 | * |
303681f4 | 5 | * Copyright (c) 2015-2019 Intel Corporation |
473eb87a | 6 | */ |
303681f4 PLB |
7 | |
8 | #ifndef __INTEL_NHLT_H__ | |
9 | #define __INTEL_NHLT_H__ | |
473eb87a | 10 | |
aba3dd5a | 11 | #include <linux/acpi.h> |
473eb87a | 12 | |
15fa179f AS |
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 | ||
0c470db0 PLB |
21 | enum nhlt_device_type { |
22 | NHLT_DEVICE_BT = 0, | |
23 | NHLT_DEVICE_DMIC = 1, | |
24 | NHLT_DEVICE_I2S = 4, | |
25 | NHLT_DEVICE_INVALID | |
26 | }; | |
27 | ||
473eb87a JK |
28 | struct wav_fmt { |
29 | u16 fmt_tag; | |
30 | u16 channels; | |
31 | u32 samples_per_sec; | |
32 | u32 avg_bytes_per_sec; | |
33 | u16 block_align; | |
34 | u16 bits_per_sample; | |
35 | u16 cb_size; | |
36 | } __packed; | |
37 | ||
38 | struct wav_fmt_ext { | |
39 | struct wav_fmt fmt; | |
40 | union samples { | |
41 | u16 valid_bits_per_sample; | |
42 | u16 samples_per_block; | |
43 | u16 reserved; | |
44 | } sample; | |
45 | u32 channel_mask; | |
46 | u8 sub_fmt[16]; | |
47 | } __packed; | |
48 | ||
473eb87a JK |
49 | struct nhlt_specific_cfg { |
50 | u32 size; | |
9ad06ebb | 51 | u8 caps[]; |
473eb87a JK |
52 | } __packed; |
53 | ||
54 | struct nhlt_fmt_cfg { | |
55 | struct wav_fmt_ext fmt_ext; | |
56 | struct nhlt_specific_cfg config; | |
57 | } __packed; | |
58 | ||
59 | struct nhlt_fmt { | |
60 | u8 fmt_count; | |
9ad06ebb | 61 | struct nhlt_fmt_cfg fmt_config[]; |
473eb87a JK |
62 | } __packed; |
63 | ||
64 | struct nhlt_endpoint { | |
65 | u32 length; | |
66 | u8 linktype; | |
67 | u8 instance_id; | |
68 | u16 vendor_id; | |
69 | u16 device_id; | |
70 | u16 revision_id; | |
71 | u32 subsystem_id; | |
72 | u8 device_type; | |
73 | u8 direction; | |
74 | u8 virtual_bus_id; | |
75 | struct nhlt_specific_cfg config; | |
76 | } __packed; | |
77 | ||
78 | struct nhlt_acpi_table { | |
aba3dd5a | 79 | struct acpi_table_header header; |
473eb87a | 80 | u8 endpoint_count; |
9ad06ebb | 81 | struct nhlt_endpoint desc[]; |
473eb87a JK |
82 | } __packed; |
83 | ||
84 | struct nhlt_resource_desc { | |
85 | u32 extra; | |
86 | u16 flags; | |
87 | u64 addr_spc_gra; | |
88 | u64 min_addr; | |
89 | u64 max_addr; | |
90 | u64 addr_trans_offset; | |
91 | u64 length; | |
92 | } __packed; | |
93 | ||
f65cf7d6 YZ |
94 | #define MIC_ARRAY_2CH 2 |
95 | #define MIC_ARRAY_4CH 4 | |
96 | ||
7a33ea70 | 97 | struct nhlt_device_specific_config { |
f65cf7d6 YZ |
98 | u8 virtual_slot; |
99 | u8 config_type; | |
100 | } __packed; | |
101 | ||
102 | struct nhlt_dmic_array_config { | |
7a33ea70 | 103 | struct nhlt_device_specific_config device_config; |
f65cf7d6 YZ |
104 | u8 array_type; |
105 | } __packed; | |
106 | ||
7a33ea70 PLB |
107 | struct nhlt_vendor_dmic_array_config { |
108 | struct nhlt_dmic_array_config dmic_config; | |
109 | u8 nb_mics; | |
110 | /* TODO add vendor mic config */ | |
111 | } __packed; | |
112 | ||
a864e8f1 PLB |
113 | enum { |
114 | NHLT_CONFIG_TYPE_GENERIC = 0, | |
115 | NHLT_CONFIG_TYPE_MIC_ARRAY = 1 | |
116 | }; | |
117 | ||
f65cf7d6 YZ |
118 | enum { |
119 | NHLT_MIC_ARRAY_2CH_SMALL = 0xa, | |
120 | NHLT_MIC_ARRAY_2CH_BIG = 0xb, | |
121 | NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc, | |
122 | NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd, | |
123 | NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe, | |
124 | NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf, | |
125 | }; | |
126 | ||
2d3694fd AS |
127 | #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT) |
128 | ||
303681f4 PLB |
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 | ||
15fa179f | 135 | bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type); |
0c470db0 PLB |
136 | |
137 | int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type); | |
138 | ||
72176fcc PLB |
139 | int intel_nhlt_ssp_mclk_mask(struct nhlt_acpi_table *nhlt, int ssp_num); |
140 | ||
15fa179f AS |
141 | struct nhlt_specific_cfg * |
142 | intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, | |
143 | u32 bus_id, u8 link_type, u8 vbps, u8 bps, | |
144 | u8 num_ch, u32 rate, u8 dir, u8 dev_type); | |
145 | ||
303681f4 PLB |
146 | #else |
147 | ||
303681f4 PLB |
148 | static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev) |
149 | { | |
150 | return NULL; | |
151 | } | |
152 | ||
153 | static inline void intel_nhlt_free(struct nhlt_acpi_table *addr) | |
154 | { | |
155 | } | |
156 | ||
157 | static inline int intel_nhlt_get_dmic_geo(struct device *dev, | |
158 | struct nhlt_acpi_table *nhlt) | |
159 | { | |
160 | return 0; | |
161 | } | |
15fa179f AS |
162 | |
163 | static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, | |
164 | u8 link_type) | |
165 | { | |
166 | return false; | |
167 | } | |
168 | ||
0c470db0 PLB |
169 | static inline int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type) |
170 | { | |
171 | return 0; | |
172 | } | |
173 | ||
72176fcc PLB |
174 | static inline int intel_nhlt_ssp_mclk_mask(struct nhlt_acpi_table *nhlt, int ssp_num) |
175 | { | |
176 | return 0; | |
177 | } | |
178 | ||
15fa179f AS |
179 | static inline struct nhlt_specific_cfg * |
180 | intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, | |
181 | u32 bus_id, u8 link_type, u8 vbps, u8 bps, | |
182 | u8 num_ch, u32 rate, u8 dir, u8 dev_type) | |
183 | { | |
184 | return NULL; | |
185 | } | |
186 | ||
303681f4 PLB |
187 | #endif |
188 | ||
473eb87a | 189 | #endif |