diff mbox series

[1/3] ALSA: pcm: add support for 128kHz sample rate

Message ID 20240628122429.2018059-2-jbrunet@baylibre.com (mailing list archive)
State New
Headers show
Series ALSA: update sample rate definition for eARC | expand

Commit Message

Jerome Brunet June 28, 2024, 12:23 p.m. UTC
The usual sample rate possible on an SPDIF link are
32k, 44.1k, 48k, 88.2k, 96k, 172.4k and 192k.

With higher bandwidth variant, such as eARC, and the introduction of 8
channels mode, the spdif frame rate may be multiplied by 4. This happens
when the interface use an IEC958_SUBFRAME format.

The spdif 8 channel mode rate list is:
128k, 176.4k, 192k, 352.8k, 384k, 705.4k and 768k.

All are already supported by ASLA expect for the 128kHz one.
Add support for it but do not insert it the SNDRV_PCM_RATE_8000_192000
macro. Doing so would silently add 128k support to a lot of HW which
probably do not support it.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 include/sound/pcm.h     | 13 +++++++------
 sound/core/pcm_native.c |  6 +++---
 2 files changed, 10 insertions(+), 9 deletions(-)

Comments

kernel test robot June 29, 2024, 11:29 p.m. UTC | #1
Hi Jerome,

kernel test robot noticed the following build errors:

[auto build test ERROR on tiwai-sound/for-next]
[also build test ERROR on tiwai-sound/for-linus broonie-sound/for-next linus/master v6.10-rc5 next-20240628]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jerome-Brunet/ALSA-pcm-add-support-for-128kHz-sample-rate/20240629-201915
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20240628122429.2018059-2-jbrunet%40baylibre.com
patch subject: [PATCH 1/3] ALSA: pcm: add support for 128kHz sample rate
config: i386-buildonly-randconfig-004-20240630
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build):

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406300718.iL828kaG-lkp@intel.com/

All errors (new ones prefixed by >>):

>> sound/usb/caiaq/audio.c:179:2: error: #error "Change this table"
    #error "Change this table"
     ^~~~~


vim +179 sound/usb/caiaq/audio.c

523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  176  
523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  177  /* this should probably go upstream */
523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  178  #if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12
523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 @179  #error "Change this table"
523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  180  #endif
523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  181
kernel test robot June 30, 2024, 1:10 a.m. UTC | #2
Hi Jerome,

kernel test robot noticed the following build errors:

[auto build test ERROR on tiwai-sound/for-next]
[also build test ERROR on tiwai-sound/for-linus broonie-sound/for-next linus/master v6.10-rc5 next-20240628]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jerome-Brunet/ALSA-pcm-add-support-for-128kHz-sample-rate/20240629-201915
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20240628122429.2018059-2-jbrunet%40baylibre.com
patch subject: [PATCH 1/3] ALSA: pcm: add support for 128kHz sample rate
config: x86_64-buildonly-randconfig-003-20240630
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build):

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406300810.fyflTsWJ-lkp@intel.com/

All errors (new ones prefixed by >>):

>> sound/usb/caiaq/audio.c:179:2: error: "Change this table"
     179 | #error "Change this table"
         |  ^
   1 error generated.


vim +179 sound/usb/caiaq/audio.c

523f1dce37434a9 sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  176  
523f1dce37434a9 sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  177  /* this should probably go upstream */
523f1dce37434a9 sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  178  #if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12
523f1dce37434a9 sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 @179  #error "Change this table"
523f1dce37434a9 sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  180  #endif
523f1dce37434a9 sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  181
Jerome Brunet June 30, 2024, 6:53 a.m. UTC | #3
On Sun 30 Jun 2024 at 07:29, kernel test robot <lkp@intel.com> wrote:

> Hi Jerome,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on tiwai-sound/for-next]
> [also build test ERROR on tiwai-sound/for-linus broonie-sound/for-next linus/master v6.10-rc5 next-20240628]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Jerome-Brunet/ALSA-pcm-add-support-for-128kHz-sample-rate/20240629-201915
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
> patch link:    https://lore.kernel.org/r/20240628122429.2018059-2-jbrunet%40baylibre.com
> patch subject: [PATCH 1/3] ALSA: pcm: add support for 128kHz sample rate
> config: i386-buildonly-randconfig-004-20240630
> compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> reproduce (this is a W=1 build):
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202406300718.iL828kaG-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>>> sound/usb/caiaq/audio.c:179:2: error: #error "Change this table"
>     #error "Change this table"
>      ^~~~~
>
>
> vim +179 sound/usb/caiaq/audio.c
>
> 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  176  
> 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  177  /* this should probably go upstream */
> 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  178  #if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12
> 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 @179  #error "Change this table"
> 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  180  #endif
> 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  181  

This file is not in mainline or
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
branch ... Don't know what to make of this error ?
Amadeusz Sławiński July 1, 2024, 8:50 a.m. UTC | #4
On 6/28/2024 2:23 PM, Jerome Brunet wrote:
> The usual sample rate possible on an SPDIF link are
> 32k, 44.1k, 48k, 88.2k, 96k, 172.4k and 192k.
> 
> With higher bandwidth variant, such as eARC, and the introduction of 8
> channels mode, the spdif frame rate may be multiplied by 4. This happens
> when the interface use an IEC958_SUBFRAME format.
> 
> The spdif 8 channel mode rate list is:
> 128k, 176.4k, 192k, 352.8k, 384k, 705.4k and 768k.
> 
> All are already supported by ASLA expect for the 128kHz one.
> Add support for it but do not insert it the SNDRV_PCM_RATE_8000_192000
> macro. Doing so would silently add 128k support to a lot of HW which
> probably do not support it.
> 
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---

 From what I remember the recommendation is to not add new rates, but 
use SNDRV_PCM_RATE_KNOT for all rates not included already.
Takashi Iwai July 1, 2024, 2:04 p.m. UTC | #5
On Sun, 30 Jun 2024 08:53:15 +0200,
Jerome Brunet wrote:
> 
> On Sun 30 Jun 2024 at 07:29, kernel test robot <lkp@intel.com> wrote:
> 
> > Hi Jerome,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on tiwai-sound/for-next]
> > [also build test ERROR on tiwai-sound/for-linus broonie-sound/for-next linus/master v6.10-rc5 next-20240628]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> >
> > url:    https://github.com/intel-lab-lkp/linux/commits/Jerome-Brunet/ALSA-pcm-add-support-for-128kHz-sample-rate/20240629-201915
> > base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
> > patch link:    https://lore.kernel.org/r/20240628122429.2018059-2-jbrunet%40baylibre.com
> > patch subject: [PATCH 1/3] ALSA: pcm: add support for 128kHz sample rate
> > config: i386-buildonly-randconfig-004-20240630
> > compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> > reproduce (this is a W=1 build):
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202406300718.iL828kaG-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> >>> sound/usb/caiaq/audio.c:179:2: error: #error "Change this table"
> >     #error "Change this table"
> >      ^~~~~
> >
> >
> > vim +179 sound/usb/caiaq/audio.c
> >
> > 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  176  
> > 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  177  /* this should probably go upstream */
> > 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  178  #if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12
> > 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26 @179  #error "Change this table"
> > 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  180  #endif
> > 523f1dce37434a sound/usb/caiaq/caiaq-audio.c Daniel Mack 2007-03-26  181  
> 
> This file is not in mainline or
> https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
> branch ...

It's sound/usb/caiaq/audio.c.


Takashi
Takashi Iwai July 1, 2024, 2:07 p.m. UTC | #6
On Mon, 01 Jul 2024 10:50:02 +0200,
Amadeusz Sławiński wrote:
> 
> On 6/28/2024 2:23 PM, Jerome Brunet wrote:
> > The usual sample rate possible on an SPDIF link are
> > 32k, 44.1k, 48k, 88.2k, 96k, 172.4k and 192k.
> > 
> > With higher bandwidth variant, such as eARC, and the introduction of 8
> > channels mode, the spdif frame rate may be multiplied by 4. This happens
> > when the interface use an IEC958_SUBFRAME format.
> > 
> > The spdif 8 channel mode rate list is:
> > 128k, 176.4k, 192k, 352.8k, 384k, 705.4k and 768k.
> > 
> > All are already supported by ASLA expect for the 128kHz one.
> > Add support for it but do not insert it the SNDRV_PCM_RATE_8000_192000
> > macro. Doing so would silently add 128k support to a lot of HW which
> > probably do not support it.
> > 
> > Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> > ---
> 
> From what I remember the recommendation is to not add new rates, but
> use SNDRV_PCM_RATE_KNOT for all rates not included already.

In general yes -- unless the new rate is used for significant amount
of drivers.

So this case is a sort of on a border line; if it's only for ASoC
SPDIF codec driver, I'd rather implement with an extra rate list
instead of extending the common bits (that has some potential risks by
breaking the existing numbers).  OTOH, if we can take this for further
cleanups of the existing requirement of 128khz rate, we can go with
it.


thanks,

Takashi
diff mbox series

Patch

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 3edd7a7346da..9cda92b34eda 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -116,12 +116,13 @@  struct snd_pcm_ops {
 #define SNDRV_PCM_RATE_64000		(1U<<8)		/* 64000Hz */
 #define SNDRV_PCM_RATE_88200		(1U<<9)		/* 88200Hz */
 #define SNDRV_PCM_RATE_96000		(1U<<10)	/* 96000Hz */
-#define SNDRV_PCM_RATE_176400		(1U<<11)	/* 176400Hz */
-#define SNDRV_PCM_RATE_192000		(1U<<12)	/* 192000Hz */
-#define SNDRV_PCM_RATE_352800		(1U<<13)	/* 352800Hz */
-#define SNDRV_PCM_RATE_384000		(1U<<14)	/* 384000Hz */
-#define SNDRV_PCM_RATE_705600		(1U<<15)	/* 705600Hz */
-#define SNDRV_PCM_RATE_768000		(1U<<16)	/* 768000Hz */
+#define SNDRV_PCM_RATE_128000		(1U<<11)	/* 128000Hz */
+#define SNDRV_PCM_RATE_176400		(1U<<12)	/* 176400Hz */
+#define SNDRV_PCM_RATE_192000		(1U<<13)	/* 192000Hz */
+#define SNDRV_PCM_RATE_352800		(1U<<14)	/* 352800Hz */
+#define SNDRV_PCM_RATE_384000		(1U<<15)	/* 384000Hz */
+#define SNDRV_PCM_RATE_705600		(1U<<16)	/* 705600Hz */
+#define SNDRV_PCM_RATE_768000		(1U<<17)	/* 768000Hz */
 
 #define SNDRV_PCM_RATE_CONTINUOUS	(1U<<30)	/* continuous range */
 #define SNDRV_PCM_RATE_KNOT		(1U<<31)	/* supports more non-continuous rates */
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 521ba56392a0..87eeb9b7f54a 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2410,13 +2410,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_768000 != 1 << 17
 #error "Change this table"
 #endif
 
 static const unsigned int rates[] = {
-	5512, 8000, 11025, 16000, 22050, 32000, 44100,
-	48000, 64000, 88200, 96000, 176400, 192000, 352800, 384000, 705600, 768000
+	5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200,
+	96000, 128000, 176400, 192000, 352800, 384000, 705600, 768000,
 };
 
 const struct snd_pcm_hw_constraint_list snd_pcm_known_rates = {