Unverified Commit 54e49a3c authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: fsl-asoc-card: add S/PDIF controller support

Merge series from Elinor Montmasson <elinor.montmasson@savoirfairelinux.com>:

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.
parents 0c6c6511 4359caad
Loading
Loading
Loading
Loading
+0 −66
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/fsl,imx-audio-spdif.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Freescale i.MX audio complex with S/PDIF transceiver

maintainers:
  - Shengjiu Wang <shengjiu.wang@nxp.com>

properties:
  compatible:
    oneOf:
      - items:
          - enum:
              - fsl,imx-sabreauto-spdif
              - fsl,imx6sx-sdb-spdif
          - const: fsl,imx-audio-spdif
      - enum:
          - fsl,imx-audio-spdif

  model:
    $ref: /schemas/types.yaml#/definitions/string
    description: User specified audio sound card name

  spdif-controller:
    $ref: /schemas/types.yaml#/definitions/phandle
    description: The phandle of the i.MX S/PDIF controller

  spdif-out:
    type: boolean
    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
    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
  - spdif-controller

anyOf:
  - required:
      - spdif-in
  - required:
      - spdif-out

additionalProperties: false

examples:
  - |
    sound-spdif {
        compatible = "fsl,imx-audio-spdif";
        model = "imx-spdif";
        spdif-controller = <&spdif>;
        spdif-out;
        spdif-in;
    };
+49 −4
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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>;
    };
+0 −1
Original line number Diff line number Diff line
@@ -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
+0 −1
Original line number Diff line number Diff line
@@ -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
+1 −9
Original line number Diff line number Diff line
@@ -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
@@ -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
Loading