Skip to content

Commit e9436dd

Browse files
bardliaosmb49
authored andcommitted
ASoC: SOF: ipc3-topology: Convert the topology pin index to ALH dai index
BugLink: https://bugs.launchpad.net/bugs/2102118 [ Upstream commit e9db1b551774037ebe39dde4a658d89ba95e260b ] Intel SoundWire machine driver always uses Pin number 2 and above. Currently, the pin number is used as the FW DAI index directly. As a result, FW DAI 0 and 1 are never used. That worked fine because we use up to 2 DAIs in a SDW link. Convert the topology pin index to ALH dai index, the mapping is using 2-off indexing, iow, pin #2 is ALH dai #0. The issue exists since beginning. And the Fixes tag is the first commit that this commit can be applied. Fixes: b66bfc3 ("ASoC: SOF: sof-audio: Fix broken early bclk feature for SSP") Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://patch.msgid.link/20241127092955.20026-1-yung-chuan.liao@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 647535d commit e9436dd

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

sound/soc/sof/ipc3-topology.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
/* size of tplg ABI in bytes */
2121
#define SOF_IPC3_TPLG_ABI_SIZE 3
2222

23+
/* Base of SOF_DAI_INTEL_ALH, this should be aligned with SOC_SDW_INTEL_BIDIR_PDI_BASE */
24+
#define INTEL_ALH_DAI_INDEX_BASE 2
25+
2326
struct sof_widget_data {
2427
int ctrl_type;
2528
int ipc_cmd;
@@ -1557,6 +1560,17 @@ static int sof_ipc3_widget_setup_comp_dai(struct snd_sof_widget *swidget)
15571560
if (ret < 0)
15581561
goto free;
15591562

1563+
/* Subtract the base to match the FW dai index. */
1564+
if (comp_dai->type == SOF_DAI_INTEL_ALH) {
1565+
if (comp_dai->dai_index < INTEL_ALH_DAI_INDEX_BASE) {
1566+
dev_err(sdev->dev,
1567+
"Invalid ALH dai index %d, only Pin numbers >= %d can be used\n",
1568+
comp_dai->dai_index, INTEL_ALH_DAI_INDEX_BASE);
1569+
return -EINVAL;
1570+
}
1571+
comp_dai->dai_index -= INTEL_ALH_DAI_INDEX_BASE;
1572+
}
1573+
15601574
dev_dbg(scomp->dev, "dai %s: type %d index %d\n",
15611575
swidget->widget->name, comp_dai->type, comp_dai->dai_index);
15621576
sof_dbg_comp_config(scomp, &comp_dai->config);
@@ -2127,8 +2141,16 @@ static int sof_ipc3_dai_config(struct snd_sof_dev *sdev, struct snd_sof_widget *
21272141
case SOF_DAI_INTEL_ALH:
21282142
if (data) {
21292143
/* save the dai_index during hw_params and reuse it for hw_free */
2130-
if (flags & SOF_DAI_CONFIG_FLAGS_HW_PARAMS)
2131-
config->dai_index = data->dai_index;
2144+
if (flags & SOF_DAI_CONFIG_FLAGS_HW_PARAMS) {
2145+
/* Subtract the base to match the FW dai index. */
2146+
if (data->dai_index < INTEL_ALH_DAI_INDEX_BASE) {
2147+
dev_err(sdev->dev,
2148+
"Invalid ALH dai index %d, only Pin numbers >= %d can be used\n",
2149+
config->dai_index, INTEL_ALH_DAI_INDEX_BASE);
2150+
return -EINVAL;
2151+
}
2152+
config->dai_index = data->dai_index - INTEL_ALH_DAI_INDEX_BASE;
2153+
}
21322154
config->alh.stream_id = data->dai_data;
21332155
}
21342156
break;

0 commit comments

Comments
 (0)