Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2636050lqp; Mon, 25 Mar 2024 05:16:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVtghUITeXGiPC7p/U5LAsk90rocPiSKozOGbdIOijdmNWZflQfq9APH8/Xv02ybUkunUuoczq9Sho3nZ2hiF03yREopsL3ycq/pBH2rQ== X-Google-Smtp-Source: AGHT+IExY24WgptS7Hi1GiYLOA2jhDtVOc4kZbS46rN++oFuovSWr7bOmYQNucNfcK3ys4TdJADl X-Received: by 2002:a17:902:d541:b0:1e0:1f1d:bd38 with SMTP id z1-20020a170902d54100b001e01f1dbd38mr8862043plf.7.1711368981339; Mon, 25 Mar 2024 05:16:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711368981; cv=pass; d=google.com; s=arc-20160816; b=zgfJajbW4CJVrLVLyd3RC8uLsBGG7D1hOJ/CCp3E0rW0GZA8s2Zmk7KdeHNIteybDT 7t9cDlWWwsMsf7aZuWEN9FpOynPiaxPfarR7rcYq2WPZ2QeGDXXNVOIG4pFO6bNSurMg flCYGINr39srBe6pj6SO35/tRBymt+cVkgRlDCy4VOgT77r2Kk0usifZqtQVP/bHq5Ah QNEPCzPjj6Ug9wrooFZo68JTV0W2fKaKOuaEf5CE358ejX67IMLdKS/8cBQ+1dJCSMmF Y6hUS9x1SE9pPJpwy7su7yGmX+RLzTzLhGh2q1DzZrNHk1VPw8fT12aphNsS3aZ8cqER 5xkg== 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=0KqdrIrzGACzOzpGDQYbmyEjvqFOToWY2dYO9G/fCQ0=; fh=Q8YkG7eLocoIzTd0FLSFkkiLp8SSoQqFNMpX42zCTrs=; b=p+zIlrlmuhnHrZ48xcUW/1eQHru2A4YQa05hnwfgCblR3ZdP8O3eF1jl6YdMmwlFbe SxDCW3o+O5AHTNc4v8B3yjTBp15aJkKC2MdaeUpiFlDVDchrNQFxj6UiTQTi5gI6q358 VKsB1h0HYhK0UtplzGy/rSdgtW2Bh0RAfZN7SjR7GHP+Z9/3xcjq5ldzcECmuduVaC1G 9KXrLwLHdjAy377zIQQBYN550JjuzmW9xwfG8STY8hvEMhH1dqcL43/rlV7WnWSrJANL d9kX5PiHSiPlmgwiPS2mPo/YkFt/0W/gGdRv/OANkJFczrPfUHpX7XePrQGnqIPGeOtx xscw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ds+azRjt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q12-20020a17090311cc00b001e087e6a6b4si4776515plh.465.2024.03.25.05.16.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:16:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ds+azRjt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115964-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115964-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5FFBEB2739B for ; Mon, 25 Mar 2024 09:56:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D37F3941F5; Mon, 25 Mar 2024 03:04:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ds+azRjt" 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 EE6392310D5; Sun, 24 Mar 2024 23:17:18 +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=1711322239; cv=none; b=snYz85CxtGCn+OWiw+swiqo6a0bh9xlyfhGgTTbEffxekJDDmakuz7RshSmLc8uOa62xW+AQYaaCcSlx+kTLcuHBi6SNE1sL4I1a2vFaPNGcRKaR3P404zYk7G77VQAPm8pal7RxnvQNNiwP9VAzeIrP5jNkDomhmc+xNmgFO9U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322239; c=relaxed/simple; bh=YP06ms3P/wyIFjeNUTYc/uZl3NCl7kwSmxM13RocM/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TNXjWwE3sei2jaAJXrLd07hDafnbbgKg2J/JD+34PqOqGW6eYDNV/4X2RdpOg3QFMDh78732isRgOTSva0YuuGozPY9bFXxEgzIE9aITLy13Cr8uekaQasM7QeJoGOLKWgNrhkgMXbhksgJWobCBov1zVNr6xqC1M/NvETHaXGQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ds+azRjt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30D05C43390; Sun, 24 Mar 2024 23:17:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322238; bh=YP06ms3P/wyIFjeNUTYc/uZl3NCl7kwSmxM13RocM/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ds+azRjte/vot04SJFLj+CM2aeucNzbZLY289dzKRn8q0PN36jhZ8Yaeie/gzAd+Q bYTPv0QxF6dJA8ceNeabhS4I8yDPy+DWjZA7IHUTU7a5OAjzF32a1NflByU2NZHMrV Lry/+2/K8ac9QJFfZmp6zYXuTj3xEBO7D/9r/jZYISZAXbRdw0QLIxNbsKjrinjVlO +nbXixWykqSXJLT+PZTrRczsHzUmyw0dfbyrgDKRwcMBYhyje5V+a4QGqxNfSY1nfH 71H+yQhYoSkF2awWRWFFPg+K/qLR0qzTXpn5iOCixe1IbLwoz2F378AajiFBdfc6zb UMsqe+fTih9LQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jerome Brunet , Mark Brown , Sasha Levin Subject: [PATCH 6.1 320/451] ASoC: meson: axg-tdm-interface: add frame rate constraint Date: Sun, 24 Mar 2024 19:09:56 -0400 Message-ID: <20240324231207.1351418-321-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 eb188ee950557..028383f949efd 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, @@ -155,19 +158,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