
The ALSA Driver API

The ALSA Driver API
This document is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any later version.
This document is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Table of Contents
1. Management of Cards and Devices......................................................................................................1
Card Managment................................................................................................................................1
snd_card_new ...........................................................................................................................1
snd_card_disconnect.................................................................................................................2
snd_card_free ...........................................................................................................................2
snd_card_free_in_thread ..........................................................................................................3
snd_card_register......................................................................................................................4
snd_component_add .................................................................................................................4
snd_card_file_add.....................................................................................................................5
snd_card_file_remove...............................................................................................................6
snd_power_wait........................................................................................................................7
snd_card_set_pm_callback.......................................................................................................8
snd_card_set_generic_pm_callback .........................................................................................8
Device Components ...........................................................................................................................9
snd_device_new......................................................................................................................10
snd_device_free......................................................................................................................10
snd_device_register ................................................................................................................11
KMOD and Device File Entries .......................................................................................................12
snd_request_card ....................................................................................................................12
snd_register_device ................................................................................................................13
snd_unregister_device ............................................................................................................14
Memory Management Helpers......................................... ................................................................15
snd_kmalloc_strdup................................................................................................................15
copy_to_user_fromio..............................................................................................................15
copy_from_user_toio..............................................................................................................16
snd_malloc_pages...................................................................................................................17
snd_free_pages .......................................................................................................................18
snd_dma_alloc_pages.............................................................................................................19
snd_dma_alloc_pages_fallback..............................................................................................19
snd_dma_free_pages ..............................................................................................................20
snd_dma_get_reserved_buf ....................................................................................................21
snd_dma_reserve_buf.............................................................................................................22
2. PCM API ..............................................................................................................................................24
PCM Core ........................................................................................................................................24
snd_pcm_new_stream ............................................................................................................24
snd_pcm_new .........................................................................................................................24
snd_pcm_set_ops....................................................................................................................25
snd_pcm_set_sync..................................................................................................................26
snd_interval_refine .................................................................................................................27
snd_interval_ratnum ...............................................................................................................28
snd_interval_list......................................................................................................................29
snd_pcm_hw_rule_add...........................................................................................................30
snd_pcm_hw_constraint_integer............................................................................................31
snd_pcm_hw_constraint_minmax..........................................................................................31
snd_pcm_hw_constraint_list ..................................................................................................32
iii

snd_pcm_hw_constraint_ratnums ..........................................................................................33
snd_pcm_hw_constraint_ratdens ...........................................................................................33
snd_pcm_hw_constraint_msbits.............................................................................................34
snd_pcm_hw_constraint_step.................................................................................................35
snd_pcm_hw_constraint_pow2 ..............................................................................................36
snd_pcm_hw_param_value_min............................................................................................37
snd_pcm_hw_param_value_max ...........................................................................................37
snd_pcm_hw_param_first.......................................................................................................38
snd_pcm_hw_param_last .......................................................................................................39
snd_pcm_hw_param_set ........................................................................................................40
snd_pcm_hw_param_mask ....................................................................................................41
snd_pcm_hw_param_near......................................................................................................42
snd_pcm_lib_ioctl ..................................................................................................................43
snd_pcm_period_elapsed .......................................................................................................44
snd_pcm_stop .........................................................................................................................44
snd_pcm_suspend...................................................................................................................45
snd_pcm_suspend_all.............................................................................................................46
PCM Format Helpers .......................................................................................................................46
snd_pcm_format_signed.........................................................................................................47
snd_pcm_format_unsigned.....................................................................................................47
snd_pcm_format_linear..........................................................................................................48
snd_pcm_format_little_endian ...............................................................................................48
snd_pcm_format_big_endian .................................................................................................49
snd_pcm_format_width..........................................................................................................50
snd_pcm_format_physical_width...........................................................................................50
snd_pcm_format_size.............................................................................................................51
snd_pcm_format_silence_64..................................................................................................52
snd_pcm_format_set_silence .................................................................................................52
snd_pcm_build_linear_format................................................................................................53
snd_pcm_limit_hw_rates........................................................................................................54
PCM Memory Managment ..............................................................................................................55
snd_pcm_lib_preallocate_free_for_all ...................................................................................55
snd_pcm_lib_preallocate_pages.............................................................................................56
snd_pcm_lib_preallocate_pages_for_all ................................................................................57
snd_pcm_sgbuf_ops_page......................................................................................................57
snd_pcm_lib_malloc_pages ...................................................................................................58
snd_pcm_lib_free_pages ........................................................................................................59
3. Control/Mixer API...............................................................................................................................61
General Control Interface ................................................. ................................................................61
snd_ctl_new............................................................................................................................61
snd_ctl_new1..........................................................................................................................61
snd_ctl_free_one.....................................................................................................................62
snd_ctl_add.............................................................................................................................63
snd_ctl_remove.......................................................................................................................64
snd_ctl_remove_id..................................................................................................................64
snd_ctl_rename_id..................................................................................................................65
snd_ctl_find_numid ........................................................................................ ........................66
iv

snd_ctl_find_id .................................................................................................... ...................67
AC97 Codec API..............................................................................................................................68
snd_ac97_write.......................................................................................................................68
snd_ac97_read ........................................................................................................................69
snd_ac97_write_cache............................................................................................................69
snd_ac97_update ....................................................................................................................70
snd_ac97_update_bits.............................................................................................................71
snd_ac97_get_short_name .....................................................................................................72
snd_ac97_bus..........................................................................................................................72
snd_ac97_mixer......................................................................................................................74
snd_ac97_suspend ..................................................................................................................74
snd_ac97_resume ...................................................................................................................75
snd_ac97_tune_hardware .......................................................................................................76
snd_ac97_set_rate...................................................................................................................77
snd_ac97_pcm_assign ............................................................................................................77
snd_ac97_pcm_open ..............................................................................................................78
snd_ac97_pcm_close..............................................................................................................79
snd_ac97_pcm_double_rate_rules .........................................................................................80
4. MIDI API..............................................................................................................................................81
Raw MIDI API.................................................................................................................................81
snd_rawmidi_receive..............................................................................................................81
snd_rawmidi_transmit_empty ................................................................................................81
snd_rawmidi_transmit_peek...................................................................................................82
snd_rawmidi_transmit_ack.....................................................................................................83
snd_rawmidi_transmit ............................................................................................................84
snd_rawmidi_new...................................................................................................................85
snd_rawmidi_set_ops .............................................................................................................86
MPU401-UART API........................................................................................................................86
snd_mpu401_uart_interrupt ...................................................................................................87
snd_mpu401_uart_new...........................................................................................................87
5. Proc Info API .......................................................................................................................................89
Proc Info Interface............................................................................................................................89
snd_iprintf...............................................................................................................................89
snd_info_get_line ...................................................................................................................89
snd_info_get_str .....................................................................................................................90
snd_info_create_module_entry ..............................................................................................91
snd_info_create_card_entry ...................................................................................................92
snd_card_proc_new................................................................................................................93
snd_info_free_entry................................................................................................................94
snd_info_register ....................................................................................................................94
snd_info_unregister ................................................................................................................95
6. Miscellaneous Functions .....................................................................................................................97
Hardware-Dependent Devices API ..................................................................................................97
snd_hwdep_new .....................................................................................................................97
ISA DMA Helpers ...........................................................................................................................98
snd_dma_program ..................................................................................................................98
snd_dma_disable ....................................................................................................................98
v
评论0