[PATCH 00/16] Harden SSP boards and add TDM support
In quite a few places in code there are checks for number of SSPs present on system, to reduce maintenance burden introduce helper functions allowing to get SSP and TDM from machine board configuration.
Current mechanism replaces "%d" present in some routes and widget names with SSP number. However there are also configurations which make use of of TDM number, in which case expected behavior would be to have string in form of SSP:TDM - see implementation of avs_i2s_platform_register() in sound/soc/intel/avs/pcm.c. Implement custom function, which parses string and make use of it when parsing topology. While at it make sure that we generate dynamic names only if there is no multiple SSPs or TDMs defined.
Migrate all boards to handle TDM if requested.
Amadeusz Sławiński (16): ASoC: Intel: avs: Only create SSP%d snd_soc_dai_driver when requested ASoC: Intel: avs: Introduce helper functions for SSP and TDM handling ASoC: Intel: avs: Improve topology parsing of dynamic strings ASoC: Intel: avs: i2s_test: Validate machine board configuration ASoC: Intel: avs: rt274: Validate machine board configuration ASoC: Intel: avs: rt5682: Validate machine board configuration ASoC: Intel: avs: max98357a: Validate machine board configuration ASoC: Intel: avs: rt298: Validate machine board configuration ASoC: Intel: avs: da7219: Validate machine board configuration ASoC: Intel: avs: es8336: Validate machine board configuration ASoC: Intel: avs: max98373: Validate machine board configuration ASoC: Intel: avs: max98927: Validate machine board configuration ASoC: Intel: avs: nau8825: Validate machine board configuration ASoC: Intel: avs: rt286: Validate machine board configuration ASoC: Intel: avs: rt5663: Validate machine board configuration ASoC: Intel: avs: ssm4567: Validate machine board configuration
sound/soc/intel/avs/board_selection.c | 2 +- sound/soc/intel/avs/boards/da7219.c | 17 +++-- sound/soc/intel/avs/boards/es8336.c | 18 +++-- sound/soc/intel/avs/boards/i2s_test.c | 55 ++++++++----- sound/soc/intel/avs/boards/max98357a.c | 18 +++-- sound/soc/intel/avs/boards/max98373.c | 18 +++-- sound/soc/intel/avs/boards/max98927.c | 18 +++-- sound/soc/intel/avs/boards/nau8825.c | 18 +++-- sound/soc/intel/avs/boards/rt274.c | 18 +++-- sound/soc/intel/avs/boards/rt286.c | 19 +++-- sound/soc/intel/avs/boards/rt298.c | 18 +++-- sound/soc/intel/avs/boards/rt5663.c | 18 +++-- sound/soc/intel/avs/boards/rt5682.c | 18 +++-- sound/soc/intel/avs/boards/ssm4567.c | 18 +++-- sound/soc/intel/avs/pcm.c | 28 ++++--- sound/soc/intel/avs/topology.c | 102 +++++++++++++++++++------ sound/soc/intel/avs/utils.h | 65 ++++++++++++++++ 17 files changed, 346 insertions(+), 122 deletions(-) create mode 100644 sound/soc/intel/avs/utils.h
When using TDM configuration some other device may be using SSP%d, so don't create snd_soc_dai_driver configuration for it unless requested by TDM configuration.
While at it adjust tdf8532 board to explicitly describe TDM configuration.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/board_selection.c | 2 +- sound/soc/intel/avs/pcm.c | 28 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/sound/soc/intel/avs/board_selection.c b/sound/soc/intel/avs/board_selection.c index 59a13feec57b..c10fff705496 100644 --- a/sound/soc/intel/avs/board_selection.c +++ b/sound/soc/intel/avs/board_selection.c @@ -193,7 +193,7 @@ static struct snd_soc_acpi_mach avs_apl_i2s_machines[] = { .mach_params = { .i2s_link_mask = AVS_SSP_RANGE(0, 5), }, - .pdata = (unsigned long[]){ 0, 0, 0x14, 0, 0, 0 }, /* SSP2 TDMs */ + .pdata = (unsigned long[]){ 0x1, 0x1, 0x14, 0x1, 0x1, 0x1 }, /* SSP2 TDMs */ .tplg_filename = "tdf8532-tplg.bin", }, { diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 5b31203bd56a..bea66e6bd438 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -1238,7 +1238,11 @@ int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned l int i, j;
ssp_count = adev->hw_cfg.i2s_caps.ctrl_count; - cpu_count = hweight_long(port_mask); + + cpu_count = 0; + for_each_set_bit(i, &port_mask, ssp_count) + if (!tdms || test_bit(0, &tdms[i])) + cpu_count++; if (tdms) for_each_set_bit(i, &port_mask, ssp_count) cpu_count += hweight_long(tdms[i]); @@ -1249,18 +1253,20 @@ int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned l
dai = cpus; for_each_set_bit(i, &port_mask, ssp_count) { - memcpy(dai, &i2s_dai_template, sizeof(*dai)); + if (!tdms || test_bit(0, &tdms[i])) { + memcpy(dai, &i2s_dai_template, sizeof(*dai));
- dai->name = - devm_kasprintf(adev->dev, GFP_KERNEL, "SSP%d Pin", i); - dai->playback.stream_name = - devm_kasprintf(adev->dev, GFP_KERNEL, "ssp%d Tx", i); - dai->capture.stream_name = - devm_kasprintf(adev->dev, GFP_KERNEL, "ssp%d Rx", i); + dai->name = + devm_kasprintf(adev->dev, GFP_KERNEL, "SSP%d Pin", i); + dai->playback.stream_name = + devm_kasprintf(adev->dev, GFP_KERNEL, "ssp%d Tx", i); + dai->capture.stream_name = + devm_kasprintf(adev->dev, GFP_KERNEL, "ssp%d Rx", i);
- if (!dai->name || !dai->playback.stream_name || !dai->capture.stream_name) - return -ENOMEM; - dai++; + if (!dai->name || !dai->playback.stream_name || !dai->capture.stream_name) + return -ENOMEM; + dai++; + } }
if (!tdms)
In quite a few places in code there are checks for number of SSPs present on system, to reduce maintenance burden introduce helper functions allowing to get SSP and TDM from machine board configuration.
Additionally in boards we use SSP and TDM to generate quite a few strings, it could be done like: if (tdms) dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d:%d-Codec", ssp_port, tdm_slot); else dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port);
but quite quickly code ends up with spaghetti of similar if elses. Instead introduce macro which can be used to generate correct string, allowing to minimize code to something like: dl->name = devm_kasprintf(dev, GFP_KERNEL, AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot));
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/utils.h | 65 +++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 sound/soc/intel/avs/utils.h
diff --git a/sound/soc/intel/avs/utils.h b/sound/soc/intel/avs/utils.h new file mode 100644 index 000000000000..6123fab527ec --- /dev/null +++ b/sound/soc/intel/avs/utils.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright(c) 2023 Intel Corporation. All rights reserved. + * + * Authors: Cezary Rojewski cezary.rojewski@intel.com + * Amadeusz Slawinski amadeuszx.slawinski@linux.intel.com + */ + +#ifndef __SOUND_SOC_INTEL_AVS_UTILS_H +#define __SOUND_SOC_INTEL_AVS_UTILS_H + +#include <sound/soc-acpi.h> + +inline bool avs_mach_singular_ssp(struct snd_soc_acpi_mach *mach) +{ + return hweight_long(mach->mach_params.i2s_link_mask) == 1; +} + +inline u32 avs_mach_ssp_port(struct snd_soc_acpi_mach *mach) +{ + return __ffs(mach->mach_params.i2s_link_mask); +} + +inline bool avs_mach_singular_tdm(struct snd_soc_acpi_mach *mach, u32 port) +{ + unsigned long *tdms = mach->pdata; + + return !tdms || (hweight_long(tdms[port]) == 1); +} + +inline u32 avs_mach_ssp_tdm(struct snd_soc_acpi_mach *mach, u32 port) +{ + unsigned long *tdms = mach->pdata; + + return tdms ? __ffs(tdms[port]) : 0; +} + +inline int avs_mach_get_ssp_tdm(struct device *dev, struct snd_soc_acpi_mach *mach, + int *ssp_port, int *tdm_slot) +{ + int port; + + if (!avs_mach_singular_ssp(mach)) { + dev_err(dev, "Invalid SSP configuration\n"); + return -EINVAL; + } + port = avs_mach_ssp_port(mach); + + if (!avs_mach_singular_tdm(mach, port)) { + dev_err(dev, "Invalid TDM configuration\n"); + return -EINVAL; + } + *ssp_port = port; + *tdm_slot = avs_mach_ssp_tdm(mach, *ssp_port); + + return 0; +} + +/* + * Macro to easily generate format strings + */ +#define AVS_STRING_FMT(prefix, suffix, ssp, tdm) \ + (tdm) ? prefix "%d:%d" suffix : prefix "%d" suffix, (ssp), (tdm) + +#endif
On 10/11/2023 2:16 PM, Amadeusz Sławiński wrote:
In quite a few places in code there are checks for number of SSPs present on system, to reduce maintenance burden introduce helper functions allowing to get SSP and TDM from machine board configuration.
Additionally in boards we use SSP and TDM to generate quite a few strings, it could be done like: if (tdms) dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d:%d-Codec", ssp_port, tdm_slot); else dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port);
but quite quickly code ends up with spaghetti of similar if elses. Instead introduce macro which can be used to generate correct string, allowing to minimize code to something like: dl->name = devm_kasprintf(dev, GFP_KERNEL, AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot));
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com
And apparently we didn't catch that functions in header should be static, which leads to linking problems when everything is built-in, I will send v2 tomorrow.
Current mechanism replaces "%d" present in some routes and widget names with SSP number. However there are also configurations which make use of TDM number, in which case expected behavior would be to have string in form of SSP:TDM - see implementation of avs_i2s_platform_register() in sound/soc/intel/avs/pcm.c.
Implement custom function, which parses string and make use of it when parsing topology. While at it make sure that we generate dynamic names only if there is no multiple SSPs or TDMs defined.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/topology.c | 102 ++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 22 deletions(-)
diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c index 45d0eb2a8e71..c74e9d622e4c 100644 --- a/sound/soc/intel/avs/topology.c +++ b/sound/soc/intel/avs/topology.c @@ -15,6 +15,7 @@ #include "avs.h" #include "control.h" #include "topology.h" +#include "utils.h"
/* Get pointer to vendor array at the specified offset. */ #define avs_tplg_vendor_array_at(array, offset) \ @@ -371,22 +372,50 @@ parse_audio_format_bitfield(struct snd_soc_component *comp, void *elem, void *ob return 0; }
+static int avs_ssp_sprint(char *buf, size_t size, const char *fmt, int port, int tdm) +{ + char *needle = strstr(fmt, "%d"); + int retsize; + + /* + * If there is %d present in fmt string it should be replaced by either + * SSP or SSP:TDM, where SSP and TDM are numbers, all other formatting + * will be ignored. + */ + if (needle) { + retsize = scnprintf(buf, min_t(size_t, size, needle - fmt + 1), "%s", fmt); + retsize += scnprintf(buf + retsize, size - retsize, "%d", port); + if (tdm) + retsize += scnprintf(buf + retsize, size - retsize, ":%d", tdm); + retsize += scnprintf(buf + retsize, size - retsize, "%s", needle + 2); + return retsize; + } + + return snprintf(buf, size, "%s", fmt); +} + static int parse_link_formatted_string(struct snd_soc_component *comp, void *elem, void *object, u32 offset) { struct snd_soc_tplg_vendor_string_elem *tuple = elem; struct snd_soc_acpi_mach *mach = dev_get_platdata(comp->card->dev); char *val = (char *)((u8 *)object + offset); + int ssp_port, tdm_slot;
/* * Dynamic naming - string formats, e.g.: ssp%d - supported only for * topologies describing single device e.g.: an I2S codec on SSP0. */ - if (hweight_long(mach->mach_params.i2s_link_mask) != 1) + if (!avs_mach_singular_ssp(mach)) + return avs_parse_string_token(comp, elem, object, offset); + + ssp_port = avs_mach_ssp_port(mach); + if (!avs_mach_singular_tdm(mach, ssp_port)) return avs_parse_string_token(comp, elem, object, offset);
- snprintf(val, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, tuple->string, - __ffs(mach->mach_params.i2s_link_mask)); + tdm_slot = avs_mach_ssp_tdm(mach, ssp_port); + + avs_ssp_sprint(val, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, tuple->string, ssp_port, tdm_slot);
return 0; } @@ -813,6 +842,7 @@ static void assign_copier_gtw_instance(struct snd_soc_component *comp, struct avs_tplg_modcfg_ext *cfg) { struct snd_soc_acpi_mach *mach; + int ssp_port, tdm_slot;
if (!guid_equal(&cfg->type, &AVS_COPIER_MOD_UUID)) return; @@ -826,11 +856,22 @@ assign_copier_gtw_instance(struct snd_soc_component *comp, struct avs_tplg_modcf return; }
+ /* If topology sets value don't overwrite it */ + if (cfg->copier.vindex.i2s.instance) + return; + mach = dev_get_platdata(comp->card->dev);
- /* Automatic assignment only when board describes single SSP. */ - if (hweight_long(mach->mach_params.i2s_link_mask) == 1 && !cfg->copier.vindex.i2s.instance) - cfg->copier.vindex.i2s.instance = __ffs(mach->mach_params.i2s_link_mask); + if (!avs_mach_singular_ssp(mach)) + return; + ssp_port = avs_mach_ssp_port(mach); + + if (!avs_mach_singular_tdm(mach, ssp_port)) + return; + tdm_slot = avs_mach_ssp_tdm(mach, ssp_port); + + cfg->copier.vindex.i2s.instance = ssp_port; + cfg->copier.vindex.i2s.time_slot = tdm_slot; }
static int avs_tplg_parse_modcfg_ext(struct snd_soc_component *comp, @@ -1381,20 +1422,24 @@ static int avs_route_load(struct snd_soc_component *comp, int index, struct snd_soc_acpi_mach *mach = dev_get_platdata(comp->card->dev); size_t len = SNDRV_CTL_ELEM_ID_NAME_MAXLEN; char buf[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; - u32 port; + int ssp_port, tdm_slot;
/* See parse_link_formatted_string() for dynamic naming when(s). */ - if (hweight_long(mach->mach_params.i2s_link_mask) == 1) { - port = __ffs(mach->mach_params.i2s_link_mask); - - snprintf(buf, len, route->source, port); - strscpy((char *)route->source, buf, len); - snprintf(buf, len, route->sink, port); - strscpy((char *)route->sink, buf, len); - if (route->control) { - snprintf(buf, len, route->control, port); - strscpy((char *)route->control, buf, len); - } + if (!avs_mach_singular_ssp(mach)) + return 0; + ssp_port = avs_mach_ssp_port(mach); + + if (!avs_mach_singular_tdm(mach, ssp_port)) + return 0; + tdm_slot = avs_mach_ssp_tdm(mach, ssp_port); + + avs_ssp_sprint(buf, len, route->source, ssp_port, tdm_slot); + strscpy((char *)route->source, buf, len); + avs_ssp_sprint(buf, len, route->sink, ssp_port, tdm_slot); + strscpy((char *)route->sink, buf, len); + if (route->control) { + avs_ssp_sprint(buf, len, route->control, ssp_port, tdm_slot); + strscpy((char *)route->control, buf, len); }
return 0; @@ -1408,6 +1453,7 @@ static int avs_widget_load(struct snd_soc_component *comp, int index, struct avs_tplg_path_template *template; struct avs_soc_component *acomp = to_avs_soc_component(comp); struct avs_tplg *tplg; + int ssp_port, tdm_slot;
if (!le32_to_cpu(dw->priv.size)) return 0; @@ -1419,16 +1465,28 @@ static int avs_widget_load(struct snd_soc_component *comp, int index,
tplg = acomp->tplg; mach = dev_get_platdata(comp->card->dev); + if (!avs_mach_singular_ssp(mach)) + goto static_name; + ssp_port = avs_mach_ssp_port(mach);
/* See parse_link_formatted_string() for dynamic naming when(s). */ - if (hweight_long(mach->mach_params.i2s_link_mask) == 1) { + if (avs_mach_singular_tdm(mach, ssp_port)) { + /* size is based on possible %d -> SSP:TDM, where SSP and TDM < 10 + '\0' */ + size_t size = strlen(dw->name) + 2; + char *buf; + + tdm_slot = avs_mach_ssp_tdm(mach, ssp_port); + + buf = kmalloc(size, GFP_KERNEL); + if (!buf) + return -ENOMEM; + avs_ssp_sprint(buf, size, dw->name, ssp_port, tdm_slot); kfree(w->name); /* w->name is freed later by soc_tplg_dapm_widget_create() */ - w->name = kasprintf(GFP_KERNEL, dw->name, __ffs(mach->mach_params.i2s_link_mask)); - if (!w->name) - return -ENOMEM; + w->name = buf; }
+static_name: template = avs_tplg_path_template_create(comp, tplg, dw->priv.array, le32_to_cpu(dw->priv.size)); if (IS_ERR(template)) {
I2S test board can be used in any SSP and TDM configuration.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/i2s_test.c | 55 ++++++++++++++++++--------- 1 file changed, 38 insertions(+), 17 deletions(-)
diff --git a/sound/soc/intel/avs/boards/i2s_test.c b/sound/soc/intel/avs/boards/i2s_test.c index 1dd0c59a8d91..3d03e1eed3a9 100644 --- a/sound/soc/intel/avs/boards/i2s_test.c +++ b/sound/soc/intel/avs/boards/i2s_test.c @@ -12,9 +12,10 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include <sound/soc-dapm.h> +#include "../utils.h"
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -26,12 +27,14 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); if (!dl->name || !dl->cpus) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs = &snd_soc_dummy_dlc; if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) return -ENOMEM; @@ -51,7 +54,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in return 0; }
-static int avs_create_dapm_routes(struct device *dev, int ssp_port, +static int avs_create_dapm_routes(struct device *dev, int ssp_port, int tdm_slot, struct snd_soc_dapm_route **routes, int *num_routes) { struct snd_soc_dapm_route *dr; @@ -61,13 +64,17 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port, if (!dr) return -ENOMEM;
- dr[0].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%dpb", ssp_port); - dr[0].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Tx", ssp_port); + dr[0].sink = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("ssp", "pb", ssp_port, tdm_slot)); + dr[0].source = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("ssp", " Tx", ssp_port, tdm_slot)); if (!dr[0].sink || !dr[0].source) return -ENOMEM;
- dr[1].sink = devm_kasprintf(dev, GFP_KERNEL, "ssp%d Rx", ssp_port); - dr[1].source = devm_kasprintf(dev, GFP_KERNEL, "ssp%dcp", ssp_port); + dr[1].sink = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("ssp", " Rx", ssp_port, tdm_slot)); + dr[1].source = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("ssp", "cp", ssp_port, tdm_slot)); if (!dr[1].sink || !dr[1].source) return -ENOMEM;
@@ -77,7 +84,7 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port, return 0; }
-static int avs_create_dapm_widgets(struct device *dev, int ssp_port, +static int avs_create_dapm_widgets(struct device *dev, int ssp_port, int tdm_slot, struct snd_soc_dapm_widget **widgets, int *num_widgets) { struct snd_soc_dapm_widget *dw; @@ -89,13 +96,15 @@ static int avs_create_dapm_widgets(struct device *dev, int ssp_port,
dw[0].id = snd_soc_dapm_hp; dw[0].reg = SND_SOC_NOPM; - dw[0].name = devm_kasprintf(dev, GFP_KERNEL, "ssp%dpb", ssp_port); + dw[0].name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("ssp", "pb", ssp_port, tdm_slot)); if (!dw[0].name) return -ENOMEM;
dw[1].id = snd_soc_dapm_mic; dw[1].reg = SND_SOC_NOPM; - dw[1].name = devm_kasprintf(dev, GFP_KERNEL, "ssp%dcp", ssp_port); + dw[1].name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("ssp", "cp", ssp_port, tdm_slot)); if (!dw[1].name) return -ENOMEM;
@@ -115,33 +124,45 @@ static int avs_i2s_test_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; const char *pname; int num_routes, num_widgets; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask); + + if (!avs_mach_singular_ssp(mach)) { + dev_err(dev, "Invalid SSP configuration\n"); + return -EINVAL; + } + ssp_port = avs_mach_ssp_port(mach); + + if (!avs_mach_singular_tdm(mach, ssp_port)) { + dev_err(dev, "Invalid TDM configuration\n"); + return -EINVAL; + } + tdm_slot = avs_mach_ssp_tdm(mach, ssp_port);
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); if (!card) return -ENOMEM;
- card->name = devm_kasprintf(dev, GFP_KERNEL, "ssp%d-loopback", ssp_port); + card->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("ssp", "-loopback", ssp_port, tdm_slot)); if (!card->name) return -ENOMEM;
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d\n", ret); return ret; }
- ret = avs_create_dapm_routes(dev, ssp_port, &routes, &num_routes); + ret = avs_create_dapm_routes(dev, ssp_port, tdm_slot, &routes, &num_routes); if (ret) { dev_err(dev, "Failed to create dapm routes: %d\n", ret); return ret; }
- ret = avs_create_dapm_widgets(dev, ssp_port, &widgets, &num_widgets); + ret = avs_create_dapm_widgets(dev, ssp_port, tdm_slot, &widgets, &num_widgets); if (ret) { dev_err(dev, "Failed to create dapm widgets: %d\n", ret); return ret;
Hi Amadeusz,
kernel test robot noticed the following build errors:
[auto build test ERROR on broonie-sound/for-next] [also build test ERROR on next-20231011] [cannot apply to tiwai-sound/for-next tiwai-sound/for-linus linus/master v6.6-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Amadeusz-S-awi-ski/ASoC-Intel... base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next patch link: https://lore.kernel.org/r/20231011121703.363652-5-amadeuszx.slawinski%40linu... patch subject: [PATCH 04/16] ASoC: Intel: avs: i2s_test: Validate machine board configuration config: powerpc-randconfig-003-20231012 (https://download.01.org/0day-ci/archive/20231012/202310120853.cfVtZkHx-lkp@i...) compiler: powerpc-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231012/202310120853.cfVtZkHx-lkp@i...)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot lkp@intel.com | Closes: https://lore.kernel.org/oe-kbuild-all/202310120853.cfVtZkHx-lkp@intel.com/
All errors (new ones prefixed by >>):
powerpc-linux-ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_singular_ssp':
i2s_test.c:(.text+0x0): multiple definition of `avs_mach_singular_ssp'; sound/soc/intel/avs/topology.o:topology.c:(.text+0x1e80): first defined here
powerpc-linux-ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_ssp_port':
i2s_test.c:(.text+0x44): multiple definition of `avs_mach_ssp_port'; sound/soc/intel/avs/topology.o:topology.c:(.text+0x1ec4): first defined here
powerpc-linux-ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_singular_tdm':
i2s_test.c:(.text+0x88): multiple definition of `avs_mach_singular_tdm'; sound/soc/intel/avs/topology.o:topology.c:(.text+0x1f08): first defined here
powerpc-linux-ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_ssp_tdm':
i2s_test.c:(.text+0x8c8): multiple definition of `avs_mach_ssp_tdm'; sound/soc/intel/avs/topology.o:topology.c:(.text+0x3214): first defined here
powerpc-linux-ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_get_ssp_tdm':
i2s_test.c:(.text+0x938): multiple definition of `avs_mach_get_ssp_tdm'; sound/soc/intel/avs/topology.o:topology.c:(.text+0x3284): first defined here
Hi Amadeusz,
kernel test robot noticed the following build errors:
[auto build test ERROR on broonie-sound/for-next] [also build test ERROR on next-20231011] [cannot apply to tiwai-sound/for-next tiwai-sound/for-linus linus/master v6.6-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Amadeusz-S-awi-ski/ASoC-Intel... base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next patch link: https://lore.kernel.org/r/20231011121703.363652-5-amadeuszx.slawinski%40linu... patch subject: [PATCH 04/16] ASoC: Intel: avs: i2s_test: Validate machine board configuration config: x86_64-randconfig-002-20231011 (https://download.01.org/0day-ci/archive/20231012/202310120938.yY6jJXJE-lkp@i...) compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231012/202310120938.yY6jJXJE-lkp@i...)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot lkp@intel.com | Closes: https://lore.kernel.org/oe-kbuild-all/202310120938.yY6jJXJE-lkp@intel.com/
All errors (new ones prefixed by >>):
ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_singular_ssp':
sound/soc/intel/avs/boards/../utils.h:16: multiple definition of `avs_mach_singular_ssp'; sound/soc/intel/avs/topology.o:sound/soc/intel/avs/utils.h:16: first defined here
ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_ssp_port':
sound/soc/intel/avs/boards/../utils.h:21: multiple definition of `avs_mach_ssp_port'; sound/soc/intel/avs/topology.o:sound/soc/intel/avs/utils.h:21: first defined here
ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_singular_tdm':
sound/soc/intel/avs/boards/../utils.h:26: multiple definition of `avs_mach_singular_tdm'; sound/soc/intel/avs/topology.o:sound/soc/intel/avs/utils.h:26: first defined here
ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_ssp_tdm':
sound/soc/intel/avs/boards/../utils.h:33: multiple definition of `avs_mach_ssp_tdm'; sound/soc/intel/avs/topology.o:sound/soc/intel/avs/utils.h:33: first defined here
ld: sound/soc/intel/avs/boards/i2s_test.o: in function `avs_mach_get_ssp_tdm':
sound/soc/intel/avs/boards/../utils.h:40: multiple definition of `avs_mach_get_ssp_tdm'; sound/soc/intel/avs/topology.o:sound/soc/intel/avs/utils.h:40: first defined here
vim +16 sound/soc/intel/avs/boards/../utils.h
4251ca5fe7340a Amadeusz Sławiński 2023-10-11 13 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 14 inline bool avs_mach_singular_ssp(struct snd_soc_acpi_mach *mach) 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 15 { 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 @16 return hweight_long(mach->mach_params.i2s_link_mask) == 1; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 17 } 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 18 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 19 inline u32 avs_mach_ssp_port(struct snd_soc_acpi_mach *mach) 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 20 { 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 @21 return __ffs(mach->mach_params.i2s_link_mask); 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 22 } 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 23 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 24 inline bool avs_mach_singular_tdm(struct snd_soc_acpi_mach *mach, u32 port) 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 25 { 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 @26 unsigned long *tdms = mach->pdata; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 27 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 28 return !tdms || (hweight_long(tdms[port]) == 1); 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 29 } 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 30 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 31 inline u32 avs_mach_ssp_tdm(struct snd_soc_acpi_mach *mach, u32 port) 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 32 { 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 @33 unsigned long *tdms = mach->pdata; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 34 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 35 return tdms ? __ffs(tdms[port]) : 0; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 36 } 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 37 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 38 inline int avs_mach_get_ssp_tdm(struct device *dev, struct snd_soc_acpi_mach *mach, 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 39 int *ssp_port, int *tdm_slot) 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 @40 { 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 41 int port; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 42 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 43 if (!avs_mach_singular_ssp(mach)) { 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 44 dev_err(dev, "Invalid SSP configuration\n"); 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 45 return -EINVAL; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 46 } 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 47 port = avs_mach_ssp_port(mach); 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 48 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 49 if (!avs_mach_singular_tdm(mach, port)) { 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 50 dev_err(dev, "Invalid TDM configuration\n"); 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 51 return -EINVAL; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 52 } 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 53 *ssp_port = port; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 54 *tdm_slot = avs_mach_ssp_tdm(mach, *ssp_port); 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 55 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 56 return 0; 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 57 } 4251ca5fe7340a Amadeusz Sławiński 2023-10-11 58
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt274.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt274.c b/sound/soc/intel/avs/boards/rt274.c index b376d4c2d706..157183b1de24 100644 --- a/sound/soc/intel/avs/boards/rt274.c +++ b/sound/soc/intel/avs/boards/rt274.c @@ -13,6 +13,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include "../../../codecs/rt274.h" +#include "../utils.h"
#define AVS_RT274_FREQ_OUT 24000000 #define AVS_RT274_BE_FIXUP_RATE 48000 @@ -145,7 +146,7 @@ static int avs_rt274_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pc }
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -157,13 +158,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT34C2:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT274_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -211,13 +214,16 @@ static int avs_rt274_probe(struct platform_device *pdev) struct snd_soc_jack *jack; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt5682.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt5682.c b/sound/soc/intel/avs/boards/rt5682.c index f1c46c6abd9d..84e850c0b085 100644 --- a/sound/soc/intel/avs/boards/rt5682.c +++ b/sound/soc/intel/avs/boards/rt5682.c @@ -21,6 +21,7 @@ #include <sound/soc-acpi.h> #include "../../common/soc-intel-quirks.h" #include "../../../codecs/rt5682.h" +#include "../utils.h"
#define AVS_RT5682_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) #define AVS_RT5682_SSP_CODEC_MASK (GENMASK(2, 0)) @@ -203,7 +204,7 @@ avs_rt5682_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_param }
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -215,13 +216,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-10EC5682:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, AVS_RT5682_CODEC_DAI_NAME); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -270,7 +273,7 @@ static int avs_rt5682_probe(struct platform_device *pdev) struct snd_soc_jack *jack; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
if (pdev->id_entry && pdev->id_entry->driver_data) avs_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data; @@ -280,9 +283,12 @@ static int avs_rt5682_probe(struct platform_device *pdev)
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/max98357a.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/max98357a.c b/sound/soc/intel/avs/boards/max98357a.c index b9b20562c691..6ba7b6564279 100644 --- a/sound/soc/intel/avs/boards/max98357a.c +++ b/sound/soc/intel/avs/boards/max98357a.c @@ -12,6 +12,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include <sound/soc-dapm.h> +#include "../utils.h"
static const struct snd_kcontrol_new card_controls[] = { SOC_DAPM_PIN_SWITCH("Spk"), @@ -46,7 +47,7 @@ avs_max98357a_be_fixup(struct snd_soc_pcm_runtime *runrime, struct snd_pcm_hw_pa }
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -58,13 +59,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "MX98357A:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "HiFi"); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -93,13 +96,16 @@ static int avs_max98357a_probe(struct platform_device *pdev) struct snd_soc_card *card; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt298.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt298.c b/sound/soc/intel/avs/boards/rt298.c index 3cd8057f0ed6..ea32a7690c8a 100644 --- a/sound/soc/intel/avs/boards/rt298.c +++ b/sound/soc/intel/avs/boards/rt298.c @@ -14,6 +14,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include "../../../codecs/rt298.h" +#include "../utils.h"
#define RT298_CODEC_DAI "rt298-aif1"
@@ -131,7 +132,7 @@ static const struct snd_soc_ops avs_rt298_ops = { };
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -143,13 +144,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343A:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT298_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -201,13 +204,16 @@ static int avs_rt298_probe(struct platform_device *pdev) struct snd_soc_jack *jack; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/da7219.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/sound/soc/intel/avs/boards/da7219.c b/sound/soc/intel/avs/boards/da7219.c index 2059d6156738..6060894954df 100644 --- a/sound/soc/intel/avs/boards/da7219.c +++ b/sound/soc/intel/avs/boards/da7219.c @@ -16,6 +16,7 @@ #include <sound/soc-dapm.h> #include <uapi/linux/input-event-codes.h> #include "../../../codecs/da7219.h" +#include "../utils.h"
#define DA7219_DAI_NAME "da7219-hifi"
@@ -164,7 +165,7 @@ avs_da7219_be_fixup(struct snd_soc_pcm_runtime *runrime, struct snd_pcm_hw_param }
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -177,12 +178,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in platform->name = platform_name;
dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-DLGS7219:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, DA7219_DAI_NAME); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -230,13 +234,16 @@ static int avs_da7219_probe(struct platform_device *pdev) struct snd_soc_jack *jack; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/es8336.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/es8336.c b/sound/soc/intel/avs/boards/es8336.c index 6d2a7c8e445e..f972ef64d284 100644 --- a/sound/soc/intel/avs/boards/es8336.c +++ b/sound/soc/intel/avs/boards/es8336.c @@ -19,6 +19,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include <asm/intel-family.h> +#include "../utils.h"
#define ES8336_CODEC_DAI "ES8316 HiFi"
@@ -194,7 +195,7 @@ static int avs_es8336_be_fixup(struct snd_soc_pcm_runtime *runtime, return 0; } static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -206,13 +207,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-ESSX8336:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, ES8336_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -261,13 +264,16 @@ static int avs_es8336_probe(struct platform_device *pdev) struct snd_soc_card *card; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/max98373.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/max98373.c b/sound/soc/intel/avs/boards/max98373.c index 7820435e3a53..cc7dfdf72083 100644 --- a/sound/soc/intel/avs/boards/max98373.c +++ b/sound/soc/intel/avs/boards/max98373.c @@ -12,6 +12,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include <sound/soc-dapm.h> +#include "../utils.h"
#define MAX98373_DEV0_NAME "i2c-MX98373:00" #define MAX98373_DEV1_NAME "i2c-MX98373:01" @@ -95,7 +96,7 @@ static const struct snd_soc_ops avs_max98373_ops = { };
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -107,13 +108,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs[0].name = devm_kasprintf(dev, GFP_KERNEL, MAX98373_DEV0_NAME); dl->codecs[0].dai_name = devm_kasprintf(dev, GFP_KERNEL, MAX98373_CODEC_NAME); dl->codecs[1].name = devm_kasprintf(dev, GFP_KERNEL, MAX98373_DEV1_NAME); @@ -148,13 +151,16 @@ static int avs_max98373_probe(struct platform_device *pdev) struct snd_soc_card *card; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/max98927.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/max98927.c b/sound/soc/intel/avs/boards/max98927.c index ae465b231249..fb0175f37d61 100644 --- a/sound/soc/intel/avs/boards/max98927.c +++ b/sound/soc/intel/avs/boards/max98927.c @@ -12,6 +12,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include <sound/soc-dapm.h> +#include "../utils.h"
#define MAX98927_DEV0_NAME "i2c-MX98927:00" #define MAX98927_DEV1_NAME "i2c-MX98927:01" @@ -92,7 +93,7 @@ static const struct snd_soc_ops avs_max98927_ops = { };
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -104,13 +105,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs[0].name = devm_kasprintf(dev, GFP_KERNEL, MAX98927_DEV0_NAME); dl->codecs[0].dai_name = devm_kasprintf(dev, GFP_KERNEL, MAX98927_CODEC_NAME); dl->codecs[1].name = devm_kasprintf(dev, GFP_KERNEL, MAX98927_DEV1_NAME); @@ -145,13 +148,16 @@ static int avs_max98927_probe(struct platform_device *pdev) struct snd_soc_card *card; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/nau8825.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/nau8825.c b/sound/soc/intel/avs/boards/nau8825.c index 9f15b22a3c3f..d98b5deb78c9 100644 --- a/sound/soc/intel/avs/boards/nau8825.c +++ b/sound/soc/intel/avs/boards/nau8825.c @@ -16,6 +16,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include "../../../codecs/nau8825.h" +#include "../utils.h"
#define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
@@ -171,7 +172,7 @@ static const struct snd_soc_ops avs_nau8825_ops = { };
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -183,13 +184,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-10508825:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, SKL_NUVOTON_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -248,13 +251,16 @@ static int avs_nau8825_probe(struct platform_device *pdev) struct snd_soc_jack *jack; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt286.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt286.c b/sound/soc/intel/avs/boards/rt286.c index 36da0578d5b4..131237471e3e 100644 --- a/sound/soc/intel/avs/boards/rt286.c +++ b/sound/soc/intel/avs/boards/rt286.c @@ -13,6 +13,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include "../../../codecs/rt286.h" +#include "../utils.h"
#define RT286_CODEC_DAI "rt286-aif1"
@@ -114,7 +115,7 @@ static const struct snd_soc_ops avs_rt286_ops = { };
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -126,13 +127,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343A:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT286_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -181,13 +184,17 @@ static int avs_rt286_probe(struct platform_device *pdev) struct snd_soc_jack *jack; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); + if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt5663.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt5663.c b/sound/soc/intel/avs/boards/rt5663.c index 2e84bd629766..3effd789a45e 100644 --- a/sound/soc/intel/avs/boards/rt5663.c +++ b/sound/soc/intel/avs/boards/rt5663.c @@ -15,6 +15,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include "../../../codecs/rt5663.h" +#include "../utils.h"
#define RT5663_CODEC_DAI "rt5663-aif"
@@ -133,7 +134,7 @@ static const struct snd_soc_ops avs_rt5663_ops = {
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -145,13 +146,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-10EC5663:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT5663_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -200,13 +203,16 @@ static int avs_rt5663_probe(struct platform_device *pdev) struct rt5663_private *priv; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
Allow for board to be used with TDMs.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/ssm4567.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/avs/boards/ssm4567.c b/sound/soc/intel/avs/boards/ssm4567.c index 27eca051122d..6bcab9deae5c 100644 --- a/sound/soc/intel/avs/boards/ssm4567.c +++ b/sound/soc/intel/avs/boards/ssm4567.c @@ -14,6 +14,7 @@ #include <sound/soc.h> #include <sound/soc-acpi.h> #include "../../../codecs/nau8825.h" +#include "../utils.h"
#define SKL_SSM_CODEC_DAI "ssm4567-hifi"
@@ -83,7 +84,7 @@ avs_ssm4567_be_fixup(struct snd_soc_pcm_runtime *runrime, struct snd_pcm_hw_para }
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -95,13 +96,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
platform->name = platform_name;
- dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM;
- dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs[0].name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343B:00"); dl->codecs[0].dai_name = devm_kasprintf(dev, GFP_KERNEL, "ssm4567-hifi"); dl->codecs[1].name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343B:01"); @@ -136,13 +139,16 @@ static int avs_ssm4567_probe(struct platform_device *pdev) struct snd_soc_card *card; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask);
- ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;
participants (2)
-
Amadeusz Sławiński
-
kernel test robot