| From 9415fe2ed03e4cd9d5095eefebd5db791f257651 Mon Sep 17 00:00:00 2001 |
| From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| Date: Wed, 30 Jul 2014 23:52:04 -0700 |
| Subject: ASoC: rsnd: care detail of SRC_BSDSR |
| |
| Driver should care more detail of SRC_BSDSR settings. |
| The sound includes noise without this patch |
| if it used SRC. |
| |
| Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| Signed-off-by: Mark Brown <broonie@linaro.org> |
| (cherry picked from commit 054cd7f4b986a941b56372b743602f7df6569c98) |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| --- |
| sound/soc/sh/rcar/src.c | 32 +++++++++++++++++++++++++++++++- |
| 1 file changed, 31 insertions(+), 1 deletion(-) |
| |
| diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c |
| index 4d39505c21cf..1ef811a26bd7 100644 |
| --- a/sound/soc/sh/rcar/src.c |
| +++ b/sound/soc/sh/rcar/src.c |
| @@ -483,15 +483,45 @@ static struct rsnd_mod_ops rsnd_src_gen1_ops = { |
| static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod, |
| struct rsnd_dai *rdai) |
| { |
| + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); |
| + struct device *dev = rsnd_priv_to_dev(priv); |
| + struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); |
| + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); |
| + struct rsnd_src *src = rsnd_mod_to_src(mod); |
| + uint ratio; |
| int ret; |
| |
| + /* 6 - 1/6 are very enough ratio for SRC_BSDSR */ |
| + if (!rsnd_src_convert_rate(src)) |
| + ratio = 0; |
| + else if (rsnd_src_convert_rate(src) > runtime->rate) |
| + ratio = 100 * rsnd_src_convert_rate(src) / runtime->rate; |
| + else |
| + ratio = 100 * runtime->rate / rsnd_src_convert_rate(src); |
| + |
| + if (ratio > 600) { |
| + dev_err(dev, "FSO/FSI ratio error\n"); |
| + return -EINVAL; |
| + } |
| + |
| ret = rsnd_src_set_convert_rate(mod, rdai); |
| if (ret < 0) |
| return ret; |
| |
| rsnd_mod_write(mod, SRC_SRCCR, 0x00011110); |
| |
| - rsnd_mod_write(mod, SRC_BSDSR, 0x01800000); |
| + switch (rsnd_mod_id(mod)) { |
| + case 5: |
| + case 6: |
| + case 7: |
| + case 8: |
| + rsnd_mod_write(mod, SRC_BSDSR, 0x02400000); |
| + break; |
| + default: |
| + rsnd_mod_write(mod, SRC_BSDSR, 0x01800000); |
| + break; |
| + } |
| + |
| rsnd_mod_write(mod, SRC_BSISR, 0x00100060); |
| |
| return 0; |
| -- |
| 2.1.2 |
| |