[alsa-devel] [PATCH] ALSA: core: update supported sample rates
Add 12KHz, 24KHz, 352.8KHz and 384KHz audio sample rates
Signed-off-by: Li Xu li.xu@cirrus.com --- include/sound/pcm.h | 27 +++++++++++++++++---------- sound/core/pcm_native.c | 7 ++++--- 2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index af1fb37..3ce4ad9 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -119,16 +119,20 @@ struct snd_pcm_ops { #define SNDRV_PCM_RATE_5512 (1<<0) /* 5512Hz */ #define SNDRV_PCM_RATE_8000 (1<<1) /* 8000Hz */ #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_12000 (1<<3) /* 12000Hz */ +#define SNDRV_PCM_RATE_16000 (1<<4) /* 16000Hz */ +#define SNDRV_PCM_RATE_22050 (1<<5) /* 22050Hz */ +#define SNDRV_PCM_RATE_24000 (1<<6) /* 24000Hz */ +#define SNDRV_PCM_RATE_32000 (1<<7) /* 32000Hz */ +#define SNDRV_PCM_RATE_44100 (1<<8) /* 44100Hz */ +#define SNDRV_PCM_RATE_48000 (1<<9) /* 48000Hz */ +#define SNDRV_PCM_RATE_64000 (1<<10) /* 64000Hz */ +#define SNDRV_PCM_RATE_88200 (1<<11) /* 88200Hz */ +#define SNDRV_PCM_RATE_96000 (1<<12) /* 96000Hz */ +#define SNDRV_PCM_RATE_176400 (1<<13) /* 176400Hz */ +#define SNDRV_PCM_RATE_192000 (1<<14) /* 192000Hz */ +#define SNDRV_PCM_RATE_352800 (1<<15) /* 352800Hz */ +#define SNDRV_PCM_RATE_384000 (1<<16) /* 384000Hz */
#define SNDRV_PCM_RATE_CONTINUOUS (1<<30) /* continuous range */ #define SNDRV_PCM_RATE_KNOT (1<<31) /* supports more non-continuos rates */ @@ -141,6 +145,9 @@ struct snd_pcm_ops { SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000) #define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\ SNDRV_PCM_RATE_192000) +#define SNDRV_PCM_RATE_8000_384000 (SNDRV_PCM_RATE_8000_192000|\ + SNDRV_PCM_RATE_384000) + #define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt) #define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8) #define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 9d33c1e..9bc1011 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1981,12 +1981,13 @@ 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_384000 != 1 << 16 #error "Change this table" #endif
-static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, - 48000, 64000, 88200, 96000, 176400, 192000 }; +static unsigned int rates[] = { 5512, 8000, 11025, 12000, 16000, 22050, + 24000, 32000, 44100, 48000, 64000, 88200, + 96000, 176400, 192000, 352800, 384000 };
const struct snd_pcm_hw_constraint_list snd_pcm_known_rates = { .count = ARRAY_SIZE(rates),
Li Xu wrote:
Add 12KHz, 24KHz, 352.8KHz and 384KHz audio sample rates
+#define SNDRV_PCM_RATE_12000 (1<<3) /* 12000Hz */ +#define SNDRV_PCM_RATE_24000 (1<<6) /* 24000Hz */ +#define SNDRV_PCM_RATE_352800 (1<<15) /* 352800Hz */ +#define SNDRV_PCM_RATE_384000 (1<<16) /* 384000Hz */
To quote http://mailman.alsa-project.org/pipermail/alsa-devel/2013-July/064461.html: You don't need such symbols to use a rate. These symbols are intended for often-used rates. As long as only one or two drivers use a rate, they can just set KNOT and install a constraint.
How many driver would actually use it?
Regards, Clemens
On Fri, 02 Dec 2016 08:36:22 +0100, Clemens Ladisch wrote:
Li Xu wrote:
Add 12KHz, 24KHz, 352.8KHz and 384KHz audio sample rates
+#define SNDRV_PCM_RATE_12000 (1<<3) /* 12000Hz */ +#define SNDRV_PCM_RATE_24000 (1<<6) /* 24000Hz */ +#define SNDRV_PCM_RATE_352800 (1<<15) /* 352800Hz */ +#define SNDRV_PCM_RATE_384000 (1<<16) /* 384000Hz */
To quote http://mailman.alsa-project.org/pipermail/alsa-devel/2013-July/064461.html: You don't need such symbols to use a rate. These symbols are intended for often-used rates. As long as only one or two drivers use a rate, they can just set KNOT and install a constraint.
How many driver would actually use it?
Maybe 352.8k or 384kHz are getting popular, but yes, I'd love to see the actual users before defining such things. Don't get me wrong, I'm not against adding it; I'm just against blindly adding it.
However, while looking at these requests, I wonder whether it'd be cleaner to add an optional rate array in snd_pcm_hardware struct itself. This will reduce the total code sizes, too, I guess.
Opinion?
thanks,
Takashi
Hi Li,
[auto build test WARNING on sound/for-next] [also build test WARNING on v4.9-rc7 next-20161202] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Li-Xu/ALSA-core-update-supported-sa... base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
sound/usb/caiaq/audio.c:199:2: sparse: "Change this table"
include/linux/compiler.h:253:8: sparse: attribute 'no_sanitize_address': unknown attribute sound/usb/caiaq/audio.c:199:2: error: #error "Change this table" #error "Change this table" ^~~~~
vim +199 sound/usb/caiaq/audio.c
523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 183 static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 184 struct snd_pcm_hw_params *hw_params) 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 185 { fc76f863 sound/usb/caiaq/audio.c Antonio Ospite 2013-06-21 186 return snd_pcm_lib_alloc_vmalloc_buffer(sub, fc76f863 sound/usb/caiaq/audio.c Antonio Ospite 2013-06-21 187 params_buffer_bytes(hw_params)); 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 188 } 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 189 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 190 static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 191 { 1c8470ce sound/usb/caiaq/audio.c Daniel Mack 2013-03-03 192 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); 1c8470ce sound/usb/caiaq/audio.c Daniel Mack 2013-03-03 193 deactivate_substream(cdev, sub); fc76f863 sound/usb/caiaq/audio.c Antonio Ospite 2013-06-21 194 return snd_pcm_lib_free_vmalloc_buffer(sub); 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 195 } 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 196 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 197 /* this should probably go upstream */ 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 198 #if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 @199 #error "Change this table" 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 200 #endif 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 201 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 202 static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 203 48000, 64000, 88200, 96000, 176400, 192000 }; 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 204 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 205 static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 206 { 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 207 int bytes_per_sample, bpp, ret, i;
:::::: The code at line 199 was first introduced by commit :::::: 523f1dce37434a9a6623bf46e7893e2b4b10ac3c [ALSA] Add Native Instrument usb audio device support
:::::: TO: Daniel Mack daniel@caiaq.org :::::: CC: Jaroslav Kysela perex@suse.cz
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Li,
[auto build test ERROR on sound/for-next] [also build test ERROR on v4.9-rc7 next-20161202] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Li-Xu/ALSA-core-update-supported-sa... base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next config: x86_64-rhel (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All errors (new ones prefixed by >>):
sound/usb/caiaq/audio.c:199:2: error: #error "Change this table"
#error "Change this table" ^~~~~
vim +199 sound/usb/caiaq/audio.c
523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 183 static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 184 struct snd_pcm_hw_params *hw_params) 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 185 { fc76f863 sound/usb/caiaq/audio.c Antonio Ospite 2013-06-21 186 return snd_pcm_lib_alloc_vmalloc_buffer(sub, fc76f863 sound/usb/caiaq/audio.c Antonio Ospite 2013-06-21 187 params_buffer_bytes(hw_params)); 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 188 } 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 189 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 190 static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 191 { 1c8470ce sound/usb/caiaq/audio.c Daniel Mack 2013-03-03 192 struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); 1c8470ce sound/usb/caiaq/audio.c Daniel Mack 2013-03-03 193 deactivate_substream(cdev, sub); fc76f863 sound/usb/caiaq/audio.c Antonio Ospite 2013-06-21 194 return snd_pcm_lib_free_vmalloc_buffer(sub); 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 195 } 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 196 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 197 /* this should probably go upstream */ 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 198 #if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 @199 #error "Change this table" 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 200 #endif 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 201 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 202 static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 203 48000, 64000, 88200, 96000, 176400, 192000 }; 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 204 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 205 static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 206 { 523f1dce sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 207 int bytes_per_sample, bpp, ret, i;
:::::: The code at line 199 was first introduced by commit :::::: 523f1dce37434a9a6623bf46e7893e2b4b10ac3c [ALSA] Add Native Instrument usb audio device support
:::::: TO: Daniel Mack daniel@caiaq.org :::::: CC: Jaroslav Kysela perex@suse.cz
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
participants (4)
-
Clemens Ladisch
-
kbuild test robot
-
Li Xu
-
Takashi Iwai