[PATCH] ALSA: pcm: add 24KHz sample rate definition

Patrick Lai quic_plai at quicinc.com
Fri Jun 10 21:09:31 CEST 2022


Add 24KHz sample rate definition as some hardware
can support 24KHz sample rate PCM data

Signed-off-by: Patrick Lai <quic_plai at quicinc.com>
---
 include/sound/pcm.h     | 24 +++++++++++++-----------
 sound/core/pcm_native.c |  4 ++--
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 6b99310b5b88..a761a4459091 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -111,23 +111,25 @@ struct snd_pcm_ops {
 #define SNDRV_PCM_RATE_11025		(1<<2)		/* 11025Hz */
 #define SNDRV_PCM_RATE_16000		(1<<3)		/* 16000Hz */
 #define SNDRV_PCM_RATE_22050		(1<<4)		/* 22050Hz */
-#define SNDRV_PCM_RATE_32000		(1<<5)		/* 32000Hz */
-#define SNDRV_PCM_RATE_44100		(1<<6)		/* 44100Hz */
-#define SNDRV_PCM_RATE_48000		(1<<7)		/* 48000Hz */
-#define SNDRV_PCM_RATE_64000		(1<<8)		/* 64000Hz */
-#define SNDRV_PCM_RATE_88200		(1<<9)		/* 88200Hz */
-#define SNDRV_PCM_RATE_96000		(1<<10)		/* 96000Hz */
-#define SNDRV_PCM_RATE_176400		(1<<11)		/* 176400Hz */
-#define SNDRV_PCM_RATE_192000		(1<<12)		/* 192000Hz */
-#define SNDRV_PCM_RATE_352800		(1<<13)		/* 352800Hz */
-#define SNDRV_PCM_RATE_384000		(1<<14)		/* 384000Hz */
+#define SNDDV_PCM_RATE_24000		(1<<5)		/* 24000Hz */
+#define SNDRV_PCM_RATE_32000		(1<<6)		/* 32000Hz */
+#define SNDRV_PCM_RATE_44100		(1<<7)		/* 44100Hz */
+#define SNDRV_PCM_RATE_48000		(1<<8)		/* 48000Hz */
+#define SNDRV_PCM_RATE_64000		(1<<9)		/* 64000Hz */
+#define SNDRV_PCM_RATE_88200		(1<<10)		/* 88200Hz */
+#define SNDRV_PCM_RATE_96000		(1<<11)		/* 96000Hz */
+#define SNDRV_PCM_RATE_176400		(1<<12)		/* 176400Hz */
+#define SNDRV_PCM_RATE_192000		(1<<13)		/* 192000Hz */
+#define SNDRV_PCM_RATE_352800		(1<<14)		/* 352800Hz */
+#define SNDRV_PCM_RATE_384000		(1<<15)		/* 384000Hz */
 
 #define SNDRV_PCM_RATE_CONTINUOUS	(1<<30)		/* continuous range */
 #define SNDRV_PCM_RATE_KNOT		(1<<31)		/* supports more non-continuos rates */
 
 #define SNDRV_PCM_RATE_8000_44100	(SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\
 					 SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_22050|\
-					 SNDRV_PCM_RATE_32000|SNDRV_PCM_RATE_44100)
+					 SNDRV_PCM_RATE_24000|SNDRV_PCM_RATE_32000|\
+					 SNDRV_PCM_RATE_44100)
 #define SNDRV_PCM_RATE_8000_48000	(SNDRV_PCM_RATE_8000_44100|SNDRV_PCM_RATE_48000)
 #define SNDRV_PCM_RATE_8000_96000	(SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_64000|\
 					 SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 4adaee62ef33..72e3eab09518 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2442,12 +2442,12 @@ static int snd_pcm_hw_rule_sample_bits(struct snd_pcm_hw_params *params,
 	return snd_interval_refine(hw_param_interval(params, rule->var), &t);
 }
 
-#if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12
+#if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 13
 #error "Change this table"
 #endif
 
 static const unsigned int rates[] = {
-	5512, 8000, 11025, 16000, 22050, 32000, 44100,
+	5512, 8000, 11025, 16000, 22050, 24000, 32000, 44100,
 	48000, 64000, 88200, 96000, 176400, 192000, 352800, 384000
 };
 
-- 
2.36.1



More information about the Alsa-devel mailing list