18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  intel-nhlt.h - Intel HDA Platform NHLT header
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (c) 2015-2019 Intel Corporation
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __INTEL_NHLT_H__
98c2ecf20Sopenharmony_ci#define __INTEL_NHLT_H__
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/acpi.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT)
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct wav_fmt {
168c2ecf20Sopenharmony_ci	u16 fmt_tag;
178c2ecf20Sopenharmony_ci	u16 channels;
188c2ecf20Sopenharmony_ci	u32 samples_per_sec;
198c2ecf20Sopenharmony_ci	u32 avg_bytes_per_sec;
208c2ecf20Sopenharmony_ci	u16 block_align;
218c2ecf20Sopenharmony_ci	u16 bits_per_sample;
228c2ecf20Sopenharmony_ci	u16 cb_size;
238c2ecf20Sopenharmony_ci} __packed;
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistruct wav_fmt_ext {
268c2ecf20Sopenharmony_ci	struct wav_fmt fmt;
278c2ecf20Sopenharmony_ci	union samples {
288c2ecf20Sopenharmony_ci		u16 valid_bits_per_sample;
298c2ecf20Sopenharmony_ci		u16 samples_per_block;
308c2ecf20Sopenharmony_ci		u16 reserved;
318c2ecf20Sopenharmony_ci	} sample;
328c2ecf20Sopenharmony_ci	u32 channel_mask;
338c2ecf20Sopenharmony_ci	u8 sub_fmt[16];
348c2ecf20Sopenharmony_ci} __packed;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cienum nhlt_link_type {
378c2ecf20Sopenharmony_ci	NHLT_LINK_HDA = 0,
388c2ecf20Sopenharmony_ci	NHLT_LINK_DSP = 1,
398c2ecf20Sopenharmony_ci	NHLT_LINK_DMIC = 2,
408c2ecf20Sopenharmony_ci	NHLT_LINK_SSP = 3,
418c2ecf20Sopenharmony_ci	NHLT_LINK_INVALID
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cienum nhlt_device_type {
458c2ecf20Sopenharmony_ci	NHLT_DEVICE_BT = 0,
468c2ecf20Sopenharmony_ci	NHLT_DEVICE_DMIC = 1,
478c2ecf20Sopenharmony_ci	NHLT_DEVICE_I2S = 4,
488c2ecf20Sopenharmony_ci	NHLT_DEVICE_INVALID
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cistruct nhlt_specific_cfg {
528c2ecf20Sopenharmony_ci	u32 size;
538c2ecf20Sopenharmony_ci	u8 caps[];
548c2ecf20Sopenharmony_ci} __packed;
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistruct nhlt_fmt_cfg {
578c2ecf20Sopenharmony_ci	struct wav_fmt_ext fmt_ext;
588c2ecf20Sopenharmony_ci	struct nhlt_specific_cfg config;
598c2ecf20Sopenharmony_ci} __packed;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistruct nhlt_fmt {
628c2ecf20Sopenharmony_ci	u8 fmt_count;
638c2ecf20Sopenharmony_ci	struct nhlt_fmt_cfg fmt_config[];
648c2ecf20Sopenharmony_ci} __packed;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistruct nhlt_endpoint {
678c2ecf20Sopenharmony_ci	u32  length;
688c2ecf20Sopenharmony_ci	u8   linktype;
698c2ecf20Sopenharmony_ci	u8   instance_id;
708c2ecf20Sopenharmony_ci	u16  vendor_id;
718c2ecf20Sopenharmony_ci	u16  device_id;
728c2ecf20Sopenharmony_ci	u16  revision_id;
738c2ecf20Sopenharmony_ci	u32  subsystem_id;
748c2ecf20Sopenharmony_ci	u8   device_type;
758c2ecf20Sopenharmony_ci	u8   direction;
768c2ecf20Sopenharmony_ci	u8   virtual_bus_id;
778c2ecf20Sopenharmony_ci	struct nhlt_specific_cfg config;
788c2ecf20Sopenharmony_ci} __packed;
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistruct nhlt_acpi_table {
818c2ecf20Sopenharmony_ci	struct acpi_table_header header;
828c2ecf20Sopenharmony_ci	u8 endpoint_count;
838c2ecf20Sopenharmony_ci	struct nhlt_endpoint desc[];
848c2ecf20Sopenharmony_ci} __packed;
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistruct nhlt_resource_desc  {
878c2ecf20Sopenharmony_ci	u32 extra;
888c2ecf20Sopenharmony_ci	u16 flags;
898c2ecf20Sopenharmony_ci	u64 addr_spc_gra;
908c2ecf20Sopenharmony_ci	u64 min_addr;
918c2ecf20Sopenharmony_ci	u64 max_addr;
928c2ecf20Sopenharmony_ci	u64 addr_trans_offset;
938c2ecf20Sopenharmony_ci	u64 length;
948c2ecf20Sopenharmony_ci} __packed;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#define MIC_ARRAY_2CH 2
978c2ecf20Sopenharmony_ci#define MIC_ARRAY_4CH 4
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cistruct nhlt_device_specific_config {
1008c2ecf20Sopenharmony_ci	u8 virtual_slot;
1018c2ecf20Sopenharmony_ci	u8 config_type;
1028c2ecf20Sopenharmony_ci} __packed;
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistruct nhlt_dmic_array_config {
1058c2ecf20Sopenharmony_ci	struct nhlt_device_specific_config device_config;
1068c2ecf20Sopenharmony_ci	u8 array_type;
1078c2ecf20Sopenharmony_ci} __packed;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cistruct nhlt_vendor_dmic_array_config {
1108c2ecf20Sopenharmony_ci	struct nhlt_dmic_array_config dmic_config;
1118c2ecf20Sopenharmony_ci	u8 nb_mics;
1128c2ecf20Sopenharmony_ci	/* TODO add vendor mic config */
1138c2ecf20Sopenharmony_ci} __packed;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cienum {
1168c2ecf20Sopenharmony_ci	NHLT_CONFIG_TYPE_GENERIC = 0,
1178c2ecf20Sopenharmony_ci	NHLT_CONFIG_TYPE_MIC_ARRAY = 1
1188c2ecf20Sopenharmony_ci};
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_cienum {
1218c2ecf20Sopenharmony_ci	NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
1228c2ecf20Sopenharmony_ci	NHLT_MIC_ARRAY_2CH_BIG = 0xb,
1238c2ecf20Sopenharmony_ci	NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
1248c2ecf20Sopenharmony_ci	NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
1258c2ecf20Sopenharmony_ci	NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
1268c2ecf20Sopenharmony_ci	NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_cistruct nhlt_acpi_table *intel_nhlt_init(struct device *dev);
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_civoid intel_nhlt_free(struct nhlt_acpi_table *addr);
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ciint intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt);
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#else
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistruct nhlt_acpi_table;
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistatic inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
1408c2ecf20Sopenharmony_ci{
1418c2ecf20Sopenharmony_ci	return NULL;
1428c2ecf20Sopenharmony_ci}
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cistatic inline void intel_nhlt_free(struct nhlt_acpi_table *addr)
1458c2ecf20Sopenharmony_ci{
1468c2ecf20Sopenharmony_ci}
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic inline int intel_nhlt_get_dmic_geo(struct device *dev,
1498c2ecf20Sopenharmony_ci					  struct nhlt_acpi_table *nhlt)
1508c2ecf20Sopenharmony_ci{
1518c2ecf20Sopenharmony_ci	return 0;
1528c2ecf20Sopenharmony_ci}
1538c2ecf20Sopenharmony_ci#endif
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci#endif
156