1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2015-2019 Intel Corporation
4 #include <linux/acpi.h>
5 #include <sound/intel-nhlt.h>
7 struct nhlt_acpi_table
*intel_nhlt_init(struct device
*dev
)
9 struct nhlt_acpi_table
*nhlt
;
12 status
= acpi_get_table(ACPI_SIG_NHLT
, 0,
13 (struct acpi_table_header
**)&nhlt
);
14 if (ACPI_FAILURE(status
)) {
15 dev_warn(dev
, "NHLT table not found\n");
21 EXPORT_SYMBOL_GPL(intel_nhlt_init
);
23 void intel_nhlt_free(struct nhlt_acpi_table
*nhlt
)
25 acpi_put_table((struct acpi_table_header
*)nhlt
);
27 EXPORT_SYMBOL_GPL(intel_nhlt_free
);
29 int intel_nhlt_get_dmic_geo(struct device
*dev
, struct nhlt_acpi_table
*nhlt
)
31 struct nhlt_endpoint
*epnt
;
32 struct nhlt_dmic_array_config
*cfg
;
33 struct nhlt_vendor_dmic_array_config
*cfg_vendor
;
34 unsigned int dmic_geo
= 0;
40 epnt
= (struct nhlt_endpoint
*)nhlt
->desc
;
42 for (j
= 0; j
< nhlt
->endpoint_count
; j
++) {
43 if (epnt
->linktype
== NHLT_LINK_DMIC
) {
44 cfg
= (struct nhlt_dmic_array_config
*)
46 switch (cfg
->array_type
) {
47 case NHLT_MIC_ARRAY_2CH_SMALL
:
48 case NHLT_MIC_ARRAY_2CH_BIG
:
49 dmic_geo
= MIC_ARRAY_2CH
;
52 case NHLT_MIC_ARRAY_4CH_1ST_GEOM
:
53 case NHLT_MIC_ARRAY_4CH_L_SHAPED
:
54 case NHLT_MIC_ARRAY_4CH_2ND_GEOM
:
55 dmic_geo
= MIC_ARRAY_4CH
;
57 case NHLT_MIC_ARRAY_VENDOR_DEFINED
:
58 cfg_vendor
= (struct nhlt_vendor_dmic_array_config
*)cfg
;
59 dmic_geo
= cfg_vendor
->nb_mics
;
62 dev_warn(dev
, "undefined DMIC array_type 0x%0x\n",
66 epnt
= (struct nhlt_endpoint
*)((u8
*)epnt
+ epnt
->length
);
71 EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo
);