aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/sh
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2014-05-08 20:44:14 -0400
committerMark Brown <broonie@linaro.org>2014-05-13 14:06:16 -0400
commitd7bdbc5d9e4e813522f46632527826211270b9d0 (patch)
treee932474d35e03c441e43980c0d418be5e5344457 /sound/soc/sh
parent739f9502fdd7c7202123ded842415a0392b7dc40 (diff)
ASoC: rsnd: add rsnd_get_adinr()
SRC module needs ADINR register settings, but, it has many similar xxx_ADINR register, and needs same settings. This patch adds rsnd_get_adinr() to sharing code. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/sh')
-rw-r--r--sound/soc/sh/rcar/core.c26
-rw-r--r--sound/soc/sh/rcar/rsnd.h1
-rw-r--r--sound/soc/sh/rcar/src.c26
3 files changed, 30 insertions, 23 deletions
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index f74d02cb70f1..e47aa53471b1 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -310,6 +310,32 @@ void rsnd_dma_quit(struct rsnd_priv *priv,
310} 310}
311 311
312/* 312/*
313 * settting function
314 */
315u32 rsnd_get_adinr(struct rsnd_mod *mod)
316{
317 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
318 struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
319 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
320 struct device *dev = rsnd_priv_to_dev(priv);
321 u32 adinr = runtime->channels;
322
323 switch (runtime->sample_bits) {
324 case 16:
325 adinr |= (8 << 16);
326 break;
327 case 32:
328 adinr |= (0 << 16);
329 break;
330 default:
331 dev_warn(dev, "not supported sample bits\n");
332 return 0;
333 }
334
335 return adinr;
336}
337
338/*
313 * rsnd_dai functions 339 * rsnd_dai functions
314 */ 340 */
315#define __rsnd_mod_call(mod, func, rdai, io) \ 341#define __rsnd_mod_call(mod, func, rdai, io) \
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 061b04cbd7d5..fee3ec21aaeb 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -136,6 +136,7 @@ void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
136 enum rsnd_reg reg, u32 data); 136 enum rsnd_reg reg, u32 data);
137void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg, 137void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
138 u32 mask, u32 data); 138 u32 mask, u32 data);
139u32 rsnd_get_adinr(struct rsnd_mod *mod);
139 140
140/* 141/*
141 * R-Car DMA 142 * R-Car DMA
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
index d51c59bf7c47..c90c36d41799 100644
--- a/sound/soc/sh/rcar/src.c
+++ b/sound/soc/sh/rcar/src.c
@@ -18,15 +18,6 @@ struct rsnd_src {
18 18
19#define RSND_SRC_NAME_SIZE 16 19#define RSND_SRC_NAME_SIZE 16
20 20
21/*
22 * ADINR
23 */
24#define OTBL_24 (0 << 16)
25#define OTBL_22 (2 << 16)
26#define OTBL_20 (4 << 16)
27#define OTBL_18 (6 << 16)
28#define OTBL_16 (8 << 16)
29
30#define rsnd_src_convert_rate(p) ((p)->info->convert_rate) 21#define rsnd_src_convert_rate(p) ((p)->info->convert_rate)
31#define rsnd_mod_to_src(_mod) \ 22#define rsnd_mod_to_src(_mod) \
32 container_of((_mod), struct rsnd_src, mod) 23 container_of((_mod), struct rsnd_src, mod)
@@ -197,7 +188,6 @@ static int rsnd_src_set_convert_rate(struct rsnd_mod *mod,
197 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 188 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
198 struct rsnd_src *src = rsnd_mod_to_src(mod); 189 struct rsnd_src *src = rsnd_mod_to_src(mod);
199 u32 convert_rate = rsnd_src_convert_rate(src); 190 u32 convert_rate = rsnd_src_convert_rate(src);
200 u32 adinr = runtime->channels;
201 u32 fsrate = 0; 191 u32 fsrate = 0;
202 192
203 if (convert_rate) 193 if (convert_rate)
@@ -214,17 +204,7 @@ static int rsnd_src_set_convert_rate(struct rsnd_mod *mod,
214 rsnd_mod_write(mod, SRC_SRCIR, 1); 204 rsnd_mod_write(mod, SRC_SRCIR, 1);
215 205
216 /* Set channel number and output bit length */ 206 /* Set channel number and output bit length */
217 switch (runtime->sample_bits) { 207 rsnd_mod_write(mod, SRC_ADINR, rsnd_get_adinr(mod));
218 case 16:
219 adinr |= OTBL_16;
220 break;
221 case 32:
222 adinr |= OTBL_24;
223 break;
224 default:
225 return -EIO;
226 }
227 rsnd_mod_write(mod, SRC_ADINR, adinr);
228 208
229 /* Enable the initial value of IFS */ 209 /* Enable the initial value of IFS */
230 if (fsrate) { 210 if (fsrate) {
@@ -487,8 +467,8 @@ static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod,
487 if (ret < 0) 467 if (ret < 0)
488 return ret; 468 return ret;
489 469
490 rsnd_mod_write(mod, SSI_BUSIF_ADINR, rsnd_mod_read(mod, SRC_ADINR)); 470 rsnd_mod_write(mod, SSI_BUSIF_ADINR, rsnd_get_adinr(mod));
491 rsnd_mod_write(mod, SSI_BUSIF_MODE, rsnd_mod_read(mod, SRC_BUSIF_MODE)); 471 rsnd_mod_write(mod, SSI_BUSIF_MODE, 1);
492 472
493 rsnd_mod_write(mod, SRC_SRCCR, 0x00011110); 473 rsnd_mod_write(mod, SRC_SRCCR, 0x00011110);
494 474