From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796168213; b=1DkgHdjKAV7eFyKNMN3R43PR6tBeNaqznyaDEuhpu+S6sCAt64l9HPXdt+G1qo3Pc0Z+ t0cGp6evziN2NKf02gUhWDjHCHhgkLEFRsSyfaIcEipC0gc+KMYuc6ivrDlyww7mBuJ1O r10E4x0snYXzeiFlTLwlp0Un6nOlQjfphpgQxqLfcNuIuaNpojH+qn1g7II35Id2ma5yA CH1jn+6X0mnKQhiO+0cgj9XZdlrz4/zPNdm27hmOE68Z8bthbpcHu9RhCe0iHNpcuiN+d mk+3BEeVDjLorADBvMxhvZaevaTYyz9Jm1lhdG1pmlFZjGWSOBXkt8KqHGrJBanfaFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796168213; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding: X-Authority-Analysis:X-Proofpoint-GUID:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=aXFedIOowDrC9LajYV37sgSIKjojOD1AZ/uOdUDUv1w=; b=qwZimK6V6cQKN/VkiEDQnlGszsUjEoChtsl8gxla5+m5yWmG2tnCk0M2N1xAkVGl1Tf5 PcGOCxzIX5c7AFLW5pg5ibDOkr1XksOTdzfAWlEiL2TQTSfOqV4fakb+kvrF+ji5zYEAN 6QVcO4FwTIjVQIf19GZdpUMdkDiXbBit4n6iNCFudBa9bwIKstailYGRGN1a7RLL0lTNJ bjFCswynDQ6bcLjpEyh0j2gC5L060/DJ7X03fSRAojLcgq0j7qj3XmqdGqTH//HS5clL3 I7/JgV99LCYE+kybO3o+nGJDpv67yDzPoWEsRcdlMQ5h9zW2d+Swmbha8CB1Klp1j7w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=bGHOmIQr; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=OiUy8uvn; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7414B606A320 for ; Tue, 1 Dec 2026 23:36:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7414B606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=bGHOmIQr; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=OiUy8uvn Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1NW2362601032 for ; Tue, 1 Dec 2026 23:36:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= aXFedIOowDrC9LajYV37sgSIKjojOD1AZ/uOdUDUv1w=; b=bGHOmIQrSqjZ9lot 5NPh/4hO4R8i+EgqZ8UUjlYwBJJUIZiTrbD0QckNEHADaVwqEYYGcjzwV9HuTA9q lFw1D8nPFGSkmrvCXmhAYPUDwW1V73zhDct++6pfq5DdtxDo1+8SqOemgv1rodMy AUWEWARTdSWFL9zM9dptoJC9VpH1Oom/nQULouwxkNObOtMlNPx/HQB4lfGYrCsi i7az6j5eIR6XqiFmS7+jKfHAUXsuxvPBOxAA3MIdUDPPzaFEbmQmha/fhb+Q0wEE 2XfTXkXsU6jFkhrjHW7TF3G2Upk+RzpGPHRZuFncfVCwBNDnVDwmSCbdBk4kEBbF 1YDjJw== Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ja3aj13sc-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 23:36:51 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-949b0d322fbso1674759585a.3 for ; Tue, 01 Dec 2026 15:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796168211; x=1796773011; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=aXFedIOowDrC9LajYV37sgSIKjojOD1AZ/uOdUDUv1w=; b=OiUy8uvn1QFQl6MkGGeFKo4U2Z/2naQHznlbYO7QAuKyUcepcTRvlpMK1YJn0qDG6v Ch5x/uRrFWjKsM9dEBmoockOA12a2KI2pPKR1zkdbOqUCIY+RQZgfC9jnoCl1dzJ+doQ n+oE8sMsnWH/Xl8umo2OrWMflwyQeZ0Qo5p96ZtSX1Ja4nG0s4lMd7ACpVCXFHqD3HHf yD+CQFRHkKAWxck3+IBeiQDvrHF9doyhw8JLXTFjenKf9cZrcgE6Xsu8b3Rr5OtbZ0lz zPfTyAfsSb+T04PdcbH9GxEQ62TrQEPg4toZtBbqLq4l3oH24zXdV3ryg52WxLgI50d9 q+EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796168211; x=1796773011; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aXFedIOowDrC9LajYV37sgSIKjojOD1AZ/uOdUDUv1w=; b=ht0Lz8lFWRu+WHrKSncKLUx2VbenE31KAZdIPW3SfG9c8kxDusutyTMQF3WbryLJVB w5aqgoiDxxC7D48Kd3/LaOAl5q1JVJQXDbMXhJD5YFlsPgqOIVpcbKfScuunWN+hGm1v km7zSTR1/Tg9TkLJ8AAyhjZtoiNshFzms0IzVs9VaGvUcn3PI25+rGjuTViVCf0ZPnXK fPRIqaVtoNvIO4KVpa18xCuKc+evKHTKOpQHoEhL465qaNuaLOV4K5oyPTZAMeSTv57a ZlaT7eFn0Bu2a+5oOtdj1De+d81vkRzIkG+h2N7ZeoIzuDOkit2ScC8HE2am51LfocyA QCog== X-Forwarded-Encrypted: i=1; AL+hErGr+e8+JIZopBIFbFpx742o5Q2rV6ksCll3E2vQBGSDutP1PLQzNgrekgYr7ud1zDWRn0kPS+rH0lfWdhU=@vger.kernel.org X-Gm-Message-State: APuU4Z8cAc+zSiQgjRvsfxnsM8nQmJhULdS4Zk8BPY2xGkQxXYppr1Ec TbrgC2wQILgSRXq+gjAOJMQLDgezKmOhmrKuTMgD3Rbe/iXUi3v7Sz9fE0vPXXyIqhwZgOrwKOu XUXlDjUseDziudnldvKlu0Plr2NTO/eqefnDGFNJel+IgGY8I271zHWVOxozrHE69oPI= X-Gm-Gg: AZFdTZdYWp5+D4Aleje3wJag3V0fFz0UG7uFldSXLUQ68CmMFsAFONFXPBMpXCQc1xi sBofTMQWZIuM0N576vYpSuOBgSBy5PvtojVOZESQL7gDm8jCzqq5NlMwQErYqDw+NpdlAPB+NQP OotGRy6zws/lG7V28oKa8W1kNHAyAJOze0vJ7zkvqldCqmXHiYLBUXH5Fx/0p0x5SF0Z+p4G4o8 ZmrEkyOGGa/+DGnI2rsAp4Mw0UGBpjTMenjxNC8pPqZSnNNETo2rS/kDywQxUmbUMM68bCDLlqN vBtVPauccl1GwtUnGGYjMMsUgD/eHrOPwVTR8QRw30M9EjMikDaMAK0kjhiXgsYPMHWWU/bmRsh eS/oogvimd29yTO5BT0TPyLqgXND+3eY7T/8OedNBfPg4XHK3qmfBep+b3ghbgBa6dgDHUF0QhK pd X-Received: by 2002:a05:620a:2956:b0:949:70ec:7e76 with SMTP id af79cd13be357-949ba80f78dmr6731887785a.1.1796168210512; Tue, 01 Dec 2026 15:36:50 -0800 (PST) X-Received: by 2002:a05:620a:2956:b0:949:70ec:7e76 with SMTP id af79cd13be357-949ba80f78dmr6731882685a.1.1796168209929; Tue, 01 Dec 2026 15:36:49 -0800 (PST) Received: from [192.168.68.120] ([5.133.47.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4bb8538b09bsm1926932275e9.4.2026.12.01.15.36.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 15:36:49 -0800 (PST) Message-ID: <1dbe1208-dd21-42be-a005-f2cf4744e12f@oss.qualcomm.com> Date: Tue, 1 Dec 2026 23:36:48 +0000 X-Mailing-List: linux-kernel@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: Pierre-Louis Bossart , 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> <15407490-13c6-432a-80f6-ceb8acf5112f@linux.dev> From: Srinivas Kandagatla Content-Language: en-US In-Reply-To: <15407490-13c6-432a-80f6-ceb8acf5112f@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=Y7xtIReN c=1 sm=1 tr=0 ts=6b0f5a13 cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=FRUnuQ5PnN9o9O2sSL4A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=PEH46H7Ffwr30OY-TuGO:22 X-Proofpoint-GUID: Ctbern_KWbXaupfO1ohFbAIuW4jrnHZX X-Proofpoint-ORIG-GUID: Ctbern_KWbXaupfO1ohFbAIuW4jrnHZX X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA5NCBTYWx0ZWRfX5EqBGSwj8Rfd nI0hbTTOy03CyxRtFU+cpdOkd8+kwA5LZXAA+tg+/iqP11G7rVvY9C+0taXMqIQFl3/4mIc5T5k vZ2Xq3SwMGQqcyBCey9r4zVWUxpJcuM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA5NCBTYWx0ZWRfXzudx2XIztbc4 JcaJHzGXayF6ZEKw4hRYWUyarPSdDllY2fgeZbmTkQ1GP2jhhYi77Ag6n+jDDZ3BHfy7GR1Fcjf yMv1aOnhYfMqrnM8KKbpeySl93bgHj6LHfA9kxNLzG44Dgt+dqkfz7URpwRLw+0gUGGMe/THllN SzO6PphZrwMQh1DAGjHnrzH6yqKyyWXXJTcGWVZpyqd4da2MCJaCLI2fTF3eMKMHj9L2QTRRhP4 fnrV5gQ+uJFTol+JKpV9bALP2raaVG/jrUrbc27wDg7TpeK0xZBHEnYykk52uPKso+IyUmJWAmg MOjBFVHEUpMxVhXR0BDqmW7h+VLYCY9TCD5EM/3LPD8jf0IKCW+YwntIpaskyYQqzlhwvYlE0DO JJflNuNZhtxX6UdLfCgtpxAK0/DD0iuKTluNrDGHjfEbTwaw9wnNQNvC/TYWKABdQuWK6OELtPv mnMPY6JxcGWUocoBRFA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_05,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 clxscore=1015 spamscore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010094 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. >