From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F2C1C2D0E2 for ; Thu, 3 Sep 2020 20:41:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63B0E2071B for ; Thu, 3 Sep 2020 20:41:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QB5fuzCP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729578AbgICUlB (ORCPT ); Thu, 3 Sep 2020 16:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729306AbgICUav (ORCPT ); Thu, 3 Sep 2020 16:30:51 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02B7EC061244; Thu, 3 Sep 2020 13:30:51 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id t10so4620632wrv.1; Thu, 03 Sep 2020 13:30:50 -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=SOE/OufDVdftX3/5DbSJXaktDiZZ0XiuGv+LhNkVuyU=; b=QB5fuzCP50t8x9ptrCUFxBtgRq7mzEUX8Hl9zZI6AyIfW9pojvgYUQUBCBRxr3kqlA 14rr62erX03m/hCwXDn0RD6DzKVkH/Jhovz7Ens7xMjD6qkBwYNaDCJZ7eDoNtCGAW5u TT1XfpsyHG8AcneQzaHt4aV42oTpzRKku2o3V8RhmdB/S3SltLxzYc8CHX5mbjqsrPLb 6MD6TQVYc6UWK52vDugIpUgFNXrObpNmQ5kKJHmj8AhRFX8I6SP/WQx2OgVBs0djoCwc nT0vqytArb7OOq2VZWbuWfkLwrH/G5zroo0ONuDDKzGzd/APM/xilplzX6st297R8rqz cHXg== 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=SOE/OufDVdftX3/5DbSJXaktDiZZ0XiuGv+LhNkVuyU=; b=hXbxoALrVHgiDNtaYxa6WqrlCJEwdKY+yp/HCND/FF0md0Fs/davnGOYw3SG1cNf2Q uvtr9g5DiJJFBowmEG9J50e7Pif+OdNlVRX3CcioVr1Eytc5ct8wMwz1u018vebTjCxo QC3RqnOEPgcrNY0VLFtkzymlwBt27o1GGa7xhOIFAusu3gcANR2O1zATWcyPio1wMRf0 EKip1k0xrXYDcHlvLsQDLkTLuxTLonu4N6AbE8x97weZyMWM6mUAVpjb/ACIA77xG9E4 FodEVykqAjwBXLuPrn8c5CbKXh31se5qHtBbtuRB/zAvtYGFqXVdZ1CFWmaZk8DA0WDZ t7wA== X-Gm-Message-State: AOAM531+fOsy6yPMzza1xH5q9ZE092v+3d6g9y+MP0rSR0yOhzD/nAV6 yij0DG92nWCLzjV9FzjThpU= X-Google-Smtp-Source: ABdhPJzhycUboTpC49Og5dyxs3aR2NUwKbYldNcNkiriHvt0HEJBsbOEZK4Uoye30aMEWSu3nDvefg== X-Received: by 2002:adf:e84a:: with SMTP id d10mr4642478wrn.60.1599165049590; Thu, 03 Sep 2020 13:30:49 -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 q186sm6818274wma.45.2020.09.03.13.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 13:30:48 -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: devicetree@vger.kernel.org, Jernej Skrabec , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Iwai , Marcus Cooper , linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Subject: [PATCH v2 05/20] ASoC: sun4i-i2s: Set sign extend sample Date: Thu, 3 Sep 2020 22:30:19 +0200 Message-Id: <20200903203034.1057334-6-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200903203034.1057334-1-peron.clem@gmail.com> References: <20200903203034.1057334-1-peron.clem@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 1b4482b0f4af..13e64180e917 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 @@ -671,6 +677,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; } @@ -767,6 +774,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; } @@ -863,6 +875,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