Configuring Sound on Linux/HW Address< Configuring Sound on Linux
This document will teach you how to find an address and confirm it is working.
Find the hardware addressEdit
The stock ALSA utility aplay can tell you the hardware addresses of the devices it is ready to use. Simply supply to aplay the --list-devices argument.
$ aplay --list-devices **** List of PLAYBACK Hardware Devices **** card 0: HDMI [HDA ATI HDMI], device 3: ATI HDMI [ATI HDMI] Subdevices: 1/1 Subdevice #0: subdevice #0
Note, for this card the notation for the physical address would be hw:0,3. While the device name, is HDMI
Here we will use proc to query our kernel for information.
By viewing the virtual file /proc/asound/cards your kernel will show you the device names for the cards it is has ready for use. If your card isn't listed here then your kernel does not support it. The device names can be found in the brackets.
$ cat /proc/asound/cards
An example of the output for device HDMI might be:
0 [HDMI ]: HDA-Intel - HDA ATI HDMI HDA ATI HDMI at 0xfbee8000 irq 19
The kernel should have created a virtual directory for each card in /proc/asound. The directories associated with the card will be prefixed by 'card' and suffixed by the number of the card, ex., card0, card1, etc.; i.e., '0' in our example.
Inside of these directories you will find a simple list of files.
$ tree /proc/asound/card0/ /proc/asound/card0/ |-- codec#0 |-- id |-- oss_mixer `-- pcm3p |-- info `-- sub0 |-- hw_params |-- info |-- prealloc |-- prealloc_max |-- status `-- sw_params 2 directories, 10 files
The most important file is the pcm3p/info, by examining this file we can finish our search for the hardware coordinates of the sound devices.
$ cat /proc/asound/card0/pcm3p/info card: 0 device: 3 subdevice: 0 stream: PLAYBACK id: ATI HDMI name: ATI HDMI subname: subdevice #0 class: 0 subclass: 0 subdevices_count: 1 subdevices_avail: 1
Writing the hardware addressEdit
Now you know the basics about your card! Specifically, you'll need the card number, and the device number. These two are often seen in ALSA hardware notation as hw:CARD,DEVICE, which is totally dependent on the order the kernel detects them.
Test the addressEdit
Firstly, make sure your device in question is un-muted! You can test the functionality of you default card at any time by using the following command:
cat /dev/urandom | aplay
This will bombard your card with random and totally irrelevant data. Your card will present this data to you in the form of sound à la modem noise. To stop that noise ^D (hold Control and press D). Alternatively, you can use the dd command to flash-test.
dd if=/dev/urandom count=5 | aplay
Presumably, if you're reading this tutorial your sound isn't working. You might want to explicitly test a sound device, or you might be having problems with the default and want to try out another device. Whatever have you, the -D argument to aplay does just that.
cat /dev/urandom | aplay -D hw:0,3 ## Where 0,3 is your hardware's coordinates
If you hear sound, enjoy—your card works and is fully compatible with your operating system.