[LAD] PCM Troubleshooting Questions

Clemens Ladisch clemens at ladisch.de
Mon Nov 1 09:00:59 UTC 2010

Rory Filer wrote:
> I've run out of ideas for things to try at the bottom end and now I
> want to make sure my top-end components are working properly. This is
> weird because I've stopped being able to hear anything lately, but a
> scope confirms my I2S lines are all lit up.

And what exactly did you change that made it stop working at all?

> 1) The CPU supports a packed mode write to the Synchronous Serial Port
> (SSP) FIFO, meaning that two 16 bit samples (one left channel and one
> right) can be written at the same time, both being packed into a
> single 32 bit FIFO write. My driver enables this mode, but my question
> is, where in the kernel would the samples be combined into a 32 bit
> chunk for writing?

There is a ring buffer in memory that is written to by the application
and read from by the device (in your case, the device is the CPU's SSP
DMA controller).  In the ideal case, the kernel never touches the data.

> 2) Are their any useful tools out there for debugging/narrowing down
> where problems in the audio path might lie? My player is an embedded
> platform and I've only ported Squeezeslave to it, but for all I know
> there could be a problem anywhere from SqueezeServer, through
> Squeezeslave, down into the stack, my PCM driver or even the FM
> transmitter.

To rule out most problems above the driver, use "aplay -D hw
something.wav" (where the wav file must have a format supported by
the hardware).

> 3) My experience with Linux and audio is just beginning and so far
> it's been right down at the driver level, so a question about audio
> playing software: when a player produces a PCM stream from, say, an
> MP3 file, does it automatically interleave the left channel and right
> channel or does it produce two separate streams, one for left and one
> for right?

ALSA supports (and automatically converts between) both formats, but
practically every hardware uses interleaved samples, so this is what
practically every software produces.

> 4) For those of you experienced with I2S and other PCM formats, what
> would a Normal I2S stream sound like on a DAC that thought it was
> receiving Justified I2S? Would the audio still be intelligible or
> would you hear nothing at all?

There is no "justified I²S" format.  The three most common formats are
I²S, left-justified, and right-justified.

Nobody in their right mind uses right-justified, because this format
must also be configured for the right sample bit width.  (But then I
don't know how many hardware designers actually are in their right

Left-justified starts the left/right sample at the rising/falling edge
of the LR clock; I²S starts the left/right sample one bit clock after
the falling/rising edge of the LR clock.  This means that when the codec
and the controller are configured for different formats, the samples are
shifted one bit left or right (i.e., the MSB/LSB of one sample is
interpreted as the LSB/MSB of another sample), and left/right channels
are exchanged.

Try playing a stereo file with silence in one channel.


More information about the Linux-audio-dev mailing list