[PATCH v2 0/3] 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 (3): 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
Changes in v2: - removed patch 1/4 swapping machine device and platform device registration order - alt_tplg_name creation now uses different field to read machine driver name - including of <sound/soc-acpi.h> moved to different patch
include/uapi/sound/skl-tplg-interface.h | 2 + sound/soc/intel/skylake/skl-topology.c | 189 +++++++++++++++++++++++- sound/soc/intel/skylake/skl-topology.h | 1 + 3 files changed, 187 insertions(+), 5 deletions(-)
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.
Signed-off-by: Mateusz Gorski mateusz.gorski@linux.intel.com ---
Changes in v2: - added <sound/soc-acpi.h> include - machine driver name is now read from different field
sound/soc/intel/skylake/skl-topology.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 69cd7a81bf2a..58f77b6c5cda 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -14,6 +14,7 @@ #include <linux/uuid.h> #include <sound/intel-nhlt.h> #include <sound/soc.h> +#include <sound/soc-acpi.h> #include <sound/soc-topology.h> #include <uapi/sound/snd_sst_tokens.h> #include <uapi/sound/skl-tplg-interface.h> @@ -3565,8 +3566,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->mach->drv_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 +3588,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
On 2020-04-22 14:05, Mateusz Gorski wrote:
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.
Signed-off-by: Mateusz Gorski mateusz.gorski@linux.intel.com
Changes in v2:
- added <sound/soc-acpi.h> include
- machine driver name is now read from different field
@@ -3575,6 +3588,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
Looks like double newline after 'component_load' slipped through my eyes. Please fix it.
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.
Signed-off-by: Mateusz Gorski mateusz.gorski@linux.intel.com Signed-off-by: S, Pavan K pavan.k.s@intel.com --- 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(+)
diff --git a/include/uapi/sound/skl-tplg-interface.h b/include/uapi/sound/skl-tplg-interface.h index 9eee32f5e407..f2711186c81f 100644 --- a/include/uapi/sound/skl-tplg-interface.h +++ b/include/uapi/sound/skl-tplg-interface.h @@ -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 diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 58f77b6c5cda..2e6eca619c4e 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -579,6 +579,38 @@ static int skl_tplg_unload_pipe_modules(struct skl_dev *skl, return ret; }
+static bool skl_tplg_is_multi_fmt(struct skl_dev *skl, struct skl_pipe *pipe) +{ + int i; + struct skl_pipe_fmt *cur_fmt; + struct skl_pipe_fmt *next_fmt; + + if (pipe->nr_cfgs <= 1) + return false; + + if (pipe->conn_type != SKL_PIPE_CONN_TYPE_FE) + return true; + + for (i = 0; i < pipe->nr_cfgs - 1; i++) { + if (pipe->direction == SNDRV_PCM_STREAM_PLAYBACK) { + cur_fmt = &pipe->configs[i].out_fmt; + next_fmt = &pipe->configs[i+1].out_fmt; + } else { + cur_fmt = &pipe->configs[i].in_fmt; + next_fmt = &pipe->configs[i+1].in_fmt; + } + + if (!CHECK_HW_PARAMS(cur_fmt->channels, cur_fmt->freq, + cur_fmt->bps, + next_fmt->channels, + next_fmt->freq, + next_fmt->bps)) + return true; + } + + return false; +} + /* * Here, we select pipe format based on the pipe type and pipe * direction to determine the current config index for the pipeline. @@ -601,6 +633,14 @@ skl_tplg_get_pipe_config(struct skl_dev *skl, struct skl_module_cfg *mconfig) return 0; }
+ if (skl_tplg_is_multi_fmt(skl, pipe)) { + pipe->cur_config_idx = pipe->pipe_config_idx; + pipe->memory_pages = pconfig->mem_pages; + dev_dbg(skl->dev, "found pipe config idx:%d\n", + pipe->cur_config_idx); + return 0; + } + if (pipe->conn_type == SKL_PIPE_CONN_TYPE_NONE) { dev_dbg(skl->dev, "No conn_type detected, take 0th config\n"); pipe->cur_config_idx = 0; @@ -1315,6 +1355,71 @@ static int skl_tplg_pga_event(struct snd_soc_dapm_widget *w, return 0; }
+static int skl_tplg_multi_config_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct hdac_bus *bus = snd_soc_component_get_drvdata(component); + struct skl_dev *skl = bus_to_skl(bus); + struct skl_pipeline *ppl; + struct skl_pipe *pipe = NULL; + u32 *pipe_id; + struct soc_enum *ec = (struct soc_enum *)kcontrol->private_value; + + if (!ec) + return -EINVAL; + + pipe_id = ec->dobj.private; + + list_for_each_entry(ppl, &skl->ppl_list, node) { + if (ppl->pipe->ppl_id == *pipe_id) { + pipe = ppl->pipe; + break; + } + } + if (!pipe) + return -EIO; + + ucontrol->value.enumerated.item[0] = pipe->pipe_config_idx; + + return 0; +} + +static int skl_tplg_multi_config_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct hdac_bus *bus = snd_soc_component_get_drvdata(component); + struct skl_dev *skl = bus_to_skl(bus); + struct skl_pipeline *ppl; + struct skl_pipe *pipe = NULL; + struct soc_enum *ec = (struct soc_enum *)kcontrol->private_value; + u32 *pipe_id; + + if (!ec) + return -EINVAL; + + if (ucontrol->value.enumerated.item[0] > ec->items) + return -EINVAL; + + pipe_id = ec->dobj.private; + + list_for_each_entry(ppl, &skl->ppl_list, node) { + if (ppl->pipe->ppl_id == *pipe_id) { + pipe = ppl->pipe; + break; + } + } + if (!pipe) + return -EIO; + + pipe->pipe_config_idx = ucontrol->value.enumerated.item[0]; + + return 0; +} + static int skl_tplg_tlv_control_get(struct snd_kcontrol *kcontrol, unsigned int __user *data, unsigned int size) { @@ -1854,6 +1959,11 @@ static const struct snd_soc_tplg_kcontrol_ops skl_tplg_kcontrol_ops[] = { .get = skl_tplg_mic_control_get, .put = skl_tplg_mic_control_set, }, + { + .id = SKL_CONTROL_TYPE_MULTI_IO_SELECT, + .get = skl_tplg_multi_config_get, + .put = skl_tplg_multi_config_set, + }, };
static int skl_tplg_fill_pipe_cfg(struct device *dev, diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index e967800dbb62..06576147cc29 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -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 {
On 2020-04-22 14:05, Mateusz Gorski wrote:
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.
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 58f77b6c5cda..2e6eca619c4e 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -579,6 +579,38 @@ static int skl_tplg_unload_pipe_modules(struct skl_dev *skl, return ret; }
+static bool skl_tplg_is_multi_fmt(struct skl_dev *skl, struct skl_pipe *pipe) +{
- int i;
- struct skl_pipe_fmt *cur_fmt;
- struct skl_pipe_fmt *next_fmt;
Hmm, some code-cosmetics are left unattended too. Please reorder 'i' declaration to the bottom.
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.
Signed-off-by: Mateusz Gorski mateusz.gorski@linux.intel.com ---
Changes in v2: - removed <sound/soc-acpi.h> include (moved po patch 1/3)
include/uapi/sound/skl-tplg-interface.h | 1 + sound/soc/intel/skylake/skl-topology.c | 59 +++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/include/uapi/sound/skl-tplg-interface.h b/include/uapi/sound/skl-tplg-interface.h index f2711186c81f..a93c0decfdd5 100644 --- a/include/uapi/sound/skl-tplg-interface.h +++ b/include/uapi/sound/skl-tplg-interface.h @@ -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 diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 2e6eca619c4e..0bcf07ddbc25 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -1420,6 +1420,18 @@ static int skl_tplg_multi_config_set(struct snd_kcontrol *kcontrol, return 0; }
+static int skl_tplg_multi_config_get_dmic(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return skl_tplg_multi_config_get(kcontrol, ucontrol); +} + +static int skl_tplg_multi_config_set_dmic(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return skl_tplg_multi_config_set(kcontrol, ucontrol); +} + static int skl_tplg_tlv_control_get(struct snd_kcontrol *kcontrol, unsigned int __user *data, unsigned int size) { @@ -1964,6 +1976,11 @@ static const struct snd_soc_tplg_kcontrol_ops skl_tplg_kcontrol_ops[] = { .get = skl_tplg_multi_config_get, .put = skl_tplg_multi_config_set, }, + { + .id = SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC, + .get = skl_tplg_multi_config_get_dmic, + .put = skl_tplg_multi_config_set_dmic, + } };
static int skl_tplg_fill_pipe_cfg(struct device *dev, @@ -3124,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); + 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; + break;
default: @@ -3599,6 +3619,38 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index, return 0; }
+static void skl_tplg_complete(struct snd_soc_component *component) +{ + struct snd_soc_dobj *dobj; + struct snd_soc_acpi_mach *mach = + dev_get_platdata(component->card->dev); + int i; + + list_for_each_entry(dobj, &component->dobj_list, list) { + struct snd_kcontrol *kcontrol = dobj->control.kcontrol; + struct soc_enum *se = + (struct soc_enum *)kcontrol->private_value; + char **texts = dobj->control.dtexts; + char chan_text[4]; + + if (dobj->type != SND_SOC_DOBJ_ENUM || + dobj->control.kcontrol->put != + skl_tplg_multi_config_set_dmic) + continue; + sprintf(chan_text, "c%d", mach->mach_params.dmic_num); + + for (i = 0; i < se->items; i++) { + struct snd_ctl_elem_value val; + + if (strstr(texts[i], chan_text)) { + val.value.enumerated.item[0] = i; + kcontrol->put(kcontrol, &val); + } + } + } +} + + static struct snd_soc_tplg_ops skl_tplg_ops = { .widget_load = skl_tplg_widget_load, .control_load = skl_tplg_control_load, @@ -3608,6 +3660,7 @@ static struct snd_soc_tplg_ops skl_tplg_ops = { .io_ops_count = ARRAY_SIZE(skl_tplg_kcontrol_ops), .manifest = skl_manifest_load, .dai_load = skl_dai_load, + .complete = skl_tplg_complete, };
/*
On 2020-04-22 14:05, Mateusz Gorski wrote:
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.
*seems like this thread is missing few maintainers in CC*
Mateusz Gorski (3): 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
Changes in v2:
- removed patch 1/4 swapping machine device and platform device registration order
- alt_tplg_name creation now uses different field to read machine driver name
- including of <sound/soc-acpi.h> moved to different patch
Ain't change-block supposed to be just below message body?
include/uapi/sound/skl-tplg-interface.h | 2 + sound/soc/intel/skylake/skl-topology.c | 189 +++++++++++++++++++++++- sound/soc/intel/skylake/skl-topology.h | 1 + 3 files changed, 187 insertions(+), 5 deletions(-)
You have forgotten to add my Reviewed-by tag as both, v1 and v2 were reviewed by me internally before upstreaming.
Thanks for addressing Pierre's review - indeed i2s_dev field usage could have been avoided. Good review, Pierre.
Don't believe series need to be resend just to fix cosmetics: Acked-by: Cezary Rojewski cezary.rojewski@intel.com
On Thu, Apr 23, 2020 at 11:11:05AM +0200, Cezary Rojewski wrote:
On 2020-04-22 14:05, Mateusz Gorski wrote:
Changes in v2:
- removed patch 1/4 swapping machine device and platform device registration order
- alt_tplg_name creation now uses different field to read machine driver name
- including of <sound/soc-acpi.h> moved to different patch
Ain't change-block supposed to be just below message body?
Only in patches to stop them getting included in the git changelog.
Don't believe series need to be resend just to fix cosmetics: Acked-by: Cezary Rojewski cezary.rojewski@intel.com
Well, I don't seem to have a copy of it so it'll need a resend for that unless it's just held up somewhere and arrives shortly.
On 2020-04-23 12:21, Mark Brown wrote:
On Thu, Apr 23, 2020 at 11:11:05AM +0200, Cezary Rojewski wrote:
On 2020-04-22 14:05, Mateusz Gorski wrote:
Changes in v2:
- removed patch 1/4 swapping machine device and platform device registration order
- alt_tplg_name creation now uses different field to read machine driver name
- including of <sound/soc-acpi.h> moved to different patch
Ain't change-block supposed to be just below message body?
Only in patches to stop them getting included in the git changelog.
Thanks for info, Mark.
Don't believe series need to be resend just to fix cosmetics: Acked-by: Cezary Rojewski cezary.rojewski@intel.com
Well, I don't seem to have a copy of it so it'll need a resend for that unless it's just held up somewhere and arrives shortly.
Doubt it will as Mateusz forgot to include you & Pierre in v2. Resend it is then!
participants (3)
-
Cezary Rojewski
-
Mark Brown
-
Mateusz Gorski