From patchwork Fri Aug 11 20:14:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13351394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B66D8C0015E for ; Fri, 11 Aug 2023 20:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WCczBIdL1v9BLi5ZtgCbt+jbryCuWXkEM9a6F08hGwY=; b=UjZ/N5FCqmLRNh CLQyP4QbQP2Ygzoxwzrwh5WWRjLte8jSoxEuHf35R2+rAVMTFuEgodWJGxQUzNi6NBxzhUbBYwuGp brJwc8L007AdELOALCfmA1hQ0tmT1Sr5/BnjvqrLr9o0bJoFR0F6uKupadYq+J8E/S9AeF1yzs3/m 2b8DQxydS1HUa7tJ9jA2cIh6CP0is7b7kniWoi1w8n0DB6OhUoCGX2b1/29ynzIv5NCEI4wfmmgn3 T8NXKEBRhH+ElNq3+qDzjPtIRqyd47cKKTrzwcpt5ryG/d/3F+F/jxSpXw0cagM/OfApLdE2pycTh qehfoShI8iaXwrSVxQhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qUYXJ-00BY1Z-10; Fri, 11 Aug 2023 20:15:05 +0000 Received: from out-68.mta1.migadu.com ([2001:41d0:203:375::44]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qUYXF-00BXyz-2n for linux-arm-kernel@lists.infradead.org; Fri, 11 Aug 2023 20:15:03 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691784898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QeLKekQPGIWeXPPUTKz0UKXYLZ76J8hy48F28uG+rX0=; b=LToGtkDrOCSOVpZih3iIpGEia0EWeKKZmc8sXDwvIDst79QFhcJMmKPTrN3sDyjY1Wy2V+ 6d5pHC5gzuuL+DV3YeuRE4CYWcZnwxcupNJ3tJ80rEWDQ6JfN4SLY7DiGJYwKfqWtUjjJo hlQ3qR7G7/W+ktYvQSU1ELwD75mHRMwo2GrfLValj+Rr+pHqoyjnO1uKCyC4tQbuSZ0b23 oJrlGZFLUvH42hPAC5gr/y6pY7gbYWeaM2Q7ApnKbPjjkWEH2BueC6PRj0KLdKAGt0IrlZ 4qb39dtKKzPT7NmuAjpPVfonV6xd//g4n3/p05BnPMSkG5/Ihe01O7RRs5AdGw== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jaroslav Kysela , Takashi Iwai , John Watts , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/7] ASoC: sunxi: sun4i-i2s: Detect TDM slots based on channel slots Date: Sat, 12 Aug 2023 06:14:04 +1000 Message-ID: <20230811201406.4096210-6-contact@jookia.org> In-Reply-To: <20230811201406.4096210-1-contact@jookia.org> References: <20230811201406.4096210-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230811_131502_049191_CC708FD1 X-CRM114-Status: GOOD ( 15.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The current controller code assumes a 1:1 relationship between audio channel and TDM slot. This may not be the case when slots are set explicitly. Instead figure out how many slots we need based on the number of slots used in the channel map. This allows the case of reading multiple data pins on a single slot. Signed-off-by: John Watts --- sound/soc/sunxi/sun4i-i2s.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 019a4856c90b..6347aaaed016 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -271,6 +271,7 @@ static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2 { struct device_node *np = dev->of_node; int max_channels = ARRAY_SIZE(i2s->channel_dins); + int slot_max; int ret; /* Use a 1:1 mapping by default */ @@ -290,6 +291,16 @@ static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2 if (ret < 0) return ret; + for (int i = 0; i < ret; ++i) { + int slot = i2s->channel_slots[i]; + + if (slot_max < slot) + slot_max = slot; + } + + /* Add 1 to be inclusive of slot 0 */ + i2s->slots = slot_max + 1; + return 0; }