diff options
Diffstat (limited to 'Documentation/sound/alsa')
-rw-r--r-- | Documentation/sound/alsa/ALSA-Configuration.txt | 210 | ||||
-rw-r--r-- | Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 923 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/DAI.txt | 6 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/clocking.txt | 10 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/codec.txt | 53 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/dapm.txt | 51 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/machine.txt | 12 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/overview.txt | 42 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/platform.txt | 6 | ||||
-rw-r--r-- | Documentation/sound/alsa/soc/pops_clicks.txt | 10 |
10 files changed, 705 insertions, 618 deletions
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 4b48c2e82c3c..e985cf5e0410 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt | |||
@@ -57,7 +57,9 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
57 | - Default: 1 | 57 | - Default: 1 |
58 | - For auto-loading more than one card, specify this | 58 | - For auto-loading more than one card, specify this |
59 | option together with snd-card-X aliases. | 59 | option together with snd-card-X aliases. |
60 | 60 | slots - Reserve the slot index for the given driver. | |
61 | This option takes multiple strings. | ||
62 | See "Module Autoloading Support" section for details. | ||
61 | 63 | ||
62 | Module snd-pcm-oss | 64 | Module snd-pcm-oss |
63 | ------------------ | 65 | ------------------ |
@@ -148,13 +150,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
148 | 150 | ||
149 | Module for sound cards based on Analog Devices AD1816A/AD1815 ISA chips. | 151 | Module for sound cards based on Analog Devices AD1816A/AD1815 ISA chips. |
150 | 152 | ||
151 | port - port # for AD1816A chip (PnP setup) | ||
152 | mpu_port - port # for MPU-401 UART (PnP setup) | ||
153 | fm_port - port # for OPL3 (PnP setup) | ||
154 | irq - IRQ # for AD1816A chip (PnP setup) | ||
155 | mpu_irq - IRQ # for MPU-401 UART (PnP setup) | ||
156 | dma1 - first DMA # for AD1816A chip (PnP setup) | ||
157 | dma2 - second DMA # for AD1816A chip (PnP setup) | ||
158 | clockfreq - Clock frequency for AD1816A chip (default = 0, 33000Hz) | 153 | clockfreq - Clock frequency for AD1816A chip (default = 0, 33000Hz) |
159 | 154 | ||
160 | This module supports multiple cards, autoprobe and PnP. | 155 | This module supports multiple cards, autoprobe and PnP. |
@@ -201,14 +196,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
201 | 196 | ||
202 | Module for sound cards based on Avance Logic ALS100/ALS120 ISA chips. | 197 | Module for sound cards based on Avance Logic ALS100/ALS120 ISA chips. |
203 | 198 | ||
204 | port - port # for ALS100 (SB16) chip (PnP setup) | ||
205 | irq - IRQ # for ALS100 (SB16) chip (PnP setup) | ||
206 | dma8 - 8-bit DMA # for ALS100 (SB16) chip (PnP setup) | ||
207 | dma16 - 16-bit DMA # for ALS100 (SB16) chip (PnP setup) | ||
208 | mpu_port - port # for MPU-401 UART (PnP setup) | ||
209 | mpu_irq - IRQ # for MPU-401 (PnP setup) | ||
210 | fm_port - port # for OPL3 FM (PnP setup) | ||
211 | |||
212 | This module supports multiple cards, autoprobe and PnP. | 199 | This module supports multiple cards, autoprobe and PnP. |
213 | 200 | ||
214 | The power-management is supported. | 201 | The power-management is supported. |
@@ -302,15 +289,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
302 | 289 | ||
303 | Module for sound cards based on Aztech System AZT2320 ISA chip (PnP only). | 290 | Module for sound cards based on Aztech System AZT2320 ISA chip (PnP only). |
304 | 291 | ||
305 | port - port # for AZT2320 chip (PnP setup) | ||
306 | wss_port - port # for WSS (PnP setup) | ||
307 | mpu_port - port # for MPU-401 UART (PnP setup) | ||
308 | fm_port - FM port # for AZT2320 chip (PnP setup) | ||
309 | irq - IRQ # for AZT2320 (WSS) chip (PnP setup) | ||
310 | mpu_irq - IRQ # for MPU-401 UART (PnP setup) | ||
311 | dma1 - 1st DMA # for AZT2320 (WSS) chip (PnP setup) | ||
312 | dma2 - 2nd DMA # for AZT2320 (WSS) chip (PnP setup) | ||
313 | |||
314 | This module supports multiple cards, PnP and autoprobe. | 292 | This module supports multiple cards, PnP and autoprobe. |
315 | 293 | ||
316 | The power-management is supported. | 294 | The power-management is supported. |
@@ -350,6 +328,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
350 | 328 | ||
351 | Module for sound cards based on C-Media CMI8330 ISA chips. | 329 | Module for sound cards based on C-Media CMI8330 ISA chips. |
352 | 330 | ||
331 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
332 | |||
333 | with isapnp=0, the following options are available: | ||
334 | |||
353 | wssport - port # for CMI8330 chip (WSS) | 335 | wssport - port # for CMI8330 chip (WSS) |
354 | wssirq - IRQ # for CMI8330 chip (WSS) | 336 | wssirq - IRQ # for CMI8330 chip (WSS) |
355 | wssdma - first DMA # for CMI8330 chip (WSS) | 337 | wssdma - first DMA # for CMI8330 chip (WSS) |
@@ -404,6 +386,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
404 | 386 | ||
405 | Module for sound cards based on CS4232/CS4232A ISA chips. | 387 | Module for sound cards based on CS4232/CS4232A ISA chips. |
406 | 388 | ||
389 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
390 | |||
391 | with isapnp=0, the following options are available: | ||
392 | |||
407 | port - port # for CS4232 chip (PnP setup - 0x534) | 393 | port - port # for CS4232 chip (PnP setup - 0x534) |
408 | cport - control port # for CS4232 chip (PnP setup - 0x120,0x210,0xf00) | 394 | cport - control port # for CS4232 chip (PnP setup - 0x120,0x210,0xf00) |
409 | mpu_port - port # for MPU-401 UART (PnP setup - 0x300), -1 = disable | 395 | mpu_port - port # for MPU-401 UART (PnP setup - 0x300), -1 = disable |
@@ -412,10 +398,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
412 | mpu_irq - IRQ # for MPU-401 UART (9,11,12,15) | 398 | mpu_irq - IRQ # for MPU-401 UART (9,11,12,15) |
413 | dma1 - first DMA # for CS4232 chip (0,1,3) | 399 | dma1 - first DMA # for CS4232 chip (0,1,3) |
414 | dma2 - second DMA # for Yamaha CS4232 chip (0,1,3), -1 = disable | 400 | dma2 - second DMA # for Yamaha CS4232 chip (0,1,3), -1 = disable |
415 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
416 | 401 | ||
417 | This module supports multiple cards. This module does not support autoprobe | 402 | This module supports multiple cards. This module does not support autoprobe |
418 | thus main port must be specified!!! Other ports are optional. | 403 | (if ISA PnP is not used) thus main port must be specified!!! Other ports are |
404 | optional. | ||
419 | 405 | ||
420 | The power-management is supported. | 406 | The power-management is supported. |
421 | 407 | ||
@@ -425,6 +411,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
425 | Module for sound cards based on CS4235/CS4236/CS4236B/CS4237B/ | 411 | Module for sound cards based on CS4235/CS4236/CS4236B/CS4237B/ |
426 | CS4238B/CS4239 ISA chips. | 412 | CS4238B/CS4239 ISA chips. |
427 | 413 | ||
414 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
415 | |||
416 | with isapnp=0, the following options are available: | ||
417 | |||
428 | port - port # for CS4236 chip (PnP setup - 0x534) | 418 | port - port # for CS4236 chip (PnP setup - 0x534) |
429 | cport - control port # for CS4236 chip (PnP setup - 0x120,0x210,0xf00) | 419 | cport - control port # for CS4236 chip (PnP setup - 0x120,0x210,0xf00) |
430 | mpu_port - port # for MPU-401 UART (PnP setup - 0x300), -1 = disable | 420 | mpu_port - port # for MPU-401 UART (PnP setup - 0x300), -1 = disable |
@@ -433,7 +423,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
433 | mpu_irq - IRQ # for MPU-401 UART (9,11,12,15) | 423 | mpu_irq - IRQ # for MPU-401 UART (9,11,12,15) |
434 | dma1 - first DMA # for CS4236 chip (0,1,3) | 424 | dma1 - first DMA # for CS4236 chip (0,1,3) |
435 | dma2 - second DMA # for CS4236 chip (0,1,3), -1 = disable | 425 | dma2 - second DMA # for CS4236 chip (0,1,3), -1 = disable |
436 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
437 | 426 | ||
438 | This module supports multiple cards. This module does not support autoprobe | 427 | This module supports multiple cards. This module does not support autoprobe |
439 | (if ISA PnP is not used) thus main port and control port must be | 428 | (if ISA PnP is not used) thus main port and control port must be |
@@ -503,13 +492,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
503 | Module for Diamond Technologies DT-019X / Avance Logic ALS-007 (PnP | 492 | Module for Diamond Technologies DT-019X / Avance Logic ALS-007 (PnP |
504 | only) | 493 | only) |
505 | 494 | ||
506 | port - Port # (PnP setup) | ||
507 | mpu_port - Port # for MPU-401 (PnP setup) | ||
508 | fm_port - Port # for FM OPL-3 (PnP setup) | ||
509 | irq - IRQ # (PnP setup) | ||
510 | mpu_irq - IRQ # for MPU-401 (PnP setup) | ||
511 | dma8 - DMA # (PnP setup) | ||
512 | |||
513 | This module supports multiple cards. This module is enabled only with | 495 | This module supports multiple cards. This module is enabled only with |
514 | ISA PnP support. | 496 | ISA PnP support. |
515 | 497 | ||
@@ -607,10 +589,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
607 | 589 | ||
608 | Module for sound cards based on ESS ES968 chip (PnP only). | 590 | Module for sound cards based on ESS ES968 chip (PnP only). |
609 | 591 | ||
610 | port - port # for ES968 (SB8) chip (PnP setup) | ||
611 | irq - IRQ # for ES968 (SB8) chip (PnP setup) | ||
612 | dma1 - DMA # for ES968 (SB8) chip (PnP setup) | ||
613 | |||
614 | This module supports multiple cards, PnP and autoprobe. | 592 | This module supports multiple cards, PnP and autoprobe. |
615 | 593 | ||
616 | The power-management is supported. | 594 | The power-management is supported. |
@@ -633,13 +611,16 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
633 | 611 | ||
634 | Module for ESS AudioDrive ES-18xx sound cards. | 612 | Module for ESS AudioDrive ES-18xx sound cards. |
635 | 613 | ||
614 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
615 | |||
616 | with isapnp=0, the following options are available: | ||
617 | |||
636 | port - port # for ES-18xx chip (0x220,0x240,0x260) | 618 | port - port # for ES-18xx chip (0x220,0x240,0x260) |
637 | mpu_port - port # for MPU-401 port (0x300,0x310,0x320,0x330), -1 = disable (default) | 619 | mpu_port - port # for MPU-401 port (0x300,0x310,0x320,0x330), -1 = disable (default) |
638 | fm_port - port # for FM (optional, not used) | 620 | fm_port - port # for FM (optional, not used) |
639 | irq - IRQ # for ES-18xx chip (5,7,9,10) | 621 | irq - IRQ # for ES-18xx chip (5,7,9,10) |
640 | dma1 - first DMA # for ES-18xx chip (0,1,3) | 622 | dma1 - first DMA # for ES-18xx chip (0,1,3) |
641 | dma2 - first DMA # for ES-18xx chip (0,1,3) | 623 | dma2 - first DMA # for ES-18xx chip (0,1,3) |
642 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
643 | 624 | ||
644 | This module supports multiple cards, ISA PnP and autoprobe (without MPU-401 | 625 | This module supports multiple cards, ISA PnP and autoprobe (without MPU-401 |
645 | port if native ISA PnP routines are not used). | 626 | port if native ISA PnP routines are not used). |
@@ -763,9 +744,12 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
763 | VIA VT8251/VT8237A, | 744 | VIA VT8251/VT8237A, |
764 | SIS966, ULI M5461 | 745 | SIS966, ULI M5461 |
765 | 746 | ||
747 | [Multiple options for each card instance] | ||
766 | model - force the model name | 748 | model - force the model name |
767 | position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size) | 749 | position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size) |
768 | probe_mask - Bitmask to probe codecs (default = -1, meaning all slots) | 750 | probe_mask - Bitmask to probe codecs (default = -1, meaning all slots) |
751 | |||
752 | [Single (global) options] | ||
769 | single_cmd - Use single immediate commands to communicate with | 753 | single_cmd - Use single immediate commands to communicate with |
770 | codecs (for debugging only) | 754 | codecs (for debugging only) |
771 | enable_msi - Enable Message Signaled Interrupt (MSI) (default = off) | 755 | enable_msi - Enable Message Signaled Interrupt (MSI) (default = off) |
@@ -774,8 +758,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
774 | power_save_controller - Reset HD-audio controller in power-saving mode | 758 | power_save_controller - Reset HD-audio controller in power-saving mode |
775 | (default = on) | 759 | (default = on) |
776 | 760 | ||
777 | This module supports one card and autoprobe. | 761 | This module supports multiple cards and autoprobe. |
778 | 762 | ||
779 | Each codec may have a model table for different configurations. | 763 | Each codec may have a model table for different configurations. |
780 | If your machine isn't listed there, the default (usually minimal) | 764 | If your machine isn't listed there, the default (usually minimal) |
781 | configuration is set up. You can pass "model=<name>" option to | 765 | configuration is set up. You can pass "model=<name>" option to |
@@ -817,17 +801,23 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
817 | will Will laptops (PB V7900) | 801 | will Will laptops (PB V7900) |
818 | replacer Replacer 672V | 802 | replacer Replacer 672V |
819 | basic fixed pin assignment (old default model) | 803 | basic fixed pin assignment (old default model) |
804 | test for testing/debugging purpose, almost all controls can | ||
805 | adjusted. Appearing only when compiled with | ||
806 | $CONFIG_SND_DEBUG=y | ||
820 | auto auto-config reading BIOS (default) | 807 | auto auto-config reading BIOS (default) |
821 | 808 | ||
822 | ALC262 | 809 | ALC262 |
823 | fujitsu Fujitsu Laptop | 810 | fujitsu Fujitsu Laptop |
824 | hp-bpc HP xw4400/6400/8400/9400 laptops | 811 | hp-bpc HP xw4400/6400/8400/9400 laptops |
825 | hp-bpc-d7000 HP BPC D7000 | 812 | hp-bpc-d7000 HP BPC D7000 |
813 | hp-tc-t5735 HP Thin Client T5735 | ||
814 | hp-rp5700 HP RP5700 | ||
826 | benq Benq ED8 | 815 | benq Benq ED8 |
827 | benq-t31 Benq T31 | 816 | benq-t31 Benq T31 |
828 | hippo Hippo (ATI) with jack detection, Sony UX-90s | 817 | hippo Hippo (ATI) with jack detection, Sony UX-90s |
829 | hippo_1 Hippo (Benq) with jack detection | 818 | hippo_1 Hippo (Benq) with jack detection |
830 | sony-assamd Sony ASSAMD | 819 | sony-assamd Sony ASSAMD |
820 | ultra Samsung Q1 Ultra Vista model | ||
831 | basic fixed pin assignment w/o SPDIF | 821 | basic fixed pin assignment w/o SPDIF |
832 | auto auto-config reading BIOS (default) | 822 | auto auto-config reading BIOS (default) |
833 | 823 | ||
@@ -835,6 +825,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
835 | 3stack 3-stack model | 825 | 3stack 3-stack model |
836 | toshiba Toshiba A205 | 826 | toshiba Toshiba A205 |
837 | acer Acer laptops | 827 | acer Acer laptops |
828 | dell Dell OEM laptops (Vostro 1200) | ||
829 | test for testing/debugging purpose, almost all controls can | ||
830 | adjusted. Appearing only when compiled with | ||
831 | $CONFIG_SND_DEBUG=y | ||
838 | auto auto-config reading BIOS (default) | 832 | auto auto-config reading BIOS (default) |
839 | 833 | ||
840 | ALC662 | 834 | ALC662 |
@@ -843,6 +837,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
843 | 3stack-6ch-dig 3-stack (6-channel) with SPDIF | 837 | 3stack-6ch-dig 3-stack (6-channel) with SPDIF |
844 | 6stack-dig 6-stack with SPDIF | 838 | 6stack-dig 6-stack with SPDIF |
845 | lenovo-101e Lenovo laptop | 839 | lenovo-101e Lenovo laptop |
840 | eeepc-p701 ASUS Eeepc P701 | ||
841 | eeepc-ep20 ASUS Eeepc EP20 | ||
846 | auto auto-config reading BIOS (default) | 842 | auto auto-config reading BIOS (default) |
847 | 843 | ||
848 | ALC882/885 | 844 | ALC882/885 |
@@ -877,6 +873,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
877 | haier-w66 Haier W66 | 873 | haier-w66 Haier W66 |
878 | 6stack-hp HP machines with 6stack (Nettle boards) | 874 | 6stack-hp HP machines with 6stack (Nettle boards) |
879 | 3stack-hp HP machines with 3stack (Lucknow, Samba boards) | 875 | 3stack-hp HP machines with 3stack (Lucknow, Samba boards) |
876 | 6stack-dell Dell machines with 6stack (Inspiron 530) | ||
877 | mitac Mitac 8252D | ||
880 | auto auto-config reading BIOS (default) | 878 | auto auto-config reading BIOS (default) |
881 | 879 | ||
882 | ALC861/660 | 880 | ALC861/660 |
@@ -928,6 +926,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
928 | AD1984 | 926 | AD1984 |
929 | basic default configuration | 927 | basic default configuration |
930 | thinkpad Lenovo Thinkpad T61/X61 | 928 | thinkpad Lenovo Thinkpad T61/X61 |
929 | dell Dell T3400 | ||
931 | 930 | ||
932 | AD1986A | 931 | AD1986A |
933 | 6stack 6-jack, separate surrounds (default) | 932 | 6stack 6-jack, separate surrounds (default) |
@@ -947,7 +946,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
947 | auto auto-config reading BIOS (default) | 946 | auto auto-config reading BIOS (default) |
948 | 947 | ||
949 | Conexant 5045 | 948 | Conexant 5045 |
950 | laptop Laptop config | 949 | laptop-hpsense Laptop with HP sense (old model laptop) |
950 | laptop-micsense Laptop with Mic sense (old model fujitsu) | ||
951 | laptop-hpmicsense Laptop with HP and Mic senses | ||
952 | benq Benq R55E | ||
951 | test for testing/debugging purpose, almost all controls | 953 | test for testing/debugging purpose, almost all controls |
952 | can be adjusted. Appearing only when compiled with | 954 | can be adjusted. Appearing only when compiled with |
953 | $CONFIG_SND_DEBUG=y | 955 | $CONFIG_SND_DEBUG=y |
@@ -960,6 +962,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
960 | can be adjusted. Appearing only when compiled with | 962 | can be adjusted. Appearing only when compiled with |
961 | $CONFIG_SND_DEBUG=y | 963 | $CONFIG_SND_DEBUG=y |
962 | 964 | ||
965 | Conexant 5051 | ||
966 | laptop Basic Laptop config (default) | ||
967 | hp HP Spartan laptop | ||
968 | |||
963 | STAC9200 | 969 | STAC9200 |
964 | ref Reference board | 970 | ref Reference board |
965 | dell-d21 Dell (unknown) | 971 | dell-d21 Dell (unknown) |
@@ -1091,6 +1097,15 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1091 | 1097 | ||
1092 | See hdspm.txt for details. | 1098 | See hdspm.txt for details. |
1093 | 1099 | ||
1100 | Module snd-hifier | ||
1101 | ----------------- | ||
1102 | |||
1103 | Module for the MediaTek/TempoTec HiFier Fantasia sound card. | ||
1104 | |||
1105 | This module supports autoprobe and multiple cards. | ||
1106 | |||
1107 | Power management is _not_ supported. | ||
1108 | |||
1094 | Module snd-ice1712 | 1109 | Module snd-ice1712 |
1095 | ------------------ | 1110 | ------------------ |
1096 | 1111 | ||
@@ -1156,11 +1171,14 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1156 | * Chaintech 9CJS | 1171 | * Chaintech 9CJS |
1157 | * Chaintech AV-710 | 1172 | * Chaintech AV-710 |
1158 | * Shuttle SN25P | 1173 | * Shuttle SN25P |
1174 | * Onkyo SE-90PCI | ||
1175 | * Onkyo SE-200PCI | ||
1159 | 1176 | ||
1160 | model - Use the given board model, one of the following: | 1177 | model - Use the given board model, one of the following: |
1161 | revo51, revo71, amp2000, prodigy71, prodigy71lt, | 1178 | revo51, revo71, amp2000, prodigy71, prodigy71lt, |
1162 | prodigy192, aureon51, aureon71, universe, ap192, | 1179 | prodigy192, aureon51, aureon71, universe, ap192, |
1163 | k8x800, phase22, phase28, ms300, av710 | 1180 | k8x800, phase22, phase28, ms300, av710, se200pci, |
1181 | se90pci | ||
1164 | 1182 | ||
1165 | This module supports multiple cards and autoprobe. | 1183 | This module supports multiple cards and autoprobe. |
1166 | 1184 | ||
@@ -1257,15 +1275,19 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1257 | Module for Gravis UltraSound PnP, Dynasonic 3-D/Pro, STB Sound Rage 32 | 1275 | Module for Gravis UltraSound PnP, Dynasonic 3-D/Pro, STB Sound Rage 32 |
1258 | and other sound cards based on AMD InterWave (tm) chip. | 1276 | and other sound cards based on AMD InterWave (tm) chip. |
1259 | 1277 | ||
1260 | port - port # for InterWave chip (0x210,0x220,0x230,0x240,0x250,0x260) | ||
1261 | irq - IRQ # for InterWave chip (3,5,9,11,12,15) | ||
1262 | dma1 - DMA # for InterWave chip (0,1,3,5,6,7) | ||
1263 | dma2 - DMA # for InterWave chip (0,1,3,5,6,7,-1=disable) | ||
1264 | joystick_dac - 0 to 31, (0.59V-4.52V or 0.389V-2.98V) | 1278 | joystick_dac - 0 to 31, (0.59V-4.52V or 0.389V-2.98V) |
1265 | midi - 1 = MIDI UART enable, 0 = MIDI UART disable (default) | 1279 | midi - 1 = MIDI UART enable, 0 = MIDI UART disable (default) |
1266 | pcm_voices - reserved PCM voices for the synthesizer (default 2) | 1280 | pcm_voices - reserved PCM voices for the synthesizer (default 2) |
1267 | effect - 1 = InterWave effects enable (default 0); | 1281 | effect - 1 = InterWave effects enable (default 0); |
1268 | requires 8 voices | 1282 | requires 8 voices |
1283 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1284 | |||
1285 | with isapnp=0, the following options are available: | ||
1286 | |||
1287 | port - port # for InterWave chip (0x210,0x220,0x230,0x240,0x250,0x260) | ||
1288 | irq - IRQ # for InterWave chip (3,5,9,11,12,15) | ||
1289 | dma1 - DMA # for InterWave chip (0,1,3,5,6,7) | ||
1290 | dma2 - DMA # for InterWave chip (0,1,3,5,6,7,-1=disable) | ||
1269 | 1291 | ||
1270 | This module supports multiple cards, autoprobe and ISA PnP. | 1292 | This module supports multiple cards, autoprobe and ISA PnP. |
1271 | 1293 | ||
@@ -1276,16 +1298,20 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1276 | and other sound cards based on AMD InterWave (tm) chip with TEA6330T | 1298 | and other sound cards based on AMD InterWave (tm) chip with TEA6330T |
1277 | circuit for extended control of bass, treble and master volume. | 1299 | circuit for extended control of bass, treble and master volume. |
1278 | 1300 | ||
1279 | port - port # for InterWave chip (0x210,0x220,0x230,0x240,0x250,0x260) | ||
1280 | port_tc - tone control (i2c bus) port # for TEA6330T chip (0x350,0x360,0x370,0x380) | ||
1281 | irq - IRQ # for InterWave chip (3,5,9,11,12,15) | ||
1282 | dma1 - DMA # for InterWave chip (0,1,3,5,6,7) | ||
1283 | dma2 - DMA # for InterWave chip (0,1,3,5,6,7,-1=disable) | ||
1284 | joystick_dac - 0 to 31, (0.59V-4.52V or 0.389V-2.98V) | 1301 | joystick_dac - 0 to 31, (0.59V-4.52V or 0.389V-2.98V) |
1285 | midi - 1 = MIDI UART enable, 0 = MIDI UART disable (default) | 1302 | midi - 1 = MIDI UART enable, 0 = MIDI UART disable (default) |
1286 | pcm_voices - reserved PCM voices for the synthesizer (default 2) | 1303 | pcm_voices - reserved PCM voices for the synthesizer (default 2) |
1287 | effect - 1 = InterWave effects enable (default 0); | 1304 | effect - 1 = InterWave effects enable (default 0); |
1288 | requires 8 voices | 1305 | requires 8 voices |
1306 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1307 | |||
1308 | with isapnp=0, the following options are available: | ||
1309 | |||
1310 | port - port # for InterWave chip (0x210,0x220,0x230,0x240,0x250,0x260) | ||
1311 | port_tc - tone control (i2c bus) port # for TEA6330T chip (0x350,0x360,0x370,0x380) | ||
1312 | irq - IRQ # for InterWave chip (3,5,9,11,12,15) | ||
1313 | dma1 - DMA # for InterWave chip (0,1,3,5,6,7) | ||
1314 | dma2 - DMA # for InterWave chip (0,1,3,5,6,7,-1=disable) | ||
1289 | 1315 | ||
1290 | This module supports multiple cards, autoprobe and ISA PnP. | 1316 | This module supports multiple cards, autoprobe and ISA PnP. |
1291 | 1317 | ||
@@ -1473,6 +1499,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1473 | 1499 | ||
1474 | Module for Yamaha OPL3-SA2/SA3 sound cards. | 1500 | Module for Yamaha OPL3-SA2/SA3 sound cards. |
1475 | 1501 | ||
1502 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1503 | |||
1504 | with isapnp=0, the following options are available: | ||
1505 | |||
1476 | port - control port # for OPL3-SA chip (0x370) | 1506 | port - control port # for OPL3-SA chip (0x370) |
1477 | sb_port - SB port # for OPL3-SA chip (0x220,0x240) | 1507 | sb_port - SB port # for OPL3-SA chip (0x220,0x240) |
1478 | wss_port - WSS port # for OPL3-SA chip (0x530,0xe80,0xf40,0x604) | 1508 | wss_port - WSS port # for OPL3-SA chip (0x530,0xe80,0xf40,0x604) |
@@ -1481,7 +1511,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1481 | irq - IRQ # for OPL3-SA chip (5,7,9,10) | 1511 | irq - IRQ # for OPL3-SA chip (5,7,9,10) |
1482 | dma1 - first DMA # for Yamaha OPL3-SA chip (0,1,3) | 1512 | dma1 - first DMA # for Yamaha OPL3-SA chip (0,1,3) |
1483 | dma2 - second DMA # for Yamaha OPL3-SA chip (0,1,3), -1 = disable | 1513 | dma2 - second DMA # for Yamaha OPL3-SA chip (0,1,3), -1 = disable |
1484 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1485 | 1514 | ||
1486 | This module supports multiple cards and ISA PnP. It does not support | 1515 | This module supports multiple cards and ISA PnP. It does not support |
1487 | autoprobe (if ISA PnP is not used) thus all ports must be specified!!! | 1516 | autoprobe (if ISA PnP is not used) thus all ports must be specified!!! |
@@ -1494,6 +1523,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1494 | Module for sound cards based on OPTi 82c92x and Analog Devices AD1848 chips. | 1523 | Module for sound cards based on OPTi 82c92x and Analog Devices AD1848 chips. |
1495 | Module works with OAK Mozart cards as well. | 1524 | Module works with OAK Mozart cards as well. |
1496 | 1525 | ||
1526 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1527 | |||
1528 | with isapnp=0, the following options are available: | ||
1529 | |||
1497 | port - port # for WSS chip (0x530,0xe80,0xf40,0x604) | 1530 | port - port # for WSS chip (0x530,0xe80,0xf40,0x604) |
1498 | mpu_port - port # for MPU-401 UART (0x300,0x310,0x320,0x330) | 1531 | mpu_port - port # for MPU-401 UART (0x300,0x310,0x320,0x330) |
1499 | fm_port - port # for OPL3 device (0x388) | 1532 | fm_port - port # for OPL3 device (0x388) |
@@ -1508,6 +1541,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1508 | 1541 | ||
1509 | Module for sound cards based on OPTi 82c92x and Crystal CS4231 chips. | 1542 | Module for sound cards based on OPTi 82c92x and Crystal CS4231 chips. |
1510 | 1543 | ||
1544 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1545 | |||
1546 | with isapnp=0, the following options are available: | ||
1547 | |||
1511 | port - port # for WSS chip (0x530,0xe80,0xf40,0x604) | 1548 | port - port # for WSS chip (0x530,0xe80,0xf40,0x604) |
1512 | mpu_port - port # for MPU-401 UART (0x300,0x310,0x320,0x330) | 1549 | mpu_port - port # for MPU-401 UART (0x300,0x310,0x320,0x330) |
1513 | fm_port - port # for OPL3 device (0x388) | 1550 | fm_port - port # for OPL3 device (0x388) |
@@ -1523,6 +1560,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1523 | 1560 | ||
1524 | Module for sound cards based on OPTi 82c93x chips. | 1561 | Module for sound cards based on OPTi 82c93x chips. |
1525 | 1562 | ||
1563 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1564 | |||
1565 | with isapnp=0, the following options are available: | ||
1566 | |||
1526 | port - port # for WSS chip (0x530,0xe80,0xf40,0x604) | 1567 | port - port # for WSS chip (0x530,0xe80,0xf40,0x604) |
1527 | mpu_port - port # for MPU-401 UART (0x300,0x310,0x320,0x330) | 1568 | mpu_port - port # for MPU-401 UART (0x300,0x310,0x320,0x330) |
1528 | fm_port - port # for OPL3 device (0x388) | 1569 | fm_port - port # for OPL3 device (0x388) |
@@ -1533,6 +1574,22 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1533 | 1574 | ||
1534 | This module supports only one card, autoprobe and PnP. | 1575 | This module supports only one card, autoprobe and PnP. |
1535 | 1576 | ||
1577 | Module snd-oxygen | ||
1578 | ----------------- | ||
1579 | |||
1580 | Module for sound cards based on the C-Media CMI8788 chip: | ||
1581 | * Asound A-8788 | ||
1582 | * AuzenTech X-Meridian | ||
1583 | * Bgears b-Enspirer | ||
1584 | * Club3D Theatron DTS | ||
1585 | * HT-Omega Claro | ||
1586 | * Razer Barracuda AC-1 | ||
1587 | * Sondigo Inferno | ||
1588 | |||
1589 | This module supports autoprobe and multiple cards. | ||
1590 | |||
1591 | Power management is _not_ supported. | ||
1592 | |||
1536 | Module snd-pcxhr | 1593 | Module snd-pcxhr |
1537 | ---------------- | 1594 | ---------------- |
1538 | 1595 | ||
@@ -1647,6 +1704,12 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1647 | SoundBlaster AWE 32 (PnP), | 1704 | SoundBlaster AWE 32 (PnP), |
1648 | SoundBlaster AWE 64 PnP | 1705 | SoundBlaster AWE 64 PnP |
1649 | 1706 | ||
1707 | mic_agc - Mic Auto-Gain-Control - 0 = disable, 1 = enable (default) | ||
1708 | csp - ASP/CSP chip support - 0 = disable (default), 1 = enable | ||
1709 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1710 | |||
1711 | with isapnp=0, the following options are available: | ||
1712 | |||
1650 | port - port # for SB DSP 4.x chip (0x220,0x240,0x260) | 1713 | port - port # for SB DSP 4.x chip (0x220,0x240,0x260) |
1651 | mpu_port - port # for MPU-401 UART (0x300,0x330), -1 = disable | 1714 | mpu_port - port # for MPU-401 UART (0x300,0x330), -1 = disable |
1652 | awe_port - base port # for EMU8000 synthesizer (0x620,0x640,0x660) | 1715 | awe_port - base port # for EMU8000 synthesizer (0x620,0x640,0x660) |
@@ -1654,9 +1717,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1654 | irq - IRQ # for SB DSP 4.x chip (5,7,9,10) | 1717 | irq - IRQ # for SB DSP 4.x chip (5,7,9,10) |
1655 | dma8 - 8-bit DMA # for SB DSP 4.x chip (0,1,3) | 1718 | dma8 - 8-bit DMA # for SB DSP 4.x chip (0,1,3) |
1656 | dma16 - 16-bit DMA # for SB DSP 4.x chip (5,6,7) | 1719 | dma16 - 16-bit DMA # for SB DSP 4.x chip (5,6,7) |
1657 | mic_agc - Mic Auto-Gain-Control - 0 = disable, 1 = enable (default) | ||
1658 | csp - ASP/CSP chip support - 0 = disable (default), 1 = enable | ||
1659 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1660 | 1720 | ||
1661 | This module supports multiple cards, autoprobe and ISA PnP. | 1721 | This module supports multiple cards, autoprobe and ISA PnP. |
1662 | 1722 | ||
@@ -1739,18 +1799,21 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1739 | 1799 | ||
1740 | Module for Turtle Beach Maui, Tropez and Tropez+ sound cards. | 1800 | Module for Turtle Beach Maui, Tropez and Tropez+ sound cards. |
1741 | 1801 | ||
1802 | use_cs4232_midi - Use CS4232 MPU-401 interface | ||
1803 | (inaccessibly located inside your computer) | ||
1804 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1805 | |||
1806 | with isapnp=0, the following options are available: | ||
1807 | |||
1742 | cs4232_pcm_port - Port # for CS4232 PCM interface. | 1808 | cs4232_pcm_port - Port # for CS4232 PCM interface. |
1743 | cs4232_pcm_irq - IRQ # for CS4232 PCM interface (5,7,9,11,12,15). | 1809 | cs4232_pcm_irq - IRQ # for CS4232 PCM interface (5,7,9,11,12,15). |
1744 | cs4232_mpu_port - Port # for CS4232 MPU-401 interface. | 1810 | cs4232_mpu_port - Port # for CS4232 MPU-401 interface. |
1745 | cs4232_mpu_irq - IRQ # for CS4232 MPU-401 interface (9,11,12,15). | 1811 | cs4232_mpu_irq - IRQ # for CS4232 MPU-401 interface (9,11,12,15). |
1746 | use_cs4232_midi - Use CS4232 MPU-401 interface | ||
1747 | (inaccessibly located inside your computer) | ||
1748 | ics2115_port - Port # for ICS2115 | 1812 | ics2115_port - Port # for ICS2115 |
1749 | ics2115_irq - IRQ # for ICS2115 | 1813 | ics2115_irq - IRQ # for ICS2115 |
1750 | fm_port - FM OPL-3 Port # | 1814 | fm_port - FM OPL-3 Port # |
1751 | dma1 - DMA1 # for CS4232 PCM interface. | 1815 | dma1 - DMA1 # for CS4232 PCM interface. |
1752 | dma2 - DMA2 # for CS4232 PCM interface. | 1816 | dma2 - DMA2 # for CS4232 PCM interface. |
1753 | isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) | ||
1754 | 1817 | ||
1755 | The below are options for wavefront_synth features: | 1818 | The below are options for wavefront_synth features: |
1756 | wf_raw - Assume that we need to boot the OS (default:no) | 1819 | wf_raw - Assume that we need to boot the OS (default:no) |
@@ -1965,6 +2028,16 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
1965 | 2028 | ||
1966 | This module supports multiple cards. | 2029 | This module supports multiple cards. |
1967 | 2030 | ||
2031 | Module snd-virtuoso | ||
2032 | ------------------- | ||
2033 | |||
2034 | Module for sound cards based on the Asus AV200 chip, i.e., | ||
2035 | Xonar D2 and Xonar D2X. | ||
2036 | |||
2037 | This module supports autoprobe and multiple cards. | ||
2038 | |||
2039 | Power management is _not_ supported. | ||
2040 | |||
1968 | Module snd-vx222 | 2041 | Module snd-vx222 |
1969 | ---------------- | 2042 | ---------------- |
1970 | 2043 | ||
@@ -2135,6 +2208,23 @@ alias sound-slot-1 snd-ens1371 | |||
2135 | In this example, the interwave card is always loaded as the first card | 2208 | In this example, the interwave card is always loaded as the first card |
2136 | (index 0) and ens1371 as the second (index 1). | 2209 | (index 0) and ens1371 as the second (index 1). |
2137 | 2210 | ||
2211 | Alternative (and new) way to fixate the slot assignment is to use | ||
2212 | "slots" option of snd module. In the case above, specify like the | ||
2213 | following: | ||
2214 | |||
2215 | options snd slots=snd-interwave,snd-ens1371 | ||
2216 | |||
2217 | Then, the first slot (#0) is reserved for snd-interwave driver, and | ||
2218 | the second (#1) for snd-ens1371. You can omit index option in each | ||
2219 | driver if slots option is used (although you can still have them at | ||
2220 | the same time as long as they don't conflict). | ||
2221 | |||
2222 | The slots option is especially useful for avoiding the possible | ||
2223 | hot-plugging and the resultant slot conflict. For example, in the | ||
2224 | case above again, the first two slots are already reserved. If any | ||
2225 | other driver (e.g. snd-usb-audio) is loaded before snd-interwave or | ||
2226 | snd-ens1371, it will be assigned to the third or later slot. | ||
2227 | |||
2138 | 2228 | ||
2139 | ALSA PCM devices to OSS devices mapping | 2229 | ALSA PCM devices to OSS devices mapping |
2140 | ======================================= | 2230 | ======================================= |
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index 2c3fc3cb3b6b..b03df4d4795c 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl | |||
@@ -18,7 +18,7 @@ | |||
18 | </affiliation> | 18 | </affiliation> |
19 | </author> | 19 | </author> |
20 | 20 | ||
21 | <date>September 10, 2007</date> | 21 | <date>Oct 15, 2007</date> |
22 | <edition>0.3.7</edition> | 22 | <edition>0.3.7</edition> |
23 | 23 | ||
24 | <abstract> | 24 | <abstract> |
@@ -67,7 +67,7 @@ | |||
67 | This document describes how to write an | 67 | This document describes how to write an |
68 | <ulink url="http://www.alsa-project.org/"><citetitle> | 68 | <ulink url="http://www.alsa-project.org/"><citetitle> |
69 | ALSA (Advanced Linux Sound Architecture)</citetitle></ulink> | 69 | ALSA (Advanced Linux Sound Architecture)</citetitle></ulink> |
70 | driver. The document focuses mainly on the PCI soundcard. | 70 | driver. The document focuses mainly on PCI soundcards. |
71 | In the case of other device types, the API might | 71 | In the case of other device types, the API might |
72 | be different, too. However, at least the ALSA kernel API is | 72 | be different, too. However, at least the ALSA kernel API is |
73 | consistent, and therefore it would be still a bit help for | 73 | consistent, and therefore it would be still a bit help for |
@@ -75,23 +75,23 @@ | |||
75 | </para> | 75 | </para> |
76 | 76 | ||
77 | <para> | 77 | <para> |
78 | The target of this document is ones who already have enough | 78 | This document targets people who already have enough |
79 | skill of C language and have the basic knowledge of linux | 79 | C language skills and have basic linux kernel programming |
80 | kernel programming. This document doesn't explain the general | 80 | knowledge. This document doesn't explain the general |
81 | topics of linux kernel codes and doesn't cover the detail of | 81 | topic of linux kernel coding and doesn't cover low-level |
82 | implementation of each low-level driver. It describes only how is | 82 | driver implementation details. It only describes |
83 | the standard way to write a PCI sound driver on ALSA. | 83 | the standard way to write a PCI sound driver on ALSA. |
84 | </para> | 84 | </para> |
85 | 85 | ||
86 | <para> | 86 | <para> |
87 | If you are already familiar with the older ALSA ver.0.5.x, you | 87 | If you are already familiar with the older ALSA ver.0.5.x API, you |
88 | can check the drivers such as <filename>es1938.c</filename> or | 88 | can check the drivers such as <filename>sound/pci/es1938.c</filename> or |
89 | <filename>maestro3.c</filename> which have also almost the same | 89 | <filename>sound/pci/maestro3.c</filename> which have also almost the same |
90 | code-base in the ALSA 0.5.x tree, so you can compare the differences. | 90 | code-base in the ALSA 0.5.x tree, so you can compare the differences. |
91 | </para> | 91 | </para> |
92 | 92 | ||
93 | <para> | 93 | <para> |
94 | This document is still a draft version. Any feedbacks and | 94 | This document is still a draft version. Any feedback and |
95 | corrections, please!! | 95 | corrections, please!! |
96 | </para> | 96 | </para> |
97 | </preface> | 97 | </preface> |
@@ -106,7 +106,7 @@ | |||
106 | <section id="file-tree-general"> | 106 | <section id="file-tree-general"> |
107 | <title>General</title> | 107 | <title>General</title> |
108 | <para> | 108 | <para> |
109 | The ALSA drivers are provided in the two ways. | 109 | The ALSA drivers are provided in two ways. |
110 | </para> | 110 | </para> |
111 | 111 | ||
112 | <para> | 112 | <para> |
@@ -114,15 +114,14 @@ | |||
114 | ALSA's ftp site, and another is the 2.6 (or later) Linux kernel | 114 | ALSA's ftp site, and another is the 2.6 (or later) Linux kernel |
115 | tree. To synchronize both, the ALSA driver tree is split into | 115 | tree. To synchronize both, the ALSA driver tree is split into |
116 | two different trees: alsa-kernel and alsa-driver. The former | 116 | two different trees: alsa-kernel and alsa-driver. The former |
117 | contains purely the source codes for the Linux 2.6 (or later) | 117 | contains purely the source code for the Linux 2.6 (or later) |
118 | tree. This tree is designed only for compilation on 2.6 or | 118 | tree. This tree is designed only for compilation on 2.6 or |
119 | later environment. The latter, alsa-driver, contains many subtle | 119 | later environment. The latter, alsa-driver, contains many subtle |
120 | files for compiling the ALSA driver on the outside of Linux | 120 | files for compiling ALSA drivers outside of the Linux kernel tree, |
121 | kernel like configure script, the wrapper functions for older, | 121 | wrapper functions for older 2.2 and 2.4 kernels, to adapt the latest kernel API, |
122 | 2.2 and 2.4 kernels, to adapt the latest kernel API, | ||
123 | and additional drivers which are still in development or in | 122 | and additional drivers which are still in development or in |
124 | tests. The drivers in alsa-driver tree will be moved to | 123 | tests. The drivers in alsa-driver tree will be moved to |
125 | alsa-kernel (eventually 2.6 kernel tree) once when they are | 124 | alsa-kernel (and eventually to the 2.6 kernel tree) when they are |
126 | finished and confirmed to work fine. | 125 | finished and confirmed to work fine. |
127 | </para> | 126 | </para> |
128 | 127 | ||
@@ -168,7 +167,7 @@ | |||
168 | <section id="file-tree-core-directory"> | 167 | <section id="file-tree-core-directory"> |
169 | <title>core directory</title> | 168 | <title>core directory</title> |
170 | <para> | 169 | <para> |
171 | This directory contains the middle layer, that is, the heart | 170 | This directory contains the middle layer which is the heart |
172 | of ALSA drivers. In this directory, the native ALSA modules are | 171 | of ALSA drivers. In this directory, the native ALSA modules are |
173 | stored. The sub-directories contain different modules and are | 172 | stored. The sub-directories contain different modules and are |
174 | dependent upon the kernel config. | 173 | dependent upon the kernel config. |
@@ -181,7 +180,7 @@ | |||
181 | The codes for PCM and mixer OSS emulation modules are stored | 180 | The codes for PCM and mixer OSS emulation modules are stored |
182 | in this directory. The rawmidi OSS emulation is included in | 181 | in this directory. The rawmidi OSS emulation is included in |
183 | the ALSA rawmidi code since it's quite small. The sequencer | 182 | the ALSA rawmidi code since it's quite small. The sequencer |
184 | code is stored in core/seq/oss directory (see | 183 | code is stored in <filename>core/seq/oss</filename> directory (see |
185 | <link linkend="file-tree-core-directory-seq-oss"><citetitle> | 184 | <link linkend="file-tree-core-directory-seq-oss"><citetitle> |
186 | below</citetitle></link>). | 185 | below</citetitle></link>). |
187 | </para> | 186 | </para> |
@@ -200,7 +199,7 @@ | |||
200 | <section id="file-tree-core-directory-seq"> | 199 | <section id="file-tree-core-directory-seq"> |
201 | <title>core/seq</title> | 200 | <title>core/seq</title> |
202 | <para> | 201 | <para> |
203 | This and its sub-directories are for the ALSA | 202 | This directory and its sub-directories are for the ALSA |
204 | sequencer. This directory contains the sequencer core and | 203 | sequencer. This directory contains the sequencer core and |
205 | primary sequencer modules such like snd-seq-midi, | 204 | primary sequencer modules such like snd-seq-midi, |
206 | snd-seq-virmidi, etc. They are compiled only when | 205 | snd-seq-virmidi, etc. They are compiled only when |
@@ -229,22 +228,22 @@ | |||
229 | <title>include directory</title> | 228 | <title>include directory</title> |
230 | <para> | 229 | <para> |
231 | This is the place for the public header files of ALSA drivers, | 230 | This is the place for the public header files of ALSA drivers, |
232 | which are to be exported to the user-space, or included by | 231 | which are to be exported to user-space, or included by |
233 | several files at different directories. Basically, the private | 232 | several files at different directories. Basically, the private |
234 | header files should not be placed in this directory, but you may | 233 | header files should not be placed in this directory, but you may |
235 | still find files there, due to historical reason :) | 234 | still find files there, due to historical reasons :) |
236 | </para> | 235 | </para> |
237 | </section> | 236 | </section> |
238 | 237 | ||
239 | <section id="file-tree-drivers-directory"> | 238 | <section id="file-tree-drivers-directory"> |
240 | <title>drivers directory</title> | 239 | <title>drivers directory</title> |
241 | <para> | 240 | <para> |
242 | This directory contains the codes shared among different drivers | 241 | This directory contains code shared among different drivers |
243 | on the different architectures. They are hence supposed not to be | 242 | on different architectures. They are hence supposed not to be |
244 | architecture-specific. | 243 | architecture-specific. |
245 | For example, the dummy pcm driver and the serial MIDI | 244 | For example, the dummy pcm driver and the serial MIDI |
246 | driver are found in this directory. In the sub-directories, | 245 | driver are found in this directory. In the sub-directories, |
247 | there are the codes for components which are independent from | 246 | there is code for components which are independent from |
248 | bus and cpu architectures. | 247 | bus and cpu architectures. |
249 | </para> | 248 | </para> |
250 | 249 | ||
@@ -271,7 +270,7 @@ | |||
271 | 270 | ||
272 | <para> | 271 | <para> |
273 | Although there is a standard i2c layer on Linux, ALSA has its | 272 | Although there is a standard i2c layer on Linux, ALSA has its |
274 | own i2c codes for some cards, because the soundcard needs only a | 273 | own i2c code for some cards, because the soundcard needs only a |
275 | simple operation and the standard i2c API is too complicated for | 274 | simple operation and the standard i2c API is too complicated for |
276 | such a purpose. | 275 | such a purpose. |
277 | </para> | 276 | </para> |
@@ -292,28 +291,28 @@ | |||
292 | 291 | ||
293 | <para> | 292 | <para> |
294 | So far, there is only Emu8000/Emu10k1 synth driver under | 293 | So far, there is only Emu8000/Emu10k1 synth driver under |
295 | synth/emux sub-directory. | 294 | the <filename>synth/emux</filename> sub-directory. |
296 | </para> | 295 | </para> |
297 | </section> | 296 | </section> |
298 | 297 | ||
299 | <section id="file-tree-pci-directory"> | 298 | <section id="file-tree-pci-directory"> |
300 | <title>pci directory</title> | 299 | <title>pci directory</title> |
301 | <para> | 300 | <para> |
302 | This and its sub-directories hold the top-level card modules | 301 | This directory and its sub-directories hold the top-level card modules |
303 | for PCI soundcards and the codes specific to the PCI BUS. | 302 | for PCI soundcards and the code specific to the PCI BUS. |
304 | </para> | 303 | </para> |
305 | 304 | ||
306 | <para> | 305 | <para> |
307 | The drivers compiled from a single file is stored directly on | 306 | The drivers compiled from a single file are stored directly |
308 | pci directory, while the drivers with several source files are | 307 | in the pci directory, while the drivers with several source files are |
309 | stored on its own sub-directory (e.g. emu10k1, ice1712). | 308 | stored on their own sub-directory (e.g. emu10k1, ice1712). |
310 | </para> | 309 | </para> |
311 | </section> | 310 | </section> |
312 | 311 | ||
313 | <section id="file-tree-isa-directory"> | 312 | <section id="file-tree-isa-directory"> |
314 | <title>isa directory</title> | 313 | <title>isa directory</title> |
315 | <para> | 314 | <para> |
316 | This and its sub-directories hold the top-level card modules | 315 | This directory and its sub-directories hold the top-level card modules |
317 | for ISA soundcards. | 316 | for ISA soundcards. |
318 | </para> | 317 | </para> |
319 | </section> | 318 | </section> |
@@ -321,16 +320,16 @@ | |||
321 | <section id="file-tree-arm-ppc-sparc-directories"> | 320 | <section id="file-tree-arm-ppc-sparc-directories"> |
322 | <title>arm, ppc, and sparc directories</title> | 321 | <title>arm, ppc, and sparc directories</title> |
323 | <para> | 322 | <para> |
324 | These are for the top-level card modules which are | 323 | They are used for top-level card modules which are |
325 | specific to each given architecture. | 324 | specific to one of these architectures. |
326 | </para> | 325 | </para> |
327 | </section> | 326 | </section> |
328 | 327 | ||
329 | <section id="file-tree-usb-directory"> | 328 | <section id="file-tree-usb-directory"> |
330 | <title>usb directory</title> | 329 | <title>usb directory</title> |
331 | <para> | 330 | <para> |
332 | This contains the USB-audio driver. On the latest version, the | 331 | This directory contains the USB-audio driver. In the latest version, the |
333 | USB MIDI driver is integrated together with usb-audio driver. | 332 | USB MIDI driver is integrated in the usb-audio driver. |
334 | </para> | 333 | </para> |
335 | </section> | 334 | </section> |
336 | 335 | ||
@@ -338,16 +337,17 @@ | |||
338 | <title>pcmcia directory</title> | 337 | <title>pcmcia directory</title> |
339 | <para> | 338 | <para> |
340 | The PCMCIA, especially PCCard drivers will go here. CardBus | 339 | The PCMCIA, especially PCCard drivers will go here. CardBus |
341 | drivers will be on pci directory, because its API is identical | 340 | drivers will be in the pci directory, because their API is identical |
342 | with the standard PCI cards. | 341 | to that of standard PCI cards. |
343 | </para> | 342 | </para> |
344 | </section> | 343 | </section> |
345 | 344 | ||
346 | <section id="file-tree-oss-directory"> | 345 | <section id="file-tree-oss-directory"> |
347 | <title>oss directory</title> | 346 | <title>oss directory</title> |
348 | <para> | 347 | <para> |
349 | The OSS/Lite source files are stored here on Linux 2.6 (or | 348 | The OSS/Lite source files are stored here in Linux 2.6 (or |
350 | later) tree. (In the ALSA driver tarball, it's empty, of course :) | 349 | later) tree. In the ALSA driver tarball, this directory is empty, |
350 | of course :) | ||
351 | </para> | 351 | </para> |
352 | </section> | 352 | </section> |
353 | </chapter> | 353 | </chapter> |
@@ -362,7 +362,7 @@ | |||
362 | <section id="basic-flow-outline"> | 362 | <section id="basic-flow-outline"> |
363 | <title>Outline</title> | 363 | <title>Outline</title> |
364 | <para> | 364 | <para> |
365 | The minimum flow of PCI soundcard is like the following: | 365 | The minimum flow for PCI soundcards is as follows: |
366 | 366 | ||
367 | <itemizedlist> | 367 | <itemizedlist> |
368 | <listitem><para>define the PCI ID table (see the section | 368 | <listitem><para>define the PCI ID table (see the section |
@@ -370,9 +370,13 @@ | |||
370 | </citetitle></link>).</para></listitem> | 370 | </citetitle></link>).</para></listitem> |
371 | <listitem><para>create <function>probe()</function> callback.</para></listitem> | 371 | <listitem><para>create <function>probe()</function> callback.</para></listitem> |
372 | <listitem><para>create <function>remove()</function> callback.</para></listitem> | 372 | <listitem><para>create <function>remove()</function> callback.</para></listitem> |
373 | <listitem><para>create pci_driver table which contains the three pointers above.</para></listitem> | 373 | <listitem><para>create a <structname>pci_driver</structname> structure |
374 | <listitem><para>create <function>init()</function> function just calling <function>pci_register_driver()</function> to register the pci_driver table defined above.</para></listitem> | 374 | containing the three pointers above.</para></listitem> |
375 | <listitem><para>create <function>exit()</function> function to call <function>pci_unregister_driver()</function> function.</para></listitem> | 375 | <listitem><para>create an <function>init()</function> function just calling |
376 | the <function>pci_register_driver()</function> to register the pci_driver table | ||
377 | defined above.</para></listitem> | ||
378 | <listitem><para>create an <function>exit()</function> function to call | ||
379 | the <function>pci_unregister_driver()</function> function.</para></listitem> | ||
376 | </itemizedlist> | 380 | </itemizedlist> |
377 | </para> | 381 | </para> |
378 | </section> | 382 | </section> |
@@ -382,15 +386,14 @@ | |||
382 | <para> | 386 | <para> |
383 | The code example is shown below. Some parts are kept | 387 | The code example is shown below. Some parts are kept |
384 | unimplemented at this moment but will be filled in the | 388 | unimplemented at this moment but will be filled in the |
385 | succeeding sections. The numbers in comment lines of | 389 | next sections. The numbers in the comment lines of the |
386 | <function>snd_mychip_probe()</function> function are the | 390 | <function>snd_mychip_probe()</function> function |
387 | markers. | 391 | refer to details explained in the following section. |
388 | 392 | ||
389 | <example> | 393 | <example> |
390 | <title>Basic Flow for PCI Drivers Example</title> | 394 | <title>Basic Flow for PCI Drivers - Example</title> |
391 | <programlisting> | 395 | <programlisting> |
392 | <![CDATA[ | 396 | <![CDATA[ |
393 | #include <sound/driver.h> | ||
394 | #include <linux/init.h> | 397 | #include <linux/init.h> |
395 | #include <linux/pci.h> | 398 | #include <linux/pci.h> |
396 | #include <linux/slab.h> | 399 | #include <linux/slab.h> |
@@ -398,6 +401,7 @@ | |||
398 | #include <sound/initval.h> | 401 | #include <sound/initval.h> |
399 | 402 | ||
400 | /* module parameters (see "Module Parameters") */ | 403 | /* module parameters (see "Module Parameters") */ |
404 | /* SNDRV_CARDS: maximum number of cards supported by this module */ | ||
401 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | 405 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
402 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | 406 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
403 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | 407 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
@@ -405,13 +409,13 @@ | |||
405 | /* definition of the chip-specific record */ | 409 | /* definition of the chip-specific record */ |
406 | struct mychip { | 410 | struct mychip { |
407 | struct snd_card *card; | 411 | struct snd_card *card; |
408 | /* rest of implementation will be in the section | 412 | /* the rest of the implementation will be in section |
409 | * "PCI Resource Managements" | 413 | * "PCI Resource Management" |
410 | */ | 414 | */ |
411 | }; | 415 | }; |
412 | 416 | ||
413 | /* chip-specific destructor | 417 | /* chip-specific destructor |
414 | * (see "PCI Resource Managements") | 418 | * (see "PCI Resource Management") |
415 | */ | 419 | */ |
416 | static int snd_mychip_free(struct mychip *chip) | 420 | static int snd_mychip_free(struct mychip *chip) |
417 | { | 421 | { |
@@ -442,7 +446,7 @@ | |||
442 | *rchip = NULL; | 446 | *rchip = NULL; |
443 | 447 | ||
444 | /* check PCI availability here | 448 | /* check PCI availability here |
445 | * (see "PCI Resource Managements") | 449 | * (see "PCI Resource Management") |
446 | */ | 450 | */ |
447 | .... | 451 | .... |
448 | 452 | ||
@@ -454,7 +458,7 @@ | |||
454 | chip->card = card; | 458 | chip->card = card; |
455 | 459 | ||
456 | /* rest of initialization here; will be implemented | 460 | /* rest of initialization here; will be implemented |
457 | * later, see "PCI Resource Managements" | 461 | * later, see "PCI Resource Management" |
458 | */ | 462 | */ |
459 | .... | 463 | .... |
460 | 464 | ||
@@ -521,7 +525,7 @@ | |||
521 | return 0; | 525 | return 0; |
522 | } | 526 | } |
523 | 527 | ||
524 | /* destructor -- see "Destructor" sub-section */ | 528 | /* destructor -- see the "Destructor" sub-section */ |
525 | static void __devexit snd_mychip_remove(struct pci_dev *pci) | 529 | static void __devexit snd_mychip_remove(struct pci_dev *pci) |
526 | { | 530 | { |
527 | snd_card_free(pci_get_drvdata(pci)); | 531 | snd_card_free(pci_get_drvdata(pci)); |
@@ -536,16 +540,16 @@ | |||
536 | <section id="basic-flow-constructor"> | 540 | <section id="basic-flow-constructor"> |
537 | <title>Constructor</title> | 541 | <title>Constructor</title> |
538 | <para> | 542 | <para> |
539 | The real constructor of PCI drivers is probe callback. The | 543 | The real constructor of PCI drivers is the <function>probe</function> callback. |
540 | probe callback and other component-constructors which are called | 544 | The <function>probe</function> callback and other component-constructors which are called |
541 | from probe callback should be defined with | 545 | from the <function>probe</function> callback should be defined with |
542 | <parameter>__devinit</parameter> prefix. You | 546 | the <parameter>__devinit</parameter> prefix. You |
543 | cannot use <parameter>__init</parameter> prefix for them, | 547 | cannot use the <parameter>__init</parameter> prefix for them, |
544 | because any PCI device could be a hotplug device. | 548 | because any PCI device could be a hotplug device. |
545 | </para> | 549 | </para> |
546 | 550 | ||
547 | <para> | 551 | <para> |
548 | In the probe callback, the following scheme is often used. | 552 | In the <function>probe</function> callback, the following scheme is often used. |
549 | </para> | 553 | </para> |
550 | 554 | ||
551 | <section id="basic-flow-constructor-device-index"> | 555 | <section id="basic-flow-constructor-device-index"> |
@@ -570,7 +574,7 @@ | |||
570 | </para> | 574 | </para> |
571 | 575 | ||
572 | <para> | 576 | <para> |
573 | At each time probe callback is called, check the | 577 | Each time the <function>probe</function> callback is called, check the |
574 | availability of the device. If not available, simply increment | 578 | availability of the device. If not available, simply increment |
575 | the device index and returns. dev will be incremented also | 579 | the device index and returns. dev will be incremented also |
576 | later (<link | 580 | later (<link |
@@ -594,7 +598,7 @@ | |||
594 | </para> | 598 | </para> |
595 | 599 | ||
596 | <para> | 600 | <para> |
597 | The detail will be explained in the section | 601 | The details will be explained in the section |
598 | <link linkend="card-management-card-instance"><citetitle> | 602 | <link linkend="card-management-card-instance"><citetitle> |
599 | Management of Cards and Components</citetitle></link>. | 603 | Management of Cards and Components</citetitle></link>. |
600 | </para> | 604 | </para> |
@@ -619,9 +623,9 @@ | |||
619 | </programlisting> | 623 | </programlisting> |
620 | </informalexample> | 624 | </informalexample> |
621 | 625 | ||
622 | The detail will be explained in the section <link | 626 | The details will be explained in the section <link |
623 | linkend="pci-resource"><citetitle>PCI Resource | 627 | linkend="pci-resource"><citetitle>PCI Resource |
624 | Managements</citetitle></link>. | 628 | Management</citetitle></link>. |
625 | </para> | 629 | </para> |
626 | </section> | 630 | </section> |
627 | 631 | ||
@@ -640,7 +644,7 @@ | |||
640 | </informalexample> | 644 | </informalexample> |
641 | 645 | ||
642 | The driver field holds the minimal ID string of the | 646 | The driver field holds the minimal ID string of the |
643 | chip. This is referred by alsa-lib's configurator, so keep it | 647 | chip. This is used by alsa-lib's configurator, so keep it |
644 | simple but unique. | 648 | simple but unique. |
645 | Even the same driver can have different driver IDs to | 649 | Even the same driver can have different driver IDs to |
646 | distinguish the functionality of each chip type. | 650 | distinguish the functionality of each chip type. |
@@ -648,7 +652,7 @@ | |||
648 | 652 | ||
649 | <para> | 653 | <para> |
650 | The shortname field is a string shown as more verbose | 654 | The shortname field is a string shown as more verbose |
651 | name. The longname field contains the information which is | 655 | name. The longname field contains the information |
652 | shown in <filename>/proc/asound/cards</filename>. | 656 | shown in <filename>/proc/asound/cards</filename>. |
653 | </para> | 657 | </para> |
654 | </section> | 658 | </section> |
@@ -703,7 +707,7 @@ | |||
703 | </informalexample> | 707 | </informalexample> |
704 | 708 | ||
705 | In the above, the card record is stored. This pointer is | 709 | In the above, the card record is stored. This pointer is |
706 | referred in the remove callback and power-management | 710 | used in the remove callback and power-management |
707 | callbacks, too. | 711 | callbacks, too. |
708 | </para> | 712 | </para> |
709 | </section> | 713 | </section> |
@@ -746,7 +750,6 @@ | |||
746 | <informalexample> | 750 | <informalexample> |
747 | <programlisting> | 751 | <programlisting> |
748 | <![CDATA[ | 752 | <![CDATA[ |
749 | #include <sound/driver.h> | ||
750 | #include <linux/init.h> | 753 | #include <linux/init.h> |
751 | #include <linux/pci.h> | 754 | #include <linux/pci.h> |
752 | #include <linux/slab.h> | 755 | #include <linux/slab.h> |
@@ -757,22 +760,22 @@ | |||
757 | </informalexample> | 760 | </informalexample> |
758 | 761 | ||
759 | where the last one is necessary only when module options are | 762 | where the last one is necessary only when module options are |
760 | defined in the source file. If the codes are split to several | 763 | defined in the source file. If the code is split into several |
761 | files, the file without module options don't need them. | 764 | files, the files without module options don't need them. |
762 | </para> | 765 | </para> |
763 | 766 | ||
764 | <para> | 767 | <para> |
765 | In addition to them, you'll need | 768 | In addition to these headers, you'll need |
766 | <filename><linux/interrupt.h></filename> for the interrupt | 769 | <filename><linux/interrupt.h></filename> for interrupt |
767 | handling, and <filename><asm/io.h></filename> for the i/o | 770 | handling, and <filename><asm/io.h></filename> for I/O |
768 | access. If you use <function>mdelay()</function> or | 771 | access. If you use the <function>mdelay()</function> or |
769 | <function>udelay()</function> functions, you'll need to include | 772 | <function>udelay()</function> functions, you'll need to include |
770 | <filename><linux/delay.h></filename>, too. | 773 | <filename><linux/delay.h></filename> too. |
771 | </para> | 774 | </para> |
772 | 775 | ||
773 | <para> | 776 | <para> |
774 | The ALSA interfaces like PCM or control API are defined in other | 777 | The ALSA interfaces like the PCM and control APIs are defined in other |
775 | header files as <filename><sound/xxx.h></filename>. | 778 | <filename><sound/xxx.h></filename> header files. |
776 | They have to be included after | 779 | They have to be included after |
777 | <filename><sound/core.h></filename>. | 780 | <filename><sound/core.h></filename>. |
778 | </para> | 781 | </para> |
@@ -795,12 +798,12 @@ | |||
795 | 798 | ||
796 | <para> | 799 | <para> |
797 | A card record is the headquarters of the soundcard. It manages | 800 | A card record is the headquarters of the soundcard. It manages |
798 | the list of whole devices (components) on the soundcard, such as | 801 | the whole list of devices (components) on the soundcard, such as |
799 | PCM, mixers, MIDI, synthesizer, and so on. Also, the card | 802 | PCM, mixers, MIDI, synthesizer, and so on. Also, the card |
800 | record holds the ID and the name strings of the card, manages | 803 | record holds the ID and the name strings of the card, manages |
801 | the root of proc files, and controls the power-management states | 804 | the root of proc files, and controls the power-management states |
802 | and hotplug disconnections. The component list on the card | 805 | and hotplug disconnections. The component list on the card |
803 | record is used to manage the proper releases of resources at | 806 | record is used to manage the correct release of resources at |
804 | destruction. | 807 | destruction. |
805 | </para> | 808 | </para> |
806 | 809 | ||
@@ -824,9 +827,8 @@ | |||
824 | <constant>THIS_MODULE</constant>), | 827 | <constant>THIS_MODULE</constant>), |
825 | and the size of extra-data space. The last argument is used to | 828 | and the size of extra-data space. The last argument is used to |
826 | allocate card->private_data for the | 829 | allocate card->private_data for the |
827 | chip-specific data. Note that this data | 830 | chip-specific data. Note that these data |
828 | <emphasis>is</emphasis> allocated by | 831 | are allocated by <function>snd_card_new()</function>. |
829 | <function>snd_card_new()</function>. | ||
830 | </para> | 832 | </para> |
831 | </section> | 833 | </section> |
832 | 834 | ||
@@ -834,10 +836,10 @@ | |||
834 | <title>Components</title> | 836 | <title>Components</title> |
835 | <para> | 837 | <para> |
836 | After the card is created, you can attach the components | 838 | After the card is created, you can attach the components |
837 | (devices) to the card instance. On ALSA driver, a component is | 839 | (devices) to the card instance. In an ALSA driver, a component is |
838 | represented as a struct <structname>snd_device</structname> object. | 840 | represented as a struct <structname>snd_device</structname> object. |
839 | A component can be a PCM instance, a control interface, a raw | 841 | A component can be a PCM instance, a control interface, a raw |
840 | MIDI interface, etc. Each of such instances has one component | 842 | MIDI interface, etc. Each such instance has one component |
841 | entry. | 843 | entry. |
842 | </para> | 844 | </para> |
843 | 845 | ||
@@ -859,7 +861,7 @@ | |||
859 | (<constant>SNDRV_DEV_XXX</constant>), the data pointer, and the | 861 | (<constant>SNDRV_DEV_XXX</constant>), the data pointer, and the |
860 | callback pointers (<parameter>&ops</parameter>). The | 862 | callback pointers (<parameter>&ops</parameter>). The |
861 | device-level defines the type of components and the order of | 863 | device-level defines the type of components and the order of |
862 | registration and de-registration. For most of components, the | 864 | registration and de-registration. For most components, the |
863 | device-level is already defined. For a user-defined component, | 865 | device-level is already defined. For a user-defined component, |
864 | you can use <constant>SNDRV_DEV_LOWLEVEL</constant>. | 866 | you can use <constant>SNDRV_DEV_LOWLEVEL</constant>. |
865 | </para> | 867 | </para> |
@@ -867,13 +869,13 @@ | |||
867 | <para> | 869 | <para> |
868 | This function itself doesn't allocate the data space. The data | 870 | This function itself doesn't allocate the data space. The data |
869 | must be allocated manually beforehand, and its pointer is passed | 871 | must be allocated manually beforehand, and its pointer is passed |
870 | as the argument. This pointer is used as the identifier | 872 | as the argument. This pointer is used as the |
871 | (<parameter>chip</parameter> in the above example) for the | 873 | (<parameter>chip</parameter> identifier in the above example) |
872 | instance. | 874 | for the instance. |
873 | </para> | 875 | </para> |
874 | 876 | ||
875 | <para> | 877 | <para> |
876 | Each ALSA pre-defined component such as ac97 or pcm calls | 878 | Each pre-defined ALSA component such as ac97 and pcm calls |
877 | <function>snd_device_new()</function> inside its | 879 | <function>snd_device_new()</function> inside its |
878 | constructor. The destructor for each component is defined in the | 880 | constructor. The destructor for each component is defined in the |
879 | callback pointers. Hence, you don't need to take care of | 881 | callback pointers. Hence, you don't need to take care of |
@@ -881,19 +883,19 @@ | |||
881 | </para> | 883 | </para> |
882 | 884 | ||
883 | <para> | 885 | <para> |
884 | If you would like to create your own component, you need to | 886 | If you wish to create your own component, you need to |
885 | set the destructor function to dev_free callback in | 887 | set the destructor function to the dev_free callback in |
886 | <parameter>ops</parameter>, so that it can be released | 888 | the <parameter>ops</parameter>, so that it can be released |
887 | automatically via <function>snd_card_free()</function>. The | 889 | automatically via <function>snd_card_free()</function>. |
888 | example will be shown later as an implementation of a | 890 | The next example will show an implementation of chip-specific |
889 | chip-specific data. | 891 | data. |
890 | </para> | 892 | </para> |
891 | </section> | 893 | </section> |
892 | 894 | ||
893 | <section id="card-management-chip-specific"> | 895 | <section id="card-management-chip-specific"> |
894 | <title>Chip-Specific Data</title> | 896 | <title>Chip-Specific Data</title> |
895 | <para> | 897 | <para> |
896 | The chip-specific information, e.g. the i/o port address, its | 898 | Chip-specific information, e.g. the I/O port address, its |
897 | resource pointer, or the irq number, is stored in the | 899 | resource pointer, or the irq number, is stored in the |
898 | chip-specific record. | 900 | chip-specific record. |
899 | 901 | ||
@@ -909,13 +911,14 @@ | |||
909 | </para> | 911 | </para> |
910 | 912 | ||
911 | <para> | 913 | <para> |
912 | In general, there are two ways to allocate the chip record. | 914 | In general, there are two ways of allocating the chip record. |
913 | </para> | 915 | </para> |
914 | 916 | ||
915 | <section id="card-management-chip-specific-snd-card-new"> | 917 | <section id="card-management-chip-specific-snd-card-new"> |
916 | <title>1. Allocating via <function>snd_card_new()</function>.</title> | 918 | <title>1. Allocating via <function>snd_card_new()</function>.</title> |
917 | <para> | 919 | <para> |
918 | As mentioned above, you can pass the extra-data-length to the 4th argument of <function>snd_card_new()</function>, i.e. | 920 | As mentioned above, you can pass the extra-data-length |
921 | to the 4th argument of <function>snd_card_new()</function>, i.e. | ||
919 | 922 | ||
920 | <informalexample> | 923 | <informalexample> |
921 | <programlisting> | 924 | <programlisting> |
@@ -925,7 +928,7 @@ | |||
925 | </programlisting> | 928 | </programlisting> |
926 | </informalexample> | 929 | </informalexample> |
927 | 930 | ||
928 | whether struct <structname>mychip</structname> is the type of the chip record. | 931 | struct <structname>mychip</structname> is the type of the chip record. |
929 | </para> | 932 | </para> |
930 | 933 | ||
931 | <para> | 934 | <para> |
@@ -1037,8 +1040,8 @@ | |||
1037 | <title>Registration and Release</title> | 1040 | <title>Registration and Release</title> |
1038 | <para> | 1041 | <para> |
1039 | After all components are assigned, register the card instance | 1042 | After all components are assigned, register the card instance |
1040 | by calling <function>snd_card_register()</function>. The access | 1043 | by calling <function>snd_card_register()</function>. Access |
1041 | to the device files are enabled at this point. That is, before | 1044 | to the device files is enabled at this point. That is, before |
1042 | <function>snd_card_register()</function> is called, the | 1045 | <function>snd_card_register()</function> is called, the |
1043 | components are safely inaccessible from external side. If this | 1046 | components are safely inaccessible from external side. If this |
1044 | call fails, exit the probe function after releasing the card via | 1047 | call fails, exit the probe function after releasing the card via |
@@ -1047,7 +1050,7 @@ | |||
1047 | 1050 | ||
1048 | <para> | 1051 | <para> |
1049 | For releasing the card instance, you can call simply | 1052 | For releasing the card instance, you can call simply |
1050 | <function>snd_card_free()</function>. As already mentioned, all | 1053 | <function>snd_card_free()</function>. As mentioned earlier, all |
1051 | components are released automatically by this call. | 1054 | components are released automatically by this call. |
1052 | </para> | 1055 | </para> |
1053 | 1056 | ||
@@ -1055,7 +1058,7 @@ | |||
1055 | As further notes, the destructors (both | 1058 | As further notes, the destructors (both |
1056 | <function>snd_mychip_dev_free</function> and | 1059 | <function>snd_mychip_dev_free</function> and |
1057 | <function>snd_mychip_free</function>) cannot be defined with | 1060 | <function>snd_mychip_free</function>) cannot be defined with |
1058 | <parameter>__devexit</parameter> prefix, because they may be | 1061 | the <parameter>__devexit</parameter> prefix, because they may be |
1059 | called from the constructor, too, at the false path. | 1062 | called from the constructor, too, at the false path. |
1060 | </para> | 1063 | </para> |
1061 | 1064 | ||
@@ -1071,20 +1074,20 @@ | |||
1071 | 1074 | ||
1072 | 1075 | ||
1073 | <!-- ****************************************************** --> | 1076 | <!-- ****************************************************** --> |
1074 | <!-- PCI Resource Managements --> | 1077 | <!-- PCI Resource Management --> |
1075 | <!-- ****************************************************** --> | 1078 | <!-- ****************************************************** --> |
1076 | <chapter id="pci-resource"> | 1079 | <chapter id="pci-resource"> |
1077 | <title>PCI Resource Managements</title> | 1080 | <title>PCI Resource Management</title> |
1078 | 1081 | ||
1079 | <section id="pci-resource-example"> | 1082 | <section id="pci-resource-example"> |
1080 | <title>Full Code Example</title> | 1083 | <title>Full Code Example</title> |
1081 | <para> | 1084 | <para> |
1082 | In this section, we'll finish the chip-specific constructor, | 1085 | In this section, we'll complete the chip-specific constructor, |
1083 | destructor and PCI entries. The example code is shown first, | 1086 | destructor and PCI entries. Example code is shown first, |
1084 | below. | 1087 | below. |
1085 | 1088 | ||
1086 | <example> | 1089 | <example> |
1087 | <title>PCI Resource Managements Example</title> | 1090 | <title>PCI Resource Management Example</title> |
1088 | <programlisting> | 1091 | <programlisting> |
1089 | <![CDATA[ | 1092 | <![CDATA[ |
1090 | struct mychip { | 1093 | struct mychip { |
@@ -1103,7 +1106,7 @@ | |||
1103 | /* release the irq */ | 1106 | /* release the irq */ |
1104 | if (chip->irq >= 0) | 1107 | if (chip->irq >= 0) |
1105 | free_irq(chip->irq, chip); | 1108 | free_irq(chip->irq, chip); |
1106 | /* release the i/o ports & memory */ | 1109 | /* release the I/O ports & memory */ |
1107 | pci_release_regions(chip->pci); | 1110 | pci_release_regions(chip->pci); |
1108 | /* disable the PCI entry */ | 1111 | /* disable the PCI entry */ |
1109 | pci_disable_device(chip->pci); | 1112 | pci_disable_device(chip->pci); |
@@ -1196,13 +1199,13 @@ | |||
1196 | .remove = __devexit_p(snd_mychip_remove), | 1199 | .remove = __devexit_p(snd_mychip_remove), |
1197 | }; | 1200 | }; |
1198 | 1201 | ||
1199 | /* initialization of the module */ | 1202 | /* module initialization */ |
1200 | static int __init alsa_card_mychip_init(void) | 1203 | static int __init alsa_card_mychip_init(void) |
1201 | { | 1204 | { |
1202 | return pci_register_driver(&driver); | 1205 | return pci_register_driver(&driver); |
1203 | } | 1206 | } |
1204 | 1207 | ||
1205 | /* clean up the module */ | 1208 | /* module clean up */ |
1206 | static void __exit alsa_card_mychip_exit(void) | 1209 | static void __exit alsa_card_mychip_exit(void) |
1207 | { | 1210 | { |
1208 | pci_unregister_driver(&driver); | 1211 | pci_unregister_driver(&driver); |
@@ -1228,10 +1231,10 @@ | |||
1228 | </para> | 1231 | </para> |
1229 | 1232 | ||
1230 | <para> | 1233 | <para> |
1231 | In the case of PCI devices, you have to call at first | 1234 | In the case of PCI devices, you first have to call |
1232 | <function>pci_enable_device()</function> function before | 1235 | the <function>pci_enable_device()</function> function before |
1233 | allocating resources. Also, you need to set the proper PCI DMA | 1236 | allocating resources. Also, you need to set the proper PCI DMA |
1234 | mask to limit the accessed i/o range. In some cases, you might | 1237 | mask to limit the accessed I/O range. In some cases, you might |
1235 | need to call <function>pci_set_master()</function> function, | 1238 | need to call <function>pci_set_master()</function> function, |
1236 | too. | 1239 | too. |
1237 | </para> | 1240 | </para> |
@@ -1261,15 +1264,15 @@ | |||
1261 | <section id="pci-resource-resource-allocation"> | 1264 | <section id="pci-resource-resource-allocation"> |
1262 | <title>Resource Allocation</title> | 1265 | <title>Resource Allocation</title> |
1263 | <para> | 1266 | <para> |
1264 | The allocation of I/O ports and irqs are done via standard kernel | 1267 | The allocation of I/O ports and irqs is done via standard kernel |
1265 | functions. Unlike ALSA ver.0.5.x., there are no helpers for | 1268 | functions. Unlike ALSA ver.0.5.x., there are no helpers for |
1266 | that. And these resources must be released in the destructor | 1269 | that. And these resources must be released in the destructor |
1267 | function (see below). Also, on ALSA 0.9.x, you don't need to | 1270 | function (see below). Also, on ALSA 0.9.x, you don't need to |
1268 | allocate (pseudo-)DMA for PCI like ALSA 0.5.x. | 1271 | allocate (pseudo-)DMA for PCI like in ALSA 0.5.x. |
1269 | </para> | 1272 | </para> |
1270 | 1273 | ||
1271 | <para> | 1274 | <para> |
1272 | Now assume that this PCI device has an I/O port with 8 bytes | 1275 | Now assume that the PCI device has an I/O port with 8 bytes |
1273 | and an interrupt. Then struct <structname>mychip</structname> will have the | 1276 | and an interrupt. Then struct <structname>mychip</structname> will have the |
1274 | following fields: | 1277 | following fields: |
1275 | 1278 | ||
@@ -1288,7 +1291,7 @@ | |||
1288 | </para> | 1291 | </para> |
1289 | 1292 | ||
1290 | <para> | 1293 | <para> |
1291 | For an i/o port (and also a memory region), you need to have | 1294 | For an I/O port (and also a memory region), you need to have |
1292 | the resource pointer for the standard resource management. For | 1295 | the resource pointer for the standard resource management. For |
1293 | an irq, you have to keep only the irq number (integer). But you | 1296 | an irq, you have to keep only the irq number (integer). But you |
1294 | need to initialize this number as -1 before actual allocation, | 1297 | need to initialize this number as -1 before actual allocation, |
@@ -1299,7 +1302,7 @@ | |||
1299 | </para> | 1302 | </para> |
1300 | 1303 | ||
1301 | <para> | 1304 | <para> |
1302 | The allocation of an i/o port is done like this: | 1305 | The allocation of an I/O port is done like this: |
1303 | 1306 | ||
1304 | <informalexample> | 1307 | <informalexample> |
1305 | <programlisting> | 1308 | <programlisting> |
@@ -1318,12 +1321,12 @@ | |||
1318 | 1321 | ||
1319 | <para> | 1322 | <para> |
1320 | <!-- obsolete --> | 1323 | <!-- obsolete --> |
1321 | It will reserve the i/o port region of 8 bytes of the given | 1324 | It will reserve the I/O port region of 8 bytes of the given |
1322 | PCI device. The returned value, chip->res_port, is allocated | 1325 | PCI device. The returned value, chip->res_port, is allocated |
1323 | via <function>kmalloc()</function> by | 1326 | via <function>kmalloc()</function> by |
1324 | <function>request_region()</function>. The pointer must be | 1327 | <function>request_region()</function>. The pointer must be |
1325 | released via <function>kfree()</function>, but there is some | 1328 | released via <function>kfree()</function>, but there is a |
1326 | problem regarding this. This issue will be explained more below. | 1329 | problem with this. This issue will be explained later. |
1327 | </para> | 1330 | </para> |
1328 | 1331 | ||
1329 | <para> | 1332 | <para> |
@@ -1351,8 +1354,8 @@ | |||
1351 | </para> | 1354 | </para> |
1352 | 1355 | ||
1353 | <para> | 1356 | <para> |
1354 | On the PCI bus, the interrupts can be shared. Thus, | 1357 | On the PCI bus, interrupts can be shared. Thus, |
1355 | <constant>IRQF_SHARED</constant> is given as the interrupt flag of | 1358 | <constant>IRQF_SHARED</constant> is used as the interrupt flag of |
1356 | <function>request_irq()</function>. | 1359 | <function>request_irq()</function>. |
1357 | </para> | 1360 | </para> |
1358 | 1361 | ||
@@ -1364,7 +1367,7 @@ | |||
1364 | </para> | 1367 | </para> |
1365 | 1368 | ||
1366 | <para> | 1369 | <para> |
1367 | I won't define the detail of the interrupt handler at this | 1370 | I won't give details about the interrupt handler at this |
1368 | point, but at least its appearance can be explained now. The | 1371 | point, but at least its appearance can be explained now. The |
1369 | interrupt handler looks usually like the following: | 1372 | interrupt handler looks usually like the following: |
1370 | 1373 | ||
@@ -1386,11 +1389,11 @@ | |||
1386 | Now let's write the corresponding destructor for the resources | 1389 | Now let's write the corresponding destructor for the resources |
1387 | above. The role of destructor is simple: disable the hardware | 1390 | above. The role of destructor is simple: disable the hardware |
1388 | (if already activated) and release the resources. So far, we | 1391 | (if already activated) and release the resources. So far, we |
1389 | have no hardware part, so the disabling is not written here. | 1392 | have no hardware part, so the disabling code is not written here. |
1390 | </para> | 1393 | </para> |
1391 | 1394 | ||
1392 | <para> | 1395 | <para> |
1393 | For releasing the resources, <quote>check-and-release</quote> | 1396 | To release the resources, the <quote>check-and-release</quote> |
1394 | method is a safer way. For the interrupt, do like this: | 1397 | method is a safer way. For the interrupt, do like this: |
1395 | 1398 | ||
1396 | <informalexample> | 1399 | <informalexample> |
@@ -1410,7 +1413,7 @@ | |||
1410 | <para> | 1413 | <para> |
1411 | When you requested I/O ports or memory regions via | 1414 | When you requested I/O ports or memory regions via |
1412 | <function>pci_request_region()</function> or | 1415 | <function>pci_request_region()</function> or |
1413 | <function>pci_request_regions()</function> like this example, | 1416 | <function>pci_request_regions()</function> like in this example, |
1414 | release the resource(s) using the corresponding function, | 1417 | release the resource(s) using the corresponding function, |
1415 | <function>pci_release_region()</function> or | 1418 | <function>pci_release_region()</function> or |
1416 | <function>pci_release_regions()</function>. | 1419 | <function>pci_release_regions()</function>. |
@@ -1429,7 +1432,7 @@ | |||
1429 | or <function>request_mem_region</function>, you can release it via | 1432 | or <function>request_mem_region</function>, you can release it via |
1430 | <function>release_resource()</function>. Suppose that you keep | 1433 | <function>release_resource()</function>. Suppose that you keep |
1431 | the resource pointer returned from <function>request_region()</function> | 1434 | the resource pointer returned from <function>request_region()</function> |
1432 | in chip->res_port, the release procedure looks like below: | 1435 | in chip->res_port, the release procedure looks like: |
1433 | 1436 | ||
1434 | <informalexample> | 1437 | <informalexample> |
1435 | <programlisting> | 1438 | <programlisting> |
@@ -1442,7 +1445,7 @@ | |||
1442 | 1445 | ||
1443 | <para> | 1446 | <para> |
1444 | Don't forget to call <function>pci_disable_device()</function> | 1447 | Don't forget to call <function>pci_disable_device()</function> |
1445 | before all finished. | 1448 | before the end. |
1446 | </para> | 1449 | </para> |
1447 | 1450 | ||
1448 | <para> | 1451 | <para> |
@@ -1459,14 +1462,14 @@ | |||
1459 | 1462 | ||
1460 | <para> | 1463 | <para> |
1461 | Again, remember that you cannot | 1464 | Again, remember that you cannot |
1462 | set <parameter>__devexit</parameter> prefix for this destructor. | 1465 | use the <parameter>__devexit</parameter> prefix for this destructor. |
1463 | </para> | 1466 | </para> |
1464 | 1467 | ||
1465 | <para> | 1468 | <para> |
1466 | We didn't implement the hardware-disabling part in the above. | 1469 | We didn't implement the hardware disabling part in the above. |
1467 | If you need to do this, please note that the destructor may be | 1470 | If you need to do this, please note that the destructor may be |
1468 | called even before the initialization of the chip is completed. | 1471 | called even before the initialization of the chip is completed. |
1469 | It would be better to have a flag to skip the hardware-disabling | 1472 | It would be better to have a flag to skip hardware disabling |
1470 | if the hardware was not initialized yet. | 1473 | if the hardware was not initialized yet. |
1471 | </para> | 1474 | </para> |
1472 | 1475 | ||
@@ -1475,14 +1478,14 @@ | |||
1475 | <function>snd_device_new()</function> with | 1478 | <function>snd_device_new()</function> with |
1476 | <constant>SNDRV_DEV_LOWLELVEL</constant> , its destructor is | 1479 | <constant>SNDRV_DEV_LOWLELVEL</constant> , its destructor is |
1477 | called at the last. That is, it is assured that all other | 1480 | called at the last. That is, it is assured that all other |
1478 | components like PCMs and controls have been already released. | 1481 | components like PCMs and controls have already been released. |
1479 | You don't have to call stopping PCMs, etc. explicitly, but just | 1482 | You don't have to stop PCMs, etc. explicitly, but just |
1480 | stop the hardware in the low-level. | 1483 | call low-level hardware stopping. |
1481 | </para> | 1484 | </para> |
1482 | 1485 | ||
1483 | <para> | 1486 | <para> |
1484 | The management of a memory-mapped region is almost as same as | 1487 | The management of a memory-mapped region is almost as same as |
1485 | the management of an i/o port. You'll need three fields like | 1488 | the management of an I/O port. You'll need three fields like |
1486 | the following: | 1489 | the following: |
1487 | 1490 | ||
1488 | <informalexample> | 1491 | <informalexample> |
@@ -1561,8 +1564,8 @@ | |||
1561 | <section id="pci-resource-entries"> | 1564 | <section id="pci-resource-entries"> |
1562 | <title>PCI Entries</title> | 1565 | <title>PCI Entries</title> |
1563 | <para> | 1566 | <para> |
1564 | So far, so good. Let's finish the rest of missing PCI | 1567 | So far, so good. Let's finish the missing PCI |
1565 | stuffs. At first, we need a | 1568 | stuff. At first, we need a |
1566 | <structname>pci_device_id</structname> table for this | 1569 | <structname>pci_device_id</structname> table for this |
1567 | chipset. It's a table of PCI vendor/device ID number, and some | 1570 | chipset. It's a table of PCI vendor/device ID number, and some |
1568 | masks. | 1571 | masks. |
@@ -1588,13 +1591,13 @@ | |||
1588 | 1591 | ||
1589 | <para> | 1592 | <para> |
1590 | The first and second fields of | 1593 | The first and second fields of |
1591 | <structname>pci_device_id</structname> struct are the vendor and | 1594 | the <structname>pci_device_id</structname> structure are the vendor and |
1592 | device IDs. If you have nothing special to filter the matching | 1595 | device IDs. If you have no reason to filter the matching |
1593 | devices, you can use the rest of fields like above. The last | 1596 | devices, you can leave the remaining fields as above. The last |
1594 | field of <structname>pci_device_id</structname> struct is a | 1597 | field of the <structname>pci_device_id</structname> struct contains |
1595 | private data for this entry. You can specify any value here, for | 1598 | private data for this entry. You can specify any value here, for |
1596 | example, to tell the type of different operations per each | 1599 | example, to define specific operations for supported device IDs. |
1597 | device IDs. Such an example is found in intel8x0 driver. | 1600 | Such an example is found in the intel8x0 driver. |
1598 | </para> | 1601 | </para> |
1599 | 1602 | ||
1600 | <para> | 1603 | <para> |
@@ -1621,10 +1624,10 @@ | |||
1621 | 1624 | ||
1622 | <para> | 1625 | <para> |
1623 | The <structfield>probe</structfield> and | 1626 | The <structfield>probe</structfield> and |
1624 | <structfield>remove</structfield> functions are what we already | 1627 | <structfield>remove</structfield> functions have already |
1625 | defined in | 1628 | been defined in the previous sections. |
1626 | the previous sections. The <structfield>remove</structfield> should | 1629 | The <structfield>remove</structfield> function should |
1627 | be defined with | 1630 | be defined with the |
1628 | <function>__devexit_p()</function> macro, so that it's not | 1631 | <function>__devexit_p()</function> macro, so that it's not |
1629 | defined for built-in (and non-hot-pluggable) case. The | 1632 | defined for built-in (and non-hot-pluggable) case. The |
1630 | <structfield>name</structfield> | 1633 | <structfield>name</structfield> |
@@ -1665,8 +1668,7 @@ | |||
1665 | 1668 | ||
1666 | <para> | 1669 | <para> |
1667 | Oh, one thing was forgotten. If you have no exported symbols, | 1670 | Oh, one thing was forgotten. If you have no exported symbols, |
1668 | you need to declare it on 2.2 or 2.4 kernels (on 2.6 kernels | 1671 | you need to declare it in 2.2 or 2.4 kernels (it's not necessary in 2.6 kernels). |
1669 | it's not necessary, though). | ||
1670 | 1672 | ||
1671 | <informalexample> | 1673 | <informalexample> |
1672 | <programlisting> | 1674 | <programlisting> |
@@ -1698,7 +1700,7 @@ | |||
1698 | 1700 | ||
1699 | <para> | 1701 | <para> |
1700 | For accessing to the PCM layer, you need to include | 1702 | For accessing to the PCM layer, you need to include |
1701 | <filename><sound/pcm.h></filename> above all. In addition, | 1703 | <filename><sound/pcm.h></filename> first. In addition, |
1702 | <filename><sound/pcm_params.h></filename> might be needed | 1704 | <filename><sound/pcm_params.h></filename> might be needed |
1703 | if you access to some functions related with hw_param. | 1705 | if you access to some functions related with hw_param. |
1704 | </para> | 1706 | </para> |
@@ -1707,21 +1709,21 @@ | |||
1707 | Each card device can have up to four pcm instances. A pcm | 1709 | Each card device can have up to four pcm instances. A pcm |
1708 | instance corresponds to a pcm device file. The limitation of | 1710 | instance corresponds to a pcm device file. The limitation of |
1709 | number of instances comes only from the available bit size of | 1711 | number of instances comes only from the available bit size of |
1710 | the linux's device number. Once when 64bit device number is | 1712 | the Linux's device numbers. Once when 64bit device number is |
1711 | used, we'll have more available pcm instances. | 1713 | used, we'll have more pcm instances available. |
1712 | </para> | 1714 | </para> |
1713 | 1715 | ||
1714 | <para> | 1716 | <para> |
1715 | A pcm instance consists of pcm playback and capture streams, | 1717 | A pcm instance consists of pcm playback and capture streams, |
1716 | and each pcm stream consists of one or more pcm substreams. Some | 1718 | and each pcm stream consists of one or more pcm substreams. Some |
1717 | soundcard supports the multiple-playback function. For example, | 1719 | soundcards support multiple playback functions. For example, |
1718 | emu10k1 has a PCM playback of 32 stereo substreams. In this case, at | 1720 | emu10k1 has a PCM playback of 32 stereo substreams. In this case, at |
1719 | each open, a free substream is (usually) automatically chosen | 1721 | each open, a free substream is (usually) automatically chosen |
1720 | and opened. Meanwhile, when only one substream exists and it was | 1722 | and opened. Meanwhile, when only one substream exists and it was |
1721 | already opened, the succeeding open will result in the blocking | 1723 | already opened, the successful open will either block |
1722 | or the error with <constant>EAGAIN</constant> according to the | 1724 | or error with <constant>EAGAIN</constant> according to the |
1723 | file open mode. But you don't have to know the detail in your | 1725 | file open mode. But you don't have to care about such details in your |
1724 | driver. The PCM middle layer will take all such jobs. | 1726 | driver. The PCM middle layer will take care of such work. |
1725 | </para> | 1727 | </para> |
1726 | </section> | 1728 | </section> |
1727 | 1729 | ||
@@ -1944,7 +1946,7 @@ | |||
1944 | <section id="pcm-interface-constructor"> | 1946 | <section id="pcm-interface-constructor"> |
1945 | <title>Constructor</title> | 1947 | <title>Constructor</title> |
1946 | <para> | 1948 | <para> |
1947 | A pcm instance is allocated by <function>snd_pcm_new()</function> | 1949 | A pcm instance is allocated by the <function>snd_pcm_new()</function> |
1948 | function. It would be better to create a constructor for pcm, | 1950 | function. It would be better to create a constructor for pcm, |
1949 | namely, | 1951 | namely, |
1950 | 1952 | ||
@@ -1971,23 +1973,23 @@ | |||
1971 | </para> | 1973 | </para> |
1972 | 1974 | ||
1973 | <para> | 1975 | <para> |
1974 | The <function>snd_pcm_new()</function> function takes the four | 1976 | The <function>snd_pcm_new()</function> function takes four |
1975 | arguments. The first argument is the card pointer to which this | 1977 | arguments. The first argument is the card pointer to which this |
1976 | pcm is assigned, and the second is the ID string. | 1978 | pcm is assigned, and the second is the ID string. |
1977 | </para> | 1979 | </para> |
1978 | 1980 | ||
1979 | <para> | 1981 | <para> |
1980 | The third argument (<parameter>index</parameter>, 0 in the | 1982 | The third argument (<parameter>index</parameter>, 0 in the |
1981 | above) is the index of this new pcm. It begins from zero. When | 1983 | above) is the index of this new pcm. It begins from zero. If |
1982 | you will create more than one pcm instances, specify the | 1984 | you create more than one pcm instances, specify the |
1983 | different numbers in this argument. For example, | 1985 | different numbers in this argument. For example, |
1984 | <parameter>index</parameter> = 1 for the second PCM device. | 1986 | <parameter>index</parameter> = 1 for the second PCM device. |
1985 | </para> | 1987 | </para> |
1986 | 1988 | ||
1987 | <para> | 1989 | <para> |
1988 | The fourth and fifth arguments are the number of substreams | 1990 | The fourth and fifth arguments are the number of substreams |
1989 | for playback and capture, respectively. Here both 1 are given in | 1991 | for playback and capture, respectively. Here 1 is used for |
1990 | the above example. When no playback or no capture is available, | 1992 | both arguments. When no playback or capture substreams are available, |
1991 | pass 0 to the corresponding argument. | 1993 | pass 0 to the corresponding argument. |
1992 | </para> | 1994 | </para> |
1993 | 1995 | ||
@@ -2045,13 +2047,13 @@ | |||
2045 | </programlisting> | 2047 | </programlisting> |
2046 | </informalexample> | 2048 | </informalexample> |
2047 | 2049 | ||
2048 | Each of callbacks is explained in the subsection | 2050 | All the callbacks are described in the |
2049 | <link linkend="pcm-interface-operators"><citetitle> | 2051 | <link linkend="pcm-interface-operators"><citetitle> |
2050 | Operators</citetitle></link>. | 2052 | Operators</citetitle></link> subsection. |
2051 | </para> | 2053 | </para> |
2052 | 2054 | ||
2053 | <para> | 2055 | <para> |
2054 | After setting the operators, most likely you'd like to | 2056 | After setting the operators, you probably will want to |
2055 | pre-allocate the buffer. For the pre-allocation, simply call | 2057 | pre-allocate the buffer. For the pre-allocation, simply call |
2056 | the following: | 2058 | the following: |
2057 | 2059 | ||
@@ -2065,8 +2067,8 @@ | |||
2065 | </programlisting> | 2067 | </programlisting> |
2066 | </informalexample> | 2068 | </informalexample> |
2067 | 2069 | ||
2068 | It will allocate up to 64kB buffer as default. The details of | 2070 | It will allocate a buffer up to 64kB as default. |
2069 | buffer management will be described in the later section <link | 2071 | Buffer management details will be described in the later section <link |
2070 | linkend="buffer-and-memory"><citetitle>Buffer and Memory | 2072 | linkend="buffer-and-memory"><citetitle>Buffer and Memory |
2071 | Management</citetitle></link>. | 2073 | Management</citetitle></link>. |
2072 | </para> | 2074 | </para> |
@@ -2095,13 +2097,13 @@ | |||
2095 | <para> | 2097 | <para> |
2096 | The destructor for a pcm instance is not always | 2098 | The destructor for a pcm instance is not always |
2097 | necessary. Since the pcm device will be released by the middle | 2099 | necessary. Since the pcm device will be released by the middle |
2098 | layer code automatically, you don't have to call destructor | 2100 | layer code automatically, you don't have to call the destructor |
2099 | explicitly. | 2101 | explicitly. |
2100 | </para> | 2102 | </para> |
2101 | 2103 | ||
2102 | <para> | 2104 | <para> |
2103 | The destructor would be necessary when you created some | 2105 | The destructor would be necessary if you created |
2104 | special records internally and need to release them. In such a | 2106 | special records internally and needed to release them. In such a |
2105 | case, set the destructor function to | 2107 | case, set the destructor function to |
2106 | pcm->private_free: | 2108 | pcm->private_free: |
2107 | 2109 | ||
@@ -2141,16 +2143,15 @@ | |||
2141 | When the PCM substream is opened, a PCM runtime instance is | 2143 | When the PCM substream is opened, a PCM runtime instance is |
2142 | allocated and assigned to the substream. This pointer is | 2144 | allocated and assigned to the substream. This pointer is |
2143 | accessible via <constant>substream->runtime</constant>. | 2145 | accessible via <constant>substream->runtime</constant>. |
2144 | This runtime pointer holds the various information; it holds | 2146 | This runtime pointer holds most information you need |
2145 | the copy of hw_params and sw_params configurations, the buffer | 2147 | to control the PCM: the copy of hw_params and sw_params configurations, the buffer |
2146 | pointers, mmap records, spinlocks, etc. Almost everything you | 2148 | pointers, mmap records, spinlocks, etc. |
2147 | need for controlling the PCM can be found there. | ||
2148 | </para> | 2149 | </para> |
2149 | 2150 | ||
2150 | <para> | 2151 | <para> |
2151 | The definition of runtime instance is found in | 2152 | The definition of runtime instance is found in |
2152 | <filename><sound/pcm.h></filename>. Here is the | 2153 | <filename><sound/pcm.h></filename>. Here are |
2153 | copy from the file. | 2154 | the contents of this file: |
2154 | <informalexample> | 2155 | <informalexample> |
2155 | <programlisting> | 2156 | <programlisting> |
2156 | <![CDATA[ | 2157 | <![CDATA[ |
@@ -2185,7 +2186,6 @@ struct _snd_pcm_runtime { | |||
2185 | struct timespec tstamp_mode; /* mmap timestamp is updated */ | 2186 | struct timespec tstamp_mode; /* mmap timestamp is updated */ |
2186 | unsigned int period_step; | 2187 | unsigned int period_step; |
2187 | unsigned int sleep_min; /* min ticks to sleep */ | 2188 | unsigned int sleep_min; /* min ticks to sleep */ |
2188 | snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */ | ||
2189 | snd_pcm_uframes_t start_threshold; | 2189 | snd_pcm_uframes_t start_threshold; |
2190 | snd_pcm_uframes_t stop_threshold; | 2190 | snd_pcm_uframes_t stop_threshold; |
2191 | snd_pcm_uframes_t silence_threshold; /* Silence filling happens when | 2191 | snd_pcm_uframes_t silence_threshold; /* Silence filling happens when |
@@ -2244,7 +2244,7 @@ struct _snd_pcm_runtime { | |||
2244 | <para> | 2244 | <para> |
2245 | For the operators (callbacks) of each sound driver, most of | 2245 | For the operators (callbacks) of each sound driver, most of |
2246 | these records are supposed to be read-only. Only the PCM | 2246 | these records are supposed to be read-only. Only the PCM |
2247 | middle-layer changes / updates these info. The exceptions are | 2247 | middle-layer changes / updates them. The exceptions are |
2248 | the hardware description (hw), interrupt callbacks | 2248 | the hardware description (hw), interrupt callbacks |
2249 | (transfer_ack_xxx), DMA buffer information, and the private | 2249 | (transfer_ack_xxx), DMA buffer information, and the private |
2250 | data. Besides, if you use the standard buffer allocation | 2250 | data. Besides, if you use the standard buffer allocation |
@@ -2285,7 +2285,7 @@ struct _snd_pcm_runtime { | |||
2285 | </para> | 2285 | </para> |
2286 | 2286 | ||
2287 | <para> | 2287 | <para> |
2288 | Typically, you'll have a hardware descriptor like below: | 2288 | Typically, you'll have a hardware descriptor as below: |
2289 | <informalexample> | 2289 | <informalexample> |
2290 | <programlisting> | 2290 | <programlisting> |
2291 | <![CDATA[ | 2291 | <![CDATA[ |
@@ -2320,10 +2320,10 @@ struct _snd_pcm_runtime { | |||
2320 | <constant>SNDRV_PCM_INFO_XXX</constant>. Here, at least, you | 2320 | <constant>SNDRV_PCM_INFO_XXX</constant>. Here, at least, you |
2321 | have to specify whether the mmap is supported and which | 2321 | have to specify whether the mmap is supported and which |
2322 | interleaved format is supported. | 2322 | interleaved format is supported. |
2323 | When the mmap is supported, add | 2323 | When the is supported, add the |
2324 | <constant>SNDRV_PCM_INFO_MMAP</constant> flag here. When the | 2324 | <constant>SNDRV_PCM_INFO_MMAP</constant> flag here. When the |
2325 | hardware supports the interleaved or the non-interleaved | 2325 | hardware supports the interleaved or the non-interleaved |
2326 | format, <constant>SNDRV_PCM_INFO_INTERLEAVED</constant> or | 2326 | formats, <constant>SNDRV_PCM_INFO_INTERLEAVED</constant> or |
2327 | <constant>SNDRV_PCM_INFO_NONINTERLEAVED</constant> flag must | 2327 | <constant>SNDRV_PCM_INFO_NONINTERLEAVED</constant> flag must |
2328 | be set, respectively. If both are supported, you can set both, | 2328 | be set, respectively. If both are supported, you can set both, |
2329 | too. | 2329 | too. |
@@ -2331,7 +2331,7 @@ struct _snd_pcm_runtime { | |||
2331 | 2331 | ||
2332 | <para> | 2332 | <para> |
2333 | In the above example, <constant>MMAP_VALID</constant> and | 2333 | In the above example, <constant>MMAP_VALID</constant> and |
2334 | <constant>BLOCK_TRANSFER</constant> are specified for OSS mmap | 2334 | <constant>BLOCK_TRANSFER</constant> are specified for the OSS mmap |
2335 | mode. Usually both are set. Of course, | 2335 | mode. Usually both are set. Of course, |
2336 | <constant>MMAP_VALID</constant> is set only if the mmap is | 2336 | <constant>MMAP_VALID</constant> is set only if the mmap is |
2337 | really supported. | 2337 | really supported. |
@@ -2345,11 +2345,11 @@ struct _snd_pcm_runtime { | |||
2345 | <quote>pause</quote> operation, while the | 2345 | <quote>pause</quote> operation, while the |
2346 | <constant>RESUME</constant> bit means that the pcm supports | 2346 | <constant>RESUME</constant> bit means that the pcm supports |
2347 | the full <quote>suspend/resume</quote> operation. | 2347 | the full <quote>suspend/resume</quote> operation. |
2348 | If <constant>PAUSE</constant> flag is set, | 2348 | If the <constant>PAUSE</constant> flag is set, |
2349 | the <structfield>trigger</structfield> callback below | 2349 | the <structfield>trigger</structfield> callback below |
2350 | must handle the corresponding (pause push/release) commands. | 2350 | must handle the corresponding (pause push/release) commands. |
2351 | The suspend/resume trigger commands can be defined even without | 2351 | The suspend/resume trigger commands can be defined even without |
2352 | <constant>RESUME</constant> flag. See <link | 2352 | the <constant>RESUME</constant> flag. See <link |
2353 | linkend="power-management"><citetitle> | 2353 | linkend="power-management"><citetitle> |
2354 | Power Management</citetitle></link> section for details. | 2354 | Power Management</citetitle></link> section for details. |
2355 | </para> | 2355 | </para> |
@@ -2382,7 +2382,7 @@ struct _snd_pcm_runtime { | |||
2382 | <constant>CONTINUOUS</constant> bit additionally. | 2382 | <constant>CONTINUOUS</constant> bit additionally. |
2383 | The pre-defined rate bits are provided only for typical | 2383 | The pre-defined rate bits are provided only for typical |
2384 | rates. If your chip supports unconventional rates, you need to add | 2384 | rates. If your chip supports unconventional rates, you need to add |
2385 | <constant>KNOT</constant> bit and set up the hardware | 2385 | the <constant>KNOT</constant> bit and set up the hardware |
2386 | constraint manually (explained later). | 2386 | constraint manually (explained later). |
2387 | </para> | 2387 | </para> |
2388 | </listitem> | 2388 | </listitem> |
@@ -2390,8 +2390,8 @@ struct _snd_pcm_runtime { | |||
2390 | <listitem> | 2390 | <listitem> |
2391 | <para> | 2391 | <para> |
2392 | <structfield>rate_min</structfield> and | 2392 | <structfield>rate_min</structfield> and |
2393 | <structfield>rate_max</structfield> define the minimal and | 2393 | <structfield>rate_max</structfield> define the minimum and |
2394 | maximal sample rate. This should correspond somehow to | 2394 | maximum sample rate. This should correspond somehow to |
2395 | <structfield>rates</structfield> bits. | 2395 | <structfield>rates</structfield> bits. |
2396 | </para> | 2396 | </para> |
2397 | </listitem> | 2397 | </listitem> |
@@ -2400,7 +2400,7 @@ struct _snd_pcm_runtime { | |||
2400 | <para> | 2400 | <para> |
2401 | <structfield>channel_min</structfield> and | 2401 | <structfield>channel_min</structfield> and |
2402 | <structfield>channel_max</structfield> | 2402 | <structfield>channel_max</structfield> |
2403 | define, as you might already expected, the minimal and maximal | 2403 | define, as you might already expected, the minimum and maximum |
2404 | number of channels. | 2404 | number of channels. |
2405 | </para> | 2405 | </para> |
2406 | </listitem> | 2406 | </listitem> |
@@ -2408,21 +2408,21 @@ struct _snd_pcm_runtime { | |||
2408 | <listitem> | 2408 | <listitem> |
2409 | <para> | 2409 | <para> |
2410 | <structfield>buffer_bytes_max</structfield> defines the | 2410 | <structfield>buffer_bytes_max</structfield> defines the |
2411 | maximal buffer size in bytes. There is no | 2411 | maximum buffer size in bytes. There is no |
2412 | <structfield>buffer_bytes_min</structfield> field, since | 2412 | <structfield>buffer_bytes_min</structfield> field, since |
2413 | it can be calculated from the minimal period size and the | 2413 | it can be calculated from the minimum period size and the |
2414 | minimal number of periods. | 2414 | minimum number of periods. |
2415 | Meanwhile, <structfield>period_bytes_min</structfield> and | 2415 | Meanwhile, <structfield>period_bytes_min</structfield> and |
2416 | define the minimal and maximal size of the period in bytes. | 2416 | define the minimum and maximum size of the period in bytes. |
2417 | <structfield>periods_max</structfield> and | 2417 | <structfield>periods_max</structfield> and |
2418 | <structfield>periods_min</structfield> define the maximal and | 2418 | <structfield>periods_min</structfield> define the maximum and |
2419 | minimal number of periods in the buffer. | 2419 | minimum number of periods in the buffer. |
2420 | </para> | 2420 | </para> |
2421 | 2421 | ||
2422 | <para> | 2422 | <para> |
2423 | The <quote>period</quote> is a term, that corresponds to | 2423 | The <quote>period</quote> is a term that corresponds to |
2424 | fragment in the OSS world. The period defines the size at | 2424 | a fragment in the OSS world. The period defines the size at |
2425 | which the PCM interrupt is generated. This size strongly | 2425 | which a PCM interrupt is generated. This size strongly |
2426 | depends on the hardware. | 2426 | depends on the hardware. |
2427 | Generally, the smaller period size will give you more | 2427 | Generally, the smaller period size will give you more |
2428 | interrupts, that is, more controls. | 2428 | interrupts, that is, more controls. |
@@ -2435,8 +2435,8 @@ struct _snd_pcm_runtime { | |||
2435 | <listitem> | 2435 | <listitem> |
2436 | <para> | 2436 | <para> |
2437 | There is also a field <structfield>fifo_size</structfield>. | 2437 | There is also a field <structfield>fifo_size</structfield>. |
2438 | This specifies the size of the hardware FIFO, but it's not | 2438 | This specifies the size of the hardware FIFO, but currently it |
2439 | used currently in the driver nor in the alsa-lib. So, you | 2439 | is neither used in the driver nor in the alsa-lib. So, you |
2440 | can ignore this field. | 2440 | can ignore this field. |
2441 | </para> | 2441 | </para> |
2442 | </listitem> | 2442 | </listitem> |
@@ -2450,7 +2450,7 @@ struct _snd_pcm_runtime { | |||
2450 | Ok, let's go back again to the PCM runtime records. | 2450 | Ok, let's go back again to the PCM runtime records. |
2451 | The most frequently referred records in the runtime instance are | 2451 | The most frequently referred records in the runtime instance are |
2452 | the PCM configurations. | 2452 | the PCM configurations. |
2453 | The PCM configurations are stored on runtime instance | 2453 | The PCM configurations are stored in the runtime instance |
2454 | after the application sends <type>hw_params</type> data via | 2454 | after the application sends <type>hw_params</type> data via |
2455 | alsa-lib. There are many fields copied from hw_params and | 2455 | alsa-lib. There are many fields copied from hw_params and |
2456 | sw_params structs. For example, | 2456 | sw_params structs. For example, |
@@ -2461,11 +2461,11 @@ struct _snd_pcm_runtime { | |||
2461 | 2461 | ||
2462 | <para> | 2462 | <para> |
2463 | One thing to be noted is that the configured buffer and period | 2463 | One thing to be noted is that the configured buffer and period |
2464 | sizes are stored in <quote>frames</quote> in the runtime | 2464 | sizes are stored in <quote>frames</quote> in the runtime. |
2465 | In the ALSA world, 1 frame = channels * samples-size. | 2465 | In the ALSA world, 1 frame = channels * samples-size. |
2466 | For conversion between frames and bytes, you can use the | 2466 | For conversion between frames and bytes, you can use the |
2467 | helper functions, <function>frames_to_bytes()</function> and | 2467 | <function>frames_to_bytes()</function> and |
2468 | <function>bytes_to_frames()</function>. | 2468 | <function>bytes_to_frames()</function> helper functions. |
2469 | <informalexample> | 2469 | <informalexample> |
2470 | <programlisting> | 2470 | <programlisting> |
2471 | <![CDATA[ | 2471 | <![CDATA[ |
@@ -2515,7 +2515,7 @@ struct _snd_pcm_runtime { | |||
2515 | <structfield>dma_area</structfield> is necessary when the | 2515 | <structfield>dma_area</structfield> is necessary when the |
2516 | buffer is mmapped. If your driver doesn't support mmap, this | 2516 | buffer is mmapped. If your driver doesn't support mmap, this |
2517 | field is not necessary. <structfield>dma_addr</structfield> | 2517 | field is not necessary. <structfield>dma_addr</structfield> |
2518 | is also not mandatory. You can use | 2518 | is also optional. You can use |
2519 | <structfield>dma_private</structfield> as you like, too. | 2519 | <structfield>dma_private</structfield> as you like, too. |
2520 | </para> | 2520 | </para> |
2521 | </section> | 2521 | </section> |
@@ -2524,14 +2524,14 @@ struct _snd_pcm_runtime { | |||
2524 | <title>Running Status</title> | 2524 | <title>Running Status</title> |
2525 | <para> | 2525 | <para> |
2526 | The running status can be referred via <constant>runtime->status</constant>. | 2526 | The running status can be referred via <constant>runtime->status</constant>. |
2527 | This is the pointer to struct <structname>snd_pcm_mmap_status</structname> | 2527 | This is the pointer to the struct <structname>snd_pcm_mmap_status</structname> |
2528 | record. For example, you can get the current DMA hardware | 2528 | record. For example, you can get the current DMA hardware |
2529 | pointer via <constant>runtime->status->hw_ptr</constant>. | 2529 | pointer via <constant>runtime->status->hw_ptr</constant>. |
2530 | </para> | 2530 | </para> |
2531 | 2531 | ||
2532 | <para> | 2532 | <para> |
2533 | The DMA application pointer can be referred via | 2533 | The DMA application pointer can be referred via |
2534 | <constant>runtime->control</constant>, which points | 2534 | <constant>runtime->control</constant>, which points to the |
2535 | struct <structname>snd_pcm_mmap_control</structname> record. | 2535 | struct <structname>snd_pcm_mmap_control</structname> record. |
2536 | However, accessing directly to this value is not recommended. | 2536 | However, accessing directly to this value is not recommended. |
2537 | </para> | 2537 | </para> |
@@ -2542,14 +2542,14 @@ struct _snd_pcm_runtime { | |||
2542 | <para> | 2542 | <para> |
2543 | You can allocate a record for the substream and store it in | 2543 | You can allocate a record for the substream and store it in |
2544 | <constant>runtime->private_data</constant>. Usually, this | 2544 | <constant>runtime->private_data</constant>. Usually, this |
2545 | done in | 2545 | is done in |
2546 | <link linkend="pcm-interface-operators-open-callback"><citetitle> | 2546 | <link linkend="pcm-interface-operators-open-callback"><citetitle> |
2547 | the open callback</citetitle></link>. | 2547 | the open callback</citetitle></link>. |
2548 | Don't mix this with <constant>pcm->private_data</constant>. | 2548 | Don't mix this with <constant>pcm->private_data</constant>. |
2549 | The <constant>pcm->private_data</constant> usually points the | 2549 | The <constant>pcm->private_data</constant> usually points to the |
2550 | chip instance assigned statically at the creation of PCM, while the | 2550 | chip instance assigned statically at the creation of PCM, while the |
2551 | <constant>runtime->private_data</constant> points a dynamic | 2551 | <constant>runtime->private_data</constant> points to a dynamic |
2552 | data created at the PCM open callback. | 2552 | data structure created at the PCM open callback. |
2553 | 2553 | ||
2554 | <informalexample> | 2554 | <informalexample> |
2555 | <programlisting> | 2555 | <programlisting> |
@@ -2579,7 +2579,7 @@ struct _snd_pcm_runtime { | |||
2579 | <para> | 2579 | <para> |
2580 | The field <structfield>transfer_ack_begin</structfield> and | 2580 | The field <structfield>transfer_ack_begin</structfield> and |
2581 | <structfield>transfer_ack_end</structfield> are called at | 2581 | <structfield>transfer_ack_end</structfield> are called at |
2582 | the beginning and the end of | 2582 | the beginning and at the end of |
2583 | <function>snd_pcm_period_elapsed()</function>, respectively. | 2583 | <function>snd_pcm_period_elapsed()</function>, respectively. |
2584 | </para> | 2584 | </para> |
2585 | </section> | 2585 | </section> |
@@ -2589,17 +2589,18 @@ struct _snd_pcm_runtime { | |||
2589 | <section id="pcm-interface-operators"> | 2589 | <section id="pcm-interface-operators"> |
2590 | <title>Operators</title> | 2590 | <title>Operators</title> |
2591 | <para> | 2591 | <para> |
2592 | OK, now let me explain the detail of each pcm callback | 2592 | OK, now let me give details about each pcm callback |
2593 | (<parameter>ops</parameter>). In general, every callback must | 2593 | (<parameter>ops</parameter>). In general, every callback must |
2594 | return 0 if successful, or a negative number with the error | 2594 | return 0 if successful, or a negative error number |
2595 | number such as <constant>-EINVAL</constant> at any | 2595 | such as <constant>-EINVAL</constant>. To choose an appropriate |
2596 | error. | 2596 | error number, it is advised to check what value other parts of |
2597 | the kernel return when the same kind of request fails. | ||
2597 | </para> | 2598 | </para> |
2598 | 2599 | ||
2599 | <para> | 2600 | <para> |
2600 | The callback function takes at least the argument with | 2601 | The callback function takes at least the argument with |
2601 | <structname>snd_pcm_substream</structname> pointer. For retrieving the | 2602 | <structname>snd_pcm_substream</structname> pointer. To retrieve |
2602 | chip record from the given substream instance, you can use the | 2603 | the chip record from the given substream instance, you can use the |
2603 | following macro. | 2604 | following macro. |
2604 | 2605 | ||
2605 | <informalexample> | 2606 | <informalexample> |
@@ -2616,7 +2617,7 @@ struct _snd_pcm_runtime { | |||
2616 | The macro reads <constant>substream->private_data</constant>, | 2617 | The macro reads <constant>substream->private_data</constant>, |
2617 | which is a copy of <constant>pcm->private_data</constant>. | 2618 | which is a copy of <constant>pcm->private_data</constant>. |
2618 | You can override the former if you need to assign different data | 2619 | You can override the former if you need to assign different data |
2619 | records per PCM substream. For example, cmi8330 driver assigns | 2620 | records per PCM substream. For example, the cmi8330 driver assigns |
2620 | different private_data for playback and capture directions, | 2621 | different private_data for playback and capture directions, |
2621 | because it uses two different codecs (SB- and AD-compatible) for | 2622 | because it uses two different codecs (SB- and AD-compatible) for |
2622 | different directions. | 2623 | different directions. |
@@ -2709,7 +2710,7 @@ struct _snd_pcm_runtime { | |||
2709 | <section id="pcm-interface-operators-ioctl-callback"> | 2710 | <section id="pcm-interface-operators-ioctl-callback"> |
2710 | <title>ioctl callback</title> | 2711 | <title>ioctl callback</title> |
2711 | <para> | 2712 | <para> |
2712 | This is used for any special action to pcm ioctls. But | 2713 | This is used for any special call to pcm ioctls. But |
2713 | usually you can pass a generic ioctl callback, | 2714 | usually you can pass a generic ioctl callback, |
2714 | <function>snd_pcm_lib_ioctl</function>. | 2715 | <function>snd_pcm_lib_ioctl</function>. |
2715 | </para> | 2716 | </para> |
@@ -2726,9 +2727,6 @@ struct _snd_pcm_runtime { | |||
2726 | ]]> | 2727 | ]]> |
2727 | </programlisting> | 2728 | </programlisting> |
2728 | </informalexample> | 2729 | </informalexample> |
2729 | |||
2730 | This and <structfield>hw_free</structfield> callbacks exist | ||
2731 | only on ALSA 0.9.x. | ||
2732 | </para> | 2730 | </para> |
2733 | 2731 | ||
2734 | <para> | 2732 | <para> |
@@ -2740,13 +2738,13 @@ struct _snd_pcm_runtime { | |||
2740 | </para> | 2738 | </para> |
2741 | 2739 | ||
2742 | <para> | 2740 | <para> |
2743 | Many hardware set-up should be done in this callback, | 2741 | Many hardware setups should be done in this callback, |
2744 | including the allocation of buffers. | 2742 | including the allocation of buffers. |
2745 | </para> | 2743 | </para> |
2746 | 2744 | ||
2747 | <para> | 2745 | <para> |
2748 | Parameters to be initialized are retrieved by | 2746 | Parameters to be initialized are retrieved by |
2749 | <function>params_xxx()</function> macros. For allocating a | 2747 | <function>params_xxx()</function> macros. To allocate |
2750 | buffer, you can call a helper function, | 2748 | buffer, you can call a helper function, |
2751 | 2749 | ||
2752 | <informalexample> | 2750 | <informalexample> |
@@ -2772,8 +2770,8 @@ struct _snd_pcm_runtime { | |||
2772 | </para> | 2770 | </para> |
2773 | 2771 | ||
2774 | <para> | 2772 | <para> |
2775 | Thus, you need to take care not to allocate the same buffers | 2773 | Thus, you need to be careful not to allocate the same buffers |
2776 | many times, which will lead to memory leak! Calling the | 2774 | many times, which will lead to memory leaks! Calling the |
2777 | helper function above many times is OK. It will release the | 2775 | helper function above many times is OK. It will release the |
2778 | previous buffer automatically when it was already allocated. | 2776 | previous buffer automatically when it was already allocated. |
2779 | </para> | 2777 | </para> |
@@ -2782,7 +2780,7 @@ struct _snd_pcm_runtime { | |||
2782 | Another note is that this callback is non-atomic | 2780 | Another note is that this callback is non-atomic |
2783 | (schedulable). This is important, because the | 2781 | (schedulable). This is important, because the |
2784 | <structfield>trigger</structfield> callback | 2782 | <structfield>trigger</structfield> callback |
2785 | is atomic (non-schedulable). That is, mutex or any | 2783 | is atomic (non-schedulable). That is, mutexes or any |
2786 | schedule-related functions are not available in | 2784 | schedule-related functions are not available in |
2787 | <structfield>trigger</structfield> callback. | 2785 | <structfield>trigger</structfield> callback. |
2788 | Please see the subsection | 2786 | Please see the subsection |
@@ -2843,15 +2841,15 @@ struct _snd_pcm_runtime { | |||
2843 | <quote>prepared</quote>. You can set the format type, sample | 2841 | <quote>prepared</quote>. You can set the format type, sample |
2844 | rate, etc. here. The difference from | 2842 | rate, etc. here. The difference from |
2845 | <structfield>hw_params</structfield> is that the | 2843 | <structfield>hw_params</structfield> is that the |
2846 | <structfield>prepare</structfield> callback will be called at each | 2844 | <structfield>prepare</structfield> callback will be called each |
2847 | time | 2845 | time |
2848 | <function>snd_pcm_prepare()</function> is called, i.e. when | 2846 | <function>snd_pcm_prepare()</function> is called, i.e. when |
2849 | recovered after underruns, etc. | 2847 | recovering after underruns, etc. |
2850 | </para> | 2848 | </para> |
2851 | 2849 | ||
2852 | <para> | 2850 | <para> |
2853 | Note that this callback became non-atomic since the recent version. | 2851 | Note that this callback is now non-atomic. |
2854 | You can use schedule-related functions safely in this callback now. | 2852 | You can use schedule-related functions safely in this callback. |
2855 | </para> | 2853 | </para> |
2856 | 2854 | ||
2857 | <para> | 2855 | <para> |
@@ -2871,7 +2869,7 @@ struct _snd_pcm_runtime { | |||
2871 | 2869 | ||
2872 | <para> | 2870 | <para> |
2873 | Be careful that this callback will be called many times at | 2871 | Be careful that this callback will be called many times at |
2874 | each set up, too. | 2872 | each setup, too. |
2875 | </para> | 2873 | </para> |
2876 | </section> | 2874 | </section> |
2877 | 2875 | ||
@@ -2893,7 +2891,7 @@ struct _snd_pcm_runtime { | |||
2893 | Which action is specified in the second argument, | 2891 | Which action is specified in the second argument, |
2894 | <constant>SNDRV_PCM_TRIGGER_XXX</constant> in | 2892 | <constant>SNDRV_PCM_TRIGGER_XXX</constant> in |
2895 | <filename><sound/pcm.h></filename>. At least, | 2893 | <filename><sound/pcm.h></filename>. At least, |
2896 | <constant>START</constant> and <constant>STOP</constant> | 2894 | the <constant>START</constant> and <constant>STOP</constant> |
2897 | commands must be defined in this callback. | 2895 | commands must be defined in this callback. |
2898 | 2896 | ||
2899 | <informalexample> | 2897 | <informalexample> |
@@ -2915,8 +2913,8 @@ struct _snd_pcm_runtime { | |||
2915 | </para> | 2913 | </para> |
2916 | 2914 | ||
2917 | <para> | 2915 | <para> |
2918 | When the pcm supports the pause operation (given in info | 2916 | When the pcm supports the pause operation (given in the info |
2919 | field of the hardware table), <constant>PAUSE_PUSE</constant> | 2917 | field of the hardware table), the <constant>PAUSE_PUSE</constant> |
2920 | and <constant>PAUSE_RELEASE</constant> commands must be | 2918 | and <constant>PAUSE_RELEASE</constant> commands must be |
2921 | handled here, too. The former is the command to pause the pcm, | 2919 | handled here, too. The former is the command to pause the pcm, |
2922 | and the latter to restart the pcm again. | 2920 | and the latter to restart the pcm again. |
@@ -2925,21 +2923,21 @@ struct _snd_pcm_runtime { | |||
2925 | <para> | 2923 | <para> |
2926 | When the pcm supports the suspend/resume operation, | 2924 | When the pcm supports the suspend/resume operation, |
2927 | regardless of full or partial suspend/resume support, | 2925 | regardless of full or partial suspend/resume support, |
2928 | <constant>SUSPEND</constant> and <constant>RESUME</constant> | 2926 | the <constant>SUSPEND</constant> and <constant>RESUME</constant> |
2929 | commands must be handled, too. | 2927 | commands must be handled, too. |
2930 | These commands are issued when the power-management status is | 2928 | These commands are issued when the power-management status is |
2931 | changed. Obviously, the <constant>SUSPEND</constant> and | 2929 | changed. Obviously, the <constant>SUSPEND</constant> and |
2932 | <constant>RESUME</constant> | 2930 | <constant>RESUME</constant> commands |
2933 | do suspend and resume of the pcm substream, and usually, they | 2931 | suspend and resume the pcm substream, and usually, they |
2934 | are identical with <constant>STOP</constant> and | 2932 | are identical to the <constant>STOP</constant> and |
2935 | <constant>START</constant> commands, respectively. | 2933 | <constant>START</constant> commands, respectively. |
2936 | See <link linkend="power-management"><citetitle> | 2934 | See the <link linkend="power-management"><citetitle> |
2937 | Power Management</citetitle></link> section for details. | 2935 | Power Management</citetitle></link> section for details. |
2938 | </para> | 2936 | </para> |
2939 | 2937 | ||
2940 | <para> | 2938 | <para> |
2941 | As mentioned, this callback is atomic. You cannot call | 2939 | As mentioned, this callback is atomic. You cannot call |
2942 | the function going to sleep. | 2940 | functions which may sleep. |
2943 | The trigger callback should be as minimal as possible, | 2941 | The trigger callback should be as minimal as possible, |
2944 | just really triggering the DMA. The other stuff should be | 2942 | just really triggering the DMA. The other stuff should be |
2945 | initialized hw_params and prepare callbacks properly | 2943 | initialized hw_params and prepare callbacks properly |
@@ -2960,8 +2958,8 @@ struct _snd_pcm_runtime { | |||
2960 | 2958 | ||
2961 | This callback is called when the PCM middle layer inquires | 2959 | This callback is called when the PCM middle layer inquires |
2962 | the current hardware position on the buffer. The position must | 2960 | the current hardware position on the buffer. The position must |
2963 | be returned in frames (which was in bytes on ALSA 0.5.x), | 2961 | be returned in frames, |
2964 | ranged from 0 to buffer_size - 1. | 2962 | ranging from 0 to buffer_size - 1. |
2965 | </para> | 2963 | </para> |
2966 | 2964 | ||
2967 | <para> | 2965 | <para> |
@@ -2983,7 +2981,7 @@ struct _snd_pcm_runtime { | |||
2983 | <para> | 2981 | <para> |
2984 | These callbacks are not mandatory, and can be omitted in | 2982 | These callbacks are not mandatory, and can be omitted in |
2985 | most cases. These callbacks are used when the hardware buffer | 2983 | most cases. These callbacks are used when the hardware buffer |
2986 | cannot be on the normal memory space. Some chips have their | 2984 | cannot be in the normal memory space. Some chips have their |
2987 | own buffer on the hardware which is not mappable. In such a | 2985 | own buffer on the hardware which is not mappable. In such a |
2988 | case, you have to transfer the data manually from the memory | 2986 | case, you have to transfer the data manually from the memory |
2989 | buffer to the hardware buffer. Or, if the buffer is | 2987 | buffer to the hardware buffer. Or, if the buffer is |
@@ -3018,8 +3016,8 @@ struct _snd_pcm_runtime { | |||
3018 | <title>page callback</title> | 3016 | <title>page callback</title> |
3019 | 3017 | ||
3020 | <para> | 3018 | <para> |
3021 | This callback is also not mandatory. This callback is used | 3019 | This callback is optional too. This callback is used |
3022 | mainly for the non-contiguous buffer. The mmap calls this | 3020 | mainly for non-contiguous buffers. The mmap calls this |
3023 | callback to get the page address. Some examples will be | 3021 | callback to get the page address. Some examples will be |
3024 | explained in the later section <link | 3022 | explained in the later section <link |
3025 | linkend="buffer-and-memory"><citetitle>Buffer and Memory | 3023 | linkend="buffer-and-memory"><citetitle>Buffer and Memory |
@@ -3035,7 +3033,7 @@ struct _snd_pcm_runtime { | |||
3035 | role of PCM interrupt handler in the sound driver is to update | 3033 | role of PCM interrupt handler in the sound driver is to update |
3036 | the buffer position and to tell the PCM middle layer when the | 3034 | the buffer position and to tell the PCM middle layer when the |
3037 | buffer position goes across the prescribed period size. To | 3035 | buffer position goes across the prescribed period size. To |
3038 | inform this, call <function>snd_pcm_period_elapsed()</function> | 3036 | inform this, call the <function>snd_pcm_period_elapsed()</function> |
3039 | function. | 3037 | function. |
3040 | </para> | 3038 | </para> |
3041 | 3039 | ||
@@ -3072,7 +3070,7 @@ struct _snd_pcm_runtime { | |||
3072 | </para> | 3070 | </para> |
3073 | 3071 | ||
3074 | <para> | 3072 | <para> |
3075 | A typical coding would be like: | 3073 | Typical code would be like: |
3076 | 3074 | ||
3077 | <example> | 3075 | <example> |
3078 | <title>Interrupt Handler Case #1</title> | 3076 | <title>Interrupt Handler Case #1</title> |
@@ -3101,21 +3099,21 @@ struct _snd_pcm_runtime { | |||
3101 | </section> | 3099 | </section> |
3102 | 3100 | ||
3103 | <section id="pcm-interface-interrupt-handler-timer"> | 3101 | <section id="pcm-interface-interrupt-handler-timer"> |
3104 | <title>High-frequent timer interrupts</title> | 3102 | <title>High frequency timer interrupts</title> |
3105 | <para> | 3103 | <para> |
3106 | This is the case when the hardware doesn't generate interrupts | 3104 | This happense when the hardware doesn't generate interrupts |
3107 | at the period boundary but do timer-interrupts at the fixed | 3105 | at the period boundary but issues timer interrupts at a fixed |
3108 | timer rate (e.g. es1968 or ymfpci drivers). | 3106 | timer rate (e.g. es1968 or ymfpci drivers). |
3109 | In this case, you need to check the current hardware | 3107 | In this case, you need to check the current hardware |
3110 | position and accumulates the processed sample length at each | 3108 | position and accumulate the processed sample length at each |
3111 | interrupt. When the accumulated size overcomes the period | 3109 | interrupt. When the accumulated size exceeds the period |
3112 | size, call | 3110 | size, call |
3113 | <function>snd_pcm_period_elapsed()</function> and reset the | 3111 | <function>snd_pcm_period_elapsed()</function> and reset the |
3114 | accumulator. | 3112 | accumulator. |
3115 | </para> | 3113 | </para> |
3116 | 3114 | ||
3117 | <para> | 3115 | <para> |
3118 | A typical coding would be like the following. | 3116 | Typical code would be like the following. |
3119 | 3117 | ||
3120 | <example> | 3118 | <example> |
3121 | <title>Interrupt Handler Case #2</title> | 3119 | <title>Interrupt Handler Case #2</title> |
@@ -3178,32 +3176,33 @@ struct _snd_pcm_runtime { | |||
3178 | <section id="pcm-interface-atomicity"> | 3176 | <section id="pcm-interface-atomicity"> |
3179 | <title>Atomicity</title> | 3177 | <title>Atomicity</title> |
3180 | <para> | 3178 | <para> |
3181 | One of the most important (and thus difficult to debug) problem | 3179 | One of the most important (and thus difficult to debug) problems |
3182 | on the kernel programming is the race condition. | 3180 | in kernel programming are race conditions. |
3183 | On linux kernel, usually it's solved via spin-locks or | 3181 | In the Linux kernel, they are usually avoided via spin-locks, mutexes |
3184 | semaphores. In general, if the race condition may | 3182 | or semaphores. In general, if a race condition can happen |
3185 | happen in the interrupt handler, it's handled as atomic, and you | 3183 | in an interrupt handler, it has to be managed atomically, and you |
3186 | have to use spinlock for protecting the critical session. If it | 3184 | have to use a spinlock to protect the critical session. If the |
3187 | never happens in the interrupt and it may take relatively long | 3185 | critical section is not in interrupt handler code and |
3188 | time, you should use semaphore. | 3186 | if taking a relatively long time to execute is acceptable, you |
3187 | should use mutexes or semaphores instead. | ||
3189 | </para> | 3188 | </para> |
3190 | 3189 | ||
3191 | <para> | 3190 | <para> |
3192 | As already seen, some pcm callbacks are atomic and some are | 3191 | As already seen, some pcm callbacks are atomic and some are |
3193 | not. For example, <parameter>hw_params</parameter> callback is | 3192 | not. For example, the <parameter>hw_params</parameter> callback is |
3194 | non-atomic, while <parameter>trigger</parameter> callback is | 3193 | non-atomic, while <parameter>trigger</parameter> callback is |
3195 | atomic. This means, the latter is called already in a spinlock | 3194 | atomic. This means, the latter is called already in a spinlock |
3196 | held by the PCM middle layer. Please take this atomicity into | 3195 | held by the PCM middle layer. Please take this atomicity into |
3197 | account when you use a spinlock or a semaphore in the callbacks. | 3196 | account when you choose a locking scheme in the callbacks. |
3198 | </para> | 3197 | </para> |
3199 | 3198 | ||
3200 | <para> | 3199 | <para> |
3201 | In the atomic callbacks, you cannot use functions which may call | 3200 | In the atomic callbacks, you cannot use functions which may call |
3202 | <function>schedule</function> or go to | 3201 | <function>schedule</function> or go to |
3203 | <function>sleep</function>. The semaphore and mutex do sleep, | 3202 | <function>sleep</function>. Semaphores and mutexes can sleep, |
3204 | and hence they cannot be used inside the atomic callbacks | 3203 | and hence they cannot be used inside the atomic callbacks |
3205 | (e.g. <parameter>trigger</parameter> callback). | 3204 | (e.g. <parameter>trigger</parameter> callback). |
3206 | For taking a certain delay in such a callback, please use | 3205 | To implement some delay in such a callback, please use |
3207 | <function>udelay()</function> or <function>mdelay()</function>. | 3206 | <function>udelay()</function> or <function>mdelay()</function>. |
3208 | </para> | 3207 | </para> |
3209 | 3208 | ||
@@ -3257,7 +3256,7 @@ struct _snd_pcm_runtime { | |||
3257 | 3256 | ||
3258 | <para> | 3257 | <para> |
3259 | There are many different constraints. | 3258 | There are many different constraints. |
3260 | Look in <filename>sound/pcm.h</filename> for a complete list. | 3259 | Look at <filename>sound/pcm.h</filename> for a complete list. |
3261 | You can even define your own constraint rules. | 3260 | You can even define your own constraint rules. |
3262 | For example, let's suppose my_chip can manage a substream of 1 channel | 3261 | For example, let's suppose my_chip can manage a substream of 1 channel |
3263 | if and only if the format is S16_LE, otherwise it supports any format | 3262 | if and only if the format is S16_LE, otherwise it supports any format |
@@ -3346,7 +3345,7 @@ struct _snd_pcm_runtime { | |||
3346 | </para> | 3345 | </para> |
3347 | 3346 | ||
3348 | <para> | 3347 | <para> |
3349 | I won't explain more details here, rather I | 3348 | I won't give more details here, rather I |
3350 | would like to say, <quote>Luke, use the source.</quote> | 3349 | would like to say, <quote>Luke, use the source.</quote> |
3351 | </para> | 3350 | </para> |
3352 | </section> | 3351 | </section> |
@@ -3364,10 +3363,9 @@ struct _snd_pcm_runtime { | |||
3364 | <title>General</title> | 3363 | <title>General</title> |
3365 | <para> | 3364 | <para> |
3366 | The control interface is used widely for many switches, | 3365 | The control interface is used widely for many switches, |
3367 | sliders, etc. which are accessed from the user-space. Its most | 3366 | sliders, etc. which are accessed from user-space. Its most |
3368 | important use is the mixer interface. In other words, on ALSA | 3367 | important use is the mixer interface. In other words, since ALSA |
3369 | 0.9.x, all the mixer stuff is implemented on the control kernel | 3368 | 0.9.x, all the mixer stuff is implemented on the control kernel API. |
3370 | API (while there was an independent mixer kernel API on 0.5.x). | ||
3371 | </para> | 3369 | </para> |
3372 | 3370 | ||
3373 | <para> | 3371 | <para> |
@@ -3379,14 +3377,15 @@ struct _snd_pcm_runtime { | |||
3379 | <para> | 3377 | <para> |
3380 | The control API is defined in | 3378 | The control API is defined in |
3381 | <filename><sound/control.h></filename>. | 3379 | <filename><sound/control.h></filename>. |
3382 | Include this file if you add your own controls. | 3380 | Include this file if you want to add your own controls. |
3383 | </para> | 3381 | </para> |
3384 | </section> | 3382 | </section> |
3385 | 3383 | ||
3386 | <section id="control-interface-definition"> | 3384 | <section id="control-interface-definition"> |
3387 | <title>Definition of Controls</title> | 3385 | <title>Definition of Controls</title> |
3388 | <para> | 3386 | <para> |
3389 | For creating a new control, you need to define the three | 3387 | To create a new control, you need to define the |
3388 | following three | ||
3390 | callbacks: <structfield>info</structfield>, | 3389 | callbacks: <structfield>info</structfield>, |
3391 | <structfield>get</structfield> and | 3390 | <structfield>get</structfield> and |
3392 | <structfield>put</structfield>. Then, define a | 3391 | <structfield>put</structfield>. Then, define a |
@@ -3414,13 +3413,13 @@ struct _snd_pcm_runtime { | |||
3414 | <para> | 3413 | <para> |
3415 | Most likely the control is created via | 3414 | Most likely the control is created via |
3416 | <function>snd_ctl_new1()</function>, and in such a case, you can | 3415 | <function>snd_ctl_new1()</function>, and in such a case, you can |
3417 | add <parameter>__devinitdata</parameter> prefix to the | 3416 | add the <parameter>__devinitdata</parameter> prefix to the |
3418 | definition like above. | 3417 | definition as above. |
3419 | </para> | 3418 | </para> |
3420 | 3419 | ||
3421 | <para> | 3420 | <para> |
3422 | The <structfield>iface</structfield> field specifies the type of | 3421 | The <structfield>iface</structfield> field specifies the control |
3423 | the control, <constant>SNDRV_CTL_ELEM_IFACE_XXX</constant>, which | 3422 | type, <constant>SNDRV_CTL_ELEM_IFACE_XXX</constant>, which |
3424 | is usually <constant>MIXER</constant>. | 3423 | is usually <constant>MIXER</constant>. |
3425 | Use <constant>CARD</constant> for global controls that are not | 3424 | Use <constant>CARD</constant> for global controls that are not |
3426 | logically part of the mixer. | 3425 | logically part of the mixer. |
@@ -3435,12 +3434,11 @@ struct _snd_pcm_runtime { | |||
3435 | 3434 | ||
3436 | <para> | 3435 | <para> |
3437 | The <structfield>name</structfield> is the name identifier | 3436 | The <structfield>name</structfield> is the name identifier |
3438 | string. On ALSA 0.9.x, the control name is very important, | 3437 | string. Since ALSA 0.9.x, the control name is very important, |
3439 | because its role is classified from its name. There are | 3438 | because its role is classified from its name. There are |
3440 | pre-defined standard control names. The details are described in | 3439 | pre-defined standard control names. The details are described in |
3441 | the subsection | 3440 | the <link linkend="control-interface-control-names"><citetitle> |
3442 | <link linkend="control-interface-control-names"><citetitle> | 3441 | Control Names</citetitle></link> subsection. |
3443 | Control Names</citetitle></link>. | ||
3444 | </para> | 3442 | </para> |
3445 | 3443 | ||
3446 | <para> | 3444 | <para> |
@@ -3456,15 +3454,15 @@ struct _snd_pcm_runtime { | |||
3456 | The <structfield>access</structfield> field contains the access | 3454 | The <structfield>access</structfield> field contains the access |
3457 | type of this control. Give the combination of bit masks, | 3455 | type of this control. Give the combination of bit masks, |
3458 | <constant>SNDRV_CTL_ELEM_ACCESS_XXX</constant>, there. | 3456 | <constant>SNDRV_CTL_ELEM_ACCESS_XXX</constant>, there. |
3459 | The detailed will be explained in the subsection | 3457 | The details will be explained in |
3460 | <link linkend="control-interface-access-flags"><citetitle> | 3458 | the <link linkend="control-interface-access-flags"><citetitle> |
3461 | Access Flags</citetitle></link>. | 3459 | Access Flags</citetitle></link> subsection. |
3462 | </para> | 3460 | </para> |
3463 | 3461 | ||
3464 | <para> | 3462 | <para> |
3465 | The <structfield>private_value</structfield> field contains | 3463 | The <structfield>private_value</structfield> field contains |
3466 | an arbitrary long integer value for this record. When using | 3464 | an arbitrary long integer value for this record. When using |
3467 | generic <structfield>info</structfield>, | 3465 | the generic <structfield>info</structfield>, |
3468 | <structfield>get</structfield> and | 3466 | <structfield>get</structfield> and |
3469 | <structfield>put</structfield> callbacks, you can pass a value | 3467 | <structfield>put</structfield> callbacks, you can pass a value |
3470 | through this field. If several small numbers are necessary, you can | 3468 | through this field. If several small numbers are necessary, you can |
@@ -3489,7 +3487,7 @@ struct _snd_pcm_runtime { | |||
3489 | <section id="control-interface-control-names"> | 3487 | <section id="control-interface-control-names"> |
3490 | <title>Control Names</title> | 3488 | <title>Control Names</title> |
3491 | <para> | 3489 | <para> |
3492 | There are some standards for defining the control names. A | 3490 | There are some standards to define the control names. A |
3493 | control is usually defined from the three parts as | 3491 | control is usually defined from the three parts as |
3494 | <quote>SOURCE DIRECTION FUNCTION</quote>. | 3492 | <quote>SOURCE DIRECTION FUNCTION</quote>. |
3495 | </para> | 3493 | </para> |
@@ -3497,7 +3495,7 @@ struct _snd_pcm_runtime { | |||
3497 | <para> | 3495 | <para> |
3498 | The first, <constant>SOURCE</constant>, specifies the source | 3496 | The first, <constant>SOURCE</constant>, specifies the source |
3499 | of the control, and is a string such as <quote>Master</quote>, | 3497 | of the control, and is a string such as <quote>Master</quote>, |
3500 | <quote>PCM</quote>, <quote>CD</quote> or | 3498 | <quote>PCM</quote>, <quote>CD</quote> and |
3501 | <quote>Line</quote>. There are many pre-defined sources. | 3499 | <quote>Line</quote>. There are many pre-defined sources. |
3502 | </para> | 3500 | </para> |
3503 | 3501 | ||
@@ -3575,22 +3573,22 @@ struct _snd_pcm_runtime { | |||
3575 | <title>Access Flags</title> | 3573 | <title>Access Flags</title> |
3576 | 3574 | ||
3577 | <para> | 3575 | <para> |
3578 | The access flag is the bit-flags which specifies the access type | 3576 | The access flag is the bitmask which specifies the access type |
3579 | of the given control. The default access type is | 3577 | of the given control. The default access type is |
3580 | <constant>SNDRV_CTL_ELEM_ACCESS_READWRITE</constant>, | 3578 | <constant>SNDRV_CTL_ELEM_ACCESS_READWRITE</constant>, |
3581 | which means both read and write are allowed to this control. | 3579 | which means both read and write are allowed to this control. |
3582 | When the access flag is omitted (i.e. = 0), it is | 3580 | When the access flag is omitted (i.e. = 0), it is |
3583 | regarded as <constant>READWRITE</constant> access as default. | 3581 | considered as <constant>READWRITE</constant> access as default. |
3584 | </para> | 3582 | </para> |
3585 | 3583 | ||
3586 | <para> | 3584 | <para> |
3587 | When the control is read-only, pass | 3585 | When the control is read-only, pass |
3588 | <constant>SNDRV_CTL_ELEM_ACCESS_READ</constant> instead. | 3586 | <constant>SNDRV_CTL_ELEM_ACCESS_READ</constant> instead. |
3589 | In this case, you don't have to define | 3587 | In this case, you don't have to define |
3590 | <structfield>put</structfield> callback. | 3588 | the <structfield>put</structfield> callback. |
3591 | Similarly, when the control is write-only (although it's a rare | 3589 | Similarly, when the control is write-only (although it's a rare |
3592 | case), you can use <constant>WRITE</constant> flag instead, and | 3590 | case), you can use the <constant>WRITE</constant> flag instead, and |
3593 | you don't need <structfield>get</structfield> callback. | 3591 | you don't need the <structfield>get</structfield> callback. |
3594 | </para> | 3592 | </para> |
3595 | 3593 | ||
3596 | <para> | 3594 | <para> |
@@ -3598,15 +3596,15 @@ struct _snd_pcm_runtime { | |||
3598 | <constant>VOLATILE</constant> flag should be given. This means | 3596 | <constant>VOLATILE</constant> flag should be given. This means |
3599 | that the control may be changed without | 3597 | that the control may be changed without |
3600 | <link linkend="control-interface-change-notification"><citetitle> | 3598 | <link linkend="control-interface-change-notification"><citetitle> |
3601 | notification</citetitle></link>. Applications should poll such | 3599 | notification</citetitle></link>. Applications should poll such |
3602 | a control constantly. | 3600 | a control constantly. |
3603 | </para> | 3601 | </para> |
3604 | 3602 | ||
3605 | <para> | 3603 | <para> |
3606 | When the control is inactive, set | 3604 | When the control is inactive, set |
3607 | <constant>INACTIVE</constant> flag, too. | 3605 | the <constant>INACTIVE</constant> flag, too. |
3608 | There are <constant>LOCK</constant> and | 3606 | There are <constant>LOCK</constant> and |
3609 | <constant>OWNER</constant> flags for changing the write | 3607 | <constant>OWNER</constant> flags to change the write |
3610 | permissions. | 3608 | permissions. |
3611 | </para> | 3609 | </para> |
3612 | 3610 | ||
@@ -3619,10 +3617,10 @@ struct _snd_pcm_runtime { | |||
3619 | <title>info callback</title> | 3617 | <title>info callback</title> |
3620 | <para> | 3618 | <para> |
3621 | The <structfield>info</structfield> callback is used to get | 3619 | The <structfield>info</structfield> callback is used to get |
3622 | the detailed information of this control. This must store the | 3620 | detailed information on this control. This must store the |
3623 | values of the given struct <structname>snd_ctl_elem_info</structname> | 3621 | values of the given struct <structname>snd_ctl_elem_info</structname> |
3624 | object. For example, for a boolean control with a single | 3622 | object. For example, for a boolean control with a single |
3625 | element will be: | 3623 | element: |
3626 | 3624 | ||
3627 | <example> | 3625 | <example> |
3628 | <title>Example of info callback</title> | 3626 | <title>Example of info callback</title> |
@@ -3653,7 +3651,7 @@ struct _snd_pcm_runtime { | |||
3653 | volume would have count = 2. The | 3651 | volume would have count = 2. The |
3654 | <structfield>value</structfield> field is a union, and | 3652 | <structfield>value</structfield> field is a union, and |
3655 | the values stored are depending on the type. The boolean and | 3653 | the values stored are depending on the type. The boolean and |
3656 | integer are identical. | 3654 | integer types are identical. |
3657 | </para> | 3655 | </para> |
3658 | 3656 | ||
3659 | <para> | 3657 | <para> |
@@ -3684,7 +3682,7 @@ struct _snd_pcm_runtime { | |||
3684 | </para> | 3682 | </para> |
3685 | 3683 | ||
3686 | <para> | 3684 | <para> |
3687 | Some common info callbacks are prepared for easy use: | 3685 | Some common info callbacks are available for your convenience: |
3688 | <function>snd_ctl_boolean_mono_info()</function> and | 3686 | <function>snd_ctl_boolean_mono_info()</function> and |
3689 | <function>snd_ctl_boolean_stereo_info()</function>. | 3687 | <function>snd_ctl_boolean_stereo_info()</function>. |
3690 | Obviously, the former is an info callback for a mono channel | 3688 | Obviously, the former is an info callback for a mono channel |
@@ -3699,7 +3697,7 @@ struct _snd_pcm_runtime { | |||
3699 | 3697 | ||
3700 | <para> | 3698 | <para> |
3701 | This callback is used to read the current value of the | 3699 | This callback is used to read the current value of the |
3702 | control and to return to the user-space. | 3700 | control and to return to user-space. |
3703 | </para> | 3701 | </para> |
3704 | 3702 | ||
3705 | <para> | 3703 | <para> |
@@ -3722,11 +3720,11 @@ struct _snd_pcm_runtime { | |||
3722 | </para> | 3720 | </para> |
3723 | 3721 | ||
3724 | <para> | 3722 | <para> |
3725 | The <structfield>value</structfield> field is depending on | 3723 | The <structfield>value</structfield> field depends on |
3726 | the type of control as well as on info callback. For example, | 3724 | the type of control as well as on the info callback. For example, |
3727 | the sb driver uses this field to store the register offset, | 3725 | the sb driver uses this field to store the register offset, |
3728 | the bit-shift and the bit-mask. The | 3726 | the bit-shift and the bit-mask. The |
3729 | <structfield>private_value</structfield> is set like | 3727 | <structfield>private_value</structfield> field is set as follows: |
3730 | <informalexample> | 3728 | <informalexample> |
3731 | <programlisting> | 3729 | <programlisting> |
3732 | <![CDATA[ | 3730 | <![CDATA[ |
@@ -3752,7 +3750,8 @@ struct _snd_pcm_runtime { | |||
3752 | </para> | 3750 | </para> |
3753 | 3751 | ||
3754 | <para> | 3752 | <para> |
3755 | In <structfield>get</structfield> callback, you have to fill all the elements if the | 3753 | In the <structfield>get</structfield> callback, |
3754 | you have to fill all the elements if the | ||
3756 | control has more than one elements, | 3755 | control has more than one elements, |
3757 | i.e. <structfield>count</structfield> > 1. | 3756 | i.e. <structfield>count</structfield> > 1. |
3758 | In the example above, we filled only one element | 3757 | In the example above, we filled only one element |
@@ -3765,7 +3764,7 @@ struct _snd_pcm_runtime { | |||
3765 | <title>put callback</title> | 3764 | <title>put callback</title> |
3766 | 3765 | ||
3767 | <para> | 3766 | <para> |
3768 | This callback is used to write a value from the user-space. | 3767 | This callback is used to write a value from user-space. |
3769 | </para> | 3768 | </para> |
3770 | 3769 | ||
3771 | <para> | 3770 | <para> |
@@ -3799,7 +3798,7 @@ struct _snd_pcm_runtime { | |||
3799 | </para> | 3798 | </para> |
3800 | 3799 | ||
3801 | <para> | 3800 | <para> |
3802 | Like <structfield>get</structfield> callback, | 3801 | As in the <structfield>get</structfield> callback, |
3803 | when the control has more than one elements, | 3802 | when the control has more than one elements, |
3804 | all elements must be evaluated in this callback, too. | 3803 | all elements must be evaluated in this callback, too. |
3805 | </para> | 3804 | </para> |
@@ -3817,7 +3816,7 @@ struct _snd_pcm_runtime { | |||
3817 | <title>Constructor</title> | 3816 | <title>Constructor</title> |
3818 | <para> | 3817 | <para> |
3819 | When everything is ready, finally we can create a new | 3818 | When everything is ready, finally we can create a new |
3820 | control. For creating a control, there are two functions to be | 3819 | control. To create a control, there are two functions to be |
3821 | called, <function>snd_ctl_new1()</function> and | 3820 | called, <function>snd_ctl_new1()</function> and |
3822 | <function>snd_ctl_add()</function>. | 3821 | <function>snd_ctl_add()</function>. |
3823 | </para> | 3822 | </para> |
@@ -3839,14 +3838,14 @@ struct _snd_pcm_runtime { | |||
3839 | struct <structname>snd_kcontrol_new</structname> object defined above, and chip | 3838 | struct <structname>snd_kcontrol_new</structname> object defined above, and chip |
3840 | is the object pointer to be passed to | 3839 | is the object pointer to be passed to |
3841 | kcontrol->private_data | 3840 | kcontrol->private_data |
3842 | which can be referred in callbacks. | 3841 | which can be referred to in callbacks. |
3843 | </para> | 3842 | </para> |
3844 | 3843 | ||
3845 | <para> | 3844 | <para> |
3846 | <function>snd_ctl_new1()</function> allocates a new | 3845 | <function>snd_ctl_new1()</function> allocates a new |
3847 | <structname>snd_kcontrol</structname> instance (that's why the definition | 3846 | <structname>snd_kcontrol</structname> instance (that's why the definition |
3848 | of <parameter>my_control</parameter> can be with | 3847 | of <parameter>my_control</parameter> can be with |
3849 | <parameter>__devinitdata</parameter> | 3848 | the <parameter>__devinitdata</parameter> |
3850 | prefix), and <function>snd_ctl_add</function> assigns the given | 3849 | prefix), and <function>snd_ctl_add</function> assigns the given |
3851 | control component to the card. | 3850 | control component to the card. |
3852 | </para> | 3851 | </para> |
@@ -3941,7 +3940,7 @@ struct _snd_pcm_runtime { | |||
3941 | <title>General</title> | 3940 | <title>General</title> |
3942 | <para> | 3941 | <para> |
3943 | The ALSA AC97 codec layer is a well-defined one, and you don't | 3942 | The ALSA AC97 codec layer is a well-defined one, and you don't |
3944 | have to write many codes to control it. Only low-level control | 3943 | have to write much code to control it. Only low-level control |
3945 | routines are necessary. The AC97 codec API is defined in | 3944 | routines are necessary. The AC97 codec API is defined in |
3946 | <filename><sound/ac97_codec.h></filename>. | 3945 | <filename><sound/ac97_codec.h></filename>. |
3947 | </para> | 3946 | </para> |
@@ -4004,7 +4003,7 @@ struct _snd_pcm_runtime { | |||
4004 | <section id="api-ac97-constructor"> | 4003 | <section id="api-ac97-constructor"> |
4005 | <title>Constructor</title> | 4004 | <title>Constructor</title> |
4006 | <para> | 4005 | <para> |
4007 | For creating an ac97 instance, first call <function>snd_ac97_bus</function> | 4006 | To create an ac97 instance, first call <function>snd_ac97_bus</function> |
4008 | with an <type>ac97_bus_ops_t</type> record with callback functions. | 4007 | with an <type>ac97_bus_ops_t</type> record with callback functions. |
4009 | 4008 | ||
4010 | <informalexample> | 4009 | <informalexample> |
@@ -4042,12 +4041,12 @@ struct _snd_pcm_runtime { | |||
4042 | </programlisting> | 4041 | </programlisting> |
4043 | </informalexample> | 4042 | </informalexample> |
4044 | 4043 | ||
4045 | where chip->ac97 is the pointer of a newly created | 4044 | where chip->ac97 is a pointer to a newly created |
4046 | <type>ac97_t</type> instance. | 4045 | <type>ac97_t</type> instance. |
4047 | In this case, the chip pointer is set as the private data, so that | 4046 | In this case, the chip pointer is set as the private data, so that |
4048 | the read/write callback functions can refer to this chip instance. | 4047 | the read/write callback functions can refer to this chip instance. |
4049 | This instance is not necessarily stored in the chip | 4048 | This instance is not necessarily stored in the chip |
4050 | record. When you need to change the register values from the | 4049 | record. If you need to change the register values from the |
4051 | driver, or need the suspend/resume of ac97 codecs, keep this | 4050 | driver, or need the suspend/resume of ac97 codecs, keep this |
4052 | pointer to pass to the corresponding functions. | 4051 | pointer to pass to the corresponding functions. |
4053 | </para> | 4052 | </para> |
@@ -4098,7 +4097,7 @@ struct _snd_pcm_runtime { | |||
4098 | </para> | 4097 | </para> |
4099 | 4098 | ||
4100 | <para> | 4099 | <para> |
4101 | These callbacks are non-atomic like the callbacks of control API. | 4100 | These callbacks are non-atomic like the control API callbacks. |
4102 | </para> | 4101 | </para> |
4103 | 4102 | ||
4104 | <para> | 4103 | <para> |
@@ -4110,14 +4109,14 @@ struct _snd_pcm_runtime { | |||
4110 | 4109 | ||
4111 | <para> | 4110 | <para> |
4112 | The <structfield>reset</structfield> callback is used to reset | 4111 | The <structfield>reset</structfield> callback is used to reset |
4113 | the codec. If the chip requires a special way of reset, you can | 4112 | the codec. If the chip requires a special kind of reset, you can |
4114 | define this callback. | 4113 | define this callback. |
4115 | </para> | 4114 | </para> |
4116 | 4115 | ||
4117 | <para> | 4116 | <para> |
4118 | The <structfield>wait</structfield> callback is used for a | 4117 | The <structfield>wait</structfield> callback is used to |
4119 | certain wait at the standard initialization of the codec. If the | 4118 | add some waiting time in the standard initialization of the codec. If the |
4120 | chip requires the extra wait-time, define this callback. | 4119 | chip requires the extra waiting time, define this callback. |
4121 | </para> | 4120 | </para> |
4122 | 4121 | ||
4123 | <para> | 4122 | <para> |
@@ -4172,7 +4171,7 @@ struct _snd_pcm_runtime { | |||
4172 | 4171 | ||
4173 | <para> | 4172 | <para> |
4174 | <function>snd_ac97_update_bits()</function> is used to update | 4173 | <function>snd_ac97_update_bits()</function> is used to update |
4175 | some bits of the given register. | 4174 | some bits in the given register. |
4176 | 4175 | ||
4177 | <informalexample> | 4176 | <informalexample> |
4178 | <programlisting> | 4177 | <programlisting> |
@@ -4185,7 +4184,7 @@ struct _snd_pcm_runtime { | |||
4185 | 4184 | ||
4186 | <para> | 4185 | <para> |
4187 | Also, there is a function to change the sample rate (of a | 4186 | Also, there is a function to change the sample rate (of a |
4188 | certain register such as | 4187 | given register such as |
4189 | <constant>AC97_PCM_FRONT_DAC_RATE</constant>) when VRA or | 4188 | <constant>AC97_PCM_FRONT_DAC_RATE</constant>) when VRA or |
4190 | DRA is supported by the codec: | 4189 | DRA is supported by the codec: |
4191 | <function>snd_ac97_set_rate()</function>. | 4190 | <function>snd_ac97_set_rate()</function>. |
@@ -4200,11 +4199,11 @@ struct _snd_pcm_runtime { | |||
4200 | </para> | 4199 | </para> |
4201 | 4200 | ||
4202 | <para> | 4201 | <para> |
4203 | The following registers are available for setting the rate: | 4202 | The following registers are available to set the rate: |
4204 | <constant>AC97_PCM_MIC_ADC_RATE</constant>, | 4203 | <constant>AC97_PCM_MIC_ADC_RATE</constant>, |
4205 | <constant>AC97_PCM_FRONT_DAC_RATE</constant>, | 4204 | <constant>AC97_PCM_FRONT_DAC_RATE</constant>, |
4206 | <constant>AC97_PCM_LR_ADC_RATE</constant>, | 4205 | <constant>AC97_PCM_LR_ADC_RATE</constant>, |
4207 | <constant>AC97_SPDIF</constant>. When the | 4206 | <constant>AC97_SPDIF</constant>. When |
4208 | <constant>AC97_SPDIF</constant> is specified, the register is | 4207 | <constant>AC97_SPDIF</constant> is specified, the register is |
4209 | not really changed but the corresponding IEC958 status bits will | 4208 | not really changed but the corresponding IEC958 status bits will |
4210 | be updated. | 4209 | be updated. |
@@ -4214,12 +4213,11 @@ struct _snd_pcm_runtime { | |||
4214 | <section id="api-ac97-clock-adjustment"> | 4213 | <section id="api-ac97-clock-adjustment"> |
4215 | <title>Clock Adjustment</title> | 4214 | <title>Clock Adjustment</title> |
4216 | <para> | 4215 | <para> |
4217 | On some chip, the clock of the codec isn't 48000 but using a | 4216 | In some chips, the clock of the codec isn't 48000 but using a |
4218 | PCI clock (to save a quartz!). In this case, change the field | 4217 | PCI clock (to save a quartz!). In this case, change the field |
4219 | bus->clock to the corresponding | 4218 | bus->clock to the corresponding |
4220 | value. For example, intel8x0 | 4219 | value. For example, intel8x0 |
4221 | and es1968 drivers have the auto-measurement function of the | 4220 | and es1968 drivers have their own function to read from the clock. |
4222 | clock. | ||
4223 | </para> | 4221 | </para> |
4224 | </section> | 4222 | </section> |
4225 | 4223 | ||
@@ -4239,15 +4237,13 @@ struct _snd_pcm_runtime { | |||
4239 | When there are several codecs on the same card, you need to | 4237 | When there are several codecs on the same card, you need to |
4240 | call <function>snd_ac97_mixer()</function> multiple times with | 4238 | call <function>snd_ac97_mixer()</function> multiple times with |
4241 | ac97.num=1 or greater. The <structfield>num</structfield> field | 4239 | ac97.num=1 or greater. The <structfield>num</structfield> field |
4242 | specifies the codec | 4240 | specifies the codec number. |
4243 | number. | ||
4244 | </para> | 4241 | </para> |
4245 | 4242 | ||
4246 | <para> | 4243 | <para> |
4247 | If you have set up multiple codecs, you need to either write | 4244 | If you set up multiple codecs, you either need to write |
4248 | different callbacks for each codec or check | 4245 | different callbacks for each codec or check |
4249 | ac97->num in the | 4246 | ac97->num in the callback routines. |
4250 | callback routines. | ||
4251 | </para> | 4247 | </para> |
4252 | </section> | 4248 | </section> |
4253 | 4249 | ||
@@ -4271,7 +4267,7 @@ struct _snd_pcm_runtime { | |||
4271 | </para> | 4267 | </para> |
4272 | 4268 | ||
4273 | <para> | 4269 | <para> |
4274 | Some soundchips have similar but a little bit different | 4270 | Some soundchips have a similar but slightly different |
4275 | implementation of mpu401 stuff. For example, emu10k1 has its own | 4271 | implementation of mpu401 stuff. For example, emu10k1 has its own |
4276 | mpu401 routines. | 4272 | mpu401 routines. |
4277 | </para> | 4273 | </para> |
@@ -4280,7 +4276,7 @@ struct _snd_pcm_runtime { | |||
4280 | <section id="midi-interface-constructor"> | 4276 | <section id="midi-interface-constructor"> |
4281 | <title>Constructor</title> | 4277 | <title>Constructor</title> |
4282 | <para> | 4278 | <para> |
4283 | For creating a rawmidi object, call | 4279 | To create a rawmidi object, call |
4284 | <function>snd_mpu401_uart_new()</function>. | 4280 | <function>snd_mpu401_uart_new()</function>. |
4285 | 4281 | ||
4286 | <informalexample> | 4282 | <informalexample> |
@@ -4307,25 +4303,24 @@ struct _snd_pcm_runtime { | |||
4307 | </para> | 4303 | </para> |
4308 | 4304 | ||
4309 | <para> | 4305 | <para> |
4310 | The 4th argument is the i/o port address. Many | 4306 | The 4th argument is the I/O port address. Many |
4311 | backward-compatible MPU401 has an i/o port such as 0x330. Or, it | 4307 | backward-compatible MPU401 have an I/O port such as 0x330. Or, it |
4312 | might be a part of its own PCI i/o region. It depends on the | 4308 | might be a part of its own PCI I/O region. It depends on the |
4313 | chip design. | 4309 | chip design. |
4314 | </para> | 4310 | </para> |
4315 | 4311 | ||
4316 | <para> | 4312 | <para> |
4317 | The 5th argument is bitflags for additional information. | 4313 | The 5th argument is a bitflag for additional information. |
4318 | When the i/o port address above is a part of the PCI i/o | 4314 | When the I/O port address above is part of the PCI I/O |
4319 | region, the MPU401 i/o port might have been already allocated | 4315 | region, the MPU401 I/O port might have been already allocated |
4320 | (reserved) by the driver itself. In such a case, pass a bit flag | 4316 | (reserved) by the driver itself. In such a case, pass a bit flag |
4321 | <constant>MPU401_INFO_INTEGRATED</constant>, | 4317 | <constant>MPU401_INFO_INTEGRATED</constant>, |
4322 | and | 4318 | and the mpu401-uart layer will allocate the I/O ports by itself. |
4323 | the mpu401-uart layer will allocate the i/o ports by itself. | ||
4324 | </para> | 4319 | </para> |
4325 | 4320 | ||
4326 | <para> | 4321 | <para> |
4327 | When the controller supports only the input or output MIDI stream, | 4322 | When the controller supports only the input or output MIDI stream, |
4328 | pass <constant>MPU401_INFO_INPUT</constant> or | 4323 | pass the <constant>MPU401_INFO_INPUT</constant> or |
4329 | <constant>MPU401_INFO_OUTPUT</constant> bitflag, respectively. | 4324 | <constant>MPU401_INFO_OUTPUT</constant> bitflag, respectively. |
4330 | Then the rawmidi instance is created as a single stream. | 4325 | Then the rawmidi instance is created as a single stream. |
4331 | </para> | 4326 | </para> |
@@ -4333,7 +4328,7 @@ struct _snd_pcm_runtime { | |||
4333 | <para> | 4328 | <para> |
4334 | <constant>MPU401_INFO_MMIO</constant> bitflag is used to change | 4329 | <constant>MPU401_INFO_MMIO</constant> bitflag is used to change |
4335 | the access method to MMIO (via readb and writeb) instead of | 4330 | the access method to MMIO (via readb and writeb) instead of |
4336 | iob and outb. In this case, you have to pass the iomapped address | 4331 | iob and outb. In this case, you have to pass the iomapped address |
4337 | to <function>snd_mpu401_uart_new()</function>. | 4332 | to <function>snd_mpu401_uart_new()</function>. |
4338 | </para> | 4333 | </para> |
4339 | 4334 | ||
@@ -4341,7 +4336,7 @@ struct _snd_pcm_runtime { | |||
4341 | When <constant>MPU401_INFO_TX_IRQ</constant> is set, the output | 4336 | When <constant>MPU401_INFO_TX_IRQ</constant> is set, the output |
4342 | stream isn't checked in the default interrupt handler. The driver | 4337 | stream isn't checked in the default interrupt handler. The driver |
4343 | needs to call <function>snd_mpu401_uart_interrupt_tx()</function> | 4338 | needs to call <function>snd_mpu401_uart_interrupt_tx()</function> |
4344 | by itself to start processing the output stream in irq handler. | 4339 | by itself to start processing the output stream in the irq handler. |
4345 | </para> | 4340 | </para> |
4346 | 4341 | ||
4347 | <para> | 4342 | <para> |
@@ -4381,7 +4376,7 @@ struct _snd_pcm_runtime { | |||
4381 | (<parameter>irq_flags</parameter>). Otherwise, pass the flags | 4376 | (<parameter>irq_flags</parameter>). Otherwise, pass the flags |
4382 | for irq allocation | 4377 | for irq allocation |
4383 | (<constant>SA_XXX</constant> bits) to it, and the irq will be | 4378 | (<constant>SA_XXX</constant> bits) to it, and the irq will be |
4384 | reserved by the mpu401-uart layer. If the card doesn't generates | 4379 | reserved by the mpu401-uart layer. If the card doesn't generate |
4385 | UART interrupts, pass -1 as the irq number. Then a timer | 4380 | UART interrupts, pass -1 as the irq number. Then a timer |
4386 | interrupt will be invoked for polling. | 4381 | interrupt will be invoked for polling. |
4387 | </para> | 4382 | </para> |
@@ -4392,8 +4387,8 @@ struct _snd_pcm_runtime { | |||
4392 | <para> | 4387 | <para> |
4393 | When the interrupt is allocated in | 4388 | When the interrupt is allocated in |
4394 | <function>snd_mpu401_uart_new()</function>, the private | 4389 | <function>snd_mpu401_uart_new()</function>, the private |
4395 | interrupt handler is used, hence you don't have to do nothing | 4390 | interrupt handler is used, hence you don't have anything else to do |
4396 | else than creating the mpu401 stuff. Otherwise, you have to call | 4391 | than creating the mpu401 stuff. Otherwise, you have to call |
4397 | <function>snd_mpu401_uart_interrupt()</function> explicitly when | 4392 | <function>snd_mpu401_uart_interrupt()</function> explicitly when |
4398 | a UART interrupt is invoked and checked in your own interrupt | 4393 | a UART interrupt is invoked and checked in your own interrupt |
4399 | handler. | 4394 | handler. |
@@ -4480,8 +4475,8 @@ struct _snd_pcm_runtime { | |||
4480 | 4475 | ||
4481 | <para> | 4476 | <para> |
4482 | The fourth and fifth arguments are the number of output and | 4477 | The fourth and fifth arguments are the number of output and |
4483 | input substreams, respectively, of this device. (A substream is | 4478 | input substreams, respectively, of this device (a substream is |
4484 | the equivalent of a MIDI port.) | 4479 | the equivalent of a MIDI port). |
4485 | </para> | 4480 | </para> |
4486 | 4481 | ||
4487 | <para> | 4482 | <para> |
@@ -4498,7 +4493,7 @@ struct _snd_pcm_runtime { | |||
4498 | <para> | 4493 | <para> |
4499 | After the rawmidi device is created, you need to set the | 4494 | After the rawmidi device is created, you need to set the |
4500 | operators (callbacks) for each substream. There are helper | 4495 | operators (callbacks) for each substream. There are helper |
4501 | functions to set the operators for all substream of a device: | 4496 | functions to set the operators for all the substreams of a device: |
4502 | <informalexample> | 4497 | <informalexample> |
4503 | <programlisting> | 4498 | <programlisting> |
4504 | <![CDATA[ | 4499 | <![CDATA[ |
@@ -4528,8 +4523,8 @@ struct _snd_pcm_runtime { | |||
4528 | </para> | 4523 | </para> |
4529 | 4524 | ||
4530 | <para> | 4525 | <para> |
4531 | If there is more than one substream, you should give each one a | 4526 | If there are more than one substream, you should give a |
4532 | unique name: | 4527 | unique name to each of them: |
4533 | <informalexample> | 4528 | <informalexample> |
4534 | <programlisting> | 4529 | <programlisting> |
4535 | <![CDATA[ | 4530 | <![CDATA[ |
@@ -4550,7 +4545,7 @@ struct _snd_pcm_runtime { | |||
4550 | <title>Callbacks</title> | 4545 | <title>Callbacks</title> |
4551 | 4546 | ||
4552 | <para> | 4547 | <para> |
4553 | In all callbacks, the private data that you've set for the | 4548 | In all the callbacks, the private data that you've set for the |
4554 | rawmidi device can be accessed as | 4549 | rawmidi device can be accessed as |
4555 | substream->rmidi->private_data. | 4550 | substream->rmidi->private_data. |
4556 | <!-- <code> isn't available before DocBook 4.3 --> | 4551 | <!-- <code> isn't available before DocBook 4.3 --> |
@@ -4583,8 +4578,8 @@ struct _snd_pcm_runtime { | |||
4583 | 4578 | ||
4584 | <para> | 4579 | <para> |
4585 | This is called when a substream is opened. | 4580 | This is called when a substream is opened. |
4586 | You can initialize the hardware here, but you should not yet | 4581 | You can initialize the hardware here, but you shouldn't |
4587 | start transmitting/receiving data. | 4582 | start transmitting/receiving data yet. |
4588 | </para> | 4583 | </para> |
4589 | </section> | 4584 | </section> |
4590 | 4585 | ||
@@ -4632,9 +4627,9 @@ struct _snd_pcm_runtime { | |||
4632 | To read data from the buffer, call | 4627 | To read data from the buffer, call |
4633 | <function>snd_rawmidi_transmit_peek</function>. It will | 4628 | <function>snd_rawmidi_transmit_peek</function>. It will |
4634 | return the number of bytes that have been read; this will be | 4629 | return the number of bytes that have been read; this will be |
4635 | less than the number of bytes requested when there is no more | 4630 | less than the number of bytes requested when there are no more |
4636 | data in the buffer. | 4631 | data in the buffer. |
4637 | After the data has been transmitted successfully, call | 4632 | After the data have been transmitted successfully, call |
4638 | <function>snd_rawmidi_transmit_ack</function> to remove the | 4633 | <function>snd_rawmidi_transmit_ack</function> to remove the |
4639 | data from the substream buffer: | 4634 | data from the substream buffer: |
4640 | <informalexample> | 4635 | <informalexample> |
@@ -4655,7 +4650,7 @@ struct _snd_pcm_runtime { | |||
4655 | <para> | 4650 | <para> |
4656 | If you know beforehand that the hardware will accept data, you | 4651 | If you know beforehand that the hardware will accept data, you |
4657 | can use the <function>snd_rawmidi_transmit</function> function | 4652 | can use the <function>snd_rawmidi_transmit</function> function |
4658 | which reads some data and removes it from the buffer at once: | 4653 | which reads some data and removes them from the buffer at once: |
4659 | <informalexample> | 4654 | <informalexample> |
4660 | <programlisting> | 4655 | <programlisting> |
4661 | <![CDATA[ | 4656 | <![CDATA[ |
@@ -4749,13 +4744,13 @@ struct _snd_pcm_runtime { | |||
4749 | 4744 | ||
4750 | <para> | 4745 | <para> |
4751 | This is only used with output substreams. This function should wait | 4746 | This is only used with output substreams. This function should wait |
4752 | until all data read from the substream buffer has been transmitted. | 4747 | until all data read from the substream buffer have been transmitted. |
4753 | This ensures that the device can be closed and the driver unloaded | 4748 | This ensures that the device can be closed and the driver unloaded |
4754 | without losing data. | 4749 | without losing data. |
4755 | </para> | 4750 | </para> |
4756 | 4751 | ||
4757 | <para> | 4752 | <para> |
4758 | This callback is optional. If you do not set | 4753 | This callback is optional. If you do not set |
4759 | <structfield>drain</structfield> in the struct snd_rawmidi_ops | 4754 | <structfield>drain</structfield> in the struct snd_rawmidi_ops |
4760 | structure, ALSA will simply wait for 50 milliseconds | 4755 | structure, ALSA will simply wait for 50 milliseconds |
4761 | instead. | 4756 | instead. |
@@ -4775,24 +4770,24 @@ struct _snd_pcm_runtime { | |||
4775 | <section id="misc-devices-opl3"> | 4770 | <section id="misc-devices-opl3"> |
4776 | <title>FM OPL3</title> | 4771 | <title>FM OPL3</title> |
4777 | <para> | 4772 | <para> |
4778 | The FM OPL3 is still used on many chips (mainly for backward | 4773 | The FM OPL3 is still used in many chips (mainly for backward |
4779 | compatibility). ALSA has a nice OPL3 FM control layer, too. The | 4774 | compatibility). ALSA has a nice OPL3 FM control layer, too. The |
4780 | OPL3 API is defined in | 4775 | OPL3 API is defined in |
4781 | <filename><sound/opl3.h></filename>. | 4776 | <filename><sound/opl3.h></filename>. |
4782 | </para> | 4777 | </para> |
4783 | 4778 | ||
4784 | <para> | 4779 | <para> |
4785 | FM registers can be directly accessed through direct-FM API, | 4780 | FM registers can be directly accessed through the direct-FM API, |
4786 | defined in <filename><sound/asound_fm.h></filename>. In | 4781 | defined in <filename><sound/asound_fm.h></filename>. In |
4787 | ALSA native mode, FM registers are accessed through | 4782 | ALSA native mode, FM registers are accessed through |
4788 | Hardware-Dependant Device direct-FM extension API, whereas in | 4783 | the Hardware-Dependant Device direct-FM extension API, whereas in |
4789 | OSS compatible mode, FM registers can be accessed with OSS | 4784 | OSS compatible mode, FM registers can be accessed with the OSS |
4790 | direct-FM compatible API on <filename>/dev/dmfmX</filename> device. | 4785 | direct-FM compatible API in <filename>/dev/dmfmX</filename> device. |
4791 | </para> | 4786 | </para> |
4792 | 4787 | ||
4793 | <para> | 4788 | <para> |
4794 | For creating the OPL3 component, you have two functions to | 4789 | To create the OPL3 component, you have two functions to |
4795 | call. The first one is a constructor for <type>opl3_t</type> | 4790 | call. The first one is a constructor for the <type>opl3_t</type> |
4796 | instance. | 4791 | instance. |
4797 | 4792 | ||
4798 | <informalexample> | 4793 | <informalexample> |
@@ -4819,12 +4814,12 @@ struct _snd_pcm_runtime { | |||
4819 | <para> | 4814 | <para> |
4820 | When the left and right ports have been already allocated by | 4815 | When the left and right ports have been already allocated by |
4821 | the card driver, pass non-zero to the fifth argument | 4816 | the card driver, pass non-zero to the fifth argument |
4822 | (<parameter>integrated</parameter>). Otherwise, opl3 module will | 4817 | (<parameter>integrated</parameter>). Otherwise, the opl3 module will |
4823 | allocate the specified ports by itself. | 4818 | allocate the specified ports by itself. |
4824 | </para> | 4819 | </para> |
4825 | 4820 | ||
4826 | <para> | 4821 | <para> |
4827 | When the accessing to the hardware requires special method | 4822 | When the accessing the hardware requires special method |
4828 | instead of the standard I/O access, you can create opl3 instance | 4823 | instead of the standard I/O access, you can create opl3 instance |
4829 | separately with <function>snd_opl3_new()</function>. | 4824 | separately with <function>snd_opl3_new()</function>. |
4830 | 4825 | ||
@@ -4845,13 +4840,13 @@ struct _snd_pcm_runtime { | |||
4845 | access function, the private data and the destructor. | 4840 | access function, the private data and the destructor. |
4846 | The l_port and r_port are not necessarily set. Only the | 4841 | The l_port and r_port are not necessarily set. Only the |
4847 | command must be set properly. You can retrieve the data | 4842 | command must be set properly. You can retrieve the data |
4848 | from opl3->private_data field. | 4843 | from the opl3->private_data field. |
4849 | </para> | 4844 | </para> |
4850 | 4845 | ||
4851 | <para> | 4846 | <para> |
4852 | After creating the opl3 instance via <function>snd_opl3_new()</function>, | 4847 | After creating the opl3 instance via <function>snd_opl3_new()</function>, |
4853 | call <function>snd_opl3_init()</function> to initialize the chip to the | 4848 | call <function>snd_opl3_init()</function> to initialize the chip to the |
4854 | proper state. Note that <function>snd_opl3_create()</function> always | 4849 | proper state. Note that <function>snd_opl3_create()</function> always |
4855 | calls it internally. | 4850 | calls it internally. |
4856 | </para> | 4851 | </para> |
4857 | 4852 | ||
@@ -4884,7 +4879,7 @@ struct _snd_pcm_runtime { | |||
4884 | <section id="misc-devices-hardware-dependent"> | 4879 | <section id="misc-devices-hardware-dependent"> |
4885 | <title>Hardware-Dependent Devices</title> | 4880 | <title>Hardware-Dependent Devices</title> |
4886 | <para> | 4881 | <para> |
4887 | Some chips need the access from the user-space for special | 4882 | Some chips need user-space access for special |
4888 | controls or for loading the micro code. In such a case, you can | 4883 | controls or for loading the micro code. In such a case, you can |
4889 | create a hwdep (hardware-dependent) device. The hwdep API is | 4884 | create a hwdep (hardware-dependent) device. The hwdep API is |
4890 | defined in <filename><sound/hwdep.h></filename>. You can | 4885 | defined in <filename><sound/hwdep.h></filename>. You can |
@@ -4893,7 +4888,7 @@ struct _snd_pcm_runtime { | |||
4893 | </para> | 4888 | </para> |
4894 | 4889 | ||
4895 | <para> | 4890 | <para> |
4896 | Creation of the <type>hwdep</type> instance is done via | 4891 | The creation of the <type>hwdep</type> instance is done via |
4897 | <function>snd_hwdep_new()</function>. | 4892 | <function>snd_hwdep_new()</function>. |
4898 | 4893 | ||
4899 | <informalexample> | 4894 | <informalexample> |
@@ -4912,8 +4907,8 @@ struct _snd_pcm_runtime { | |||
4912 | You can then pass any pointer value to the | 4907 | You can then pass any pointer value to the |
4913 | <parameter>private_data</parameter>. | 4908 | <parameter>private_data</parameter>. |
4914 | If you assign a private data, you should define the | 4909 | If you assign a private data, you should define the |
4915 | destructor, too. The destructor function is set to | 4910 | destructor, too. The destructor function is set in |
4916 | <structfield>private_free</structfield> field. | 4911 | the <structfield>private_free</structfield> field. |
4917 | 4912 | ||
4918 | <informalexample> | 4913 | <informalexample> |
4919 | <programlisting> | 4914 | <programlisting> |
@@ -4925,7 +4920,7 @@ struct _snd_pcm_runtime { | |||
4925 | </programlisting> | 4920 | </programlisting> |
4926 | </informalexample> | 4921 | </informalexample> |
4927 | 4922 | ||
4928 | and the implementation of destructor would be: | 4923 | and the implementation of the destructor would be: |
4929 | 4924 | ||
4930 | <informalexample> | 4925 | <informalexample> |
4931 | <programlisting> | 4926 | <programlisting> |
@@ -4943,7 +4938,7 @@ struct _snd_pcm_runtime { | |||
4943 | <para> | 4938 | <para> |
4944 | The arbitrary file operations can be defined for this | 4939 | The arbitrary file operations can be defined for this |
4945 | instance. The file operators are defined in | 4940 | instance. The file operators are defined in |
4946 | <parameter>ops</parameter> table. For example, assume that | 4941 | the <parameter>ops</parameter> table. For example, assume that |
4947 | this chip needs an ioctl. | 4942 | this chip needs an ioctl. |
4948 | 4943 | ||
4949 | <informalexample> | 4944 | <informalexample> |
@@ -4964,7 +4959,7 @@ struct _snd_pcm_runtime { | |||
4964 | <title>IEC958 (S/PDIF)</title> | 4959 | <title>IEC958 (S/PDIF)</title> |
4965 | <para> | 4960 | <para> |
4966 | Usually the controls for IEC958 devices are implemented via | 4961 | Usually the controls for IEC958 devices are implemented via |
4967 | control interface. There is a macro to compose a name string for | 4962 | the control interface. There is a macro to compose a name string for |
4968 | IEC958 controls, <function>SNDRV_CTL_NAME_IEC958()</function> | 4963 | IEC958 controls, <function>SNDRV_CTL_NAME_IEC958()</function> |
4969 | defined in <filename><include/asound.h></filename>. | 4964 | defined in <filename><include/asound.h></filename>. |
4970 | </para> | 4965 | </para> |
@@ -4973,7 +4968,7 @@ struct _snd_pcm_runtime { | |||
4973 | There are some standard controls for IEC958 status bits. These | 4968 | There are some standard controls for IEC958 status bits. These |
4974 | controls use the type <type>SNDRV_CTL_ELEM_TYPE_IEC958</type>, | 4969 | controls use the type <type>SNDRV_CTL_ELEM_TYPE_IEC958</type>, |
4975 | and the size of element is fixed as 4 bytes array | 4970 | and the size of element is fixed as 4 bytes array |
4976 | (value.iec958.status[x]). For <structfield>info</structfield> | 4971 | (value.iec958.status[x]). For the <structfield>info</structfield> |
4977 | callback, you don't specify | 4972 | callback, you don't specify |
4978 | the value field for this type (the count field must be set, | 4973 | the value field for this type (the count field must be set, |
4979 | though). | 4974 | though). |
@@ -5001,7 +4996,7 @@ struct _snd_pcm_runtime { | |||
5001 | enable/disable or to set the raw bit mode. The implementation | 4996 | enable/disable or to set the raw bit mode. The implementation |
5002 | will depend on the chip, but the control should be named as | 4997 | will depend on the chip, but the control should be named as |
5003 | <quote>IEC958 xxx</quote>, preferably using | 4998 | <quote>IEC958 xxx</quote>, preferably using |
5004 | <function>SNDRV_CTL_NAME_IEC958()</function> macro. | 4999 | the <function>SNDRV_CTL_NAME_IEC958()</function> macro. |
5005 | </para> | 5000 | </para> |
5006 | 5001 | ||
5007 | <para> | 5002 | <para> |
@@ -5036,12 +5031,12 @@ struct _snd_pcm_runtime { | |||
5036 | The allocation of pages with fallback is | 5031 | The allocation of pages with fallback is |
5037 | <function>snd_malloc_xxx_pages_fallback()</function>. This | 5032 | <function>snd_malloc_xxx_pages_fallback()</function>. This |
5038 | function tries to allocate the specified pages but if the pages | 5033 | function tries to allocate the specified pages but if the pages |
5039 | are not available, it tries to reduce the page sizes until the | 5034 | are not available, it tries to reduce the page sizes until |
5040 | enough space is found. | 5035 | enough space is found. |
5041 | </para> | 5036 | </para> |
5042 | 5037 | ||
5043 | <para> | 5038 | <para> |
5044 | For releasing the space, call | 5039 | The release the pages, call |
5045 | <function>snd_free_xxx_pages()</function> function. | 5040 | <function>snd_free_xxx_pages()</function> function. |
5046 | </para> | 5041 | </para> |
5047 | 5042 | ||
@@ -5050,8 +5045,8 @@ struct _snd_pcm_runtime { | |||
5050 | a large contiguous physical space | 5045 | a large contiguous physical space |
5051 | at the time the module is loaded for the later use. | 5046 | at the time the module is loaded for the later use. |
5052 | This is called <quote>pre-allocation</quote>. | 5047 | This is called <quote>pre-allocation</quote>. |
5053 | As already written, you can call the following function at the | 5048 | As already written, you can call the following function at |
5054 | construction of pcm instance (in the case of PCI bus). | 5049 | pcm instance construction time (in the case of PCI bus). |
5055 | 5050 | ||
5056 | <informalexample> | 5051 | <informalexample> |
5057 | <programlisting> | 5052 | <programlisting> |
@@ -5063,34 +5058,34 @@ struct _snd_pcm_runtime { | |||
5063 | </informalexample> | 5058 | </informalexample> |
5064 | 5059 | ||
5065 | where <parameter>size</parameter> is the byte size to be | 5060 | where <parameter>size</parameter> is the byte size to be |
5066 | pre-allocated and the <parameter>max</parameter> is the maximal | 5061 | pre-allocated and the <parameter>max</parameter> is the maximum |
5067 | size to be changed via <filename>prealloc</filename> proc file. | 5062 | size to be changed via the <filename>prealloc</filename> proc file. |
5068 | The allocator will try to get as large area as possible | 5063 | The allocator will try to get an area as large as possible |
5069 | within the given size. | 5064 | within the given size. |
5070 | </para> | 5065 | </para> |
5071 | 5066 | ||
5072 | <para> | 5067 | <para> |
5073 | The second argument (type) and the third argument (device pointer) | 5068 | The second argument (type) and the third argument (device pointer) |
5074 | are dependent on the bus. | 5069 | are dependent on the bus. |
5075 | In the case of ISA bus, pass <function>snd_dma_isa_data()</function> | 5070 | In the case of the ISA bus, pass <function>snd_dma_isa_data()</function> |
5076 | as the third argument with <constant>SNDRV_DMA_TYPE_DEV</constant> type. | 5071 | as the third argument with <constant>SNDRV_DMA_TYPE_DEV</constant> type. |
5077 | For the continuous buffer unrelated to the bus can be pre-allocated | 5072 | For the continuous buffer unrelated to the bus can be pre-allocated |
5078 | with <constant>SNDRV_DMA_TYPE_CONTINUOUS</constant> type and the | 5073 | with <constant>SNDRV_DMA_TYPE_CONTINUOUS</constant> type and the |
5079 | <function>snd_dma_continuous_data(GFP_KERNEL)</function> device pointer, | 5074 | <function>snd_dma_continuous_data(GFP_KERNEL)</function> device pointer, |
5080 | whereh <constant>GFP_KERNEL</constant> is the kernel allocation flag to | 5075 | where <constant>GFP_KERNEL</constant> is the kernel allocation flag to |
5081 | use. For the SBUS, <constant>SNDRV_DMA_TYPE_SBUS</constant> and | 5076 | use. For the SBUS, <constant>SNDRV_DMA_TYPE_SBUS</constant> and |
5082 | <function>snd_dma_sbus_data(sbus_dev)</function> are used instead. | 5077 | <function>snd_dma_sbus_data(sbus_dev)</function> are used instead. |
5083 | For the PCI scatter-gather buffers, use | 5078 | For the PCI scatter-gather buffers, use |
5084 | <constant>SNDRV_DMA_TYPE_DEV_SG</constant> with | 5079 | <constant>SNDRV_DMA_TYPE_DEV_SG</constant> with |
5085 | <function>snd_dma_pci_data(pci)</function> | 5080 | <function>snd_dma_pci_data(pci)</function> |
5086 | (see the section | 5081 | (see the |
5087 | <link linkend="buffer-and-memory-non-contiguous"><citetitle>Non-Contiguous Buffers | 5082 | <link linkend="buffer-and-memory-non-contiguous"><citetitle>Non-Contiguous Buffers |
5088 | </citetitle></link>). | 5083 | </citetitle></link> section). |
5089 | </para> | 5084 | </para> |
5090 | 5085 | ||
5091 | <para> | 5086 | <para> |
5092 | Once when the buffer is pre-allocated, you can use the | 5087 | Once the buffer is pre-allocated, you can use the |
5093 | allocator in the <structfield>hw_params</structfield> callback | 5088 | allocator in the <structfield>hw_params</structfield> callback: |
5094 | 5089 | ||
5095 | <informalexample> | 5090 | <informalexample> |
5096 | <programlisting> | 5091 | <programlisting> |
@@ -5116,8 +5111,8 @@ struct _snd_pcm_runtime { | |||
5116 | </para> | 5111 | </para> |
5117 | 5112 | ||
5118 | <para> | 5113 | <para> |
5119 | The first case works fine if the external hardware buffer is enough | 5114 | The first case works fine if the external hardware buffer is large |
5120 | large. This method doesn't need any extra buffers and thus is | 5115 | enough. This method doesn't need any extra buffers and thus is |
5121 | more effective. You need to define the | 5116 | more effective. You need to define the |
5122 | <structfield>copy</structfield> and | 5117 | <structfield>copy</structfield> and |
5123 | <structfield>silence</structfield> callbacks for | 5118 | <structfield>silence</structfield> callbacks for |
@@ -5127,25 +5122,25 @@ struct _snd_pcm_runtime { | |||
5127 | </para> | 5122 | </para> |
5128 | 5123 | ||
5129 | <para> | 5124 | <para> |
5130 | The second case allows the mmap of the buffer, although you have | 5125 | The second case allows for mmap on the buffer, although you have |
5131 | to handle an interrupt or a tasklet for transferring the data | 5126 | to handle an interrupt or a tasklet to transfer the data |
5132 | from the intermediate buffer to the hardware buffer. You can find an | 5127 | from the intermediate buffer to the hardware buffer. You can find an |
5133 | example in vxpocket driver. | 5128 | example in the vxpocket driver. |
5134 | </para> | 5129 | </para> |
5135 | 5130 | ||
5136 | <para> | 5131 | <para> |
5137 | Another case is that the chip uses a PCI memory-map | 5132 | Another case is when the chip uses a PCI memory-map |
5138 | region for the buffer instead of the host memory. In this case, | 5133 | region for the buffer instead of the host memory. In this case, |
5139 | mmap is available only on certain architectures like intel. In | 5134 | mmap is available only on certain architectures like the Intel one. |
5140 | non-mmap mode, the data cannot be transferred as the normal | 5135 | In non-mmap mode, the data cannot be transferred as in the normal |
5141 | way. Thus you need to define <structfield>copy</structfield> and | 5136 | way. Thus you need to define the <structfield>copy</structfield> and |
5142 | <structfield>silence</structfield> callbacks as well | 5137 | <structfield>silence</structfield> callbacks as well, |
5143 | as in the cases above. The examples are found in | 5138 | as in the cases above. The examples are found in |
5144 | <filename>rme32.c</filename> and <filename>rme96.c</filename>. | 5139 | <filename>rme32.c</filename> and <filename>rme96.c</filename>. |
5145 | </para> | 5140 | </para> |
5146 | 5141 | ||
5147 | <para> | 5142 | <para> |
5148 | The implementation of <structfield>copy</structfield> and | 5143 | The implementation of the <structfield>copy</structfield> and |
5149 | <structfield>silence</structfield> callbacks depends upon | 5144 | <structfield>silence</structfield> callbacks depends upon |
5150 | whether the hardware supports interleaved or non-interleaved | 5145 | whether the hardware supports interleaved or non-interleaved |
5151 | samples. The <structfield>copy</structfield> callback is | 5146 | samples. The <structfield>copy</structfield> callback is |
@@ -5184,8 +5179,8 @@ struct _snd_pcm_runtime { | |||
5184 | 5179 | ||
5185 | <para> | 5180 | <para> |
5186 | What you have to do in this callback is again different | 5181 | What you have to do in this callback is again different |
5187 | between playback and capture directions. In the case of | 5182 | between playback and capture directions. In the |
5188 | playback, you do: copy the given amount of data | 5183 | playback case, you copy the given amount of data |
5189 | (<parameter>count</parameter>) at the specified pointer | 5184 | (<parameter>count</parameter>) at the specified pointer |
5190 | (<parameter>src</parameter>) to the specified offset | 5185 | (<parameter>src</parameter>) to the specified offset |
5191 | (<parameter>pos</parameter>) on the hardware buffer. When | 5186 | (<parameter>pos</parameter>) on the hardware buffer. When |
@@ -5202,7 +5197,7 @@ struct _snd_pcm_runtime { | |||
5202 | </para> | 5197 | </para> |
5203 | 5198 | ||
5204 | <para> | 5199 | <para> |
5205 | For the capture direction, you do: copy the given amount of | 5200 | For the capture direction, you copy the given amount of |
5206 | data (<parameter>count</parameter>) at the specified offset | 5201 | data (<parameter>count</parameter>) at the specified offset |
5207 | (<parameter>pos</parameter>) on the hardware buffer to the | 5202 | (<parameter>pos</parameter>) on the hardware buffer to the |
5208 | specified pointer (<parameter>dst</parameter>). | 5203 | specified pointer (<parameter>dst</parameter>). |
@@ -5216,7 +5211,7 @@ struct _snd_pcm_runtime { | |||
5216 | </programlisting> | 5211 | </programlisting> |
5217 | </informalexample> | 5212 | </informalexample> |
5218 | 5213 | ||
5219 | Note that both of the position and the data amount are given | 5214 | Note that both the position and the amount of data are given |
5220 | in frames. | 5215 | in frames. |
5221 | </para> | 5216 | </para> |
5222 | 5217 | ||
@@ -5247,7 +5242,7 @@ struct _snd_pcm_runtime { | |||
5247 | </para> | 5242 | </para> |
5248 | 5243 | ||
5249 | <para> | 5244 | <para> |
5250 | The meanings of arguments are identical with the | 5245 | The meanings of arguments are the same as in the |
5251 | <structfield>copy</structfield> | 5246 | <structfield>copy</structfield> |
5252 | callback, although there is no <parameter>src/dst</parameter> | 5247 | callback, although there is no <parameter>src/dst</parameter> |
5253 | argument. In the case of interleaved samples, the channel | 5248 | argument. In the case of interleaved samples, the channel |
@@ -5284,8 +5279,8 @@ struct _snd_pcm_runtime { | |||
5284 | <section id="buffer-and-memory-non-contiguous"> | 5279 | <section id="buffer-and-memory-non-contiguous"> |
5285 | <title>Non-Contiguous Buffers</title> | 5280 | <title>Non-Contiguous Buffers</title> |
5286 | <para> | 5281 | <para> |
5287 | If your hardware supports the page table like emu10k1 or the | 5282 | If your hardware supports the page table as in emu10k1 or the |
5288 | buffer descriptors like via82xx, you can use the scatter-gather | 5283 | buffer descriptors as in via82xx, you can use the scatter-gather |
5289 | (SG) DMA. ALSA provides an interface for handling SG-buffers. | 5284 | (SG) DMA. ALSA provides an interface for handling SG-buffers. |
5290 | The API is provided in <filename><sound/pcm.h></filename>. | 5285 | The API is provided in <filename><sound/pcm.h></filename>. |
5291 | </para> | 5286 | </para> |
@@ -5296,7 +5291,7 @@ struct _snd_pcm_runtime { | |||
5296 | <function>snd_pcm_lib_preallocate_pages_for_all()</function> | 5291 | <function>snd_pcm_lib_preallocate_pages_for_all()</function> |
5297 | with <constant>SNDRV_DMA_TYPE_DEV_SG</constant> | 5292 | with <constant>SNDRV_DMA_TYPE_DEV_SG</constant> |
5298 | in the PCM constructor like other PCI pre-allocator. | 5293 | in the PCM constructor like other PCI pre-allocator. |
5299 | You need to pass the <function>snd_dma_pci_data(pci)</function>, | 5294 | You need to pass <function>snd_dma_pci_data(pci)</function>, |
5300 | where pci is the struct <structname>pci_dev</structname> pointer | 5295 | where pci is the struct <structname>pci_dev</structname> pointer |
5301 | of the chip as well. | 5296 | of the chip as well. |
5302 | The <type>struct snd_sg_buf</type> instance is created as | 5297 | The <type>struct snd_sg_buf</type> instance is created as |
@@ -5314,7 +5309,7 @@ struct _snd_pcm_runtime { | |||
5314 | 5309 | ||
5315 | <para> | 5310 | <para> |
5316 | Then call <function>snd_pcm_lib_malloc_pages()</function> | 5311 | Then call <function>snd_pcm_lib_malloc_pages()</function> |
5317 | in <structfield>hw_params</structfield> callback | 5312 | in the <structfield>hw_params</structfield> callback |
5318 | as well as in the case of normal PCI buffer. | 5313 | as well as in the case of normal PCI buffer. |
5319 | The SG-buffer handler will allocate the non-contiguous kernel | 5314 | The SG-buffer handler will allocate the non-contiguous kernel |
5320 | pages of the given size and map them onto the virtually contiguous | 5315 | pages of the given size and map them onto the virtually contiguous |
@@ -5335,7 +5330,7 @@ struct _snd_pcm_runtime { | |||
5335 | </para> | 5330 | </para> |
5336 | 5331 | ||
5337 | <para> | 5332 | <para> |
5338 | For releasing the data, call | 5333 | To release the data, call |
5339 | <function>snd_pcm_lib_free_pages()</function> in the | 5334 | <function>snd_pcm_lib_free_pages()</function> in the |
5340 | <structfield>hw_free</structfield> callback as usual. | 5335 | <structfield>hw_free</structfield> callback as usual. |
5341 | </para> | 5336 | </para> |
@@ -5390,7 +5385,7 @@ struct _snd_pcm_runtime { | |||
5390 | </para> | 5385 | </para> |
5391 | 5386 | ||
5392 | <para> | 5387 | <para> |
5393 | For creating a proc file, call | 5388 | To create a proc file, call |
5394 | <function>snd_card_proc_new()</function>. | 5389 | <function>snd_card_proc_new()</function>. |
5395 | 5390 | ||
5396 | <informalexample> | 5391 | <informalexample> |
@@ -5402,7 +5397,7 @@ struct _snd_pcm_runtime { | |||
5402 | </programlisting> | 5397 | </programlisting> |
5403 | </informalexample> | 5398 | </informalexample> |
5404 | 5399 | ||
5405 | where the second argument specifies the proc-file name to be | 5400 | where the second argument specifies the name of the proc file to be |
5406 | created. The above example will create a file | 5401 | created. The above example will create a file |
5407 | <filename>my-file</filename> under the card directory, | 5402 | <filename>my-file</filename> under the card directory, |
5408 | e.g. <filename>/proc/asound/card0/my-file</filename>. | 5403 | e.g. <filename>/proc/asound/card0/my-file</filename>. |
@@ -5417,8 +5412,8 @@ struct _snd_pcm_runtime { | |||
5417 | 5412 | ||
5418 | <para> | 5413 | <para> |
5419 | When the creation is successful, the function stores a new | 5414 | When the creation is successful, the function stores a new |
5420 | instance at the pointer given in the third argument. | 5415 | instance in the pointer given in the third argument. |
5421 | It is initialized as a text proc file for read only. For using | 5416 | It is initialized as a text proc file for read only. To use |
5422 | this proc file as a read-only text file as it is, set the read | 5417 | this proc file as a read-only text file as it is, set the read |
5423 | callback with a private data via | 5418 | callback with a private data via |
5424 | <function>snd_info_set_text_ops()</function>. | 5419 | <function>snd_info_set_text_ops()</function>. |
@@ -5470,9 +5465,9 @@ struct _snd_pcm_runtime { | |||
5470 | </para> | 5465 | </para> |
5471 | 5466 | ||
5472 | <para> | 5467 | <para> |
5473 | The file permission can be changed afterwards. As default, it's | 5468 | The file permissions can be changed afterwards. As default, it's |
5474 | set as read only for all users. If you want to add the write | 5469 | set as read only for all users. If you want to add write |
5475 | permission to the user (root as default), set like below: | 5470 | permission for the user (root as default), do as follows: |
5476 | 5471 | ||
5477 | <informalexample> | 5472 | <informalexample> |
5478 | <programlisting> | 5473 | <programlisting> |
@@ -5503,7 +5498,7 @@ struct _snd_pcm_runtime { | |||
5503 | </para> | 5498 | </para> |
5504 | 5499 | ||
5505 | <para> | 5500 | <para> |
5506 | For a raw-data proc-file, set the attributes like the following: | 5501 | For a raw-data proc-file, set the attributes as follows: |
5507 | 5502 | ||
5508 | <informalexample> | 5503 | <informalexample> |
5509 | <programlisting> | 5504 | <programlisting> |
@@ -5524,7 +5519,7 @@ struct _snd_pcm_runtime { | |||
5524 | 5519 | ||
5525 | <para> | 5520 | <para> |
5526 | The callback is much more complicated than the text-file | 5521 | The callback is much more complicated than the text-file |
5527 | version. You need to use a low-level i/o functions such as | 5522 | version. You need to use a low-level I/O functions such as |
5528 | <function>copy_from/to_user()</function> to transfer the | 5523 | <function>copy_from/to_user()</function> to transfer the |
5529 | data. | 5524 | data. |
5530 | 5525 | ||
@@ -5560,28 +5555,28 @@ struct _snd_pcm_runtime { | |||
5560 | <title>Power Management</title> | 5555 | <title>Power Management</title> |
5561 | <para> | 5556 | <para> |
5562 | If the chip is supposed to work with suspend/resume | 5557 | If the chip is supposed to work with suspend/resume |
5563 | functions, you need to add the power-management codes to the | 5558 | functions, you need to add power-management code to the |
5564 | driver. The additional codes for the power-management should be | 5559 | driver. The additional code for power-management should be |
5565 | <function>ifdef</function>'ed with | 5560 | <function>ifdef</function>'ed with |
5566 | <constant>CONFIG_PM</constant>. | 5561 | <constant>CONFIG_PM</constant>. |
5567 | </para> | 5562 | </para> |
5568 | 5563 | ||
5569 | <para> | 5564 | <para> |
5570 | If the driver supports the suspend/resume | 5565 | If the driver <emphasis>fully</emphasis> supports suspend/resume |
5571 | <emphasis>fully</emphasis>, that is, the device can be | 5566 | that is, the device can be |
5572 | properly resumed to the status at the suspend is called, | 5567 | properly resumed to its state when suspend was called, |
5573 | you can set <constant>SNDRV_PCM_INFO_RESUME</constant> flag | 5568 | you can set the <constant>SNDRV_PCM_INFO_RESUME</constant> flag |
5574 | to pcm info field. Usually, this is possible when the | 5569 | in the pcm info field. Usually, this is possible when the |
5575 | registers of ths chip can be safely saved and restored to the | 5570 | registers of the chip can be safely saved and restored to |
5576 | RAM. If this is set, the trigger callback is called with | 5571 | RAM. If this is set, the trigger callback is called with |
5577 | <constant>SNDRV_PCM_TRIGGER_RESUME</constant> after resume | 5572 | <constant>SNDRV_PCM_TRIGGER_RESUME</constant> after the resume |
5578 | callback is finished. | 5573 | callback completes. |
5579 | </para> | 5574 | </para> |
5580 | 5575 | ||
5581 | <para> | 5576 | <para> |
5582 | Even if the driver doesn't support PM fully but only the | 5577 | Even if the driver doesn't support PM fully but |
5583 | partial suspend/resume is possible, it's still worthy to | 5578 | partial suspend/resume is still possible, it's still worthy to |
5584 | implement suspend/resume callbacks. In such a case, applications | 5579 | implement suspend/resume callbacks. In such a case, applications |
5585 | would reset the status by calling | 5580 | would reset the status by calling |
5586 | <function>snd_pcm_prepare()</function> and restart the stream | 5581 | <function>snd_pcm_prepare()</function> and restart the stream |
5587 | appropriately. Hence, you can define suspend/resume callbacks | 5582 | appropriately. Hence, you can define suspend/resume callbacks |
@@ -5590,22 +5585,22 @@ struct _snd_pcm_runtime { | |||
5590 | </para> | 5585 | </para> |
5591 | 5586 | ||
5592 | <para> | 5587 | <para> |
5593 | Note that the trigger with SUSPEND can be always called when | 5588 | Note that the trigger with SUSPEND can always be called when |
5594 | <function>snd_pcm_suspend_all</function> is called, | 5589 | <function>snd_pcm_suspend_all</function> is called, |
5595 | regardless of <constant>SNDRV_PCM_INFO_RESUME</constant> flag. | 5590 | regardless of the <constant>SNDRV_PCM_INFO_RESUME</constant> flag. |
5596 | The <constant>RESUME</constant> flag affects only the behavior | 5591 | The <constant>RESUME</constant> flag affects only the behavior |
5597 | of <function>snd_pcm_resume()</function>. | 5592 | of <function>snd_pcm_resume()</function>. |
5598 | (Thus, in theory, | 5593 | (Thus, in theory, |
5599 | <constant>SNDRV_PCM_TRIGGER_RESUME</constant> isn't needed | 5594 | <constant>SNDRV_PCM_TRIGGER_RESUME</constant> isn't needed |
5600 | to be handled in the trigger callback when no | 5595 | to be handled in the trigger callback when no |
5601 | <constant>SNDRV_PCM_INFO_RESUME</constant> flag is set. But, | 5596 | <constant>SNDRV_PCM_INFO_RESUME</constant> flag is set. But, |
5602 | it's better to keep it for compatibility reason.) | 5597 | it's better to keep it for compatibility reasons.) |
5603 | </para> | 5598 | </para> |
5604 | <para> | 5599 | <para> |
5605 | In the earlier version of ALSA drivers, a common | 5600 | In the earlier version of ALSA drivers, a common |
5606 | power-management layer was provided, but it has been removed. | 5601 | power-management layer was provided, but it has been removed. |
5607 | The driver needs to define the suspend/resume hooks according to | 5602 | The driver needs to define the suspend/resume hooks according to |
5608 | the bus the device is assigned. In the case of PCI driver, the | 5603 | the bus the device is connected to. In the case of PCI drivers, the |
5609 | callbacks look like below: | 5604 | callbacks look like below: |
5610 | 5605 | ||
5611 | <informalexample> | 5606 | <informalexample> |
@@ -5629,7 +5624,7 @@ struct _snd_pcm_runtime { | |||
5629 | </para> | 5624 | </para> |
5630 | 5625 | ||
5631 | <para> | 5626 | <para> |
5632 | The scheme of the real suspend job is as following. | 5627 | The scheme of the real suspend job is as follows. |
5633 | 5628 | ||
5634 | <orderedlist> | 5629 | <orderedlist> |
5635 | <listitem><para>Retrieve the card and the chip data.</para></listitem> | 5630 | <listitem><para>Retrieve the card and the chip data.</para></listitem> |
@@ -5679,11 +5674,11 @@ struct _snd_pcm_runtime { | |||
5679 | </para> | 5674 | </para> |
5680 | 5675 | ||
5681 | <para> | 5676 | <para> |
5682 | The scheme of the real resume job is as following. | 5677 | The scheme of the real resume job is as follows. |
5683 | 5678 | ||
5684 | <orderedlist> | 5679 | <orderedlist> |
5685 | <listitem><para>Retrieve the card and the chip data.</para></listitem> | 5680 | <listitem><para>Retrieve the card and the chip data.</para></listitem> |
5686 | <listitem><para>Set up PCI. First, call <function>pci_restore_state()</function>. | 5681 | <listitem><para>Set up PCI. First, call <function>pci_restore_state()</function>. |
5687 | Then enable the pci device again by calling <function>pci_enable_device()</function>. | 5682 | Then enable the pci device again by calling <function>pci_enable_device()</function>. |
5688 | Call <function>pci_set_master()</function> if necessary, too.</para></listitem> | 5683 | Call <function>pci_set_master()</function> if necessary, too.</para></listitem> |
5689 | <listitem><para>Re-initialize the chip.</para></listitem> | 5684 | <listitem><para>Re-initialize the chip.</para></listitem> |
@@ -5734,7 +5729,7 @@ struct _snd_pcm_runtime { | |||
5734 | <function>snd_pcm_suspend_all()</function> or | 5729 | <function>snd_pcm_suspend_all()</function> or |
5735 | <function>snd_pcm_suspend()</function>. It means that the PCM | 5730 | <function>snd_pcm_suspend()</function>. It means that the PCM |
5736 | streams are already stoppped when the register snapshot is | 5731 | streams are already stoppped when the register snapshot is |
5737 | taken. But, remind that you don't have to restart the PCM | 5732 | taken. But, remember that you don't have to restart the PCM |
5738 | stream in the resume callback. It'll be restarted via | 5733 | stream in the resume callback. It'll be restarted via |
5739 | trigger call with <constant>SNDRV_PCM_TRIGGER_RESUME</constant> | 5734 | trigger call with <constant>SNDRV_PCM_TRIGGER_RESUME</constant> |
5740 | when necessary. | 5735 | when necessary. |
@@ -5795,7 +5790,7 @@ struct _snd_pcm_runtime { | |||
5795 | </para> | 5790 | </para> |
5796 | 5791 | ||
5797 | <para> | 5792 | <para> |
5798 | If you need a space for saving the registers, allocate the | 5793 | If you need a space to save the registers, allocate the |
5799 | buffer for it here, too, since it would be fatal | 5794 | buffer for it here, too, since it would be fatal |
5800 | if you cannot allocate a memory in the suspend phase. | 5795 | if you cannot allocate a memory in the suspend phase. |
5801 | The allocated buffer should be released in the corresponding | 5796 | The allocated buffer should be released in the corresponding |
@@ -5833,7 +5828,7 @@ struct _snd_pcm_runtime { | |||
5833 | <title>Module Parameters</title> | 5828 | <title>Module Parameters</title> |
5834 | <para> | 5829 | <para> |
5835 | There are standard module options for ALSA. At least, each | 5830 | There are standard module options for ALSA. At least, each |
5836 | module should have <parameter>index</parameter>, | 5831 | module should have the <parameter>index</parameter>, |
5837 | <parameter>id</parameter> and <parameter>enable</parameter> | 5832 | <parameter>id</parameter> and <parameter>enable</parameter> |
5838 | options. | 5833 | options. |
5839 | </para> | 5834 | </para> |
@@ -5841,8 +5836,8 @@ struct _snd_pcm_runtime { | |||
5841 | <para> | 5836 | <para> |
5842 | If the module supports multiple cards (usually up to | 5837 | If the module supports multiple cards (usually up to |
5843 | 8 = <constant>SNDRV_CARDS</constant> cards), they should be | 5838 | 8 = <constant>SNDRV_CARDS</constant> cards), they should be |
5844 | arrays. The default initial values are defined already as | 5839 | arrays. The default initial values are defined already as |
5845 | constants for ease of programming: | 5840 | constants for easier programming: |
5846 | 5841 | ||
5847 | <informalexample> | 5842 | <informalexample> |
5848 | <programlisting> | 5843 | <programlisting> |
@@ -5858,7 +5853,7 @@ struct _snd_pcm_runtime { | |||
5858 | <para> | 5853 | <para> |
5859 | If the module supports only a single card, they could be single | 5854 | If the module supports only a single card, they could be single |
5860 | variables, instead. <parameter>enable</parameter> option is not | 5855 | variables, instead. <parameter>enable</parameter> option is not |
5861 | always necessary in this case, but it wouldn't be so bad to have a | 5856 | always necessary in this case, but it would be better to have a |
5862 | dummy option for compatibility. | 5857 | dummy option for compatibility. |
5863 | </para> | 5858 | </para> |
5864 | 5859 | ||
@@ -5923,22 +5918,22 @@ struct _snd_pcm_runtime { | |||
5923 | </para> | 5918 | </para> |
5924 | 5919 | ||
5925 | <para> | 5920 | <para> |
5926 | Suppose that you'll create a new PCI driver for the card | 5921 | Suppose that you create a new PCI driver for the card |
5927 | <quote>xyz</quote>. The card module name would be | 5922 | <quote>xyz</quote>. The card module name would be |
5928 | snd-xyz. The new driver is usually put into alsa-driver | 5923 | snd-xyz. The new driver is usually put into the alsa-driver |
5929 | tree, <filename>alsa-driver/pci</filename> directory in | 5924 | tree, <filename>alsa-driver/pci</filename> directory in |
5930 | the case of PCI cards. | 5925 | the case of PCI cards. |
5931 | Then the driver is evaluated, audited and tested | 5926 | Then the driver is evaluated, audited and tested |
5932 | by developers and users. After a certain time, the driver | 5927 | by developers and users. After a certain time, the driver |
5933 | will go to alsa-kernel tree (to the corresponding directory, | 5928 | will go to the alsa-kernel tree (to the corresponding directory, |
5934 | such as <filename>alsa-kernel/pci</filename>) and eventually | 5929 | such as <filename>alsa-kernel/pci</filename>) and eventually |
5935 | integrated into Linux 2.6 tree (the directory would be | 5930 | will be integrated into the Linux 2.6 tree (the directory would be |
5936 | <filename>linux/sound/pci</filename>). | 5931 | <filename>linux/sound/pci</filename>). |
5937 | </para> | 5932 | </para> |
5938 | 5933 | ||
5939 | <para> | 5934 | <para> |
5940 | In the following sections, the driver code is supposed | 5935 | In the following sections, the driver code is supposed |
5941 | to be put into alsa-driver tree. The two cases are assumed: | 5936 | to be put into alsa-driver tree. The two cases are covered: |
5942 | a driver consisting of a single source file and one consisting | 5937 | a driver consisting of a single source file and one consisting |
5943 | of several source files. | 5938 | of several source files. |
5944 | </para> | 5939 | </para> |
@@ -6033,7 +6028,7 @@ struct _snd_pcm_runtime { | |||
6033 | <listitem> | 6028 | <listitem> |
6034 | <para> | 6029 | <para> |
6035 | Add a new directory (<filename>xyz</filename>) in | 6030 | Add a new directory (<filename>xyz</filename>) in |
6036 | <filename>alsa-driver/pci/Makefile</filename> like below | 6031 | <filename>alsa-driver/pci/Makefile</filename> as below |
6037 | 6032 | ||
6038 | <informalexample> | 6033 | <informalexample> |
6039 | <programlisting> | 6034 | <programlisting> |
@@ -6102,7 +6097,7 @@ struct _snd_pcm_runtime { | |||
6102 | <section id="useful-functions-snd-printk"> | 6097 | <section id="useful-functions-snd-printk"> |
6103 | <title><function>snd_printk()</function> and friends</title> | 6098 | <title><function>snd_printk()</function> and friends</title> |
6104 | <para> | 6099 | <para> |
6105 | ALSA provides a verbose version of | 6100 | ALSA provides a verbose version of the |
6106 | <function>printk()</function> function. If a kernel config | 6101 | <function>printk()</function> function. If a kernel config |
6107 | <constant>CONFIG_SND_VERBOSE_PRINTK</constant> is set, this | 6102 | <constant>CONFIG_SND_VERBOSE_PRINTK</constant> is set, this |
6108 | function prints the given message together with the file name | 6103 | function prints the given message together with the file name |
@@ -6170,7 +6165,7 @@ struct _snd_pcm_runtime { | |||
6170 | <section id="useful-functions-snd-bug"> | 6165 | <section id="useful-functions-snd-bug"> |
6171 | <title><function>snd_BUG()</function></title> | 6166 | <title><function>snd_BUG()</function></title> |
6172 | <para> | 6167 | <para> |
6173 | It shows <computeroutput>BUG?</computeroutput> message and | 6168 | It shows the <computeroutput>BUG?</computeroutput> message and |
6174 | stack trace as well as <function>snd_assert</function> at the point. | 6169 | stack trace as well as <function>snd_assert</function> at the point. |
6175 | It's useful to show that a fatal error happens there. | 6170 | It's useful to show that a fatal error happens there. |
6176 | </para> | 6171 | </para> |
@@ -6199,6 +6194,4 @@ struct _snd_pcm_runtime { | |||
6199 | in the hardware constraints section. | 6194 | in the hardware constraints section. |
6200 | </para> | 6195 | </para> |
6201 | </chapter> | 6196 | </chapter> |
6202 | |||
6203 | |||
6204 | </book> | 6197 | </book> |
diff --git a/Documentation/sound/alsa/soc/DAI.txt b/Documentation/sound/alsa/soc/DAI.txt index 3feeb9ecdec4..0ebd7ea9706c 100644 --- a/Documentation/sound/alsa/soc/DAI.txt +++ b/Documentation/sound/alsa/soc/DAI.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | ASoC currently supports the three main Digital Audio Interfaces (DAI) found on | 1 | ASoC currently supports the three main Digital Audio Interfaces (DAI) found on |
2 | SoC controllers and portable audio CODECS today, namely AC97, I2S and PCM. | 2 | SoC controllers and portable audio CODECs today, namely AC97, I2S and PCM. |
3 | 3 | ||
4 | 4 | ||
5 | AC97 | 5 | AC97 |
@@ -25,7 +25,7 @@ left/right clock (LRC) synchronise the link. I2S is flexible in that either the | |||
25 | controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock | 25 | controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock |
26 | usually varies depending on the sample rate and the master system clock | 26 | usually varies depending on the sample rate and the master system clock |
27 | (SYSCLK). LRCLK is the same as the sample rate. A few devices support separate | 27 | (SYSCLK). LRCLK is the same as the sample rate. A few devices support separate |
28 | ADC and DAC LRCLK's, this allows for simultaneous capture and playback at | 28 | ADC and DAC LRCLKs, this allows for simultaneous capture and playback at |
29 | different sample rates. | 29 | different sample rates. |
30 | 30 | ||
31 | I2S has several different operating modes:- | 31 | I2S has several different operating modes:- |
@@ -35,7 +35,7 @@ I2S has several different operating modes:- | |||
35 | 35 | ||
36 | o Left Justified - MSB is transmitted on transition of LRC. | 36 | o Left Justified - MSB is transmitted on transition of LRC. |
37 | 37 | ||
38 | o Right Justified - MSB is transmitted sample size BCLK's before LRC | 38 | o Right Justified - MSB is transmitted sample size BCLKs before LRC |
39 | transition. | 39 | transition. |
40 | 40 | ||
41 | PCM | 41 | PCM |
diff --git a/Documentation/sound/alsa/soc/clocking.txt b/Documentation/sound/alsa/soc/clocking.txt index 14930887c25f..b1300162e01c 100644 --- a/Documentation/sound/alsa/soc/clocking.txt +++ b/Documentation/sound/alsa/soc/clocking.txt | |||
@@ -13,7 +13,7 @@ or SYSCLK). This audio master clock can be derived from a number of sources | |||
13 | (e.g. crystal, PLL, CPU clock) and is responsible for producing the correct | 13 | (e.g. crystal, PLL, CPU clock) and is responsible for producing the correct |
14 | audio playback and capture sample rates. | 14 | audio playback and capture sample rates. |
15 | 15 | ||
16 | Some master clocks (e.g. PLL's and CPU based clocks) are configurable in that | 16 | Some master clocks (e.g. PLLs and CPU based clocks) are configurable in that |
17 | their speed can be altered by software (depending on the system use and to save | 17 | their speed can be altered by software (depending on the system use and to save |
18 | power). Other master clocks are fixed at a set frequency (i.e. crystals). | 18 | power). Other master clocks are fixed at a set frequency (i.e. crystals). |
19 | 19 | ||
@@ -41,11 +41,11 @@ BCLK = LRC * x | |||
41 | BCLK = LRC * Channels * Word Size | 41 | BCLK = LRC * Channels * Word Size |
42 | 42 | ||
43 | This relationship depends on the codec or SoC CPU in particular. In general | 43 | This relationship depends on the codec or SoC CPU in particular. In general |
44 | it's best to configure BCLK to the lowest possible speed (depending on your | 44 | it is best to configure BCLK to the lowest possible speed (depending on your |
45 | rate, number of channels and wordsize) to save on power. | 45 | rate, number of channels and word size) to save on power. |
46 | 46 | ||
47 | It's also desirable to use the codec (if possible) to drive (or master) the | 47 | It is also desirable to use the codec (if possible) to drive (or master) the |
48 | audio clocks as it's usually gives more accurate sample rates than the CPU. | 48 | audio clocks as it usually gives more accurate sample rates than the CPU. |
49 | 49 | ||
50 | 50 | ||
51 | 51 | ||
diff --git a/Documentation/sound/alsa/soc/codec.txt b/Documentation/sound/alsa/soc/codec.txt index 1e766ad0ebd1..1e95342ed72e 100644 --- a/Documentation/sound/alsa/soc/codec.txt +++ b/Documentation/sound/alsa/soc/codec.txt | |||
@@ -9,7 +9,7 @@ code should be added to the platform and machine drivers respectively. | |||
9 | Each codec driver *must* provide the following features:- | 9 | Each codec driver *must* provide the following features:- |
10 | 10 | ||
11 | 1) Codec DAI and PCM configuration | 11 | 1) Codec DAI and PCM configuration |
12 | 2) Codec control IO - using I2C, 3 Wire(SPI) or both API's | 12 | 2) Codec control IO - using I2C, 3 Wire(SPI) or both APIs |
13 | 3) Mixers and audio controls | 13 | 3) Mixers and audio controls |
14 | 4) Codec audio operations | 14 | 4) Codec audio operations |
15 | 15 | ||
@@ -19,7 +19,7 @@ Optionally, codec drivers can also provide:- | |||
19 | 6) DAPM event handler. | 19 | 6) DAPM event handler. |
20 | 7) DAC Digital mute control. | 20 | 7) DAC Digital mute control. |
21 | 21 | ||
22 | It's probably best to use this guide in conjunction with the existing codec | 22 | Its probably best to use this guide in conjunction with the existing codec |
23 | driver code in sound/soc/codecs/ | 23 | driver code in sound/soc/codecs/ |
24 | 24 | ||
25 | ASoC Codec driver breakdown | 25 | ASoC Codec driver breakdown |
@@ -27,8 +27,8 @@ ASoC Codec driver breakdown | |||
27 | 27 | ||
28 | 1 - Codec DAI and PCM configuration | 28 | 1 - Codec DAI and PCM configuration |
29 | ----------------------------------- | 29 | ----------------------------------- |
30 | Each codec driver must have a struct snd_soc_codec_dai to define it's DAI and | 30 | Each codec driver must have a struct snd_soc_codec_dai to define its DAI and |
31 | PCM's capabilities and operations. This struct is exported so that it can be | 31 | PCM capabilities and operations. This struct is exported so that it can be |
32 | registered with the core by your machine driver. | 32 | registered with the core by your machine driver. |
33 | 33 | ||
34 | e.g. | 34 | e.g. |
@@ -67,18 +67,18 @@ EXPORT_SYMBOL_GPL(wm8731_dai); | |||
67 | 67 | ||
68 | 2 - Codec control IO | 68 | 2 - Codec control IO |
69 | -------------------- | 69 | -------------------- |
70 | The codec can usually be controlled via an I2C or SPI style interface (AC97 | 70 | The codec can usually be controlled via an I2C or SPI style interface |
71 | combines control with data in the DAI). The codec drivers will have to provide | 71 | (AC97 combines control with data in the DAI). The codec drivers provide |
72 | functions to read and write the codec registers along with supplying a register | 72 | functions to read and write the codec registers along with supplying a |
73 | cache:- | 73 | register cache:- |
74 | 74 | ||
75 | /* IO control data and register cache */ | 75 | /* IO control data and register cache */ |
76 | void *control_data; /* codec control (i2c/3wire) data */ | 76 | void *control_data; /* codec control (i2c/3wire) data */ |
77 | void *reg_cache; | 77 | void *reg_cache; |
78 | 78 | ||
79 | Codec read/write should do any data formatting and call the hardware read write | 79 | Codec read/write should do any data formatting and call the hardware |
80 | below to perform the IO. These functions are called by the core and alsa when | 80 | read write below to perform the IO. These functions are called by the |
81 | performing DAPM or changing the mixer:- | 81 | core and ALSA when performing DAPM or changing the mixer:- |
82 | 82 | ||
83 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | 83 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); |
84 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | 84 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); |
@@ -131,7 +131,7 @@ Defines a stereo enumerated control | |||
131 | 131 | ||
132 | 4 - Codec Audio Operations | 132 | 4 - Codec Audio Operations |
133 | -------------------------- | 133 | -------------------------- |
134 | The codec driver also supports the following alsa operations:- | 134 | The codec driver also supports the following ALSA operations:- |
135 | 135 | ||
136 | /* SoC audio ops */ | 136 | /* SoC audio ops */ |
137 | struct snd_soc_ops { | 137 | struct snd_soc_ops { |
@@ -142,15 +142,15 @@ struct snd_soc_ops { | |||
142 | int (*prepare)(struct snd_pcm_substream *); | 142 | int (*prepare)(struct snd_pcm_substream *); |
143 | }; | 143 | }; |
144 | 144 | ||
145 | Please refer to the alsa driver PCM documentation for details. | 145 | Please refer to the ALSA driver PCM documentation for details. |
146 | http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm | 146 | http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm |
147 | 147 | ||
148 | 148 | ||
149 | 5 - DAPM description. | 149 | 5 - DAPM description. |
150 | --------------------- | 150 | --------------------- |
151 | The Dynamic Audio Power Management description describes the codec's power | 151 | The Dynamic Audio Power Management description describes the codec power |
152 | components, their relationships and registers to the ASoC core. Please read | 152 | components and their relationships and registers to the ASoC core. |
153 | dapm.txt for details of building the description. | 153 | Please read dapm.txt for details of building the description. |
154 | 154 | ||
155 | Please also see the examples in other codec drivers. | 155 | Please also see the examples in other codec drivers. |
156 | 156 | ||
@@ -158,8 +158,8 @@ Please also see the examples in other codec drivers. | |||
158 | 6 - DAPM event handler | 158 | 6 - DAPM event handler |
159 | ---------------------- | 159 | ---------------------- |
160 | This function is a callback that handles codec domain PM calls and system | 160 | This function is a callback that handles codec domain PM calls and system |
161 | domain PM calls (e.g. suspend and resume). It's used to put the codec to sleep | 161 | domain PM calls (e.g. suspend and resume). It is used to put the codec |
162 | when not in use. | 162 | to sleep when not in use. |
163 | 163 | ||
164 | Power states:- | 164 | Power states:- |
165 | 165 | ||
@@ -175,13 +175,14 @@ Power states:- | |||
175 | SNDRV_CTL_POWER_D3cold: /* Everything Off, without power */ | 175 | SNDRV_CTL_POWER_D3cold: /* Everything Off, without power */ |
176 | 176 | ||
177 | 177 | ||
178 | 7 - Codec DAC digital mute control. | 178 | 7 - Codec DAC digital mute control |
179 | ------------------------------------ | 179 | ---------------------------------- |
180 | Most codecs have a digital mute before the DAC's that can be used to minimise | 180 | Most codecs have a digital mute before the DACs that can be used to |
181 | any system noise. The mute stops any digital data from entering the DAC. | 181 | minimise any system noise. The mute stops any digital data from |
182 | entering the DAC. | ||
182 | 183 | ||
183 | A callback can be created that is called by the core for each codec DAI when the | 184 | A callback can be created that is called by the core for each codec DAI |
184 | mute is applied or freed. | 185 | when the mute is applied or freed. |
185 | 186 | ||
186 | i.e. | 187 | i.e. |
187 | 188 | ||
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt index ab0766fd7869..c784a18b94dc 100644 --- a/Documentation/sound/alsa/soc/dapm.txt +++ b/Documentation/sound/alsa/soc/dapm.txt | |||
@@ -4,20 +4,20 @@ Dynamic Audio Power Management for Portable Devices | |||
4 | 1. Description | 4 | 1. Description |
5 | ============== | 5 | ============== |
6 | 6 | ||
7 | Dynamic Audio Power Management (DAPM) is designed to allow portable Linux devices | 7 | Dynamic Audio Power Management (DAPM) is designed to allow portable |
8 | to use the minimum amount of power within the audio subsystem at all times. It | 8 | Linux devices to use the minimum amount of power within the audio |
9 | is independent of other kernel PM and as such, can easily co-exist with the | 9 | subsystem at all times. It is independent of other kernel PM and as |
10 | other PM systems. | 10 | such, can easily co-exist with the other PM systems. |
11 | 11 | ||
12 | DAPM is also completely transparent to all user space applications as all power | 12 | DAPM is also completely transparent to all user space applications as |
13 | switching is done within the ASoC core. No code changes or recompiling are | 13 | all power switching is done within the ASoC core. No code changes or |
14 | required for user space applications. DAPM makes power switching decisions based | 14 | recompiling are required for user space applications. DAPM makes power |
15 | upon any audio stream (capture/playback) activity and audio mixer settings | 15 | switching decisions based upon any audio stream (capture/playback) |
16 | within the device. | 16 | activity and audio mixer settings within the device. |
17 | 17 | ||
18 | DAPM spans the whole machine. It covers power control within the entire audio | 18 | DAPM spans the whole machine. It covers power control within the entire |
19 | subsystem, this includes internal codec power blocks and machine level power | 19 | audio subsystem, this includes internal codec power blocks and machine |
20 | systems. | 20 | level power systems. |
21 | 21 | ||
22 | There are 4 power domains within DAPM | 22 | There are 4 power domains within DAPM |
23 | 23 | ||
@@ -34,7 +34,7 @@ There are 4 power domains within DAPM | |||
34 | Automatically set when mixer and mux settings are changed by the user. | 34 | Automatically set when mixer and mux settings are changed by the user. |
35 | e.g. alsamixer, amixer. | 35 | e.g. alsamixer, amixer. |
36 | 36 | ||
37 | 4. Stream domain - DAC's and ADC's. | 37 | 4. Stream domain - DACs and ADCs. |
38 | Enabled and disabled when stream playback/capture is started and | 38 | Enabled and disabled when stream playback/capture is started and |
39 | stopped respectively. e.g. aplay, arecord. | 39 | stopped respectively. e.g. aplay, arecord. |
40 | 40 | ||
@@ -51,7 +51,7 @@ widgets hereafter. | |||
51 | Audio DAPM widgets fall into a number of types:- | 51 | Audio DAPM widgets fall into a number of types:- |
52 | 52 | ||
53 | o Mixer - Mixes several analog signals into a single analog signal. | 53 | o Mixer - Mixes several analog signals into a single analog signal. |
54 | o Mux - An analog switch that outputs only 1 of it's inputs. | 54 | o Mux - An analog switch that outputs only one of many inputs. |
55 | o PGA - A programmable gain amplifier or attenuation widget. | 55 | o PGA - A programmable gain amplifier or attenuation widget. |
56 | o ADC - Analog to Digital Converter | 56 | o ADC - Analog to Digital Converter |
57 | o DAC - Digital to Analog Converter | 57 | o DAC - Digital to Analog Converter |
@@ -78,14 +78,14 @@ parameters for stream name and kcontrols. | |||
78 | 2.1 Stream Domain Widgets | 78 | 2.1 Stream Domain Widgets |
79 | ------------------------- | 79 | ------------------------- |
80 | 80 | ||
81 | Stream Widgets relate to the stream power domain and only consist of ADC's | 81 | Stream Widgets relate to the stream power domain and only consist of ADCs |
82 | (analog to digital converters) and DAC's (digital to analog converters). | 82 | (analog to digital converters) and DACs (digital to analog converters). |
83 | 83 | ||
84 | Stream widgets have the following format:- | 84 | Stream widgets have the following format:- |
85 | 85 | ||
86 | SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert), | 86 | SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert), |
87 | 87 | ||
88 | NOTE: the stream name must match the corresponding stream name in your codecs | 88 | NOTE: the stream name must match the corresponding stream name in your codec |
89 | snd_soc_codec_dai. | 89 | snd_soc_codec_dai. |
90 | 90 | ||
91 | e.g. stream widgets for HiFi playback and capture | 91 | e.g. stream widgets for HiFi playback and capture |
@@ -97,7 +97,7 @@ SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1), | |||
97 | 2.2 Path Domain Widgets | 97 | 2.2 Path Domain Widgets |
98 | ----------------------- | 98 | ----------------------- |
99 | 99 | ||
100 | Path domain widgets have a ability to control or effect the audio signal or | 100 | Path domain widgets have a ability to control or affect the audio signal or |
101 | audio paths within the audio subsystem. They have the following form:- | 101 | audio paths within the audio subsystem. They have the following form:- |
102 | 102 | ||
103 | SND_SOC_DAPM_PGA(name, reg, shift, invert, controls, num_controls) | 103 | SND_SOC_DAPM_PGA(name, reg, shift, invert, controls, num_controls) |
@@ -149,7 +149,7 @@ SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), | |||
149 | 2.4 Codec Domain | 149 | 2.4 Codec Domain |
150 | ---------------- | 150 | ---------------- |
151 | 151 | ||
152 | The Codec power domain has no widgets and is handled by the codecs DAPM event | 152 | The codec power domain has no widgets and is handled by the codecs DAPM event |
153 | handler. This handler is called when the codec powerstate is changed wrt to any | 153 | handler. This handler is called when the codec powerstate is changed wrt to any |
154 | stream event or by kernel PM events. | 154 | stream event or by kernel PM events. |
155 | 155 | ||
@@ -158,8 +158,8 @@ stream event or by kernel PM events. | |||
158 | ------------------- | 158 | ------------------- |
159 | 159 | ||
160 | Sometimes widgets exist in the codec or machine audio map that don't have any | 160 | Sometimes widgets exist in the codec or machine audio map that don't have any |
161 | corresponding register bit for power control. In this case it's necessary to | 161 | corresponding soft power control. In this case it is necessary to create |
162 | create a virtual widget - a widget with no control bits e.g. | 162 | a virtual widget - a widget with no control bits e.g. |
163 | 163 | ||
164 | SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_DAPM_NOPM, 0, 0, NULL, 0), | 164 | SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_DAPM_NOPM, 0, 0, NULL, 0), |
165 | 165 | ||
@@ -172,13 +172,14 @@ subsystem individually with a call to snd_soc_dapm_new_control(). | |||
172 | 3. Codec Widget Interconnections | 172 | 3. Codec Widget Interconnections |
173 | ================================ | 173 | ================================ |
174 | 174 | ||
175 | Widgets are connected to each other within the codec and machine by audio | 175 | Widgets are connected to each other within the codec and machine by audio paths |
176 | paths (called interconnections). Each interconnection must be defined in order | 176 | (called interconnections). Each interconnection must be defined in order to |
177 | to create a map of all audio paths between widgets. | 177 | create a map of all audio paths between widgets. |
178 | |||
178 | This is easiest with a diagram of the codec (and schematic of the machine audio | 179 | This is easiest with a diagram of the codec (and schematic of the machine audio |
179 | system), as it requires joining widgets together via their audio signal paths. | 180 | system), as it requires joining widgets together via their audio signal paths. |
180 | 181 | ||
181 | i.e. from the WM8731 codec's output mixer (wm8731.c) | 182 | e.g., from the WM8731 output mixer (wm8731.c) |
182 | 183 | ||
183 | The WM8731 output mixer has 3 inputs (sources) | 184 | The WM8731 output mixer has 3 inputs (sources) |
184 | 185 | ||
diff --git a/Documentation/sound/alsa/soc/machine.txt b/Documentation/sound/alsa/soc/machine.txt index 72bd222f2a21..f370e7db86af 100644 --- a/Documentation/sound/alsa/soc/machine.txt +++ b/Documentation/sound/alsa/soc/machine.txt | |||
@@ -16,7 +16,7 @@ struct snd_soc_machine { | |||
16 | int (*remove)(struct platform_device *pdev); | 16 | int (*remove)(struct platform_device *pdev); |
17 | 17 | ||
18 | /* the pre and post PM functions are used to do any PM work before and | 18 | /* the pre and post PM functions are used to do any PM work before and |
19 | * after the codec and DAI's do any PM work. */ | 19 | * after the codec and DAIs do any PM work. */ |
20 | int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); | 20 | int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); |
21 | int (*suspend_post)(struct platform_device *pdev, pm_message_t state); | 21 | int (*suspend_post)(struct platform_device *pdev, pm_message_t state); |
22 | int (*resume_pre)(struct platform_device *pdev); | 22 | int (*resume_pre)(struct platform_device *pdev); |
@@ -38,7 +38,7 @@ probe/remove are optional. Do any machine specific probe here. | |||
38 | suspend()/resume() | 38 | suspend()/resume() |
39 | ------------------ | 39 | ------------------ |
40 | The machine driver has pre and post versions of suspend and resume to take care | 40 | The machine driver has pre and post versions of suspend and resume to take care |
41 | of any machine audio tasks that have to be done before or after the codec, DAI's | 41 | of any machine audio tasks that have to be done before or after the codec, DAIs |
42 | and DMA is suspended and resumed. Optional. | 42 | and DMA is suspended and resumed. Optional. |
43 | 43 | ||
44 | 44 | ||
@@ -49,10 +49,10 @@ The machine specific audio operations can be set here. Again this is optional. | |||
49 | 49 | ||
50 | Machine DAI Configuration | 50 | Machine DAI Configuration |
51 | ------------------------- | 51 | ------------------------- |
52 | The machine DAI configuration glues all the codec and CPU DAI's together. It can | 52 | The machine DAI configuration glues all the codec and CPU DAIs together. It can |
53 | also be used to set up the DAI system clock and for any machine related DAI | 53 | also be used to set up the DAI system clock and for any machine related DAI |
54 | initialisation e.g. the machine audio map can be connected to the codec audio | 54 | initialisation e.g. the machine audio map can be connected to the codec audio |
55 | map, unconnnected codec pins can be set as such. Please see corgi.c, spitz.c | 55 | map, unconnected codec pins can be set as such. Please see corgi.c, spitz.c |
56 | for examples. | 56 | for examples. |
57 | 57 | ||
58 | struct snd_soc_dai_link is used to set up each DAI in your machine. e.g. | 58 | struct snd_soc_dai_link is used to set up each DAI in your machine. e.g. |
@@ -67,7 +67,7 @@ static struct snd_soc_dai_link corgi_dai = { | |||
67 | .ops = &corgi_ops, | 67 | .ops = &corgi_ops, |
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct snd_soc_machine then sets up the machine with it's DAI's. e.g. | 70 | struct snd_soc_machine then sets up the machine with it's DAIs. e.g. |
71 | 71 | ||
72 | /* corgi audio machine driver */ | 72 | /* corgi audio machine driver */ |
73 | static struct snd_soc_machine snd_soc_machine_corgi = { | 73 | static struct snd_soc_machine snd_soc_machine_corgi = { |
@@ -110,4 +110,4 @@ details. | |||
110 | Machine Controls | 110 | Machine Controls |
111 | ---------------- | 111 | ---------------- |
112 | 112 | ||
113 | Machine specific audio mixer controls can be added in the dai init function. \ No newline at end of file | 113 | Machine specific audio mixer controls can be added in the DAI init function. |
diff --git a/Documentation/sound/alsa/soc/overview.txt b/Documentation/sound/alsa/soc/overview.txt index c47ce9530677..1e4c6d3655f2 100644 --- a/Documentation/sound/alsa/soc/overview.txt +++ b/Documentation/sound/alsa/soc/overview.txt | |||
@@ -1,25 +1,26 @@ | |||
1 | ALSA SoC Layer | 1 | ALSA SoC Layer |
2 | ============== | 2 | ============== |
3 | 3 | ||
4 | The overall project goal of the ALSA System on Chip (ASoC) layer is to provide | 4 | The overall project goal of the ALSA System on Chip (ASoC) layer is to |
5 | better ALSA support for embedded system-on-chip processors (e.g. pxa2xx, au1x00, | 5 | provide better ALSA support for embedded system-on-chip processors (e.g. |
6 | iMX, etc) and portable audio codecs. Currently there is some support in the | 6 | pxa2xx, au1x00, iMX, etc) and portable audio codecs. Prior to the ASoC |
7 | kernel for SoC audio, however it has some limitations:- | 7 | subsystem there was some support in the kernel for SoC audio, however it |
8 | had some limitations:- | ||
8 | 9 | ||
9 | * Currently, codec drivers are often tightly coupled to the underlying SoC | 10 | * Codec drivers were often tightly coupled to the underlying SoC |
10 | CPU. This is not ideal and leads to code duplication i.e. Linux now has 4 | 11 | CPU. This is not ideal and leads to code duplication - for example, |
11 | different wm8731 drivers for 4 different SoC platforms. | 12 | Linux had different wm8731 drivers for 4 different SoC platforms. |
12 | 13 | ||
13 | * There is no standard method to signal user initiated audio events (e.g. | 14 | * There was no standard method to signal user initiated audio events (e.g. |
14 | Headphone/Mic insertion, Headphone/Mic detection after an insertion | 15 | Headphone/Mic insertion, Headphone/Mic detection after an insertion |
15 | event). These are quite common events on portable devices and often require | 16 | event). These are quite common events on portable devices and often require |
16 | machine specific code to re-route audio, enable amps, etc., after such an | 17 | machine specific code to re-route audio, enable amps, etc., after such an |
17 | event. | 18 | event. |
18 | 19 | ||
19 | * Current drivers tend to power up the entire codec when playing | 20 | * Drivers tended to power up the entire codec when playing (or |
20 | (or recording) audio. This is fine for a PC, but tends to waste a lot of | 21 | recording) audio. This is fine for a PC, but tends to waste a lot of |
21 | power on portable devices. There is also no support for saving power via | 22 | power on portable devices. There was also no support for saving |
22 | changing codec oversampling rates, bias currents, etc. | 23 | power via changing codec oversampling rates, bias currents, etc. |
23 | 24 | ||
24 | 25 | ||
25 | ASoC Design | 26 | ASoC Design |
@@ -31,12 +32,13 @@ features :- | |||
31 | * Codec independence. Allows reuse of codec drivers on other platforms | 32 | * Codec independence. Allows reuse of codec drivers on other platforms |
32 | and machines. | 33 | and machines. |
33 | 34 | ||
34 | * Easy I2S/PCM audio interface setup between codec and SoC. Each SoC interface | 35 | * Easy I2S/PCM audio interface setup between codec and SoC. Each SoC |
35 | and codec registers it's audio interface capabilities with the core and are | 36 | interface and codec registers it's audio interface capabilities with the |
36 | subsequently matched and configured when the application hw params are known. | 37 | core and are subsequently matched and configured when the application |
38 | hardware parameters are known. | ||
37 | 39 | ||
38 | * Dynamic Audio Power Management (DAPM). DAPM automatically sets the codec to | 40 | * Dynamic Audio Power Management (DAPM). DAPM automatically sets the codec to |
39 | it's minimum power state at all times. This includes powering up/down | 41 | its minimum power state at all times. This includes powering up/down |
40 | internal power blocks depending on the internal codec audio routing and any | 42 | internal power blocks depending on the internal codec audio routing and any |
41 | active streams. | 43 | active streams. |
42 | 44 | ||
@@ -45,16 +47,16 @@ features :- | |||
45 | signals the codec when to change power states. | 47 | signals the codec when to change power states. |
46 | 48 | ||
47 | * Machine specific controls: Allow machines to add controls to the sound card | 49 | * Machine specific controls: Allow machines to add controls to the sound card |
48 | (e.g. volume control for speaker amp). | 50 | (e.g. volume control for speaker amplifier). |
49 | 51 | ||
50 | To achieve all this, ASoC basically splits an embedded audio system into 3 | 52 | To achieve all this, ASoC basically splits an embedded audio system into 3 |
51 | components :- | 53 | components :- |
52 | 54 | ||
53 | * Codec driver: The codec driver is platform independent and contains audio | 55 | * Codec driver: The codec driver is platform independent and contains audio |
54 | controls, audio interface capabilities, codec dapm definition and codec IO | 56 | controls, audio interface capabilities, codec DAPM definition and codec IO |
55 | functions. | 57 | functions. |
56 | 58 | ||
57 | * Platform driver: The platform driver contains the audio dma engine and audio | 59 | * Platform driver: The platform driver contains the audio DMA engine and audio |
58 | interface drivers (e.g. I2S, AC97, PCM) for that platform. | 60 | interface drivers (e.g. I2S, AC97, PCM) for that platform. |
59 | 61 | ||
60 | * Machine driver: The machine driver handles any machine specific controls and | 62 | * Machine driver: The machine driver handles any machine specific controls and |
@@ -81,4 +83,4 @@ machine.txt: Machine driver internals. | |||
81 | 83 | ||
82 | pop_clicks.txt: How to minimise audio artifacts. | 84 | pop_clicks.txt: How to minimise audio artifacts. |
83 | 85 | ||
84 | clocking.txt: ASoC clocking for best power performance. \ No newline at end of file | 86 | clocking.txt: ASoC clocking for best power performance. |
diff --git a/Documentation/sound/alsa/soc/platform.txt b/Documentation/sound/alsa/soc/platform.txt index d4678b4dc6c6..b681d17fc388 100644 --- a/Documentation/sound/alsa/soc/platform.txt +++ b/Documentation/sound/alsa/soc/platform.txt | |||
@@ -8,7 +8,7 @@ specific code. | |||
8 | Audio DMA | 8 | Audio DMA |
9 | ========= | 9 | ========= |
10 | 10 | ||
11 | The platform DMA driver optionally supports the following alsa operations:- | 11 | The platform DMA driver optionally supports the following ALSA operations:- |
12 | 12 | ||
13 | /* SoC audio ops */ | 13 | /* SoC audio ops */ |
14 | struct snd_soc_ops { | 14 | struct snd_soc_ops { |
@@ -38,7 +38,7 @@ struct snd_soc_platform { | |||
38 | struct snd_pcm_ops *pcm_ops; | 38 | struct snd_pcm_ops *pcm_ops; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | Please refer to the alsa driver documentation for details of audio DMA. | 41 | Please refer to the ALSA driver documentation for details of audio DMA. |
42 | http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm | 42 | http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm |
43 | 43 | ||
44 | An example DMA driver is soc/pxa/pxa2xx-pcm.c | 44 | An example DMA driver is soc/pxa/pxa2xx-pcm.c |
@@ -52,7 +52,7 @@ Each SoC DAI driver must provide the following features:- | |||
52 | 1) Digital audio interface (DAI) description | 52 | 1) Digital audio interface (DAI) description |
53 | 2) Digital audio interface configuration | 53 | 2) Digital audio interface configuration |
54 | 3) PCM's description | 54 | 3) PCM's description |
55 | 4) Sysclk configuration | 55 | 4) SYSCLK configuration |
56 | 5) Suspend and resume (optional) | 56 | 5) Suspend and resume (optional) |
57 | 57 | ||
58 | Please see codec.txt for a description of items 1 - 4. | 58 | Please see codec.txt for a description of items 1 - 4. |
diff --git a/Documentation/sound/alsa/soc/pops_clicks.txt b/Documentation/sound/alsa/soc/pops_clicks.txt index 3371bd9d7cfa..e1e74daa4497 100644 --- a/Documentation/sound/alsa/soc/pops_clicks.txt +++ b/Documentation/sound/alsa/soc/pops_clicks.txt | |||
@@ -15,11 +15,11 @@ click every time a component power state is changed. | |||
15 | Minimising Playback Pops and Clicks | 15 | Minimising Playback Pops and Clicks |
16 | =================================== | 16 | =================================== |
17 | 17 | ||
18 | Playback pops in portable audio subsystems cannot be completely eliminated atm, | 18 | Playback pops in portable audio subsystems cannot be completely eliminated |
19 | however future audio codec hardware will have better pop and click suppression. | 19 | currently, however future audio codec hardware will have better pop and click |
20 | Pops can be reduced within playback by powering the audio components in a | 20 | suppression. Pops can be reduced within playback by powering the audio |
21 | specific order. This order is different for startup and shutdown and follows | 21 | components in a specific order. This order is different for startup and |
22 | some basic rules:- | 22 | shutdown and follows some basic rules:- |
23 | 23 | ||
24 | Startup Order :- DAC --> Mixers --> Output PGA --> Digital Unmute | 24 | Startup Order :- DAC --> Mixers --> Output PGA --> Digital Unmute |
25 | 25 | ||