Skip to contentSkip to conversation

ASoC: SOF: Intel: Soundwire integration

PATCH In review Pierre-Louis Bossart 2 participants 8 messages Oct 23, 2019 – Nov 6, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: SOF: Intel: Soundwire integration

This patchset applies on top of the series "[PATCH 0/4] soundwire:
update ASoC interfaces". The SOF/Intel code makes use of the interfaces defined for initialization.

Build support for SoundWire is not provided for now, all Soundwire-related code will be handled with a dummy fallback. We will enable SoundWire interfaces in the Kconfigs when the functionality is enabled in the soundwire tree.

In short, if the interfaces are agreed on, there is no risk with the integration of these patches on the ASoC side.

Pierre-Louis Bossart (5):
ASoC: SOF: Intel: add SoundWire configuration interface
ASoC: SOF: IPC: dai-intel: move ALH declarations in header file
ASoC: SOF: Intel: hda: add SoundWire stream config/free callbacks
ASoC: SOF: Intel: hda: initial SoundWire machine driver autodetect
ASoC: SOF: Intel: hda: disable SoundWire interrupts on suspend

 include/sound/sof/dai-intel.h    |  18 +--
 sound/soc/sof/intel/hda-dsp.c    |   2 +
 sound/soc/sof/intel/hda-loader.c |  13 ++
 sound/soc/sof/intel/hda.c        | 230 ++++++++++++++++++++++++++++++-
 sound/soc/sof/intel/hda.h        |  44 ++++++
 5 files changed, 295 insertions(+), 12 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/5 ASoC: SOF: Intel: add SoundWire configuration interface

Now that the SoundWire core supports the multi-step initialization, call the relevant APIs.

The actual hardware enablement can be done in two places, ideally we'd want to startup the SoundWire IP as soon as possible (while still taking power rail dependencies into account)

However when suspend/resume is implemented, the DSP device will be resumed first, and only when the DSP firmware is downloaded/booted would the SoundWire child devices be resumed, so there are only marginal benefits in starting the IP earlier for the first probe.

---
 sound/soc/sof/intel/hda-loader.c |  13 ++++
 sound/soc/sof/intel/hda.c        | 121 ++++++++++++++++++++++++++++++-
 sound/soc/sof/intel/hda.h        |  44 +++++++++++
 3 files changed, 177 insertions(+), 1 deletion(-)
sound/soc/sof/intel/hda-loader.c +13 -0
index b1783360fe10..2f5cd2c1ea3c 100644
@@ -397,6 +397,19 @@ int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev)
 /* post fw run operations */
 int hda_dsp_post_fw_run(struct snd_sof_dev *sdev)
 {
+	int ret;
+
+	if (sdev->first_boot) {
+		ret = hda_sdw_startup(sdev);
+		if (ret < 0) {
+			dev_err(sdev->dev,
+				"error: could not startup SoundWire links\n");
+			return ret;
+		}
+	}
+
+	hda_sdw_int_enable(sdev, true);
+
 	/* re-enable clock gating and power gating */
 	return hda_dsp_ctrl_clock_power_gating(sdev, true);
 }
sound/soc/sof/intel/hda.c +120 -1

162 lines not on this page · raw message

sound/soc/sof/intel/hda.h +44 -0

62 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 1/5] ASoC: SOF: Intel: add SoundWire configuration interface

I love your patch! Yet something to improve:

Hi Pierre-Louis,

I love your patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[cannot apply to v5.4-rc4 next-20191025]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Pierre-Louis-Bossart/ASoC-SOF-Intel-Soundwire-integration/20191026-034949
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: s390-allmodconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=s390

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

In file included from sound/soc/sof/sof-pci-dev.c:22:0:

>> sound/soc/sof/intel/hda.h:408:29: error: field 'info' has incomplete type
     struct sdw_intel_acpi_info info;
                                ^~~~

vim +/info +408 sound/soc/sof/intel/hda.h

387
388 struct hda_bus hbus;
389
390 /* hw config */
391 const struct sof_intel_dsp_desc *desc;
392
393 /* trace */
394 struct hdac_ext_stream *dtrace_stream;
395
396 /* if position update IPC needed */
397 u32 no_ipc_position;
398
399 /* the maximum number of streams (playback + capture) supported */
400 u32 stream_max;
401
402 int irq;
403
404 /* DMIC device */
405 struct platform_device *dmic_dev;
406
407 /* ACPI information stored between scan and probe steps */

 > 408		struct sdw_intel_acpi_info info;

409
410 /* sdw context allocated by SoundWire driver */
411 struct sdw_intel_ctx *sdw;
412 };
413

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

PATCH 2/5 ASoC: SOF: IPC: dai-intel: move ALH declarations in header file

In reply to Pierre-Louis Bossart

ALH was inserted in the wrong place during integration, add after DMIC to mirror the file used by SOF firmware.

No functional change, just text move in the same file to better track changes, if any.

---
 include/sound/sof/dai-intel.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
include/sound/sof/dai-intel.h +9 -9
index 5f1ef5565be6..04e48227f542 100644
@@ -87,6 +87,15 @@ struct sof_ipc_dai_hda_params {
 	uint32_t link_dma_ch;
 } __packed;
 
+/* ALH Configuration Request - SOF_IPC_DAI_ALH_CONFIG */
+struct sof_ipc_dai_alh_params {
+	struct sof_ipc_hdr hdr;
+	uint32_t stream_id;
+
+	/* reserved for future use */
+	uint32_t reserved[15];
+} __packed;
+
 /* DMIC Configuration Request - SOF_IPC_DAI_DMIC_CONFIG */
 
 /* This struct is defined per 2ch PDM controller available in the platform.
@@ -179,13 +188,4 @@ struct sof_ipc_dai_dmic_params {
 	struct sof_ipc_dai_dmic_pdm_ctrl pdm[0];
 } __packed;
 
-/* ALH Configuration Request - SOF_IPC_DAI_ALH_CONFIG */
-struct sof_ipc_dai_alh_params {
-	struct sof_ipc_hdr hdr;
-	uint32_t stream_id;
-
-	/* reserved for future use */
-	uint32_t reserved[15];
-} __packed;
-
 #endif
Signature · 1 line
2.20.1
#4 lore raw

PATCH 3/5 ASoC: SOF: Intel: hda: add SoundWire stream config/free callbacks

In reply to Pierre-Louis Bossart

These callbacks are invoked when a matching hw_params/hw_free() DAI operation takes place, and will result in IPC operations with the SOF firmware.

---
 sound/soc/sof/intel/hda.c | 70 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
sound/soc/sof/intel/hda.c +70 -0
index 7e36f3bd6b39..98ac38ca0afa 100644
@@ -38,6 +38,74 @@
 
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
 
+static int sdw_params_stream(struct device *dev,
+			     struct sdw_intel_stream_params_data *params_data)
+{
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+	struct snd_soc_dai *d = params_data->dai;
+	struct sof_ipc_dai_config config;
+	struct sof_ipc_reply reply;
+	int link_id = params_data->link_id;
+	int alh_stream_id = params_data->alh_stream_id;
+	int ret;
+	u32 size = sizeof(config);
+
+	memset(&config, 0, size);
+	config.hdr.size = size;
+	config.hdr.cmd = SOF_IPC_GLB_DAI_MSG | SOF_IPC_DAI_CONFIG;
+	config.type = SOF_DAI_INTEL_ALH;
+	config.dai_index = (link_id << 8) | (d->id);
+	config.alh.stream_id = alh_stream_id;
+
+	/* send message to DSP */
+	ret = sof_ipc_tx_message(sdev->ipc,
+				 config.hdr.cmd, &config, size, &reply,
+				 sizeof(reply));
+	if (ret < 0) {
+		dev_err(sdev->dev,
+			"error: failed to set DAI hw_params for link %d dai->id %d ALH %d\n",
+			link_id, d->id, alh_stream_id);
+	}
+
+	return ret;
+}
+
+static int sdw_free_stream(struct device *dev,
+			   struct sdw_intel_stream_free_data *free_data)
+{
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+	struct snd_soc_dai *d = free_data->dai;
+	struct sof_ipc_dai_config config;
+	struct sof_ipc_reply reply;
+	int link_id = free_data->link_id;
+	int ret;
+	u32 size = sizeof(config);
+
+	memset(&config, 0, size);
+	config.hdr.size = size;
+	config.hdr.cmd = SOF_IPC_GLB_DAI_MSG | SOF_IPC_DAI_CONFIG;
+	config.type = SOF_DAI_INTEL_ALH;
+	config.dai_index = (link_id << 8) | d->id;
+	config.alh.stream_id = 0xFFFF; /* invalid value on purpose */
+
+	/* send message to DSP */
+	ret = sof_ipc_tx_message(sdev->ipc,
+				 config.hdr.cmd, &config, size, &reply,
+				 sizeof(reply));
+	if (ret < 0) {
+		dev_err(sdev->dev,
+			"error: failed to free stream for link %d dai->id %d\n",
+			link_id, d->id);
+	}
+
+	return ret;
+}
+
+static const struct sdw_intel_ops sdw_callback = {
+	.params_stream = sdw_params_stream,
+	.free_stream = sdw_free_stream,
+};
+
 void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable)
 {
 	sdw_intel_enable_irq(sdev->bar[HDA_DSP_BAR], enable);
@@ -80,6 +148,8 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)
 	res.irq = sdev->ipc_irq;
 	res.handle = hdev->info.handle;
 	res.parent = sdev->dev;
+	res.ops = &sdw_callback;
+	res.dev = sdev->dev;
 
 	/*
 	 * ops and arg fields are not populated for now,
Signature · 1 line
2.20.1
#5 lore raw

PATCH 4/5 ASoC: SOF: Intel: hda: initial SoundWire machine driver autodetect

In reply to Pierre-Louis Bossart

For now we have a limited number of machine driver configurations, and we can detect them based on the link configuration returned after checking hardware and firmware (BIOS) configurations.

It's likely that in the future we will need to check for _ADR match as well, which can easily be done by extending the acpi_info structure.

There is a chance that in extreme cases where the BIOS contains too much information we would need to detect which Slave devices actually report as 'attached'. This would be more accurate than static table-based solutions, but it also introduces timing dependencies since we don't know when those devices might become attached, so will only be only be looked at if we see limitations with static methods and the usual quirks based e.g. on DMI information.

---
 sound/soc/sof/intel/hda.c | 61 ++++++++++++++++++++++++++++++---------
 1 file changed, 48 insertions(+), 13 deletions(-)
sound/soc/sof/intel/hda.c +48 -13
index 98ac38ca0afa..5f614ec8de1d 100644
@@ -179,6 +179,9 @@ int hda_sdw_startup(struct snd_sof_dev *sdev)
 
 	hdev = sdev->pdata->hw_pdata;
 
+	if (!hdev->sdw)
+		return 0;
+
 	return sdw_intel_startup(hdev->sdw);
 }
 
@@ -502,11 +505,11 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
 	struct snd_sof_pdata *pdata = sdev->pdata;
+	struct snd_soc_acpi_mach *mach;
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
 	struct hdac_ext_link *hlink;
-	struct snd_soc_acpi_mach_params *mach_params;
 	struct snd_soc_acpi_mach *hda_mach;
-	struct snd_soc_acpi_mach *mach;
+	struct snd_soc_acpi_mach_params *mach_params;
 	const char *tplg_filename;
 	const char *idisp_str;
 	const char *dmic_str;
@@ -547,24 +550,56 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
 	/* scan SoundWire capabilities exposed by DSDT */
 	ret = hda_sdw_acpi_scan(sdev);
 	if (ret < 0) {
-		dev_err(sdev->dev, "error: SoundWire ACPI scan error\n");
-		return ret;
+		dev_dbg(sdev->dev, "skipping SoundWire, ACPI scan error\n");
+		goto skip_soundwire;
 	}
 
 	link_mask = hdev->info.link_mask;
 	if (!link_mask) {
-		/*
-		 * probe/allocated SoundWire resources.
-		 * The hardware configuration takes place in hda_sdw_startup
-		 * after power rails are enabled.
-		 */
-		ret = hda_sdw_probe(sdev);
-		if (ret < 0) {
-			dev_err(sdev->dev, "error: SoundWire probe error\n");
-			return ret;
+		dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n");
+		goto skip_soundwire;
+	}
+
+	/*
+	 * probe/allocate SoundWire resources.
+	 * The hardware configuration takes place in hda_sdw_startup
+	 * after power rails are enabled.
+	 * It's entirely possible to have a mix of I2S/DMIC/SoundWire
+	 * devices, so we allocate the resources in all cases.
+	 */
+	ret = hda_sdw_probe(sdev);
+	if (ret < 0) {
+		dev_err(sdev->dev, "error: SoundWire probe error\n");
+		return ret;
+	}
+
+	/*
+	 * Select SoundWire machine driver if needed using the
+	 * alternate tables. This case deals with SoundWire-only
+	 * machines, for mixed cases with I2C/I2S the detection relies
+	 * on the HID list.
+	 */
+	if (!pdata->machine) {
+		mach = pdata->desc->alt_machines;
+		while (mach && mach->link_mask && mach->link_mask != link_mask)
+			mach++;
+		if (mach && mach->link_mask) {
+			dev_dbg(bus->dev,
+				"SoundWire machine driver %s topology %s\n",
+				mach->drv_name,
+				mach->sof_tplg_filename);
+			pdata->machine = mach;
+			mach->mach_params.platform = dev_name(sdev->dev);
+			pdata->fw_filename = mach->sof_fw_filename;
+			pdata->tplg_filename = mach->sof_tplg_filename;
+		} else {
+			dev_info(sdev->dev,
+				 "No SoundWire machine driver found\n");
 		}
 	}
 
+skip_soundwire:
+
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
 	if (bus->mlcap)
 		snd_hdac_ext_bus_get_ml_capabilities(bus);
Signature · 1 line
2.20.1
#6 lore raw

PATCH 5/5 ASoC: SOF: Intel: hda: disable SoundWire interrupts on suspend

In reply to Pierre-Louis Bossart

Doing this avoid conflicts and errors reported on the bus.

The interrupts are only re-enabled on resume after the firmware is downloaded, so the behavior is not fully symmetric

---
 sound/soc/sof/intel/hda-dsp.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/sof/intel/hda-dsp.c +2 -0
index fa2f1f66c72c..a7509e8a0e30 100644
@@ -361,6 +361,8 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
 #endif
 	int ret;
 
+	hda_sdw_int_enable(sdev, false);
+
 	/* disable IPC interrupts */
 	hda_dsp_ipc_int_disable(sdev);
 
Signature · 1 line
2.20.1
#7 lore raw
In reply to Pierre-Louis Bossart
Quoted 11 lines · Pierre-Louis Bossart

This patchset applies on top of the series "[PATCH 0/4] soundwire:
update ASoC interfaces". The SOF/Intel code makes use of the interfaces defined for initialization.

Build support for SoundWire is not provided for now, all Soundwire-related code will be handled with a dummy fallback. We will enable SoundWire interfaces in the Kconfigs when the functionality is enabled in the soundwire tree.

In short, if the interfaces are agreed on, there is no risk with the integration of these patches on the ASoC side.

Mark, Vinod, any comments/objections on the suggested interfaces? I tried to make your life simpler with a clean separation between SoundWire and ASoC/SOF.

Quoted 15 lines

Pierre-Louis Bossart (5):
ASoC: SOF: Intel: add SoundWire configuration interface
ASoC: SOF: IPC: dai-intel: move ALH declarations in header file
ASoC: SOF: Intel: hda: add SoundWire stream config/free callbacks
ASoC: SOF: Intel: hda: initial SoundWire machine driver autodetect
ASoC: SOF: Intel: hda: disable SoundWire interrupts on suspend

  include/sound/sof/dai-intel.h    |  18 +--
  sound/soc/sof/intel/hda-dsp.c    |   2 +
  sound/soc/sof/intel/hda-loader.c |  13 ++
  sound/soc/sof/intel/hda.c        | 230 ++++++++++++++++++++++++++++++-
  sound/soc/sof/intel/hda.h        |  44 ++++++
  5 files changed, 295 insertions(+), 12 deletions(-)