diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2016-03-07 00:08:33 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-07 02:41:54 -0500 |
commit | cbf1494fbcc80d363477af1efefb2380e7660a24 (patch) | |
tree | 0aa10c9ece476f52c5bd08a391f4c8e7d94c4c4d | |
parent | ab2049f9de72c901c07eec25eff74dae2e82df7e (diff) |
ASoC: rsnd: add rsnd_src_get_in/out_rate()
SRC will convert rate, and then, CMD and SSI want to know its
rate (= SRC.in / SRC.out) for each purpose.
Current driver is supporting only Playback, but SRC+Capture support
needs more flexibility.
This patch adds rsnd_src_get_in/out_rate() for it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/sh/rcar/rsnd.h | 10 | ||||
-rw-r--r-- | sound/soc/sh/rcar/src.c | 20 | ||||
-rw-r--r-- | sound/soc/sh/rcar/ssi.c | 5 |
3 files changed, 27 insertions, 8 deletions
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index ff53f96e5006..4b77f33358fb 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -627,9 +627,13 @@ void rsnd_ssiu_remove(struct rsnd_priv *priv); | |||
627 | int rsnd_src_probe(struct rsnd_priv *priv); | 627 | int rsnd_src_probe(struct rsnd_priv *priv); |
628 | void rsnd_src_remove(struct rsnd_priv *priv); | 628 | void rsnd_src_remove(struct rsnd_priv *priv); |
629 | struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id); | 629 | struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id); |
630 | unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, | 630 | |
631 | struct rsnd_dai_stream *io, | 631 | #define rsnd_src_get_in_rate(priv, io) rsnd_src_get_rate(priv, io, 1) |
632 | struct snd_pcm_runtime *runtime); | 632 | #define rsnd_src_get_out_rate(priv, io) rsnd_src_get_rate(priv, io, 0) |
633 | unsigned int rsnd_src_get_rate(struct rsnd_priv *priv, | ||
634 | struct rsnd_dai_stream *io, | ||
635 | int is_in); | ||
636 | |||
633 | #define rsnd_src_of_node(priv) \ | 637 | #define rsnd_src_of_node(priv) \ |
634 | of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,src") | 638 | of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,src") |
635 | #define rsnd_parse_connect_src(rdai, playback, capture) \ | 639 | #define rsnd_parse_connect_src(rdai, playback, capture) \ |
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 1d5aedb50213..d1a8741cc446 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c | |||
@@ -116,12 +116,26 @@ static u32 rsnd_src_convert_rate(struct rsnd_dai_stream *io, | |||
116 | return convert_rate; | 116 | return convert_rate; |
117 | } | 117 | } |
118 | 118 | ||
119 | unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, | 119 | unsigned int rsnd_src_get_rate(struct rsnd_priv *priv, |
120 | struct rsnd_dai_stream *io, | 120 | struct rsnd_dai_stream *io, |
121 | struct snd_pcm_runtime *runtime) | 121 | int is_in) |
122 | { | 122 | { |
123 | struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io); | 123 | struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io); |
124 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); | ||
124 | unsigned int rate = 0; | 125 | unsigned int rate = 0; |
126 | int is_play = rsnd_io_is_play(io); | ||
127 | |||
128 | /* | ||
129 | * | ||
130 | * Playback | ||
131 | * runtime_rate -> [SRC] -> convert_rate | ||
132 | * | ||
133 | * Capture | ||
134 | * convert_rate -> [SRC] -> runtime_rate | ||
135 | */ | ||
136 | |||
137 | if (is_play == is_in) | ||
138 | return runtime->rate; | ||
125 | 139 | ||
126 | /* | 140 | /* |
127 | * return convert rate if SRC is used, | 141 | * return convert rate if SRC is used, |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 540489755367..5f848f054745 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
@@ -190,7 +190,6 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, | |||
190 | struct rsnd_dai_stream *io) | 190 | struct rsnd_dai_stream *io) |
191 | { | 191 | { |
192 | struct rsnd_priv *priv = rsnd_io_to_priv(io); | 192 | struct rsnd_priv *priv = rsnd_io_to_priv(io); |
193 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); | ||
194 | struct device *dev = rsnd_priv_to_dev(priv); | 193 | struct device *dev = rsnd_priv_to_dev(priv); |
195 | struct rsnd_dai *rdai = rsnd_io_to_rdai(io); | 194 | struct rsnd_dai *rdai = rsnd_io_to_rdai(io); |
196 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); | 195 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
@@ -201,7 +200,9 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, | |||
201 | 1, 2, 4, 8, 16, 6, 12, | 200 | 1, 2, 4, 8, 16, 6, 12, |
202 | }; | 201 | }; |
203 | unsigned int main_rate; | 202 | unsigned int main_rate; |
204 | unsigned int rate = rsnd_src_get_ssi_rate(priv, io, runtime); | 203 | unsigned int rate = rsnd_io_is_play(io) ? |
204 | rsnd_src_get_out_rate(priv, io) : | ||
205 | rsnd_src_get_in_rate(priv, io); | ||
205 | 206 | ||
206 | if (!rsnd_rdai_is_clk_master(rdai)) | 207 | if (!rsnd_rdai_is_clk_master(rdai)) |
207 | return 0; | 208 | return 0; |