2020-10-30 14:51:18

by Clément Péron

[permalink] [raw]
Subject: [PATCH v10 00/15] Add Allwinner H3/H5/H6/A64 HDMI audio

Hi,

This series add H6 I2S support and the I2S node missing to support
HDMI audio in different Allwinner SoC.

As we first use some TDM property to make the I2S working with the
simple soundcard. We have now drop this simple sound card and a
proper dedicated soundcard will be introduce later.

This make the title of this series wrong now but to be able to
follow the previous release I keep the same name.

Regards,
Clement

Change since v9:
- fix lrck_period computation for I2S justified mode

Change since v8:
- move the comment near the function prototype
- collect Maxime Ripard tags

Change since v7:
- rebase on next-20201026
- comment about slots and slot_width

Change since v6:
- move set_channel_cfg() in first position
- convert return value to decimal

Change since v5:
- Drop HDMI simple soundcard
- Collect Chen-Yu Tsai tags
- Configure channels from 9 to 15.
- Remove DMA RX for H3/H5
- Fix Documentation for H3/H5

Change since v4:
- add more comment on get_wss() and set_channel_cfg() patch
- merge soundcard and DAI HDMI patches

Change since v3:
- add Samuel Holland patch to reconfigure FIFO_TX_REG when suspend is enabled
- readd inversion to H6 LRCK sun50i_h6_i2s_set_soc_fmt()
- Fix get_wss() for sun4i
- Add a commit to fix checkpatch warning

Change since v2:
- rebase on next-20200918
- drop revert LRCK polarity patch
- readd simple-audio-card,frame-inversion in dts
- Add patch for changing set_chan_cfg params

Change since v1:
- rebase on next-20200828
- add revert LRCK polarity
- remove all simple-audio-card,frame-inversion in dts
- add Ondrej patches for Orange Pi board
- Add arm64 defconfig patch

Clément Péron (7):
ASoC: sun4i-i2s: Fix lrck_period computation for I2S justified mode
ASoC: sun4i-i2s: Change set_chan_cfg() params
ASoC: sun4i-i2s: Change get_sr() and get_wss() to be more explicit
ASoC: sun4i-i2s: Fix sun8i volatile regs
ASoC: sun4i-i2s: fix coding-style for callback definition
arm64: defconfig: Enable Allwinner i2s driver
dt-bindings: sound: sun4i-i2s: Document H3 with missing RX channel
possibility

Jernej Skrabec (3):
ASoC: sun4i-i2s: Add support for H6 I2S
dt-bindings: ASoC: sun4i-i2s: Add H6 compatible
arm64: dts: allwinner: h6: Add I2S1 node

Marcus Cooper (4):
ASoC: sun4i-i2s: Set sign extend sample
ASoC: sun4i-i2s: Add 20 and 24 bit support
arm64: dts: allwinner: a64: Add I2S2 node
arm: dts: sunxi: h3/h5: Add I2S2 node

Samuel Holland (1):
ASoC: sun4i-i2s: Fix setting of FIFO modes

.../sound/allwinner,sun4i-a10-i2s.yaml | 6 +-
arch/arm/boot/dts/sunxi-h3-h5.dtsi | 13 +
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 14 +
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 13 +
arch/arm64/configs/defconfig | 1 +
sound/soc/sunxi/sun4i-i2s.c | 388 +++++++++++++++---
6 files changed, 378 insertions(+), 57 deletions(-)

--
2.25.1


2020-10-30 14:52:05

by Clément Péron

[permalink] [raw]
Subject: [PATCH v10 04/15] ASoC: sun4i-i2s: Change get_sr() and get_wss() to be more explicit

We are actually using a complex formula to just return a bunch of
simple values. Also this formula is wrong for sun4i when calling
get_wss() the function return 4 instead of 3.

Replace this with a simpler switch case.

Also drop the i2s params which is unused and return a simple int as
returning an error code could be out of range for an s8 and there is
no optim to return a s8 here.

Fixes: 619c15f7fac9 ("ASoC: sun4i-i2s: Change SR and WSS computation")
Reviewed-by: Chen-Yu Tsai <[email protected]>
Acked-by: Maxime Ripard <[email protected]>
Signed-off-by: Clément Péron <[email protected]>
---
sound/soc/sunxi/sun4i-i2s.c | 69 +++++++++++++++++++++++--------------
1 file changed, 44 insertions(+), 25 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 24b3137afbc2..6ee9c2995b4f 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -175,8 +175,8 @@ struct sun4i_i2s_quirks {
unsigned int num_mclk_dividers;

unsigned long (*get_bclk_parent_rate)(const struct sun4i_i2s *);
- s8 (*get_sr)(const struct sun4i_i2s *, int);
- s8 (*get_wss)(const struct sun4i_i2s *, int);
+ int (*get_sr)(unsigned int width);
+ int (*get_wss)(unsigned int width);

/*
* In the set_chan_cfg() function pointer:
@@ -387,37 +387,56 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai,
return 0;
}

-static s8 sun4i_i2s_get_sr(const struct sun4i_i2s *i2s, int width)
+static int sun4i_i2s_get_sr(unsigned int width)
{
- if (width < 16 || width > 24)
- return -EINVAL;
-
- if (width % 4)
- return -EINVAL;
+ switch (width) {
+ case 16:
+ return 0;
+ case 20:
+ return 1;
+ case 24:
+ return 2;
+ }

- return (width - 16) / 4;
+ return -EINVAL;
}

-static s8 sun4i_i2s_get_wss(const struct sun4i_i2s *i2s, int width)
+static int sun4i_i2s_get_wss(unsigned int width)
{
- if (width < 16 || width > 32)
- return -EINVAL;
-
- if (width % 4)
- return -EINVAL;
+ switch (width) {
+ case 16:
+ return 0;
+ case 20:
+ return 1;
+ case 24:
+ return 2;
+ case 32:
+ return 3;
+ }

- return (width - 16) / 4;
+ return -EINVAL;
}

-static s8 sun8i_i2s_get_sr_wss(const struct sun4i_i2s *i2s, int width)
+static int sun8i_i2s_get_sr_wss(unsigned int width)
{
- if (width % 4)
- return -EINVAL;
-
- if (width < 8 || width > 32)
- return -EINVAL;
+ switch (width) {
+ case 8:
+ return 1;
+ case 12:
+ return 2;
+ case 16:
+ return 3;
+ case 20:
+ return 4;
+ case 24:
+ return 5;
+ case 28:
+ return 6;
+ case 32:
+ return 7;
+ }

- return (width - 8) / 4 + 1;
+ return -EINVAL;
}

static int sun4i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s,
@@ -582,11 +601,11 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
}
i2s->playback_dma_data.addr_width = width;

- sr = i2s->variant->get_sr(i2s, word_size);
+ sr = i2s->variant->get_sr(word_size);
if (sr < 0)
return -EINVAL;

- wss = i2s->variant->get_wss(i2s, slot_width);
+ wss = i2s->variant->get_wss(slot_width);
if (wss < 0)
return -EINVAL;

--
2.25.1

2020-10-30 14:52:44

by Clément Péron

[permalink] [raw]
Subject: [PATCH v10 07/15] ASoC: sun4i-i2s: Fix sun8i volatile regs

The FIFO TX reg is volatile and sun8i i2s register
mapping is different from sun4i.

Even if in this case it's doesn't create an issue,
Avoid setting some regs that are undefined in sun8i.

Acked-by: Maxime Ripard <[email protected]>
Reviewed-by: Chen-Yu Tsai <[email protected]>
Signed-off-by: Clément Péron <[email protected]>
---
sound/soc/sunxi/sun4i-i2s.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 786731191d90..003610c0badf 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -1162,12 +1162,19 @@ static bool sun8i_i2s_rd_reg(struct device *dev, unsigned int reg)

static bool sun8i_i2s_volatile_reg(struct device *dev, unsigned int reg)
{
- if (reg == SUN8I_I2S_INT_STA_REG)
+ switch (reg) {
+ case SUN4I_I2S_FIFO_CTRL_REG:
+ case SUN4I_I2S_FIFO_RX_REG:
+ case SUN4I_I2S_FIFO_STA_REG:
+ case SUN4I_I2S_RX_CNT_REG:
+ case SUN4I_I2S_TX_CNT_REG:
+ case SUN8I_I2S_FIFO_TX_REG:
+ case SUN8I_I2S_INT_STA_REG:
return true;
- if (reg == SUN8I_I2S_FIFO_TX_REG)
- return false;

- return sun4i_i2s_volatile_reg(dev, reg);
+ default:
+ return false;
+ }
}

static const struct reg_default sun4i_i2s_reg_defaults[] = {
--
2.25.1

2020-11-02 14:12:39

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH v10 00/15] Add Allwinner H3/H5/H6/A64 HDMI audio

On Fri, Oct 30, 2020 at 07:41:21PM +0000, Mark Brown wrote:
> On Fri, 30 Oct 2020 15:46:33 +0100, Cl?ment P?ron wrote:
> > This series add H6 I2S support and the I2S node missing to support
> > HDMI audio in different Allwinner SoC.
> >
> > As we first use some TDM property to make the I2S working with the
> > simple soundcard. We have now drop this simple sound card and a
> > proper dedicated soundcard will be introduce later.
> >
> > [...]
>
> Applied to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
>
> Thanks!
>
> [01/11] ASoC: sun4i-i2s: Fix lrck_period computation for I2S justified mode
> commit: 93c0210671d8f3ec2262da703fab93a1497158a8
> [02/11] ASoC: sun4i-i2s: Change set_chan_cfg() params
> commit: c779e2de0ac6156bea63e759481ee383587336cc
> [03/11] ASoC: sun4i-i2s: Add support for H6 I2S
> commit: 73adf87b7a5882408b0a17da59e69df4be12a968
> [04/11] ASoC: sun4i-i2s: Change get_sr() and get_wss() to be more explicit
> commit: 9c2d255f0e63f8e54bd8345f9c59c4060cf4bbd4
> [05/11] ASoC: sun4i-i2s: Set sign extend sample
> commit: d8659dd9a13ce7a92c017c352aea1c390f300937
> [06/11] ASoC: sun4i-i2s: Add 20 and 24 bit support
> commit: 6ad7ca6297f8679162ee62ed672b603e8d004146
> [07/11] ASoC: sun4i-i2s: Fix sun8i volatile regs
> commit: 64359246abe4421ad409be5b0bc9a534caa18b7d
> [08/11] ASoC: sun4i-i2s: Fix setting of FIFO modes
> commit: 38d7adc0a003298013786cfffe5f4cc907009d30
> [09/11] ASoC: sun4i-i2s: fix coding-style for callback definition
> commit: 08c7b7d546fddce76d500e5e5767aa08836f7cae
> [10/11] ASoC: sun4i-i2s: Add H6 compatible
> commit: e84f44ba4604e55a51e7caf01464f220d0eabef4
> [11/11] ASoC: sun4i-i2s: Document H3 with missing RX channel possibility
> commit: 0bc1bf241de551842535c3d0b080e0f38c11aed1

Applied the rest, thanks!
Maxime


Attachments:
(No filename) (1.90 kB)
signature.asc (235.00 B)
Download all attachments