[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
Thu Jun 23 04:29:26 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 2cc99d03a6557ceb0da86857162352dbe6551dc0
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 audio 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       | 55 ++++++++++++++++++++++++
 src/drivers/intel/audio/Makefile.inc  | 43 +++++++++++++++++++
 src/drivers/intel/audio/audio.h       | 53 +++++++++++++++++++++++
 src/drivers/intel/audio/audio_codec.c | 80 +++++++++++++++++++++++++++++++++++
 src/drivers/intel/audio/dmic.c        | 52 +++++++++++++++++++++++
 src/drivers/intel/audio/nhlt.c        | 76 +++++++++++++++++++++++++++++++++
 6 files changed, 359 insertions(+)

diff --git a/src/drivers/intel/audio/Kconfig b/src/drivers/intel/audio/Kconfig
new file mode 100644
index 0000000..f82ef61
--- /dev/null
+++ b/src/drivers/intel/audio/Kconfig
@@ -0,0 +1,55 @@
+config USE_COMMON_NHLT
+	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_NHLT
+	default n
+	help
+	  Include DSP firmware settings for 2 channel 16B DMIC array.
+
+config AUDIO_DMIC_2CH_32B
+	bool
+	depends on USE_COMMON_NHLT
+	default n
+	help
+	  Include DSP firmware settings for 2 channel 32B DMIC array.
+
+config AUDIO_DMIC_4CH_16B
+	bool
+	depends on USE_COMMON_NHLT
+	default n
+	help
+	  Include DSP firmware settings for 4 channel 16B DMIC array.
+
+config AUDIO_DMIC_4CH_32B
+	bool
+	depends on USE_COMMON_NHLT
+	default n
+	help
+	  Include DSP firmware settings for 4 channel 32B DMIC array.
+
+config AUDIO_HEADSET
+	bool
+	depends on USE_COMMON_NHLT
+	default n
+	help
+	  Include DSP firmware settings for headset codec.
+
+config AUDIO_SPEAKER_RENDER
+	bool
+	depends on USE_COMMON_NHLT
+	default n
+	help
+	  Include DSP firmware settings for speaker-render amplifier.
+
+config AUDIO_SPEAKER_CAPTURE
+	bool
+	depends on USE_COMMON_NHLT
+	default n
+	help
+	  Include DSP firmware settings for speaker-capture amplifier.
diff --git a/src/drivers/intel/audio/Makefile.inc b/src/drivers/intel/audio/Makefile.inc
new file mode 100644
index 0000000..56aa697
--- /dev/null
+++ b/src/drivers/intel/audio/Makefile.inc
@@ -0,0 +1,43 @@
+ramstage-$(CONFIG_USE_COMMON_NHLT) += nhlt.c
+ramstage-$(CONFIG_USE_COMMON_NHLT) += dmic.c
+ramstage-$(CONFIG_USE_COMMON_NHLT) += audio_codec.c
+
+# DSP firmware settings files.
+NHLT_BLOB_PATH = 3rdparty/blobs/soc/intel/common/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.bin
+
+SPEAKER_RENDER = speaker-render.bin
+SPEAKER_CAPTURE = speaker-capture.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_RENDER) += $(SPEAKER_RENDER)
+$(SPEAKER_RENDER)-file := $(NHLT_BLOB_PATH)/$(SPEAKER_RENDER)
+$(SPEAKER_RENDER)-type := raw
+
+cbfs-files-$(CONFIG_AUDIO_SPEAKER_CAPTURE) += $(SPEAKER_CAPTURE)
+$(SPEAKER_CAPTURE)-file := $(NHLT_BLOB_PATH)/$(SPEAKER_CAPTURE)
+$(SPEAKER_CAPTURE)-type := raw
diff --git a/src/drivers/intel/audio/audio.h b/src/drivers/intel/audio/audio.h
new file mode 100644
index 0000000..51fc6ed
--- /dev/null
+++ b/src/drivers/intel/audio/audio.h
@@ -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.
+ */
+
+#ifndef _DRIVERS_AUDIO_H_
+#define _DRIVERS_AUDIO_H_
+
+#include <nhlt.h>
+
+/*
+ * NHLT device and hardware link types. These values are used with
+ * nhlt_soc_add_endpoint().
+ */
+
+enum {
+	AUDIO_DEV_I2S,
+	AUDIO_DEV_DMIC,
+	AUDIO_DEV_BT,
+};
+
+enum {
+	AUDIO_RENDER,
+	AUDIO_CAPTURE,
+	AUDIO_BIDIR = AUDIO_RENDER | AUDIO_CAPTURE,
+};
+
+/*
+ * 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, int num_channels,
+	const struct nhlt_format_config *dmic_ch_config, int num_fmt);
+
+/*
+ * Add audio codec on provided SSP link. Return 0 on succes, < 0 on error.
+ */
+int nhlt_soc_add_codec_on_ssp(struct nhlt *nhlt, int hwlink, int direction,
+		const struct nhlt_format_config *render_cfg, int r_num_fmt,
+		const struct nhlt_format_config *capture_cfg, int c_num_fmt,
+		struct nhlt_tdm_config *tdm_config);
+
+#endif
diff --git a/src/drivers/intel/audio/audio_codec.c b/src/drivers/intel/audio/audio_codec.c
new file mode 100644
index 0000000..cfe655b
--- /dev/null
+++ b/src/drivers/intel/audio/audio_codec.c
@@ -0,0 +1,80 @@
+/*
+ * 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/intel/audio/audio.h>
+#include <console/console.h>
+
+/* The same DSP firmware settings can be used for both the capture and render
+ * endpoints in some cases. Most of the smart amps use different DSP firmware
+ * settings for capture and render endpoints.
+ *
+ * render_cfg, capture_cfg: These are the audio codec configuration defined
+ * in mainboard souce code.
+ * cfg_size: This is the number of configurations defined in codec config.
+ * 	Each configuration is added as an endpoint.
+ * tdm_config: This is also board specific and defined in mainboard.c
+ * hwlink: This is the SSP hardware port number.
+ * direction: This can be Render only, Capture only or Bi-directional.
+ */
+int nhlt_soc_add_codec_on_ssp (struct nhlt *nhlt, int hwlink, int direction,
+		const struct nhlt_format_config *render_cfg, int r_num_fmt,
+		const struct nhlt_format_config *capture_cfg, int c_num_fmt,
+		struct nhlt_tdm_config *tdm_config)
+{
+	struct nhlt_endpoint *endp;
+
+	/* For Bi-directional amplifiers, both capture and render
+	 * configuratoins are needed.
+	 */
+	if (direction == AUDIO_BIDIR &&
+	  (render_cfg == NULL || capture_cfg == NULL))
+		return -1;
+
+	/* Render Endpoint */
+	if (direction == AUDIO_RENDER || direction == AUDIO_BIDIR) {
+		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, render_cfg, r_num_fmt))
+			return -1;
+	}
+
+	/* Capture Endpoint */
+	if (direction == AUDIO_CAPTURE || direction == AUDIO_BIDIR) {
+		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, capture_cfg, c_num_fmt))
+			return -1;
+	}
+
+	nhlt_next_instance (nhlt, NHLT_LINK_SSP);
+
+	return 0;
+}
diff --git a/src/drivers/intel/audio/dmic.c b/src/drivers/intel/audio/dmic.c
new file mode 100644
index 0000000..9171201
--- /dev/null
+++ b/src/drivers/intel/audio/dmic.c
@@ -0,0 +1,52 @@
+ /*
+ * 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/intel/audio/audio.h>
+#include <soc/nhlt_ids.h>
+#include <string.h>
+
+int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels,
+		const struct nhlt_format_config *dmic_ch_cfg, int num_fmt)
+{
+	struct nhlt_endpoint *endp;
+	struct nhlt_dmic_array_config mic_config;
+
+	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;
+
+	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, dmic_ch_cfg, num_fmt);
+}
+
diff --git a/src/drivers/intel/audio/nhlt.c b/src/drivers/intel/audio/nhlt.c
new file mode 100644
index 0000000..4920c84
--- /dev/null
+++ b/src/drivers/intel/audio/nhlt.c
@@ -0,0 +1,76 @@
+/*
+ * 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 <cbmem.h>
+#include <drivers/intel/audio/audio.h>
+#include <soc/acpi.h>
+#include <soc/nhlt_ids.h>
+#include <soc/nvs.h>
+
+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;
+
+	nhlt_link_type = get_nhlt_link_type(soc_hwintf, soc_devtype);	
+
+	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 link is the hardware port id. */
+	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);
+}



More information about the coreboot-gerrit mailing list