Skip to content

Commit

Permalink
ASoC: rsnd: add MIX (Mixer) support
Browse files Browse the repository at this point in the history
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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Kuninori Morimoto authored and Mark Brown committed Jul 17, 2015
1 parent 9269e3c commit 70fb105
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 13 deletions.
8 changes: 8 additions & 0 deletions Documentation/devicetree/bindings/sound/renesas,rsnd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 { };
Expand Down
7 changes: 7 additions & 0 deletions include/sound/rcar_snd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sh/rcar/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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
Expand Down
85 changes: 73 additions & 12 deletions sound/soc/sh/rcar/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,23 +605,74 @@ 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);
u32 path[] = {
[0] = 0x30000,
[1] = 0x30001,
[2] = 0x40000,
[3] = 0x10000,
[4] = 0x20000,
[5] = 0x40100
};
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;

rsnd_mod_write(dvc, CMD_ROUTE_SLCT, path[src_id]);
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,
[2] = 0x40000,
[3] = 0x10000,
[4] = 0x20000,
[5] = 0x40100
};

data = path[rsnd_mod_id(src)];

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,
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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) \
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions sound/soc/sh/rcar/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions sound/soc/sh/rcar/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ static int rsnd_gen2_probe(struct platform_device *pdev,
RSND_GEN_M_REG(SRC_BSISR, 0x238, 0x40),
RSND_GEN_M_REG(CTU_CTUIR, 0x504, 0x100),
RSND_GEN_M_REG(CTU_ADINR, 0x508, 0x100),
RSND_GEN_M_REG(MIX_SWRSR, 0xd00, 0x40),
RSND_GEN_M_REG(MIX_MIXIR, 0xd04, 0x40),
RSND_GEN_M_REG(MIX_ADINR, 0xd08, 0x40),
RSND_GEN_M_REG(MIX_MIXMR, 0xd10, 0x40),
RSND_GEN_M_REG(MIX_MVPDR, 0xd14, 0x40),
RSND_GEN_M_REG(MIX_MDBAR, 0xd18, 0x40),
RSND_GEN_M_REG(MIX_MDBBR, 0xd1c, 0x40),
RSND_GEN_M_REG(MIX_MDBCR, 0xd20, 0x40),
RSND_GEN_M_REG(MIX_MDBDR, 0xd24, 0x40),
RSND_GEN_M_REG(MIX_MDBER, 0xd28, 0x40),
RSND_GEN_M_REG(DVC_SWRSR, 0xe00, 0x100),
RSND_GEN_M_REG(DVC_DVUIR, 0xe04, 0x100),
RSND_GEN_M_REG(DVC_ADINR, 0xe08, 0x100),
Expand Down
Loading

0 comments on commit 70fb105

Please sign in to comment.