Linux Driver: Audio driver (i) alsa__linux

Source: Internet
Author: User

First, "Basic knowledge"

1, J2 "--hpr_out+hpl_out"--U13 (TLV320AIC3104IRHBR) hprout+hplout

2. Driving source code

Ipnc_rdk_v3.8.0.1/source/ti_tools/ipnc_psp_arago/kernel/sound/soc/codecs/tlv320aic3x.c

3, depends on the I2C drive

4, sound card driver frame: ALSA (Advanced Linux Sound architecture)

5, ALSA website: http://www.alsa-project.org

6, the structure body Snd_card describes a sound card device

7, the structure body snd_device the description child equipment

8, sound card equipment

Lisa@ubuntu:kernel$ls/dev/snd/-L

Total dosage 0

Drwxr-xr-x 2 root 815 09:10 By-Path

CRW-RW---t+1 root audio 116, 275 09:10 controlC0

CRW-RW---t+1 root audio 116, 235 09:10 midic0d0

CRW-RW---t+1 root audio 116, 265 09:11 pcmc0d0c

CRW-RW---t+1 root audio 116, 255 09:36 pcmc0d0p

CRW-RW---t+1 root audio 116, 245 09:10 pcmc0d1p

CRW-RW---t+1 root audio 116, 225 09:10 seq

CRW-RW---t+1 root audio 116, 545 09:10 Timer

lisa@ubuntu:kernel$ls/dev/snd/by-path/-L

Total dosage 0

lrwxrwxrwx1 root root 335 09:10pci-0000:02:03.0->. /controlc0

9. Main equipment Number

In Include/sound/core.h

#defineCONFIG_SND_MAJOR 116/* standardconfiguration * *

10, Sound Directory Description: In the "depth of practice embedded ..." "640 pages

Second, "Driving framework"

1. Create sound card: Snd_card_new (Linux 2.6.22 snd_card_create replaced)--->

2, the creation of child devices:

Snd_device_new (Snd_pcm_new, Snd_rawmidi_new, Snd_ctl_new, Snd_timer_new, snd_card_proc_new, snd_jack_new)--->

3, registered sound card: snd_card_register

Third, "PCM function"

PCM: Pulse-coded modulation, converting analog to digital

0, the structure of the inclusion of relations

0.1struct snd_pcm--> snc_pcm_str--> snd_pcm_substream--> (snd_pcm_ops+ snd_pcm_runtime)

0.2snd_pcm_runtime--> Snd_pcm_hardware

1. Structure Description Pcm:struct SND_PCM

2, Registered Pcm:snd_pcm_new

3. PCM Stream and PCM stream: Snc_pcm_str, Snd_pcm_substream

4. Important structural body in sub-flow

4.1snd_pcm_ops: The operation method of PCM flow need to be implemented in the specific sound card

4.2snd_pcm_runtime: Hardware descriptions, interrupt callbacks, DMA buffers, and private data need to be implemented in a specific sound card

4.2.1snd_pcm_hardware: Hardware Description

5, the establishment of PCM equipment files

5.1 Structural body describing logical devices: Snd_minor

5.2 Establishment Process:

snd_card_register--> snd_pcm_register-->snd_pcm_new--> snd_pcm_dev_register--> For_dev--> (Snd_kernel_minor get device number +device_create create device node)

6, the PCM equipment file access

6.1 Designation of the file Operation F_ops

An action set is an item in a snd_pcm_f_ops array, defined in SOUND/CORE/PCM_NATIVE.C

6.2 Registering character devices

Alsa_sound_init--> Register_chrdev (Major, "Alsa", &snd_fops)

There is only one snd_open function in the Snd_fops, which takes the corresponding Snd_minor object from the snd_miors array and replaces the action set (FILE->F_OP) of the file with the F_ops member of the object, based on the secondary device number. Specific to PCM device (a Snd_minor object), the file operation set is the corresponding operation in Snd_pcm_f_ops

Four, "sound card Control"

1. Control Item Creation

1.1 Description Control Structure body: Snd_kcontorl (include/sound/control.h)

1.2 Creating the control function: Snd_ctl_new1

1.3 Add the control to the sound card to which it belongs: Snd_ctl_add

1.4 Control callback Function: info, GET, put

2, Cotrol Equipment establishment

snd_card_create--> snd_ctl_new--> Snd_ctl_dev_register-->snd_register_device_for_dev--> (snd_kernel_ Minor Get device number +device_create create device node)

3, Cotrol equipment file access

Process is the same as PCM, different points: replace the set of file operations into Snd_ctl_f_ops

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.