From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
To: Vinod Koul <vkoul@kernel.org>,
Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
Sanyog Kale <sanyog.r.kale@intel.com>,
Mark Brown <broonie@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>,
alsa-devel@alsa-project.org, linux-sound@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH 0/2] soundwire: multi-direction stream API
Date: Mon, 30 Nov 2026 22:40:16 +0000 [thread overview]
Message-ID: <20261130224018.20359-1-srinivas.kandagatla@oss.qualcomm.com> (raw)
During Speaker Protection patches for Qualcomm SoCs, Pierre suggested
that we should add support to multi-direction in sdw_stream.
This patchset is to start that discussion on how these apis should look
like.
Some SoundWire codec-codec links drive more than one direction on the
same BE and the two directions are coupled on the bus: they share a
bring-up sequence and want to fail or succeed together. The first
in-tree case is WSA playback plus V/I-sense feedback on the same BE
(DSP speaker protection and thermal/excursion feedback).
Today callers like sound/soc/qcom/sdw.c hand-roll that: call
sdw_prepare_stream() / sdw_enable_stream() per direction, open-code
rollback when the second direction fails. The branching lives in
every driver that wants a multi-direction codec-codec link.
-- DO NOT APPLY THIS PATCH ---
This RFC proposes a small first-class object for the concept, so the
coupling is expressed in the type rather than left to caller
discipline:
struct sdw_multi_direction_stream;
void sdw_multi_direction_stream_init (struct sdw_multi_direction_stream *md,
const char *name);
struct sdw_multi_direction_stream *
sdw_multi_direction_stream_alloc (const char *name);
void sdw_multi_direction_stream_release(struct sdw_multi_direction_stream *md);
int sdw_multi_direction_stream_add (struct sdw_multi_direction_stream *md,
struct sdw_stream_runtime *stream);
int sdw_prepare_multi_direction_stream (struct sdw_multi_direction_stream *md);
int sdw_enable_multi_direction_stream (struct sdw_multi_direction_stream *md);
int sdw_disable_multi_direction_stream (struct sdw_multi_direction_stream *md);
int sdw_deprepare_multi_direction_stream(struct sdw_multi_direction_stream *md);
A group with one constituent behaves exactly like calling the matching
sdw_prepare_stream() / ... directly, so callers can use this
unconditionally instead of branching on dai_link->multi_direction_codecs.
prepare/enable do all-or-nothing rollback: on failure at step N the
earlier streams are torn down in reverse order. disable/deprepare are
best-effort (first error returned, all entries walked) so the bus
always ends up quiesced.
sdw_multi_direction_stream_init() exists for callers that want to
embed the handle in their own state (dai_link drvdata) and avoid any
allocation on the PCM hot path; _alloc() is kept for callers that
prefer a heap handle. Both expose the same lifecycle entry points.
Patch 2 illustrates the shape at the call site by converting
sound/soc/qcom/sdw.c. qcom_snd_sdw_prepare() and _hw_free() lose their
hand-rolled rollback and funnel single-direction and multi-direction
links through the same code. Patch 2 depends on the WSA
speaker-protection series for the multi_direction_codecs dai_link
flag; it is included here to validate the API shape and is not
intended to land through the SoundWire tree.
Open questions
--------------
1. Future: coalescing the bank switch.
2. SDW_MULTI_DIRECTION_STREAM_MAX is set to 4 - comfortably covers
WSA+VI (2) and leaves headroom for future TX+RX+companion-amp
topologies. Let me know if a different ceiling or a growable
backing array is preferred.
3. Bank switching.
Build-tested and exercised on Qualcomm X1E (Glymur CRD) and Lenovo
ThinkPad T14s Gen 7 with the WSA speaker-protection series, which
is the first in-tree user of a multi-direction codec-codec link.
Srinivas Kandagatla (2):
soundwire: stream: add multi-direction stream lifecycle API
ASoC: qcom: sdw: use multi-direction stream lifecycle for
prepare/hw_free
Documentation/driver-api/soundwire/stream.rst | 50 +++++
drivers/soundwire/stream.c | 202 ++++++++++++++++++
include/linux/soundwire/sdw.h | 39 ++++
sound/soc/qcom/sdw.c | 113 +++++-----
4 files changed, 353 insertions(+), 51 deletions(-)
base-commit: 253f86660c1f882fbf554db5eaa34bc5d66dc7e8
--
2.53.0
next reply other threads:[~2026-11-30 22:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 22:40 Srinivas Kandagatla [this message]
2026-11-30 22:40 ` [PATCH] soundwire: stream: add multi-direction stream lifecycle API Srinivas Kandagatla
2026-11-30 23:24 ` Randy Dunlap
2026-11-30 22:40 ` [RFC PATCH 2/2] ASoC: qcom: sdw: use multi-direction stream lifecycle for prepare/hw_free Srinivas Kandagatla
2026-12-01 16:44 ` [RFC PATCH 0/2] soundwire: multi-direction stream API Pierre-Louis Bossart
2026-12-01 23:36 ` Srinivas Kandagatla
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=20261130224018.20359-1-srinivas.kandagatla@oss.qualcomm.com \
--to=srinivas.kandagatla@oss.qualcomm.com \
--cc=alsa-devel@alsa-project.org \
--cc=andersson@kernel.org \
--cc=broonie@kernel.org \
--cc=corbet@lwn.net \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=pierre-louis.bossart@linux.dev \
--cc=sanyog.r.kale@intel.com \
--cc=vkoul@kernel.org \
--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
all inboxes | Powered by JetHome®