Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -925,13 +925,18 @@ config SND_SOC_ES7134
config SND_SOC_ES7241
tristate "Everest Semi ES7241 CODEC"

config SND_SOC_ES83XX_DSM_COMMON
tristate

config SND_SOC_ES8316
tristate "Everest Semi ES8316 CODEC"
depends on I2C
select SND_SOC_ES83XX_DSM_COMMON if ACPI

config SND_SOC_ES8326
tristate "Everest Semi ES8326 CODEC"
depends on I2C
select SND_SOC_ES83XX_DSM_COMMON if ACPI

config SND_SOC_ES8328
tristate
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/codecs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ snd-soc-da9055-objs := da9055.o
snd-soc-dmic-objs := dmic.o
snd-soc-es7134-objs := es7134.o
snd-soc-es7241-objs := es7241.o
snd-soc-es83xx-dsm-common-objs := es83xx-dsm-common.o
snd-soc-es8316-objs := es8316.o
snd-soc-es8326-objs := es8326.o
snd-soc-es8328-objs := es8328.o
Expand Down Expand Up @@ -462,6 +463,7 @@ obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o
obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o
obj-$(CONFIG_SND_SOC_ES7134) += snd-soc-es7134.o
obj-$(CONFIG_SND_SOC_ES7241) += snd-soc-es7241.o
obj-$(CONFIG_SND_SOC_ES83XX_DSM_COMMON) += snd-soc-es83xx-dsm-common.o
obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o
obj-$(CONFIG_SND_SOC_ES8326) += snd-soc-es8326.o
obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/codecs/es8316.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <sound/tlv.h>
#include <sound/jack.h>
#include "es8316.h"
#include "es83xx-dsm-common.h"

/* In slave mode at single speed, the codec is documented as accepting 5
* MCLK/LRCK ratios, but we also add ratio 400, which is commonly used on
Expand Down Expand Up @@ -833,6 +834,14 @@ static int es8316_i2c_probe(struct i2c_client *i2c_client)
if (es8316 == NULL)
return -ENOMEM;

/* read jack information from _DSM */
ret = es83xx_dsm_jack_inverted(dev);
if (ret < 0)
dev_warn(dev, "%s: Could not get jack detection information with ACPI _DSM method\n",
__func__);
else
es8316->jd_inverted = ret;

i2c_set_clientdata(i2c_client, es8316);

es8316->regmap = devm_regmap_init_i2c(i2c_client, &es8316_regmap);
Expand Down
10 changes: 10 additions & 0 deletions sound/soc/codecs/es8326.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <sound/soc-dapm.h>
#include <sound/tlv.h>
#include "es8326.h"
#include "es83xx-dsm-common.h"

struct es8326_priv {
struct clk *mclk;
Expand Down Expand Up @@ -816,13 +817,22 @@ static const struct snd_soc_component_driver soc_component_dev_es8326 = {

static int es8326_i2c_probe(struct i2c_client *i2c)
{
struct device *dev = &i2c->dev;
struct es8326_priv *es8326;
int ret;

es8326 = devm_kzalloc(&i2c->dev, sizeof(struct es8326_priv), GFP_KERNEL);
if (!es8326)
return -ENOMEM;

/* read jack information from _DSM */
ret = es83xx_dsm_jack_inverted(dev);
if (ret < 0)
dev_warn(dev, "%s: Could not get jack detection information with ACPI _DSM method\n",
__func__);
else
es8326->jd_inverted = ret;

i2c_set_clientdata(i2c, es8326);
es8326->i2c = i2c;
mutex_init(&es8326->lock);
Expand Down
62 changes: 62 additions & 0 deletions sound/soc/codecs/es83xx-dsm-common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright (c) Intel Corporation, 2022
// Copyright Everest Semiconductor Co.,Ltd

#include <linux/module.h>
#include <linux/acpi.h>
#include "es83xx-dsm-common.h"

/* UUID ("a9800c04-e016-343e-41f4-6bcce70f4332") */
static const guid_t es83xx_dsm_guid =
GUID_INIT(0xa9800c04, 0xe016, 0x343e,
0x41, 0xf4, 0x6b, 0xcc, 0xe7, 0x0f, 0x43, 0x32);

#define ES83xx_DSM_REVID 1

static int es83xx_dsm(struct device *dev, int arg, int *value)
{
acpi_handle dhandle;
union acpi_object *obj;
int ret = 0;

dhandle = ACPI_HANDLE(dev);
if (!dhandle)
return -ENOENT;

obj = acpi_evaluate_dsm(dhandle, &es83xx_dsm_guid, ES83xx_DSM_REVID,
arg, NULL);
if (!obj) {
dev_err(dev, "%s: acpi_evaluate_dsm() failed\n", __func__);
ret = -EINVAL;
goto out;
}

if (obj->type != ACPI_TYPE_INTEGER) {
dev_err(dev, "%s: object is not ACPI_TYPE_INTEGER\n", __func__);
ret = -EINVAL;
goto err;
}

*value = obj->integer.value;
err:
ACPI_FREE(obj);
out:
return ret;
}

int es83xx_dsm_jack_inverted(struct device *dev)
{
int value;
int ret;

ret = es83xx_dsm(dev, PLATFORM_HPDET_INV_ARG, &value);
if (ret < 0)
return ret;
dev_info(dev, "HP jack detect inverted %d\n", value);
return value;
}
EXPORT_SYMBOL_GPL(es83xx_dsm_jack_inverted);

MODULE_DESCRIPTION("Everest Semi ES83xx DSM helpers");
MODULE_LICENSE("GPL");
Loading