Put in remaining pages and wiki contents.
[ikiwiki.git] / docs / handbook / handbook-sound-setup.mdwn
1 \r
2 \r
3 ## 16.2 Setting Up the Sound Card \r
4 \r
5 ***Contributed by Moses Moore. ***\r
6 \r
7 ### 16.2.1 Locating the Correct Device \r
8 \r
9 Before you begin, you should know the model of the card you have, the chip it uses, and whether it is a PCI or ISA card. DragonFly supports a wide variety of both PCI and ISA cards. Check the [pcm(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#pcm&section4) manual page for a more complete list.\r
10 \r
11 To use your sound device, you will need to load the proper device driver. This may be accomplished in one of two ways. The easiest way is to simply load a kernel module for your sound card with [kldload(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#kldload&section8) which can either be done from the command line:\r
12 \r
13     \r
14     # kldload snd_emu10k1.ko\r
15 \r
16 \r
17 or by adding the appropriate line to the file `/boot/loader.conf` like this:\r
18 \r
19     \r
20     snd_emu10k1_load="YES"\r
21 \r
22 \r
23 These examples are for a Creative SoundBlaster Live! sound card. Other available loadable sound modules are listed in `/boot/defaults/loader.conf`.\r
24 \r
25 Alternatively, you may statically compile in support for your sound card in your kernel. The sections below provide the information you need to add support for your hardware in this manner. For more information about recompiling your kernel, please see [Kernel Configuration](kernelconfig.html).\r
26 \r
27 #### 16.2.1.1 Creative, Advance, and ESS Sound Cards \r
28 \r
29 If you have one of the above cards, you will need to add:\r
30 \r
31     \r
32     device pcm\r
33 \r
34 \r
35 to your kernel configuration file. If you have a PnP ISA card, you will also need to add:\r
36 \r
37     \r
38     device sbc\r
39 \r
40 \r
41 For a non-PnP ISA card, add:\r
42 \r
43     \r
44     device pcm\r
45     device sbc0 at isa? port 0x220 irq 5 drq 1 flags 0x15\r
46 \r
47 \r
48 to your kernel configuration file. The settings shown above are the defaults. You may need to change the IRQ or the other settings to match your card. See the [sbc(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#sbc&section4) manual page for more information.\r
49 \r
50 #### 16.2.1.2 Gravis UltraSound Cards \r
51 \r
52 For a PnP ISA card, you will need to add:\r
53 \r
54     \r
55     device pcm\r
56     device gusc\r
57 \r
58 \r
59 to your kernel configuration file. If you have a non-PnP ISA card, you will need to add:\r
60 \r
61     \r
62     device pcm\r
63     device gus0 at isa? port 0x220 irq 5 drq 1 flags 0x13\r
64 \r
65 \r
66 to your kernel configuration file. You may need to change the IRQ or the other settings to match your card. See the [gusc(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#gusc&section4) manual page for more information.\r
67 \r
68 #### 16.2.1.3 Crystal Sound Cards \r
69 \r
70 For Crystal cards, you will need to add:\r
71 \r
72     \r
73     device pcm\r
74     device csa\r
75 \r
76 \r
77 to your kernel configuration file.\r
78 \r
79 #### 16.2.1.4 Generic Support \r
80 \r
81 For PnP ISA or PCI cards, you will need to add:\r
82 \r
83     \r
84     device pcm\r
85 \r
86 \r
87 to your kernel configuration file. If you have a non-PnP ISA sound card that does not have a bridge driver, you will need to add:\r
88 \r
89     \r
90     device pcm0 at isa? irq 10 drq 1 flags 0x0\r
91 \r
92 \r
93 to your kernel configuration file. You may need to change the IRQ or the other settings to match your card.\r
94 \r
95 #### 16.2.1.5 Onboard Sound \r
96 \r
97 Some systems with built-in motherboard sound devices may require the following device in your kernel configuration:\r
98 \r
99     \r
100     device pnpbios\r
101 \r
102 \r
103 ### 16.2.2 Creating and Testing the Device Nodes \r
104 \r
105 After you reboot, log in and check for the device in the `/var/run/dmesg.boot` file, as shown below:\r
106 \r
107     \r
108     # grep pcm /var/run/dmesg.boot\r
109     pcm0: <SB16 DSP 4.11> on sbc0\r
110 \r
111 \r
112 The output from your system may look different. If no `pcm` devices show up, something went wrong earlier. If that happens, go through your kernel configuration file again and make sure you chose the correct device. Common problems are listed in [Sound Setup](sound-setup.html).\r
113 \r
114 If the previous command returned `pcm0`, you will have to run the following as `root`:\r
115 \r
116     \r
117     # cd /dev\r
118     # sh MAKEDEV snd0\r
119 \r
120 \r
121 If the command returned `pcm1`, follow the same steps as shown above, replacing `snd0` with `snd1`.\r
122 \r
123  **Note:** The above commands will ***not*** create a `/dev/snd` device!\r
124 \r
125 `MAKEDEV` will create a group of device nodes, including:\r
126 \r
127 [[!table  data="""
128 | Device | Description 
129  `/dev/audio` | SparcĀ® compatible audio device 
130  `/dev/dsp` | Digitized voice device 
131  `/dev/dspW` | Like `/dev/dsp`, but 16 bits per sample 
132  `/dev/midi` | Raw midi access device 
133  `/dev/mixer` | Control port mixer device 
134  `/dev/music` | Level 2 sequencer interface 
135  `/dev/sequencer` | Sequencer device 
136  `/dev/pss` | Programmable device interface |\r
137 """]]\r
138 If all goes well, you should now have a functioning sound card. If your CD-ROM or DVD-ROM drive is properly coupled to your sound card, you can put a CD in the drive and play it with [cdcontrol(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#cdcontrol&section1):\r
139 \r
140     \r
141     % cdcontrol -f /dev/acd0c play 1\r
142 \r
143 \r
144 Various applications, such as [audio/xmms](http://pkgsrc.se/audio/xmms) offer a better interface. You may want to install an application such as [audio/mpg123](http://pkgsrc.se/audio/mpg123) to listen to MP3 audio files.\r
145 \r
146 #### 16.2.2.1 Common Problems \r
147 \r
148 [[!table  data="""
149 | Error | Solution 
150  ***`unsupported subdevice XX`*** | One or more of the device nodes was not created correctly. Repeat the steps above. 
151  ***`sb_dspwr(XX) timed out`*** | The I/O port is not set correctly. 
152  ***`bad irq XX`*** | The IRQ is set incorrectly. Make sure that the set IRQ and the sound IRQ are the same. 
153  ***`xxx: gus pcm not attached, out of memory`*** | There is not enough available memory to use the device. 
154  ***`xxx: can't open /dev/dsp!`*** | Check with `fstat | grep dsp` if another application is holding the device open. Noteworthy troublemakers are  **esound**  and  **KDE** 's sound support. |\r
155 """]]\r
156 ### 16.2.3 Utilizing Multiple Sound Sources \r
157 \r
158  ***Contributed by Munish Chopra.***\r
159 \r
160 It is often desirable to have multiple sources of sound that are able to play simultaneously, such as when  **esound**  or  **artsd**  do not support sharing of the sound device with a certain application.\r
161 \r
162 DragonFly lets you do this through 'virtual' sound channels, which can be set with the [sysctl(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#sysctl&section8) facility. Virtual channels allow you to multiplex your sound card's playback channels by mixing sound in the kernel.\r
163 \r
164 To set the number of virtual channels, there are two sysctl knobs which, if you are the `root` user, can be set like this:\r
165 \r
166     \r
167     # sysctl hw.snd.pcm0.vchans=4\r
168     # sysctl hw.snd.maxautovchans=4\r
169 \r
170 \r
171 The above example allocates four virtual channels, which is a practical number for everyday use. `hw.snd.pcm0.vchans` is the number of virtual channels `pcm0` has, and is configurable once a device has been attached. `hw.snd.maxautovchans` is the number of virtual channels a new audio device is given when it is attached using [kldload(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#kldload&section8). Since the `pcm` module can be loaded independently of the hardware drivers, `hw.snd.maxautovchans` can store how many virtual channels any devices which are attached later will be given.\r
172 \r
173 As DragonFly doesn't support devfs you will have to point your applications at `/dev/dsp0`.`x`, where `x` is 0 to 3 if `hw.snd.pcm.0.vchans` is set to 4 as in the above example.\r
174 \r
175 \r
176 \r
177 CategoryHandbook\r
178 CategoryHandbook-multimedia\r