[alsa-devel] [uclinux-dist-devel] [PATCH 1/4] Blackfin: Use 8bit spi transfers for the ad1836

Lars-Peter Clausen lars at metafoo.de
Fri May 6 15:19:51 CEST 2011

On 05/06/2011 02:48 PM, Mark Brown wrote:
> On Fri, May 06, 2011 at 02:28:32PM +0200, Lars-Peter Clausen wrote:
>> The snd_soc_cache infrastructure has several helper functions for writing spi
>> on a spi bus. The one used by the ad1836 was specifically added for the ad1836
>> and is special compared to the other spi helper functions in the regard that it
>> swaps the upper and the lower byte of the to be transferred data.
>> While this works on blackfin which is litte-endian this scheme will obviously
>> fail on big-endian machines. Also this might not work for other codecs which
>> want to reuse the same helper function.
> So clearly the cache stuff ought to be using cpu_to_be16 for this stuff.
> At present we've been lazy about this as on most CPUs the swap boils
> down to a noop.  If we do end up needing both swaps then we just add
> this as another parameter in the cache infrastructure.

Currently everything is stored as big endian.
The easiest way to support 16-bit spi writes on little endian systems, would be
to add a do_spi_write16 which would be used for those devices. On big-endian
systems it would be an alias to do_spi_write, on litte-endian systems it would
perform a byte swap on the buffer.

An alternative would be to provide litte-endian versions of snd_soc_x_y_write.
This would amount to more code, but less runtime overhead since we can store it
in litte-endian format right away instead of having to swap the bytes.

- Lars

More information about the Alsa-devel mailing list