cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sharknado
Visitor
Visitor
348 Views
Registered: ‎04-26-2021

ALSA Codec Volume Control with distinct Xilinx PL Sound Card (Audio Formatter -> I2S cores) and Codec

Greetings Xilinx users and mods,

I have been tasked with developing sound functionality (Playback only!) for an embedded Linux device. The three blocks at play in this audio path are:

1) Xilinx audio formatter core

2) Xilinx I2S transmitter core

3) TI PCM1681 DAC

I currently have a functional Xilinx PL Sound Card and can play .wav files using ALSA utils' aplay command. Now I would like to provide high-level, user-space volume control via ALSA tapping into the DAC digital attenuation control. The complexity lies in the fpga "middle-man" components, which provide the means to transmit audio but not - AFAIK - configure the actual codec being streamed to!

 

What I have working:

  • streaming of .wav files through the Xilinx cores and into the PCM1681
  • volume control via direct I2C register writes. This is an undesirable interface for the user-space application.

 

Attempted solutions:

Replace Dummy-DAC DAI component of Xilinx PL Card

sharknado_0-1620320734379.png

sharknado_5-1620320960342.png

sharknado_1-1620320739909.png

The Xilinx card bails here, so we are without sound card. Maybe I'm using the wrong names in the COMP_CODEC macro?

 

ALSA simple-audio-card device tree shenanigans

I thought producing a simple card with a dummy node might give me volume control, but I can't get such a card to come up.

sharknado_2-1620320749289.png

sharknado_4-1620320838737.png

sharknado_3-1620320785776.png

 

Are either of the approaches I listed above valid? If not, is there any way to simply give ALSA control of the codec volume? Any help is much appreciated!

 

 

 

 

2 Replies
melofelossa
Observer
Observer
315 Views
Registered: ‎03-18-2021

Hello!

I suggest you to not use the ASoC simple card soundcard driver. I struggled alot with it and at the end I still couldn't make it work with the Xilinx IP cores and drivers (Audio_Formatter, I2S Rx/Tx).
I contacted Kuninori Morimoto, the author of simple-card.c, and Alexandre Belloni from Bootlin. They gave me suggestions on how I could make it work but I still wasn't able to make it work. 
At the moment it seems like the Xilinx drivers are incompatible with simple-card. But thats just a tought. You could take a look at the sourcecode to tell if they should be able to work together.
I conntacted the Xilinx support and they suggested me to use the Xilinx PL Soundcard driver. After that the support answered to my forum post to make the information public:
Solved: Re: Is the ASoC Simple-Card driver compatible with... - Community Forums (xilinx.com)
However, the Xilinx Soundcard is not as good as the Simple-Card driver because you have to be capable of linux device driver development. Also this is a much more time consuming task in comparison to just write a device tree node.

I found a guy who wrote a working Xilinx PL soundcard. Here is the link to his projekt: 
Linux device driver for Zedboard audio (2/2) | by Yuhei Horibe | Medium
Here is the link to his soundcard .c file
zedboard_audio.c · GitHub

Note that he didn't use the 18,xx MHz dyamic MCLK which you SHOULD use. He decided to use a fixed MCLK with another fequency. Because of this he faced some problems which he mentioned at the end of his post.

Hope this helps!

sharknado
Visitor
Visitor
294 Views
Registered: ‎04-26-2021

Thanks for the reply! I am checking out that resource now.

That post of yours is helpful for noting that the Xilinx PL and simple-audio cards are incompatible. That confirms what I have come to suspect. In light of that, the two approaches which I outlined in the original post may still be plausible solutions. Hopefully there is a way to replace that dummy codec component in the driver with the actual codec i2c component; it would be disappointing if the Xilinx PL soundcard cannot directly adjust controls, and that is the only way I see to do it. Maybe I just have the wrong names for my codec, but that is what appears in it's driver.

 

Thanks again for the response!