SOUND/CORE/PCM_NATIVE.C provides packaging for the lower-level PCM drive, provides a unified interface for the upper layer, and functions snd_pcm_f_ops_playback the file operation structure to provide playback functions, Snd_pcm_f_ops_ Capture file operation structure provides a function of recording function.
SOUND/CORE/CONTROL.C provides packaging for the lower control driver, provides a unified interface for the upper layer, and snd_ctl_f_ops the file operation structure, which is mainly a snd_ctl_ioctl function.
The playback process is generally as follows:
Snd_pcm_f_ops_playback.write that Snd_pcm_write call Snd_pcm_lib_write
Snd_pcm_lib_write Call Snd_pcm_lib_write1
Snd_pcm_lib_write1 writes data through Snd_pcm_lib_write_transfer to DMA buffer, and then invokes Snd_pcm_start to start DMA transfer data into WM9713.
The recording process is generally as follows:
Snd_pcm_f_ops_capture.read that Snd_pcm_read call Snd_pcm_lib_read
Snd_pcm_lib_read Call Snd_pcm_lib_read1
Snd_pcm_lib_read1 calls Snd_pcm_start transfers data from WM9713 to DMA memory, and then invokes the Snd_pcm_lib_read_transfer copy data to the user's buffer.
The control interface primarily allows user-space Applications (ALSA-LIB) to access and manage the multi-channel switches, sliding controls, etc. in the audio codec chip. The control interface is particularly important for mixer (remix), starting with the Alsa 0.9.x version, where all mixer work is done through the API of the control interface.
Definition of controls
To customize a control, we first define 3 callback functions: Info,get and put. Then, define a SND_KCONTROL_NEW structure:[C-sharp]View plain copy static struct snd_kcontrol_new My_control __devinitdata = {. Iface = sndrv_ctl_elem_iface_mixer,// The type of control. Name = "PCM Playback Switch",//control's name. Because the role of control is categorized by name. ALSA has pre-defined some control names.. Index = 0,//Save the number of the control in the card. Access = Sndrv_ctl_elem_access_readwrite,//visit of the control Ask the type. Private_value = 0xFFFF,//contains an arbitrary long integer type value. This value can be accessed by info,get,put these several callback functions.. info = my_control_info,//For more information on control, ALSA has implemented some common info callback functions for us. Get = My_cont Rol_get,. put = my_control_put};
The control device, like the PCM device, belongs to the logical device under the sound card. The user-space application accesses the control device through Alsa-lib to read or control the controlling state of control, thereby controlling the audio codec for various mixer and other control operations.