From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
Vinod Koul <vkoul@kernel.org>,
Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: 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>,
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: Re: [RFC PATCH 0/2] soundwire: multi-direction stream API
Date: Tue, 1 Dec 2026 23:36:48 +0000 [thread overview]
Message-ID: <1dbe1208-dd21-42be-a005-f2cf4744e12f@oss.qualcomm.com> (raw)
In-Reply-To: <15407490-13c6-432a-80f6-ceb8acf5112f@linux.dev>
On 12/1/26 4:44 PM, Pierre-Louis Bossart wrote:
>
>
> On 11/30/26 11:40 PM, Srinivas Kandagatla wrote:
>> 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.
>
> Thanks for starting this!
>
>> 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).
>
> Humm, maybe before we start looking further, can you clarify if the
> feedback has the same format as the playback PCM? I vaguely recall that
> some amplifiers use custom formats, e.g. 10bits, for IV sense. The
> resolution doesn't need to be as precise as for PCM, does it?
For dai links with multi-direction flag there is a fixup callback where
we set the format constriants for VI in our speaker protection dai-link.
>
> I initially thought that we could combine all ports for all
> 'constituents', but if they transport different data formats we do have
> to stick with the rule 'one stream - one data format'.
Not necessarly because the format for codec-to-codec like in this case
is not necessarily same, VI module only supports fixed format.
>
> The second question is whether the goal is to only deal with the
> direction problem, or if we want a way to 'link' or 'bind' data streams
> that need to be prepared together and later activated together. In that
> case you could simplify the API to 'sdw_multi_stream' and forget about
> the direction?
Its both. That is good idea.
>
> The feedback in your example does flow in the opposite direction, but
> for companion amps the data comes from the main amp. SDCA also has a
> concept of a DSP-generated 'enhancement' stream that would flow in
> parallel to the main playback stream.
>
That should not matter I guess, in that case codec-codec without any
multi-direction flag should work.
> One important point is also that the concept of multiple streams is
> 'hidden' below the ASoC dailink level, where I don't think we can work-
> around the direction. This API would only be for low-level data that is
> not exposed to userspace, ever.
correct.
IOW the Linux drivers would provide
> configuration capability but no PCM devices/DMA support for those
> auxiliary streams.
true.
>
>> 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.
>
> sorry, I am confused by the prepare/enable notation. Did you mean that
this notion is exactly same as what we have with single stream.
> all streams are prepared in all-or-nothing manner, and separately that
> the enable is also all-or-nothing? we're not combining prepare and
> enable, are we?
>
> edit: the patch2 does suggest combining prepare and enable in the same
> routine, that's how I understand
that is how qcom side is implemented i guess, that does not mean that it
has to be done together.
> qcom_snd_sdw_build_multi_direction_stream()
> This isn't how the Intel/AMD implementations work, see sound/soc/
> sdw_utils/soc_sdw_utils.c. There are different callbacks for prepare and
> trigger, not sure how they could ever be combined.
>> 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.
>
> I think you mean that all 'constituents' of a multi_stream would start
> at the same time on the same frame boundary?
Yes.
>
> I wonder how difficult that would be - in theory it's a broadcast write
> command that doesn't depend on the number of ports, directions or
> configuration.
>
> One could push-back and argue that a single bank switch isn't really
> needed, given the internal delays inside the peripherals and the lower
> resolution of those additional data streams. Another point is that no
> one will have a test rig to check if the synchronous start is actually
> happening.
>
> Ironically I think the prepare case is more complicated. One could have
> a first pass to configure the bandwidth needs for the regular stream,
> then a second pass for the next constituent. If that requires a clock
> scaling or the use of another data lane this could be interesting to
> unroll.
>
> At any rate, this is a very interesting extension indeed, thanks again
> for starting this thread.
>
prev parent reply other threads:[~2026-12-01 23:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 22:40 Srinivas Kandagatla
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 [this message]
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=1dbe1208-dd21-42be-a005-f2cf4744e12f@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®