[maemo-developers] ALSA sound driver for Nokia 770 and DSP programming

From: Siarhei Siamashka siarhei.siamashka at gmail.com
Date: Thu Sep 25 22:07:52 EEST 2008
Hi,

As has been discovered long ago [1] but eventually forgotten, Nokia 770 has
AIC23 audio hardware [2] which can be used not only from DSP side, but
from ARM as well. Moreover, OS2006 kernel sources even contain an ARM driver
for it, but this driver is disabled (that's understandable as the driver is
not in a very good shape and has quite a number of bugs).

Recently I have been trying to make it running and seems like we have a very
good chance to have it working nicely. It is also interesting, that the
linux-omap guys seem to be developing a new driver [3] for AIC23 which may
eventually become a better alternative.

Kernel patch is attached. It enables AIC32 driver, adds a hack to
power on/off code so that audio codec is permanently powered on (power 
on/off code is not reliable and needs to be reworked). Also it fixes a 
problem with audio stuttering on video playback in mplayer (the driver
had broken position reporting which is critical for proper audio/video
synchronization).

Here is some usage instruction (beware that standard disclaimer applies: 
you can use this patch at your own risk, this code is quite untested. If it
somehow manages to fry your device, you have been warned and I'm not
responsible for any breakages):

1. Disable esd daemon and DSP stuff in order to move it out of the way
(temporarily rename '/usr/bin/esd' and '/usr/sbin/dsp_dld' to something else)
2. Apply the attached patch to OS2006 kernel, compile and flash it to the
device
3. Compile and install alsa userspace library, I used alsa-lib-1.0.11.tar.bz2
4. Put attached 'asound.conf' into '/etc' directory on the device, it enables
dmix plugin for audio mixing and resampling
5. Compile and try some applications which use ALSA, I tested 'aplay' 
and 'mplayer'

The driver is semi-usable now, but a lot still needs to be done:
* proper power management to avoid excessive battery drain
* audio volume control
* switch between speaker/headphone
* audio quality is a bit crappy now, this needs to be fixed
* maybe some more fixes for bugs that are yet to be discovered...

DMA code is quite suspicious (especially the way it does channels linking) and
might be responsible for audio quality issues. Also sofware mixing/resampling
code in dmix plugin can benefit from ARM optimizations.


Now regarding why we may want it. Once if we get a good, low latency, fully
functional and reliable ALSA sound driver running on ARM, it gives maemo 
community a nice possibility to scrap all the proprietary DSP binaries. This
provides us with a new and shiny 252MHz C55x DSP core ready to be used by
something else :)

Free linux DSP toolchain from TI [4] supports generation of both DSP kernel
and DSP tasks for OMAP1 based devices which is sufficient for DSP development.
The toolchain license was supposed to permit open source development (with
noncommercial restriction), though the license text itself is a bit
questionable [5].

With DSP avalable for use and having no need to spend efforts on ensuring
compatibility and peaceful coexistence with proprietary binary codecs (free
and proprietary code does not mix well), it should be possible to turn 
Nokia 770 into quite a powerful media player.


1. http://lists.maemo.org/pipermail/maemo-developers/2006-June/022231.html
2. http://focus.ti.com/docs/prod/folders/print/tlv320aic23b.html
3. http://thread.gmane.org/gmane.linux.ports.arm.omap/11700/focus=11709
4. 
https://www-a.ti.com/downloads/sds_support/targetcontent/LinuxDspTools/index.html
5. http://www.gossamer-threads.com/lists/maemo/developers/30611

-- 
Best regards,
Siarhei Siamashka
-------------- next part --------------
A non-text attachment was scrubbed...
Name: n770-alsa-aic23-experimental-fix.diff
Type: text/x-diff
Size: 4908 bytes
Desc: not available
Url : http://lists.maemo.org/pipermail/maemo-developers/attachments/20080925/bc306c4c/attachment.diff 
-------------- next part --------------
pcm.dmixer {
    type dmix
    ipc_key 321456
    ipc_key_add_uid true
    slave {
        pcm "hw:0"
    }
}
pcm.!default {
    type plug
    slave.pcm "dmixer"
}
More information about the maemo-developers mailing list