The currently designed interfaces are listed below:
- Information Interface (/proc/asound)
- Control Interface (/dev/snd/controlCX)
- Mixer Interface (/dev/snd/mixerCXDX)
- PCM Interface (/dev/snd/pcmCXDX)
- Raw MIDI Interface (/dev/snd/midiCXDX)
- Sequencer Interface (/dev/snd/seq)
- Timer Interface (/dev/snd/timer)
https://www.alsa-project.org/main/index.php/ALSA_Library_API
/proc/asound # ls -all
total 0
dr-xr-xr-x 3 admin 0 0 Jan 2 02:43 .
dr-xr-xr-x 125 admin 0 0 Jan 2 1970 ..
dr-xr-xr-x 10 admin 0 0 Jan 2 02:47 card0
-r--r--r-- 1 admin 0 0 Jan 2 02:47 cards
-r--r--r-- 1 admin 0 0 Jan 2 02:47 devices
-r--r--r-- 1 admin 0 0 Jan 2 02:47 pcm
-r--r--r-- 1 admin 0 0 Jan 2 02:47 timers
-r--r--r-- 1 admin 0 0 Jan 2 02:47 version
lrwxrwxrwx 1 admin 0 5 Jan 2 02:47 zx297520v3es837 -> card0
/proc/asound/card0 # ls
id pcm0c pcm0p pcm1c pcm1p pcm2c pcm2p pcm3c pcm3p
/proc/asound/card0 # cat id
zx297520v3es837
/proc/asound # cat devices
0: [ 0] : control
16: [ 0- 0]: digital audio playback
17: [ 0- 1]: digital audio playback
18: [ 0- 2]: digital audio playback
19: [ 0- 3]: digital audio playback
24: [ 0- 0]: digital audio capture
25: [ 0- 1]: digital audio capture
26: [ 0- 2]: digital audio capture
27: [ 0- 3]: digital audio capture
33: : timer
/proc/asound # cat timers
G0: system timer : 5000.000us (10000000 ticks)
P0-0-0: PCM playback 0-0-0 : SLAVE
P0-0-1: PCM capture 0-0-1 : SLAVE
P0-1-0: PCM playback 0-1-0 : SLAVE
P0-1-1: PCM capture 0-1-1 : SLAVE
P0-2-0: PCM playback 0-2-0 : SLAVE
P0-2-1: PCM capture 0-2-1 : SLAVE
P0-3-0: PCM playback 0-3-0 : SLAVE
P0-3-1: PCM capture 0-3-1 : SLAVE
/proc/asound # cat cards
0 [zx297520v3es837]: zx297520v3_es83 - zx297520v3_es8374
zx297520v3_es8374
/proc/asound # cat pcm
00-00: MultiMedia ES8374 HiFi-0 : : playback 1 : capture 1
00-01: voice ES8374 HiFi-1 : : playback 1 : capture 1
00-02: 2_3g_voice ES8374 HiFi-2 : : playback 1 : capture 1
00-03: loop_voice ES8374 HiFi-3 : : playback 1 : capture 1
/proc/asound # cat version
Advanced Linux Sound Architecture Driver Version 1.0.25.
/test_tool # ./tinyinfo
Usage: ./tinyinfo -D card -d device
/test_tool # ./tinyinfo -D 0 -d 0
Info for card 0, device 0:
PCM out:
Access: 0x000009
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=4 max=2048
Period count: min=2 max=5
PCM in:
Access: 0x000009
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=4 max=2048
Period count: min=2 max=5
/test_tool # ./tinyinfo -D 0 -d 1
Info for card 0, device 1:
PCM out:
Access: 0x000008
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=512 max=4096
Period count: min=2 max=128
PCM in:
Access: 0x000008
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=512 max=4096
Period count: min=2 max=128
/test_tool # ./tinyinfo -D 0 -d 2
Info for card 0, device 2:
PCM out:
Access: 0x000009
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=20 max=2048
Period count: min=2 max=128
PCM in:
Access: 0x000009
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=20 max=2048
Period count: min=2 max=128
/test_tool # ./tinyinfo -D 0 -d 3
Info for card 0, device 3:
PCM out:
Access: 0x000008
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=512 max=4096
Period count: min=2 max=128
PCM in:
Access: 0x000008
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=8000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=512 max=4096
Period count: min=2 max=128
其中以下几项值有差异:
Access: 0x000008
Period size: min=4 max=2048
Period count: min=2 max=5
http://www.alsa-project.org/main/index.php/FramesPeriods
驱动中的结构体:
struct snd_pcm_hardware {
unsigned int info; /* SNDRV_PCM_INFO_* */
u64 formats; /* SNDRV_PCM_FMTBIT_* */
unsigned int rates; /* SNDRV_PCM_RATE_* */
unsigned int rate_min; /* min rate */
unsigned int rate_max; /* max rate */
unsigned int channels_min; /* min channels */
unsigned int channels_max; /* max channels */
size_t buffer_bytes_max; /* max buffer size */
size_t period_bytes_min; /* min period size */
size_t period_bytes_max; /* max period size */
unsigned int periods_min; /* min # of periods */
unsigned int periods_max; /* max # of periods */
size_t fifo_size; /* fifo size in bytes */
};
平台已经进行了定义:
/test_tool # ./tinymix
Mixer name: 'zx297520v3_es8374'
Number of controls: 47
ctl type num name value
0 BOOL 1 D2SE MIC BOOST GAIN On
1 INT 1 LIN PGA GAIN 0
2 BOOL 1 DMIC 6DB SCALE UP GAIN Off
3 BOOL 1 ADC Double FS Mode Off
4 BOOL 1 ADC Soft Ramp Off
5 BOOL 1 ADC MUTE Off
6 BOOL 1 ADC INVERTED Off
7 INT 1 ADC HPF COEFFICIENT 5
8 INT 1 ADC Capture Volume 0
9 INT 1 ALC Capture Target Volume 1
10 INT 1 ALC Capture Max PGA 28
11 INT 1 ALC Capture Min PGA 0
12 INT 1 ALC Capture Hold Time 4
13 INT 1 ALC Capture Decay Time 3
14 INT 1 ALC Capture Attack Time 2
15 INT 1 ALC WIN SIZE 3
16 INT 1 ALC Capture NG Threshold 0
17 ENUM 1 ALC Capture NG Type Constant PGA Gain
18 BOOL 1 ALC Capture NG Switch Off
19 BOOL 1 DAC Double FS Mode Off
20 INT 1 DAC Soft Ramp Rate 0
21 BOOL 1 DAC MUTE On
22 INT 1 DAC OFFSET 0
23 ENUM 1 DAC AUTO MUTE TYPE AUTO MUTE DISABLE
24 ENUM 1 DAC DSM MUTE TYPE DAC DSM MUTE
25 INT 1 DAC Playback Volume 192
26 INT 1 MONO OUT GAIN 3
27 INT 1 SPEAKER MIXER GAIN 0
28 INT 1 SPEAKER OUTPUT Volume 0
29 ENUM 1 EQUALIZER MUX FROM ADC OUT
30 BOOL 1 SPEAKER MIXER LIN TO SPEAKER OUT Switch Off
31 BOOL 1 SPEAKER MIXER DAC TO SPEAKER OUT Switch Off
32 BOOL 1 MONO MIXER LIN TO MONO OUT Switch Off
33 BOOL 1 MONO MIXER DAC TO MONO OUT Switch Off
34 ENUM 1 ANALOG INPUT MUX LIN1
35 ENUM 1 DAC SRC MUX FROM SDP IN
36 ENUM 1 DAC SDP SRC MUX SELECT SDP LEFT DATA
37 ENUM 1 SDP OUT MUX FROM ADC OUT
38 ENUM 1 ALC MUX ALC OFF
39 ENUM 1 DMIC MUX DMIC DISABLE1
40 ENUM 1 DIFFERENTIAL MUX LIN1-RIN1
41 ENUM 1 voice processing path select handset
42 INT 1 voice processing path Volume 3
43 BOOL 1 voice uplink mute Off
44 ENUM 1 voice tone sel Lowpower
45 BOOL 1 path stauts dump Off
46 ENUM 1 audio path select handset
https://www.kernel.org/doc/html/v4.17/sound/kernel-api/writing-an-alsa-driver.html#preface
http://www.alsa-project.org/alsa-doc/alsa-lib/group__ucm.html