world leader in high performance signal processing
Trace: » ad1836

Adding Audio to the Kernel (AD1836A)

Adding Kernel Support - As a module

To add support for the AD1836A audio card to the kernel build system, a few things must be enabled properly for things to work.

 Linux Kernel Configuration 
    Sound  ---> 
      [M] Sound card support
       Advanced Linux Sound Architecture  --->
        [ ] OSS Sequencer API
        [M] OSS Mixer API 
        [M] OSS PCM (digital audio) API
        <M> ALSA for SoC audio support  --->
           <M>   SoC I2S(TDM mode) Audio for the ADI BF5xx chip
           <M>     SoC AD1836 Audio support for BF5xx
           (0)   Set a SPORT for Sound chip

The SPORT port number should match the SPORT which you have plugged the Audio card into, and the SPI channel selection bit should match the jumper (J5) on the card.

I2S interface is not supported on 0.9 and earlier version of AD1836 daughter card

The AD1836 has been tested with the AD1836A audio card only. It will NOT work with the AV-Extender card from ADI

Doing this will create modules (outside the kernel). The modules will be inserted automatically when it is needed. You can also build sound driver into kernel.

Testing the built in kernel driver

If audio is configured as modules, skip this section. If audio is built into kernel and you have booted the kernel, there are a few things to check to ensure audio is working:

  1. Check the boot messages to see if you have booted the correct kernel. During kernel boot, it should print out:
    Advanced Linux Sound Architecture Driver Version 1.0.9rc2  (Thu Mar 24 10:33:39 2005 UTC).
    dma_alloc_init: dma_page @ 0x03a79000 - 256 pages at 0x03f00000
    ALSA device list:
      #0: Analog Devices AD1836A at SPI irq 17/47, SPORT0 rx/tx dma 3/4 err irq /45
  2. Check to make sure that the audio device is compiled into your kernel. If the special directory /proc/asound/AD1836A/ is in the root filesystem, the audio driver is compiled in.
    root:~> ls -l /proc/asound/AD1836A/
    -r--r--r--    1 0        0               0 id
    -rw-r--r--    1 0        0               0 oss_mixer
    dr-xr-xr-x    3 0        0               0 pcm0c
    dr-xr-xr-x    3 0        0               0 pcm0p
    -rw-r--r--    1 0        0               0 registers
    -r--r--r--    1 0        0               0 spi
    -r--r--r--    1 0        0               0 sport
    -rw-r--r--    1 0        0               0 talktrough

Testing the audio module

root:~> modprobe snd-ad1836
root:~> modprobe snd-pcm-oss
root:~> lsmod
Module                  Size  Used by
snd_pcm_oss            31952  0
snd_mixer_oss          11436  1 snd_pcm_oss
snd_ad1836             14876  0
snd_pcm                49628  2 snd_pcm_oss,snd_ad1836
snd_timer              13644  1 snd_pcm
snd_page_alloc          3940  1 snd_pcm
snd                    32032  5 snd_pcm_oss,snd_mixer_oss,snd_ad1836,snd_pcm,snd_timer
soundcore               4032  1 snd
root:~> tone
TONE: generating sine wave at 1000 Hz...

Testing Audio

  1. Check the output
    root:~> tone
    TONE: generating sine wave at 1000 Hz...

    You should hear something out of the green jack. NOTE: The tone application seems to be broken. (plays at the wrong frequency, and doesn't produce the waveshape you ask it.

  2. Set the audio mixer to Microphone(default input is Line) :

By default,Line and Mic can work at the same time for multi-channel captures(Line for 2 channel captures,Line and Mic together for 4 channel captures),if you make the codec work in 5.1 channel mode.but once you've run “mixer +rec mic/line”,then Line and Mic will be mutually exclusive.

root:~> mixer +rec mic
Recording source: mic
  1. Check to make sure mp3s work (assuming you have built mp3play),
    1. The first step is to download a mp3 file onto the platform. The wget command assumes that networking is properly configured (you have an IP number, the default gateway is set, and DNS servers can be accessed), and working. See the network setup page for more info.
      root:/> cd /var
      root:/var> wget http://www.radiocrazy.com/shows/A/AbbottCostello/ABCOWhosOnFirstclip.mp3
    2. Next, play it with mp3play:
      root:/var> mp3play ABCOWhosOnFirstclip.mp3
  2. You can play it in one step with:
    root:~> mp3play http://www.radiocrazy.com/shows/A/AbbottCostello/ABCOWhosOnFirstclip.mp3
    http://www.radiocrazy.com/shows/A/AbbottCostello/ABCOWhosOnFirstclip.mp3: MPEG2-III (0 ms)
  3. Play two mp3 files at the same time. When running “make menuconfig”, if the 3 seperate stereos option is selected, two mp3 files can be played at the same time.
    root: /var> mp3play ABCOWhosOnFirstclip.mp3 &
    root: /var> mp3play ABCOWhosOnFirstclip.mp3

    You can hear the song from both the green jack and black jack. The two songs don't need to be the same. The first song is always output to the green jack. The second song is always output to the black jack.

  4. Optionally check to make sure the mic and headphones are working properly:
    root:~> mixer +rec mic
    Recording source: mic
    root:~> vrec -w -t 10 test.wav
    Recording VOC : Speed 8000 Hz Mono ...
    root:~> vplay test.wav
    Playing Creative Labs Voice file ...

    This should record 10 seconds of whatever is on the MIC, and then play it back over the output.

  5. You should also be able to do a “talkthrough”, and hear on the speakers anything you say on the mic.
    root:~> vrec -w | vplay
  6. You can make the codec work in 5.1 channel mode by selecting 5.1 channels mode when configure codec driver.
    5.1 Channels or 3 Separate Stereos (5.1 Channels)  ---> 
    
    root:~>aplay -c 6 6chan.wav
    

Debugging

Most of the time, and issues we have seen have been tracked down to proper jumper settings, which are detailed on how to set up your AD1836A audio card section.