ΣSigmaStudio Ask AI Русский Log in

ALSA Implementation Questions with adau1761 codec

SigmaDSP & SigmaStudio MOONG Feb 20, 2024 00:00 5 replies Original on forum ↗
Thread Summary

Thread Summary

The user encountered I2C and ALSA hw_params errors while implementing the ADAU1761 codec on a SoC using Synopsys I2C/I2S IP. The I2C issue was resolved by changing the device address from 0x70 to 0x38. However, the user is still facing issues with the firmware upload from the kernel, despite the firmware working correctly when loaded via a converter. The user asks if a custom firmware download algorithm is required in the machine driver.
AI Generated Content
Subscribe
MOONG Question
Feb 20, 2024 00:00

Below are some of the dts I wrote.
I want to implement ALSA by applying it as above, but the parts that are not applied well are as follows

1. ADAU1761 probe error occurred
: : Unable to sync register 0x4002-0x4002

2. hw_params error during aplay test
: : ASoC: can't set adau-hifi hw params: -121
: : Unable to install hw_params

3. # cat /proc/asound/card0/pcm0p/sub0/hw_params : closed

I used synopsys i2c/i2s IP on SoC Chip.

I need your help.

codec_clk: codec-clock {

#clock-cells = <0>;

compatible = "fixed-clock";

clock-frequency = <12288000>;

};

sound {

compatible ="simple-audio-card";

i2s-controller = <&i2s0>;

status = "okay";

simple-audio-card.name = "adau1761";

simple-audio-card,format = "i2s";

simple-audio-card,bitclock-master = <&dailink0_master>;

simple-audio-card,frame-master = <&dailink0_master>;

simple-audio-card,widgets =

"Headphone", "Headphones",

"Line" , "Line In",

"Line", "Line Out",

"Microphone", "Mic In";

simple-audio-card,routing =

"Headphones", "LHP",

"Headphones", "RHP",

"Line Out", "LOUT",

"Line Out", "ROUT",

"Mic In", "MICBIAS",

"LINN", "Mic In",

"RINN", "Mic In",

"LINP", "Mic In",

"RINP", "Mic In",

"LAUX", "Line In",

"RAUX", "Line In";

simple-audio-card,cpu {

status = "okay";

sound-dai = <&i2s0>;

};

dailink0_master: simple-audio-card,codec {

status = "okay";

sound-dai = <&adau1761>;

};

};

i2s: i2s@reg_addr {

compatible = "snps,designware-i2s";

reg = <0x0 reg_addr 0x0 0x4000>;

#sound-dai-cells = <0>;

clocks = <&clock CLKEN_I2S_APB>;

clock-names = "i2sclk";

dmas = <&pdma0 0>, <&pdma0 1>;

dma-names = "tx", "rx";

status = "okay";

};

i2c: i2c@reg_addr {

compatible = "snps,designware-i2c";

reg = <0x0 reg_addr 0x0 0x4000>;

#address-cells = <1>;

#size-cells = <0>;

clock-frequency = <400000>;

clock-names = "ic_clk", "pclk";

clocks = <&clock CLKEN_I2C6_CORE>, <&clock CLKEN_I2C6_APB>;

pinctrl-0 = <&pinctrl_i2c6_default>;

pinctrl-names = "default";

status = "okay";

adau1761:adau1761@70{

compatible = "adi,adau1761";

#sound-dai-cells = <0>;

reg = <0x70>;

clocks = <&codec_clk>;

clock-names = "mclk";

};

};

Thread Notes
MOONG - Moved from Linux Software Drivers to Audio. Post date updated from Tuesday, February 20, 2024 6:37 AM UTC to Wednesday, February 21, 2024 1:54 AM UTC to reflect the move.

MOONG - Moved from Audio to SigmaDSP Processors & SigmaStudio Dev. Tool. Post date updated from Wednesday, February 21, 2024 1:54 AM UTC to Wednesday, February 21, 2024 2:04 AM UTC to reflect the move.

btogorean Reply
Feb 20, 2024 00:00

Hi,

can you please tell us which Linux kernel version you use? Is it mainline or a specific tree?

The "Unable to sync register" error is raised from drivers/base/regmap/regcache.c and it represents a failed I2C transaction.

Can you please probe the I2C bus and check if you have acknowledge after 0x4002 register write?

Also is not clear for me why you state "sound-dai = <&i2s0>; i2s-controller = <&i2s0>;" in device tree but the label for I2S controller is just i2s. i2s: i2s@reg_addr {

- Bogdan

MOONG Reply
Feb 20, 2024 00:00

Dear Bogdan,

thank you very much for your response.

I use is 5.4.192 kernel version.

This is the device tree of the SOC that I currently use.

Do I need to check for approval separately?

I am trying to implement this using only the compatible without any additional coding,

using adau1761.c, adau17x1.c, and adau1761-i2c.c included in the Linux kernel.

added my kernel log

[ 10.345900] adau1761 6-0070: probe
[ 10.349542] i2c i2c-6: client [adau1761] registered with bus id 6-0070
[ 10.435316] debugfs: Directory '6228000.i2s' with parent '6228000.i2s-adau-hifi' already present!
[ 10.444439] asoc-simple-card systembus:sound: adau-hifi <-> 6228000.i2s mapping ok
[ 10.452069] asoc-simple-card systembus:sound: ASoC: no DMI vendor name!
[ 10.459695] adau1761 6-0070: Unable to sync registers 0x4002-0x4002. -121

I made a mistake in specifying I2S. It is i2s0:i2s@reg_addr, which is why I wrote &i2s0.

thank you.

DaveThib Reply
Feb 26, 2024 00:00

Hello Moong,

Have you seen this driver we have available? Would this be helpful?

ADAU1361 Sound CODEC Linux Driver [Analog Devices Wiki]

I looked for some other threads. There is this one but it is really old.

(+) Need Help Using the adau1761 SigmaDSP in Linux-based Embedded System - Q&A - SigmaDSP Processors & SigmaStudio Dev. Tool - EngineerZone (analog.com)

There are some answers here but still not a lot.

(+) About ADAU1761 DSP Control in Linux - Q&A - SigmaDSP Processors & SigmaStudio Dev. Tool - EngineerZone (analog.com)

This user realized that the controls in the DSP are all custom so we cannot produce a driver since we have no idea where a control will reside in parameter RAM until it is compiled. So you have to wrtie that into the driver once your DSP program is complete.

This page has information about interfacing with a microcontroller if you scroll down just a little you will see it.

Tutorials, Guides, Walkthroughs, and other Information [Analog Devices Wiki]

One other little detail,

You sent me a PM but I cannot respond because your account is set to not accept PMs from anybody. So you have to send me a friend request so I will be able to respond.

Dave T

MOONG Reply
Mar 3, 2024 00:00

Thank you for your kind response. I have resolved the I2C issue. The problem was solved by changing the I2C Device address from 0x70 to 0x38, after which it started working correctly.

However, I am facing another issue. I extracted the adau1761.bin file from SigmaStudio and included it in the kernel for upload, but it seems to not perform any actions when executed. Interestingly, when I download the codec using a converter, it works fine, but it does not work properly when loaded by the kernel. Do I need to write a firmware download algorithm in the machine driver myself?

Below is my adau1761.bin file / SigmaStudio.

pastedimage1709508000856v1.png
pastedimage1709508000856v1.png
pastedimage1709508398616v1.png
pastedimage1709508398616v1.png
MOONG Reply
Mar 7, 2024 00:00

The issue was due to the Slave Register address.

I thought addr1 / addr0 were connected, making it 0x70, but it was a bit questionable. However, it worked when I set it to 0x38.