Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2390694lqp; Sun, 24 Mar 2024 17:20:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUe9jj6+BPBwYoITf+NHTbM0F3tVCgH3iMcqDMHMOBSnSdvTd/8ZHE3uEPf8sVNjWASzYbt9gWL8S0UVb0G1WwG9jXiBeXwfZfeUgpOXQ== X-Google-Smtp-Source: AGHT+IE25YCsRRQ2n/kextFRtDJEoKggKBh3RgRnQXeYEP4xARvHFbT/KYmh6aMs95z67kK3cJc3 X-Received: by 2002:a05:622a:343:b0:431:5eb3:7b09 with SMTP id r3-20020a05622a034300b004315eb37b09mr108999qtw.52.1711326039128; Sun, 24 Mar 2024 17:20:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711326039; cv=pass; d=google.com; s=arc-20160816; b=yf2fmRlbPI8hZRt9DYlOF7R3lyvOTVv+9voDKUNfdIWxWfV0gHYCv/0nugqdzaGuhB vbQMaucGBO6J0wuySWEFRQPg2ApFWJPvTxP+t+4RyEHbazS3AXoTAvKTVsWTpYaBr9qR 3khUGDBB0FJ7HCnYxB8C7j35EH6yTLx84Fo/c3oOUt00wwwCk6lf4VQcWGt88YAkJTy3 P3CYhjc6QNh3LqQSCRf7FzdkMQCm3N72B8VcQm97rF0TS6RI+yZ3GljK2DAx1asq39v5 uRdgDI1J9J5jKwscNKBZLM1ISY5ViHsbTuFvcoHSU55Oah1Yy+vbEY3PFZIbzCAhg+hw PbIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4kZw4rMEUfJI72+dr2pGL4APj7bIfg4UhfnCPt/VIVs=; fh=Q8YkG7eLocoIzTd0FLSFkkiLp8SSoQqFNMpX42zCTrs=; b=eYR2k0YsCKDA8h79om6uABDz1FP9OvspID3qzRKGru+7fY0UWiiXejDfKYy9lFgqhW azXeM0zIbRph0vKLkwWb+YewKtECOR3O7bj9afaoAb1aQ+ZHYAMFasforK3+UAsJy8Lg 54g03R9v76qiXmjUES4/aZ+j9tHpfPsEQsN2Sfqaz0takt5qUCG43BQeZ7XqOVWkbkpE QIFzl9iQtPFOkuQY8iTgr02rTqgShmi0PxsL/ZqlNClxiMSn+lajbXLoJJlyh2d9pbnp fQfcrKxt3+F0sEzP+y36VnLWZ7rmvsurJtDYZI0SEyYe7Z5+L65/1BXiJ3VsK3W1xTzW 3WTw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gef299Z4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113372-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113372-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cb12-20020a05622a1f8c00b00430eddef715si4672071qtb.745.2024.03.24.17.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:20:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113372-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gef299Z4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113372-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113372-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D2F781C237CF for ; Mon, 25 Mar 2024 00:20:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A28AC19E689; Sun, 24 Mar 2024 22:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gef299Z4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5E5819E66D; Sun, 24 Mar 2024 22:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320173; cv=none; b=u4K3u2sI/483gwYT1Z4MF/9Za/qYUxmZuO7M8yu4k4yxbvWNvV+Psrc0KTY37GaBgh1chyioiEgZ8sj8NRjTNVQWf8IkoV93WN8nlvJL5lLtOdrI+v0pc+MHCseWlbm/CfwvVRlTRoQAZNjHmSglGQQ8sscaJux9d3LKxYuIyjc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320173; c=relaxed/simple; bh=Z8X2zP+nEhY/enFqxgIxcycK4W9hG7UStcYvoIYNi8M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c5q1uIOKfi8hbIWnLWKqBxUr02uvTtiT8d5eEOMGiAYIuMVF55hH7jLZduhzB3iCFPLgnzpfZu3o3OyiqTjgl1N+jwFN3AO3QZCY7ETRINJ2AY2PrAZ9YuBKClgG0SbcdVfO0XMzB06BMh9j1Wd1A2ADSHxixl+blyuN1EWXwl8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gef299Z4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB338C433B1; Sun, 24 Mar 2024 22:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320173; bh=Z8X2zP+nEhY/enFqxgIxcycK4W9hG7UStcYvoIYNi8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gef299Z4C94fQh0YJhcfhKCh18mmd2PC2l9/mXPp0hmjVx54g5RgUG+kPMaCoeFBC AxyQNFiyrkL0WeSIXiK2HNnIzThcEPjVwPZL5JVOj7kIE4MS8PTnt+jGyxLr+xM+p/ NtxP5eHru8iiWcups2v4kyRuYJPaOb2Ezq14kaJLcBcmZoLy1mqr6ud427tlE3ZMj9 7o/ehDw/B+GLviqITnEsueoRWXGGosbm5mKV3NXp82XhNATqzzW2GOm6VnMWkX28xY n6hP7A3umZ6cbyGG0UKgtEIp+9LEB07fV4Ba2TFb5To8BhxBdIFJD3kw7UhrfZdZx2 fXPwchwnRNYjw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jerome Brunet , Mark Brown , Sasha Levin Subject: [PATCH 6.8 481/715] ASoC: meson: axg-tdm-interface: add frame rate constraint Date: Sun, 24 Mar 2024 18:31:00 -0400 Message-ID: <20240324223455.1342824-482-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Jerome Brunet [ Upstream commit 59c6a3a43b221cc2a211181b1298e43b2c2df782 ] According to Amlogic datasheets for the SoCs supported by this driver, the maximum bit clock rate is 100MHz. The tdm interface allows the rates listed by the DAI driver, regardless of the number slots or their width. However, these will impact the bit clock rate. Hitting the 100MHz limit is very unlikely for most use cases but it is possible. For example with 32 slots / 32 bits wide, the maximum rate is no longer 384kHz but ~96kHz. Add the constraint accordingly if the component is not already active. If it is active, the rate is already constrained by the first stream rate. Fixes: d60e4f1e4be5 ("ASoC: meson: add tdm interface driver") Signed-off-by: Jerome Brunet Link: https://msgid.link/r/20240223175116.2005407-3-jbrunet@baylibre.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/meson/axg-tdm-interface.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c index cd5168e826df4..2cedbce738373 100644 --- a/sound/soc/meson/axg-tdm-interface.c +++ b/sound/soc/meson/axg-tdm-interface.c @@ -12,6 +12,9 @@ #include "axg-tdm.h" +/* Maximum bit clock frequency according the datasheets */ +#define MAX_SCLK 100000000 /* Hz */ + enum { TDM_IFACE_PAD, TDM_IFACE_LOOPBACK, @@ -153,19 +156,27 @@ static int axg_tdm_iface_startup(struct snd_pcm_substream *substream, return -EINVAL; } - /* Apply component wide rate symmetry */ if (snd_soc_component_active(dai->component)) { + /* Apply component wide rate symmetry */ ret = snd_pcm_hw_constraint_single(substream->runtime, SNDRV_PCM_HW_PARAM_RATE, iface->rate); - if (ret < 0) { - dev_err(dai->dev, - "can't set iface rate constraint\n"); - return ret; - } + + } else { + /* Limit rate according to the slot number and width */ + unsigned int max_rate = + MAX_SCLK / (iface->slots * iface->slot_width); + ret = snd_pcm_hw_constraint_minmax(substream->runtime, + SNDRV_PCM_HW_PARAM_RATE, + 0, max_rate); } - return 0; + if (ret < 0) + dev_err(dai->dev, "can't set iface rate constraint\n"); + else + ret = 0; + + return ret; } static int axg_tdm_iface_set_stream(struct snd_pcm_substream *substream, -- 2.43.0