ASoC: fsl_sai: add 12kHz, 24kHz, 176.4kHz and 192kHz sample rate support
authorZidan Wang <zidan.wang@freescale.com>
Mon, 11 May 2015 10:24:43 +0000 (18:24 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 12 May 2015 18:44:45 +0000 (19:44 +0100)
Normally we don't support 12kHz, 24kHz in audio driver, alsa didn't
have formal definition of 12kHz, 24kHz, but alsa supply a way to
support these sample rates. And add 176.4kHz and 192kHz support.

Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/fsl_sai.c

index cca72b8287a984ce585312d1dcf2d428d3779bc4..84ca28fdce7f4f59e11ff7f1ba6220540e5ce709 100644 (file)
 #define FSL_SAI_FLAGS (FSL_SAI_CSR_SEIE |\
                       FSL_SAI_CSR_FEIE)
 
+static u32 fsl_sai_rates[] = {
+       8000, 11025, 12000, 16000, 22050,
+       24000, 32000, 44100, 48000, 64000,
+       88200, 96000, 176400, 192000
+};
+
+static struct snd_pcm_hw_constraint_list fsl_sai_rate_constraints = {
+       .count = ARRAY_SIZE(fsl_sai_rates),
+       .list = fsl_sai_rates,
+};
+
 static irqreturn_t fsl_sai_isr(int irq, void *devid)
 {
        struct fsl_sai *sai = (struct fsl_sai *)devid;
@@ -519,7 +530,10 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream,
        regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx), FSL_SAI_CR3_TRCE,
                           FSL_SAI_CR3_TRCE);
 
-       return 0;
+       ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
+                       SNDRV_PCM_HW_PARAM_RATE, &fsl_sai_rate_constraints);
+
+       return ret;
 }
 
 static void fsl_sai_shutdown(struct snd_pcm_substream *substream,
@@ -573,14 +587,18 @@ static struct snd_soc_dai_driver fsl_sai_dai = {
                .stream_name = "CPU-Playback",
                .channels_min = 1,
                .channels_max = 2,
-               .rates = SNDRV_PCM_RATE_8000_96000,
+               .rate_min = 8000,
+               .rate_max = 192000,
+               .rates = SNDRV_PCM_RATE_KNOT,
                .formats = FSL_SAI_FORMATS,
        },
        .capture = {
                .stream_name = "CPU-Capture",
                .channels_min = 1,
                .channels_max = 2,
-               .rates = SNDRV_PCM_RATE_8000_96000,
+               .rate_min = 8000,
+               .rate_max = 192000,
+               .rates = SNDRV_PCM_RATE_KNOT,
                .formats = FSL_SAI_FORMATS,
        },
        .ops = &fsl_sai_pcm_dai_ops,