Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp391424ybl; Tue, 13 Aug 2019 23:10:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJwVTTA5JqSeerZHs0Yi3E6tLh7JOozzYeceBzTfwGKoLZ0YVayHrHPFquShviN28vhnu9 X-Received: by 2002:a17:90a:fe5:: with SMTP id 92mr5649203pjz.35.1565763013759; Tue, 13 Aug 2019 23:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565763013; cv=none; d=google.com; s=arc-20160816; b=JQOSnv2ALeuqN0PH+dBNyKAMlosz2E8c1bLNKFeW7Db5UiUFd1AHmAM1jIJ57QUes7 hZAhFylNVSaejnnyjL2b60ikq7Rf1C7PcGU4zYqip23o4RVAUOsEVvCnUZIrKTvA+ALp DI9flc11Sl0vDPfUq68nvqqK8C3lbOg7NLH9DPc6C31IlDtlw/V3hwyNTaJgrHj9sxIV tEy0ztyHQMqQEmuKwUxf8xfn5tP5UabFVYMOZTqnFX2p0JYafMcwqcdGXw04P1NCLnMj LRB7rCEbSFKn+DVadZvU6c+pXvg+f0hVBX81NjJtFwbFubOUdV+iKhY6KbVjzsfZ4c2F vz+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WcXLpkWRNvSxcqtatiiekWehZjraN19gKJu3w8caFTE=; b=RHbBsSP6fm9dZofS5tpJmnlCIGdvCVTUQxoRLsz7uWxWg3t/4STMVj7oVihe/sWUTg JB++UNfQWowgnJeZo43pXa25mUYntoyqlw6xJLAYlD99Ecikt1WKYej/Ip687rBHu6rc G8j/WyMM937K1mp8aA3XffuFnYMjpjPoI6CkQWUp4JObhO+wkLwOKbQ2aUWceAFtLB2X 1LwGbNM4qfWOCM4TVZnMjCPpnO+vbuyJd82ihrCjg3wKllrmhgWkKDa8sY20zDRw9shE dW/UvdLFa88qvgsmyqPSsxNEWobj6qAiE13wi2HABh7Nr7yEI9MRaW5vatYKpciJxv4U SyCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=k+iVAlO1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j16si57088372pfh.0.2019.08.13.23.09.41; Tue, 13 Aug 2019 23:10:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=k+iVAlO1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727447AbfHNGJC (ORCPT + 99 others); Wed, 14 Aug 2019 02:09:02 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:33723 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727198AbfHNGJB (ORCPT ); Wed, 14 Aug 2019 02:09:01 -0400 Received: by mail-lf1-f67.google.com with SMTP id x3so78574097lfc.0 for ; Tue, 13 Aug 2019 23:08:59 -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=WcXLpkWRNvSxcqtatiiekWehZjraN19gKJu3w8caFTE=; b=k+iVAlO1Ic0+XyC1XvdM9+B5qmVcF4DbIhOV66/zc6fLSEACgC8aDdct29YKugVIx0 qrHZOY9Kerz6/msxIrbCmYxJLdDN/WAUFKPe6e4mmVeNZRA2PF3G6FG5ozyyQOGlP29J 21Y7qFUcumZe8ICuj/hcmK+5CMBcmMj19c4eGbW3FDTvEycMD99NEoXzIONsjoOnFf5w yl4q/TdHBNaMg33U4ElrAs3H0IsacPH2G5SXug//bAXCcnd6wWrliaA5cBRBBru2ClqC scIOuz7SOPceYpELkdPmDdPJtJZ03vZDZxRoyP3+sR91cCTKTivYkKZdQXLxkQdIjCif DI6A== 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=WcXLpkWRNvSxcqtatiiekWehZjraN19gKJu3w8caFTE=; b=ojZu8P9si1xIdM9nOjHtoEM5gilSht61ABVuA6rUc/qQ4Z2LT+72As/Fb5JmtHAVS1 8ipl08cuta2C6mPWgMJfcRinL6GP5t1TBnr9JtHQ+vWHtubPG/HGk4nSKb5Gxy69RkGo prM1MutGtDeX+onN1EkJZ8turIbvg8TFzdM9chbNgQ9UPkZXhUrA43t/tmRhjgieVwnL hKfXS6qEKZvPQbmxuQwNvhbRd2fkPWwXqP9id+y8/UeJDJE9ycaYAYZ11wZPIeQVqatY GVkeTRsTMvXTRmnyd5shNs0HSqGsfP8w3Meyg3Zg9q/eXz6BCQYFZdu4oILHW4yQaVHr aYGQ== X-Gm-Message-State: APjAAAXobz9+ZIvpO8wO8XDPKTCUXP/bd7vxuXD4Dl4jThUIyAAkFrs3 A89NV++TOBZIDnZwCRIAEaM= X-Received: by 2002:ac2:54a3:: with SMTP id w3mr25207168lfk.169.1565762939167; Tue, 13 Aug 2019 23:08:59 -0700 (PDT) Received: from localhost.localdomain (c213-102-74-69.bredband.comhem.se. [213.102.74.69]) by smtp.gmail.com with ESMTPSA id s10sm3124235ljm.35.2019.08.13.23.08.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 23:08:58 -0700 (PDT) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com, wens@csie.org, linux-sunxi@googlegroups.com Cc: linux-arm-kernel@lists.infradead.org, lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, be17068@iperbole.bo.it, Marcus Cooper Subject: [PATCH v5 01/15] ASoC: sun4i-i2s: Add regmap field to sign extend sample Date: Wed, 14 Aug 2019 08:08:40 +0200 Message-Id: <20190814060854.26345-2-codekipper@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814060854.26345-1-codekipper@gmail.com> References: <20190814060854.26345-1-codekipper@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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 whilst 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. Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sun4i-i2s.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 793457394efe..8201334a059b 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -135,6 +135,7 @@ struct sun4i_i2s; * @field_fmt_bclk: regmap field to set clk polarity. * @field_fmt_lrclk: regmap field to set frame polarity. * @field_fmt_mode: regmap field to set the operational mode. + * @field_fmt_sext: regmap field to set the sign extension. * @field_txchanmap: location of the tx channel mapping register. * @field_rxchanmap: location of the rx channel mapping register. * @field_txchansel: location of the tx channel select bit fields. @@ -159,6 +160,7 @@ struct sun4i_i2s_quirks { struct reg_field field_fmt_bclk; struct reg_field field_fmt_lrclk; struct reg_field field_fmt_mode; + struct reg_field field_fmt_sext; struct reg_field field_txchanmap; struct reg_field field_rxchanmap; struct reg_field field_txchansel; @@ -186,6 +188,7 @@ struct sun4i_i2s { struct regmap_field *field_fmt_bclk; struct regmap_field *field_fmt_lrclk; struct regmap_field *field_fmt_mode; + struct regmap_field *field_fmt_sext; struct regmap_field *field_txchanmap; struct regmap_field *field_rxchanmap; struct regmap_field *field_txchansel; @@ -345,6 +348,9 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, SUN8I_I2S_FMT0_LRCK_PERIOD_MASK, SUN8I_I2S_FMT0_LRCK_PERIOD(32)); + /* Set sign extension to pad out LSB with 0 */ + regmap_field_write(i2s->field_fmt_sext, 0); + return 0; } @@ -917,6 +923,7 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), .has_slave_select_bit = true, .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), + .field_fmt_sext = REG_FIELD(SUN4I_I2S_FMT1_REG, 8, 8), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -936,6 +943,7 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), .has_slave_select_bit = true, .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), + .field_fmt_sext = REG_FIELD(SUN4I_I2S_FMT1_REG, 8, 8), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -979,6 +987,7 @@ static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 19, 19), .field_fmt_mode = REG_FIELD(SUN4I_I2S_CTRL_REG, 4, 5), + .field_fmt_sext = REG_FIELD(SUN4I_I2S_FMT1_REG, 4, 5), .field_txchanmap = REG_FIELD(SUN8I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN8I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN8I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -998,6 +1007,7 @@ static const struct sun4i_i2s_quirks sun50i_a64_codec_i2s_quirks = { .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), + .field_fmt_sext = REG_FIELD(SUN4I_I2S_FMT1_REG, 8, 8), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -1045,6 +1055,12 @@ static int sun4i_i2s_init_regmap_fields(struct device *dev, if (IS_ERR(i2s->field_fmt_mode)) return PTR_ERR(i2s->field_fmt_mode); + i2s->field_fmt_sext = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_fmt_sext); + if (IS_ERR(i2s->field_fmt_sext)) + return PTR_ERR(i2s->field_fmt_sext); + i2s->field_txchanmap = devm_regmap_field_alloc(dev, i2s->regmap, i2s->variant->field_txchanmap); -- 2.22.0