Skip to content

Commit 8ea0825

Browse files
committed
ASoC: Intel: bytcht_es8316: Determine
Merge series from Hans de Goede <[email protected]>: This takes some of the work done to auto-configure quirks/routing for ESS83xx codecs by getting the info from ACPI from: thesofproject#4112 And then builds on top of this to add auto-configuration to the bytcht_es8316 board driver. Note compared to the pull-request, which deals with the ES8336, this series deals with the ES8316 (for which I have several devices to test on) and this moves handling of the _DSM from the codec driver to the board driver since with the ES8316 the board driver takes care of setting up various routes for things like the mic and speakers. After this series audio now works properly on a CHT Chuwi Hi12 tablet without needing to add an extra quirk for that model. This has also been tested on the following devices, where things are unchanged from before (the ACPI autoconfiguration gives the same results as the old defaults) : Onda V80 plus (CHT) GP-electronic T701 (BYT) I also tested this on a Nanote UMPC-01, here the _DSM result for PLATFORM_SPK_TYPE_ARG wrongly returns 1 (mono) while the device actually has 2 speakers, so this model needs to keep its DMI quirk. I don't have an IRBIS NB41 nor a TECLAST X98 Plus II, so the DMI quirks for those are left in place too on a better safe then sorry basis.
2 parents d0ae9dc + 7650862 commit 8ea0825

File tree

6 files changed

+557
-3
lines changed

6 files changed

+557
-3
lines changed

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)