This driver is written for a custome board which has 4 cascaded AD73322s,but since there is a macro(NUM_DEVICES_CHAIN)to decide how many DAC/ADC pairs are connected,so it should be a generic driver for AD73322.
To add support for the AD73322 to the kernel build system, a few things must be enabled properly for things to work. The configuration is as following:
Linux Kernel Configuration Sound ---> [*] Sound card support Advanced Linux Sound Architecture ---> [ ] OSS Sequencer API [*] OSS Mixer API [*] OSS PCM (digital audio) API ALSA Blackfin devices ---> <*> Cascaded AD73322 Audio support for BF53x (2) Blackfin Audio SPORT port (10) PF pin for AD73322 Chip Select on SPORT0 (14) PF pin for AD73322 Chip Select on SPORT1 (12) PF pin for AD73322 Chip Reset
If audio is configured as modules, skip this section. If audio is built into kernel and you have booted the kernel, you need to check if audio is working: Check the boot messages to see if you have booted the correct kernel. During kernel booting, it should print out message like this(There are two cards on both SPORT0 and SPORT1 in this case):
Advanced Linux Sound Architecture Driver Version 1.0.18rc3. dma_alloc_init: dma_page @ 0x032e6000 - 512 pages at 0x03e00000 ALSA device list: #0: Analog Devices AD73322 at PF10 SPORT0 rx/tx dma 3/4 err irq 45 #1: Analog Devices AD73322 at PF14 SPORT1 rx/tx dma 5/6 err irq 46
Configure file:
Since AD73322 card has at least two pairs of ADC/DAC(also called input/output devices, and index of device is mapped to index of ADC/DAC in cascade mode),a configure file is needed to make full use of all these devices,otherwise only the first pair of ADC/DAC of card 0 can be used as default devices.An example of the config file is as following,it should be copy to /etc/asound.conf
#Copy this file as /etc/asound.conf to use device "plughw:x,y". #x:index of card, from 0 to 1 for two cards case; y:index of device,from 0 to 7 for 4 AD73322s on each card case. pcm.!plughw { @args [ CARD DEV SUBDEV ] @args.CARD { type string default { @func getenv vars [ ALSA_PCM_CARD ALSA_CARD ] default { @func refer name defaults.pcm.card } } } @args.DEV { type integer default { @func igetenv vars [ ALSA_PCM_DEVICE ] default { @func refer name defaults.pcm.device } } } @args.SUBDEV { type integer default { @func refer name defaults.pcm.subdevice } } type plug slave.pcm { type mmap_emul slave.pcm { type hw card $CARD device $DEV subdevice $SUBDEV } } }
Usage example:
Supposing that there are two cards on both two SPORTS,one is card 0,the other is card 1. And each cards has 8 input and 8 output devices(4 AD73322). Example for running record and playback at the same time: root:/> arecord -D plughw:0,0|aplay -D plughw:0,0 Recording from card 0 device 0 and playbacking to card 0 device 0. Card 0 device 0 also called default device,so, command as above is equal to: root:/> arecord|aplay root:/> arecord -D plughw:0,4|aplay -D plughw:1,0 Recording from card 0 device 4 and playbacking to card 1 device 0. Example for running playback/record only root:/> arecord -D plughw:0,1 -d 5 a.wav root:/> aplay -D plughw:0,1 a.wav
As mentioned above this driver is written for a customer board( with 4 cascaded AD73322 on it),and there are wrong mappings between the input Jacks and and input data lines on the board,so a function named get_cap_slotindex is implemented to correct it.Normally,it is not necessary and just get the slot_index by NUM_DEVICE_CHAN-(index+1),please refer to playback side functions.Also please feel free to tell the author if you find that something need be changed for your card,Since we want it to be more generic.