Hi,
I have a question about how linux deal with audio sample rate.
I'm using an IMX6 SABRE board with an IMX6DL. I replaced the audio codec WM8962 with an other codec.
I implemented a new codec and machine driver and playing/recording works fine.
But something is bugging me :
ALSA always set codec and platform sample rate to 48KHz, no matter what is the actual music sample rate.
For example, here is what I see when I start a music with a sample rate of 176.4KHz :
aplay -v music-wav
M: Rate conversion PCM (48000, sformat=S16_LE)
Converter: linear-interpolation
Protocol version: 10002
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 176400
exact rate : 176400 (176400/1)
msbits : 16
buffer_size : 60211
period_size : 7526
period_time : 42666
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 7526
period_event : 0
start_threshold : 60211
stop_threshold : 60211
silence_threshold: 0
silence_size : 0
boundary : 1972994048
Slave: Direct Stream Mixing PCM
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 16384
period_size : 2048
period_time : 42666
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2048
period_event : 0
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 1073741824
Hardware PCM card 0 'cs47l24-audio' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 16384
period_size : 2048
period_time : 42666
tstamp_mode : ENABLE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2048
period_event : 0
start_threshold : 1
stop_threshold : 1073741824
silence_threshold: 0
silence_size : 1073741824
boundary : 1073741824
appl_ptr : 0
hw_ptr : 0
So I'm wondering : why ALSA is configuring codec/platform at 48KHz and resampling the file output instead of configuring directly the codec with the good sample rate ?
In the platform/codec driver there is a structure setting the range of possible sample rate : snd_soc_dai_driver->playback.rates
For codec it's set to : SNDRV_PCM_RATE_8000_192000
For platfrom it's set to : SNDRV_PCM_RATE_CONTINUOUS
It seems to be correctly configured, so why keeping the same sample rate ?
If anybody have an idea, thank you :smileywink:
Hi Clement
please check imx6qdl.dtsi, in particular fsl,asrc-rate
linux-2.6-imx.git - Freescale i.MX Linux Tree
linux/Documentation/devicetree/bindings/sound/fsl,asrc.txt
and Chapter 29 Asynchronous Sample Rate Converter (ASRC) Driver
attached Linux Manual.
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------