Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2564660pxk; Sun, 27 Sep 2020 12:32:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXVo8tJkGsRWZ5YDtzsQ1Lpq0/ZIAWxFT8rKcZSLqoz4IfciozgmmC4A/6iPInVSja4jw1 X-Received: by 2002:a05:6402:144c:: with SMTP id d12mr12591747edx.168.1601235148428; Sun, 27 Sep 2020 12:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601235148; cv=none; d=google.com; s=arc-20160816; b=VXXCrA4XhmVjjIgxulJik8T7JgarBbOPHrm4COe4wmH8ke+8pelt9KkJDo6lhAGO4G ypujiJouGI8EPTQtso8EVpCp98R7+Ss/kPNYcBmi/ANZm1qgYJ9sWmqWWNwkPMfH3WSe Wl21vJE5nyRFHlaTslI8/p6hVMaRXQqd+1Plejt5UoIDWkHYCzhETu09ng1IL+AfbAdj yRhSth6mTKB7FDTtosW7Uq5le7Djl0epaHe5+voEvX9WbjYPnQyjUg9XcEQ8CiLIiAAQ gjB7ExCWlIw7I7b4tElEEoHZMS1B3STo09ysnhP+xUsC5seXaDdEpXsZI6NLbaP314Xh hQuw== 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=U836kMnIm9OVtnsGLVK3iz9PKF3eFCFtxxEFlUe/IkU=; b=KLkfOy8xTF0ASEwLaFoB/oxqj1h2RO5yr6eE9UMsA35ImTn36HY8IxMbUqKfkZG/P7 y7YGdc5oRCzugRYGT1EPl+hNgpGnLb/Q8QNL3UMR5IR4CaeCoTxDj/MurqUnUEPMNYWZ BpIOVTmfmh3jJ1SWMp7OuMrljlWbUkrxWgnzOa5i7tqO5GBXcVaGQjxdli+Vm/WTAcsx t/X8QteMrIRmAOBvnJt03Wa29x4QC03HhQAcCjuo4NIEsAZDl5ErHoHbEw1d/gzxtRMQ wIt6t8nknJZUdvV3pSwR9Q8rusw8zC2QkEjPIi9eE1QJNOqfWDb8meX0lbSpnwxmYqit ZIGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rtzn+Paw; 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 j4si5945416ejt.277.2020.09.27.12.32.05; Sun, 27 Sep 2020 12:32:28 -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=Rtzn+Paw; 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 S1726788AbgI0TaV (ORCPT + 99 others); Sun, 27 Sep 2020 15:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgI0T3Z (ORCPT ); Sun, 27 Sep 2020 15:29:25 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11B7DC0613CE; Sun, 27 Sep 2020 12:29:25 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id d4so4376526wmd.5; Sun, 27 Sep 2020 12:29:24 -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=U836kMnIm9OVtnsGLVK3iz9PKF3eFCFtxxEFlUe/IkU=; b=Rtzn+PawsxJSG4C4aYy5ZxM24Z9N5/jaimpdUAYpG3Bhqd9xr8m769bY0+IQJ8IDNo ao7Ep1e8Is/jLDcNE/i17pLpEAOMcCOCbXLiulXHlyMER8griMBESWiRzrHzipY0VvNq 9S91j3Xb1sCOyZlbgRmH/b3spAvTDj7BiQ8mp35eLP0RMCaDroGNltMFoD4wHo+M39Ms HfrAXutwX1Qz7uOltoeGY9x8EN29AVYkhTwcbRyGoRxnQNbCAXZaa1By8E6cflVkRcHJ Ya9sVrhnGrWnyum2/uAJydI+GJFaaehbibN6DArKYIPwwqUprk7mnYqGRDxr2IMTh9tY 62hw== 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=U836kMnIm9OVtnsGLVK3iz9PKF3eFCFtxxEFlUe/IkU=; b=pv3aozKGxdxmdEjPGexPEFawoFRtPtREOEa2m5zMbwlatQScYK3EZt9AoVe6nG0JqM Xf5nJ5zTVGyJHI6Bw5E5Sf5BtO1OAfDuG79VqcWmC8Vs12NKZKRMKN53pTTvBBhmJHf9 9UH9YS9Zn+43TlEZBT021pCN3V8AE58RDlR0OeczhPVeMtl5DVkCG6Q9+h+2wZnEWOOw FFM7Z1JmPUqI9ephDNsXFLsYsf8/MXxqsxlKnMMjx0Gltb01mQZVeASa6ljnuU13Iiz3 v11lvU+uwTFopSRdy1eKMNihoqdK6HXlhs0BHTVICJtZnYpvQ/pdSgWbdN+9cNuK81eU Caog== X-Gm-Message-State: AOAM530EmkpKFMbX6ylai7dzAMP20dNMmb1r3rcmJj/PYGmVvxgrpl1w Zaz755CNpDqcBgolyca4riA= X-Received: by 2002:a1c:7c01:: with SMTP id x1mr7789147wmc.57.1601234963606; Sun, 27 Sep 2020 12:29:23 -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 n21sm6149609wmi.21.2020.09.27.12.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 12:29:22 -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 v5 05/20] ASoC: sun4i-i2s: Set sign extend sample Date: Sun, 27 Sep 2020 21:28:57 +0200 Message-Id: <20200927192912.46323-6-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200927192912.46323-1-peron.clem@gmail.com> References: <20200927192912.46323-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 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 11bbcbe24d6b..b31454eee43c 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 @@ -676,6 +682,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; } @@ -778,6 +785,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; } @@ -880,6 +892,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