[alsa-devel] force byte-swap at soc level before codec?

Mark Brown broonie at opensource.wolfsonmicro.com
Sat May 23 12:43:57 CEST 2009

On Sat, May 23, 2009 at 06:28:41AM -0400, Brad Parker wrote:

> The codec claims S16_LE.  The i2s layer claims S16_LE as does the pcm

A change has been merged for 2.6.31 which makes CODEC drivers match
against either endianess in order to support this use case, though
obviously the 2.6.31 release won't happen for a while.

> layer inside soc.  The source data in user land is S16_LE.  But when the
> i2s hardware (which I can't change) does dma the bytes go to the codec
> in reverse order.

> So, I need a byte swap somewhere.  I verified this by sending constant
> data from user land via the oss compat layer (i.e. /dev/dsp).  If I swap
> them in userland they come out on the scope at the codec in the correct
> order.

> Any know the simplest way to do this?

> I've tried a bunch of ways but nothing seems to work correctly. It seems like
> ALSA already handles this as long as I tell the right thing from below.

Yes, if your driver tells userspace the format it needs then things
should've been figured out by the time the driver sees the data.  Change
your CPU drivers to advertise _BE variants instead and either change the
CODEC driver locally to do the same thing or run with the latest ASoC
code which will make the change for you.  The ASoC core will pass on the
common constraints that the individual drivers advertise to userspace.

More information about the Alsa-devel mailing list