Received: by 10.213.65.68 with SMTP id h4csp134896imn; Mon, 12 Mar 2018 09:01:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELvuEjasPdgm4LLfXHGx4+OR2haNcrfgW7cfN7FFJHb5EuXGv/jP9Uc4kL0TUO5AcrqOgkW/ X-Received: by 10.98.28.202 with SMTP id c193mr8494134pfc.109.1520870482423; Mon, 12 Mar 2018 09:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520870482; cv=none; d=google.com; s=arc-20160816; b=HPc1NA+ZBiOzPopATAPZj5+Otmv2IOoAh8jcSlQOC9plv/LItJBC8SKXJ7ZmygsD0F oWznzUwQ0gkWrJa1F6Pse5Wy7kKSH7zPm44HswtuQMFB0On42vjWKfH0irKB3wRTemPN xWOW7EFLmwKymIsc3hFPAQewyrOi8M8ortvoY8VPcKu6mlvSFOazsSGZVmWPWZ2f2/+B VDLbNZOTnlzB9CrbouMkOvMSS/e1tD6vCR4tnlkOTcy7eIktavZiZqoceQrd891mGUQj x6AlXDYJ/uw4yIQl4y1L1N5JIHU2TFcKTFCzg/9Og2JB0E4ROBjKUR0rkn7axsRXZWx1 xXJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=yijg2TdjJ6PtPJdRHY4VSzwYjZUowLxUWHyLfwt5vGQ=; b=NngHDPmmbMFEdOH4MiNDOP+L/newzZ1Q77vUUpOYUILY6zsVDhqX+M/urqJqHgiffD 7TWl8RZqVxgzJDbGkoz6IhfXRFaXBevnVdsKBLn3wS5shChqS73XVxd2TikAnVZudIz1 cu0qPKu0oAfLg8d2sm0WpUi+OZ8U49SE7WxVUwZYu6klVnQATzFDSKMK/XP7lB7V+QPu jQySQPTEhxNqmtn8MLPPom2Pz4CRtl25bXRkEqO9Ya+EUl8JCGbMR8HjV+NNOlh/liFx YMA07XzJ/T5ElBmDR8pRXP934I2Z6jbYOX4NydWLLLfh/YHn7QNnv8jwsyECmiqgqXOz s4jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VB1690bm; 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 s9-v6si6106780plr.57.2018.03.12.09.01.02; Mon, 12 Mar 2018 09:01:22 -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=VB1690bm; 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 S932792AbeCLP7Y (ORCPT + 99 others); Mon, 12 Mar 2018 11:59:24 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:43988 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932425AbeCLP6A (ORCPT ); Mon, 12 Mar 2018 11:58:00 -0400 Received: by mail-lf0-f68.google.com with SMTP id q69-v6so24002800lfi.10 for ; Mon, 12 Mar 2018 08:58:00 -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; bh=yijg2TdjJ6PtPJdRHY4VSzwYjZUowLxUWHyLfwt5vGQ=; b=VB1690bmLLUujFgUCnGVAt5g1eGJOgJ7kxCcCM0Dzbb/mv5AwccAUeG81XYVw41Gx3 y+2k3XjhHxgOCRe+5dEzViUhT2SzyQ0w+ZcA3IXGOX/lYYH/e/i6O2HpZ1OCwP0f69JO sz29twbetR8ILOuxv9qqCnuHn1phPP/5UfmLKFZ+iOFlTp9wKjsZSN3VElewTtg66nRr 082ADqC+YKDWxNwtVs7R+f5Gmy1H5sQ2J+JSsklujoJ7xc3v2lqcWdyXMcD5U5ScVRx1 J5wKBreh6nowP1eieJo5BHoxIgQaFX3MiCmFzXG/jT2C1Duw/QUJgM5nHFbw1OJlhaw1 NA4A== 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; bh=yijg2TdjJ6PtPJdRHY4VSzwYjZUowLxUWHyLfwt5vGQ=; b=ClZFn0tMbry2de7mlTnfuVQxanfCFD8Axgowj6xr3TEa+UpkKsAkp7NI1maPh8OmqM vFIuharc7DOx8IIPPoYlD/x9AL7zwNyRlcp+6HF8iECcUPU2OIi2GY8kWNMb5hKfn7XU HAyR0uI/UpOR9v2rYFY0PJsQAcqfXKFw4yIpQsp+595L6Wt9PqxkTfvPfCiflQGN2OAG SgssjduZ8hwsmYiELSHrjVRoAzqRbZdSc8HCJ5gu7yyp0K1m2fygDHxIv1xQO0Iwk5lS bUwleG8sH3FLPW8A6BMuQPVkP9i+c/RyQbydChsRZRDDMaSdUhYlxmxYLdW8a5jBstJk SQNg== X-Gm-Message-State: AElRT7HbzFx/c+TaT90zWe++nN7ub1ZtJ0QjXtUTzkp9cv6vlZXGdcSL xbQpKX2cAqkseO4PJmaXqwo= X-Received: by 2002:a19:db94:: with SMTP id t20-v6mr5263311lfi.39.1520870279175; Mon, 12 Mar 2018 08:57:59 -0700 (PDT) Received: from localhost.localdomain (c83-253-254-90.bredband.comhem.se. [83.253.254.90]) by smtp.gmail.com with ESMTPSA id h11-v6sm1833448lfd.88.2018.03.12.08.57.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 08:57: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 v2 2/6] ASoC: sun4i-i2s: Add regmap field to sign extend sample Date: Mon, 12 Mar 2018 16:57:49 +0100 Message-Id: <20180312155753.9478-3-codekipper@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180312155753.9478-1-codekipper@gmail.com> References: <20180312155753.9478-1-codekipper@gmail.com> 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 (H3, H5, A64 etc) this is set by default to transfer a 0 after each sample in each slot whereas on the earlier SoCs (A20, A31 etc) the default sign extension is to pad the LSB. Add the regmap field to configure this and set it so that it pads the sample with 0s. 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 873054a6c3be..396b11346361 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -138,6 +138,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. @@ -163,6 +164,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; @@ -187,6 +189,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; @@ -348,6 +351,9 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, SUN8I_I2S_FMT0_LRCK_PERIOD_MASK, SUN8I_I2S_FMT0_LRCK_PERIOD(word_size)); + /* Set sign extension to pad out LSB with 0 */ + regmap_field_write(i2s->field_fmt_sext, 0); + return 0; } @@ -901,6 +907,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), @@ -918,6 +925,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), @@ -958,6 +966,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), @@ -1003,6 +1012,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.16.2