All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vasily Khoruzhick <anarsoul@gmail.com>
To: "Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	"Chen-Yu Tsai" <wens@csie.org>,
	"Marcus Cooper" <codekipper@gmail.com>,
	"Mylène Josserand" <mylene.josserand@free-electrons.com>,
	alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Subject: [PATCH 1/9] ASoC: sun4i-i2s: Add quirk to handle fixed WSS
Date: Sun,  3 Dec 2017 12:41:49 -0800	[thread overview]
Message-ID: <20171203204157.20829-2-anarsoul@gmail.com> (raw)
In-Reply-To: <20171203204157.20829-1-anarsoul@gmail.com>

I2S for audio codec on sun50i-A64 always uses fixed word select size value,
no matter what is sample width. Add quirk to support that.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 sound/soc/sunxi/sun4i-i2s.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 04f92583a969..54c16eb64713 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -132,6 +132,8 @@
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
  * @bclk_offset: Value by which bclkdiv needs to be adjusted.
  * @fmt_offset: Value by which wss and sr needs to be adjusted.
+ * @fixed_wss: Hardcoded 'word select size' value needs to be used
+ * @wss_value: Value to be used as WSS if fixed_wss is set
  * @field_clkdiv_mclk_en: regmap field to enable mclk output.
  * @field_fmt_wss: regmap field to set word select size.
  * @field_fmt_sr: regmap field to set sample resolution.
@@ -150,11 +152,13 @@ struct sun4i_i2s_quirks {
 	bool				has_chcfg;
 	bool				has_chsel_tx_chen;
 	bool				has_chsel_offset;
+	bool				fixed_wss;
 	unsigned int			reg_offset_txdata;	/* TX FIFO */
 	const struct regmap_config	*sun4i_i2s_regmap;
 	unsigned int			mclk_offset;
 	unsigned int			bclk_offset;
 	unsigned int			fmt_offset;
+	unsigned int			wss_value;
 
 	/* Register fields for i2s */
 	struct reg_field		field_clkdiv_mclk_en;
@@ -345,7 +349,7 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
 			       struct snd_soc_dai *dai)
 {
 	struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
-	int sr, wss, channels;
+	int sr, wss, channels, pwidth;
 	u32 width;
 
 	channels = params_channels(params);
@@ -386,7 +390,8 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
 	}
 	i2s->playback_dma_data.addr_width = width;
 
-	switch (params_width(params)) {
+	pwidth = params_width(params);
+	switch (pwidth) {
 	case 16:
 		sr = 0;
 		wss = 0;
@@ -396,13 +401,30 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
+	if (i2s->variant->fixed_wss) {
+		wss = i2s->variant->wss_value;
+		switch (wss) {
+		case 0:
+			pwidth = 16;
+			break;
+		case 1:
+			pwidth = 20;
+			break;
+		case 2:
+			pwidth = 24;
+			break;
+		case 3:
+			pwidth = 32;
+			break;
+		}
+	}
+
 	regmap_field_write(i2s->field_fmt_wss,
 			   wss + i2s->variant->fmt_offset);
 	regmap_field_write(i2s->field_fmt_sr,
 			   sr + i2s->variant->fmt_offset);
 
-	return sun4i_i2s_set_clk_rate(i2s, params_rate(params),
-				      params_width(params));
+	return sun4i_i2s_set_clk_rate(i2s, params_rate(params), pwidth);
 }
 
 static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-- 
2.15.0

WARNING: multiple messages have this Message-ID (diff)
From: anarsoul@gmail.com (Vasily Khoruzhick)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/9] ASoC: sun4i-i2s: Add quirk to handle fixed WSS
Date: Sun,  3 Dec 2017 12:41:49 -0800	[thread overview]
Message-ID: <20171203204157.20829-2-anarsoul@gmail.com> (raw)
In-Reply-To: <20171203204157.20829-1-anarsoul@gmail.com>

I2S for audio codec on sun50i-A64 always uses fixed word select size value,
no matter what is sample width. Add quirk to support that.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 sound/soc/sunxi/sun4i-i2s.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 04f92583a969..54c16eb64713 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -132,6 +132,8 @@
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
  * @bclk_offset: Value by which bclkdiv needs to be adjusted.
  * @fmt_offset: Value by which wss and sr needs to be adjusted.
+ * @fixed_wss: Hardcoded 'word select size' value needs to be used
+ * @wss_value: Value to be used as WSS if fixed_wss is set
  * @field_clkdiv_mclk_en: regmap field to enable mclk output.
  * @field_fmt_wss: regmap field to set word select size.
  * @field_fmt_sr: regmap field to set sample resolution.
@@ -150,11 +152,13 @@ struct sun4i_i2s_quirks {
 	bool				has_chcfg;
 	bool				has_chsel_tx_chen;
 	bool				has_chsel_offset;
+	bool				fixed_wss;
 	unsigned int			reg_offset_txdata;	/* TX FIFO */
 	const struct regmap_config	*sun4i_i2s_regmap;
 	unsigned int			mclk_offset;
 	unsigned int			bclk_offset;
 	unsigned int			fmt_offset;
+	unsigned int			wss_value;
 
 	/* Register fields for i2s */
 	struct reg_field		field_clkdiv_mclk_en;
@@ -345,7 +349,7 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
 			       struct snd_soc_dai *dai)
 {
 	struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
-	int sr, wss, channels;
+	int sr, wss, channels, pwidth;
 	u32 width;
 
 	channels = params_channels(params);
@@ -386,7 +390,8 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
 	}
 	i2s->playback_dma_data.addr_width = width;
 
-	switch (params_width(params)) {
+	pwidth = params_width(params);
+	switch (pwidth) {
 	case 16:
 		sr = 0;
 		wss = 0;
@@ -396,13 +401,30 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
+	if (i2s->variant->fixed_wss) {
+		wss = i2s->variant->wss_value;
+		switch (wss) {
+		case 0:
+			pwidth = 16;
+			break;
+		case 1:
+			pwidth = 20;
+			break;
+		case 2:
+			pwidth = 24;
+			break;
+		case 3:
+			pwidth = 32;
+			break;
+		}
+	}
+
 	regmap_field_write(i2s->field_fmt_wss,
 			   wss + i2s->variant->fmt_offset);
 	regmap_field_write(i2s->field_fmt_sr,
 			   sr + i2s->variant->fmt_offset);
 
-	return sun4i_i2s_set_clk_rate(i2s, params_rate(params),
-				      params_width(params));
+	return sun4i_i2s_set_clk_rate(i2s, params_rate(params), pwidth);
 }
 
 static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-- 
2.15.0

  reply	other threads:[~2017-12-03 20:42 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-03 20:41 [PATCH 0/9] Add audiocodec support for A64 SoC Vasily Khoruzhick
2017-12-03 20:41 ` Vasily Khoruzhick
2017-12-03 20:41 ` Vasily Khoruzhick [this message]
2017-12-03 20:41   ` [PATCH 1/9] ASoC: sun4i-i2s: Add quirk to handle fixed WSS Vasily Khoruzhick
2017-12-04  0:43   ` Chen-Yu Tsai
2017-12-04  0:43     ` Chen-Yu Tsai
2017-12-03 20:41 ` [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S Vasily Khoruzhick
2017-12-03 20:41   ` Vasily Khoruzhick
2017-12-04  6:42   ` Code Kipper
2017-12-04  6:42     ` Code Kipper
2017-12-04  7:34     ` Vasily Khoruzhick
2017-12-04  7:34       ` Vasily Khoruzhick
2017-12-05  8:01       ` Maxime Ripard
2017-12-05  8:01         ` Maxime Ripard
2017-12-05 23:04         ` Vasily Khoruzhick
2017-12-05 23:04           ` Vasily Khoruzhick
2017-12-06 15:27           ` Maxime Ripard
2017-12-06 15:27             ` Maxime Ripard
2017-12-07  9:21       ` Code Kipper
2017-12-07  9:21         ` Code Kipper
2017-12-07  9:30         ` Chen-Yu Tsai
2017-12-07  9:30           ` Chen-Yu Tsai
2017-12-07 22:48         ` Vasily Khoruzhick
2017-12-07 22:48           ` Vasily Khoruzhick
2017-12-08  6:40           ` Code Kipper
2017-12-08  6:40             ` Code Kipper
2017-12-08 22:16             ` Vasily Khoruzhick
2017-12-08 22:16               ` Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 3/9] ASoC: sun8i-codec: Add quirk to specify aif1_lrck_div value Vasily Khoruzhick
2017-12-03 20:41   ` Vasily Khoruzhick
2017-12-04  7:23   ` Code Kipper
2017-12-04  7:23     ` Code Kipper
2017-12-04  7:38   ` Chen-Yu Tsai
2017-12-04  7:38     ` Chen-Yu Tsai
2017-12-04  8:26     ` Chen-Yu Tsai
2017-12-04  8:26       ` Chen-Yu Tsai
2017-12-03 20:41 ` [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC Vasily Khoruzhick
2017-12-03 20:41   ` Vasily Khoruzhick
2017-12-05  8:04   ` Maxime Ripard
2017-12-05  8:04     ` Maxime Ripard
2017-12-05 23:17     ` Vasily Khoruzhick
2017-12-05 23:17       ` Vasily Khoruzhick
2017-12-06 15:32       ` Maxime Ripard
2017-12-06 15:32         ` Maxime Ripard
2017-12-06 15:48         ` Mark Brown
2017-12-06 15:48           ` Mark Brown
2017-12-06 18:53           ` Maxime Ripard
2017-12-06 18:53             ` Maxime Ripard
2017-12-06 19:13             ` Mark Brown
2017-12-06 19:13               ` Mark Brown
2017-12-03 20:41 ` [PATCH 5/9] ASoC: sun8i-codec-analog: Use callbacks to add headphones and lineout outputs Vasily Khoruzhick
2017-12-03 20:41   ` Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 6/9] ASoC: sun8i-codec-analog: Add component driver field to quirks structure Vasily Khoruzhick
2017-12-03 20:41   ` Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 7/9] ASoC: sun8i-codec-analog: Add support for A64 SoC Vasily Khoruzhick
2017-12-03 20:41   ` Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 8/9] arm64: dts: allwinner: a64: Add nodes necessary for analog sound support Vasily Khoruzhick
2017-12-03 20:41   ` Vasily Khoruzhick
2017-12-03 20:41 ` [PATCH 9/9] arm64: dts: allwinner: a64: Enable sound on Pine64 and SoPine Vasily Khoruzhick
2017-12-03 20:41   ` Vasily Khoruzhick
2017-12-05  3:24   ` Chen-Yu Tsai
2017-12-05  3:24     ` Chen-Yu Tsai
2017-12-09 19:54     ` Vasily Khoruzhick
2017-12-09 19:54       ` Vasily Khoruzhick

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171203204157.20829-2-anarsoul@gmail.com \
    --to=anarsoul@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=codekipper@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=mylene.josserand@free-electrons.com \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.