2010-08-03 12:14:18     ALSA Driver for AD73322 (3-cascaded chips) on BF537

Document created by Aaronwu Employee on Aug 22, 2013
Version 1Show Document
  • View in full screen mode

2010-08-03 12:14:18     ALSA Driver for AD73322 (3-cascaded chips) on BF537

Steven Vacca (UNITED STATES)

Message: 92111   

 

Using the BF537 and 3 cascaded AD73322 CODEC chips (6 devices),

I want to use ALSA to play audio to 6 DAC outputs, and receive audio into 6 ADC inputs

(for software filtering and subsequent playing to the DAC outputs).

 

I need direction regarding configuration, setup, and implementation.

 

I have selected in the config:

 

    --- Advanced Linux Sound Architecture

    [*] SPI sound devices  --->

        ALSA Blackfin devices  --->

        <*> Cascaded AD73322 Audio support for BF53x

        (0)   Blackfin Audio SPORT port

        (9)   PF pin for AD73322 Chip Select on SPORT 0

        (14)  PF pin for AD73322 Chip Reset

 

My NUM_DEVICE_CHAN is set = 6. (Is there still a problem working with 6 devices (3 chips)?)

 

During bootup I get:

 

...

Advanced Linux Sound Architecture Driver Version 1.0.18rc3.

dma_alloc_init: dma_page @ 0x01028000 - 256 pages at 0x01f00000

ALSA device list:

  #0: Analog Devices AD73322 at PF9 SPORT0,rx/tx dma ch:3/4,err irq:45

...

 

I have copied the file AD73322.asound.conf to /etc/asound.conf

 

 

What do I need to do to get to the point of being able to execute:

 

    aplay -D plughw:0,2 a.wav

  

How do I get the 6 devices to become exposed for application under /dev/snd?

 

In fact, how do I get access to the executables aplay and arecord?

 

 

Thanks.

QuoteReplyEditDelete

 

 

2010-08-03 12:58:37     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Mike Frysinger (UNITED STATES)

Message: 92114   

 

what version of software exactly are you using (dist/toolchain/etc...) ?

 

what exactly is under /dev/snd/ now ?

QuoteReplyEditDelete

 

 

2010-08-03 14:35:16     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Steven Vacca (UNITED STATES)

Message: 92123   

 

The  distribution  uClinux-dist-2.6.28.10-ADI-2009R1-pre-svn6340.  The toolchain was downloaded at the same time - not sure of exact version.

 

There is no /dev/snd currently. Haven't gotten that far.

 

I'm assuming I need to compile the alsa-lib.  Currently the Blackfin Build Options->Binary Format is set for FLAT.  Should that be changed to FDPIC?   If so, then should I also enable "Build ALSA lib"?

QuoteReplyEditDelete

 

 

2010-08-03 14:41:19     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Mike Frysinger (UNITED STATES)

Message: 92124   

 

yes, you'll need to use FDPIC if you want to use ALSA

QuoteReplyEditDelete

 

 

2010-08-18 12:35:37     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Steven Vacca (UNITED STATES)

Message: 92558   

 

I am using 6 devices (3 chips cascaded), but am having trouble getting any sound out.

I am using aplay to send the bhc.wav file for testing:

 

    aplay -D plughw:0,0 bhc.wav

 

I have the necessary short across the first chip’s SDIFS and the 3rd chip’s SDOFS

for the "Directly-Coupled" configuration between the BF537 and the 3 AD73322 chips..

 

When using the original, unmodifed ad73322.c file, all of the signals

(SDI/SDO,SDFIS,SDOFS,SCLK,SE) look good and proper.

 

But, after adding the modifications per the patch, ad73322.patch, that Cliff Cai

attached in the thread

 

  blackfin.uclinux.org/gf/project/uclinux-dist/forum/?_forum_action=ForumMessageBrowse&thread_id=34595&action=ForumBrowse

 

the SDI/SDO signals are no longer continuous streams, but pulsed streams at about

once per sec.

 

 

I have added the mods listed in the thread's attached file, ad73322.patch, to ad73322.c.

I also added these additional mods to ad73322.c:

 

(1) Changed:

 

    #define DMA_PERIOD_BYTES FRAGMENT_SIZE_MIN*4

 

    to

 

    #define DMA_PERIOD_BYTES 3*4

 

 

 

(2) Changed previous get_cap_slotindex() to:

 

static inline int  get_cap_slotindex(int index)

{

  int  slot_index;

 

 

  slot_index = (NUM_DEVICES_CHAIN-(index+1));

  return(slot_index);

}

 

 

 

I added these mods to ad73322.h:

 

(3) Changed:

 

    #define NUM_DEVICES_CHAIN    8

  

    to

  

    #define NUM_DEVICES_CHAIN    6

  

 

(4) In typedef struct snd_ad73322, changed:

 

    substream_info_t  tx_substreams[8];

    substream_info_t  rx_substreams[8];

  

    to

 

    substream_info_t  tx_substreams[NUM_DEVICES_CHAIN];

    substream_info_t  rx_substreams[NUM_DEVICES_CHAIN];

 

Is there anything else I need to modify?

QuoteReplyEditDelete

 

 

2010-08-19 05:23:54     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Bob Liu (CHINA)

Message: 92576   

 

Hi, Steven

 

What about the two results:

 

1. Just use the original, unmodifed ad73322.c file.

 

2. Just change the NUM_DEVICES_CHAIN to 6 in function snd_ad73322_configure().

 

I am sorry but I have no env to test 3 chips cascaded device.

 

Thanks

 

-Bob

QuoteReplyEditDelete

 

 

2010-08-19 11:19:37     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Steven Vacca (UNITED STATES)

Message: 92588   

 

This, "#define DMA_PERIOD_BYTES 3*4", mentioned above, was an error.

I changed it so my settings are now:

 

    #define AD73322_BUF_SZ    0x30000

    #define PCM_BUFFER_MAX    0x10000

    #define FRAGMENT_SIZE_MIN 1440        //12*120. For 8 devices was 1024.

 

    //This makes "#define DMA_PERIOD_BYTES  FRAGMENT_SIZE_MIN*4" evenly divisible by 12.

 

When I do "aplay -D plughw:0,0 bhc.wav", the signals appear continuous to the 1st

chips SDI input, and the SDIFS/SDOFS signals are pulsed approx. every 8 us (actually

2 pulses 8 us apart, then 11 us, then 2 more pulses 8 us apart, etc.)

 

After about 6 secs of gettings signals, but no sound, these printk()'s are

continuously printed:

 

  sport status error: TUVF

  snd_ad73322_sport_err: error happened on sport

QuoteReplyEditDelete

 

 

2010-08-19 22:11:59     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Bob Liu (CHINA)

Message: 92597   

 

Hi, Steven

 

There may be other unknown problem.

 

So would you please test it with:

 

1. Just use the original, unmodifed ad73322.c file. This will just leave two fake 6,7 PCM devices.

 

2. Just change the NUM_DEVICES_CHAIN to 6 in function snd_ad73322_configure().

 

These tests  don't change the buffer  size.

QuoteReplyEditDelete

 

 

2010-08-20 09:45:37     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Steven Vacca (UNITED STATES)

Message: 92640   

 

Ok, I'll test with that, and see what I get,  Thanks.

QuoteReplyEditDelete

 

 

2010-08-20 12:07:33     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Steven Vacca (UNITED STATES)

Message: 92643   

 

Bob, wouldn't it still be necessary to make the mod to get_cap_slotindex()  (as below)?

 

static inline int  get_cap_slotindex(int index)

{

  int  slot_index;

 

 

  slot_index = (NUM_DEVICES_CHAIN-(index+1));

  return(slot_index);

}

QuoteReplyEditDelete

 

 

2010-08-20 14:22:52     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Steven Vacca (UNITED STATES)

Message: 92650   

 

I set ad73322.c back to the original, unmodified version, except I changed

get_cap_slotindex() to return (NUM_DEVICES_CHAIN-(index+1)). I set NUM_DEVICES_CHAIN to 8.

I ran this on a unit that has only 1 ad73322 chip (2 devices).

I was able to execute  (aplay -D plughw:0,0 bhc.wav)  to channel 0, playing audio.

To record audio, I had to record on channel 6  (arecord -D plughw:0,6 -d 10 a1.wav)

instead of channel 0, for some reason, It did record audio that I could play back.

 

But, when I go back to my unit that has 3 ad73322 chips (6 devices), it doesn't matter if I

set NUM_DEVICES_CHAIN = 8, or 6, I still get no audio.  But, the signals on SDI/SDO

and SDIFS/SDOFS look great, and are present for the duration of the bhc.wav file play time.

 

Could this be due to the misalignment issue?

QuoteReplyEditDelete

 

 

2010-08-23 11:30:17     Re: ALSA Driver for AD73322 (3-cascaded chips) on BF537

Steven Vacca (UNITED STATES)

Message: 92695   

 

Success!!!

 

The only changes I have made to the original ad73322.c/.h files are:

 

- I have NUM_DEVICES_CHAIN set = 8 for all occurrences, though I'm actually only

  using 3 chips (6 devices).

 

- I have the get_cap_slotindex() changed to:

 

static inline int  get_cap_slotindex(int index)

{

  int  slot_index;

 

  slot_index = (NUM_DEVICES_CHAIN-(index+1));

  return(slot_index);

}

 

 

I am now getting audio out of the 6 channels on the 3-chip setup. I can aplay the  .wav  file

to channels 0 - 5, specifying 0,0, 0,1, 0,2, 0,3, 0,4, or 0,5.  For arecord, I record on

channel 2 to record audio on the 1st input of the 1st cascaded chip. So recording on the

6 inputs would mean specifying 0,2, 0,3, 0,4, 0,5, 0,6, or 0,7. The recorded audio sound great.

 

Thanks for the valuable help!

Attachments

    Outcomes