1 /* SPDX-License-Identifier: GPL-2.0-only */
12 struct nhlt_format_config
;
15 * Non HD Audio ACPI support. This table is typically used for Intel Smart
16 * Sound Technology DSP. It provides a way to encode opaque settings in
19 * While the structure fields of the NHLT structs are exposed below
20 * the SoC/chipset code should be the only other user manipulating the
21 * fields directly aside from the library itself.
23 * The NHLT table consists of endpoints which in turn contain different
24 * supporting stream formats. Each endpoint may contain a device specific
25 * configuration payload as well as each stream format.
27 * Most code should use the SoC variants of the functions because
28 * there is required logic needed to be performed by the SoC. The SoC
29 * code should be abstracting the inner details of these functions that
30 * specifically apply to NHLT objects for that SoC.
32 * An example sequence:
35 * ep = nhlt_add_endpoint()
36 * nhlt_endpoint_append_config(ep)
37 * nhlt_endpoint_add_formats(ep)
38 * nhlt_soc_serialize()
41 /* Obtain an nhlt object for adding endpoints. Returns NULL on error. */
42 struct nhlt
*nhlt_init(void);
44 /* Return the size of the NHLT table including ACPI header. */
45 size_t nhlt_current_size(struct nhlt
*nhlt
);
48 * Helper functions for adding NHLT devices utilizing an nhlt_endp_descriptor
52 struct nhlt_endp_descriptor
{
53 /* NHLT endpoint types. */
59 /* Optional endpoint specific configuration data. */
62 /* Formats supported for endpoint. */
63 const struct nhlt_format_config
*formats
;
68 * Add the number of endpoints described by each descriptor. The virtual bus
69 * id for each descriptor is the default value of 0.
70 * Returns < 0 on error, 0 on success.
72 int nhlt_add_endpoints(struct nhlt
*nhlt
,
73 const struct nhlt_endp_descriptor
*epds
,
77 * Add the number of endpoints associated with a single NHLT SSP instance id.
78 * Each endpoint described in the endpoint descriptor array uses the provided
79 * virtual bus id. Returns < 0 on error, 0 on success.
81 int nhlt_add_ssp_endpoints(struct nhlt
*nhlt
, int virtual_bus_id
,
82 const struct nhlt_endp_descriptor
*epds
, size_t num_epds
);
85 * Add endpoint to NHLT object. Returns NULL on error.
87 * generic nhlt_add_endpoint() is called by the SoC code to provide
88 * the specific assumptions/uses for NHLT for that platform. All fields
89 * are the NHLT enumerations found within this header file.
91 struct nhlt_endpoint
*nhlt_add_endpoint(struct nhlt
*nhlt
, int link_type
,
92 int device_type
, int dir
,
93 uint16_t vid
, uint16_t did
);
96 * Append blob of configuration to the endpoint proper. Returns 0 on
97 * success, < 0 on error. A copy of the configuration is made so any
98 * resources pointed to by config can be freed after the call.
100 int nhlt_endpoint_append_config(struct nhlt_endpoint
*endpoint
,
101 const void *config
, size_t config_sz
);
103 /* Add a format type to the provided endpoint. Returns NULL on error. */
104 struct nhlt_format
*nhlt_add_format(struct nhlt_endpoint
*endpoint
,
107 int container_bits_per_sample
,
108 int valid_bits_per_sample
,
109 uint32_t speaker_mask
);
112 * Append blob of configuration to the format proper. Returns 0 on
113 * success, < 0 on error. A copy of the configuration is made so any
114 * resources pointed to by config can be freed after the call.
116 int nhlt_format_append_config(struct nhlt_format
*format
, const void *config
,
120 * Add num_formats described by formats to the endpoint. This function
121 * effectively wraps nhlt_add_format() and nhlt_format_config() using the
122 * data found in each nhlt_format_config object. Returns 0 on success, < 0
125 int nhlt_endpoint_add_formats(struct nhlt_endpoint
*endpoint
,
126 const struct nhlt_format_config
*formats
,
130 * Increment the instance id for a given link type. This function is
131 * used for marking a device being completely added to the NHLT object.
132 * Subsequent endpoints added to the nhlt object with the same link type
133 * will use incremented instance id.
135 void nhlt_next_instance(struct nhlt
*nhlt
, int link_type
);
138 * Serialize NHLT object to ACPI table. Take in the beginning address of where
139 * the table will reside and return the address of the next ACPI table. On
140 * error 0 will be returned. The NHLT object is no longer valid after this
141 * function is called.
143 uintptr_t nhlt_serialize(struct nhlt
*nhlt
, uintptr_t acpi_addr
);
146 * Serialize NHLT object to ACPI table. Take in the beginning address of where
147 * the table will reside oem_id and oem_table_id and return the address of the
148 * next ACPI table. On error 0 will be returned. The NHLT object is no longer
149 * valid after this function is called.
151 uintptr_t nhlt_serialize_oem_overrides(struct nhlt
*nhlt
, uintptr_t acpi_addr
,
152 const char *oem_id
, const char *oem_table_id
,
153 uint32_t oem_revision
);
156 * While very similar to nhlt_serialize() the SoC specific function allows
157 * the chipset to perform any needed accounting work such as updating ACPI
158 * field references for the serialized structure.
160 uintptr_t nhlt_soc_serialize(struct nhlt
*nhlt
, uintptr_t acpi_addr
);
163 * While very similar to nhlt_serialize_oem_overrides() the SoC specific
164 * function allows the chipset to perform any needed accounting work such
165 * as updating ACPI field references for the serialized structure.
167 uintptr_t nhlt_soc_serialize_oem_overrides(struct nhlt
*nhlt
,
168 uintptr_t acpi_addr
, const char *oem_id
, const char *oem_table_id
,
169 uint32_t oem_revision
);
171 /* Link and device types. */
181 NHLT_SSP_DEV_BT
, /* Bluetooth */
184 NHLT_SSP_DEV_RESERVED
,
185 NHLT_SSP_DEV_I2S
= 4,
190 NHLT_PDM_DEV_CAVS15
, // NHLT_PDM_DEV on cAVS1.5 (KBL) based platforms
193 /* Endpoint direction. */
197 NHLT_DIR_BIDIRECTIONAL
,
200 /* Channel Mask for an endpoint. While they are prefixed with 'SPEAKER' the
201 * channel masks are also used for capture devices. */
203 SPEAKER_FRONT_LEFT
= 1 << 0,
204 SPEAKER_FRONT_RIGHT
= 1 << 1,
205 SPEAKER_FRONT_CENTER
= 1 << 2,
206 SPEAKER_LOW_FREQUENCY
= 1 << 3,
207 SPEAKER_BACK_LEFT
= 1 << 4,
208 SPEAKER_BACK_RIGHT
= 1 << 5,
209 SPEAKER_FRONT_LEFT_OF_CENTER
= 1 << 6,
210 SPEAKER_FRONT_RIGHT_OF_CENTER
= 1 << 7,
211 SPEAKER_BACK_CENTER
= 1 << 8,
212 SPEAKER_SIDE_LEFT
= 1 << 9,
213 SPEAKER_SIDE_RIGHT
= 1 << 10,
214 SPEAKER_TOP_CENTER
= 1 << 11,
215 SPEAKER_TOP_FRONT_LEFT
= 1 << 12,
216 SPEAKER_TOP_FRONT_CENTER
= 1 << 13,
217 SPEAKER_TOP_FRONT_RIGHT
= 1 << 14,
218 SPEAKER_TOP_BACK_LEFT
= 1 << 15,
219 SPEAKER_TOP_BACK_CENTER
= 1 << 16,
220 SPEAKER_TOP_BACK_RIGHT
= 1 << 17,
223 /* Supporting structures. Only SoC/chipset and the library code directly should
224 * be manipulating these structures. */
232 struct nhlt_specific_config
{
237 struct nhlt_waveform
{
239 uint16_t num_channels
;
240 uint32_t samples_per_second
;
241 uint32_t bytes_per_second
;
242 uint16_t block_align
;
243 uint16_t bits_per_sample
;
245 uint16_t valid_bits_per_sample
;
246 uint32_t channel_mask
;
247 struct sub_format sub_format
;
251 struct nhlt_waveform waveform
;
252 struct nhlt_specific_config config
;
256 * This struct is used by nhlt_endpoint_add_formats() for easily adding
257 * waveform formats with associated settings file.
259 struct nhlt_format_config
{
262 int container_bits_per_sample
;
263 int valid_bits_per_sample
;
264 uint32_t speaker_mask
;
265 const char *settings_file
;
268 /* Arbitrary max number of formats per endpoint. */
269 #define MAX_FORMATS 2
270 struct nhlt_endpoint
{
276 uint16_t revision_id
;
277 uint32_t subsystem_id
;
280 uint8_t virtual_bus_id
;
281 struct nhlt_specific_config config
;
283 struct nhlt_format formats
[MAX_FORMATS
];
286 #define MAX_ENDPOINTS 8
288 uint32_t subsystem_id
;
289 uint8_t num_endpoints
;
290 struct nhlt_endpoint endpoints
[MAX_ENDPOINTS
];
291 uint8_t current_instance_id
[NHLT_MAX_LINK_TYPES
];
294 struct nhlt_tdm_config
{
295 uint8_t virtual_slot
;
302 NHLT_TDM_RENDER_WITH_LOOPBACK
,
303 NHLT_TDM_RENDER_FEEDBACK
,
305 NHLT_TDM_MULTI_MODE_MIC_ARRAY
= NHLT_TDM_MULTI_MODE
| NHLT_TDM_MIC_ARRAY
308 struct nhlt_feedback_config
{
309 struct nhlt_tdm_config tdm_config
;
310 uint8_t feedback_virtual_slot
;
311 uint16_t feedback_channels
;
312 uint16_t feedback_valid_bits_per_sample
;
315 struct nhlt_dmic_array_config
{
316 struct nhlt_tdm_config tdm_config
;
321 * Microphone array definitions may be found here:
322 * https://msdn.microsoft.com/en-us/library/windows/hardware/dn613960%28v=vs.85%29.aspx
325 NHLT_MIC_ARRAY_2CH_SMALL
= 0xa,
326 NHLT_MIC_ARRAY_2CH_BIG
= 0xb,
327 NHLT_MIC_ARRAY_4CH_1ST_GEOM
= 0xc,
328 NHLT_MIC_ARRAY_4CH_L_SHAPED
= 0xd,
329 NHLT_MIC_ARRAY_4CH_2ND_GEOM
= 0xe,
330 NHLT_MIC_ARRAY_VENDOR_DEFINED
= 0xf,