Re: [alsa-devel] Stream format conversion in SoC driver
Giedrius Trainavičius wrote:
It uses I2S for sending / receiving audio. However, the master clock on our sound card is generated by the ADC, which supports only 24 bit data, so getting other sample formats is not possible.
The I2S sample format need not be the same as what the DMA controller reads/writes from/to memory.
A question on 'plug' - it accepts 'nearest' as the argument for format, rate, what happens in case the slave pcm stream supports the exact same format as requested by user software?
The plug plugin instantiates the actual conversion plugins only as needed; with no conversion, it vanishes entirely.
Regards, Clemens
The I2S and DMA format asymmetry sounds like what I'd be after. Do you have any pointers for APIs / keywords to look around for in the code to see how this should be set up? Is such format conversion supposed to be happening in hardware itself, or the CPU when accessing the DMA buffer has the chance to do the conversion?
The relevant documentation and code I found so far would be:
https://www.raspberrypi.org/documentation/hardware/ raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf https://github.com/raspberrypi/linux/blob/rpi-4. 4.y/sound/soc/bcm/bcm2835-i2s.c
I can't locate any relevant bits of code or information that'd indicate capabilities of sample format conversion...
Thank you, Giedrius.
On Thu, Dec 29, 2016 at 7:53 AM, Clemens Ladisch clemens@ladisch.de wrote:
Giedrius Trainavičius wrote:
It uses I2S for sending / receiving audio. However, the master clock on
our
sound card is generated by the ADC, which supports only 24 bit data, so getting other sample formats is not possible.
The I2S sample format need not be the same as what the DMA controller reads/writes from/to memory.
A question on 'plug' - it accepts 'nearest' as the argument for format, rate, what happens in case the slave pcm stream supports the exact same format as requested by user software?
The plug plugin instantiates the actual conversion plugins only as needed; with no conversion, it vanishes entirely.
Regards, Clemens
Hey,
Any thoughts or pointers on what to look for in order to use different sample format between actual I2S and DMA?
Thank you, Giedrius.
On Thu, Dec 29, 2016 at 4:32 PM, Giedrius Trainavičius < giedrius.trainavicius@gmail.com> wrote:
The I2S and DMA format asymmetry sounds like what I'd be after. Do you have any pointers for APIs / keywords to look around for in the code to see how this should be set up? Is such format conversion supposed to be happening in hardware itself, or the CPU when accessing the DMA buffer has the chance to do the conversion?
The relevant documentation and code I found so far would be:
https://www.raspberrypi.org/documentation/hardware/raspberry pi/bcm2835/BCM2835-ARM-Peripherals.pdf https://github.com/raspberrypi/linux/blob/rpi-4.4.y/sound/ soc/bcm/bcm2835-i2s.c
I can't locate any relevant bits of code or information that'd indicate capabilities of sample format conversion...
Thank you, Giedrius.
On Thu, Dec 29, 2016 at 7:53 AM, Clemens Ladisch clemens@ladisch.de wrote:
Giedrius Trainavičius wrote:
It uses I2S for sending / receiving audio. However, the master clock on
our
sound card is generated by the ADC, which supports only 24 bit data, so getting other sample formats is not possible.
The I2S sample format need not be the same as what the DMA controller reads/writes from/to memory.
A question on 'plug' - it accepts 'nearest' as the argument for format, rate, what happens in case the slave pcm stream supports the exact same format as requested by user software?
The plug plugin instantiates the actual conversion plugins only as needed; with no conversion, it vanishes entirely.
Regards, Clemens
Giedrius Trainavičius wrote:
The I2S and DMA format asymmetry sounds like what I'd be after. Do you have any pointers for APIs / keywords to look around for in the code to see how this should be set up?
This is typically done in the hw_params callback.
Is such format conversion supposed to be happening in hardware itself
Yes; see figure 8-1:
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM28...
Regards, Clemens
Great! I managed to get 16 bit output to work just fine! Thank you!
After investigating related code and the PCM registers documentation, turned out all I had to do was to call:
snd_soc_dai_set_bclk_ratio(dai, 32*2); // 32 bits for each of 2 channels
I've seen this method before, but its use / meaning wasn't obvious at first...
However, recording using ADC generating 64 bit frames, 24 bit samples, didn't work as expected when using 16bits... (it was producing noise mostly in one channel, and less noise in the other) I haven't yet investigated why, but will do.
Any way I can provide different sample format constraints for playback and capture? (until 16 bit recording issue is resolved)
Thank you, Giedrius.
participants (2)
-
Clemens Ladisch
-
Giedrius Trainavičius