alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Maxime Ripard <mripard@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: Ondrej Jirman <megous@megous.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Samuel Holland <samuel@sholland.org>
Subject: [PATCH v2 09/17] ASoC: sun8i-codec: Enable all supported sample rates
Date: Wed, 14 Oct 2020 01:19:33 -0500	[thread overview]
Message-ID: <20201014061941.4306-10-samuel@sholland.org> (raw)
In-Reply-To: <20201014061941.4306-1-samuel@sholland.org>

The system sample rate programmed into the hardware is really a clock
divider from SYSCLK to the ADC and DAC. Since we support two SYSCLK
frequencies, we can use all sample rates corresponding to one of those
frequencies divided by any available divisor.

This commit enables support for those sample rates. It also stops
advertising support for a 64 kHz sample rate, which is not supported.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 sound/soc/sunxi/sun8i-codec.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c
index 21104e6e8892..38349d85fb17 100644
--- a/sound/soc/sunxi/sun8i-codec.c
+++ b/sound/soc/sunxi/sun8i-codec.c
@@ -89,16 +89,23 @@
 #define SUN8I_SYS_SR_CTRL_AIF1_FS_MASK		GENMASK(15, 12)
 #define SUN8I_SYS_SR_CTRL_AIF2_FS_MASK		GENMASK(11, 8)
 #define SUN8I_AIF1CLK_CTRL_AIF1_CLK_INV_MASK	GENMASK(14, 13)
 #define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK	GENMASK(12, 9)
 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK	GENMASK(8, 6)
 #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK	GENMASK(5, 4)
 #define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT_MASK	GENMASK(3, 2)
 
+#define SUN8I_CODEC_PCM_RATES	(SNDRV_PCM_RATE_8000_48000|\
+				 SNDRV_PCM_RATE_88200     |\
+				 SNDRV_PCM_RATE_96000     |\
+				 SNDRV_PCM_RATE_176400    |\
+				 SNDRV_PCM_RATE_192000    |\
+				 SNDRV_PCM_RATE_KNOT)
+
 enum {
 	SUN8I_CODEC_AIF1,
 	SUN8I_CODEC_NAIFS
 };
 
 struct sun8i_codec_aif {
 	unsigned int	slots;
 	unsigned int	slot_width;
@@ -142,37 +149,41 @@ static int sun8i_codec_runtime_suspend(struct device *dev)
 	return 0;
 }
 
 static int sun8i_codec_get_hw_rate(struct snd_pcm_hw_params *params)
 {
 	unsigned int rate = params_rate(params);
 
 	switch (rate) {
-	case 8000:
 	case 7350:
+	case 8000:
 		return 0x0;
 	case 11025:
 		return 0x1;
 	case 12000:
 		return 0x2;
+	case 14700:
 	case 16000:
 		return 0x3;
 	case 22050:
 		return 0x4;
 	case 24000:
 		return 0x5;
+	case 29400:
 	case 32000:
 		return 0x6;
 	case 44100:
 		return 0x7;
 	case 48000:
 		return 0x8;
+	case 88200:
 	case 96000:
 		return 0x9;
+	case 176400:
 	case 192000:
 		return 0xa;
 	default:
 		return -EINVAL;
 	}
 }
 
 static int sun8i_codec_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
@@ -408,26 +419,26 @@ static struct snd_soc_dai_driver sun8i_codec_dais[] = {
 		.name	= "sun8i-codec-aif1",
 		.id	= SUN8I_CODEC_AIF1,
 		.ops	= &sun8i_codec_dai_ops,
 		/* capture capabilities */
 		.capture = {
 			.stream_name	= "AIF1 Capture",
 			.channels_min	= 1,
 			.channels_max	= 2,
-			.rates		= SNDRV_PCM_RATE_8000_192000,
+			.rates		= SUN8I_CODEC_PCM_RATES,
 			.formats	= SNDRV_PCM_FMTBIT_S16_LE,
 			.sig_bits	= 24,
 		},
 		/* playback capabilities */
 		.playback = {
 			.stream_name	= "AIF1 Playback",
 			.channels_min	= 1,
 			.channels_max	= 2,
-			.rates		= SNDRV_PCM_RATE_8000_192000,
+			.rates		= SUN8I_CODEC_PCM_RATES,
 			.formats	= SNDRV_PCM_FMTBIT_S16_LE,
 		},
 		.symmetric_rates	= true,
 		.symmetric_channels	= true,
 		.symmetric_samplebits	= true,
 	},
 };
 
-- 
2.26.2


  parent reply	other threads:[~2020-10-14  6:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14  6:19 [PATCH v2 00/17] ASoC: sun8i-codec: support for AIF2 and AIF3 Samuel Holland
2020-10-14  6:19 ` [PATCH v2 01/17] ASoC: sun8i-codec: Prepare to extend the DAI driver Samuel Holland
2020-10-14  6:19 ` [PATCH v2 02/17] ASoC: sun8i-codec: Program DAI format before clock inversion Samuel Holland
2020-10-14  6:19 ` [PATCH v2 03/17] ASoC: sun8i-codec: Enable all supported clock inversions Samuel Holland
2020-10-19  8:24   ` Maxime Ripard
2020-10-14  6:19 ` [PATCH v2 04/17] ASoC: sun8i-codec: Use the provided word size Samuel Holland
2020-10-14  6:19 ` [PATCH v2 05/17] ASoC: sun8i-codec: Round up the LRCK divisor Samuel Holland
2020-10-14  6:19 ` [PATCH v2 06/17] ASoC: sun8i-codec: Correct the BCLK divisor calculation Samuel Holland
2020-10-14  6:19 ` [PATCH v2 07/17] ASoC: sun8i-codec: Support the TDM slot binding Samuel Holland
2020-10-14  6:19 ` [PATCH v2 08/17] ASoC: sun8i-codec: Enforce symmetric DAI parameters Samuel Holland
2020-10-14  6:19 ` Samuel Holland [this message]
2020-10-14  6:19 ` [PATCH v2 10/17] ASoC: sun8i-codec: Automatically set the system sample rate Samuel Holland
2020-10-19  8:25   ` Maxime Ripard
2020-10-14  6:19 ` [PATCH v2 11/17] ASoC: sun8i-codec: Constrain to compatible sample rates Samuel Holland
2020-10-14  6:19 ` [PATCH v2 12/17] ASoC: sun8i-codec: Protect the clock rate while streams are open Samuel Holland
2020-10-19  8:28   ` Maxime Ripard
2020-10-14  6:19 ` [PATCH v2 13/17] ASoC: sun8i-codec: Require an exact BCLK divisor match Samuel Holland
2020-10-14  6:19 ` [PATCH v2 14/17] ASoC: sun8i-codec: Enable all supported PCM formats Samuel Holland
2020-10-14  6:19 ` [PATCH v2 15/17] ASoC: sun8i-codec: Generalize AIF clock control Samuel Holland
2020-10-19  8:56   ` Maxime Ripard
2020-10-14  6:19 ` [PATCH v2 16/17] ASoC: sun8i-codec: Add the AIF2 DAI, widgets, and routes Samuel Holland
2020-10-14  6:19 ` [PATCH v2 17/17] ASoC: sun8i-codec: Add the AIF3 " Samuel Holland
2020-10-15  3:24   ` Samuel Holland
2020-10-26 23:46 ` [PATCH v2 00/17] ASoC: sun8i-codec: support for AIF2 and AIF3 Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201014061941.4306-10-samuel@sholland.org \
    --to=samuel@sholland.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=megous@megous.com \
    --cc=mripard@kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).