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.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 15151C00A89 for ; Fri, 30 Oct 2020 14:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A765C20727 for ; Fri, 30 Oct 2020 14:47:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eg6zCeWg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbgJ3OrQ (ORCPT ); Fri, 30 Oct 2020 10:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbgJ3OrL (ORCPT ); Fri, 30 Oct 2020 10:47:11 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAFC7C0613D2; Fri, 30 Oct 2020 07:47:11 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id k3so5769394otp.1; Fri, 30 Oct 2020 07:47:11 -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=/ufOq9Flrrc9vXqwE5zqji5Z5n7SZE+rxtv7Vn1g85Y=; b=eg6zCeWgrp65U4Aijwu42/kgWXWNgE3g/LAzQrSKBgP7g7/9vJN7jqA5NcvacBp9lc qaHeKOBXiyRTlM04TCmgo3jDudiCetwBO54sLSe4pU4FDmwLHdOr0Ljz7KO4Bd+hlQK/ K3lSfXQeTYwzZhuT9mTSyADmwLpH0cV01NYs8xSEp8f2GrVxkg9Kz1ikWLQ67bdKm0Rk BQ2HpSbkMo0lJepa3n7SS96D4ABcq2miMJLzSJeDv/dC/R4n9jZtu5WQzqR37dih54hQ BLsxHaF5xFHpYgvnDGXz9Mi/WEskj7S0lcwDD9NPDcpOk0Zzk7hVJaKtz2f5G7UsLYUk MN7g== 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=/ufOq9Flrrc9vXqwE5zqji5Z5n7SZE+rxtv7Vn1g85Y=; b=kZsCqFw7Iw0a4HKfaRytzDlBnZJac1gyHa2WhrDSj5O1oDYy3JivU1k/5xkerP+5Fd VcE0xXx6FDQ+5g7KdrCEFo6aIovbY972zmhaCU9gc7k4eIf0Y6TIzUCTeZscYM9z05Ri iwpEcheluL9HYOuRBaQgAnjIT+2Z/mNQtt6Zn6KITtDG1YO6McRJERrt68WQ6l9HcbgA UObnbdOlAm7PKtwsrdYxOHlsEXpaPcgSLGjMqlShHnWAPLLqTTMW3I6yWOqTZWnQGBwj UK00Aq/fBCWXj61sSKQ0mu1eqTMpUcrOYMfUEdxooHiEwYj9vzxMGpyGHh+KhDTlDpmx t6Hw== X-Gm-Message-State: AOAM533jitBxXwuEg4MKmQuBjLElKsaK5Qpwe/Cs3wNnFAlBVBnEF9+f yGOsxaGNiUsd6AdMGUTrG5s= X-Google-Smtp-Source: ABdhPJxmfFwnN568AH144QV8IaB64bG5SixGAAIGK/ifreoUdVD+GZVjd4ds6xaNAedqG7OUzR9rDg== X-Received: by 2002:a9d:1c7:: with SMTP id e65mr2088601ote.22.1604069231040; Fri, 30 Oct 2020 07:47:11 -0700 (PDT) Received: from localhost.localdomain (213-245-241-245.rev.numericable.fr. [213.245.241.245]) by smtp.gmail.com with ESMTPSA id s20sm1462856oof.39.2020.10.30.07.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 07:47:10 -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 v10 05/15] ASoC: sun4i-i2s: Set sign extend sample Date: Fri, 30 Oct 2020 15:46:38 +0100 Message-Id: <20201030144648.397824-6-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201030144648.397824-1-peron.clem@gmail.com> References: <20201030144648.397824-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 Acked-by: Maxime Ripard 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 6ee9c2995b4f..46e4da18c27f 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 @@ -686,6 +692,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; } @@ -788,6 +795,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; } @@ -890,6 +902,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