Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3661458pxu; Sun, 11 Oct 2020 19:14:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy57ZwwmuApduWd7P288sukUwOIQh85jZMIf1baxUu1FFqB8ND01awOp7t8cEklstHgZ537 X-Received: by 2002:a05:6402:a42:: with SMTP id bt2mr11454677edb.193.1602468857103; Sun, 11 Oct 2020 19:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602468857; cv=none; d=google.com; s=arc-20160816; b=gDucsW1JfWPCzVSSPbwWmbyYN9j0cdX3Mpv6RpuFIoIdX78TP7zvM/Nxn02tvirc1y fVE0bxbBDFtLRdKh2M+oZLAUFUgrM/W/1s8KgEk2Fs3AJW41WhQtuK66m6eiayaR0jQs g7oGyKrCI/aYGTOm+JH0QfXxVlJiyX9U67PhRLLhSsk+9JFCZve1Oao2pxAFpHeknZxA Jk7qh0/CDZvTjwUUrqxF1W6TKeA96/bnIsn2KYFgM+jpfU27UU7NbPXkPJVc4qQj4eAS geDVdobl1mZtyEBRIRGv9Ntx96wHZGQSvWoWM2QZs3PpNAxIYizEEWDGdCJmN6/VtqU3 99mw== 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=Ej9LaMzdEDJzAv73zOk0RleDj1ZozYjS69cI8rWWfxc=; b=fZwJdUgL8vNQhxcLEtozxhOoho58hhMCfh7szLNdInSAHEdqqx3TXmPP03tTGpUiOA x9Gc/apIuZ3V9OCCIQlgZP72lAzEHQXR7B9/Q+9wgbrPwEq7Gs0rBgy5c0vy7lgZXv5o jGFjTsw2xolVa6WZwXKRxEDw86T4FJhHFiYWus5P5yNETjTNwJdoMIAagRJiY4CgEYCV l7yjz+WxEM8L03q1N2JPupDnzWZgiE3zV9O/Xoo8oZRSShMlRXI89P+OLB3wSo5o5Ype cskJkWNK+zT0mkJaArgDi5JQGaYRG1L/or6of4FHwExSfqxStBZskJOBoRpCpbWD+ung l6eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ibJHGgWN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si11006398ejz.318.2020.10.11.19.13.54; Sun, 11 Oct 2020 19:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ibJHGgWN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729189AbgJKUXN (ORCPT + 99 others); Sun, 11 Oct 2020 16:23:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729193AbgJKUWo (ORCPT ); Sun, 11 Oct 2020 16:22:44 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8817C0613CE; Sun, 11 Oct 2020 13:22:44 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id s1so1329874qvm.13; Sun, 11 Oct 2020 13:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ej9LaMzdEDJzAv73zOk0RleDj1ZozYjS69cI8rWWfxc=; b=ibJHGgWNe58D+ZWWll+jyrm/aFvW8UbvR7UWQl8ZKfmiHCbfTmMkrhu5sirtDTBRnG sknip4P9927xR3HdHyeQKHK31qz5GsK/7+RQ27E0ib0HOJIhC0CD6p/c0tSLOEsDJrhP UTBEusoitsD6au7M6sKUx1BpmHrIooiDaH3S8qdWECF/Ut2hhXURTw10ZR5Sv5aevuN6 n2t67HXwSk6Tw7PCINGWbNZEt+TZaABIY7/KGT9ovV490HXqsneu8u9aubLnheiUjrWA kX279bsxByyzpa84RZl4FabqxhgN7MyGd4JCEpBHZtIom3aOe/ZP5aWcxDRUBN4Hsu8k Nh9w== 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=Ej9LaMzdEDJzAv73zOk0RleDj1ZozYjS69cI8rWWfxc=; b=uCehm1IrgOI6lLPDhLAtsctprxSzMSpiT1WWBBVArlbeM+5cGaO5+7bECiIqOezoRc 6P831Pqz/uWjElnFyaUCzJOG6BUoFJ0WRVEbtbGcMQo/vmWHf/zy0Vf0pkoZrI86sE3O 33E4VX5jpBc7ptig/6e1I2dboeUXAUuyERGyJcBZ+T5KlUz33ys+VlKlYZHMHSq/2uty c/4hqSFVlBH8oocW3hBuf8fJ+y7xPz2GQz9npUenDgpyDHaqQskG+EjTtncXKOl/ExeO 8Y382bUv1+WPVBgtQMXN8AMM2MXP6OXViNBWIIkpG+3RrgFJ0BXanGtJ5Dm9isCjGaLE TnMQ== X-Gm-Message-State: AOAM5325fhZCuO9FxSyrH30x8Jhu78tlUsv4mmgR9gZVk7dpwrcWGYAN Ct4Ah+4G+QfLHHcm/8aIVi8= X-Received: by 2002:ad4:4105:: with SMTP id i5mr17777300qvp.47.1602447763738; Sun, 11 Oct 2020 13:22:43 -0700 (PDT) Received: from clement-Latitude-7490.numericable.fr (213-245-241-245.rev.numericable.fr. [213.245.241.245]) by smtp.gmail.com with ESMTPSA id c72sm2987778qkg.56.2020.10.11.13.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Oct 2020 13:22:43 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= To: Maxime Ripard , Chen-Yu Tsai , Rob Herring , Mark Brown , Liam Girdwood Cc: Jaroslav Kysela , Takashi Iwai , Marcus Cooper , Jernej Skrabec , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Subject: [PATCH v7 04/14] ASoC: sun4i-i2s: Set sign extend sample Date: Sun, 11 Oct 2020 22:22:14 +0200 Message-Id: <20201011202224.47544-5-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201011202224.47544-1-peron.clem@gmail.com> References: <20201011202224.47544-1-peron.clem@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcus Cooper On the newer SoCs such as the H3 and A64 this is set by default to transfer a 0 after each sample in each slot. However the A10 and A20 SoCs that this driver was developed on had a default setting where it padded the audio gain with zeros. This isn't a problem while we have only support for 16bit audio but with larger sample resolution rates in the pipeline then SEXT bits should be cleared so that they also pad at the LSB. Without this the audio gets distorted. Set sign extend sample for all the sunxi generations even if they are not affected. This will keep consistency and avoid relying on default. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Clément Péron --- sound/soc/sunxi/sun4i-i2s.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index f1fdb9a0ba54..0b242f4615fe 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -48,6 +48,9 @@ #define SUN4I_I2S_FMT0_FMT_I2S (0 << 0) #define SUN4I_I2S_FMT1_REG 0x08 +#define SUN4I_I2S_FMT1_REG_SEXT_MASK BIT(8) +#define SUN4I_I2S_FMT1_REG_SEXT(sext) ((sext) << 8) + #define SUN4I_I2S_FIFO_TX_REG 0x0c #define SUN4I_I2S_FIFO_RX_REG 0x10 @@ -105,6 +108,9 @@ #define SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED (1 << 7) #define SUN8I_I2S_FMT0_BCLK_POLARITY_NORMAL (0 << 7) +#define SUN8I_I2S_FMT1_REG_SEXT_MASK GENMASK(5, 4) +#define SUN8I_I2S_FMT1_REG_SEXT(sext) ((sext) << 4) + #define SUN8I_I2S_INT_STA_REG 0x0c #define SUN8I_I2S_FIFO_TX_REG 0x20 @@ -678,6 +684,7 @@ static int sun4i_i2s_set_soc_fmt(const struct sun4i_i2s *i2s, } regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, SUN4I_I2S_CTRL_MODE_MASK, val); + return 0; } @@ -780,6 +787,11 @@ static int sun8i_i2s_set_soc_fmt(const struct sun4i_i2s *i2s, SUN8I_I2S_CTRL_BCLK_OUT | SUN8I_I2S_CTRL_LRCK_OUT, val); + /* Set sign extension to pad out LSB with 0 */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT1_REG, + SUN8I_I2S_FMT1_REG_SEXT_MASK, + SUN8I_I2S_FMT1_REG_SEXT(0)); + return 0; } @@ -882,6 +894,11 @@ static int sun50i_h6_i2s_set_soc_fmt(const struct sun4i_i2s *i2s, SUN8I_I2S_CTRL_BCLK_OUT | SUN8I_I2S_CTRL_LRCK_OUT, val); + /* Set sign extension to pad out LSB with 0 */ + regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT1_REG, + SUN8I_I2S_FMT1_REG_SEXT_MASK, + SUN8I_I2S_FMT1_REG_SEXT(0)); + return 0; } -- 2.25.1