SGTL5000 access/set PEQ from Linux userspace

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SGTL5000 access/set PEQ from Linux userspace

2,881 Views
michalbury
Contributor II

Hello,

we working on custom made system with i.MX25 module and SGTL5000 codec. All works fine, we use ALSA subsystem to capture audio and  a software band pass filter in our application.

I have seen possibility to set a band pass filter directly in SGTL5000 codec, and already have coefficients calculated. Now the question is how to write the coefficients to SGTL5000 through Llinux user space?

It's not possible to do it directly through I2C because the Chip is used by ALSA.

We don't want to modify SGTL5000 kernel driver.

thank you

Michal Bury

Labels (1)
Tags (3)
7 Replies

1,622 Views
stevenriedl
Contributor III

While this is assumed answered, I can -f attempt to read the SGTL5000 registers, but the values that get returned make no sense and change on every read. 

Any hints on the wrapper methods using ALSA lib API's? Digging through the ALSA API's but have not found those yet.

0 Kudos

1,622 Views
ask
Contributor III

Hi Michal,

There will be two ways to access the codec registers.

1.  Userspace code can access the i2c host adapters via device nodes. To operate on the nth adapter open /dev/i2c-n. After you have a file descriptor tied to a host adapter, you can command it through ioctls to connect to specific slave devices attached to it. (Ref: Essential Linux device drivers chapter 19 user mod I2C)(If codec interfaced with i2c bus)

2. You  can implement wrapper methods using ALSA lib apis

1,622 Views
abhijeet_ghodga
Contributor III

Hi ask,

Which files in the ALSA lib have to be used for implementing wrapper, for i2c codec registers access?

If there is a specific file, how to modify it?

Best,

Abhijeet

0 Kudos

1,622 Views
igorpadykov
NXP Employee
NXP Employee

Hi Michal

seems one can try i2c tools

All Boards I2C-tools

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,622 Views
michalbury
Contributor II

I have already tried I2C tools.

i2cdetect shows:

  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- UU -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: 20 21 22 -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- 56 -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --

UU means - that the address is used - opened.

When I try i2cdump or i2cset i get error:

Error: Could not set address to 0x0a: Device or resource busy

Problem is , Alsa driver in kernel hold the SGTL5000 I2C address open, therefore there is no possibility to communicate with SGTL5000 directly through I2C bus.

Is there a way to set the wanted parameter for PEQ to SGTL5000 through Alsa driver?

1,622 Views
andrewdyer
Contributor III

You can use the -f option in i2cdump, i2cset to bypass the check on whether the device is in use by the kernel if you are running with root permissions.  For example, on my system I have a EEPROM on i2c bus 0 at address 0x50 that is used by a kernel driver, but 'i2cdump -f -y -r 0-0xff 0 0x50' will dump the contents.

1,622 Views
michalbury
Contributor II

Yes with -f option I can access the codec registers. Now I need to do this from C code. I will investigate the i2cdump sources to see how gain access to used device. thanks.