^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * intel-nhlt.h - Intel HDA Platform NHLT header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2015-2019 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef __INTEL_NHLT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define __INTEL_NHLT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct wav_fmt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) u16 fmt_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) u16 channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) u32 samples_per_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) u32 avg_bytes_per_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) u16 block_align;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) u16 bits_per_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) u16 cb_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct wav_fmt_ext {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct wav_fmt fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) union samples {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u16 valid_bits_per_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) u16 samples_per_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u16 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) } sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u32 channel_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u8 sub_fmt[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) enum nhlt_link_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) NHLT_LINK_HDA = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) NHLT_LINK_DSP = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) NHLT_LINK_DMIC = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) NHLT_LINK_SSP = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) NHLT_LINK_INVALID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) enum nhlt_device_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) NHLT_DEVICE_BT = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) NHLT_DEVICE_DMIC = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) NHLT_DEVICE_I2S = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) NHLT_DEVICE_INVALID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct nhlt_specific_cfg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) u8 caps[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct nhlt_fmt_cfg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct wav_fmt_ext fmt_ext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct nhlt_specific_cfg config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct nhlt_fmt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) u8 fmt_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct nhlt_fmt_cfg fmt_config[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct nhlt_endpoint {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u8 linktype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u8 instance_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) u16 vendor_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u16 device_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u16 revision_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u32 subsystem_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) u8 device_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u8 direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u8 virtual_bus_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct nhlt_specific_cfg config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct nhlt_acpi_table {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct acpi_table_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u8 endpoint_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct nhlt_endpoint desc[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct nhlt_resource_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) u32 extra;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) u16 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) u64 addr_spc_gra;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) u64 min_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) u64 max_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) u64 addr_trans_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) u64 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define MIC_ARRAY_2CH 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define MIC_ARRAY_4CH 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct nhlt_device_specific_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) u8 virtual_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) u8 config_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct nhlt_dmic_array_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct nhlt_device_specific_config device_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) u8 array_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct nhlt_vendor_dmic_array_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct nhlt_dmic_array_config dmic_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) u8 nb_mics;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /* TODO add vendor mic config */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) NHLT_CONFIG_TYPE_GENERIC = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) NHLT_CONFIG_TYPE_MIC_ARRAY = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) NHLT_MIC_ARRAY_2CH_BIG = 0xb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct nhlt_acpi_table *intel_nhlt_init(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) void intel_nhlt_free(struct nhlt_acpi_table *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct nhlt_acpi_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static inline void intel_nhlt_free(struct nhlt_acpi_table *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static inline int intel_nhlt_get_dmic_geo(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct nhlt_acpi_table *nhlt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #endif