From patchwork Wed Dec 18 17:24:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 11301499 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B31F14E3 for ; Wed, 18 Dec 2019 17:27:58 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75D062146E for ; Wed, 18 Dec 2019 17:27:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Ms83ZPa4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="bbqrbWIy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75D062146E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BCF661691; Wed, 18 Dec 2019 18:27:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BCF661691 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1576690075; bh=bSaI/kcMU2Fi09rhgBHECQ7R9sEGrOZdvrIte4SjfJ0=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ms83ZPa4y6yrg8vMrzidAziLhpD5XQyhmGWoYjGY+MvoCTslCIm6ONVM+eImGVt2i LOTdOk5Vb8G/8uogi52ObZJbCCdpLExP78v7A0ccSn+Oa/HyGxeXvhVJP3J2uggibw gqry19j+1BfUVO6/Mse+zDwEYECz8U6NUIqZIuhY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2F740F8027B; Wed, 18 Dec 2019 18:24:39 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 13F0CF8026F; Wed, 18 Dec 2019 18:24:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, SPF_HELO_NONE,SPF_PASS,SURBL_BLOCKED,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5933FF80259 for ; Wed, 18 Dec 2019 18:24:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5933FF80259 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="bbqrbWIy" Received: by mail-wr1-x443.google.com with SMTP id d16so3147159wre.10 for ; Wed, 18 Dec 2019 09:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nI3wHpadQrFAs/JfgdrJy2gaVNas6wWVbz5bBhEZKws=; b=bbqrbWIy171rY+l3dGMJy2f78+t+6Y9QcSsfd9gwoJIz8jkMgkc5lGrDZmVu6xQqL/ qL5I3Xmb59jIDiBZXrvknewZyAAdkzidKB/cHIdG0tWHiuScNSJTk64Z4CFei93BZQix vMS1qnHOU0ScDaSQfYZqVvh33GopiHNU5CaCoA3iLb1xiw8ybBJgosGCFQvGa0icwWcR LoU072dWdylTSaklZ8D41kp3gdMzOlVvJ3JIeJVBPn003qO01931s6K7MU4i/3bKmCCl 8udC3LYY7D5DYl5WbKhSe39rTPZ6Or0Ki8Nn/yH1nQ0LX0AuK1UeNjlqKRxTKYhREuZw vAPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nI3wHpadQrFAs/JfgdrJy2gaVNas6wWVbz5bBhEZKws=; b=poxG8OsV5dkZBRWCRUxqxPnAB75RDK0OmpLQo1059nowBjHDb+Cb6rqKE/iDzB3GHP 5AAOj1eS+h4G9nIjf0DAPc/S6Ky0Uf4VfGgadnwr8ng8amT8yk9dyD81mqR1iVxW8RYI txro+es8l8jUbvX/S/RBQSIYCE87sVDMYou3aqZ8Nv3HTkp2iD6xZ8f1Sf3F4Dd4bmn5 aB7jJX2OlvaUN+GinOmveusB8OL0OiWddFT4slZbXARWE0YIxWIDua1+bNqltaXYPe8e 7JqH7lgCGdY1x5etmyo1Mgh3fJ4lBmXOTRcXFREG1qvhwBB5WYIn0EjuC8WnzAHONsX4 Vmhw== X-Gm-Message-State: APjAAAUJU98RXXqBSOVs8TNxj9QVEE3Krxl4xC4FVxpKhY9kMc427mNj sSogeGZ423AgSHG25PRn0x7AZA== X-Google-Smtp-Source: APXvYqyKdYK3rXzKrzwUO5iXVrWIg6dPjJNj4tYZ8+IWgFIrT8fWvTqSm7KF8srCCiQVg2C/hMhqCA== X-Received: by 2002:a5d:6692:: with SMTP id l18mr4345862wru.382.1576689871239; Wed, 18 Dec 2019 09:24:31 -0800 (PST) Received: from localhost.localdomain (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id 4sm2883231wmg.22.2019.12.18.09.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2019 09:24:30 -0800 (PST) From: Jerome Brunet To: Mark Brown , Liam Girdwood Date: Wed, 18 Dec 2019 18:24:19 +0100 Message-Id: <20191218172420.1199117-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191218172420.1199117-1-jbrunet@baylibre.com> References: <20191218172420.1199117-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Kevin Hilman , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, Jerome Brunet Subject: [alsa-devel] [PATCH 3/4] ASoC: meson: axg-fifo: improve depth handling X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Let the fifo driver parse the fifo depth from DT. Eventually all DT should have this property. Until it is actually the case, default to 256 bytes if the property is missing. 256 bytes is the size of the smallest fifo on the supported SoCs. On the supported SoC, fifo A is usually bigger than the other ones. With depth known, we can improve the usage of the fifo and adapt the setup of request threshold. Signed-off-by: Jerome Brunet --- sound/soc/meson/axg-fifo.c | 19 +++++++++++++++++-- sound/soc/meson/axg-fifo.h | 1 + sound/soc/meson/axg-frddr.c | 13 ++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c index 4365086c9a31..c2742a02d866 100644 --- a/sound/soc/meson/axg-fifo.c +++ b/sound/soc/meson/axg-fifo.c @@ -132,8 +132,7 @@ int axg_fifo_pcm_hw_params(struct snd_soc_component *component, * - Half the fifo size * - Half the period size */ - threshold = min(period / 2, - (unsigned int)AXG_FIFO_MIN_DEPTH / 2); + threshold = min(period / 2, fifo->depth / 2); /* * With the threshold in bytes, register value is: @@ -320,6 +319,7 @@ int axg_fifo_probe(struct platform_device *pdev) const struct axg_fifo_match_data *data; struct axg_fifo *fifo; void __iomem *regs; + int ret; data = of_device_get_match_data(dev); if (!data) { @@ -370,6 +370,21 @@ int axg_fifo_probe(struct platform_device *pdev) if (IS_ERR(fifo->field_threshold)) return PTR_ERR(fifo->field_threshold); + ret = of_property_read_u32(dev->of_node, "amlogic,fifo-depth", + &fifo->depth); + if (ret) { + /* Error out for anything but a missing property */ + if (ret != -EINVAL) + return ret; + /* + * If the property is missing, it might be because of an old + * DT. In such case, assume the smallest known fifo depth + */ + fifo->depth = 256; + dev_warn(dev, "fifo depth not found, assume %u bytes\n", + fifo->depth); + } + return devm_snd_soc_register_component(dev, data->component_drv, data->dai_drv, 1); } diff --git a/sound/soc/meson/axg-fifo.h b/sound/soc/meson/axg-fifo.h index c442195ba191..521b54e98fd3 100644 --- a/sound/soc/meson/axg-fifo.h +++ b/sound/soc/meson/axg-fifo.h @@ -68,6 +68,7 @@ struct axg_fifo { struct clk *pclk; struct reset_control *arb; struct regmap_field *field_threshold; + unsigned int depth; int irq; }; diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c index df104303351f..c3ae8ac30745 100644 --- a/sound/soc/meson/axg-frddr.c +++ b/sound/soc/meson/axg-frddr.c @@ -50,7 +50,7 @@ static int axg_frddr_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct axg_fifo *fifo = snd_soc_dai_get_drvdata(dai); - unsigned int fifo_depth; + unsigned int val; int ret; /* Enable pclk to access registers and clock the fifo ip */ @@ -61,15 +61,10 @@ static int axg_frddr_dai_startup(struct snd_pcm_substream *substream, /* Apply single buffer mode to the interface */ regmap_update_bits(fifo->map, FIFO_CTRL0, CTRL0_FRDDR_PP_MODE, 0); - /* - * TODO: We could adapt the fifo depth and the fifo threshold - * depending on the expected memory throughput and lantencies - * For now, we'll just use the same values as the vendor kernel - * Depth and threshold are zero based. - */ - fifo_depth = AXG_FIFO_MIN_CNT - 1; + /* Use all fifo depth */ + val = (fifo->depth / AXG_FIFO_BURST) - 1; regmap_update_bits(fifo->map, FIFO_CTRL1, CTRL1_FRDDR_DEPTH_MASK, - CTRL1_FRDDR_DEPTH(fifo_depth)); + CTRL1_FRDDR_DEPTH(val)); return 0; }