Skip to content

Commit

Permalink
ASoC: fsl-asoc-card: add S/PDIF controller support
Browse files Browse the repository at this point in the history
Merge series from Elinor Montmasson <[email protected]>:

This is a series of patches aiming to make the machine driver
`fsl-asoc-card` compatible with S/PDIF controllers on imx boards.  The
main goal is to allow the use of S/PDIF controllers with ASRC modules.

The `imx-spdif` machine driver already has specific support for S/PDIF
controllers but doesn't support using an ASRC with it. However, the
`fsl-asoc-card` machine driver has the necessary code to create a sound
card which can use an ASRC module.
It is then possible to extend the support for S/PDIF audio cards by
merging the `imx-spdif` driver into `fsl-asoc-card`.

The first three patches adapt the `fsl-asoc-card` driver to support
multiple codec use cases.
The driver can get 2 codec phandles from the device tree, and
codec-related variables are doubled.
`for_each_codecs` macros are also used when possible to ease adding
other multi-codec use cases in the future.
It makes possible to use the two S/PDIF dummy codec drivers
`spdif_receiver` and `spdif_transmitter` instead of `snd-soc-dummy`,
which was used in `imx-spdif`.

The fourth patch merges the S/PDIF support from `imx-spdif` to
`fsl-asoc-card`.
`fsl-asoc-card` offers the same functionalities as `imx-spdif` did, but
this merge also extends the S/PDIF support with the possibility of using
an ASRC.
Compatible "fsl,imx-audio-spdif" is kept, but `fsl-asoc-card` uses
different DT properties compared to `imx-spdif`:
* The "spdif-controller" property from `imx-spdif` is named "audio-cpu"
  in `fsl-asoc-card`.
* `fsl-asoc-card` uses codecs explicitly declared in DT with
  "audio-codec". With an S/PDIF, codec drivers `spdif_transmitter` and
  `spdif_receiver` should be used. Driver `imx-spdif` used instead the
  dummy codec and a pair of boolean properties, "spdif-in" and
  "spdif-out".
Backward compatibility is therefore implemented in `fsl-asoc-card`.
However, it is recommended to use the new properties when needed.
Especially, declaring and using S/PDIF transmitter and/or receiver nodes
is better than using the dummy codec.

The last three patches update the device tree bindings of
`fsl-asoc-card` and update all in-tree device trees to use the
`fsl-asoc-card` properties.
Note that as the old properties are still supported:
* previous versions of in-tree device trees are still supported.
* out-of-tree device trees are still supported.

This series of patches was successfully built for arm64 and x86 on top
of the latest "for-next" branch of the ASoC git tree on the 26th of June
2024.
These modifications have also been tested on an i.MX8MN evaluation board
with a linux kernel RT v6.1.26-rt8.
  • Loading branch information
broonie committed Jul 8, 2024
2 parents 0c6c651 + 4359caa commit 54e49a3
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 313 deletions.
66 changes: 0 additions & 66 deletions Documentation/devicetree/bindings/sound/fsl,imx-audio-spdif.yaml

This file was deleted.

53 changes: 49 additions & 4 deletions Documentation/devicetree/bindings/sound/fsl-asoc-card.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ properties:
- fsl,imx-audio-sgtl5000
- fsl,imx-audio-wm8960
- fsl,imx-audio-wm8962
- items:
- enum:
- fsl,imx-sabreauto-spdif
- fsl,imx6sx-sdb-spdif
- const: fsl,imx-audio-spdif
- items:
- enum:
- fsl,imx-audio-ac97
Expand All @@ -81,6 +86,7 @@ properties:
- fsl,imx-audio-wm8960
- fsl,imx-audio-wm8962
- fsl,imx-audio-wm8958
- fsl,imx-audio-spdif

model:
$ref: /schemas/types.yaml#/definitions/string
Expand All @@ -93,8 +99,15 @@ properties:
need to add ASRC support via DPCM.

audio-codec:
$ref: /schemas/types.yaml#/definitions/phandle
description: The phandle of an audio codec
$ref: /schemas/types.yaml#/definitions/phandle-array
description: |
The phandle of an audio codec.
With "fsl,imx-audio-spdif", either SPDIF audio codec spdif_transmitter,
spdif_receiver or both.
minItems: 1
maxItems: 2
items:
maxItems: 1

audio-cpu:
$ref: /schemas/types.yaml#/definitions/phandle
Expand Down Expand Up @@ -150,8 +163,10 @@ properties:
description: dai-link uses bit clock inversion.

mclk-id:
$ref: /schemas/types.yaml#/definitions/uint32
description: main clock id, specific for each card configuration.
$ref: /schemas/types.yaml#/definitions/uint32-array
description: Main clock id for each codec, specific for each card configuration.
minItems: 1
maxItems: 2

mux-int-port:
$ref: /schemas/types.yaml#/definitions/uint32
Expand All @@ -167,6 +182,27 @@ properties:
$ref: /schemas/types.yaml#/definitions/phandle
description: The phandle of an CPU DAI controller

spdif-controller:
$ref: /schemas/types.yaml#/definitions/phandle
deprecated: true
description: The phandle of an S/PDIF CPU DAI controller.

spdif-out:
type: boolean
deprecated: true
description: |
If present, the transmitting function of S/PDIF will be enabled,
indicating there's a physical S/PDIF out connector or jack on the
board or it's connecting to some other IP block, such as an HDMI
encoder or display-controller.
spdif-in:
type: boolean
deprecated: true
description: |
If present, the receiving function of S/PDIF will be enabled,
indicating there is a physical S/PDIF in connector/jack on the board.
required:
- compatible
- model
Expand Down Expand Up @@ -195,3 +231,12 @@ examples:
"AIN2L", "Line In Jack",
"AIN2R", "Line In Jack";
};
- |
sound-spdif-asrc {
compatible = "fsl,imx-audio-spdif";
model = "spdif-asrc-audio";
audio-cpu = <&spdif>;
audio-asrc = <&easrc>;
audio-codec = <&spdifdit>, <&spdifdir>;
};
1 change: 0 additions & 1 deletion arch/arm/configs/imx_v6_v7_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ CONFIG_SND_IMX_SOC=y
CONFIG_SND_SOC_EUKREA_TLV320=y
CONFIG_SND_SOC_IMX_ES8328=y
CONFIG_SND_SOC_IMX_SGTL5000=y
CONFIG_SND_SOC_IMX_SPDIF=y
CONFIG_SND_SOC_FSL_ASOC_CARD=y
CONFIG_SND_SOC_AC97_CODEC=y
CONFIG_SND_SOC_CS42XX8_I2C=y
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/configs/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ CONFIG_SND_SOC_FSL_MICFIL=m
CONFIG_SND_SOC_FSL_EASRC=m
CONFIG_SND_IMX_SOC=m
CONFIG_SND_SOC_IMX_SGTL5000=m
CONFIG_SND_SOC_IMX_SPDIF=m
CONFIG_SND_SOC_FSL_ASOC_CARD=m
CONFIG_SND_SOC_IMX_AUDMIX=m
CONFIG_SND_SOC_MT8183=m
Expand Down
10 changes: 1 addition & 9 deletions sound/soc/fsl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,6 @@ config SND_SOC_IMX_SGTL5000
SND_SOC_FSL_ASOC_CARD and SND_SOC_SGTL5000 to use the newer
driver.

config SND_SOC_IMX_SPDIF
tristate "SoC Audio support for i.MX boards with S/PDIF"
select SND_SOC_IMX_PCM_DMA
select SND_SOC_FSL_SPDIF
help
SoC Audio support for i.MX boards with S/PDIF
Say Y if you want to add support for SoC audio on an i.MX board with
a S/DPDIF.

config SND_SOC_FSL_ASOC_CARD
tristate "Generic ASoC Sound Card with ASRC support"
depends on OF && I2C
Expand All @@ -323,6 +314,7 @@ config SND_SOC_FSL_ASOC_CARD
select SND_SOC_FSL_ESAI
select SND_SOC_FSL_SAI
select SND_SOC_FSL_SSI
select SND_SOC_FSL_SPDIF
select SND_SOC_TLV320AIC31XX
select SND_SOC_WM8994
select MFD_WM8994
Expand Down
2 changes: 0 additions & 2 deletions sound/soc/fsl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ obj-$(CONFIG_SND_SOC_IMX_PCM_RPMSG) += imx-pcm-rpmsg.o
snd-soc-eukrea-tlv320-y := eukrea-tlv320.o
snd-soc-imx-es8328-y := imx-es8328.o
snd-soc-imx-sgtl5000-y := imx-sgtl5000.o
snd-soc-imx-spdif-y := imx-spdif.o
snd-soc-imx-audmix-y := imx-audmix.o
snd-soc-imx-hdmi-y := imx-hdmi.o
snd-soc-imx-rpmsg-y := imx-rpmsg.o
Expand All @@ -76,7 +75,6 @@ snd-soc-imx-card-y := imx-card.o
obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
obj-$(CONFIG_SND_SOC_IMX_ES8328) += snd-soc-imx-es8328.o
obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o
obj-$(CONFIG_SND_SOC_IMX_AUDMIX) += snd-soc-imx-audmix.o
obj-$(CONFIG_SND_SOC_IMX_HDMI) += snd-soc-imx-hdmi.o
obj-$(CONFIG_SND_SOC_IMX_RPMSG) += snd-soc-imx-rpmsg.o
Expand Down
Loading

0 comments on commit 54e49a3

Please sign in to comment.