From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796146277; b=zhHtnpyvE8Pn5DzVkaUilLfP0ED0NKxfe6fa5+bXsRULpk224Lw6posoNiDEA0DXilfs U6G4VUG+hZEw5Bv253DshvfbE94xmjoqN4GW/x0cJ4VvbHZFhlngymrgmOaRcdqXWncHQ Gn2JiT7rHfRCq9R5gwRK/bmo660mwGvuQx+BuKaIVbKeocK6fLSqz/7Tm7wMyt0wKVIJN b+EYo7labtJwhKG+cA+OG8TViajR04j4LBbiPQ7Wn7gpEcDurxinq2vxOX/RUhTbfL4Ca KTXN6GmlHkeUQSiYj0s0Px6YIXixtFbA+W83qi1xQ0wro9PJxyEcitky3vdRtpMD1HA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146277; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:Content-Language:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=6erbuMEgqp6DZ1WsNEykCbs4XsenWbKp5Fn26anOU84=; b=2zuKfT9vJtlKxqiPFwJmAT3nXcf0iy8PtZitKLClEJCLyjETWlbO3hk+SYjxOGmL4Uhp +nyhQIInUvZzUCppSOd3qliGFgK450NX0h/HRK4uq4dcTz57SpTvVKQaOPfi5hjPv70tS +14rZGQAsy+fgaPt4vjwZBHxeBZWOb0FTAcXQ+2VzaYFQUW7nC9DLZBlYbYcyLAt6866o 9fN9SfeDPWJTAFrGg0eCW8oX61de09PHTiJLZM8OL7vro3llleXciOknCZ/95Nush3jl+ 0k+ZXGzso6Yhj76nq5rs+aNywx4cDQjTbTHUrDVAfSLOct3o1vYyTeeTWndeaZ7gCcg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Yl1avfmB; arc=none smtp.remote-ip=91.218.175.172 Received: from mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7507D606A322 for ; Tue, 1 Dec 2026 17:31:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7507D606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Yl1avfmB X-Envelope-To: linux-doc@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=kYgEaFgrXQALnqHRmB2j7y9KGx6cW+eq5wmHjejoTTo=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796146274; v=1; x=1796751074; b=Yl1avfmBE+l3mJOWhJ9j6YBX7Gsz4FR4aLTKHWlmwwujXMLEx6AHOrLKboV5wyWTj6cJnecZ tkrMSoKJUawrYR6PQFfKFJeWNQbPcR96rYwHwGJZyt6iE6oOl1jJRhl8KUP9+vtird6wmje5GSW eMAdyDUt1TgQbeQ4k6ORUIjs= X-Envelope-To: linux-doc@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 91b4f8bee4bdac7c; Tue, 01 Dec 2026 17:31:14 +0000 X-Mizu-Trace-ID: 91b4f8bee4bdac7c X-Migadu-Flow: FLOW_OUT Message-ID: <15407490-13c6-432a-80f6-ceb8acf5112f@linux.dev> Date: Tue, 1 Dec 2026 17:44:55 +0100 X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 0/2] soundwire: multi-direction stream API To: Srinivas Kandagatla , Vinod Koul , Bard Liao Cc: Sanyog Kale , Mark Brown , Jonathan Corbet , Bjorn Andersson , Konrad Dybcio , 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 References: <20261130224018.20359-1-srinivas.kandagatla@oss.qualcomm.com> From: Pierre-Louis Bossart Content-Language: en-US In-Reply-To: <20261130224018.20359-1-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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? 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'. 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? 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. 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. IOW the Linux drivers would provide configuration capability but no PCM devices/DMA support for those auxiliary streams. > 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 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 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? 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.