Skip to contentSkip to conversation

ASoC: Intel: Skylake: Add DSP management routines

PATCH Superseded Vinod Koul 2 participants 19 messages Jul 21, 2015 – Aug 1, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

cover ASoC: Intel: Skylake: Add DSP management routines

This series adds NHLT table support in the driver. This also adds support for dsp init, modules configuration and messaging support

Hardik T Shah (1):
ASoC: Intel: Skylake: Add helpers for SRC and converter modules

Jeeja KP (5):
ASoC: Intel: Skylake: Add NHLT support to get BE config
ASoC: Intel: Skylake: Add dsp and ipc init helpers
ASoC: Intel: Skylake: Add functions for DSP module configuration
ASoC: Intel: Skylake: Add DSP module init and binding routines
ASoC: Intel: Skylake: Add pipe management helpers

 sound/soc/intel/skylake/Makefile             |   2 +-
 sound/soc/intel/skylake/skl-messages.c       | 828 +++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-nhlt.c           | 141 +++++
 sound/soc/intel/skylake/skl-nhlt.h           | 116 ++++
 sound/soc/intel/skylake/skl-topology.h       | 276 +++++++++
 sound/soc/intel/skylake/skl-tplg-interface.h |  88 +++
 sound/soc/intel/skylake/skl.h                |  13 +
 7 files changed, 1463 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-messages.c
 create mode 100644 sound/soc/intel/skylake/skl-nhlt.c
 create mode 100644 sound/soc/intel/skylake/skl-nhlt.h
 create mode 100644 sound/soc/intel/skylake/skl-topology.h
 create mode 100644 sound/soc/intel/skylake/skl-tplg-interface.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/6 ASoC: Intel: Skylake: Add NHLT support to get BE config

From: Jeeja KP <[email protected]>

The Non-HD Audio Endpoint Description table contains the link configuration information for the DSP. This is specific to Non HDA links only, like I2s and PDM

Skylake driver will use NHLT table to retrieve the configuration based on the link type, format, channel and rate. This configuration is passed to DSP FW

---
 sound/soc/intel/skylake/Makefile   |   2 +-
 sound/soc/intel/skylake/skl-nhlt.c | 141 +++++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-nhlt.h | 116 ++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl.h      |   7 ++
 4 files changed, 265 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-nhlt.c
 create mode 100644 sound/soc/intel/skylake/skl-nhlt.h
sound/soc/intel/skylake/Makefile +1 -1
index 1fccb378e62c..b35faef05779 100644
@@ -1,4 +1,4 @@
-snd-soc-skl-objs := skl.o skl-pcm.o
+snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o
 
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
 
sound/soc/intel/skylake/skl-nhlt.c new file +141 -0

141 lines not on this page · raw message

sound/soc/intel/skylake/skl-nhlt.h new file +116 -0

116 lines not on this page · raw message

sound/soc/intel/skylake/skl.h +7 -0
index cc0f3e263495..31dafa8a0594 100644
@@ -23,6 +23,7 @@
 
 #include <sound/hda_register.h>
 #include <sound/hdaudio_ext.h>
+#include "skl-nhlt.h"
 
 #define SKL_SUSPEND_DELAY 2000
 
@@ -53,6 +54,8 @@ struct skl {
 
 	unsigned int init_failed:1; /* delayed init failed */
 	struct platform_device *dmic_dev;
+
+	void __iomem *nhlt; /* nhlt ptr */
 };
 
 #define skl_to_ebus(s)	(&(s)->ebus)
@@ -68,4 +71,8 @@ struct skl_dma_params {
 int skl_platform_unregister(struct device *dev);
 int skl_platform_register(struct device *dev);
 
+void __iomem *skl_nhlt_init(struct device *dev);
+void skl_nhlt_free(void __iomem *addr);
+struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
+			u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn);
 #endif /* __SOUND_SOC_SKL_H */
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Applied "ASoC: Intel: Skylake: Add NHLT support to get BE config" to the asoc tree

The patch

ASoC: Intel: Skylake: Add NHLT support to get BE config

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 473eb87adcf69204cd7e8fb5b0e4956edd6feae3 Mon Sep 17 00:00:00 2001

From: Jeeja KP <[email protected]>
Date: Tue, 21 Jul 2015 23:53:55 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Add NHLT support to get BE config

The Non-HD Audio Endpoint Description table contains the link configuration information for the DSP. This is specific to Non HDA links only, like I2s and PDM

Skylake driver will use NHLT table to retrieve the configuration based on the link type, format, channel and rate. This configuration is passed to DSP FW

---
 sound/soc/intel/skylake/Makefile   |   2 +-
 sound/soc/intel/skylake/skl-nhlt.c | 141 +++++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-nhlt.h | 116 ++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl.h      |   7 ++
 4 files changed, 265 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-nhlt.c
 create mode 100644 sound/soc/intel/skylake/skl-nhlt.h
sound/soc/intel/skylake/Makefile +1 -1
index 1fccb378e62c..b35faef05779 100644
@@ -1,4 +1,4 @@
-snd-soc-skl-objs := skl.o skl-pcm.o
+snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o
 
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
 
sound/soc/intel/skylake/skl-nhlt.c new file +141 -0

141 lines not on this page · raw message

sound/soc/intel/skylake/skl-nhlt.h new file +116 -0

116 lines not on this page · raw message

sound/soc/intel/skylake/skl.h +7 -0
index cc0f3e263495..31dafa8a0594 100644
@@ -23,6 +23,7 @@
 
 #include <sound/hda_register.h>
 #include <sound/hdaudio_ext.h>
+#include "skl-nhlt.h"
 
 #define SKL_SUSPEND_DELAY 2000
 
@@ -53,6 +54,8 @@ struct skl {
 
 	unsigned int init_failed:1; /* delayed init failed */
 	struct platform_device *dmic_dev;
+
+	void __iomem *nhlt; /* nhlt ptr */
 };
 
 #define skl_to_ebus(s)	(&(s)->ebus)
@@ -68,4 +71,8 @@ struct skl_dma_params {
 int skl_platform_unregister(struct device *dev);
 int skl_platform_register(struct device *dev);
 
+void __iomem *skl_nhlt_init(struct device *dev);
+void skl_nhlt_free(void __iomem *addr);
+struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
+			u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn);
 #endif /* __SOUND_SOC_SKL_H */
Signature · 1 line
2.1.4
author
#3 lore raw

PATCH 2/6 ASoC: Intel: Skylake: Add dsp and ipc init helpers

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

This helper function will be used by the Skylake driver for dsp and ipc initialization if processing pipe capability is supported.

---
 sound/soc/intel/skylake/Makefile       |   2 +-
 sound/soc/intel/skylake/skl-messages.c | 133 +++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl.h          |   6 ++
 3 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-messages.c
sound/soc/intel/skylake/Makefile +1 -1
index b35faef05779..27db22178204 100644
@@ -1,4 +1,4 @@
-snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o
+snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o
 
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
 
sound/soc/intel/skylake/skl-messages.c new file +133 -0

133 lines not on this page · raw message

sound/soc/intel/skylake/skl.h +6 -0
index 31dafa8a0594..f7fdbb02947f 100644
@@ -56,6 +56,7 @@ struct skl {
 	struct platform_device *dmic_dev;
 
 	void __iomem *nhlt; /* nhlt ptr */
+	struct skl_sst *skl_sst; /* sst skl ctx */
 };
 
 #define skl_to_ebus(s)	(&(s)->ebus)
@@ -75,4 +76,9 @@ void __iomem *skl_nhlt_init(struct device *dev);
 void skl_nhlt_free(void __iomem *addr);
 struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
 			u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn);
+
+int skl_init_dsp(struct skl *skl);
+void skl_free_dsp(struct skl *skl);
+int skl_suspend_dsp(struct skl *skl);
+int skl_resume_dsp(struct skl *skl);
 #endif /* __SOUND_SOC_SKL_H */
Signature · 1 line
1.9.1
maintainer
#4 lore raw

Applied "ASoC: Intel: Skylake: Add dsp and ipc init helpers" to the asoc tree

The patch

ASoC: Intel: Skylake: Add dsp and ipc init helpers

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From d255b09555e8ea0e517a4d3368ec60097ac9cf96 Mon Sep 17 00:00:00 2001

From: Jeeja KP <[email protected]>
Date: Tue, 21 Jul 2015 23:53:56 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Add dsp and ipc init helpers

This helper function will be used by the Skylake driver for dsp and ipc initialization if processing pipe capability is supported.

---
 sound/soc/intel/skylake/Makefile       |   2 +-
 sound/soc/intel/skylake/skl-messages.c | 133 +++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl.h          |   6 ++
 3 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-messages.c
sound/soc/intel/skylake/Makefile +1 -1
index b35faef05779..27db22178204 100644
@@ -1,4 +1,4 @@
-snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o
+snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o
 
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
 
sound/soc/intel/skylake/skl-messages.c new file +133 -0

133 lines not on this page · raw message

sound/soc/intel/skylake/skl.h +6 -0
index 31dafa8a0594..f7fdbb02947f 100644
@@ -56,6 +56,7 @@ struct skl {
 	struct platform_device *dmic_dev;
 
 	void __iomem *nhlt; /* nhlt ptr */
+	struct skl_sst *skl_sst; /* sst skl ctx */
 };
 
 #define skl_to_ebus(s)	(&(s)->ebus)
@@ -75,4 +76,9 @@ void __iomem *skl_nhlt_init(struct device *dev);
 void skl_nhlt_free(void __iomem *addr);
 struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
 			u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn);
+
+int skl_init_dsp(struct skl *skl);
+void skl_free_dsp(struct skl *skl);
+int skl_suspend_dsp(struct skl *skl);
+int skl_resume_dsp(struct skl *skl);
 #endif /* __SOUND_SOC_SKL_H */
Signature · 1 line
2.1.4
author
#5 lore raw

PATCH 3/6 ASoC: Intel: Skylake: Add functions for DSP module configuration

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

This adds helper functions to configure DSP FW modules and to be used when the modules is initialized, or when modules have to be bind/unbind.

---
 sound/soc/intel/skylake/skl-messages.c       | 379 ++++++++++++++++++++++++++-
 sound/soc/intel/skylake/skl-topology.h       | 251 ++++++++++++++++++
 sound/soc/intel/skylake/skl-tplg-interface.h |  88 +++++++
 3 files changed, 714 insertions(+), 4 deletions(-)
 create mode 100644 sound/soc/intel/skylake/skl-topology.h
 create mode 100644 sound/soc/intel/skylake/skl-tplg-interface.h
sound/soc/intel/skylake/skl-messages.c +375 -4
index 7c07b76bf0bf..766729451fe3 100644
@@ -19,13 +19,12 @@
 
 #include <linux/slab.h>
 #include <linux/pci.h>
-#include <sound/core.h>
 #include <sound/pcm.h>
-#include "skl-sst-dsp.h"
-#include "skl-sst-ipc.h"
-#include "skl.h"
 #include "../common/sst-dsp.h"
 #include "../common/sst-dsp-priv.h"
+#include "skl-sst-ipc.h"
+#include "skl-topology.h"
+#include "skl-tplg-interface.h"
 
 static int skl_alloc_dma_buf(struct device *dev,
 		struct snd_dma_buffer *dmab, size_t size)
@@ -131,3 +130,375 @@ int skl_resume_dsp(struct skl *skl)
 
 	return skl_dsp_wake(ctx->dsp);
 }
+
+enum skl_bitdepth skl_get_bit_depth(int params)
+{
+	switch (params) {
+	case 8:
+		return SKL_DEPTH_8BIT;
+
+	case 16:
+		return SKL_DEPTH_16BIT;
+
+	case 24:
+		return SKL_DEPTH_24BIT;
+
+	case 32:
+		return SKL_DEPTH_32BIT;
+
+	default:
+		return SKL_DEPTH_INVALID;
+
+	}
+}
+
+static u32 skl_create_channel_map(enum skl_ch_cfg ch_cfg)
+{
+	u32 config;
+
+	switch (ch_cfg) {
+	case SKL_CH_CFG_MONO:
+		config =  (0xFFFFFFF0 | SKL_CHANNEL_LEFT);
+		break;
+
+	case SKL_CH_CFG_STEREO:
+		config = (0xFFFFFF00 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_RIGHT << 4));
+		break;
+
+	case SKL_CH_CFG_2_1:
+		config = (0xFFFFF000 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_RIGHT << 4)
+			| (SKL_CHANNEL_LFE << 8));
+		break;
+
+	case SKL_CH_CFG_3_0:
+		config =  (0xFFFFF000 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_CENTER << 4)
+			| (SKL_CHANNEL_RIGHT << 8));
+		break;
+
+	case SKL_CH_CFG_3_1:
+		config = (0xFFFF0000 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_CENTER << 4)
+			| (SKL_CHANNEL_RIGHT << 8)
+			| (SKL_CHANNEL_LFE << 12));
+		break;
+
+	case SKL_CH_CFG_QUATRO:
+		config = (0xFFFF0000 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_RIGHT << 4)
+			| (SKL_CHANNEL_LEFT_SURROUND << 8)
+			| (SKL_CHANNEL_RIGHT_SURROUND << 12));
+		break;
+
+	case SKL_CH_CFG_4_0:
+		config = (0xFFFF0000 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_CENTER << 4)
+			| (SKL_CHANNEL_RIGHT << 8)
+			| (SKL_CHANNEL_CENTER_SURROUND << 12));
+		break;
+
+	case SKL_CH_CFG_5_0:
+		config = (0xFFF00000 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_CENTER << 4)
+			| (SKL_CHANNEL_RIGHT << 8)
+			| (SKL_CHANNEL_LEFT_SURROUND << 12)
+			| (SKL_CHANNEL_RIGHT_SURROUND << 16));
+		break;
+
+	case SKL_CH_CFG_5_1:
+		config = (0xFF000000 | SKL_CHANNEL_CENTER
+			| (SKL_CHANNEL_LEFT << 4)
+			| (SKL_CHANNEL_RIGHT << 8)
+			| (SKL_CHANNEL_LEFT_SURROUND << 12)
+			| (SKL_CHANNEL_RIGHT_SURROUND << 16)
+			| (SKL_CHANNEL_LFE << 20));
+		break;
+
+	case SKL_CH_CFG_DUAL_MONO:
+		config = (0xFFFFFF00 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_LEFT << 4));
+		break;
+
+	case SKL_CH_CFG_I2S_DUAL_STEREO_0:
+		config = (0xFFFFFF00 | SKL_CHANNEL_LEFT
+			| (SKL_CHANNEL_RIGHT << 4));
+		break;
+
+	case SKL_CH_CFG_I2S_DUAL_STEREO_1:
+		config = (0xFFFF00FF | (SKL_CHANNEL_LEFT << 8)
+			| (SKL_CHANNEL_RIGHT << 12));
+		break;
+
+	default:
+		config =  0xFFFFFFFF;
+	}
+
+	return config;
+}
+
+/*
+ * Fills in base_cfg structure
+ * base_cfg is sent as input buffer with INIT_INSTANCE IPC msg
+ */
+static void skl_set_base_module_format(struct skl_sst *ctx,
+			struct skl_module_cfg *mconfig,
+			struct skl_base_cfg *base_cfg)
+{
+	struct skl_module_fmt *format = &mconfig->in_fmt;
+
+	base_cfg->audio_fmt.number_of_channels = (u8)format->channels;
+
+	base_cfg->audio_fmt.s_freq = format->s_freq;
+	base_cfg->audio_fmt.bit_depth = format->bit_depth;
+	base_cfg->audio_fmt.valid_bit_depth = format->valid_bit_depth;
+	base_cfg->audio_fmt.ch_cfg = format->ch_cfg;
+
+	dev_dbg(ctx->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n",
+			format->bit_depth, format->valid_bit_depth,
+			format->ch_cfg);
+
+	base_cfg->audio_fmt.channel_map = skl_create_channel_map(
+					base_cfg->audio_fmt.ch_cfg);
+
+	base_cfg->audio_fmt.interleaving = SKL_INTERLEAVING_PER_CHANNEL;
+
+	base_cfg->cps = mconfig->mcps;
+	base_cfg->ibs = mconfig->ibs;
+	base_cfg->obs = mconfig->obs;
+}
+
+/*
+ * Copies copier capabilities into copier module and updates copier module
+ * config size.
+ */
+static void skl_copy_copier_caps(struct skl_module_cfg *mconfig,
+				struct skl_cpr_cfg *cpr_mconfig)
+{
+	if (mconfig->formats_config.caps_size == 0)
+		return;
+
+	memcpy(cpr_mconfig->gtw_cfg.config_data,
+			mconfig->formats_config.caps,
+			mconfig->formats_config.caps_size);
+
+	cpr_mconfig->gtw_cfg.config_length =
+			(mconfig->formats_config.caps_size) / 4;
+}
+
+static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx,
+			struct skl_module_cfg *mconfig,
+			struct skl_cpr_cfg *cpr_mconfig)
+{
+	union skl_connector_node_id node_id = {0};
+	struct skl_pipe_params *params = mconfig->pipe->p_params;
+
+	switch (mconfig->dev_type) {
+	case SKL_DEVICE_BT:
+		node_id.node.dma_type =
+			(SKL_CONN_SOURCE == mconfig->hw_conn_type) ?
+			SKL_DMA_I2S_LINK_OUTPUT_CLASS :
+			SKL_DMA_I2S_LINK_INPUT_CLASS;
+		node_id.node.vindex = params->host_dma_id +
+					(mconfig->vbus_id << 3);
+		break;
+
+	case SKL_DEVICE_I2S:
+		node_id.node.dma_type =
+			(SKL_CONN_SOURCE == mconfig->hw_conn_type) ?
+			SKL_DMA_I2S_LINK_OUTPUT_CLASS :
+			SKL_DMA_I2S_LINK_INPUT_CLASS;
+		node_id.node.vindex = params->host_dma_id +
+					 (mconfig->time_slot << 1) +
+					 (mconfig->vbus_id << 3);
+		break;
+
+	case SKL_DEVICE_DMIC:
+		node_id.node.dma_type = SKL_DMA_DMIC_LINK_INPUT_CLASS;
+		node_id.node.vindex = mconfig->vbus_id +
+					 (mconfig->time_slot);
+		break;
+
+	case SKL_DEVICE_HDALINK:
+		node_id.node.dma_type =
+			(SKL_CONN_SOURCE == mconfig->hw_conn_type) ?
+			SKL_DMA_HDA_LINK_OUTPUT_CLASS :
+			SKL_DMA_HDA_LINK_INPUT_CLASS;
+		node_id.node.vindex = params->link_dma_id;
+		break;
+
+	default:
+		node_id.node.dma_type =
+			(SKL_CONN_SOURCE == mconfig->hw_conn_type) ?
+			SKL_DMA_HDA_HOST_OUTPUT_CLASS :
+			SKL_DMA_HDA_HOST_INPUT_CLASS;
+		node_id.node.vindex = params->host_dma_id;
+		break;
+	}
+
+	cpr_mconfig->gtw_cfg.node_id = node_id.val;
+
+	if (SKL_CONN_SOURCE == mconfig->hw_conn_type)
+		cpr_mconfig->gtw_cfg.dma_buffer_size = 2 * mconfig->obs;
+	else
+		cpr_mconfig->gtw_cfg.dma_buffer_size = 2 * mconfig->ibs;
+
+	cpr_mconfig->cpr_feature_mask = 0;
+	cpr_mconfig->gtw_cfg.config_length  = 0;
+
+	skl_copy_copier_caps(mconfig, cpr_mconfig);
+}
+
+static void skl_setup_out_format(struct skl_sst *ctx,
+			struct skl_module_cfg *mconfig,
+			struct skl_audio_data_format *out_fmt)
+{
+	struct skl_module_fmt *format = &mconfig->out_fmt;
+
+	out_fmt->number_of_channels = (u8)format->channels;
+	out_fmt->s_freq = format->s_freq;
+	out_fmt->bit_depth = format->bit_depth;
+	out_fmt->valid_bit_depth = format->valid_bit_depth;
+	out_fmt->ch_cfg = format->ch_cfg;
+
+	out_fmt->channel_map = skl_create_channel_map(out_fmt->ch_cfg);
+	out_fmt->interleaving = SKL_INTERLEAVING_PER_CHANNEL;
+
+	dev_dbg(ctx->dev, "copier out format chan=%d fre=%d bitdepth=%d\n",
+		out_fmt->number_of_channels, format->s_freq, format->bit_depth);
+}
+
+/*
+ * copier_module_config is sent as input buffer with INIT_INSTANCE IPC msg
+ */
+static void skl_set_copier_format(struct skl_sst *ctx,
+			struct skl_module_cfg *mconfig,
+			struct skl_cpr_cfg *cpr_mconfig)
+{
+	struct skl_audio_data_format *out_fmt = &cpr_mconfig->out_fmt;
+	struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)cpr_mconfig;
+
+	skl_set_base_module_format(ctx, mconfig, base_cfg);
+
+	skl_setup_out_format(ctx, mconfig, out_fmt);
+	skl_setup_cpr_gateway_cfg(ctx, mconfig, cpr_mconfig);
+}
+
+static u16 skl_get_module_param_size(struct skl_sst *ctx,
+			struct skl_module_cfg *mconfig)
+{
+	u16 param_size;
+
+	switch (mconfig->m_type) {
+	case SKL_MODULE_TYPE_COPIER:
+		param_size = sizeof(struct skl_cpr_cfg);
+		param_size += mconfig->formats_config.caps_size;
+		return param_size;
+
+	default:
+		/*
+		 * return only base cfg when no specific module type is
+		 * specified
+		 */
+		return sizeof(struct skl_base_cfg);
+	}
+
+	return 0;
+}
+
+static int skl_set_module_format(struct skl_sst *ctx,
+			struct skl_module_cfg *module_config,
+			u16 *module_config_size,
+			void **param_data)
+{
+	u16 param_size;
+
+	param_size  = skl_get_module_param_size(ctx, module_config);
+
+	*param_data = kzalloc(param_size, GFP_KERNEL);
+	if (NULL == *param_data)
+		return -ENOMEM;
+
+	*module_config_size = param_size;
+
+	switch (module_config->m_type) {
+	case SKL_MODULE_TYPE_COPIER:
+		skl_set_copier_format(ctx, module_config, *param_data);
+		break;
+
+	default:
+		skl_set_base_module_format(ctx, module_config, *param_data);
+	}
+
+	dev_dbg(ctx->dev, "Module type=%d config size: %d bytes\n",
+			module_config->id.module_id, param_size);
+	print_hex_dump_bytes("Module params :\n", DUMP_PREFIX_OFFSET,
+			param_data, param_size);
+	return 0;
+}
+
+static struct skl_module_pin skl_get_queue(struct skl_module_pin *mpin,
+				struct skl_module_inst_id id, int max)
+{
+	int i;
+	struct skl_module_pin m_pin;
+
+	m_pin.pin_index = -EINVAL;
+
+	/*
+	 * if pin in dynamic, find first free pin
+	 * otherwise find match module and instance id pin
+	 */
+	for (i = 0; i < max; i++)  {
+		if (mpin[i].is_dynamic) {
+			if (!mpin[i].in_use)
+				return mpin[i];
+		} else {
+			if (mpin[i].id.module_id == id.module_id &&
+				mpin[i].id.instance_id == id.instance_id)
+				return mpin[i];
+		}
+	}
+
+	return m_pin;
+}
+
+/*
+ * Allocates queue for each module.
+ * if dynamic, the pin_index is allocated 0 to max_pin.
+ * In static, the pin_index is fixed based on module_id and instance id
+ */
+static int skl_alloc_queue(struct skl_module_pin *mpin,
+			struct skl_module_inst_id id, int max)
+{
+	struct skl_module_pin m_pin = skl_get_queue(mpin, id, max);
+
+	if (m_pin.pin_index < 0)
+		return -EINVAL;
+
+	if (m_pin.is_dynamic) {
+			m_pin.in_use = true;
+			m_pin.id.module_id = id.module_id;
+			m_pin.id.instance_id = id.instance_id;
+	}
+
+	return m_pin.pin_index;
+}
+
+static int skl_free_queue(struct skl_module_pin *mpin,
+			struct skl_module_inst_id id, int max)
+{
+	struct skl_module_pin m_pin = skl_get_queue(mpin, id, max);
+
+	if (m_pin.pin_index < 0)
+		return -EINVAL;
+
+	if (m_pin.is_dynamic) {
+		m_pin.in_use = false;
+		m_pin.id.module_id = 0;
+		m_pin.id.instance_id = 0;
+	}
+
+	return m_pin.pin_index;
+}
sound/soc/intel/skylake/skl-topology.h new file +251 -0

251 lines not on this page · raw message

sound/soc/intel/skylake/skl-tplg-interface.h new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#6 lore raw

Re: [PATCH 3/6] ASoC: Intel: Skylake: Add functions for DSP module configuration

sound/soc/intel/skylake/skl-messages.c int skl_resume_dsp(struct skl *skl) · line 236

Quoted 8 lines · Vinod Koul
sound/soc/intel/skylake/skl-messages.c +8 -0
+	case SKL_CH_CFG_I2S_DUAL_STEREO_1:
+		config = (0xFFFF00FF | (SKL_CHANNEL_LEFT << 8)
+			| (SKL_CHANNEL_RIGHT << 12));
+		break;
+
+	default:
+		config =  0xFFFFFFFF;
+	}

Missing break.

Quoted 8 lines
sound/soc/intel/skylake/skl-messages.c +8 -0
+/*
+ * Allocates queue for each module.
+ * if dynamic, the pin_index is allocated 0 to max_pin.
+ * In static, the pin_index is fixed based on module_id and instance id
+ */
+static int skl_alloc_queue(struct skl_module_pin *mpin,
+			struct skl_module_inst_id id, int max)
+{

sound/soc/intel/skylake/skl-messages.c int skl_resume_dsp(struct skl *skl) · line 484

Quoted 10 lines
sound/soc/intel/skylake/skl-messages.c +10 -0
+	struct skl_module_pin m_pin = skl_get_queue(mpin, id, max);
+
+	if (m_pin.pin_index < 0)
+		return -EINVAL;
+
+	if (m_pin.is_dynamic) {
+			m_pin.in_use = true;
+			m_pin.id.module_id = id.module_id;
+			m_pin.id.instance_id = id.instance_id;
+	}

Double indentation here. It's really unclear to me why a static pin doesn't need to get merked as in use?

author
#7 lore raw

Re: [PATCH 3/6] ASoC: Intel: Skylake: Add functions for DSP module configuration

Quoted 12 lines · Mark Brown

sound/soc/intel/skylake/skl-messages.c int skl_resume_dsp(struct skl *skl) · line 236

Quoted 8 lines · Vinod Koul
sound/soc/intel/skylake/skl-messages.c +8 -0
+	case SKL_CH_CFG_I2S_DUAL_STEREO_1:
+		config = (0xFFFF00FF | (SKL_CHANNEL_LEFT << 8)
+			| (SKL_CHANNEL_RIGHT << 12));
+		break;
+
+	default:
+		config =  0xFFFFFFFF;
+	}

Missing break.

Should default have one always :)

Quoted 14 lines
Quoted 14 lines
sound/soc/intel/skylake/skl-messages.c +13 -0
+/*
+ * Allocates queue for each module.
+ * if dynamic, the pin_index is allocated 0 to max_pin.
+ * In static, the pin_index is fixed based on module_id and instance id
+ */
+static int skl_alloc_queue(struct skl_module_pin *mpin,
+			struct skl_module_inst_id id, int max)
+{
+	struct skl_module_pin m_pin = skl_get_queue(mpin, id, max);
+
+	if (m_pin.pin_index < 0)
+		return -EINVAL;
+
Quoted 8 lines

sound/soc/intel/skylake/skl-messages.c int skl_resume_dsp(struct skl *skl) · line 484

Quoted 5 lines
sound/soc/intel/skylake/skl-messages.c +5 -0
+	if (m_pin.is_dynamic) {
+			m_pin.in_use = true;
+			m_pin.id.module_id = id.module_id;
+			m_pin.id.instance_id = id.instance_id;
+	}

Double indentation here. It's really unclear to me why a static pin doesn't need to get merked as in use?

Oops, will fix

In static pin case, the pins come from topology binary where these are fixed for a configuration, so don't need to be allocated thus marked and hence freed.

Signature · 2 lines
~Vinod
-- 
maintainer
#8 lore raw

Re: [PATCH 3/6] ASoC: Intel: Skylake: Add functions for DSP module configuration

Quoted 19 lines · Vinod Koul
Quoted 8 lines · Mark Brown
Quoted 8 lines
sound/soc/intel/skylake/skl-messages.c +8 -0
+static int skl_alloc_queue(struct skl_module_pin *mpin,
+			struct skl_module_inst_id id, int max)
+{
+	struct skl_module_pin m_pin = skl_get_queue(mpin, id, max);
+
+	if (m_pin.pin_index < 0)
+		return -EINVAL;
+
Quoted 8 lines

sound/soc/intel/skylake/skl-messages.c int skl_resume_dsp(struct skl *skl) · line 484

Quoted 5 lines
sound/soc/intel/skylake/skl-messages.c +5 -0
+	if (m_pin.is_dynamic) {
+			m_pin.in_use = true;
+			m_pin.id.module_id = id.module_id;
+			m_pin.id.instance_id = id.instance_id;
+	}

Double indentation here. It's really unclear to me why a static pin doesn't need to get merked as in use?

Quoted 5 lines

Oops, will fix

In static pin case, the pins come from topology binary where these are fixed for a configuration, so don't need to be allocated thus marked and hence freed.

But isn't this also protecting against attempts to use the resource multiple times within the configuration (or shouldn't we be doing that)?

Please bear in mind that this stuff has basically zero documentation or explanation so I'm kind of guessing as to what this is supposed to do.

author
#9 lore raw

Re: [PATCH 3/6] ASoC: Intel: Skylake: Add functions for DSP module configuration

Quoted 20 lines · Mark Brown
Quoted 18 lines · Vinod Koul
Quoted 16 lines · Mark Brown

sound/soc/intel/skylake/skl-messages.c int skl_resume_dsp(struct skl *skl) · line 484

Quoted 13 lines
sound/soc/intel/skylake/skl-messages.c +13 -0
+static int skl_alloc_queue(struct skl_module_pin *mpin,
+			struct skl_module_inst_id id, int max)
+{
+	struct skl_module_pin m_pin = skl_get_queue(mpin, id, max);
+
+	if (m_pin.pin_index < 0)
+		return -EINVAL;
+
+	if (m_pin.is_dynamic) {
+			m_pin.in_use = true;
+			m_pin.id.module_id = id.module_id;
+			m_pin.id.instance_id = id.instance_id;
+	}

Double indentation here. It's really unclear to me why a static pin doesn't need to get merked as in use?

Quoted 8 lines
Quoted 5 lines

Oops, will fix

In static pin case, the pins come from topology binary where these are fixed for a configuration, so don't need to be allocated thus marked and hence freed.

But isn't this also protecting against attempts to use the resource multiple times within the configuration (or shouldn't we be doing that)?

In case of static since a module pin is allocated while designing topology we shouldn't have clash as per design of topology

For example I have a Gain module connected to Mixer. Gain module pin 0 will be allocated to connect to Mixer Pin0. I wont assign Pin0 to any other module if I am doing static mapping.

Whereas in dynamic we will check for first free pin and allocate.

If all the pins has same meaning then dynamic would make sense, but non linear modules need reference signals so they have special pins so we need both approaches here

Quoted 2 lines

Please bear in mind that this stuff has basically zero documentation or explanation so I'm kind of guessing as to what this is supposed to do.

I did try to add explanation where I felt was missing, but yes this is good feedback, I will add more bits in next rev. Also please do point out where you feel we missed.

Thanks

Signature · 1 line
~Vinod
maintainer
#10 lore raw

Re: [PATCH 3/6] ASoC: Intel: Skylake: Add functions for DSP module configuration

Quoted 12 lines · Vinod Koul
Quoted 2 lines · Mark Brown

But isn't this also protecting against attempts to use the resource multiple times within the configuration (or shouldn't we be doing that)?

In case of static since a module pin is allocated while designing topology we shouldn't have clash as per design of topology

For example I have a Gain module connected to Mixer. Gain module pin 0 will be allocated to connect to Mixer Pin0. I wont assign Pin0 to any other module if I am doing static mapping.

Quoted 5 lines

Whereas in dynamic we will check for first free pin and allocate.

If all the pins has same meaning then dynamic would make sense, but non linear modules need reference signals so they have special pins so we need both approaches here

I'm not sure where I see the thing in here that controls the routing? I thought this might be something to do with it.

Quoted 6 lines
Quoted 2 lines

Please bear in mind that this stuff has basically zero documentation or explanation so I'm kind of guessing as to what this is supposed to do.

I did try to add explanation where I felt was missing, but yes this is good feedback, I will add more bits in next rev. Also please do point out where you feel we missed.

So, the summary for the series was:

| This series adds NHLT table support in the driver. This also adds support | for dsp init, modules configuration and messaging support

and the description for this patch was:

| This adds helper functions to configure DSP FW modules and to be used when | the modules is initialized, or when modules have to be bind/unbind.

so there's a *little* room for more detail. I don't have any kind of big picture of what the firmware does, what it needs from the kernel, how this fits in with the bigger picture of the driver or anything. Some more of that where this is going direction stuff would be helpful, right now I'm not 100% sure where this is going or anything.

author
#11 lore raw

Re: [PATCH 3/6] ASoC: Intel: Skylake: Add functions for DSP module configuration

Quoted 36 lines · Mark Brown
Quoted 12 lines · Vinod Koul
Quoted 2 lines · Mark Brown

But isn't this also protecting against attempts to use the resource multiple times within the configuration (or shouldn't we be doing that)?

In case of static since a module pin is allocated while designing topology we shouldn't have clash as per design of topology

For example I have a Gain module connected to Mixer. Gain module pin 0 will be allocated to connect to Mixer Pin0. I wont assign Pin0 to any other module if I am doing static mapping.

Quoted 5 lines

Whereas in dynamic we will check for first free pin and allocate.

If all the pins has same meaning then dynamic would make sense, but non linear modules need reference signals so they have special pins so we need both approaches here

I'm not sure where I see the thing in here that controls the routing? I thought this might be something to do with it.

Quoted 6 lines
Quoted 2 lines

Please bear in mind that this stuff has basically zero documentation or explanation so I'm kind of guessing as to what this is supposed to do.

I did try to add explanation where I felt was missing, but yes this is good feedback, I will add more bits in next rev. Also please do point out where you feel we missed.

So, the summary for the series was:

| This series adds NHLT table support in the driver. This also adds support | for dsp init, modules configuration and messaging support

and the description for this patch was:

Quoted 8 lines

| This adds helper functions to configure DSP FW modules and to be used when | the modules is initialized, or when modules have to be bind/unbind.

so there's a *little* room for more detail. I don't have any kind of big picture of what the firmware does, what it needs from the kernel, how this fits in with the bigger picture of the driver or anything. Some more of that where this is going direction stuff would be helpful, right now I'm not 100% sure where this is going or anything.

Fair enough.

I am adding more text and comments in the updated patchset to explain. That should help :)

On your questions above, one thing I would like to point that typically we have alsa controls and dapm widgets to model the DSP, but now with topology core, we have moved these into the usermode.
In driver we have handlers for the topology events, so yes it becomes little difficult to visualize but we can do better by adding comments. This series is mostly helper code for getting topology created in DSP and next (last series in current SKL driver work) series will add topology handlers which will use these helpers, so the big picture will be clear easily and complete flow can be visualized when these helpers are invoked.

Signature · 1 line
~Vinod
maintainer
#12 lore raw

Re: [PATCH 3/6] ASoC: Intel: Skylake: Add functions for DSP module configuration

Quoted 5 lines · Vinod Koul
Quoted 4 lines · Mark Brown

On Thu, Jul 30, 2015 at 08:45:07AM +0530, Vinod Koul wrote:

| This series adds NHLT table support in the driver. This also adds support | for dsp init, modules configuration and messaging support

One issue I should probably highlight is - what is a NHLT table and has is it documented (I guess it is part of some part of some ACPI spec given my understanding of the rules on publication of ACPI bindings).

Quoted 3 lines

On your questions above, one thing I would like to point that typically we have alsa controls and dapm widgets to model the DSP, but now with topology core, we have moved these into the usermode.

I'm not sure how that's relevant?

Quoted 6 lines

In driver we have handlers for the topology events, so yes it becomes little difficult to visualize but we can do better by adding comments. This series is mostly helper code for getting topology created in DSP and next (last series in current SKL driver work) series will add topology handlers which will use these helpers, so the big picture will be clear easily and complete flow can be visualized when these helpers are invoked.

Right, but you're sending all this stuff piecemeal with no advance explanation of where we're going. This is a recurring problem here - there's lots of Intel specific abstraction layers which aren't terribly clear and some of which seem to turn out to be redundant on review.

author
#13 lore raw

Re: [PATCH 3/6] ASoC: Intel: Skylake: Add functions for DSP module configuration

Quoted 10 lines · Mark Brown
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Mark Brown

On Thu, Jul 30, 2015 at 08:45:07AM +0530, Vinod Koul wrote:

| This series adds NHLT table support in the driver. This also adds support | for dsp init, modules configuration and messaging support

One issue I should probably highlight is - what is a NHLT table and has is it documented (I guess it is part of some part of some ACPI spec given my understanding of the rules on publication of ACPI bindings).

So by default, SKL BIOS has a new ACPI Table called NHLT, Non HDA-Link Table. This table contains the settings the driver has to pick up for the non HDA links (SSP, PDM) and send them to firmware for applying.

The firmware expects it in the same format as stored in the BIOS so we just query the 'endpoint' blob and send it to FW when that BE is enabled from DPCM. These contain the hardware register settings that are required for that 'board' and also the DMA gateway settings. All these are taken up by FW and applied for that link. We are reusing infrastructure made for other OSes here and will help us when someone installs Linux on SKL devices we always get the link settings which have been already tested.

Quoted 13 lines
Quoted 3 lines

On your questions above, one thing I would like to point that typically we have alsa controls and dapm widgets to model the DSP, but now with topology core, we have moved these into the usermode.

I'm not sure how that's relevant?

Quoted 6 lines

In driver we have handlers for the topology events, so yes it becomes little difficult to visualize but we can do better by adding comments. This series is mostly helper code for getting topology created in DSP and next (last series in current SKL driver work) series will add topology handlers which will use these helpers, so the big picture will be clear easily and complete flow can be visualized when these helpers are invoked.

Quoted 4 lines

Right, but you're sending all this stuff piecemeal with no advance explanation of where we're going. This is a recurring problem here - there's lots of Intel specific abstraction layers which aren't terribly clear and some of which seem to turn out to be redundant on review.

The piecemeal approach was required to manage and split the traffic. This series adds the handlers on how send bind and unbind messages, pin management routines, how driver compute PCM params when we have a 'converter widget' like SRC, channel converter etc
Next series will add the topology handler which will use these. Okay need to create a pipeline so call module init, bind, calculate pcm params, apply them etc
I will try my best to add more clarity to updated patchset (holding that up and rereading to see if I can add more comments to help) and pls do ask where you feel where stuff is ambiguous

Signature · 1 line
~Vinod
author
#14 lore raw

PATCH 4/6 ASoC: Intel: Skylake: Add helpers for SRC and converter modules

In reply to Vinod Koul

From: Hardik T Shah <[email protected]>

SRC and converter modules module configuration helpers and format calculation for these modules and added here

---
 sound/soc/intel/skylake/skl-messages.c | 45 ++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-topology.h | 16 ++++++++++++
 2 files changed, 61 insertions(+)
sound/soc/intel/skylake/skl-messages.c +45 -0
index 766729451fe3..faa0e71d4ae5 100644
@@ -369,6 +369,37 @@ static void skl_setup_out_format(struct skl_sst *ctx,
 		out_fmt->number_of_channels, format->s_freq, format->bit_depth);
 }
 
+static void skl_set_src_format(struct skl_sst *ctx,
+			struct skl_module_cfg *mconfig,
+			struct skl_src_module_cfg *src_mconfig)
+{
+	struct skl_module_fmt *fmt = &mconfig->out_fmt;
+
+	skl_set_base_module_format(ctx, mconfig,
+		(struct skl_base_cfg *)src_mconfig);
+
+	src_mconfig->src_cfg = fmt->s_freq;
+}
+
+static void skl_set_updown_mixer_format(struct skl_sst *ctx,
+			struct skl_module_cfg *mconfig,
+			struct skl_up_down_mixer_cfg *mixer_mconfig)
+{
+	struct skl_module_fmt *fmt = &mconfig->out_fmt;
+	int i = 0;
+
+	skl_set_base_module_format(ctx,	mconfig,
+		(struct skl_base_cfg *)mixer_mconfig);
+	mixer_mconfig->out_ch_cfg = fmt->ch_cfg;
+
+	/* Select F/W default coefficient */
+	mixer_mconfig->coeff_sel = 0x0;
+
+	/* User coeff, don't care since we are selecting F/W defaults */
+	for (i = 0; i < UP_DOWN_MIXER_MAX_COEFF; i++)
+		mixer_mconfig->coeff[i] = 0xDEADBEEF;
+}
+
 /*
  * copier_module_config is sent as input buffer with INIT_INSTANCE IPC msg
  */
@@ -396,6 +427,12 @@ static u16 skl_get_module_param_size(struct skl_sst *ctx,
 		param_size += mconfig->formats_config.caps_size;
 		return param_size;
 
+	case SKL_MODULE_TYPE_SRCINT:
+		return sizeof(struct skl_src_module_cfg);
+
+	case SKL_MODULE_TYPE_UPDWMIX:
+		return sizeof(struct skl_up_down_mixer_cfg);
+
 	default:
 		/*
 		 * return only base cfg when no specific module type is
@@ -427,6 +464,14 @@ static int skl_set_module_format(struct skl_sst *ctx,
 		skl_set_copier_format(ctx, module_config, *param_data);
 		break;
 
+	case SKL_MODULE_TYPE_SRCINT:
+		skl_set_src_format(ctx, module_config, *param_data);
+		break;
+
+	case SKL_MODULE_TYPE_UPDWMIX:
+		skl_set_updown_mixer_format(ctx, module_config, *param_data);
+		break;
+
 	default:
 		skl_set_base_module_format(ctx, module_config, *param_data);
 	}
sound/soc/intel/skylake/skl-topology.h +16 -0
index 6ba137a43e68..e4b2a339b2f4 100644
@@ -123,6 +123,21 @@ struct skl_cpr_cfg {
 	struct skl_cpr_gtw_cfg gtw_cfg;
 } __packed;
 
+
+struct skl_src_module_cfg {
+	struct skl_base_cfg base_cfg;
+	enum skl_s_freq src_cfg;
+} __packed;
+
+struct skl_up_down_mixer_cfg {
+	struct skl_base_cfg base_cfg;
+	enum skl_ch_cfg out_ch_cfg;
+	/* This should be set to 1 if user coefficients are required */
+	u32 coeff_sel;
+	/* Pass the user coeff in this array */
+	s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
+} __packed;
+
 enum skl_dma_type {
 	SKL_DMA_HDA_HOST_OUTPUT_CLASS = 0,
 	SKL_DMA_HDA_HOST_INPUT_CLASS = 1,
@@ -247,5 +262,6 @@ struct skl_module_cfg {
 	struct skl_pipe *pipe;
 	struct skl_specific_cfg formats_config;
 };
+
 enum skl_bitdepth skl_get_bit_depth(int params);
 #endif
Signature · 1 line
1.9.1
author
#15 lore raw

PATCH 5/6 ASoC: Intel: Skylake: Add DSP module init and binding routines

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

The modules init and binding helper function creates module init and bind IPC message based on module parameter and calls IPC interface to send the IPC to DSP FW.

---
 sound/soc/intel/skylake/skl-messages.c | 165 +++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-topology.h |   4 +
 2 files changed, 169 insertions(+)
sound/soc/intel/skylake/skl-messages.c +165 -0
index faa0e71d4ae5..72af582183ae 100644
@@ -547,3 +547,168 @@ static int skl_free_queue(struct skl_module_pin *mpin,
 
 	return m_pin.pin_index;
 }
+
+int skl_init_module(struct skl_sst *ctx,
+			struct skl_module_cfg *mconfig, char *param)
+{
+	u16 module_config_size = 0;
+	void *param_data = NULL;
+	int ret;
+	struct skl_ipc_init_instance_msg msg;
+
+	dev_dbg(ctx->dev, "%s: module_id = %d instance=%d\n", __func__,
+		 mconfig->id.module_id, mconfig->id.instance_id);
+
+	if (mconfig->pipe->state != SKL_PIPE_CREATED) {
+		dev_err(ctx->dev, "Pipe not created state= %d pipe_id= %d\n",
+				 mconfig->pipe->state, mconfig->pipe->ppl_id);
+		return -EIO;
+	}
+
+	ret = skl_set_module_format(ctx, mconfig,
+			&module_config_size, &param_data);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to set module format ret=%d\n", ret);
+		return ret;
+	}
+
+	msg.module_id = mconfig->id.module_id;
+	msg.instance_id = mconfig->id.instance_id;
+	msg.ppl_instance_id = mconfig->pipe->ppl_id;
+	msg.param_data_size = module_config_size;
+	msg.core_id = mconfig->core_id;
+
+	ret = skl_ipc_init_instance(&ctx->ipc, &msg, param_data);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to init instance ret=%d\n", ret);
+		kfree(param_data);
+		return ret;
+	}
+	mconfig->m_state = SKL_MODULE_INIT_DONE;
+
+	return ret;
+}
+
+static int skl_unbind_modules(struct skl_sst *ctx,
+			struct skl_module_cfg *src_mcfg,
+			struct skl_module_cfg *dst_mcfg)
+{
+	int ret;
+	struct skl_ipc_bind_unbind_msg msg;
+	struct skl_module_inst_id src_id = src_mcfg->id;
+	struct skl_module_inst_id dst_id = dst_mcfg->id;
+	int in_max = dst_mcfg->max_in_queue;
+	int out_max = src_mcfg->max_out_queue;
+	struct skl_module_pin m_pin;
+
+	if (src_mcfg->m_state != SKL_MODULE_BIND_DONE)
+		return 0;
+
+	/*
+	 * if intra module unbind, check if both modules are BIND,
+	 * then send unbind
+	 */
+	if ((src_mcfg->pipe->ppl_id != dst_mcfg->pipe->ppl_id) &&
+				dst_mcfg->m_state != SKL_MODULE_BIND_DONE)
+		return 0;
+	else if (src_mcfg->m_state < SKL_MODULE_INIT_DONE &&
+				 dst_mcfg->m_state < SKL_MODULE_INIT_DONE)
+		return 0;
+
+	/* get src pin index */
+	m_pin = skl_get_queue(src_mcfg->m_out_pin, src_id, out_max);
+	if (m_pin.pin_index < 0)
+		return -EINVAL;
+
+	msg.src_queue = m_pin.pin_index;
+
+	/* get dst pin index */
+	m_pin  = skl_get_queue(dst_mcfg->m_in_pin, dst_id, in_max);
+	if (m_pin.pin_index < 0) {
+		skl_free_queue(src_mcfg->m_out_pin, src_id, out_max);
+		return -EINVAL;
+	}
+
+	msg.dst_queue = m_pin.pin_index;
+
+	msg.module_id = src_mcfg->id.module_id;
+	msg.instance_id = src_mcfg->id.instance_id;
+	msg.dst_module_id = dst_mcfg->id.module_id;
+	msg.dst_instance_id = dst_mcfg->id.instance_id;
+	msg.bind = false;
+
+	ret = skl_ipc_bind_unbind(&ctx->ipc, &msg);
+	if (!ret)
+		src_mcfg->m_state = SKL_MODULE_UNINIT;
+
+	skl_free_queue(src_mcfg->m_out_pin, src_id, out_max);
+	skl_free_queue(dst_mcfg->m_in_pin, dst_id, in_max);
+
+	return ret;
+}
+
+static int skl_bind_modules(struct skl_sst *ctx,
+			struct skl_module_cfg *src_mcfg,
+			struct skl_module_cfg *dst_mcfg)
+{
+	int pin_index, ret;
+	struct skl_ipc_bind_unbind_msg msg;
+	struct skl_module_inst_id src_id = src_mcfg->id;
+	struct skl_module_inst_id dst_id = dst_mcfg->id;
+	int in_max = dst_mcfg->max_in_queue;
+	int out_max = src_mcfg->max_out_queue;
+
+	if (src_mcfg->m_state < SKL_MODULE_INIT_DONE &&
+		dst_mcfg->m_state < SKL_MODULE_INIT_DONE)
+		return 0;
+
+	pin_index = skl_alloc_queue(src_mcfg->m_out_pin, src_id, out_max);
+	if (pin_index < 0)
+		return -EINVAL;
+
+	msg.src_queue = pin_index;
+	pin_index = skl_alloc_queue(dst_mcfg->m_in_pin, dst_id, in_max);
+	if (pin_index < 0) {
+		skl_free_queue(src_mcfg->m_out_pin, src_id, out_max);
+		return -EINVAL;
+	}
+
+	msg.dst_queue = pin_index;
+	dev_dbg(ctx->dev, "src queue = %d dst queue =%d\n",
+			 msg.src_queue, msg.dst_queue);
+
+	msg.module_id = src_mcfg->id.module_id;
+	msg.instance_id = src_mcfg->id.instance_id;
+	msg.dst_module_id = dst_mcfg->id.module_id;
+	msg.dst_instance_id = dst_mcfg->id.instance_id;
+	msg.bind = true;
+
+	ret = skl_ipc_bind_unbind(&ctx->ipc, &msg);
+
+	if (!ret) {
+		src_mcfg->m_state = SKL_MODULE_BIND_DONE;
+	} else {
+		/* error case , if IPC fails, clear the queue index */
+		skl_free_queue(src_mcfg->m_out_pin, src_id, out_max);
+		skl_free_queue(dst_mcfg->m_in_pin, dst_id, in_max);
+	}
+
+	return ret;
+}
+
+int skl_bind_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
+	*src_module, struct skl_module_cfg *dst_module, bool bind)
+{
+	dev_dbg(ctx->dev, "%s: src module_id = %d  src_instance=%d\n",
+		__func__, src_module->id.module_id, src_module->id.instance_id);
+	dev_dbg(ctx->dev, "%s: dst_module=%d dst_instacne=%d\n", __func__,
+		 dst_module->id.module_id, dst_module->id.instance_id);
+
+	dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n",
+		src_module->m_state, dst_module->m_state);
+
+	if (bind)
+		return skl_bind_modules(ctx, src_module, dst_module);
+	else
+		return skl_unbind_modules(ctx, src_module, dst_module);
+}
sound/soc/intel/skylake/skl-topology.h +4 -0
index e4b2a339b2f4..c944ec024e62 100644
@@ -263,5 +263,9 @@ struct skl_module_cfg {
 	struct skl_specific_cfg formats_config;
 };
 
+int skl_init_module(struct skl_sst *ctx, struct skl_module_cfg *module_config,
+	char *param);
+int skl_bind_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
+	*src_module, struct skl_module_cfg *dst_module, bool bind);
 enum skl_bitdepth skl_get_bit_depth(int params);
 #endif
Signature · 1 line
1.9.1
maintainer
#16 lore raw

Re: [PATCH 5/6] ASoC: Intel: Skylake: Add DSP module init and binding routines

Quoted 6 lines · Vinod Koul
sound/soc/intel/skylake/skl-messages.c +6 -0
+int skl_bind_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
+	*src_module, struct skl_module_cfg *dst_module, bool bind)
+{
+	dev_dbg(ctx->dev, "%s: src module_id = %d  src_instance=%d\n",
+		__func__, src_module->id.module_id, src_module->id.instance_id);
+	dev_dbg(ctx->dev, "%s: dst_module=%d dst_instacne=%d\n", __func__,

sound/soc/intel/skylake/skl-messages.c static int skl_free_queue(struct skl_module_pin *mpin, · line 714

Quoted 10 lines
sound/soc/intel/skylake/skl-messages.c +10 -0
+		 dst_module->id.module_id, dst_module->id.instance_id);
+
+	dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n",
+		src_module->m_state, dst_module->m_state);
+
+	if (bind)
+		return skl_bind_modules(ctx, src_module, dst_module);
+	else
+		return skl_unbind_modules(ctx, src_module, dst_module);
+}

I'm not sure I understand the purpose of this function - why not just use the bind and unbind functions directly if they share nothing?

author
#17 lore raw

Re: [PATCH 5/6] ASoC: Intel: Skylake: Add DSP module init and binding routines

Quoted 13 lines · Mark Brown
Quoted 11 lines · Vinod Koul
sound/soc/intel/skylake/skl-messages.c +11 -0
+int skl_bind_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
+	*src_module, struct skl_module_cfg *dst_module, bool bind)
+{
+	dev_dbg(ctx->dev, "%s: src module_id = %d  src_instance=%d\n",
+		__func__, src_module->id.module_id, src_module->id.instance_id);
+	dev_dbg(ctx->dev, "%s: dst_module=%d dst_instacne=%d\n", __func__,
+		 dst_module->id.module_id, dst_module->id.instance_id);
+
+	dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n",
+		src_module->m_state, dst_module->m_state);
+
Quoted 8 lines

sound/soc/intel/skylake/skl-messages.c static int skl_free_queue(struct skl_module_pin *mpin, · line 714

Quoted 5 lines
sound/soc/intel/skylake/skl-messages.c +5 -0
+	if (bind)
+		return skl_bind_modules(ctx, src_module, dst_module);
+	else
+		return skl_unbind_modules(ctx, src_module, dst_module);
+}

I'm not sure I understand the purpose of this function - why not just use the bind and unbind functions directly if they share nothing?

Yes that can be done, this allows us to have common dump and invoking skl_bind_unbind_modules() with argument rather than calling two APIs.

But yes I did look at the usage and can be removed

Thanks

Signature · 1 line
~Vinod
author
#18 lore raw

PATCH 6/6 ASoC: Intel: Skylake: Add pipe management helpers

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

To manage the DSP pipelines we need routines to create, delete and message creation helpers. These helpers also check status and creates IPC messages with the required parameter and send using IPC lib interface.

---
 sound/soc/intel/skylake/skl-messages.c | 114 +++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-topology.h |   5 ++
 2 files changed, 119 insertions(+)
sound/soc/intel/skylake/skl-messages.c +114 -0
index 72af582183ae..002297249c11 100644
@@ -712,3 +712,117 @@ int skl_bind_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
 	else
 		return skl_unbind_modules(ctx, src_module, dst_module);
 }
+
+static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe,
+	enum skl_pipe_state state)
+{
+	dev_dbg(ctx->dev, "%s: pipe_satate = %d\n", __func__, state);
+
+	return skl_ipc_set_pipeline_state(&ctx->ipc, pipe->ppl_id, state);
+}
+
+/*
+ * Creates pipeline, by sending IPC messages to FW
+ */
+int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe)
+{
+	int ret;
+
+	dev_dbg(ctx->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id);
+
+	ret = skl_ipc_create_pipeline(&ctx->ipc, pipe->memory_pages,
+				pipe->pipe_priority, pipe->ppl_id);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to create pipeline\n");
+		return ret;
+	}
+
+	pipe->state = SKL_PIPE_CREATED;
+
+	return 0;
+}
+
+/*
+ * Sets pipe state to RUNNING
+ */
+int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
+{
+	int ret;
+
+	dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
+
+	/* If pipe was not created in FW, do not try to pause or delete */
+	if (pipe->state < SKL_PIPE_CREATED)
+		return 0;
+
+	/* Pipe has to be paused before it is started */
+	ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to pause pipe\n");
+		return ret;
+	}
+
+	pipe->state = SKL_PIPE_PAUSED;
+
+	ret = skl_set_pipe_state(ctx, pipe, PPL_RUNNING);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to start pipe\n");
+		return ret;
+	}
+
+	pipe->state = SKL_PIPE_STARTED;
+
+	return 0;
+}
+
+/*
+ * Sets pipe state to PAUSED in FW, stops DMA engines and releases resources
+ */
+int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
+{
+	int ret;
+
+	dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
+
+	/* If pipe is not started, do not try to stop the pipe in FW. */
+	if (pipe->state > SKL_PIPE_STARTED) {
+		ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED);
+		if (ret < 0) {
+			dev_err(ctx->dev, "Failed to stop pipeline\n");
+			return ret;
+		}
+
+		pipe->state = SKL_PIPE_PAUSED;
+	} else {
+		/* If pipe was not created in FW, do not try to delete it */
+		if (pipe->state < SKL_PIPE_CREATED)
+			return 0;
+
+		ret = skl_ipc_delete_pipeline(&ctx->ipc, pipe->ppl_id);
+		if (ret < 0)
+			dev_err(ctx->dev, "Failed to delete pipeline\n");
+	}
+
+	return ret;
+}
+
+int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
+{
+	int ret;
+
+	dev_dbg(ctx->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id);
+
+	/* If pipe was not created in FW, do not try to pause or delete */
+	if (pipe->state < SKL_PIPE_PAUSED)
+		return 0;
+
+	ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED);
+	if (ret < 0) {
+		dev_dbg(ctx->dev, "Failed to stop pipe\n");
+		return ret;
+	}
+
+	pipe->state = SKL_PIPE_CREATED;
+
+	return 0;
+}
sound/soc/intel/skylake/skl-topology.h +5 -0
index c944ec024e62..f5584d189ef0 100644
@@ -263,6 +263,11 @@ struct skl_module_cfg {
 	struct skl_specific_cfg formats_config;
 };
 
+int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe);
+int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
+int skl_pause_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
+int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
+int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
 int skl_init_module(struct skl_sst *ctx, struct skl_module_cfg *module_config,
 	char *param);
 int skl_bind_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
Signature · 1 line
1.9.1