Linux Alsa One of the sound card drivers: Alsa Architecture Introduction "Go"

Source: Internet
Author: User

This article was reproduced from: http://blog.csdn.net/droidphone/article/details/6271122

Statement: The content of this blog by Http://blog.csdn.net/droidphone Original, reproduced please indicate the source, thank you!

I. Overview

ALSA is the acronym for Advanced Linux Sound Architecture and has become the mainstream audio architecture for Linux, for more information and knowledge about this open source project for ALSA, please see the following URL:/http www.alsa-project.org/.

In the kernel device driver layer, ALSA provides alsa-driver, and at the application layer, ALSA gives us alsa-lib, and the application can complete control of the underlying audio hardware by invoking the API provided by Alsa-lib.

Figure 1.1 Software architecture for ALSA

As can be seen from Figure 1.1, the alsa-lib of the user space provides a unified API interface to the application, which hides the implementation details of the driver layer and simplifies the implementation of the application. In kernel space, ALSA-SOC is actually a further encapsulation of alsa-driver, and he provides some column-enhanced functionality for embedded devices. This series of posts only discusses Alsa-driver and ALSA-SOC in embedded systems.

Two. ALSA Device file structure

We started our Alsa journey from Alsa's device file structure in Linux. Look at the ALSA-driven device file structure in My Computer:

$ cd/dev/snd
$ ls-l

CRW-RW----+ 1 root audio, 8 2011-02-23 21:38 controlC0
CRW-RW----+ 1 root audio, 4 2011-02-23 21:38 midic0d0
CRW-RW----+ 1 root audio, 7 2011-02-23 21:39 pcmc0d0c
CRW-RW----+ 1 root audio, 6 2011-02-23 21:56 pcmc0d0p
CRW-RW----+ 1 root audio, 5 2011-02-23 21:38 pcmc0d1p
CRW-RW----+ 1 root audio, 3 2011-02-23 21:38 seq
CRW-RW----+ 1 root audio, 2 2011-02-23 21:38 timer
$


We can see the following device files:

    • controlC0-->                  controls for sound cards, such as channel selection, mixing, microphone control, etc.
    • midic0d0 -->                  for playing MIDI audio
    • pcmc0d0c--〉                PCM device for recording
    • pcmc0d0p--〉                PCM device for playback
    • seq --〉                          Sequencer
    • Timer--〉                        Timer

Where c0d0 represents the device in sound card 0 0,pcmc0d0c The last C represents the capture,pcmc0d0p last p for playback, these are the naming rules in Alsa-driver. As can be seen from the list above, my sound card hangs 6 devices, according to the actual ability of the sound card, the driver can actually hang more kinds of devices, in include/sound/core.h, defined 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)

In general, we are more concerned with both the PCM and control devices.

Three. Driver-driven code file structure

In the Linux2.6 code tree, the ALSA code file structure is as follows:

Sound
/core
/oss
/seq
/ioctl32
/include
/drivers
/i2c
/synth
/emux
/pci
/(Cards)
/isa
/(Cards)
/arm
/ppc
/sparc
/usb
/pcmcia/(cards)
/oss
/soc
/codecs

    • Core This directory contains the middle tier of the Alsa driver, which is the central part of the entire ALSA drive
    • Core/oss contains PCM and mixer modules that mimic the old OSS architecture
    • Core/seq about sequencer-related code
    • Include Alsa driver common header file directory, the header file of the directory needs to be exported to the user space of the application used, usually, the driver module private header file should not be placed here
    • Drivers placing some common code that is not related to CPU, bus architecture
    • I²c alsa own I²c control code
    • Top-level directory for PCI PCI sound cards, subdirectories containing code for various PCI sound cards
    • The top-level directory of the Isa ISA sound card, and the subdirectories contain the code for the various ISA sound cards
    • Soc code for the System-on-chip system's middle tier
    • Soc/codecs the various codec codes for SOC systems, regardless of the platform

Linux Alsa One of the sound card drivers: Alsa Architecture Introduction "Go"

Related Article

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.