MLK-22333: ASoC: fsl_easrc: Support FLOAT_LE
authorShengjiu Wang <shengjiu.wang@nxp.com>
Fri, 26 Jul 2019 08:08:17 +0000 (16:08 +0800)
committerShengjiu Wang <shengjiu.wang@nxp.com>
Mon, 29 Jul 2019 10:01:52 +0000 (18:01 +0800)
commit912eb85211eff912edbaaf901fafee8ff0f5f7a0
tree055f1e538dbc562e3fce6fb6ce2648a50402ff73
parentb9b521dfb0ab10b85e0a42414a6f7e3f80ad5ddc
MLK-22333: ASoC: fsl_easrc: Support FLOAT_LE

The audio float point data range is (-1, 1), the asrc would output
all zero for float point input and integer output case, that is to
drop the fractional part of the data directly.

In order to support float to int conversion or int to float conversion
we need to do special operation on the coefficient to enlarge/reduce
the data to the expected range.

For float to int case:
Up sampling:
1. Create a 1 tap filter with center tap (only tap) of 2^31
   in 64 bits floating point.
   double value = (double)(((uint64_t)1) << 31);
2. Program 1 tap prefilter with center tap above.

Down sampling,
1. If the filter is single stage filter, add "shift" to the exponent of
   stage 1 coefficients.
2. If the filter is two stage filter , add "shift" to the exponent of
   stage 2 coefficients.

The "shift" is 31, same for int16, int24, int32 case.

For int to float case:
Up sampling:
1. Create a 1 tap filter with center tap (only tap) of 2^-31
   in 64 bits floating point.
2. Program 1 tap prefilter with center tap above.

Down sampling,
1. If the filter is single stage filter, subtract "shift" to the
   exponent of stage 1 coefficients.
2. If the filter is two stage filter , subtract "shift" to the
   exponent of stage 2 coefficients.

The "shift" is 15,23,31, different for int16, int24, int32 case.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
(cherry picked from commit 8a18a7a2dd1184814c6c61cb116f4d868b003447)
sound/soc/fsl/fsl_easrc.c
sound/soc/fsl/fsl_easrc.h
sound/soc/fsl/fsl_easrc_m2m.c