I am trying to understand how to write platform, codec, and machine drivers for ALSA SoC. I will be using the SSI platform driver written by Freescale, my own codec driver, and will link the two in a machine driver. I am having some trouble understanding the PCM formats given by the SNDRV_PCM_FMTBIT_* definitions and how to correctly set the PCM format field in snd_soc_dai_driver structures. I tried looking elsewhere online but unfortunately a lot of the documentation related to ALSA is either ambiguous or just non existent.
Hi Paul
* for alsa data endian definitions one can look at alsa project documentation and alsa mail lists.
ALSA project - the C library reference: Helper Functions
[alsa-devel] WM9712 - Big and little endian format conversion.
* right, data bytes and bits written in STX register use the same order
as arranged in memory. So SSI module has not special "endian" settings/conversions.
> Is this saying that if a multi-byte PCM data value is stored in big-endian in memory
>then it will be written to the STX register with the most significant byte in the lower end of the register?
in general, SSI data bit/byte order remains the same as it was arranged in memory. May be useful to look at
sect.61.8.2.1 Data Alignment Formats Supported i.MX6DQ Reference Manual
https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf
* NXP sound drivers support limited number of codecs and pcm formats. One can refer to
sect.7.1.1 ALSA Sound Driver Introduction attached Linux Manual. Full list of alsa formats can be found on
ALSA project - the C library reference: PCM Interface
* Linux SSI driver written by NXP (Freescale) does not support all alsa formats. Supported only
configurations presented in NXP reference boards. Other formats can be added by customers themselves.
Below some useful links for adding support for new formats:
ALSA is not supporting 16 bits signed audio · Issue #173 · raspberrypi/firmware · GitHub
c++ - Signed 16-bit ALSA PCM data to U8 Conversion on Linux - Stack Overflow
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Igor,
Thank you for your response. I will try to dig deeper into ALSA documentation for some answers. I would like to confirm my understanding of the SSI STX register using an example. Suppose the processor stores data in little-endian and the STX register is configured for MSB aligned 16-bit data. Suppose I want to transmit the value 0x2211. This value is stored at address N as a 32 bit value as follows:
N+0: 0x11
N+1: 0x22
N+2: 0x00
N+3: 0x00
When this value is moved into the STX register it will look like 0x00002211. However, because of the 16 bit MSB setting of the STX register, only 0x0000 is transmitted. To transmit the value correctly it would have to be stored in memory as the following 32 bit value:
N+0: 0x00
N+1: 0x00
N+2: 0x11
N+3: 0x22
When this value is moved into the STX register it will look like 0x22110000. Since the STX register is MSB aligned for 16 bit data, 0x22111 will be transmitted.
Is this correct?
Hi Paul
from sect.61.8.2.1 Data Alignment Formats Supported Reference Manual:
"With MSB alignment, the most significant byte is bits 31 through 24 of the data register
if the word length is larger than or equal to 16 bits."
so seems value 0x2211 will appear as 0x22110000 :
Best regards
igor