Skip to contentSkip to conversation

Add support for different DMIC configurations

PATCH Superseded Mateusz Gorski 2 participants 9 messages Apr 21, 2020 – Apr 22, 2020

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover Add support for different DMIC configurations

Set of patches to enable DMIC capture on different hardware configurations.
Information about supported DMIC configuration is read from NHLT and correct pipeline configuration is selected automatically. Also, adding additional option for topology binary name which is based on used machine driver.

Mateusz Gorski (4):
ASoC: Intel: Skylake: Change the order of machine device and platform
registration
ASoC: Intel: Skylake: Add alternative topology binary name
ASoC: Intel: Multiple I/O PCM format support for pipe
ASoC: Intel: Skylake: Automatic DMIC format configuration according to
information from NHLT

 include/uapi/sound/skl-tplg-interface.h |   2 +
 sound/soc/intel/skylake/skl-topology.c  | 189 +++++++++++++++++++++++-
 sound/soc/intel/skylake/skl-topology.h  |   1 +
 sound/soc/intel/skylake/skl.c           |  10 +-
 4 files changed, 192 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 ASoC: Intel: Skylake: Change the order of machine device and platform registration

Swap the order of machine device and platform device registration. This change ensures that even if the codec enumeration falls late - during the driver module or topology reload - i2s_dev field is always ready to be used.

Follow-up patch uses data from this field to create alternative topology name based on used machine device.

---
 sound/soc/intel/skylake/skl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/intel/skylake/skl.c +5 -5
index 63182bfd7941..8473eb13ea65 100644
@@ -819,16 +819,16 @@ static void skl_probe_work(struct work_struct *work)
 	/* create codec instances */
 	skl_codec_create(bus);
 
-	/* register platform dai and controls */
-	err = skl_platform_register(bus->dev);
+	err = skl_machine_device_register(skl);
 	if (err < 0) {
-		dev_err(bus->dev, "platform register failed: %d\n", err);
+		dev_err(bus->dev, "machine register failed: %d\n", err);
 		goto out_err;
 	}
 
-	err = skl_machine_device_register(skl);
+	/* register platform dai and controls */
+	err = skl_platform_register(bus->dev);
 	if (err < 0) {
-		dev_err(bus->dev, "machine register failed: %d\n", err);
+		dev_err(bus->dev, "platform register failed: %d\n", err);
 		goto out_err;
 	}
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/4] ASoC: Intel: Skylake: Change the order of machine device and platform registration

Quoted 4 lines · Mateusz Gorski

Swap the order of machine device and platform device registration. This change ensures that even if the codec enumeration falls late - during the driver module or topology reload - i2s_dev field is always ready to be used.

Are you sure?

The platform device will register the DAIs that are used by the machine driver, don't you have a risk of missing dependencies during the card registration with this change?

Put differently, why do this now when the existing code has been 'working' for a number of years without needing such a change?

Quoted 35 lines

Follow-up patch uses data from this field to create alternative topology name based on used machine device.

---
  sound/soc/intel/skylake/skl.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/intel/skylake/skl.c +5 -5
index 63182bfd7941..8473eb13ea65 100644
@@ -819,16 +819,16 @@ static void skl_probe_work(struct work_struct *work)
  	/* create codec instances */
  	skl_codec_create(bus);
 
-	/* register platform dai and controls */
-	err = skl_platform_register(bus->dev);
+	err = skl_machine_device_register(skl);
  	if (err < 0) {
-		dev_err(bus->dev, "platform register failed: %d\n", err);
+		dev_err(bus->dev, "machine register failed: %d\n", err);
  		goto out_err;
  	}
 
-	err = skl_machine_device_register(skl);
+	/* register platform dai and controls */
+	err = skl_platform_register(bus->dev);
  	if (err < 0) {
-		dev_err(bus->dev, "machine register failed: %d\n", err);
+		dev_err(bus->dev, "platform register failed: %d\n", err);
  		goto out_err;
  	}
 
#3 lore raw

Re: [PATCH 1/4] ASoC: Intel: Skylake: Change the order of machine device and platform registration

Quoted 6 lines

Swap the order of machine device and platform device registration.

Quoted 3 lines

This change ensures that even if the codec enumeration falls late - during the driver module or topology reload - i2s_dev field is always ready to be used.

Quoted 6 lines

Are you sure?

The platform device will register the DAIs that are used by the machine driver, don't you have a risk of missing dependencies during the card registration with this change?

Put differently, why do this now when the existing code has been 'working' for a number of years without needing such a change?

This change was tested on multiple platforms (including production laptops) and did not show any issues. Anyway, in patchset v2 the alt_tplg_name creation mechanism was slightly changed and this patch was removed.

Thanks for your input,
Mateusz

#4 lore raw

PATCH 2/4 ASoC: Intel: Skylake: Add alternative topology binary name

In reply to Mateusz Gorski

Add alternative topology binary file name based on used machine driver and fallback to use this name after failed attempt to load topology file with name based on NHLT.
This change addresses multiple issues with current mechanism, for example - there are devices without NHLT table, and that currently results in tplg_name being empty.

---
 sound/soc/intel/skylake/skl-topology.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
sound/soc/intel/skylake/skl-topology.c +17 -2
index 69cd7a81bf2a..344b06df0e15 100644
@@ -3565,8 +3565,20 @@ int skl_tplg_init(struct snd_soc_component *component, struct hdac_bus *bus)
 
 	ret = request_firmware(&fw, skl->tplg_name, bus->dev);
 	if (ret < 0) {
-		dev_info(bus->dev, "tplg fw %s load failed with %d, falling back to dfw_sst.bin",
-				skl->tplg_name, ret);
+		char alt_tplg_name[64];
+
+		snprintf(alt_tplg_name, sizeof(alt_tplg_name), "%s-tplg.bin",
+				skl->i2s_dev->name);
+		dev_info(bus->dev, "tplg fw %s load failed with %d, trying alternative tplg name %s",
+				skl->tplg_name, ret, alt_tplg_name);
+
+		ret = request_firmware(&fw, alt_tplg_name, bus->dev);
+		if (!ret)
+			goto component_load;
+
+		dev_info(bus->dev, "tplg %s failed with %d, falling back to dfw_sst.bin",
+				alt_tplg_name, ret);
+
 		ret = request_firmware(&fw, "dfw_sst.bin", bus->dev);
 		if (ret < 0) {
 			dev_err(bus->dev, "Fallback tplg fw %s load failed with %d\n",
@@ -3575,6 +3587,9 @@ int skl_tplg_init(struct snd_soc_component *component, struct hdac_bus *bus)
 		}
 	}
 
+component_load:
+
+
 	/*
 	 * The complete tplg for SKL is loaded as index 0, we don't use
 	 * any other index
Signature · 1 line
2.17.1
#5 lore raw

PATCH 3/4 ASoC: Intel: Multiple I/O PCM format support for pipe

In reply to Mateusz Gorski

For pipes supporting multiple input/output formats, kcontrol is created and selection of pipe input and output configuration is done based on control set.

If more than one configuration is supported, then this patch allows user to select configuration of choice using amixer settings.

---
 include/uapi/sound/skl-tplg-interface.h |   1 +
 sound/soc/intel/skylake/skl-topology.c  | 110 ++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-topology.h  |   1 +
 3 files changed, 112 insertions(+)
include/uapi/sound/skl-tplg-interface.h +1 -0
index 9eee32f5e407..f2711186c81f 100644
@@ -18,6 +18,7 @@
  */
 #define SKL_CONTROL_TYPE_BYTE_TLV	0x100
 #define SKL_CONTROL_TYPE_MIC_SELECT	0x102
+#define SKL_CONTROL_TYPE_MULTI_IO_SELECT	0x103
 
 #define HDA_SST_CFG_MAX	900 /* size of copier cfg*/
 #define MAX_IN_QUEUE 8
sound/soc/intel/skylake/skl-topology.c +110 -0

134 lines not on this page · raw message

sound/soc/intel/skylake/skl-topology.h +1 -0
index e967800dbb62..06576147cc29 100644
@@ -306,6 +306,7 @@ struct skl_pipe {
 	struct skl_path_config configs[SKL_MAX_PATH_CONFIGS];
 	struct list_head w_list;
 	bool passthru;
+	u32 pipe_config_idx;
 };
 
 enum skl_module_state {
Signature · 1 line
2.17.1
#6 lore raw

PATCH 4/4 ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT

In reply to Mateusz Gorski

Automatically choose DMIC pipeline format configuration depending on information included in NHLT.
Change the access rights of appropriate kcontrols to read-only in order to prevent user interference.

---
 include/uapi/sound/skl-tplg-interface.h |  1 +
 sound/soc/intel/skylake/skl-topology.c  | 60 +++++++++++++++++++++++--
 2 files changed, 58 insertions(+), 3 deletions(-)
include/uapi/sound/skl-tplg-interface.h +1 -0
index f2711186c81f..a93c0decfdd5 100644
@@ -19,6 +19,7 @@
 #define SKL_CONTROL_TYPE_BYTE_TLV	0x100
 #define SKL_CONTROL_TYPE_MIC_SELECT	0x102
 #define SKL_CONTROL_TYPE_MULTI_IO_SELECT	0x103
+#define SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC	0x104
 
 #define HDA_SST_CFG_MAX	900 /* size of copier cfg*/
 #define MAX_IN_QUEUE 8
sound/soc/intel/skylake/skl-topology.c +57 -3

99 lines not on this page · raw message

Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH 4/4] ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT

Quoted 9 lines
sound/soc/intel/skylake/skl-topology.c +1 -1
@@ -3123,12 +3141,15 @@ static int skl_tplg_control_load(struct snd_soc_component *cmpnt,
  	case SND_SOC_TPLG_CTL_ENUM:
  		tplg_ec = container_of(hdr,
  				struct snd_soc_tplg_enum_control, hdr);
-		if (kctl->access & SNDRV_CTL_ELEM_ACCESS_READWRITE) {
+		if (kctl->access & SNDRV_CTL_ELEM_ACCESS_READ) {

sound/soc/intel/skylake/skl-topology.c static int skl_tplg_control_load(struct snd_soc_component *cmpnt, · line 3152

Quoted 10 lines
sound/soc/intel/skylake/skl-topology.c +5 -2
  			se = (struct soc_enum *)kctl->private_value;
  			if (tplg_ec->priv.size)
-				return skl_init_enum_data(bus->dev, se,
-						tplg_ec);
+				skl_init_enum_data(bus->dev, se, tplg_ec);
  		}
+
+		if (hdr->ops.get == SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC)
+			kctl->access = SNDRV_CTL_ELEM_ACCESS_READ;
+

Is it intentional that you first test the kctrl->access as READ only, and then later set it to READ only for DMICs? The sequence looks rather odd?

#8 lore raw

Re: [PATCH 4/4] ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT

Quoted 12 lines
Quoted 12 lines
(quoted diff) +0 -0
@@ -3123,12 +3141,15 @@ static int skl_tplg_control_load(struct 
 snd_soc_component *cmpnt,

      case SND_SOC_TPLG_CTL_ENUM:
          tplg_ec = container_of(hdr,
                  struct snd_soc_tplg_enum_control, hdr); -        if (kctl->access & SNDRV_CTL_ELEM_ACCESS_READWRITE) { +        if (kctl->access & SNDRV_CTL_ELEM_ACCESS_READ) { se = (struct soc_enum *)kctl->private_value; if (tplg_ec->priv.size)
-                return skl_init_enum_data(bus->dev, se, -                        tplg_ec);

Quoted 8 lines

sound/soc/intel/skylake/skl-topology.c static int skl_tplg_control_load(struct snd_soc_component *cmpnt, · line 3152

Quoted 6 lines

+                skl_init_enum_data(bus->dev, se, tplg_ec); }

sound/soc/intel/skylake/skl-topology.c +4 -0
+
+        if (hdr->ops.get == SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC)
+            kctl->access = SNDRV_CTL_ELEM_ACCESS_READ;
+

Is it intentional that you first test the kctrl->access as READ only, and then later set it to READ only for DMICs? The sequence looks rather odd?

This basiccally checks if given control has READ access right, it will pass for both READ and READWRITE (since READWRITE = READ|WRITE).

And when the control has READWRITE access we change it to READ-only, to prevent interference from user.