Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/sof es8336 quirk #26

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e918778
ASoC: soc-acpi: fix kernel-doc descriptor
plbossart Dec 14, 2021
3349f9b
ASoC: soc-acpi: add information on I2S/TDM link mask
plbossart Dec 14, 2021
092e260
ASoC: SOF: Intel: hda: retrieve DMIC number for I2S boards
plbossart Dec 14, 2021
01198fd
ALSA: intel-nhlt: add helper to detect SSP link mask
plbossart Dec 14, 2021
31dcc15
ASoC: SOF: Intel: hda: report SSP link mask to machine driver
plbossart Dec 14, 2021
9a92e01
ASoC: Intel: soc-acpi: quirk topology filename dynamically
plbossart Jan 12, 2022
dc7d678
ASoC: Intel: sof_es8336: make gpio optional
plbossart Jan 12, 2022
9fde854
ASoC: Intel: sof_es8336: get codec device with ACPI instead of bus se…
plbossart Jan 13, 2022
a2588ff
ASoC: Intel: sof_es8336: use NHLT information to set dmic and SSP
plbossart Dec 14, 2021
03d28c5
ALSA: intel-dsp-config: add more ACPI HIDs for ES83x6 devices
plbossart Jan 24, 2022
6a4b9fe
ASoC: Intel: soc-acpi: add more ACPI HIDs for ES83x6 devices
plbossart Jan 24, 2022
0fa152d
ASoC: SOF: ipc3-topology: add quirk for Intel SSP mclk_id
plbossart Feb 11, 2022
c8a704c
ASoC: Intel: sof_es8336: log all quirks
plbossart Feb 12, 2022
2f9e82c
ASoC: Intel: sof_es8336: move comment to the right place
plbossart Feb 12, 2022
55ef2fa
ASoC: Intel: sof_es8336: add support for JD inverted quirk
plbossart Feb 12, 2022
ecc3ecd
ASoC: Intel: bytcht_es8316: move comment to the right place
plbossart Feb 12, 2022
5929fad
ASoC: Intel: sof_es8336: extend machine driver to support ES8326 codec
plbossart Feb 12, 2022
42c13e5
ALSA: intel-dspconfig: add ES8336 support for CNL
plbossart Feb 16, 2022
3e46914
ASoC: Intel: soc-acpi: add ESSX8336 support on Cannon Lake machines
realnickel Feb 15, 2022
e97f887
ASoC: codecs: add support for ES8326
yangxiaohua1977 Feb 18, 2022
935ca4b
Now use clock API
yangxiaohua1977 Mar 8, 2022
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
110 changes: 110 additions & 0 deletions Documentation/devicetree/bindings/sound/everest,es8326.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/everest,es8326.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Everest ES8326 audio CODEC

maintainers:
- Daniel Drake <[email protected]>
- David Yang <[email protected]>

properties:
compatible:
const: everest,es8326

reg:
maxItems: 1

clocks:
items:
- description: clock for master clock (MCLK)

clock-names:
items:
- const: mclk

"#sound-dai-cells":
const: 0

mclk-rate:
description:
clock rate of mclk
$ref: /schemas/types.yaml#/definitions/uint32-array
minItems: 1

jack-pol:
description:
just the value of reg 57. Bit(3) decides whether the jack polarity is inverted.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this work since you also have the 'jack-inverted' value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A default value is defined here which can be inverted by 'jack-inverted' ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Bit(2) decides whether the bottom on the headset is inverted.
Bit(1)/(0) decides the mic properity to be OMTP/CTIA or auto.
$ref: /schemas/types.yaml#/definitions/uint8-array
minimum: 0
maximum: 0x0f
default: 0x0f

mic1-src:
description:
the value of reg 2A when headset plugged.
$ref: /schemas/types.yaml#/definitions/uint8-array
minimum: 0x00
maximum: 0x77
default: 0x22

mic2-src:
description:
the value of reg 2A when headset unplugged.
$ref: /schemas/types.yaml#/definitions/uint8-array
minimum: 0x00
maximum: 0x77
default: 0x44

amic1-src:
description:
the value of reg 23 when headset plugged.
$ref: /schemas/types.yaml#/definitions/uint8-array
minimum: 0x19
maximum: 0x29
default: 0x19

amic2-src:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need the 'everest,' prefix for all properties?

description:
the value of reg 23 when headset unplugged.
Set to 0x19 if dmic used. Set to 0x29 if amic used.
$ref: /schemas/types.yaml#/definitions/uint8-array
minimum: 0x19
maximum: 0x29
default: 0x19

everest,jack-detect-inverted:
description:
Defined to invert the jack detection.
$ref: /schemas/types.yaml#/definitions/flag

required:
- compatible
- reg
- "#sound-dai-cells"


additionalProperties: false

examples:
- |
i2c0 {
#address-cells = <1>;
#size-cells = <0>;
es8326: codec@19 {
compatible = "everest,es8326";
reg = <0x19>;
clocks = <&clks 10>;
clock-names = "mclk";
#sound-dai-cells = <0>;
mic1-src = [22];
mic2-src = [44];
amic1-src = [19];
amic2-src = [19];
jack-pol = [0e];
};
};
22 changes: 15 additions & 7 deletions include/sound/intel-nhlt.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ enum nhlt_link_type {
NHLT_LINK_INVALID
};

enum nhlt_device_type {
NHLT_DEVICE_BT = 0,
NHLT_DEVICE_DMIC = 1,
NHLT_DEVICE_I2S = 4,
NHLT_DEVICE_INVALID
};

#if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT)

struct wav_fmt {
Expand All @@ -41,13 +48,6 @@ struct wav_fmt_ext {
u8 sub_fmt[16];
} __packed;

enum nhlt_device_type {
NHLT_DEVICE_BT = 0,
NHLT_DEVICE_DMIC = 1,
NHLT_DEVICE_I2S = 4,
NHLT_DEVICE_INVALID
};

struct nhlt_specific_cfg {
u32 size;
u8 caps[];
Expand Down Expand Up @@ -133,6 +133,9 @@ void intel_nhlt_free(struct nhlt_acpi_table *addr);
int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt);

bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type);

int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type);

struct nhlt_specific_cfg *
intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
u32 bus_id, u8 link_type, u8 vbps, u8 bps,
Expand Down Expand Up @@ -163,6 +166,11 @@ static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt,
return false;
}

static inline int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type)
{
return 0;
}

static inline struct nhlt_specific_cfg *
intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
u32 bus_id, u8 link_type, u8 vbps, u8 bps,
Expand Down
27 changes: 25 additions & 2 deletions include/sound/soc-acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
* @acpi_ipc_irq_index: used for BYT-CR detection
* @platform: string used for HDAudio codec support
* @codec_mask: used for HDAudio support
* @dmic_num: number of SoC- or chipset-attached PDM digital microphones
* @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver
* @link_mask: links enabled on the board
* @links: array of link _ADR descriptors, null terminated
* @link_mask: SoundWire links enabled on the board
* @links: array of SoundWire link _ADR descriptors, null terminated
* @i2s_link_mask: I2S/TDM links enabled on the board
* @num_dai_drivers: number of elements in @dai_drivers
* @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode
*/
Expand All @@ -74,6 +76,7 @@ struct snd_soc_acpi_mach_params {
bool common_hdmi_codec_drv;
u32 link_mask;
const struct snd_soc_acpi_link_adr *links;
u32 i2s_link_mask;
u32 num_dai_drivers;
struct snd_soc_dai_driver *dai_drivers;
};
Expand Down Expand Up @@ -122,6 +125,24 @@ struct snd_soc_acpi_link_adr {
const struct snd_soc_acpi_adr_device *adr_d;
};

/*
* when set the topology uses the -ssp<N> suffix, where N is determined based on
* BIOS or DMI information
*/
#define SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER BIT(0)

/*
* when more than one SSP is reported in the link mask, use the most significant.
* This choice was found to be valid on platforms with ES8336 codecs.
*/
#define SND_SOC_ACPI_TPLG_INTEL_SSP_MSB BIT(1)

/*
* when set the topology uses the -dmic<N>ch suffix, where N is determined based on
* BIOS or DMI information
*/
#define SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER BIT(2)

/**
* snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
* related to the hardware, except for the firmware and topology file names.
Expand All @@ -143,6 +164,7 @@ struct snd_soc_acpi_link_adr {
* @pdata: intended for platform data or machine specific-ops. This structure
* is not constant since this field may be updated at run-time
* @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
* @tplg_quirk_mask: quirks to select different topology files dynamically
*/
/* Descriptor for SST ASoC machine driver */
struct snd_soc_acpi_mach {
Expand All @@ -158,6 +180,7 @@ struct snd_soc_acpi_mach {
void *pdata;
struct snd_soc_acpi_mach_params mach_params;
const char *sof_tplg_filename;
const u32 tplg_quirk_mask;
};

#define SND_SOC_ACPI_MAX_CODECS 3
Expand Down
34 changes: 25 additions & 9 deletions sound/hda/intel-dsp-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sound/core.h>
#include <sound/intel-dsp-config.h>
#include <sound/intel-nhlt.h>
#include <sound/soc-acpi.h>

static int dsp_driver;

Expand All @@ -31,7 +32,12 @@ struct config_entry {
u16 device;
u8 acpi_hid[ACPI_ID_LEN];
const struct dmi_system_id *dmi_table;
u8 codec_hid[ACPI_ID_LEN];
const struct snd_soc_acpi_codecs *codec_hid;
};

static const struct snd_soc_acpi_codecs __maybe_unused essx_83x6 = {
.num_codecs = 3,
.codecs = { "ESSX8316", "ESSX8326", "ESSX8336"},
};

/*
Expand Down Expand Up @@ -77,7 +83,7 @@ static const struct config_entry config_table[] = {
{
.flags = FLAG_SOF,
.device = 0x5a98,
.codec_hid = "ESSX8336",
.codec_hid = &essx_83x6,
},
#endif
#if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)
Expand Down Expand Up @@ -163,7 +169,7 @@ static const struct config_entry config_table[] = {
{
.flags = FLAG_SOF,
.device = 0x3198,
.codec_hid = "ESSX8336",
.codec_hid = &essx_83x6,
},
#endif

Expand Down Expand Up @@ -193,6 +199,11 @@ static const struct config_entry config_table[] = {
{}
}
},
{
.flags = FLAG_SOF,
.device = 0x09dc8,
.codec_hid = &essx_83x6,
},
{
.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
.device = 0x9dc8,
Expand Down Expand Up @@ -251,7 +262,7 @@ static const struct config_entry config_table[] = {
{
.flags = FLAG_SOF,
.device = 0x02c8,
.codec_hid = "ESSX8336",
.codec_hid = &essx_83x6,
},
{
.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
Expand Down Expand Up @@ -280,7 +291,7 @@ static const struct config_entry config_table[] = {
{
.flags = FLAG_SOF,
.device = 0x06c8,
.codec_hid = "ESSX8336",
.codec_hid = &essx_83x6,
},
{
.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
Expand Down Expand Up @@ -327,7 +338,7 @@ static const struct config_entry config_table[] = {
{
.flags = FLAG_SOF,
.device = 0x4dc8,
.codec_hid = "ESSX8336",
.codec_hid = &essx_83x6,
},
{
.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Expand All @@ -353,7 +364,7 @@ static const struct config_entry config_table[] = {
{
.flags = FLAG_SOF,
.device = 0xa0c8,
.codec_hid = "ESSX8336",
.codec_hid = &essx_83x6,
},
{
.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
Expand Down Expand Up @@ -414,8 +425,13 @@ static const struct config_entry *snd_intel_dsp_find_config
continue;
if (table->dmi_table && !dmi_check_system(table->dmi_table))
continue;
if (table->codec_hid[0] && !acpi_dev_present(table->codec_hid, NULL, -1))
continue;
if (table->codec_hid) {
int i;

for (i = 0; i < table->codec_hid->num_codecs; i++)
if (!acpi_dev_present(table->codec_hid->codecs[i], NULL, -1))
continue;
}
return table;
}
return NULL;
Expand Down
22 changes: 22 additions & 0 deletions sound/hda/intel-nhlt.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,28 @@ bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type)
}
EXPORT_SYMBOL(intel_nhlt_has_endpoint_type);

int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type)
{
struct nhlt_endpoint *epnt;
int ssp_mask = 0;
int i;

if (!nhlt || (device_type != NHLT_DEVICE_BT && device_type != NHLT_DEVICE_I2S))
return 0;

epnt = (struct nhlt_endpoint *)nhlt->desc;
for (i = 0; i < nhlt->endpoint_count; i++) {
if (epnt->linktype == NHLT_LINK_SSP && epnt->device_type == device_type) {
/* for SSP the virtual bus id is the SSP port */
ssp_mask |= BIT(epnt->virtual_bus_id);
}
epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
}

return ssp_mask;
}
EXPORT_SYMBOL(intel_nhlt_ssp_endpoint_mask);

static struct nhlt_specific_cfg *
nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch,
u32 rate, u8 vbps, u8 bps)
Expand Down
5 changes: 5 additions & 0 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ config SND_SOC_ALL_CODECS
imply SND_SOC_DA9055
imply SND_SOC_DMIC
imply SND_SOC_ES8316
imply SND_SOC_ES8326
imply SND_SOC_ES8328_SPI
imply SND_SOC_ES8328_I2C
imply SND_SOC_ES7134
Expand Down Expand Up @@ -863,6 +864,10 @@ config SND_SOC_ES8316
tristate "Everest Semi ES8316 CODEC"
depends on I2C

config SND_SOC_ES8326
tristate "Everest Semi ES8326 CODEC"
depends on I2C

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 @@ -95,6 +95,7 @@ snd-soc-dmic-objs := dmic.o
snd-soc-es7134-objs := es7134.o
snd-soc-es7241-objs := es7241.o
snd-soc-es8316-objs := es8316.o
snd-soc-es8326-objs := es8326.o
snd-soc-es8328-objs := es8328.o
snd-soc-es8328-i2c-objs := es8328-i2c.o
snd-soc-es8328-spi-objs := es8328-spi.o
Expand Down Expand Up @@ -436,6 +437,7 @@ 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_ES8316) += snd-soc-es8316.o
obj-$(CONFIG_SND_SOC_ES8326) += snd-soc-es8326.o
obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o
obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
Expand Down
Loading