Subject: Re: mulaw.c & endianness
To: Eduardo E. Horvath <eeh@one-o.com>
From: Leo Weppelman <leo@wau.mis.ah.nl>
List: tech-kern
Date: 11/01/1999 21:53:36
On Mon, Nov 01, 1999 at 09:07:06AM -0800, Eduardo E. Horvath wrote:

> > The functions in question:
> > 	mulaw_to_[us]linear16() and alaw_to_[us]linear16().
> 
> I presume you mean that these functions do conversions to little
> endian format if needed?

Currently, they do conversion to the endianness of the CPU, dependant
on the compile time BYTE_ORDER define. This is wrong.

[ solution methods ]
> > It depends on how much chance there is on drivers wanting big-endian versions
> > of these functions. This is something that I really don't know...
> 
> That depends on whether these chipsets are available on cards that
> attach to big endian buses.  I am aware of several chips that are,
> most notably the ISPs are available on SBus and PCI.  

Yes, this is true. 

> The other thing to keep in mind is that one machine may have several
> buses.  It is quite possible today to have a machine with a Qlogic ISP
> on both an SBus card and PCI bus.  In fact I think I may have one
> lying around somewhere at work.  This means that the endianness and
> byte flipping would need to be set differently for each device
> instance.

I think the conversion is dependent on the endianness of the bus, the
requirements of the card and the way the data is transferred to the
card. Examples (Assuming big-endian CPU and pci-audio):
     Bus      transfer method          endian-type

    PCI-bus     DMA                   little-endian
    PCI-bus     bus_space_stream_2    little-endian
    PCI-bus     bus_space_write_2     big-endian

Leo.