Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3028277pxk; Mon, 21 Sep 2020 03:30:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuHJcZCy9FIhHhCrv6e4ON0N/guxgiGyVcjZnv4jP4iyWNDFVcLSGLUDUdgRmLDxWcXLEq X-Received: by 2002:a50:cf8a:: with SMTP id h10mr52342433edk.43.1600684223984; Mon, 21 Sep 2020 03:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600684223; cv=none; d=google.com; s=arc-20160816; b=aAm1jsFx51ILG/R75NzF6glTAqG0k9kjaPOw91YlRzRMteKIStoyX5a7WufgMU7ftD GtKzLtolkzk8aw60uWgKUl/CnDRSirWlT8ak4Ta+DEpmpMJczaDw2q3P7vVgD2A8LcTD Q5uE3A7AISmPgffJgSU9xY/GHbwe3g4uayFKj43J/HzTotnToIMtrfP9G+NwHWqaOGss HfsNyGkh7GoTkOe4x/XUSX7wE9usmI5bwpQyoIarCXptydSinE3s4ZO3Wdr9bnaSH+8m 8V/HoASe+pndcO2BUS37TcDJ3UlW2UNjJBme96+L5jI3A3dPeLlFQOVDAIYkbk1Z52aM jD1w== 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=IkA5ZIA1KxHZ5pTf87m4sDK9/i82Ww5AqVaY+sWQc6ov/JtIoH6Eox8RoZoeOJQDy+ oqHvDRvNegaHRnY0tE7bVBUedSImEhOINzGtXN2M3kNICyPtBlD14iSeCRM1P8SK4AVv 1YMrwfD9toJdjIVZY2Mwv21haXnOoBdY5dY+rGOpK7AEsurMta3nxlok4Wv1kDXqPRO4 qpbqLX9Zwk+1BvF+Ezyo7jxFysqn/UJDyTtpTIOq+82ZFAQR+JSprgGGFx41Y5xNQJ1H G0XhAANuLSxcpVgN9dBGQ5pm8LS02Cf1/bBwGwlVYmnnxBa6JSbjCsfpoONV/gA/hK52 rm7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ZbuYowe/"; 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 r26si7847421eda.569.2020.09.21.03.30.00; Mon, 21 Sep 2020 03:30:23 -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="ZbuYowe/"; 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 S1726470AbgIUK3D (ORCPT + 99 others); Mon, 21 Sep 2020 06:29:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbgIUK1n (ORCPT ); Mon, 21 Sep 2020 06:27:43 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 698D9C061755; Mon, 21 Sep 2020 03:27:43 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id e17so11583526wme.0; Mon, 21 Sep 2020 03:27:43 -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=ZbuYowe/exjNSbzyxWOsn0UkKuQtse3CnJeL9q8ycWEJieTy1i2UN3YU9zsuUdOay6 7nENve0r6Uegf7qeymFnFzLLXkkEwU86uVPdvxV8t1ReqijDJK1cI0WNPMPASQtAXZGq ii+Rv1shuaiirWfJdVC4xDZbT9FMYlJ4OWwBLKFfY5hGramdfm7Sl5mWs5weEgS6lO8x Ex2576w4v5VrB5epna9j9fgIZpX+vUeC8AG8TdgqDvaybZwKfib+2x9d87LVxlGCFn9U 2e4pZIifUVW4RjNZeCpf702urA0M30GYCpVei+Ud7fRj7CXbNAu9ZEZfMTJz9ZR7hag9 Vi2A== 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=lGBy7U4Ev4txIwGySgD9F2Vmxd2p6GUz4hEh/5jANed558vfAAXm4e5BuLGJFM9v8d iE7TVZP+CZ30rj5N7WZdS9MFm53BrCVe67Gi1RRSU0B80pFbODZwHy32wWMz+E6pjRtQ 4X9ASWi3Ve/2nfPVndpY7wLTf5Mu1gKUAP5DGXPxpRCckDrr7MDJjVLFHCbONFgxAvct legs9/SDrVI5YR0Q5RbI0pEGaN7uVWB3+eitY+YEw/mM+j4FnphOigj0T2HZym3yJNKN XMxyXkOhOzlc/aSzPd04V81YvxfQFAWQ9RuoAzc0s5SVCLTt561Rs/xIVczSjmLfM12W 014Q== X-Gm-Message-State: AOAM532mRu3t7A7Qo44QnhyM3kcuHwALu0zvnKwpLJPdcTl4MHh9NRHr dd6klwAGyLn+I0HQi01FYOw= X-Received: by 2002:a7b:c0ca:: with SMTP id s10mr29366622wmh.103.1600684061978; Mon, 21 Sep 2020 03:27:41 -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 h2sm20713774wrp.69.2020.09.21.03.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 03:27:41 -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 v4 05/22] ASoC: sun4i-i2s: Set sign extend sample Date: Mon, 21 Sep 2020 12:27:14 +0200 Message-Id: <20200921102731.747736-6-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200921102731.747736-1-peron.clem@gmail.com> References: <20200921102731.747736-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