1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2015-2019 Intel Corporation
4 #include <linux/acpi.h>
5 #include <sound/intel-nhlt.h>
7 #define NHLT_ACPI_HEADER_SIG "NHLT"
9 /* Unique identification for getting NHLT blobs */
10 static guid_t osc_guid
=
11 GUID_INIT(0xA69F886E, 0x6CEB, 0x4594,
12 0xA4, 0x1F, 0x7B, 0x5D, 0xCE, 0x24, 0xC5, 0x53);
14 struct nhlt_acpi_table
*intel_nhlt_init(struct device
*dev
)
17 union acpi_object
*obj
;
18 struct nhlt_resource_desc
*nhlt_ptr
;
19 struct nhlt_acpi_table
*nhlt_table
= NULL
;
21 handle
= ACPI_HANDLE(dev
);
23 dev_err(dev
, "Didn't find ACPI_HANDLE\n");
27 obj
= acpi_evaluate_dsm(handle
, &osc_guid
, 1, 1, NULL
);
32 if (obj
->type
!= ACPI_TYPE_BUFFER
) {
33 dev_dbg(dev
, "No NHLT table found\n");
38 nhlt_ptr
= (struct nhlt_resource_desc
*)obj
->buffer
.pointer
;
40 nhlt_table
= (struct nhlt_acpi_table
*)
41 memremap(nhlt_ptr
->min_addr
, nhlt_ptr
->length
,
45 (strncmp(nhlt_table
->header
.signature
,
47 strlen(NHLT_ACPI_HEADER_SIG
)) != 0)) {
49 dev_err(dev
, "NHLT ACPI header signature incorrect\n");
54 EXPORT_SYMBOL_GPL(intel_nhlt_init
);
56 void intel_nhlt_free(struct nhlt_acpi_table
*nhlt
)
58 memunmap((void *)nhlt
);
60 EXPORT_SYMBOL_GPL(intel_nhlt_free
);
62 int intel_nhlt_get_dmic_geo(struct device
*dev
, struct nhlt_acpi_table
*nhlt
)
64 struct nhlt_endpoint
*epnt
;
65 struct nhlt_dmic_array_config
*cfg
;
66 struct nhlt_vendor_dmic_array_config
*cfg_vendor
;
67 unsigned int dmic_geo
= 0;
73 epnt
= (struct nhlt_endpoint
*)nhlt
->desc
;
75 for (j
= 0; j
< nhlt
->endpoint_count
; j
++) {
76 if (epnt
->linktype
== NHLT_LINK_DMIC
) {
77 cfg
= (struct nhlt_dmic_array_config
*)
79 switch (cfg
->array_type
) {
80 case NHLT_MIC_ARRAY_2CH_SMALL
:
81 case NHLT_MIC_ARRAY_2CH_BIG
:
82 dmic_geo
= MIC_ARRAY_2CH
;
85 case NHLT_MIC_ARRAY_4CH_1ST_GEOM
:
86 case NHLT_MIC_ARRAY_4CH_L_SHAPED
:
87 case NHLT_MIC_ARRAY_4CH_2ND_GEOM
:
88 dmic_geo
= MIC_ARRAY_4CH
;
90 case NHLT_MIC_ARRAY_VENDOR_DEFINED
:
91 cfg_vendor
= (struct nhlt_vendor_dmic_array_config
*)cfg
;
92 dmic_geo
= cfg_vendor
->nb_mics
;
95 dev_warn(dev
, "undefined DMIC array_type 0x%0x\n",
99 epnt
= (struct nhlt_endpoint
*)((u8
*)epnt
+ epnt
->length
);
104 EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo
);
106 MODULE_LICENSE("GPL v2");
107 MODULE_DESCRIPTION("Intel NHLT driver");