Sunday, March 18, 2012

HowTo: nForce2 sound on FreeBSD

I finally got around to replace the northbridge fan of my ABIT AN-7 powered desktop and with it boot its old FreeBSD 7.4-STABLE install. Though I have a Creative SoundBlaster Audigy 4 I wanted to make sure I could go by with just the motherboard's nForce2 integrated sound system, so bellow I'll explain how to enable the nForce2 sound on FreeBSD.

Let's check if FreeBSD recognized and assigned a sound driver to the device:
$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2007061600/i386)
Installed devices:

# dmesg | grep -i audio
pci0: at device 5.0 (no driver attached)
pci0: at device 6.0 (no driver attached)

# cd /usr/ports/sysutils/pciutils ; make install clean ; rehash

# lspci | grep -i audio
00:05.0 Multimedia audio controller: nVidia Corporation nForce Audio Processing Unit (rev a2)
00:06.0 Multimedia audio controller: nVidia Corporation nForce2 AC97 Audio Controler (MCP) (rev a1)

Ok. So no sound driver is attached to the device. To use the sound device load the proper driver which in this case is snd_ich according to FreeBSD 7 Relase Notes

Let's attach the driver to the device:

# kldload snd_ich

To be sure that the sound driver was correctly loaded run:

$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2007061600/i386)
Installed devices:
pcm0: at io 0xb400, 0xb800 irq 22 bufsz 16384 kld snd_ich [MPSAFE] (1p:1v/1r:1v channels duplex default)

To attach the appropriate driver at boot, we need to add it to loader.conf(5) like so:
# echo 'snd_ich_load="YES"' >> /boot/loader.conf

To setup sound output levels for various audio sources and frequency ranges you can use the FreeBSD mixer. To display the current mixer values do the following:

$ mixer
Mixer vol      is currently set to  75:75
Mixer pcm      is currently set to  75:75
Mixer speaker  is currently set to  75:75
Mixer line     is currently set to  75:75
Mixer mic      is currently set to   0:0
Mixer cd       is currently set to  75:75
Mixer rec      is currently set to   0:0
Mixer igain    is currently set to   0:0
Mixer ogain    is currently set to  50:50
Mixer line1    is currently set to  75:75
Mixer phin     is currently set to   0:0
Recording source: mic

To change mixer values you can type mixer followed by the name of the device and the desired level. If you wanted to change the CD output volume to 95 percent on left channel and 85 on the right channel:

$ mixer cd 95:85

And that's it. As a side note, though I mention FreeBSD 7.4-STABLE these instructions apply to recent versions of FreeBSD, namely FreeBSD 9.0-RELEASE.

For additional information consult sound(4) and snd_ich(4) man pages.

No comments: