[coreboot-gerrit] Patch set updated for coreboot: drivers/intel/audio: Add common NHLT audio for Intel platforms

Saurabh Satija (saurabh.satija@intel.com) gerrit at coreboot.org
Wed Jun 1 03:24:20 CEST 2016


Saurabh Satija (saurabh.satija at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15023

-gerrit

commit dc432beb0fde7f24f92801c91139a1fcc61c9c73
Author: Saurabh Satija <saurabh.satija at intel.com>
Date:   Thu May 26 15:53:41 2016 -0700

    drivers/intel/audio: Add common NHLT audio for Intel platforms
    
    The use of a NHLT table is required to make audio work
    on the intel SoCs employing the internal DSP. The table
    describes the audo endpoints (render vs capture) along with
    their supported formats. These formats are not only dependent
    on the audio peripheral but also hardware interfaces. As such
    each format has an associated blob of DSP settings to make
    the peripheral work. Lastly, each of these settings are provided
    by Intel and need to be generated for each device's hardware
    connection plus mode/format it supports. This patch does not
    include the dsp setting blobs.
    
    Change-Id: I3c75d3537288c47d29e8949ca253ea8c5c1a387d
    Signed-off-by: Saurabh Satija <saurabh.satija at intel.com>
---
 src/drivers/intel/audio/Kconfig                 | 48 +++++++++++++
 src/drivers/intel/audio/Makefile.inc            | 43 +++++++++++
 src/drivers/intel/audio/dmic.c                  | 53 ++++++++++++++
 src/drivers/intel/audio/headset.c               | 60 ++++++++++++++++
 src/drivers/intel/audio/include/drivers/audio.h | 59 +++++++++++++++
 src/drivers/intel/audio/nhlt.c                  | 95 +++++++++++++++++++++++++
 src/drivers/intel/audio/speaker.c               | 40 +++++++++++
 7 files changed, 398 insertions(+)

diff --git a/src/drivers/intel/audio/Kconfig b/src/drivers/intel/audio/Kconfig
new file mode 100644
index 0000000..fdc494c
--- /dev/null
+++ b/src/drivers/intel/audio/Kconfig
@@ -0,0 +1,48 @@
+config USE_COMMON_AUDIO
+        bool
+        default n
+        help
+          Build support for drivers audio code, common to intel
+          platforms that use NHLT.
+
+config AUDIO_DMIC_2CH_16B
+        bool
+        depends on USE_COMMON_AUDIO
+        default n
+        help
+          Include DSP firmware settings for 2 channel 16B DMIC array.
+
+config AUDIO_DMIC_2CH_32B
+        bool
+        depends on USE_COMMON_AUDIO
+        default n
+        help
+          Include DSP firmware settings for 2 channel 32B DMIC array.
+
+config AUDIO_DMIC_4CH_16B
+        bool
+        depends on USE_COMMON_AUDIO
+        default n
+        help
+          Include DSP firmware settings for 4 channel 16B DMIC array.
+
+config AUDIO_DMIC_4CH_32B
+        bool
+        depends on USE_COMMON_AUDIO
+        default n
+        help
+          Include DSP firmware settings for 4 channel 32B DMIC array.
+
+config AUDIO_HEADSET
+        bool
+        depends on USE_COMMON_AUDIO
+        default n
+        help
+          Include DSP firmware settings for headset codec.
+
+config AUDIO_SPEAKER
+        bool
+        depends on USE_COMMON_AUDIO
+        default n
+        help
+          Include DSP firmware settings for speaker amplifier.
diff --git a/src/drivers/intel/audio/Makefile.inc b/src/drivers/intel/audio/Makefile.inc
new file mode 100644
index 0000000..6bea190
--- /dev/null
+++ b/src/drivers/intel/audio/Makefile.inc
@@ -0,0 +1,43 @@
+ifeq ($(CONFIG_USE_COMMON_AUDIO),y)
+ramstage-y += nhlt.c
+ramstage-y += dmic.c
+ramstage-y += headset.c
+ramstage-y += speaker.c
+
+# DSP firmware settings files.
+NHLT_BLOB_PATH = 3rdparty/blobs/soc/intel/apollolake/nhlt-blobs
+DMIC_2CH_48KHZ_16B = dmic-2ch-48khz-16b.bin
+DMIC_2CH_48KHZ_32B = dmic-2ch-48khz-32b.bin
+DMIC_4CH_48KHZ_16B = dmic-4ch-48khz-16b.bin
+DMIC_4CH_48KHZ_32B = dmic-4ch-48khz-32b.bin
+
+HEADSET = headset-2ch-48khz-24b.bin
+
+SPEAKER_RENDER = max98357-render-2ch-48khz-24b.bin
+
+cbfs-files-$(CONFIG_AUDIO_DMIC_2CH_16B) += $(DMIC_2CH_48KHZ_16B)
+$(DMIC_2CH_48KHZ_16B)-file := $(NHLT_BLOB_PATH)/$(DMIC_2CH_48KHZ_16B)
+$(DMIC_2CH_48KHZ_16B)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_DMIC_2CH_32B) += $(DMIC_2CH_48KHZ_32B)
+$(DMIC_2CH_48KHZ_32B)-file := $(NHLT_BLOB_PATH)/$(DMIC_2CH_48KHZ_32B)
+$(DMIC_2CH_48KHZ_32B)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_DMIC_4CH_16B) += $(DMIC_4CH_48KHZ_16B)
+$(DMIC_4CH_48KHZ_16B)-file := $(NHLT_BLOB_PATH)/$(DMIC_4CH_48KHZ_16B)
+$(DMIC_4CH_48KHZ_16B)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_DMIC_4CH_32B) += $(DMIC_4CH_48KHZ_32B)
+$(DMIC_4CH_48KHZ_32B)-file := $(NHLT_BLOB_PATH)/$(DMIC_4CH_48KHZ_32B)
+$(DMIC_4CH_48KHZ_32B)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_HEADSET) += $(HEADSET)
+$(HEADSET)-file := $(NHLT_BLOB_PATH)/$(HEADSET)
+$(HEADSET)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_SPEAKER) += $(SPEAKER_RENDER)
+$(SPEAKER_RENDER)-file := $(NHLT_BLOB_PATH)/$(SPEAKER_RENDER)
+$(SPEAKER_RENDER)-type := raw
+endif
+
+CPPFLAGS_common += -I$(src)/drivers/intel/audio/include
diff --git a/src/drivers/intel/audio/dmic.c b/src/drivers/intel/audio/dmic.c
new file mode 100644
index 0000000..fe11d51
--- /dev/null
+++ b/src/drivers/intel/audio/dmic.c
@@ -0,0 +1,53 @@
+ /*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <drivers/audio.h>
+#include <string.h>
+
+int nhlt_soc_add_dmic_array(struct nhlt *nhlt, const struct nhlt_format_config *dmic_ch_cfg, int fmt_size, int num_channels)
+{
+	struct nhlt_endpoint *endp;
+	struct nhlt_dmic_array_config mic_config;
+	const struct nhlt_format_config *formats;
+
+	if (num_channels != 2 && num_channels != 4)
+                return -1;
+
+	endp = nhlt_soc_add_endpoint(nhlt, AUDIO_LINK_DMIC, AUDIO_DEV_DMIC,
+					NHLT_DIR_CAPTURE);
+
+	if (endp == NULL)
+		return -1;
+
+	memset(&mic_config, 0, sizeof(mic_config));
+	mic_config.tdm_config.config_type = NHLT_TDM_MIC_ARRAY;
+
+	formats = dmic_ch_cfg;
+
+	switch (num_channels) {
+	case 2:
+		mic_config.array_type = NHLT_MIC_ARRAY_2CH_SMALL;
+		break;
+	case 4:
+		mic_config.array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED;
+		break;
+	}
+
+	if (nhlt_endpoint_append_config(endp, &mic_config, sizeof(mic_config)))
+		return -1;
+
+	return nhlt_endpoint_add_formats(endp, formats, fmt_size);
+}
+
diff --git a/src/drivers/intel/audio/headset.c b/src/drivers/intel/audio/headset.c
new file mode 100644
index 0000000..68acee2
--- /dev/null
+++ b/src/drivers/intel/audio/headset.c
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <drivers/audio.h>
+#include <console/console.h>
+
+/* The same DSP firmwware settings are used for both the capture and
+ * render endpoints. */
+int nhlt_soc_add_headset(struct nhlt *nhlt, const struct nhlt_format_config *headset_cfg, int fmt_size, struct nhlt_tdm_config *tdm_config, int hwlink)
+{
+	struct nhlt_endpoint *endp;
+	/* The headphone codec has headphones and a mic. Both the capture and
+	 * render endpoints occupy the same virtual slot. */
+	const void *fmt_cfg = headset_cfg;
+	size_t fmt_sz = fmt_size;
+
+	/* Render Endpoint */
+	endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+					NHLT_DIR_RENDER);
+	if (endp == NULL)
+		return -1;
+
+	if(tdm_config != NULL){
+		if (nhlt_endpoint_append_config(endp, tdm_config, 1))
+			return -1;
+	}
+
+	if (nhlt_endpoint_add_formats(endp, fmt_cfg, fmt_sz))
+		return -1;
+
+	/* Capture Endpoint */
+	endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+					NHLT_DIR_CAPTURE);
+	if (endp == NULL)
+		return -1;
+
+	if(tdm_config != NULL){
+		if (nhlt_endpoint_append_config(endp, &tdm_config, 1))
+			return -1;
+	}
+
+	if (nhlt_endpoint_add_formats(endp, fmt_cfg, fmt_sz))
+		return -1;
+
+	nhlt_next_instance(nhlt, NHLT_LINK_SSP);
+
+	return 0;
+}
diff --git a/src/drivers/intel/audio/include/drivers/audio.h b/src/drivers/intel/audio/include/drivers/audio.h
new file mode 100644
index 0000000..caf1edc
--- /dev/null
+++ b/src/drivers/intel/audio/include/drivers/audio.h
@@ -0,0 +1,59 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DRIVERS_AUDIO_H_
+#define _DRIVERS_AUDIO_H_
+
+#include <nhlt.h>
+
+/*
+ * Skylake NHLT device and hardware link types. These values are to be used
+ * with nhlt_soc_add_endpoint().
+ */
+
+enum {
+	AUDIO_LINK_SSP0,
+	AUDIO_LINK_SSP1,
+	AUDIO_LINK_SSP2, /* Only Bluetooth supported on SSP2. */
+	AUDIO_LINK_SSP3,
+	AUDIO_LINK_SSP4,
+	AUDIO_LINK_SSP5,
+	AUDIO_LINK_DMIC,
+};
+
+enum {
+	AUDIO_DEV_I2S,
+	AUDIO_DEV_DMIC,
+	AUDIO_DEV_BT,
+};
+
+/*
+ * Add a dmic array composed of the provided number of channels. 
+ * Returns 0 on success, < 0 on error.
+ */
+int nhlt_soc_add_dmic_array(struct nhlt *nhlt, const struct nhlt_format_config *dmic_ch_config, int cfg_size, int num_channels);
+
+/*
+ * Add headset codec on provided SSP link. Return 0 on succes, < 0 on error.
+ */
+int nhlt_soc_add_headset(struct nhlt *nhlt, const struct nhlt_format_config *headset_cfg, int cfg_size, struct nhlt_tdm_config *tdm_config, int hwlink);
+
+/*
+ * Add speaker amplifier in stereo configuration on provide SSP link.
+ * Return 0 on success, < 0 on error.
+ */
+int nhlt_soc_add_speaker(struct nhlt *nhlt, const struct nhlt_format_config *speaker_cfg, int cfg_size, struct nhlt_tdm_config *tdm_config, int hwlink);
+
+#endif
diff --git a/src/drivers/intel/audio/nhlt.c b/src/drivers/intel/audio/nhlt.c
new file mode 100644
index 0000000..0f8e6e1
--- /dev/null
+++ b/src/drivers/intel/audio/nhlt.c
@@ -0,0 +1,95 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <cbmem.h>
+#include <soc/acpi.h>
+#include <drivers/audio.h>
+
+#define NHLT_VID 0x8086
+#define NHLT_DID_DMIC 0xae20
+#define NHLT_DID_BT 0xae30
+#define NHLT_DID_SSP 0xae34
+
+struct nhlt_endpoint *nhlt_soc_add_endpoint(struct nhlt *nhlt, int soc_hwintf,
+						int soc_devtype, int dir)
+{
+	int nhlt_link_type;
+	int nhlt_dev_type;
+	uint16_t did;
+	struct nhlt_endpoint *endp;
+
+	/* Check link type and device type. */
+	switch (soc_hwintf) {
+	case AUDIO_LINK_SSP0:
+	case AUDIO_LINK_SSP1:
+	case AUDIO_LINK_SSP5:
+	case AUDIO_LINK_SSP2:
+		nhlt_link_type = NHLT_LINK_SSP;
+		break;
+	case AUDIO_LINK_DMIC:
+		/* Only DMIC devices on DMIC links. */
+		if (soc_devtype != AUDIO_DEV_DMIC)
+			return NULL;
+		nhlt_link_type = NHLT_LINK_PDM;
+		break;
+	default:
+		return NULL;
+	}
+
+	switch (soc_devtype) {
+	case AUDIO_DEV_I2S:
+		nhlt_dev_type = NHLT_SSP_DEV_I2S;
+		did = NHLT_DID_SSP;
+		break;
+	case AUDIO_DEV_DMIC:
+		nhlt_dev_type = NHLT_PDM_DEV;
+		did = NHLT_DID_DMIC;
+		break;
+	case AUDIO_DEV_BT:
+		nhlt_dev_type = NHLT_SSP_DEV_BT;
+		did = NHLT_DID_BT;
+		break;
+	default:
+		return NULL;
+	}
+
+	endp = nhlt_add_endpoint(nhlt, nhlt_link_type, nhlt_dev_type, dir,
+				NHLT_VID, did);
+
+	if (endp == NULL)
+		return NULL;
+
+	/* Virtual bus id of SSP links are the hardware port ids proper. */
+	if (nhlt_link_type == NHLT_LINK_SSP)
+		endp->virtual_bus_id = soc_hwintf;
+
+	return endp;
+}
+
+uintptr_t nhlt_soc_serialize(struct nhlt *nhlt, uintptr_t acpi_addr)
+{
+	struct global_nvs_t *gnvs;
+
+	gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS);
+
+	if (gnvs == NULL)
+		return acpi_addr;
+
+	/* Update NHLT GNVS Data */
+	gnvs->nhla = (uintptr_t)acpi_addr;
+	gnvs->nhll = nhlt_current_size(nhlt);
+
+	return nhlt_serialize(nhlt, acpi_addr);
+}
diff --git a/src/drivers/intel/audio/speaker.c b/src/drivers/intel/audio/speaker.c
new file mode 100644
index 0000000..63dba66
--- /dev/null
+++ b/src/drivers/intel/audio/speaker.c
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <drivers/audio.h>
+
+int nhlt_soc_add_speaker(struct nhlt *nhlt, const struct nhlt_format_config *speaker_cfg, int fmt_size, struct nhlt_tdm_config *tdm_config, int hwlink)
+{
+	struct nhlt_endpoint *endp;
+
+	/* Render Endpoint */
+	endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+					NHLT_DIR_RENDER);
+
+	if (endp == NULL)
+		return -1;
+
+	if(tdm_config != NULL){
+                if (nhlt_endpoint_append_config(endp, &tdm_config, 1))
+                        return -1;
+        }
+
+	if (nhlt_endpoint_add_formats(endp, speaker_cfg, fmt_size))
+		return -1;
+
+	nhlt_next_instance(nhlt, NHLT_LINK_SSP);
+
+	return 0;
+}



More information about the coreboot-gerrit mailing list