ASoC: meson: gx: add base support for I2S audio input
Subsystems (5)
v3 cover ASoC: meson: gx: add base support for I2S audio input
This series is the 2nd part of the initial RFC [1] proposed to add audio input support to the Meson GX SoCs. After the AIU reshaping series [2] that has recently been merged, this one adds the audio input path itself.
Apart from some glue commits for gx-formatter Kconfig split, a fix for i2s clock divider disabling in aiu-encoder-i2s, DT, bindings and integration with gx-card, the core commit is the 4th one, which adds the AUDIN driver. This is the counterpart of AIU for capture: it gets the entire register range, it handles peripheral clock and reset, it instantiates the I2S data formatter as widget and FIFOs as DAIs.
Resulting capture topology is:
pads --> AIU I2S Encoder -> AUDIN I2S Formatter -> AUDIN FIFO -> RAM
This series includes all the changes related to this work (dt-bindings, drivers and device-tree) in order to give the full picture in one single place.
Unfortunately, since no Meson GXBB/GXL board available in the tree features an I2S capture capable codec, this work cannot be directly tested out of the box. To test it an external codec must be connected to the SoC. When working on this series, a custom hat board with an NXP SGTL5000 codec has been plugged on top of an Odroid-C2 (GXBB). The last commit of this series fully details all the device-tree changes which are required to finalize the support for this scenario.
With this hardware configuration it has been possible to successfully validate the implementation with:
- alsa tools (arecord)
- pcm-tests
[1]: https://lore.kernel.org/linux-sound/[email protected]/
[2]: https://lore.kernel.org/linux-sound/[email protected]/
---
Changes in v3:
- Fixed i2s clock divider disabling in 'aiu-encoder-i2s' 'hw_free'. [Sashiko]
- Specified const value of "#sound-dai-cells" property in dt-binding. [Sashiko]
- Advance 'last_pos' by whole periods in the FIFO polling timer to avoid drifting period notifications. [Sashiko]
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Dropped FIFO child nodes from AUDIN in device-tree. Now AUDIN is the only sound component and FIFOs are its DAIs. This is the same design used in AIU. [Krzysztof]
- Renamed driver compatible, using 'amlogic,gx-audin' as fallback and 'amlogic,gx[bb|l]-audin' as SoC specific. Fixed also other reported comments on the binding. [Krzysztof]
- Adjusted headers inclusion in 'audin.c' and spacing in the empty entry of 'meson_gx_audin_of_match'. [Uwe]
- Replaced 'snd_soc_component_read' with 'regmap_read' in 'audin_fifo_pos' in order to prevent sleeping in atomic context. Also changed the hrtimer from hard-irq to a soft-irq one. [Sashiko]
- Added 'sync_stop' callback in 'audin_component' to ensure the hrtimer is fully stopped before attempting to restart the stream in a "start->stop->prepare->start" scenario.
- Link to v1: https://patch.msgid.link/[email protected]
To: Jerome Brunet <[email protected]>
To: Liam Girdwood <[email protected]>
To: Mark Brown <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Valerio Setti <[email protected]>
To: Jaroslav Kysela <[email protected]>
To: Takashi Iwai <[email protected]>
To: Neil Armstrong <[email protected]>
To: Kevin Hilman <[email protected]>
To: Martin Blumenstingl <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Valerio Setti (7):
ASoC: dt-bindings: amlogic,gx-audin: add schema
ASoC: meson: build gx-formatter as a separate module
ASoC: meson: aiu-encoder-i2s: ensure clk divider gets disabled in hw_free
ASoC: meson: add AUDIN driver
ASoC: meson: aiu: add I2S Capture DAI
ASoC: meson: gx-card: add support for audin FIFO
arm64: dts: amlogic: gx: add AUDIN node
.../bindings/sound/amlogic,gx-audin.yaml | 69 ++++ arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 9 + arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 6 + arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 6 + sound/soc/meson/Kconfig | 14 + sound/soc/meson/Makefile | 7 +- sound/soc/meson/aiu-encoder-i2s.c | 12 +- sound/soc/meson/aiu.c | 7 + sound/soc/meson/audin-fifo.c | 371 +++++++++++++++++++++ sound/soc/meson/audin-formatter-i2s.c | 174 ++++++++++ sound/soc/meson/audin.c | 188 +++++++++++ sound/soc/meson/audin.h | 30 ++ sound/soc/meson/gx-card.c | 16 +- 13 files changed, 894 insertions(+), 15 deletions(-)
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260831-audin-9cabb450cc94
Best regards,
Signature · 1 line
Valerio Setti <[email protected]>
PATCH v3 1/7 ASoC: dt-bindings: amlogic,gx-audin: add schema
AUDIN provides I2S audio input support to the Meson GX platforms (GXBB/GXL).
Note: GXBB and GXL are not known to differ so the driver binds on the 'amlogic,gx-audin' fallback.
--- .../bindings/sound/amlogic,gx-audin.yaml | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+)
Documentation/devicetree/bindings/sound/amlogic,gx-audin.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/amlogic,gx-audin.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Amlogic GX AUDIN + +maintainers: + - Valerio Setti <[email protected]> + +description: + AUDIN is the audio input block of the Amlogic GXBB/GXL SoCs. It supports + various input formatters (I2S, SPDIF, PCM, HDMI) feeding three FIFOs that + transfer captured samples to memory. The sound-dai cell selects the FIFO. + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + items: + - enum: + - amlogic,gxbb-audin + - amlogic,gxl-audin + - const: amlogic,gx-audin + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: AUDIN peripheral clock + + "#sound-dai-cells": + const: 1 + +required: + - compatible + - reg + - resets + - interrupts + - clocks + - "#sound-dai-cells" + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/gxbb-clkc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/reset/amlogic,meson-gxbb-reset.h> + + audio-controller@a000 { + compatible = "amlogic,gxbb-audin", "amlogic,gx-audin"; + reg = <0xa000 0x148>; + resets = <&reset RESET_AUDIN>; + interrupts = <GIC_SPI 7 IRQ_TYPE_EDGE_RISING>; + sound-name-prefix = "AUDIN"; + #sound-dai-cells = <1>; + clocks = <&clkc CLKID_I2S_SPDIF>; + };
Signature · 1 line
2.47.3
Re: [PATCH v3 1/7] ASoC: dt-bindings: amlogic,gx-audin: add schema
Quoted 5 lines · Valerio Setti
AUDIN provides I2S audio input support to the Meson GX platforms (GXBB/GXL).
Note: GXBB and GXL are not known to differ so the driver binds on the 'amlogic,gx-audin' fallback.
What the driver does is usually less relevant. Here, completely irrelevant. Explain the compatibility between hardware.
OTOH, you cannot have family compatibles (clearly documented and explained on every beginners talk), so what is the GX?
And I already asked for this:
https://lore.kernel.org/all/20260913-inventive-millipede-of-certainty-dd58ce@quoll/
We have it extensively documented - in tree, in talks, in existing examples - how this is handled.
Best regards,
Krzysztof
Re: [PATCH v3 1/7] ASoC: dt-bindings: amlogic,gx-audin: add schema
Quoted 7 lines · Krzysztof Kozlowski
Quoted 5 lines · Valerio Setti
AUDIN provides I2S audio input support to the Meson GX platforms (GXBB/GXL).
Note: GXBB and GXL are not known to differ so the driver binds on the 'amlogic,gx-audin' fallback.
Quoted 8 lines
What the driver does is usually less relevant. Here, completely irrelevant. Explain the compatibility between hardware.
OTOH, you cannot have family compatibles (clearly documented and explained on every beginners talk), so what is the GX?
And I already asked for this:
https://lore.kernel.org/all/20260913-inventive-millipede-of-certainty-dd58ce@quoll/
GX is not an SoC. It's just the common part ('meson-gx.dtsi') between GXBB and GXL, which are the real SoCs.
I think the confusion on my end arose from following the AIU design, which I now suspect not being up to date with newest design guides. I will rework the series using 'amlogic,gxbb-audin' as the fallback compatible and only extend it with 'amlogic,gxl-audin' for GXL. Please apologize for the mistake.
Signature · 1 line
Valerio
PATCH v3 2/7 ASoC: meson: build gx-formatter as a separate module
In reply to Valerio SettiInstead of including it in 'snd-soc-meson-aiu', create a separate module for it. This way it can be independently selected by either AIU or the (upcoming) AUDIN.
--- sound/soc/meson/Kconfig | 5 +++++ sound/soc/meson/Makefile | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)
sound/soc/meson/Kconfig +5 -0
@@ -2,10 +2,15 @@ menu "Amlogic" depends on ARCH_MESON || (COMPILE_TEST && COMMON_CLK) +config SND_MESON_GX_FORMATTER + tristate + select REGMAP_MMIO + config SND_MESON_AIU tristate "Amlogic AIU" select SND_MESON_CODEC_GLUE select SND_PCM_IEC958 + select SND_MESON_GX_FORMATTER imply SND_SOC_MESON_T9015 imply SND_SOC_HDMI_CODEC if DRM_MESON_DW_HDMI help
sound/soc/meson/Makefile +2 -1
@@ -4,12 +4,12 @@ snd-soc-meson-aiu-y := aiu.o snd-soc-meson-aiu-y += aiu-acodec-ctrl.o snd-soc-meson-aiu-y += aiu-codec-ctrl.o snd-soc-meson-aiu-y += aiu-encoder-i2s.o -snd-soc-meson-aiu-y += gx-formatter.o snd-soc-meson-aiu-y += aiu-formatter-i2s.o snd-soc-meson-aiu-y += aiu-encoder-spdif.o snd-soc-meson-aiu-y += aiu-fifo.o snd-soc-meson-aiu-y += aiu-fifo-i2s.o snd-soc-meson-aiu-y += aiu-fifo-spdif.o +snd-soc-meson-gx-formatter-y := gx-formatter.o snd-soc-meson-axg-fifo-y := axg-fifo.o snd-soc-meson-axg-frddr-y := axg-frddr.o snd-soc-meson-axg-toddr-y := axg-toddr.o
@@ -29,6 +29,7 @@ snd-soc-meson-g12a-tohdmitx-y := g12a-tohdmitx.o snd-soc-meson-t9015-y := t9015.o obj-$(CONFIG_SND_MESON_AIU) += snd-soc-meson-aiu.o +obj-$(CONFIG_SND_MESON_GX_FORMATTER) += snd-soc-meson-gx-formatter.o obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o
Signature · 1 line
2.47.3
PATCH v3 3/7 ASoC: meson: aiu-encoder-i2s: ensure clk divider gets disabled in hw_free
In reply to Valerio SettiA recent Sashiko review [1] on this code revealed the following problem:
If a user opens both streams so snd_soc_dai_active(dai) evaluates to 2, and explicitly calls SNDRV_PCM_IOCTL_HW_FREE before closing them, snd_soc_dai_active(dai) remains 2. This skips disabling the clock divider.
When the streams are subsequently closed, the ALSA core skips invoking hw_free again because the state was already changed to SNDRV_PCM_STATE_OPEN. This would leave the clock divider permanently enabled, potentially draining battery or blocking system suspend.
This commit resolves this problem by using the 'clk_enabled' field of 'struct gx_stream'. In particular when 'hw_free()' is called on a stream the code check what is the status of the other stream and then only if both are off the clock divider is disabled.
[1]: https://lore.kernel.org/all/[email protected]/
--- sound/soc/meson/aiu-encoder-i2s.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
sound/soc/meson/aiu-encoder-i2s.c +5 -7
@@ -219,16 +219,14 @@ static int aiu_encoder_i2s_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct gx_stream *ts =snd_soc_dai_get_dma_data (dai, substream); +struct gx_stream *other =snd_soc_dai_dma_data_get (dai, !substream->stream);struct snd_soc_component *component = dai->component; -/* -* If this is the last substream being closed then disable the i2s -* clock divider. -*/ -if (snd_soc_dai_active (dai) <=1 ) -aiu_encoder_i2s_divider_enable (component,0 ); -if (ts->clk_enabled) { +/* Disable the clk divider only if also the other stream is not using it */ +if (!other || !other->clk_enabled) +aiu_encoder_i2s_divider_enable (component, false); +clk_disable_unprepare (ts->iface->mclk); ts->clk_enabled = false; }
Signature · 1 line
2.47.3
PATCH v3 4/7 ASoC: meson: add AUDIN driver
In reply to Valerio SettiAUDIN provides audio input support to the Amlogic GX based platforms (GXBB/GXL). It is the counterpart of AIU for capture and it strictly follows the same structure:
- It takes the ownership of the entire register range;
- It sets up peripheral clock and handles the reset;
- It adds support for I2S data formatter through a widget;
- It instantiates each of the FIFOs as component's DAI.
Both I2S data formatter and FIFO code live separate files ('audin-formatter-i2s' and 'audin-fifo', respectively) for a better code organization. Unfortunately it wasn't possible to add them as independent devices due to the messy register layout organization that has been implemented by the manufacturer on this platform.
This component could ideally handle multiple input sources (SPDIF, I2S, PCM, HDMI), but for the time being only I2S is added and has been tested.
Note: due to default register configuration, at boot all FIFO input sources are set to "SPDIF". In order to be able to test I2S they must be switched to "I2S". This can easily be achieved with:
$ amixer sset 'AUDIN FIFO0 SRC SEL' 'I2S'
--- sound/soc/meson/Kconfig | 9 + sound/soc/meson/Makefile | 4 + sound/soc/meson/audin-fifo.c | 371 ++++++++++++++++++++++++++++++++++ sound/soc/meson/audin-formatter-i2s.c | 174 ++++++++++++++++ sound/soc/meson/audin.c | 188 +++++++++++++++++ sound/soc/meson/audin.h | 30 +++ 6 files changed, 776 insertions(+)
sound/soc/meson/Kconfig +9 -0
@@ -17,6 +17,14 @@ config SND_MESON_AIU Select Y or M to add support for the Audio output subsystem found in the Amlogic Meson8, Meson8b and GX SoC families +config SND_MESON_AUDIN + tristate "Amlogic AUDIN" + select REGMAP_MMIO + select SND_MESON_GX_FORMATTER + help + Select Y or M to add support for the audio input subsystem found + in the Amlogic GX SoC family. Currently only I2S input is supported. + config SND_MESON_AXG_FIFO tristate select REGMAP_MMIO
@@ -113,6 +121,7 @@ config SND_MESON_GX_SOUND_CARD tristate "Amlogic GX Sound Card Support" select SND_MESON_CARD_UTILS imply SND_MESON_AIU + imply SND_MESON_AUDIN help Select Y or M to add support for the GXBB/GXL SoC sound card
sound/soc/meson/Makefile +4 -0
@@ -10,6 +10,9 @@ snd-soc-meson-aiu-y += aiu-fifo.o snd-soc-meson-aiu-y += aiu-fifo-i2s.o snd-soc-meson-aiu-y += aiu-fifo-spdif.o snd-soc-meson-gx-formatter-y := gx-formatter.o +snd-soc-meson-audin-y := audin.o +snd-soc-meson-audin-y += audin-formatter-i2s.o +snd-soc-meson-audin-y += audin-fifo.o snd-soc-meson-axg-fifo-y := axg-fifo.o snd-soc-meson-axg-frddr-y := axg-frddr.o snd-soc-meson-axg-toddr-y := axg-toddr.o
@@ -30,6 +33,7 @@ snd-soc-meson-t9015-y := t9015.o obj-$(CONFIG_SND_MESON_AIU) += snd-soc-meson-aiu.o obj-$(CONFIG_SND_MESON_GX_FORMATTER) += snd-soc-meson-gx-formatter.o +obj-$(CONFIG_SND_MESON_AUDIN) += snd-soc-meson-audin.o obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o
sound/soc/meson/audin-fifo.c new file +371 -0
371 lines not on this page · raw message
sound/soc/meson/audin-formatter-i2s.c new file +174 -0
174 lines not on this page · raw message
sound/soc/meson/audin.c new file +188 -0
188 lines not on this page · raw message
sound/soc/meson/audin.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ +/* +* Copyright (c) 2026 BayLibre, SAS. +* Author: Valerio Setti <[email protected]> +*/ + +#ifndef _MESON_AUDIN_H +#define _MESON_AUDIN_H + +#include "gx-formatter.h" + +/* FIFOx CTRL registers and bits */ +#define AUDIN_FIFO_CTRL 0x14 +#define AUDIN_FIFO_CTRL_EN BIT(0) +#define AUDIN_FIFO_CTRL_RST BIT(1) +#define AUDIN_FIFO_CTRL_LOAD BIT(2) +#define AUDIN_FIFO_CTRL_DIN_SEL_OFF 3 +#define AUDIN_FIFO_CTRL_ENDIAN_MASK GENMASK(10, 8) +#define AUDIN_FIFO_CTRL_CHAN_MASK GENMASK(14, 11) +#define AUDIN_FIFO_CTRL_UG BIT(15) + +extern const struct gx_formatter_driver audin_formatter_i2s_drv; + +extern const struct snd_soc_dai_ops audin_fifo_dai_ops; +extern snd_pcm_uframes_t audin_fifo_component_pointer (struct snd_soc_component *component, +struct snd_pcm_substream *substream); +extern int audin_fifo_sync_stop (struct snd_soc_component *component, +struct snd_pcm_substream *substream); + +#endif
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v3 4/7] ASoC: meson: add AUDIN driver
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] sound: soc: meson: data race due to global state modification in probe --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] sound: soc: meson: data race due to global state modification in probe --
commit 19f0be491d181acce1da0bdd85fd37b9549fa25c
Author: Valerio Setti <[email protected]>
ASoC: meson: add AUDIN driver
This commit adds the AUDIN driver to provide audio input support for Amlogic GX based platforms. It incorporates FIFO handling and an I2S data formatter to route audio streams.
Quoted 5 lines
sound/soc/meson/audin.c new file +0
-0
[ ... ]
Quoted 7 lines
sound/soc/meson/audin.c new file +7
-0+static struct snd_soc_dapm_widget audin_dapm_widgets[] = { + [AUDIN_WIDGET_I2S_FORMATTER ] = +SND_SOC_DAPM_PGA_E ("I2S Formatter" ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 , + gx_formatter_event, + (SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_PRE_PMD )), +SND_SOC_DAPM_MUX ("FIFO0 SRC SEL" ,SND_SOC_NOPM ,0 ,0 , + &audin_fifo0_input_sel_mux),
[ ... ]
Quoted 2 lines
sound/soc/meson/audin.c new file +2
-0+static int audin_probe (struct platform_device *pdev) +{
[ ... ]
sound/soc/meson/audin.c line 151
Quoted 2 lines
sound/soc/meson/audin.c new file +2
-0+ ret =gx_formatter_create (dev, &audin_dapm_widgets[AUDIN_WIDGET_I2S_FORMATTER ], + &audin_formatter_i2s_drv, regmap);
[Severity: Low]
Is it safe to mutate the static audin_dapm_widgets array here in audin_probe() with a per-device allocated pointer?
Calling gx_formatter_create() modifies w->priv where w points to the static global audin_dapm_widgets array.
While ASoC's snd_soc_dapm_new_controls() uses kmemdup() to clone widget templates, modifying shared static global structs without synchronization introduces a structural data race if multiple instances are probed concurrently. This also appears to violate driver design principles against modifying static templates.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v3 5/7 ASoC: meson: aiu: add I2S Capture DAI
In reply to Valerio SettiAdd capture stream to CPU_I2S_ENCODER making it able to handle both playback and capture streams. Captured data is formatted from "audin-formatter-i2s" widget, buffered from "audin-fifo" into an internal FIFO and then bulk transmitted into RAM when the FIFO is full.
As for the naming of the stream "I2S Encoder" is kept as base following the same pattern used for the playback stream and with the goal to minimize changes.
Supported format for capture is currently limited to S16_LE because it's the only one that has been tested. According to the manual also S24_LE should be supported, but this is kept as follow-up.
This capture support also takes advantage of the following commits that has recently been merged:
commit df3c987ab3d7 ("ASoC: meson: aiu-encoder-i2s: reflect bs quirk in hw constraints") commit e82159384a50 ("ASoC: meson: aiu-encoder-i2s: use the core symmetric_rate handling")
They ensure bs_quirk and rate symmetry across playback and capture streams.
--- sound/soc/meson/aiu.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/meson/aiu.c +7 -0
@@ -153,6 +153,13 @@ static struct snd_soc_dai_driver aiu_cpu_dai_drv[] = { .rates = SNDRV_PCM_RATE_8000_192000, .formats = AIU_FORMATS, }, + .capture = { + .stream_name = "I2S Encoder Capture", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, .ops = &aiu_encoder_i2s_dai_ops, .symmetric_rate = 1, },
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v3 5/7] ASoC: meson: aiu: add I2S Capture DAI
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] ASoC: meson: missing DAPM route for I2S Encoder Capture breaks capture --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ASoC: meson: missing DAPM route for I2S Encoder Capture breaks capture --
commit fa09911e4a594b581f33e550b8e59c1534b784f0
Author: Valerio Setti <[email protected]>
ASoC: meson: aiu: add I2S Capture DAI
Add capture stream to CPU_I2S_ENCODER to handle both playback and capture streams. Captured data is formatted and buffered from the widgets, then bulk transmitted into RAM.
Quoted 4 lines
Add capture stream to
CPU_I2S_ENCODERmaking it able to handle both playback and capture streams. Captured data is formatted from "audin-formatter-i2s" widget, buffered from "audin-fifo" into an internal FIFO and then bulk transmitted into RAM when the FIFO is full.
Is the formatter widget in audin.c erroneously named 'I2S Formatter' instead of 'audin-formatter-i2s' as claimed here?
This creates a naming collision with the playback formatter in aiu.c.
sound/soc/meson/aiu.c static struct snd_soc_dai_driver aiu_cpu_dai_drv[] = { · line 157
Quoted 10 lines
sound/soc/meson/aiu.c +2
-0@@ -153,6 +153,13 @@ static struct snd_soc_dai_driver aiu_cpu_dai_drv[] = { .rates = SNDRV_PCM_RATE_8000_192000, .formats = AIU_FORMATS, }, + .capture = { + .stream_name = "I2S Encoder Capture",
[Severity: High]
Are the DAPM routes for this capture path missing?
The patch creates the 'I2S Encoder Capture' BE stream widget but fails to add any snd_soc_dapm_route connecting it to the formatter (neither in aiu.c nor in audin.c). As a result, the capture path is disjoint.
When the capture stream is opened, the DAPM graph traversal in audin_formatter_i2s_get_be() fails to find a backend source, returning NULL.
This triggers a WARN_ON(!ts) inside gx_formatter_power_up() and returns -ENODEV, breaking capture functionality.
Quoted 8 lines
sound/soc/meson/aiu.c +5
-0+ .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, .ops = &aiu_encoder_i2s_dai_ops, .symmetric_rate = 1, },
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v3 6/7 ASoC: meson: gx-card: add support for audin FIFO
In reply to Valerio SettiSlightly modify "gx_card_cpu_identify()" by making the compatible matching string an input parameter. This allows to easily support also AUDIN's FIFO with minimal changes.
--- sound/soc/meson/gx-card.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
sound/soc/meson/gx-card.c +9 -7
@@ -66,10 +66,10 @@ static int gx_card_parse_i2s(struct snd_soc_card *card, }static int gx_card_cpu_identify (struct snd_soc_dai_link_component *c, -char *match) +const char *compatible_match,const char *dai_match) { -if (of_device_is_compatible (c->of_node,DT_PREFIX "aiu" )) { -if (strstr (c->dai_name, match)) +if (of_device_is_compatible (c->of_node, compatible_match)) { +if (strstr (c->dai_name, dai_match))return 1 ; }
@@ -96,21 +96,23 @@ static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,if (ret)return ret; -if (gx_card_cpu_identify (dai_link->cpus,"FIFO" )) -return meson_card_set_fe_link (card, dai_link, np, true); +if (gx_card_cpu_identify (dai_link->cpus,DT_PREFIX "aiu" ,"FIFO" )) +return meson_card_set_fe_link (card, dai_link, np, true); +if (gx_card_cpu_identify (dai_link->cpus,DT_PREFIX "gx-audin" ,"FIFO" )) +return meson_card_set_fe_link (card, dai_link, np, false); ret =meson_card_set_be_link (card, dai_link, np);if (ret)return ret;/* Or apply codec to codec params if necessary */ -if (gx_card_cpu_identify (dai_link->cpus,"CODEC CTRL" )) { +if (gx_card_cpu_identify (dai_link->cpus,DT_PREFIX "aiu" ,"CODEC CTRL" )) { dai_link->c2c_params = &codec_params; dai_link->num_c2c_params =1 ; }else { dai_link->no_pcm =1 ;/* Check if the cpu is the i2s encoder and parse i2s data */ -if (gx_card_cpu_identify (dai_link->cpus,"I2S Encoder" )) +if (gx_card_cpu_identify (dai_link->cpus,DT_PREFIX "aiu" ,"I2S Encoder" )) ret =gx_card_parse_i2s (card, np, index); }
Signature · 1 line
2.47.3
PATCH v3 7/7 arm64: dts: amlogic: gx: add AUDIN node
In reply to Valerio SettiAUDIN provides audio input support to Amlogic Meson GXBB/GXL platforms.
What's missing after this to get capture support working is to connect a capture capable codec to the SoC. For example to test these changes an NXP SGTL5000 chip has been connected to an OdroidC2 (Meson GXBB) board using a custom hat board.
The following additions/overlay are required on top of 'amlogic/meson-gxbb-odroidc2.dts' to make that hat board to work:
&sound {
audio-routing = "AUDIN I2S Formatter", "AIU I2S Encoder Capture";
dai-link-1 {
codec-1 {
sound-dai = <&sgtl5000>;
};
};
dai-link-3 {
sound-dai = <&audin 0>;
};
};
&audin {
status = "okay";
};Then, from userspace:
$ amixer sset 'AUDIN FIFO0 SRC SEL' 'I2S'
$ arecord -l # find the "FIFO Capture" device
$ arecord -D hw:0,<N> -f S16_LE -r 48000 -c 2 /tmp/in.wav--- arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 9 +++++++++ arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 6 ++++++ arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 6 ++++++ 3 files changed, 21 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gx.dtsi +9 -0
@@ -436,6 +436,15 @@ watchdog@98d0 { reg = <0x0 0x098d0 0x0 0x10>; clocks = <&xtal>; }; + + audin: audio-controller@a000 { + compatible = "amlogic,gx-audin"; + reg = <0x0 0xa000 0x0 0x148>; + interrupts = <GIC_SPI 7 IRQ_TYPE_EDGE_RISING>; + sound-name-prefix = "AUDIN"; + #sound-dai-cells = <1>; + status = "disabled"; + }; }; gic: interrupt-controller@c4301000 {
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +6 -0
@@ -84,6 +84,12 @@ &aiu { resets = <&reset RESET_AIU>; }; +&audin { + compatible = "amlogic,gxbb-audin", "amlogic,gx-audin"; + clocks = <&clkc CLKID_I2S_SPDIF>; + resets = <&reset RESET_AUDIN>; +}; + &aobus { pinctrl_aobus: pinctrl@14 { compatible = "amlogic,meson-gxbb-aobus-pinctrl";
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi +6 -0
@@ -100,6 +100,12 @@ &aiu { resets = <&reset RESET_AIU>; }; +&audin { + compatible = "amlogic,gxl-audin", "amlogic,gx-audin"; + clocks = <&clkc CLKID_I2S_SPDIF>; + resets = <&reset RESET_AUDIN>; +}; + &apb { usb2_phy0: phy@78000 { compatible = "amlogic,meson-gxl-usb2-phy";
Signature · 1 line
2.47.3