2830 views|2 replies

118

Posts

0

Resources
The OP
 

[Technical Tips] It turns out that the ARM+Linux audio solution is so simple! [Copy link]

Audio input and output problems are often encountered in embedded product development. How to add "speaker" and "microphone" devices to them? This article will briefly introduce the audio solution in ARM+Linux products.

Let's first get to know the I2S (Inter-IC Sound) bus. I2S is also known as the integrated circuit built-in audio bus. This bus is specifically used for data transmission between audio devices and is widely used in various multimedia systems. It adopts a design that transmits clock and data signals along independent wires. By separating the data and clock signals, distortion caused by time difference can be effectively avoided.

Taking the HDG2L-IoT evaluation kit as an example, the RZ/G2L processor provides at least one I2S bus, which is connected to the audio codec chip (IC model WM8960) to provide high-quality recording and broadcasting functions. The hardware deployment of the audio module is shown below.

HDG2L-IoT Audio Interface

Figure 1 HDG2L-IoT audio interface

The audio communication pins between the G2L core board and WM8960 are as follows:

Audio communication pin

In the audio codec driver of the Linux system, the I2C communication interface communicates with the audio IC, abstracting the various function registers in the audio IC into audio controls, so that users can directly adjust the parameters in the IC in the User space. The I2S audio pin is the channel for sending and receiving digital signals.

When broadcasting, the audio IC converts the received digital signal into an analog signal and sends it out. When recording, the audio IC converts the received audio analog quantity into a digital quantity and sends it to the processor.

ALSA is the mainstream audio architecture of Linux. It includes a set of kernel drivers, API libraries and tools to support Linux sound. Applications can control the underlying audio hardware by calling the API provided by alsa-lib.

Linux manages audio IC controls through the alsa library and alsa tools, and lists the audio controls in the current system through "amixer controls":

Audio Controls

The key control information of the audio function is as follows: (recording channel, broadcast channel, headphone volume, speaker volume).

Key control information for audio functions

On the development board, run the aplay program to test audio playback. Before testing, plug the earphone into the earphone jack of the development board.

To test the I2S-based audio output interface, execute the following command in the command line:

5.jpg

2.wav is the audio file to be played, and it is assumed here that 2.wav is located in the /home/root/audios directory.

When playing audio, for the I2S-based audio output interface, you can use the amixer program to adjust the volume. The command line format for using the amixer program to adjust the headphone playback volume is:

6.jpg

The volume value ranges from 0 to 127, with 127 indicating the maximum volume. For example, to set the volume to 100, execute the following command in the command line:

7.jpg

Connect the speakers to the left and right channel sockets of the HDG2L-IOT development board. Before playing the audio, you can set the speaker playback volume and total volume, and then play the audio file:

8.jpg

The recording function requires setting the parameters of the recording control, as shown below.

9.jpg

Use the arecord command to record and save it as "/tmp/t.wav", then use the aplay command to play it back for verification.

10.jpg

Since the current microphone output signal is only connected to the Left end of the audio processing as input, only the left channel is output when playing the recording file. If you want to record the microphone output signal in both the left and right channels, you can make the following settings:

11.jpg

Set “ADC Data Output Select” to 1, which means “Left Data = Left ADC; Right Data = Left ADC”.

As can be seen from the above, the audio codec chip exists in the form of a control in the Linux system. The internal parameters are generally only recorded in the memory. When the system loses power, the modified parameters will disappear, so save and restore instructions are needed to save the last parameters in the configuration file.

The configuration file of alsa is: /var/lib/alsa/asound.state

The write operation after the control is modified is shown below.

12.jpg

The operation of restoring the control parameters is as follows (Note: the configuration file will be automatically read after restarting the board).

13.jpg

This post is from ARM Technology

Latest reply

It's time to learn the necessity of I2S. Is there a tutorial on driving i2s under python?  Details Published on 2022-8-5 06:59
 

2

Posts

0

Resources
2
 
Thank you for sharing the guidance!
This post is from ARM Technology
 
 
 

6818

Posts

11

Resources
3
 
It's time to learn the necessity of I2S. Is there a tutorial on driving i2s under python?
This post is from ARM Technology
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list