Unverified Commit 9a61277a authored by Mark Brown's avatar Mark Brown
Browse files

Merge series "ASoC: Add Audio Graph Card2 support" from Kuninori Morimoto...

Merge series "ASoC: Add Audio Graph Card2 support" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Hi Mark

We already have Audio-Graph-Card which is Of-Graph base general sound
card driver. Basically it supports basic CPU-Codec connection, and is
also supporting DPCM connection. Because it was forcibly expanded to
DPCM, DT parsing is very limited and very difficult to add new features
on it, for example Multi-CPU/Codec support, Codec2Codec support, etc.

This patch adds more flexible new Audio-Graph-Card2 driver for it.
Audio-Graph-Card and Audio-Graph-Card2 are similar, but don't have
full compatibility.
The reason why I need Audio-Graph-Card2 instead of updating Audio-Graph-Card
is that it is very difficult to keep compatibility.

Audio-Graph-Card2 supports Normal/DPCM/Codec2Codec Connection wich
Single/Multi DAIs. And it is possible to Customizing.

This patch-set adds Audio-Graph-Card2 driver and its custom driver
sample, and DT settings sample which can be used for testing.

To enable testing/debuging, this patch-set also adds Test-Component
driver. We already have Dummy Component and/or Dummy DAI on soc-utils,
but 1) we can't use it from DT, 2) it do nothing.
Added new Test-Component can be used from DT, and it can indicate called
function name. We can use it to trace callback order, understanding
ALSA SoC behavior, etc, etc...
Sample DT settings of Audio Graph Card2 is using Test-Component as CPU/Codec DAI.

You can easily try to use/test it if you added below line to your DT file.
Your .config needs to have below CONFIGs to use/test it.
It will probe sample Sound Card which has Normal/DPCM/Multi/Codec2Codec
connections.

	#include "../../../../../sound/soc/generic/audio-graph-card2-custom-sample.dtsi"

	CONFIG_SND_AUDIO_GRAPH_CARD2
	CONFIG_SND_AUDIO_GRAPH_CARD2_CUSTOM_SAMPLE
	CONFIG_SND_TEST_COMPONENT

Because Audio Graph Card2 is still under experimental stage, it will
indicate such warning when probing, and the DT might be updated/exchanged.

It can use Codec2Codec, but it will start automatically when probed,
and can't stop it so far. It should be updated.

Link: https://lore.kernel.org/r/87k0xszlep.wl-kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/871r8u4s6q.wl-kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/87a6mhwyqn.wl-kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/87tuitusy4.wl-kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/87a6jn56x0.wl-kuninori.morimoto.gx@renesas.com

v1 -> v2
	- don't use "port" base for_each loop

v2 -> v3
	- Rename audio-graph-card2 to rich-graph-card
	- Rename DSP to DPCM not to confuse
	- Normal/DPCM/Codec2Codec can use Single/Multi DAIs.
	- use dpcm/multi/codec2codec node instead of using extra compatible
	- Sample DTSI patch is separated to Single/Multi.

v3 -> v4
	- Rename rich-graph-card to audio-graph-card2
	- fixup custom sample driver's connection bug
	- test-component compatible uses "verbose" instead of "vv"

v4 -> v5
	- tidyup git-log comment at
	- tidyup Custom Sample comment

Kuninori Morimoto (16):
  ASoC: test-component: add Test Component YAML bindings
  ASoC: test-component: add Test Component for Sound debug/test
  ASoC: simple-card-utils: add asoc_graph_is_ports0()
  ASoC: simple-card-utils: add codec2codec support
  ASoC: add Audio Graph Card2 driver
  ASoC: audio-graph-card2: add Multi CPU/Codec support
  ASoC: audio-graph-card2: add DPCM support
  ASoC: audio-graph-card2: add Codec2Codec support
  ASoC: add Audio Graph Card2 Yaml Document
  ASoC: add Audio Graph Card2 Custom Sample
  ASoC: audio-graph-card2-custom-sample.dtsi: add Sample DT for Normal (Single)
  ASoC: audio-graph-card2-custom-sample.dtsi: add Sample DT for Normal (Nulti)
  ASoC: audio-graph-card2-custom-sample.dtsi: add DPCM sample (Single)
  ASoC: audio-graph-card2-custom-sample.dtsi: add DPCM sample (Multi)
  ASoC: audio-graph-card2-custom-sample.dtsi: add Codec2Codec sample (Single)
  ASoC: audio-graph-card2-custom-sample.dtsi: add Codec2Codec sample (Multi)

 .../bindings/sound/audio-graph-card2.yaml     |   57 +
 .../bindings/sound/test-component.yaml        |   33 +
 include/sound/graph_card.h                    |   21 +
 include/sound/simple_card_utils.h             |    4 +
 sound/soc/generic/Kconfig                     |   20 +
 sound/soc/generic/Makefile                    |    6 +
 .../generic/audio-graph-card2-custom-sample.c |  183 +++
 .../audio-graph-card2-custom-sample.dtsi      |  227 +++
 sound/soc/generic/audio-graph-card2.c         | 1281 +++++++++++++++++
 sound/soc/generic/simple-card-utils.c         |   46 +-
 sound/soc/generic/test-component.c            |  659 +++++++++
 11 files changed, 2536 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/test-component.yaml
 create mode 100644 sound/soc/generic/audio-graph-card2-custom-sample.c
 create mode 100644 sound/soc/generic/audio-graph-card2-custom-sample.dtsi
 create mode 100644 sound/soc/generic/audio-graph-card2.c
 create mode 100644 sound/soc/generic/test-component.c

--
2.25.1
parents b296997c baa274db
Loading
Loading
Loading
Loading
+57 −0
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/audio-graph-card2.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Audio Graph Card2 Device Tree Bindings

maintainers:
  - Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

properties:
  compatible:
    enum:
      - audio-graph-card2
  links:
    $ref: /schemas/types.yaml#/definitions/phandle-array
  label:
    maxItems: 1
  routing:
    description: |
      A list of the connections between audio components.
      Each entry is a pair of strings, the first being the
      connection's sink, the second being the connection's source.
    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
  multi:
    description: Multi-CPU/Codec node
  dpcm:
    description: DPCM node
  codec2codec:
    description: Codec to Codec node

required:
  - compatible
  - links

additionalProperties: false

examples:
  - |
    sound {
        compatible = "audio-graph-card2";

        links = <&cpu_port>;
    };

    cpu {
        compatible = "cpu-driver";

        cpu_port: port { cpu_ep: endpoint { remote-endpoint = <&codec_ep>; }; };
    };

    codec {
        compatible = "codec-driver";

        port { codec_ep: endpoint { remote-endpoint = <&cpu_ep>; }; };
    };
+33 −0
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/test-component.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Test Component Device Tree Bindings

maintainers:
  - Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

properties:
  compatible:
    enum:
      - test-cpu
      - test-cpu-verbose
      - test-cpu-verbose-dai
      - test-cpu-verbose-component
      - test-codec
      - test-codec-verbose
      - test-codec-verbose-dai
      - test-codec-verbose-component

required:
  - compatible

additionalProperties: true

examples:
  - |
    test_cpu {
        compatible = "test-cpu";
    };
+21 −0
Original line number Diff line number Diff line
@@ -9,6 +9,27 @@

#include <sound/simple_card_utils.h>

typedef int (*GRAPH2_CUSTOM)(struct asoc_simple_priv *priv,
			     struct device_node *lnk,
			     struct link_info *li);

struct graph2_custom_hooks {
	int (*hook_pre)(struct asoc_simple_priv *priv);
	int (*hook_post)(struct asoc_simple_priv *priv);
	GRAPH2_CUSTOM custom_normal;
	GRAPH2_CUSTOM custom_dpcm;
	GRAPH2_CUSTOM custom_c2c;
};

int audio_graph_parse_of(struct asoc_simple_priv *priv, struct device *dev);
int audio_graph2_parse_of(struct asoc_simple_priv *priv, struct device *dev,
			  struct graph2_custom_hooks *hooks);

int audio_graph2_link_normal(struct asoc_simple_priv *priv,
			     struct device_node *lnk, struct link_info *li);
int audio_graph2_link_dpcm(struct asoc_simple_priv *priv,
			   struct device_node *lnk, struct link_info *li);
int audio_graph2_link_c2c(struct asoc_simple_priv *priv,
			  struct device_node *lnk, struct link_info *li);

#endif /* __GRAPH_CARD_H */
+4 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ struct prop_nums {
	int cpus;
	int codecs;
	int platforms;
	int c2c;
};

struct asoc_simple_priv {
@@ -54,6 +55,7 @@ struct asoc_simple_priv {
		struct snd_soc_dai_link_component *platforms;
		struct asoc_simple_data adata;
		struct snd_soc_codec_conf *codec_conf;
		struct snd_soc_pcm_stream *c2c_conf;
		struct prop_nums num;
		unsigned int mclk_fs;
	} *dai_props;
@@ -64,6 +66,7 @@ struct asoc_simple_priv {
	struct snd_soc_dai_link_component *dlcs;
	struct snd_soc_dai_link_component dummy;
	struct snd_soc_codec_conf *codec_conf;
	struct snd_soc_pcm_stream *c2c_conf;
	struct gpio_desc *pa_gpio;
	const struct snd_soc_ops *ops;
	unsigned int dpcm_selectable:1;
@@ -180,6 +183,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
int asoc_simple_remove(struct platform_device *pdev);

int asoc_graph_card_probe(struct snd_soc_card *card);
int asoc_graph_is_ports0(struct device_node *port);

#ifdef DEBUG
static inline void asoc_simple_debug_dai(struct asoc_simple_priv *priv,
+20 −0
Original line number Diff line number Diff line
@@ -17,3 +17,23 @@ config SND_AUDIO_GRAPH_CARD
	  This option enables generic simple sound card support
	  with OF-graph DT bindings.
	  It also support DPCM of multi CPU single Codec ststem.

config SND_AUDIO_GRAPH_CARD2
	tristate "ASoC Audio Graph sound card2 support"
	depends on OF
	select SND_SIMPLE_CARD_UTILS
	help
	  This option enables generic simple sound card2 support
	  with OF-graph DT bindings.

config SND_AUDIO_GRAPH_CARD2_CUSTOM_SAMPLE
	tristate "ASoC Audio Graph Card2 base custom sample support"
	depends on SND_AUDIO_GRAPH_CARD2
	help
	  This option enables Audio Graph Card2 base custom sample

config SND_TEST_COMPONENT
	tristate "ASoC Test component sound support"
	depends on OF
	help
	  This option enables test component sound driver support.
Loading