/proc/asound详细介绍

本文转载于:Proc asound 文档

ALSA使用/proc/asound目录下的文件保存设备信息并且实现一些控制目的。

这些文件是什么?
/proc信息与硬件(驱动)无关,例如USB描述符。他的内容由驱动的作者负责,所以在实际中很难进行完整全面的描述。也就是说ALSA具有一些标准,大多数驱动都支持这些标准。。

由ALSA本身提供的最基本的文件:
/proc/asound/cardX(这里X是声卡的编号,从0到7)
对于系统中已经识别的每个声卡都存在对应的cardX目录。关于这个目录内容的信息请看下面。
/pro/asound/cards(只读)
已注册的声卡的列表
/proc/asound/dev/
存放特殊的设备文件,用于针对声音操作进行编程。
如果系统使用devfs,就会有这个目录。
如果系统没有使用devfs(从2006-06起,大多数都没有使用),就根本不会有这个文件或者仅仅是指向/dev/snd的符号链接。
/proc/asound/devices (只读)
已注册的ALSA设备的列表(主设备号为116)
/proc/asound/hwdep (只读)
hwdep(硬件相关)控制列表。并不会在所有的系统中出现(仍然存在吗?)
/proc/asound/meminfo (只读)
内存使用信息。该proc文件仅当使用内存调试或所有选项构建ALSA驱动时才会有,该文件显示了当前在内核空间分配的内存。
/proc/asound/modules (只读)
已注册声卡驱动的列表,并不是所有为ALSA所加载的内核模块,而是硬件驱动的列表。一行对应一个正在使用的声卡
/proc/asound/oss/
包含关于OSS模拟的信息的目录。关于该目录内容的信息请看下面
/proc/asound/pcm (只读)
已分配的pcm流的列表。注意:可能并不意味着是激活的流的列表,它是设备的一个列表。这对于断定hw:0,0风格的设备名称非常有用,设备名称往往是命令如aplay所需要的。
/proc/aasound/seq/
包含关于音序器的信息。关于该目录内容的信息请看下面
/proc/asound/timers (只读)
类似于/proc/asound/pcm, 它是一个ALSA已知的计时器的列表,并且(好像)描述了当前哪个是实际正在实际使用。
/proc/asound/version (只读)
ALSA子系统模块(或内核)构建的版本和日期。
请注意:标明“只读”的设备仅仅用来从内核中提供信息。其他的文件是可读可写的,可以用来向ALSA发送命令。
在/dev/snd(/proc/asound/dev)目录下的设备文件
设备文件是应用为了执行声音操作如录音、播放、改变声音大小、获取时间信息、执行MIDI序列化所相关的文件。通常位于/dev/snd,在有些系统上也可能在/proc/asound/dev
通常这些设备文件以 aaaCxDy 的形式命名
aaa 是服务的名字
x 是卡的编号
y 设备编号

controlC? control devices (i.e. mixer, etc.)
hwC?D? hwdep devices
midiC?D? rawmidi devices
pcmC?D?p pcm playback devices
pcmC?D?c pcm capture devices
seq sequencer device
timer timer device
/proc/asound/oss目录
该目录下文件的内容是动态改变的,没有OSS模拟模块(snd-pcm-oss, snd-mixer-oss)加载时,就不会列出pcm或mixer设备。

/proc/asound/oss/devices (RO)
the list of devices already registered

/proc/asound/oss/sndstat (RO)
/dev/sndstat compatible list
/proc/sound/cardX/目录

id (RO)
the id string of the card

ac97#? (RO)
AC97 codec information

ac97#?regs (RO)
(printable) register dump

midi? (RO)
the current status of input/output on the
rawmidi device

pcm?p
the directory status of the given pcm playback stream
pcm?c
the directory status of the given pcm capture stream
/proc/asound/cardX/pcmXX目录
这些可选目录中的文件包含了PCM流的信息。注意,在内核2.6.17和之后的内核只有在内核配置文件中使能了CONFIG_SND_VERBOSE_PROCFS(“详细的procfs内容”)后都会出现这些文件。

pcm??/info (RO)
the pcm stream general info (card, device, name, etc.)

pcm??/oss (RO)
oss emulation info (shown only when the pcm is opened
as an oss device).

pcm??/sub?
the substream information directory

pcm??/sub?/info (RO)
the pcm substream general info (card, device, name, etc.)

pcm??/sub?/status (RO)
the current status of the given pcm substream
(status, position, delay, tick time, etc.)

pcm??/sub?/hw_params (RO)
hw_params set-up on the substream
(buffer size, format, etc.)

pcm??/sub?/sw_params (RO)
sw_params set-up on the substream
(threshold, etc.)

pcm??/sub?/prealloc (RW)
the number of pre-allocated buffer size in kb.
you can specify the buffer size by writing to this proc file:

echo 128 > /proc/asound/card0/pcm0p/sub0/prealloc

to allocate 128kbyte for playback, substream #0, stream #0
on the card #0.
可以运行下面的命令查看所有alsa模块的选项:

modinfo $(modprobe -l snd-*) > ~/modinfo

/proc/asound/seq/ 目录

clients

Need info

drivers

Need info

oss

Need info

queues

Need info

timer

Need info

硬件设备是什么呢?

典型的输出类似于下面:

prompt# cat /proc/asound/devices
0: [ 0] : control
1: : sequencer
16: [ 0- 0]: digital audio playback
18: [ 0- 2]: digital audio playback
24: [ 0- 0]: digital audio capture
25: [ 0- 1]: digital audio capture
33: : timer
上面的例子说明有一个控制通道,两个PCM 放音(playback)设备(DAC’s),两个PCM录音设备(ADC‘s),一个MIDI序列器(sequencer)和一个计时器。

在上面例子的系统上,没有任何重映射,这等价于下面:

设备:

First PCM playback DAC
What it does: Plays sound
The device file looks like:
crw-rw---- 1 root audio 116, 16 Mar 4 21:30 pcmC0D0p
(the date on yours will probably be different)
What ALSA calls it: the playback half of hw:0,0, which is a duplex device
First PCM recording ADC
What it does: Plays sound
The device file looks like:
crw-rw---- 1 root audio 116, 16 Mar 4 21:30 pcmC0D0c
What ALSA calls it: the recording half of hw:0,0, which is a duplex device
Control Channel for first soundcard
What it Does: controls volume/recording gain (and other stuff?)
The device file looks like:
crw-rw---- 1 root audio 116, 0 Mon DD hh:mm /dev/snd/controlC0
(Mon DD hh:mm will be the date and time the device file was created on your system)
What ALSA calls it: ??

/proc将会改变:

在将来,/proc将仅仅被用于进程信息,之后要在/sys系统中查找ALSA

在2.6内核源码中,/Documentation/filesystems/sysfs.txt有所说明。/sys自从2006-06(内核2.6.16)就存在了,然而/proc接口还没有改变。

猜你喜欢

转载自blog.csdn.net/mynameislinduan/article/details/103045234