Onboard audio support and DBDMA API extensions.

Marco Trillo marcotrillo at gmail.com
Fri Sep 26 18:17:27 UTC 2008


Hi,

I'm working in a pcm(4) driver for the Apple onboard audio. The
current status is that audio output works on my machine using a
default volume, but volume changing is not supported yet.

In more detail, what I have is support for audio output using the
I2S-based mac-io audio controller (which is the one used on most
new-world Apple machines), using DBDMA to transfer the audio. Support
for the older, DAVbus-based controllers should be easy too since the
DBDMA stuff is mostly the same. I would like to propose two extensions
for the DBDMA API, detailed below.

I also have preliminary support for the GPIO controls, which are used
mainly to select the output port (built-in speakers or headphones).
What I have yet to do is to support the mixer(4) interface (to support
changing the output volume), which needs support for the Keywest I2C
controller in order to talk to the codec. I have in fact ported a
Keywest I2C driver from NetBSD, but I don't use it much yet.

Some dmesg output of the driver with debugging enabled:

macio0: <Intrepid I/O Controller> mem 0x80000000-0x8007ffff at device
23.0 on pci1
pcm0: <Apple I2S audio controller> mem
0x10000-0x10fff,0x8000-0x80ff,0x8100-0x81ff,0x8200-0x82ff,0x8300-0x83ff
irq 30,1,2,31,3,4 on macio0
interrupting at irq 1
pcm0: [ITHREAD]
GPIO <headphone-mute>: addr 0x6f
GPIO <amp-mute>: addr 0x70
GPIO <audio-hw-reset>: addr 0x75
GPIO <headphone-detect>: addr 0x67
enabled outputs: SPEAKER
resetting codec
pcm_getbuffersize returned 65536
aoa_dma_setprd: addr = 31391744, 32 slots
aoa_chan_setformat: format = 268435488
aoa_chan_setspeed: speed = 44100
aoa_chan_setformat: format = 268435488
aoa_chan_setblocksize: blocksz = 2048, dma->blksz = 2048
aoa_chan_setspeed: speed = 44100
aoa_chan_setformat: format = 268435488
aoa_chan_setblocksize: blocksz = 2048, dma->blksz = 2048
aoa_chan_setblocksize: blocksz = 2048, dma->blksz = 2048
aoa_chan_setspeed: speed = 44100
aoa_chan_setformat: format = 268435488
aoa_chan_setblocksize: blocksz = 2048, dma->blksz = 2048
kiic0: <Keywest I2C controller> mem 0x18000-0x18fff irq 26 on macio0


$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2007061600/powerpc)
Installed devices:
pcm0: <Apple I2S audio controller> at irq 1 [GIANT] (1p:1v/0r:0v
channels default)

Playing an audio file (in this case using the "aifftools" utilities):

$ cd dl/aiff/aifftools/aifftools
$ ./aiffopen 1\ Kyrie.aiff
=> Reading '1 Kyrie.aiff'...

   +---------------------------------+
   |          1 Kyrie.aiff           |
   +----------------+----------------+
   |         Author:|       <unknown>|
   +----------------+----------------+
   |         Length:|         0:07:08|
   +----------------+----------------+
   |  Sampling rate:|      44.100 kHz|
   +----------------+----------------+
   |       Channels:|          Stereo|
   +----------------+----------------+
   |     Resolution:|          16 bps|
   +----------------+----------------+
   |        Bitrate:|       1411 kbps|
   +----------------+----------------+



=> oss: Open Sound System (OSS)
=> Start playing
  [0:00:38]^C
=> Aborted by signal 2

The current work-in-progress version of the driver is at:
<http://www.telefonica.net/web2/marco2z/fbsd/aoa.c>.

I would like to propose the following additions to the DBDMA API,
which I'm using in the driver:

void dbdma_clear_cmd_status(dbdma_channel_t *, int slot);
Clears the cmdStatus of DBDMA command at slot 'slot'. Used for keeping
track of completed blocks.

void dbdma_control(dbdma_channel_t *, uint8_t mask, uint8_t in);
General-purpose manipulation of the DBDMA channel control register.
Used for setting/clearing general-purpose control bits such as S0.

What do you think?

Thanks,
Marco.


More information about the freebsd-ppc mailing list