understand 、 Study Linux Sound card driver , And in Tiny4412 Realize the playback and recording of sound on .

1. Sound card Foundation

1.1 Basic concepts

Remember junior high school or high school physics , It says that sound is produced by the vibration of objects , And then through the air to the ears .
Replace your ears with a microphone , Sound vibration microphone , Changed the voltage at both ends of the microphone ,ADC Then collect the voltage , Just recorded the audio data ; conversely , Record the data through DAC Turn it into voltage , Amplification by op amp , Just make the horn vibrate and make a sound .
The whole process , There are three parameters related to sound quality :

  • sampling frequency : Unit time ADC The number of times to collect , It's usually 8kHz~96kHz;
  • Conversion accuracy : Every time ADC Collect or DAC The accuracy of the transformation . Generally speaking, there are 8bit、16bit、24bit;
  • The channel number : It's mono 、 Two channel ;

stay Linux In the development of sound card driver , The original sound card driver framework is OSS(Open Sound System).
from 2.6 Version start ,ALSA(Advanced Linux Sound Architecture) Become Linux The default set of standard audio drivers in the kernel ,OSS Is marked as abandoned .
OSS and ALSA The main difference :

  • OSS: Offer based on ioctl Wait for the original programming interface to access the device ;
  • ALSA: In addition to providing based on ioctl And so on , It also provides the corresponding function library specially for simplifying the writing of application program , relative OSS It is more convenient ;

The driver written later , Will adopt ALSA frame .

1.2 Audio codec chip

Generally speaking , majority SOC None of the audio conversion , Maybe it's power consumption 、 Analog to digital interference, etc , So most of them are connected with an audio codec chip (Codec).
Audio files from Flash Load into RAM in , Again by DMA It through I2S Send to Codec, Again by Codec Of DAC It turns into an analog signal , Drive the amplifier to make the speaker play sound ; meanwhile ,SOC adopt I2C( There are some Codec No I2C, But other interfaces ) Set up Codec The register of , Adjust the sound size, etc .

therefore , The drivers involved in the whole sound card frame may have SOC Of DMA、I2S、I2C as well as Codec drive .

2. Hardware interface

Tiny4412 The schematic diagram of the sound card is as follows , Adopted by the codec The chip is WM8960, The circuit can be divided into four parts :

① IIS Interface , be responsible for Exynos4412 and WM8960 Data transfer between

Function SOC Codec Note
Date Xi2sCDCLK0 MCLK The system clock
Xi2sSCLK0 BCLK Data clock
Xi2sLRCK0 DACLRC Left and right channel switching
Xi2sSDO0_0 DATDAT Data output ( Play )
Xi2sSDI0 ADCDAT data input ( sound recording )


② I2C Interface , be responsible for Exynos4412 Yes WM8960 Register configuration

Function SOC Codec Note
Control Xi2cSCL0 SCLK I2C The clock
Xi2cSDA0 SDIN I2C data

③ sound recording
Recording with microphone and earphone interface ;

④ Play
Use headphone interface to play audio , There's also a headphone insertion test Earphone_detect;