Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4443699ybi; Mon, 3 Jun 2019 10:57:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqw69sVEJy63kIvtM1hrVG27Bvxb9UGUVgXKeIUWWs+EaC/s3UFYKv2BwCFOhdAA2+CssDxg X-Received: by 2002:a17:902:8c94:: with SMTP id t20mr30364607plo.141.1559584649660; Mon, 03 Jun 2019 10:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559584649; cv=none; d=google.com; s=arc-20160816; b=V0zAfR4ypdvUdmEAySzsh9iTYM4nN7oQCEb3Loc2Xhn3bX7TzEbxMKNw349W76jVzt xyYBrnud78C62LpfGeBETBJO0xWBqa0xpu3rj/7gqX//ReAgDl9UPNtranE2DAap8WKF g3P7OYnQxEhejXUFl8dZfhvnYB7DFcTp8ysHLj110wAX+E9EdO+5MMExbjnxGBIcChMj ss72BckAcqPccpDWO4hsEyh5tiEVx/oCefPmHD/Q6aEXHamTBFpbfnetegeWZGA8YAeO 5FHkQIPaiy+B/H6t25N7EAaFyGIcHoIwOHzw6dihm7GEZuMVT53rmWx9Nj7t5uZvi4MD tQmg== 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=eTpr5vmYx+4PQoKXbPkvuxXzIJqpQ3J3+BEDcR37i9o=; b=K606Y6verpNrewlFXwpRxz/zjgsyqxGdtwk8GwFAyl4TK27HicTN0SSPHsTMIeAwHQ Q/kMpXl6Vs/hzXi6pfzUzRsKMGxGxLiAYvlLVC/jbi5OEUNlLw+a95hkfG855dc2JZk6 D+wXidbVM6OIRbT4joTDEp6rBj1GyH7Jc0LnxAzq64aLFDDgpQiCmbmBuonaPpEbz3KF 6RZ3y0asfBJJaLH/e0m6LHb1YNQ2KHLP0SbxzINxJBqQv9+YpW0rWvFZAZ93t7HpsOFr lerBVAHjDa1vr7Ca+7mkYeYeufYN9FGVMu9S14SQZFl+sAAFow4ADuN10nkOS2d6FkXA H3hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AdhORNEG; 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 s17si6717867pfc.237.2019.06.03.10.57.13; Mon, 03 Jun 2019 10:57:29 -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=AdhORNEG; 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 S1729028AbfFCRro (ORCPT + 99 others); Mon, 3 Jun 2019 13:47:44 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:40730 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728966AbfFCRrn (ORCPT ); Mon, 3 Jun 2019 13:47:43 -0400 Received: by mail-lf1-f67.google.com with SMTP id a9so12869956lff.7 for ; Mon, 03 Jun 2019 10:47:41 -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=eTpr5vmYx+4PQoKXbPkvuxXzIJqpQ3J3+BEDcR37i9o=; b=AdhORNEGJyXa28hjmgyo+I46Wacno8kLfpt5N581IFLrUXkcGYATKdc9DktXkTSftY 5fF/V8rwGZYcsdkLst4jq1jCHNY8gcFoUIU3j/DloS+iritZfrBnZSJhDnzOWvYroBR4 ZQ5VkrfHTCc3CJLwKlxjyT6qOCGMmd+prkSjvi+jjeyjNNsBtt8VY57ecOL1pkUhFD3u S+EJH458MjZqPDGIj5/wvIAg5RIR1HywmNaGoZCD6ocmoYSD9mzODxr7G0QAXMCh6Mf6 ILspvhgjwtR6Ix7P1h6OMQrNN57x6pVeU1MCLYqVrY/xNRnTN3X8Y4V9v5ax0pNByujl Ncqw== 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=eTpr5vmYx+4PQoKXbPkvuxXzIJqpQ3J3+BEDcR37i9o=; b=HpddZh55WcJjmiO7S5sHIiNGda0Xu9+P4hqQiyHlZjCXwv45/3ohzue/Gai6c6sFCN BfkuOxWRS8O4sAyD0BhBvhlbyCp33zjtyWXp2GBT6q2q9T1DGxbM+aWadD8DraGgrCrg 9k9iHE7gTVPMiOfVA3dwWaryugjo8r2/iIpRM/v+1c20V540UwAaWIL/nPoWXXi4Nyca DC8tnPbgPiMD4j9Uwd8A+ClIKK9j4L6zFWbpPaf60fPd1AbPovTQHL9uDBfp25IkkQNO uBy/rTrxRxcwQNvwujZlRD1Yro3D8+OLbGjNdkni/DMwxT35kO56yHLS5YH811udAXkP MyAQ== X-Gm-Message-State: APjAAAX59fLf44xE3acwgBoVggbKB/k315GQi0nL/rgEeRW7BpvJRj8W mE7RznJwwWVcvpCAdq8EBzA= X-Received: by 2002:a19:9e53:: with SMTP id h80mr14028072lfe.77.1559584060567; Mon, 03 Jun 2019 10:47:40 -0700 (PDT) Received: from localhost.localdomain ([188.150.253.81]) by smtp.gmail.com with ESMTPSA id n7sm2803532lfi.68.2019.06.03.10.47.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 10:47:40 -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 v4 3/9] ASoC: sun4i-i2s: Add regmap field to sign extend sample Date: Mon, 3 Jun 2019 19:47:29 +0200 Message-Id: <20190603174735.21002-4-codekipper@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603174735.21002-1-codekipper@gmail.com> References: <20190603174735.21002-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 this is set by default to transfer a 0 after each sample in each slot. However the platform that this driver was developed on had the 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 it should be fixed to also pad. Without this the audio gets distorted. Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sun4i-i2s.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index fd7c37596f21..e2961d8f6e8c 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -134,6 +134,7 @@ * @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; @@ -183,6 +185,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; @@ -342,6 +345,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; } @@ -887,6 +893,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), @@ -904,6 +911,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), @@ -944,6 +952,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), @@ -1006,6 +1015,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.21.0