Skip to content

Commit 519c44a

Browse files
plbossartjwrdegoede
authored andcommitted
ASoC: es83xx: add ACPI DSM helper module
Most of the ES83xx codec configuration is exposed in the DSDT table and accessible via a _DSM method. Start adding basic definitions and helpers to dump the information. Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org> Co-developed-by: David Yang <yangxiaohua@everest-semi.com> Signed-off-by: David Yang <yangxiaohua@everest-semi.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- Changes in v2: - Move es83xx-dsm-common.c back to sound/soc/codecs like the orignal version from: thesofproject#4112
1 parent f752dcf commit 519c44a

4 files changed

Lines changed: 488 additions & 0 deletions

File tree

sound/soc/codecs/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,10 @@ config SND_SOC_ES7134
10761076
config SND_SOC_ES7241
10771077
tristate "Everest Semi ES7241 CODEC"
10781078

1079+
config SND_SOC_ES83XX_DSM_COMMON
1080+
depends on ACPI
1081+
tristate
1082+
10791083
config SND_SOC_ES8316
10801084
tristate "Everest Semi ES8316 CODEC"
10811085
depends on I2C

sound/soc/codecs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ snd-soc-da9055-objs := da9055.o
116116
snd-soc-dmic-objs := dmic.o
117117
snd-soc-es7134-objs := es7134.o
118118
snd-soc-es7241-objs := es7241.o
119+
snd-soc-es83xx-dsm-common-objs := es83xx-dsm-common.o
119120
snd-soc-es8316-objs := es8316.o
120121
snd-soc-es8326-objs := es8326.o
121122
snd-soc-es8328-objs := es8328.o
@@ -505,6 +506,7 @@ obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o
505506
obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o
506507
obj-$(CONFIG_SND_SOC_ES7134) += snd-soc-es7134.o
507508
obj-$(CONFIG_SND_SOC_ES7241) += snd-soc-es7241.o
509+
obj-$(CONFIG_SND_SOC_ES83XX_DSM_COMMON) += snd-soc-es83xx-dsm-common.o
508510
obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o
509511
obj-$(CONFIG_SND_SOC_ES8326) += snd-soc-es8326.o
510512
obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
//
3+
// Copyright (c) Intel Corporation, 2022
4+
// Copyright Everest Semiconductor Co.,Ltd
5+
6+
#include <linux/module.h>
7+
#include <linux/acpi.h>
8+
#include "es83xx-dsm-common.h"
9+
10+
/* UUID ("a9800c04-e016-343e-41f4-6bcce70f4332") */
11+
static const guid_t es83xx_dsm_guid =
12+
GUID_INIT(0xa9800c04, 0xe016, 0x343e,
13+
0x41, 0xf4, 0x6b, 0xcc, 0xe7, 0x0f, 0x43, 0x32);
14+
15+
#define ES83xx_DSM_REVID 1
16+
17+
int es83xx_dsm(struct device *dev, int arg, int *value)
18+
{
19+
acpi_handle dhandle;
20+
union acpi_object *obj;
21+
int ret = 0;
22+
23+
dhandle = ACPI_HANDLE(dev);
24+
if (!dhandle)
25+
return -ENOENT;
26+
27+
obj = acpi_evaluate_dsm(dhandle, &es83xx_dsm_guid, ES83xx_DSM_REVID,
28+
arg, NULL);
29+
if (!obj) {
30+
dev_err(dev, "%s: acpi_evaluate_dsm() failed\n", __func__);
31+
ret = -EINVAL;
32+
goto out;
33+
}
34+
35+
if (obj->type != ACPI_TYPE_INTEGER) {
36+
dev_err(dev, "%s: object is not ACPI_TYPE_INTEGER\n", __func__);
37+
ret = -EINVAL;
38+
goto err;
39+
}
40+
41+
*value = obj->integer.value;
42+
err:
43+
ACPI_FREE(obj);
44+
out:
45+
return ret;
46+
}
47+
EXPORT_SYMBOL_GPL(es83xx_dsm);
48+
49+
int es83xx_dsm_dump(struct device *dev)
50+
{
51+
int value;
52+
int ret;
53+
54+
ret = es83xx_dsm(dev, PLATFORM_MAINMIC_TYPE_ARG, &value);
55+
if (ret < 0)
56+
return ret;
57+
dev_info(dev, "PLATFORM_MAINMIC_TYPE %#x\n", value);
58+
59+
ret = es83xx_dsm(dev, PLATFORM_HPMIC_TYPE_ARG, &value);
60+
if (ret < 0)
61+
return ret;
62+
dev_info(dev, "PLATFORM_HPMIC_TYPE %#x\n", value);
63+
64+
ret = es83xx_dsm(dev, PLATFORM_SPK_TYPE_ARG, &value);
65+
if (ret < 0)
66+
return ret;
67+
dev_info(dev, "PLATFORM_SPK_TYPE %#x\n", value);
68+
69+
ret = es83xx_dsm(dev, PLATFORM_HPDET_INV_ARG, &value);
70+
if (ret < 0)
71+
return ret;
72+
dev_info(dev, "PLATFORM_HPDET_INV %#x\n", value);
73+
74+
ret = es83xx_dsm(dev, PLATFORM_PCM_TYPE_ARG, &value);
75+
if (ret < 0)
76+
return ret;
77+
dev_info(dev, "PLATFORM_PCM_TYPE %#x\n", value);
78+
79+
ret = es83xx_dsm(dev, PLATFORM_MIC_DE_POP_ARG, &value);
80+
if (ret < 0)
81+
return ret;
82+
dev_info(dev, "PLATFORM_MIC_DE_POP %#x\n", value);
83+
84+
return 0;
85+
}
86+
EXPORT_SYMBOL_GPL(es83xx_dsm_dump);
87+
88+
MODULE_DESCRIPTION("Everest Semi ES83xx DSM helpers");
89+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)