Subject: Re: PCI-audio & endianness (eso.c/mulaw.c)
To: Izumi Tsutsui <>
From: Leo Weppelman <>
List: tech-kern
Date: 10/27/1999 17:05:10
On Wed, Oct 27, 1999 at 11:16:52PM +0900, Izumi Tsutsui wrote:
> In <>
> wrote:
> >   2 - dev/mulaw.c
> > 
> >      Here also, endianness is taken into account. However, I can not play
> >      '.au' files when compiling for big-endian. If I compile for the little
> >      endian case, the samples play fine. Now it isn't obvious to me what
> >      is the 'correct' case here. I have absolutely no experience with
> >      audio drivers. From my observation of the eso.c file, it is clear that
> >      the sound-card uses DMA to fetch the data (== no endian conversion) and
> >      from the docs on the Hades PCI-bus it looks that there is no magic
> >      like hardware swaps involved.
> I guess most PCI bus-master devices assume the host is little endian,
> so bswap*() functions are needed on passing non-bytestream data via DMA.
> (i.e. on accessing variables allocated by bus_dmamem_alloc(9) and
>  bus_dmamem_map(9))

I really hope that 'most' turns out to be either 'all' or 'none'! Otherwise
it will get really messy. But you have a point. Because the device assumes
it has a little-endian host, it expects little endian data when doing a
DMA transfer. That would lead to the conclusion that not the endian type
of the host determines the need for byte swapping, but the way the data
is used. I.e. when the DMA-transfer had been done by a big-endian bus,
the swap was necessary. Mmmm, this means either separate functions
or adding a parameter.