⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lsg10.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 3 页
字号:


<BR>







<BR>







<LI>/dev/audio2 is the second audio device (Sun compatible)







<BR>







<BR>







<LI>/dev/dsp is the first digital sampling device







<BR>







<BR>







<LI>/dev/dsp2 is the second digital sampling device







<BR>







<BR>







<LI>/dev/midi is the MIDI device driver







<BR>







<BR>







<LI>/dev/mixer is the sound mixer device







<BR>







<BR>







<LI>/dev/pcaudio is the audio device driver for the PC speaker







<BR>







<BR>







<LI>/dev/pcsp is the PC speaker's digital sampling device







<BR>







<BR>







<LI>/dev/pcmixer is the PC speaker's mixer device







<BR>







<BR>







<LI>/dev/sequencer is the sequencer device for MIDI, FM, and GUS files







<BR>







<BR>







<LI>/dev/sndstat is a file that displays the sound card device driver's status







<BR>







<BR>







</UL>







<P>The PC speaker devices (/dev/pcaudio, /dev/pcsp, and /dev/pcmixer) are only used when the PC speaker device driver is loaded into the kernel.







<BR>







<BR>







<A NAME="E69E88"></A>







<H4 ALIGN=CENTER>







<CENTER>







<FONT SIZE=4 COLOR="#FF0000"><B> Linking the Sound Card Files</B></FONT></CENTER></H4>







<BR>







<P>Before you link in the sound card drivers, you must isolate the proper files that the compiler uses to form the device driver that is linked into the kernel. These files are usually supplied as part of the distribution software, or you can obtain them from the FTP or BBS sites. You may be able to skip the compilation step if you can find a precompiled device driver.







<BR>







<P>Each sound card has several source code files, usually with the .c extension, that take care of various aspects of the sound card support. These files include the device's initialization file and the drivers for the mixer, sequencer, MIDI interface, and so on. As a bare minimum, you need the file that initializes the card. This file is usually named after the sound card itself, such as sb_card.c for the Sound Blaster card or gus_card.c for the Gravis UltraSound card. In addition to the .c files, there are essential matching .h files for each component. You also need the files soundcard.c, soundcard.h, and audio.c (only for later versions of Linux), which are the driver skeletons to which the specific sound card details are linked.







<BR>







<P>An important component of the sound card device driver is the soundinstall script that constructs the drivers. This script may be supplied as a specific file, or it may be attached to the end of a documentation file. Slackware releases, for example, include a file called Readme.Linux in the sound directory that has the script appended to the end of the file. This script must be cut out and run by itself. The soundinstall script checks for the existence of a current device file, removes it if it exists, and then uses mknod to create a new device file. Of course, you also can perform these steps manually.







<BR>







<P>To compile the sound card drivers, follow a sequence of steps that places the required files in particular locations (as defined in the compilation script or Makefile), and then invoke the compilation process. The procedure is as follows:







<BR>







<UL>







<LI>Copy the file soundcard.h to /usr/include/linux from whatever directory it currently resides in.







<BR>







<BR>







<LI>Copy the sound card .h files (such as sb.h) to /usr/include/sys.







<BR>







<BR>







<LI>Create a symbolic link between the /usr/include/linux and /usr/include/sys versions of soundcard.h by using the command







<BR>ln -s /usr/include/linux/soundcard.h /usr/include/sys/soundcard.h







<BR>







<LI>Compile the device drivers using the Makefile for sound card devices. You can skip this step if you have the device driver already compiled, as with some distributions of Linux.







<BR>







<BR>







<LI>Run the soundinstall script to create the sound card devices, or create them manually.







<BR>







<BR>







</UL>







<P>The soundinstall script uses the mknod command to create the device drivers in the /dev directory. If you want to perform the steps manually, these basic mknod commands are required:







<BR>







<PRE>







<FONT COLOR="#000080">mknod -m 666 /dev/mixer c 14 0







mknod -m 666 /dev/sequencer c 14 1







mknod -m 666 /dev/patmgr0 c 14 17







mknod -m 666 /dev/midi00 c 14 2







mknod -m 666 /dev/dsp c 14 3







mknod -m 666 /dev/audio c 14 4







mknod -m 666 /dev/sndstat c 14 6</FONT></PRE>







<P>Some of these commands aren't needed if your sound card doesn't support the functions (such as a MIDI interface or sequencer). The preceding steps are for the first sound card. If you are installing two sound cards, you have to repeat the commands with the second device names. The soundinstall script handles this step automatically.







<BR>







<BR>







<A NAME="E69E89"></A>







<H4 ALIGN=CENTER>







<CENTER>







<FONT SIZE=4 COLOR="#FF0000"><B>Providing Configuration Information</B></FONT></CENTER></H4>







<BR>







<P>When the installation process is running, either from an installation script like setup or install or from a compilation of the sound card drivers, you are asked for a number of configuration parameters. These parameters are used to generate a file called local.h that defines the sound card configuration information. You are prompted for the type of sound card, IRQ, DMA, and I/O address, as well as other information pertaining to each type of driver.







<BR>







<P>If you don't get asked for this kind of information, you must edit the local.h file (if it exists) manually. A file called sound_config.h contains generic configuration information. You can edit this file to complete any configuration parameters that are not prompted for by the configuration routine. Most of the sections of the sound_config.h file are clearly labeled as to their purpose.







<BR>







<P>The installation procedure should end with the Linux kernel rebuilding, relinking, and then setting the new kernel as the boot image so that the drivers are active when you start Linux. Without this step, none of the changes you made will be effective.







<BR>







<BR>







<A NAME="E69E90"></A>







<H4 ALIGN=CENTER>







<CENTER>







<FONT SIZE=4 COLOR="#FF0000"><B>Testing the Sound Card Drivers</B></FONT></CENTER></H4>







<BR>







<P>After the kernel has been rebuilt with the sound card drivers embedded, reboot the machine to test the sound card. Watch the startup messages carefully to see the initialization messages. If you miss the messages, you can recall them with the command







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">dmesg</FONT></PRE>







<P>which shows all the kernel's startup messages on-screen again.







<BR>







<P>If the sound card drivers were properly installed in the kernel, Linux tries to contact the sound card and initialize it. In the startup messages, you see a line similar to







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">snd1 &lt;SoundBlaster Pro&gt; at 0x220 irq 5 drq 1</FONT></PRE>







<P>which, in this case, shows that the driver for a Sound Blaster Pro card (or compatible) was loaded with the I/O address set to 220H, an IRQ of 5, and a DMA of 1. If the sound card had values for any of these parameters that were different from the ones shown, the card initialization would probably fail.







<BR>







<P>If you are booting Linux for the first time after installing new drivers, some diagnostic, warning, or extra error messages may be displayed. These messages may not be repeated every time you reboot, just the first time. For this reason, you should use the dmesg command to check for these messages after relinking and rebooting the kernel with the sound card driver.







<BR>







<P>Assuming the drivers are linked properly, the device drivers initialize the card and the Linux registers that use it. All you need to do now is test the sound card with an application that tries to access the card. Any sound file will do. A few samples are usually included with the sound card drivers, or you can obtain sound files from FTP or BBS sites or possibly the Linux distribution disks.







<BR>







<P>To test the sound card, use the cat command to send the test file to the sound device. For example, if you have a sound file called parrot_sketch.au (many sound files have .au as their extension, although this is far from a convention) and your sound card is called /dev/audio, you can send the file to the sound card with the command







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">cat parrot_sketch.au &gt; /dev/audio</FONT></PRE>







<P>If you don't hear anything from the sound card (and you have headphones or speakers connected with the volume set properly), the drivers are not communicating with the card properly. (Or your sound file is not properly formatted, in which case a prudent test is to use another sound file to confirm that the problem is the configuration.) Try the steps outlined in the Troubleshooting section later in this chapter. If you hear your sound file played properly, all is well and you have completed your sound card's installation.







<BR>







<P>If your sound card is capable of recording, and you have linked in a driver that supports recording from the sound card's microphone (or other input), you can test the recording capability of the sound card by recording a few seconds of audio and storing it in a file. The easiest way to do this procedure is to use the command







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">dd bs=8k count=10 &lt; /dev/audio &gt; test_mic.au</FONT></PRE>







<P>This command records 10 seconds from the input of /dev/audio and stores it in the file test_mic.au. You can then play this sound file back to check the fidelity of the recording with the command







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">cat test_mic.au &gt; /dev/audio</FONT></PRE>







<P>If you heard whatever sounds you recorded, the input sampling of the sound card is working properly. If you heard silence or got an error message, either the sound card driver doesn't support recording or the settings are incorrect.







<BR>







<BR>







<A NAME="E68E56"></A>







<H3 ALIGN=CENTER>







<CENTER>







<FONT SIZE=5 COLOR="#FF0000"><B>Using the PC Speaker</B></FONT></CENTER></H3>







<BR>







<P>Don't have a sound card in your system, or you do have one but it is not supported and you don't want to hassle with drivers? Use the PC speaker instead. The quality of sound from a PC internal speaker is a lot more limited than a sound card, but it isbetter than no sound at all.







<BR>







<P>The Linux drivers for the PC speaker are usually located in an archive file with the name pcsndrv followed by the version number, such as pcsndrv-0.6.tar.z. You can search your filesystem or distribution media for a file with this name using the command







<BR>







<BR>







<PRE>







<FONT COLOR="#000080">find / -name pcsndrv* -print</FONT></PRE>







<P>Many Linux software distributions do not include the PC speaker sound drivers, but they are available from almost all FTP and BBS sites. For example, the latest PC speaker sound drivers are located in the directory /pub/Linux/kernel/misc-patches at the sunsite.unc.edu FTP site. Check for the most recent release of the drivers.







<BR>







<P>Installing the PC speaker sound driver is a matter of linking the device driver into the kernel, and then rebuilding the kernel. The documentation that accompanies the device driver explains the process in detail.



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -