0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __INTEL_NHLT_H__
0009 #define __INTEL_NHLT_H__
0010
0011 #include <linux/acpi.h>
0012
0013 enum nhlt_link_type {
0014 NHLT_LINK_HDA = 0,
0015 NHLT_LINK_DSP = 1,
0016 NHLT_LINK_DMIC = 2,
0017 NHLT_LINK_SSP = 3,
0018 NHLT_LINK_INVALID
0019 };
0020
0021 enum nhlt_device_type {
0022 NHLT_DEVICE_BT = 0,
0023 NHLT_DEVICE_DMIC = 1,
0024 NHLT_DEVICE_I2S = 4,
0025 NHLT_DEVICE_INVALID
0026 };
0027
0028 struct wav_fmt {
0029 u16 fmt_tag;
0030 u16 channels;
0031 u32 samples_per_sec;
0032 u32 avg_bytes_per_sec;
0033 u16 block_align;
0034 u16 bits_per_sample;
0035 u16 cb_size;
0036 } __packed;
0037
0038 struct wav_fmt_ext {
0039 struct wav_fmt fmt;
0040 union samples {
0041 u16 valid_bits_per_sample;
0042 u16 samples_per_block;
0043 u16 reserved;
0044 } sample;
0045 u32 channel_mask;
0046 u8 sub_fmt[16];
0047 } __packed;
0048
0049 struct nhlt_specific_cfg {
0050 u32 size;
0051 u8 caps[];
0052 } __packed;
0053
0054 struct nhlt_fmt_cfg {
0055 struct wav_fmt_ext fmt_ext;
0056 struct nhlt_specific_cfg config;
0057 } __packed;
0058
0059 struct nhlt_fmt {
0060 u8 fmt_count;
0061 struct nhlt_fmt_cfg fmt_config[];
0062 } __packed;
0063
0064 struct nhlt_endpoint {
0065 u32 length;
0066 u8 linktype;
0067 u8 instance_id;
0068 u16 vendor_id;
0069 u16 device_id;
0070 u16 revision_id;
0071 u32 subsystem_id;
0072 u8 device_type;
0073 u8 direction;
0074 u8 virtual_bus_id;
0075 struct nhlt_specific_cfg config;
0076 } __packed;
0077
0078 struct nhlt_acpi_table {
0079 struct acpi_table_header header;
0080 u8 endpoint_count;
0081 struct nhlt_endpoint desc[];
0082 } __packed;
0083
0084 struct nhlt_resource_desc {
0085 u32 extra;
0086 u16 flags;
0087 u64 addr_spc_gra;
0088 u64 min_addr;
0089 u64 max_addr;
0090 u64 addr_trans_offset;
0091 u64 length;
0092 } __packed;
0093
0094 #define MIC_ARRAY_2CH 2
0095 #define MIC_ARRAY_4CH 4
0096
0097 struct nhlt_device_specific_config {
0098 u8 virtual_slot;
0099 u8 config_type;
0100 } __packed;
0101
0102 struct nhlt_dmic_array_config {
0103 struct nhlt_device_specific_config device_config;
0104 u8 array_type;
0105 } __packed;
0106
0107 struct nhlt_vendor_dmic_array_config {
0108 struct nhlt_dmic_array_config dmic_config;
0109 u8 nb_mics;
0110
0111 } __packed;
0112
0113 enum {
0114 NHLT_CONFIG_TYPE_GENERIC = 0,
0115 NHLT_CONFIG_TYPE_MIC_ARRAY = 1
0116 };
0117
0118 enum {
0119 NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
0120 NHLT_MIC_ARRAY_2CH_BIG = 0xb,
0121 NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
0122 NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
0123 NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
0124 NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
0125 };
0126
0127 #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT)
0128
0129 struct nhlt_acpi_table *intel_nhlt_init(struct device *dev);
0130
0131 void intel_nhlt_free(struct nhlt_acpi_table *addr);
0132
0133 int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt);
0134
0135 bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type);
0136
0137 int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type);
0138
0139 struct nhlt_specific_cfg *
0140 intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
0141 u32 bus_id, u8 link_type, u8 vbps, u8 bps,
0142 u8 num_ch, u32 rate, u8 dir, u8 dev_type);
0143
0144 #else
0145
0146 static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
0147 {
0148 return NULL;
0149 }
0150
0151 static inline void intel_nhlt_free(struct nhlt_acpi_table *addr)
0152 {
0153 }
0154
0155 static inline int intel_nhlt_get_dmic_geo(struct device *dev,
0156 struct nhlt_acpi_table *nhlt)
0157 {
0158 return 0;
0159 }
0160
0161 static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt,
0162 u8 link_type)
0163 {
0164 return false;
0165 }
0166
0167 static inline int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type)
0168 {
0169 return 0;
0170 }
0171
0172 static inline struct nhlt_specific_cfg *
0173 intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
0174 u32 bus_id, u8 link_type, u8 vbps, u8 bps,
0175 u8 num_ch, u32 rate, u8 dir, u8 dev_type)
0176 {
0177 return NULL;
0178 }
0179
0180 #endif
0181
0182 #endif