From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org, chao.song@linux.intel.com
Cc: alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com,
pierre-louis.bossart@linux.intel.com, rander.wang@intel.com,
ranjani.sridharan@linux.intel.com,
yung-chuan.liao@linux.intel.com
Subject: [PATCH 1/3] ASoC: SOF: Add support for parsing the number of sink/source pins
Date: Mon, 7 Nov 2022 10:57:04 +0200 [thread overview]
Message-ID: <20221107085706.2550-2-peter.ujfalusi@linux.intel.com> (raw)
In-Reply-To: <20221107085706.2550-1-peter.ujfalusi@linux.intel.com>
From: Chao Song <chao.song@linux.intel.com>
Add support for parsing the number of sink/source pins
per widget from topology. They will be used to determine
the sink/source queue IDs during widget binding.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Chao Song <chao.song@linux.intel.com>
Suggested-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
include/uapi/sound/sof/tokens.h | 2 ++
sound/soc/sof/sof-audio.h | 15 +++++++++++++++
sound/soc/sof/topology.c | 33 +++++++++++++++++++++++++++++----
3 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h
index 5caf75cadaf8..4f4881850650 100644
--- a/include/uapi/sound/sof/tokens.h
+++ b/include/uapi/sound/sof/tokens.h
@@ -88,6 +88,8 @@
#define SOF_TKN_COMP_CPC 406
#define SOF_TKN_COMP_IS_PAGES 409
#define SOF_TKN_COMP_NUM_AUDIO_FORMATS 410
+#define SOF_TKN_COMP_NUM_SINK_PINS 411
+#define SOF_TKN_COMP_NUM_SOURCE_PINS 412
/* SSP */
#define SOF_TKN_INTEL_SSP_CLKS_CONTROL 500
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
index 4284ea2f3a1f..dfca713f00df 100644
--- a/sound/soc/sof/sof-audio.h
+++ b/sound/soc/sof/sof-audio.h
@@ -23,6 +23,13 @@
#define SOF_AUDIO_PCM_DRV_NAME "sof-audio-component"
+/*
+ * The ipc4 firmware only supports up to 8 sink or source pins
+ * per widget, because only 3 bits are used for queue(pin) ID
+ * in ipc4 protocol.
+ */
+#define SOF_WIDGET_MAX_NUM_PINS 8
+
/* max number of FE PCMs before BEs */
#define SOF_BE_PCM_BASE 16
@@ -387,6 +394,14 @@ struct snd_sof_widget {
int num_tuples;
struct snd_sof_tuple *tuples;
+ /*
+ * The allowed range for num_sink/source_pins is [0, SOF_WIDGET_MAX_NUM_PINS].
+ * Widgets may have zero sink or source pins, for example the tone widget has
+ * zero sink pins.
+ */
+ u32 num_sink_pins;
+ u32 num_source_pins;
+
void *private; /* core does not touch this */
};
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 38855dd60617..e839fcdc938b 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -392,6 +392,13 @@ static const struct sof_topology_token led_tokens[] = {
offsetof(struct snd_sof_led_control, direction)},
};
+static const struct sof_topology_token comp_pin_tokens[] = {
+ {SOF_TKN_COMP_NUM_SINK_PINS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
+ offsetof(struct snd_sof_widget, num_sink_pins)},
+ {SOF_TKN_COMP_NUM_SOURCE_PINS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
+ offsetof(struct snd_sof_widget, num_source_pins)},
+};
+
/**
* sof_parse_uuid_tokens - Parse multiple sets of UUID tokens
* @scomp: pointer to soc component
@@ -1259,6 +1266,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg;
const struct sof_ipc_tplg_widget_ops *widget_ops = ipc_tplg_ops->widget;
+ struct snd_soc_tplg_private *priv = &tw->priv;
struct snd_sof_widget *swidget;
struct snd_sof_dai *dai;
enum sof_tokens *token_list;
@@ -1277,10 +1285,27 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
swidget->pipeline_id = index;
swidget->private = NULL;
- dev_dbg(scomp->dev, "tplg: ready widget id %d pipe %d type %d name : %s stream %s\n",
- swidget->comp_id, index, swidget->id, tw->name,
- strnlen(tw->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0
- ? tw->sname : "none");
+ ret = sof_parse_tokens(scomp, swidget, comp_pin_tokens,
+ ARRAY_SIZE(comp_pin_tokens), priv->array,
+ le32_to_cpu(priv->size));
+ if (ret < 0) {
+ dev_err(scomp->dev, "failed to parse component pin tokens for %s\n",
+ w->name);
+ return ret;
+ }
+
+ if (swidget->num_sink_pins > SOF_WIDGET_MAX_NUM_PINS ||
+ swidget->num_source_pins > SOF_WIDGET_MAX_NUM_PINS) {
+ dev_err(scomp->dev, "invalid pins for %s: [sink: %d, src: %d]\n",
+ swidget->widget->name, swidget->num_sink_pins, swidget->num_source_pins);
+ return -EINVAL;
+ }
+
+ dev_dbg(scomp->dev,
+ "tplg: widget %d (%s) is ready [type: %d, pipe: %d, pins: %d / %d, stream: %s]\n",
+ swidget->comp_id, w->name, swidget->id, index,
+ swidget->num_sink_pins, swidget->num_source_pins,
+ strnlen(w->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0 ? w->sname : "none");
token_list = widget_ops[w->id].token_list;
token_list_size = widget_ops[w->id].token_list_size;
--
2.38.1
next prev parent reply other threads:[~2022-11-07 8:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 8:57 [PATCH 0/3] ASoC: SOF: ipc4-topology: Add widget queue support Peter Ujfalusi
2022-11-07 8:57 ` Peter Ujfalusi [this message]
2022-11-07 8:57 ` [PATCH 2/3] ASoC: SOF: Add support to parse pin binding array from topology Peter Ujfalusi
2022-11-07 8:57 ` [PATCH 3/3] ASoC: SOF: topology: Add helper to get/put widget queue id Peter Ujfalusi
2022-11-10 17:55 ` [PATCH 0/3] ASoC: SOF: ipc4-topology: Add widget queue support Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221107085706.2550-2-peter.ujfalusi@linux.intel.com \
--to=peter.ujfalusi@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=chao.song@linux.intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rander.wang@intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox