aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Bondavalli <andrea.bondavalli74@gmail.com>2017-12-12 04:14:50 -0500
committerMark Brown <broonie@kernel.org>2017-12-12 05:38:03 -0500
commit5a0cf02465a0510c48ab34e7ba88b0f8c20b9ea1 (patch)
treefbb0c3808480db4713231684bf1f492cd3cf0683
parent21faaea1343f2f8dc6539302c92231afc6d999a5 (diff)
ASoC: sun4i-codec: enable 12Khz and 24Khz audio sample rates
H3 ASoC supports 12Khz and 24Khz audio sample rates but the current drivers doesn't advertise these rates properly and they cannot be used. For example attempt to capture at 12Khz uses 11Khz (same applies to audio playback): Recording raw data '/tmp/testS16_LE.raw' : Signed 16 bit Little Endian, Rate 12000 Hz, Stereo Warning: rate is not accurate (requested = 12000Hz, got = 11025Hz) This patch fixes the audio sample rates declared and supported by the driver according to the H3 data sheet. Specifically for audio playback: 8000, 11050, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, 192000 and for audio capture: 8000, 11050, 12000, 16000, 22050, 24000, 32000, 44100, 48000 Signed-off-by: Andrea Bondavalli <andrea.bondavalli74@gmail.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sunxi/sun4i-codec.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 5da4efe7a550..886281673972 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -590,12 +590,28 @@ static int sun4i_codec_hw_params(struct snd_pcm_substream *substream,
590 hwrate); 590 hwrate);
591} 591}
592 592
593
594static unsigned int sun4i_codec_src_rates[] = {
595 8000, 11025, 12000, 16000, 22050, 24000, 32000,
596 44100, 48000, 96000, 192000
597};
598
599
600static struct snd_pcm_hw_constraint_list sun4i_codec_constraints = {
601 .count = ARRAY_SIZE(sun4i_codec_src_rates),
602 .list = sun4i_codec_src_rates,
603};
604
605
593static int sun4i_codec_startup(struct snd_pcm_substream *substream, 606static int sun4i_codec_startup(struct snd_pcm_substream *substream,
594 struct snd_soc_dai *dai) 607 struct snd_soc_dai *dai)
595{ 608{
596 struct snd_soc_pcm_runtime *rtd = substream->private_data; 609 struct snd_soc_pcm_runtime *rtd = substream->private_data;
597 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); 610 struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card);
598 611
612 snd_pcm_hw_constraint_list(substream->runtime, 0,
613 SNDRV_PCM_HW_PARAM_RATE, &sun4i_codec_constraints);
614
599 /* 615 /*
600 * Stop issuing DRQ when we have room for less than 16 samples 616 * Stop issuing DRQ when we have room for less than 16 samples
601 * in our TX FIFO 617 * in our TX FIFO
@@ -633,9 +649,7 @@ static struct snd_soc_dai_driver sun4i_codec_dai = {
633 .channels_max = 2, 649 .channels_max = 2,
634 .rate_min = 8000, 650 .rate_min = 8000,
635 .rate_max = 192000, 651 .rate_max = 192000,
636 .rates = SNDRV_PCM_RATE_8000_48000 | 652 .rates = SNDRV_PCM_RATE_CONTINUOUS,
637 SNDRV_PCM_RATE_96000 |
638 SNDRV_PCM_RATE_192000,
639 .formats = SNDRV_PCM_FMTBIT_S16_LE | 653 .formats = SNDRV_PCM_FMTBIT_S16_LE |
640 SNDRV_PCM_FMTBIT_S32_LE, 654 SNDRV_PCM_FMTBIT_S32_LE,
641 .sig_bits = 24, 655 .sig_bits = 24,
@@ -645,11 +659,8 @@ static struct snd_soc_dai_driver sun4i_codec_dai = {
645 .channels_min = 1, 659 .channels_min = 1,
646 .channels_max = 2, 660 .channels_max = 2,
647 .rate_min = 8000, 661 .rate_min = 8000,
648 .rate_max = 192000, 662 .rate_max = 48000,
649 .rates = SNDRV_PCM_RATE_8000_48000 | 663 .rates = SNDRV_PCM_RATE_CONTINUOUS,
650 SNDRV_PCM_RATE_96000 |
651 SNDRV_PCM_RATE_192000 |
652 SNDRV_PCM_RATE_KNOT,
653 .formats = SNDRV_PCM_FMTBIT_S16_LE | 664 .formats = SNDRV_PCM_FMTBIT_S16_LE |
654 SNDRV_PCM_FMTBIT_S32_LE, 665 SNDRV_PCM_FMTBIT_S32_LE,
655 .sig_bits = 24, 666 .sig_bits = 24,
@@ -1128,7 +1139,7 @@ static const struct snd_soc_component_driver sun4i_codec_component = {
1128 .name = "sun4i-codec", 1139 .name = "sun4i-codec",
1129}; 1140};
1130 1141
1131#define SUN4I_CODEC_RATES SNDRV_PCM_RATE_8000_192000 1142#define SUN4I_CODEC_RATES SNDRV_PCM_RATE_CONTINUOUS
1132#define SUN4I_CODEC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ 1143#define SUN4I_CODEC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
1133 SNDRV_PCM_FMTBIT_S32_LE) 1144 SNDRV_PCM_FMTBIT_S32_LE)
1134 1145