One of the Linux ALSA Sound Card Drivers: ALSA Architecture Overview [zz]

Source: Internet
Author: User

Address: http://blog.csdn.net/droidphone/article/details/6271122

 

Statement: the content of this blog is composedHttp://blog.csdn.net/droidphoneOriginal, reprinted please indicate the source, thank you!


I. Overview

ALSA is short for advanced Linux sound architecture and has become the mainstream audio architecture of Linux. I would like to learn more about ALSA's open-source project, for more information, see http://www.alsa-project.org /.

In the driver layer of the internal device, ALSA provides ALSA-driver. At the application layer, ALSA provides ALSA-lib and applications.ProgramYou only need to call the API provided by ALSA-lib to control the underlying audio hardware.

 

Figure 1.1 ALSA Software Architecture

As shown in Figure 1.1, ALSA-lib of the user space provides a unified API interface for the application, which hides the implementation details of the driver layer and simplifies the implementation of the application. In the inner-core space, ALSA-Soc is actually further encapsulation of ALSA-driver. It provides some column-enhanced functions for embedded devices. This series of blog posts only discuss ALSA-driver and ALSA-SOC in embedded systems.

Ii. ALSA device file structure

Let's start our ALSA journey from the device file structure of ALSA in Linux. Let's take a look at the structure of the device file of the Alsa driver in my computer:

$ CD/dev/SND
$ LS-l

CrW-RW ---- + 1 root audio 116, 8 controlc0
CrW-RW ---- + 1 root audio 116, 4 midic0d0
CrW-RW ---- + 1 root audio 116, 7 pcmc0d0c
CrW-RW ---- + 1 root audio 116, 6 pcmc0d0p
CrW-RW ---- + 1 root audio 116, 5 pcmc0d1p
CrW-RW ---- + 1 root audio 116, 3 seq
CrW-RW ---- + 1 root audio 116, 2 Timer
$

We can see the following device files:

    • controlc0 --> used for sound card control, such as channel selection, sound mixing, and microphone Control
    • midic0d0 --> used to play MIDI audio
    • pcmc0d0c --> PCM device used for recording
    • pcmc0d0p --> PCM device used for playback
    • seq --> sequencer
    • timer --> timer

Among them, c0d0 represents the device 0 in sound card 0, pcmc0d0c the last c Represents capture, and pcmc0d0p the last p represents playback. These are naming rules in ALSA-driver. From the list above, we can see that my sound card has 6 devices mounted. According to the actual capacity of the Sound Card, more types of devices can be mounted to the driver, in the include/sound/core. h defines the following device types:

[C-sharp] View plaincopy
  1. # Define sndrv_dev_toplevel (_ force snd_device_type_t) 0)
  2. # Define sndrv_dev_control (_ force snd_device_type_t) 1)
  3. # Define sndrv_dev_lowlevel_pre (_ force snd_device_type_t) 2)
  4. # Define sndrv_dev_lowlevel_normal (_ force snd_device_type_t) 0x1000)
  5. # Define sndrv_dev_pcm (_ force snd_device_type_t) 0x1001)
  6. # Define sndrv_dev_rawmidi (_ force snd_device_type_t) 0x1002)
  7. # Define sndrv_dev_timer (_ force snd_device_type_t) 0x1003)
  8. # Define sndrv_dev_sequencer (_ force snd_device_type_t) 0x1004)
  9. # Define sndrv_dev_hwdep (_ force snd_device_type_t) 0x1005)
  10. # Define sndrv_dev_info (_ force snd_device_type_t) 0x1006)
  11. # Define sndrv_dev_bus (_ force snd_device_type_t) 0x1007)
  12. # Define sndrv_dev_codec (_ force snd_device_type_t) 0x1008)
  13. # Define sndrv_dev_jack (_ force snd_device_type_t) 0x1009)
  14. # Define sndrv_dev_lowlevel (_ force snd_device_type_t) 0x2000)

Generally, we are more concerned with PCM and control devices.

 

3. Driver Code File structure

In the linux2.6 code tree, the structure of the Alsa code file is as follows:

Sound
/Core
/OSS
/Seq
/Ioctl32
/Include
/Drivers
/I2C
/Synth
/Emux
/PCI
/(CARDS)
/Isa
/(CARDS)
/ARM
/PPC
/ISCSI
/USB
/PCMCIA/(CARDS)
/OSS
/SOC
/Codecs

  • Core this directory contains the intermediate layer of the Alsa driver, which is the core part of the entire ALSA driver
  • Core/OSS contains PCM and mixer modules that simulate the old OSS Architecture
  • Core/seq Code related to sequencer
  • Include the public header file directory of the Alsa driver. The header file of this directory must be exported to applications in the user space. Generally, the private header file of the driver module should not be placed here.
  • Drivers places some public code irrelevant to the CPU and bus architecture
  • I2C ALSA's own I2C control code
  • The top-level directory of the PCI sound card. The subdirectory contains various PCI sound card codes.
  • The top-level directory of the ISA sound card. The subdirectory contains various ISA sound card codes.
  • SOC's intermediate layer Code for the System-on-chip system
  • SOC/codecs code for codec of SoC system, independent of Platform

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.