Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70fb1052 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown
Browse files

ASoC: rsnd: add MIX (Mixer) support



This patch adds MIX (Mixer) initial support for rsnd driver.
It is assuming that this MIX is used via DPCM.

This is sample code for playback.

	CPU0  : [MEM] -> [SRC1] -> [CTU02] -+
					    |
					    +-> [MIX0] -> [DVC0] -> [SSI0]
	                                    |
	CPU1  : [MEM] -> [SRC2] -> [CTU03] -+

	sound {
		compatible = "renesas,rsrc-card";

		...

		cpu@0 {
			sound-dai = <&rcar_sound 0>;
		};

		cpu@1 {
			sound-dai = <&rcar_sound 1>;
		};

		codec {
			...
		};
	};

	rcar_sound {

		...

		rcar_sound,dai {
			dai0 {
				playback = <&src1 &ctu02 &mix0 &dvc0 &ssi0>;
			};
			dai1 {
				playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>;
			};
		};
	};

Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: default avatarKeita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9269e3c3
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ Required properties:
- rcar_sound,ctu		: Should contain CTU feature.
				  The number of CTU subnode should be same as HW.
				  see below for detail.
- rcar_sound,mix		: Should contain MIX feature.
				  The number of MIX subnode should be same as HW.
				  see below for detail.
- rcar_sound,dvc		: Should contain DVC feature.
				  The number of DVC subnode should be same as HW.
				  see below for detail.
@@ -93,6 +96,11 @@ rcar_sound: sound@ec500000 {
		};
	};

	rcar_sound,mix {
		mix0: mix@0 { };
		mix1: mix@1 { };
	};

	rcar_sound,ctu {
		ctu00: ctu@0 { };
		ctu01: ctu@1 { };
+7 −0
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ struct rsnd_ctu_platform_info {
	u32 flags;
};

struct rsnd_mix_platform_info {
	u32 flags;
};

struct rsnd_dvc_platform_info {
	u32 flags;
};
@@ -73,6 +77,7 @@ struct rsnd_dai_path_info {
	struct rsnd_ssi_platform_info *ssi;
	struct rsnd_src_platform_info *src;
	struct rsnd_ctu_platform_info *ctu;
	struct rsnd_mix_platform_info *mix;
	struct rsnd_dvc_platform_info *dvc;
};

@@ -100,6 +105,8 @@ struct rcar_snd_info {
	int src_info_nr;
	struct rsnd_ctu_platform_info *ctu_info;
	int ctu_info_nr;
	struct rsnd_mix_platform_info *mix_info;
	int mix_info_nr;
	struct rsnd_dvc_platform_info *dvc_info;
	int dvc_info_nr;
	struct rsnd_dai_platform_info *dai_info;
+1 −1
Original line number Diff line number Diff line
snd-soc-rcar-objs	:= core.o gen.o dma.o adg.o ssi.o src.o ctu.o dvc.o
snd-soc-rcar-objs	:= core.o gen.o dma.o adg.o ssi.o src.o ctu.o mix.o dvc.o
obj-$(CONFIG_SND_SOC_RCAR)	+= snd-soc-rcar.o

snd-soc-rsrc-card-objs	:= rsrc-card.o
+73 −12
Original line number Diff line number Diff line
@@ -605,9 +605,55 @@ static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
void rsnd_path_parse(struct rsnd_priv *priv,
		     struct rsnd_dai_stream *io)
{
	struct rsnd_mod *src = rsnd_io_to_mod_src(io);
	struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
	int src_id = rsnd_mod_id(src);
	struct rsnd_mod *mix = rsnd_io_to_mod_mix(io);
	struct rsnd_mod *src = rsnd_io_to_mod_src(io);
	struct rsnd_mod *cmd;
	struct device *dev = rsnd_priv_to_dev(priv);
	u32 data;

	/* Gen1 is not supported */
	if (rsnd_is_gen1(priv))
		return;

	if (!mix && !dvc)
		return;

	if (mix) {
		struct rsnd_dai *rdai;
		int i;
		u32 path[] = {
			[0] = 0,
			[1] = 1 << 0,
			[2] = 0,
			[3] = 0,
			[4] = 0,
			[5] = 1 << 8
		};

		/*
		 * it is assuming that integrater is well understanding about
		 * data path. Here doesn't check impossible connection,
		 * like src2 + src5
		 */
		data = 0;
		for_each_rsnd_dai(rdai, priv, i) {
			io = &rdai->playback;
			if (mix == rsnd_io_to_mod_mix(io))
				data |= path[rsnd_mod_id(src)];

			io = &rdai->capture;
			if (mix == rsnd_io_to_mod_mix(io))
				data |= path[rsnd_mod_id(src)];
		}

		/*
		 * We can't use ctu = rsnd_io_ctu() here.
		 * Since, ID of dvc/mix are 0 or 1 (= same as CMD number)
		 * but ctu IDs are 0 - 7 (= CTU00 - CTU13)
		 */
		cmd = mix;
	} else {
		u32 path[] = {
			[0] = 0x30000,
			[1] = 0x30001,
@@ -617,11 +663,16 @@ void rsnd_path_parse(struct rsnd_priv *priv,
			[5] = 0x40100
		};

	/* Gen1 is not supported */
	if (rsnd_is_gen1(priv))
		return;
		data = path[rsnd_mod_id(src)];

	rsnd_mod_write(dvc, CMD_ROUTE_SLCT, path[src_id]);
		cmd = dvc;
	}

	dev_dbg(dev, "ctu/mix path = 0x%08x", data);

	rsnd_mod_write(cmd, CMD_ROUTE_SLCT, data);

	rsnd_mod_write(cmd, CMD_CTRL, 0x10);
}

static int rsnd_path_init(struct rsnd_priv *priv,
@@ -656,6 +707,11 @@ static int rsnd_path_init(struct rsnd_priv *priv,
	if (ret < 0)
		return ret;

	/* MIX */
	ret = rsnd_path_add(priv, io, mix);
	if (ret < 0)
		return ret;

	/* DVC */
	ret = rsnd_path_add(priv, io, dvc);
	if (ret < 0)
@@ -672,13 +728,14 @@ static void rsnd_of_parse_dai(struct platform_device *pdev,
	struct device_node *ssi_node,	*ssi_np;
	struct device_node *src_node,	*src_np;
	struct device_node *ctu_node,	*ctu_np;
	struct device_node *mix_node,	*mix_np;
	struct device_node *dvc_node,	*dvc_np;
	struct device_node *playback, *capture;
	struct rsnd_dai_platform_info *dai_info;
	struct rcar_snd_info *info = rsnd_priv_to_info(priv);
	struct device *dev = &pdev->dev;
	int nr, i;
	int dai_i, ssi_i, src_i, ctu_i, dvc_i;
	int dai_i, ssi_i, src_i, ctu_i, mix_i, dvc_i;

	if (!of_data)
		return;
@@ -705,6 +762,7 @@ static void rsnd_of_parse_dai(struct platform_device *pdev,
	ssi_node = of_get_child_by_name(dev->of_node, "rcar_sound,ssi");
	src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src");
	ctu_node = of_get_child_by_name(dev->of_node, "rcar_sound,ctu");
	mix_node = of_get_child_by_name(dev->of_node, "rcar_sound,mix");
	dvc_node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc");

#define mod_parse(name)							\
@@ -742,6 +800,7 @@ if (name##_node) { \
			mod_parse(ssi);
			mod_parse(src);
			mod_parse(ctu);
			mod_parse(mix);
			mod_parse(dvc);

			of_node_put(playback);
@@ -1155,6 +1214,7 @@ static int rsnd_probe(struct platform_device *pdev)
		rsnd_ssi_probe,
		rsnd_src_probe,
		rsnd_ctu_probe,
		rsnd_mix_probe,
		rsnd_dvc_probe,
		rsnd_adg_probe,
		rsnd_dai_probe,
@@ -1251,6 +1311,7 @@ static int rsnd_remove(struct platform_device *pdev)
		rsnd_ssi_remove,
		rsnd_src_remove,
		rsnd_ctu_remove,
		rsnd_mix_remove,
		rsnd_dvc_remove,
	};
	int ret = 0, i;
+5 −0
Original line number Diff line number Diff line
@@ -427,6 +427,7 @@ rsnd_gen2_dma_addr(struct rsnd_dai_stream *io,
	int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod);
	int use_src = !!rsnd_io_to_mod_src(io);
	int use_cmd = !!rsnd_io_to_mod_dvc(io) ||
		      !!rsnd_io_to_mod_mix(io) ||
		      !!rsnd_io_to_mod_ctu(io);
	int id = rsnd_mod_id(mod);
	struct dma_addr {
@@ -506,6 +507,7 @@ static void rsnd_dma_of_path(struct rsnd_dma *dma,
	struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io);
	struct rsnd_mod *src = rsnd_io_to_mod_src(io);
	struct rsnd_mod *ctu = rsnd_io_to_mod_ctu(io);
	struct rsnd_mod *mix = rsnd_io_to_mod_mix(io);
	struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
	struct rsnd_mod *mod[MOD_MAX];
	struct rsnd_mod *mod_start, *mod_end;
@@ -548,6 +550,9 @@ static void rsnd_dma_of_path(struct rsnd_dma *dma,
		} else if (ctu) {
			mod[i] = ctu;
			ctu = NULL;
		} else if (mix) {
			mod[i] = mix;
			mix = NULL;
		} else if (dvc) {
			mod[i] = dvc;
			dvc = NULL;
Loading