Unify the supported input and output rate, add the
12kHz/24kHz/128kHz to the support list

Signed-off-by: Shengjiu Wang <shengjiu.w...@nxp.com>
Acked-by: Nicolin Chen <nicoleots...@gmail.com>
---
 sound/soc/fsl/fsl_asrc.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index a8d6710f2541..cbbf6257f08a 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -27,13 +27,14 @@
        dev_dbg(&asrc_priv->pdev->dev, "Pair %c: " fmt, 'A' + index, 
##__VA_ARGS__)
 
 /* Corresponding to process_option */
-static int supported_input_rate[] = {
-       5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200,
-       96000, 176400, 192000,
+static unsigned int supported_asrc_rate[] = {
+       5512, 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
+       64000, 88200, 96000, 128000, 176400, 192000,
 };
 
-static int supported_asrc_rate[] = {
-       8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000, 
176400, 192000,
+static struct snd_pcm_hw_constraint_list fsl_asrc_rate_constraints = {
+       .count = ARRAY_SIZE(supported_asrc_rate),
+       .list = supported_asrc_rate,
 };
 
 /**
@@ -293,11 +294,11 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair 
*pair)
        ideal = config->inclk == INCLK_NONE;
 
        /* Validate input and output sample rates */
-       for (in = 0; in < ARRAY_SIZE(supported_input_rate); in++)
-               if (inrate == supported_input_rate[in])
+       for (in = 0; in < ARRAY_SIZE(supported_asrc_rate); in++)
+               if (inrate == supported_asrc_rate[in])
                        break;
 
-       if (in == ARRAY_SIZE(supported_input_rate)) {
+       if (in == ARRAY_SIZE(supported_asrc_rate)) {
                pair_err("unsupported input sample rate: %dHz\n", inrate);
                return -EINVAL;
        }
@@ -311,7 +312,7 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair)
                return -EINVAL;
        }
 
-       if ((outrate >= 8000 && outrate <= 30000) &&
+       if ((outrate >= 5512 && outrate <= 30000) &&
            (outrate > 24 * inrate || inrate > 8 * outrate)) {
                pair_err("exceed supported ratio range [1/24, 8] for \
                                inrate/outrate: %d/%d\n", inrate, outrate);
@@ -486,7 +487,9 @@ static int fsl_asrc_dai_startup(struct snd_pcm_substream 
*substream,
                snd_pcm_hw_constraint_step(substream->runtime, 0,
                                           SNDRV_PCM_HW_PARAM_CHANNELS, 2);
 
-       return 0;
+
+       return snd_pcm_hw_constraint_list(substream->runtime, 0,
+                       SNDRV_PCM_HW_PARAM_RATE, &fsl_asrc_rate_constraints);
 }
 
 static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream,
@@ -599,7 +602,6 @@ static int fsl_asrc_dai_probe(struct snd_soc_dai *dai)
        return 0;
 }
 
-#define FSL_ASRC_RATES          SNDRV_PCM_RATE_8000_192000
 #define FSL_ASRC_FORMATS       (SNDRV_PCM_FMTBIT_S24_LE | \
                                 SNDRV_PCM_FMTBIT_S16_LE | \
                                 SNDRV_PCM_FMTBIT_S20_3LE)
@@ -610,14 +612,18 @@ static struct snd_soc_dai_driver fsl_asrc_dai = {
                .stream_name = "ASRC-Playback",
                .channels_min = 1,
                .channels_max = 10,
-               .rates = FSL_ASRC_RATES,
+               .rate_min = 5512,
+               .rate_max = 192000,
+               .rates = SNDRV_PCM_RATE_KNOT,
                .formats = FSL_ASRC_FORMATS,
        },
        .capture = {
                .stream_name = "ASRC-Capture",
                .channels_min = 1,
                .channels_max = 10,
-               .rates = FSL_ASRC_RATES,
+               .rate_min = 5512,
+               .rate_max = 192000,
+               .rates = SNDRV_PCM_RATE_KNOT,
                .formats = FSL_ASRC_FORMATS,
        },
        .ops = &fsl_asrc_dai_ops,
-- 
2.21.0

Reply via email to