Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1267296rdg; Fri, 11 Aug 2023 16:02:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/VNXG0mT6oj/kiYR2OQ9zIkK0uI3/BJhdfeMgfAfIfNu0/rnXlN0pXNv3yx3xQP2MHMaB X-Received: by 2002:a17:90a:7046:b0:268:47c2:e490 with SMTP id f64-20020a17090a704600b0026847c2e490mr2358273pjk.1.1691794937661; Fri, 11 Aug 2023 16:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691794937; cv=none; d=google.com; s=arc-20160816; b=lr+TYEKTX2qqugOvOCNFWM4/VRiTV/YGubN1rFvAIq69X5hgmjO7Qwa2eUs2oY78B5 oSvfHN/OdxM92ITbiPL6TrFaonBGyhQqyVUI+NmHPPoi036wD3RDv+DQPOhqK4NgsKKz 1HIgeuBHQxjwSuREufbPqeGuIi1f8q9fzyUGasB44K0lDneKDbezo1/SV9PXS1J87Ngd G4IYxSef8E/B8HJUEYxbHNinb3AtMFwEWXY41rJ94efZvQ+iAV3qz95Zp5vSeABkluo1 kQwaox/MhUHDTOoefG0Pjxyy5qLuEbhdyLd7MmtJG6oQTOLuUN39pTeu/oAeIGH/2Y6X J/qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QeLKekQPGIWeXPPUTKz0UKXYLZ76J8hy48F28uG+rX0=; fh=I2+cRdOi+5kEg31kmXDPfOMZarcf60s2JZeRBWoy9GY=; b=DE4ynEy9wuTN5dwozI2W5fE1MuZNwCs3h4Zbx0svADRifVSkmzBkcmahEnWY4OFd99 HgZLdMsbs5whNtyq06Jy32MOSBV/Xnexepx2rQezsjSFwcRGE7vJzHeNkqEcTuEJKLxo jOltA9tX62WEQskvFWfWZ9VvKOaN47688KEdzdgvO0FfgKHaPfIjp8/GHycdbUajQMOK jLLSVKt3pXH9p0zXf7rAMF8vTvcjNhZzy0IXTwmQcU3WzqDswPEvhH9CSCltmnWvpE2V 03tOrBshomoLuNqUY7xqNGFKZJbmJMlwm6FsFbi5AFVoi+hpzhd5Yx+0GpmPeaaO11K9 8eQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=LToGtkDr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=jookia.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a17090a488800b00267f01101fesi4017833pjh.36.2023.08.11.16.01.55; Fri, 11 Aug 2023 16:02:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=LToGtkDr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=jookia.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236842AbjHKUPG (ORCPT + 99 others); Fri, 11 Aug 2023 16:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236762AbjHKUPE (ORCPT ); Fri, 11 Aug 2023 16:15:04 -0400 Received: from out-79.mta1.migadu.com (out-79.mta1.migadu.com [95.215.58.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA3733584 for ; Fri, 11 Aug 2023 13:14:59 -0700 (PDT) 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?Uwe=20Kleine-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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; } -- 2.41.0