From dc5a4818433a59c187fa52b7d4585940ba6b2da5 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Tue, 10 Mar 2020 19:02:18 +0800 Subject: LF-941: ASoC: fsl_easrc: Switch to 32 taps for resampling filter With 128 taps of resampling filter, there is performance issue for high sample rate and mulitchannel. For example, there is noise issue for converting 48kHz to 768kHz, channel number is larger than 5 channels, and p2p case. So in order to increase performance, we reduce the taps number to 32 in default, the quality is relatively downgraded. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_easrc.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'sound/soc/fsl/fsl_easrc.c') diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c index c7917ccf8c82..4659844ff997 100644 --- a/sound/soc/fsl/fsl_easrc.c +++ b/sound/soc/fsl/fsl_easrc.c @@ -200,6 +200,12 @@ static int set_rs_ratio(struct fsl_easrc_context *ctx) val = ((uint64_t)in_rate << frac_bits) / out_rate; r = (uint32_t *)&val; + + if (r[1] & 0xFFFFF000) { + dev_err(&easrc->pdev->dev, "ratio exceed range\n"); + return -EINVAL; + } + ret = regmap_write(easrc->regmap, REG_EASRC_RRL(ctx->index), EASRC_RRL_RS_RL(r[0])); @@ -2267,6 +2273,7 @@ static int fsl_easrc_probe(struct platform_device *pdev) struct device_node *np; void __iomem *regs; int ret, irq; + u32 rstap = 0; u32 width; easrc = devm_kzalloc(&pdev->dev, sizeof(*easrc), GFP_KERNEL); @@ -2316,9 +2323,24 @@ static int fsl_easrc_probe(struct platform_device *pdev) /*Set default value*/ easrc->chn_avail = 32; - easrc->rs_num_taps = EASRC_RS_128_TAPS; easrc->const_coeff = 0x3FF0000000000000; + of_property_read_u32(np, "fsl,asrc-rstap", &rstap); + switch (rstap) { + case 32: + easrc->rs_num_taps = EASRC_RS_32_TAPS; + break; + case 64: + easrc->rs_num_taps = EASRC_RS_64_TAPS; + break; + case 128: + easrc->rs_num_taps = EASRC_RS_128_TAPS; + break; + default: + easrc->rs_num_taps = EASRC_RS_32_TAPS; + break; + } + ret = of_property_read_u32(np, "fsl,asrc-rate", &easrc->easrc_rate); if (ret) { -- cgit v1.2.3