From patchwork Tue Oct 27 18:31:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11861343 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_SIGNED,DKIM_VALID,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=ham 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 87710C4363A for ; Tue, 27 Oct 2020 18:33:12 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 1BD0E20724 for ; Tue, 27 Oct 2020 18:33:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Um4jWqIg"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hfD0lzWr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BD0E20724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YEMY9Mk9acqEjCliK2mSz//CkVqOjJ3pkJn56MRtnwc=; b=Um4jWqIgy8NZ5qVkhupa9ti9i S7lrGtJy9fD3xyLH1SnSr92rBaz9KSfHURsWGUumusiXtb6FvsmdUXVX50s0Z+55L72J6XicCRTJQ 4L60oqgYC1KsPS6PiQ5ze2Ic1VgDImaOst4ubeoo+xJxOoDXJasFxKzbKwLAukJ12pWKQ4eOViHQs 0TovSR+KvtM0tZxT8tMAaeulChqd8je6+XUsz0BTNAPOLUiD9XslVlW0p3UHyT5lum5aMjkb+SufX 9Wvbfa68u2zvTWH5HphSHCdDvILZ/ir+C6BL4peTFIXFTnQOLZJ8gWbyb34UCHVDuv10uzIvDD9JB sv6LovT2A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXTlm-0002c6-KW; Tue, 27 Oct 2020 18:32:30 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXTlG-0002QI-6z for linux-arm-kernel@lists.infradead.org; Tue, 27 Oct 2020 18:32:03 +0000 Received: by mail-wr1-x442.google.com with SMTP id b8so3078913wrn.0 for ; Tue, 27 Oct 2020 11:31:58 -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=PzIzkaAO7tDGE4Xw0UBFwOTz26e4q0eFQkKHnes8+P0=; b=hfD0lzWrpzfZOIduBPFba3YAYManfeVarb3bKIdMXRc5b6DtV5rN8nGTpbr0BQX0qR pHqtI1aXXMw3YLLd4VAEZLXEhLkmlvPv76MlAaTNtP8OEhiJS+cmqSy+31XSDoUrLLH+ Xu3eWYQuGL++qB0LvvocxJg0MgmOta9Ywn6Lt78wFYLNin9yB8sM22PBbUB5V56pEepn YuZ71YdqZ4nPuNHdtb5caERa6AuB0fRMeY793DaNPwVRiX1Ap5PlVpxGmxYmDE9JADto p6QCotdYHYu5A+1qEzUsAKabdAykBEe1/wOOlFeIZbNUmhODtNEbVJxFlpjnKEt/1bQe pcwQ== 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=PzIzkaAO7tDGE4Xw0UBFwOTz26e4q0eFQkKHnes8+P0=; b=VAaUDl7CSf8vBOfhjwkwqvbV2Y0I9aCaaJDyR2r3fPyRtAYW1Q6LanLJVcvqxiNZxo c+GpEQjm8mNK/XCT3jY8aZC+vuz8KKq5RjuGbC9fyIqr3pQpC5TXAxHv9enDQY8rARza p3msHmaKq1AnoOkDbtewlqEfZl9JoF5+DULczXDViTZP3uz8Dy3SDLBVbaovoh15hX72 OAg1S6DoonyTMEwRTYDEJ6tCcUuaqjmK/iHkK5PRgirFIBL64BDl1ejMYRhY6nHgItdR 1mkUogESvbTDC28hayWGHD42f10c5u5gL7naMIZ9CsGLbhPOpf2bGOCh4MDRYcjwYUxn eeDw== X-Gm-Message-State: AOAM5310ImcdxK+/v1uXG3lfBupDO0nerWahaobU69f+GRNooruzNjxW 9vwLuOia1P7YM5xVojcie24= X-Google-Smtp-Source: ABdhPJwMwK6nzkh0dSOrG4Zp1NIatSqiv5juI0VS0YtzY1h6rKylT8P1NxrdyZGomNP6L2JT/BtS3A== X-Received: by 2002:adf:ce8a:: with SMTP id r10mr4595923wrn.188.1603823516832; Tue, 27 Oct 2020 11:31:56 -0700 (PDT) Received: from localhost.localdomain (lputeaux-656-1-11-33.w82-127.abo.wanadoo.fr. [82.127.142.33]) by smtp.gmail.com with ESMTPSA id m9sm2864148wmc.31.2020.10.27.11.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 11:31:55 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Maxime Ripard , Chen-Yu Tsai , Rob Herring , Mark Brown , Liam Girdwood Subject: [PATCH v9 04/14] ASoC: sun4i-i2s: Set sign extend sample Date: Tue, 27 Oct 2020 19:31:39 +0100 Message-Id: <20201027183149.145165-5-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201027183149.145165-1-peron.clem@gmail.com> References: <20201027183149.145165-1-peron.clem@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201027_143158_405591_B39A4A94 X-CRM114-Status: GOOD ( 15.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Jernej Skrabec , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Iwai , Jaroslav Kysela , Marcus Cooper , linux-sunxi@googlegroups.com, =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 073ee60da011..9f9d3e7baad0 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; }