Skip to contentSkip to conversation

24 bit sample embedded in 32 bits

DISCUSSION Vipin Kumar 3 participants 4 messages Jul 2, 2012

lore
Share & tools
lore
#0 lore raw

Hello,

I assume that the alsa framework expects the 24 bit sample data to be packed one after the other. for example while recording a 2 channel, 24 bit sample data, typically the dma reads a fifo (which receives data from adc) and prepares a buffer which is then passed to the upper layers.

This buffer is expeted to be 24byte left channel and then 24 byte right channel. Am I right?

If the above assumption is correct, I need to find a way to tell the framework that the data is 24bit but is embedded in 32 bit. ie 32bit left and then 32 bit right channel data

I am tending to think that there has to be a way but I am unable to find it. Can you please point me to the right direction

Regards
Vipin

#1 lore raw
Quoted 10 lines · Vipin Kumar

Hello,

I assume that the alsa framework expects the 24 bit sample data to be packed one after the other. for example while recording a 2 channel, 24 bit sample data, typically the dma reads a fifo (which receives data from adc) and prepares a buffer which is then passed to the upper layers.

This buffer is expeted to be 24byte left channel and then 24 byte right channel. Am I right?

Quoted 6 lines

If the above assumption is correct, I need to find a way to tell the framework that the data is 24bit but is embedded in 32 bit. ie 32bit left and then 32 bit right channel data

I am tending to think that there has to be a way but I am unable to find it. Can you please point me to the right direction

Use S/U24 or S/U32 formats - look to adriver.h for SNDRV_PCM_FORMAT constants. S/U24 expects 24-bit samples with zero MSB in 32-bit words. S/U32 expects 32-bit samples (LSB is zero for 24-bit data).

Jaroslav

Signature · 3 lines
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.
#2 lore raw
In reply to Vipin Kumar
Quoted 2 lines · Vipin Kumar

I assume that the alsa framework expects the 24 bit sample data to be packed one after the other.

ALSA expects the sample data to conform to whatever sample format has been configured.

Most hardware uses 32-bit sample words in memory to make the interface to the PCI bus easier.

Quoted 2 lines

I need to find a way to tell the framework that the data is 24bit but is embedded in 32 bit.

(HH = highest byte, LL = lowest byte, MM = middle byte)

LL MM HH     SNDRV_PCM_FORMAT_S24_3LE
xx LL MM HH  SNDRV_PCM_FORMAT_S32_LE
LL MM HH xx  SNDRV_PCM_FORMAT_S24_LE
HH MM LL     SNDRV_PCM_FORMAT_S24_3BE
HH MM LL xx  SNDRV_PCM_FORMAT_S32_BE
xx HH MM LL  SNDRV_PCM_FORMAT_S24_BE

Regards,
Clemens

#3 lore raw
Quoted 13 lines · Clemens Ladisch
Quoted 2 lines · Vipin Kumar

I assume that the alsa framework expects the 24 bit sample data to be packed one after the other.

ALSA expects the sample data to conform to whatever sample format has been configured.

Most hardware uses 32-bit sample words in memory to make the interface to the PCI bus easier.

Quoted 2 lines

I need to find a way to tell the framework that the data is 24bit but is embedded in 32 bit.

Quoted 9 lines

(HH = highest byte, LL = lowest byte, MM = middle byte)

LL MM HH     SNDRV_PCM_FORMAT_S24_3LE
xx LL MM HH  SNDRV_PCM_FORMAT_S32_LE
LL MM HH xx  SNDRV_PCM_FORMAT_S24_LE
HH MM LL     SNDRV_PCM_FORMAT_S24_3BE
HH MM LL xx  SNDRV_PCM_FORMAT_S32_BE
xx HH MM LL  SNDRV_PCM_FORMAT_S24_BE

Thanks Clemens, Jaroslav,

This was very helpful..I would try more cases and come back for more doubts if there are any :)

Regards
Vipin

Quoted 5 lines

Regards,
Clemens
.