Advanced Linux Sound Architecture - Driver
Jaroslav Kysela <perex@suse.cz>
v0.0.1, 12 May 1998
This document describes, in full detail, the Advanced Linux Sound
Architecture driver.
______________________________________________________________________
Table of Contents
1. Introduction
1.1 Source files
1.2 Devices
1.3 Memory allocation
1.4 Basic coding
1.5 Upper level (/cards)
1.6 Private data/values
1.7 CLI/STI & spin locking
1.8 Examples
2. Soundcard
2.1 Variables and functions
2.1.1 Examples
2.2 Resources
2.2.1 Examples
2.3 ISA DMA
2.4 PCI bus
2.4.1 Examples
3. File operations
3.1 Variables and functions
3.2 Examples
4. Mixer
4.1 Variables and functions
4.2 Exaples
5. PCM - Digital Audio
5.1 Variables and functions
5.2 Examples
______________________________________________________________________
11.. IInnttrroodduuccttiioonn
This document describes the ALSA driver and kernel API. Application
programmers should use the library API rather than kernel API. The
ALSA Library offers 100% of the functionally of the kernel API, but
add next major improvements in usability, making the application code
simpler and better looking. In addition, some of the some
fixes/compatibility code in, may be placed in the library code instead
of the kernel driver.
11..11.. SSoouurrccee ffiilleess
Source files are separated to:
//iinncclluuddee
Directory contains all header files which are included from more
sources.
//kkeerrnneell
Directory with kernel code and abstract layers (middle level
code and library).
//lloowwlleevveell
Generic lowlevel code for chip(set)s.
//ccaarrddss
Upper level for soundcards and specific lowlevel code.
//ddeetteecctt
Detection layer (_/_p_r_o_c_/_a_s_o_u_n_d_/_d_e_t_e_c_t - to make installation
easy).
11..22.. DDeevviicceess
Devices should use abstract code from sound kernel, but it should use
own code and register minors separetely (with snd_minor_register and
snd_minor_unregister functions). This method totaly bypass all
abstract code, so code for these soundcards must handle all things.
11..33.. MMeemmoorryy aallllooccaattiioonn
+o vvooiidd **ssnndd__mmaalllloocc(( uunnssiiggnneedd lloonngg ssiizzee ))
+o vvooiidd ssnndd__ffrreeee(( vvooiidd **ppttrr,, uunnssiiggnneedd lloonngg ssiizzee ))
+o cchhaarr **ssnndd__mmaalllloocc__ssttrrdduupp(( cchhaarr **ssttrriinngg ))
+o vvooiidd ssnndd__ffrreeee__ssttrr(( cchhaarr **ssttrriinngg ))
These routines use their own memory allocation algoritm. It should be
removed in the future and replaced with kmalloc and kfree calls, but
for now I need to trace all allocation problems to make code clean...
Note: ALSA driver heavily uses dynamic allocation for most things.
For debugging you should use command './configure --with-debug=full'
for configuration. This enables trace of allocated memory with above
functions and this makes debugging a little bit easier.
11..44.. BBaassiicc ccooddiinngg
All things are made as objects (which encapsulates data and functions)
and are referenced in this way. I don't prefer to pass index to some
array of structure or something like this. Objects contain both data
and functions. Pointers to these objects are passed around (like
C++).
All main structures should have snd_xxxx_new, snd_xxxx_free,
snd_xxxx_register, snd_xxxx_unregister functions.
+o ssnndd__ccaarrdd__tt is a basic structure which contains info about a
soundcard, index and resource tracking variables. Look at
_i_n_c_l_u_d_e_/_d_r_i_v_e_r_._h for all things related to this structure.
+o ssnndd__ppccmm__tt is a basic structure for a PCM device.
+o ssnndd__ppccmm__cchhaannnneell__tt is a basic structure for a PCM channel
(direction).
+o ssttrruucctt ssnndd__ssttrruu__ppccmm__hhaarrddwwaarree is a structure which must be filled by
lowlevel code. Look at _i_n_c_l_u_d_e_/_p_c_m_._h for all things related to
these structures.
+o ssnndd__kkmmiixxeerr__tt is a basic structure for a MIXER device.
+o ssnndd__kkmmiixxeerr__cchhaannnneell__tt is a basic structure for a MIXER channel.
+o ssttrruucctt ssnndd__ssttrruu__mmiixxeerr__cchhaannnneell__hhww is a structure which must be
filled by lowlevel code. Look at _i_n_c_l_u_d_e_/_m_i_x_e_r_._h for all things
related to these structures.
11..55.. UUppppeerr lleevveell ((//ccaarrddss))
Code for soundcards should contain these things:
1. Support for more than one of the same soundcard (up to
SND_CARDS)...
+o it isn't really possible due to HW limitations
2. Autodetection/autoconfiguration feature (if it's possible)...
+o if lowlevel code is specific for soundcard type - it should be
here, too..
3. Initialization code for soundcard
+o snd_card_new
+o snd_card_free (frees all hardware resources)
4. Allocate/free hardware resources for soundcard
+o snd_register_ioport
+o snd_unregister_ioports (frees all ioports)
+o snd_register_interrupt
+o snd_unregister_interrupts (frees all interrupts)
+o snd_register_dma_channel
+o snd_unregister_dma_channels (frees all DMA channels)
5. Initialize other layers (PCMs, Mixers etc.)
+o snd_pcm_new
+o snd_pcm_free
+o snd_pcm_register
+o snd_pcm_unregister (calls snd_pcm_free)
+o snd_mixer_new
+o snd_mixer_free
+o snd_mixer_register
+o snd_mixer_unregister (calls snd_mixer_free)
6. Register soundcard
+o snd_card_register
+o snd_card_unregister (doesn't call snd_card_free)
NNoottee:: Due to module dependency you should separate code for soundcards
from the same manufacture which have slightly different hardware.
Example: The GUS Extreme has an ESS ES-1688 chip. This chip isn't in
the GUS Classic. For GUS Classic, the generic code in the snd-es1688.o
module isn't needed. So there are two upper level modules (snd-
gusextreme.o and snd-gusclassic.o).
11..66.. PPrriivvaattee ddaattaa//vvaalluueess
Some structures have pointers to private data and values. These
variables aren't used with the abstract layers and are intended for
low-level code use only.
______________________________________________________________________
snd_card_t -> private_data
snd_card_t -> private_free (called from snd_card_free if not NULL)
______________________________________________________________________
______________________________________________________________________
struct snd_stru_pcm_hardware -> private_data
struct snd_stru_pcm_hardware -> private_free (called from snd_pcm_free if not NULL)
snd_pcm_t -> private_data
snd_pcm_t -> private_free (called from snd_pcm_free if not NULL)
______________________________________________________________________
______________________________________________________________________
struct snd_stru_mixer_channel_hw -> private_value
snd_kmixer_channel_t -> private_data
snd_kmixer_channel_t -> private_free (called from snd_mixer_free if not NULL)
snd_kmixer_t -> private_value
snd_kmixer_t -> private_data
snd_kmixer_t -> private_free (called from snd_mixer_free if not NULL)
_______________________________________________________
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ALSA音频驱动源代码 (377个子文件)
patch.Makefile.2.2.10 521B
alsasound 3KB
buildrpm 645B
cs4236.c 80KB
cs4231.c 72KB
pcm1_native.c 68KB
s3_86c617.c 66KB
pcm1_oss.c 64KB
ac97_codec.c 63KB
seq_clientmgr.c 56KB
wavefront.c 55KB
ak4531_codec.c 54KB
es18xx.c 54KB
trident_dx_nx.c 54KB
isapnp_new.c 52KB
isapnp.c 49KB
ad1848.c 48KB
mixer_lib.c 47KB
ens1370.c 43KB
cs461x.c 43KB
mixer.c 42KB
es1688.c 39KB
wavefront_fx.c 36KB
gus_pcm.c 36KB
soundfont.c 36KB
mixer16.c 35KB
rawmidi.c 34KB
card-interwave.c 34KB
card-opti9xx.c 34KB
card-opl3sa2.c 33KB
emu8000_synth.c 32KB
card-wavefront.c 30KB
timer.c 29KB
es1938.c 29KB
sb16.c 28KB
uart16550_seq.c 27KB
info.c 27KB
card-dummy.c 26KB
hal2.c 26KB
card-sb16.c 24KB
isapnp_new_proc.c 24KB
isapnp_proc.c 22KB
uart16550.c 21KB
card-cs4236.c 21KB
seq_midi.c 20KB
gus_simple.c 20KB
card-cmi8330.c 20KB
seq_midi_emul.c 18KB
sound.c 18KB
sb16_csp.c 17KB
card-es18xx.c 17KB
seq_instr.c 17KB
card-gusextreme.c 17KB
ainstr_iw.c 17KB
gus_io.c 17KB
mixer8.c 17KB
pcm.c 16KB
seq_ports.c 16KB
fm801.c 15KB
control.c 15KB
sb8.c 15KB
card-sgalaxy.c 15KB
card-gusmax.c 14KB
seq_queue.c 14KB
emu8000_init.c 14KB
mixer_oss.c 14KB
init.c 13KB
card-als100.c 13KB
gus_mixer.c 13KB
gus_reset.c 13KB
wavefront_midi.c 13KB
gus_utils.c 12KB
gus_lfo.c 12KB
card-azt2320.c 12KB
midi.c 12KB
opl3.c 12KB
sound_oss.c 12KB
seq_oss_midi.c 12KB
seq_oss_init.c 12KB
tea6330t.c 12KB
card-gusclassic.c 12KB
seq_oss_event.c 11KB
gus.c 11KB
emu8000_nrpn.c 11KB
emu8000_oss.c 11KB
i2c.c 11KB
card-mozart.c 10KB
seq_memory.c 10KB
emu8000_equalizer.c 10KB
seq_oss_synth.c 10KB
seq_device.c 10KB
card-sonicvibes.c 10KB
gus_mem.c 10KB
pcm_proc.c 10KB
ainstr_gf1.c 10KB
card-es1688.c 10KB
emu8000.c 9KB
card-cs4231.c 9KB
midi_coder.c 9KB
card-ens1370.c 9KB
共 377 条
- 1
- 2
- 3
- 4
资源评论
- zhouxch20072012-04-05有各种驱动,程序挺多,要理解好还是得花一些时间的,程序风格挺好的
- 一路狂狂狂奔2014-03-26不错,表示对我有所帮助。如果需要了解更多,还需要自己去ALSA的官网上去慢慢看的,www.alsa-project.org.
- ChrysanYang2011-10-10里面各种驱动很全面,给了很好的参考,但是刚开始没有注意到帮助,所以饶了一些弯路。刚开始看alsa时候完全看不懂,缺少必要的指导文档。
Jewell.Yeh
- 粉丝: 31
- 资源: 54
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功