Sunday, March 25, 2012

Tip: Improve NVIDIA driver performance on FreeBSD

When my desktop northbridge fan died I stopped both playing Enemy Territory and using FreeBSD to do so. I've recently replaced the northbridge cooling and went back to install FreeBSD, NVIDIA drivers for the graphics card and Enemy Territory.

I use the same demo file to benchmark Enemy Territory since 2003 and imagine my surprise as I score 33 FPS when I usually achieved ~100 FPS on the same exact setup under FreeBSD.

With X11 running I dropped to the ttyv0 and saw a suspicious message "NVRM: detected agp.ko, aborting NVIDIA AGP setup".

I suspected that FreeBSD AGP module agp.ko wasn't playing nice with NVIDIA's AGP module.

So I went back to my post on configuring NVIDIA driver on FreeBSD and read NVIDIA README /usr/local/share/doc/NVIDIA_GLX-1.0/README that is installed with the port.

Adding hint.agp.0.disabled="1" to /boot/device.hints and Option "NvAGP" "1" under the Device section of /etc/X11/xorg.conf fixed the problem.

Upon rebooting and running the benchmark again I scored 98,3 FPS which is close to 3x the score without NVIDIA's AGP module!

The solution was in both my old post and NVIDIA's README file all along ;)

Sunday, March 18, 2012

HowTo: Enabling Broadcom BCM4318 wireless on Linux Mint

After a HDD failure my wife asked for a Linux distribution (!) for her old HP dv5000 laptop. I picked Linux Mint due to its multimedia friendliness and restricted firmware support.

Funny enough it didn't attach a driver to the wireless chipset nor offered one through the restricted firmware pop-up.

lspci allowed me to identify the chipset, a Broadcom BCM4318 wireless device:

$ sudo lspci
00:00.0 Host bridge: ATI Technologies Inc RS480 Host Bridge (rev 01)
00:01.0 PCI bridge: ATI Technologies Inc RS480 PCI Bridge
00:05.0 PCI bridge: ATI Technologies Inc RS480 PCI Bridge
00:13.0 USB Controller: ATI Technologies Inc IXP SB400 USB Host Controller
00:13.1 USB Controller: ATI Technologies Inc IXP SB400 USB Host Controller
00:13.2 USB Controller: ATI Technologies Inc IXP SB400 USB2 Host Controller
00:14.0 SMBus: ATI Technologies Inc IXP SB400 SMBus Controller (rev 11)
00:14.1 IDE interface: ATI Technologies Inc IXP SB400 IDE Controller
00:14.3 ISA bridge: ATI Technologies Inc IXP SB400 PCI-ISA Bridge
00:14.4 PCI bridge: ATI Technologies Inc IXP SB400 PCI-PCI Bridge
00:14.5 Multimedia audio controller: ATI Technologies Inc IXP SB400 AC'97 Audio Controller (rev 02)
00:14.6 Modem: ATI Technologies Inc SB400 AC'97 Modem Controller (rev 02)
00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:05.0 VGA compatible controller: ATI Technologies Inc Radeon XPRESS 200M 5955 (PCIE)
06:02.0 Network controller: Broadcom Corporation BCM4318 [AirForce 54g] 802.11a/b/g PCI Express Transceiver (rev 02)
06:04.0 CardBus bridge: Texas Instruments PCIxx21/x515 Cardbus Controller
06:04.2 FireWire (IEEE 1394): Texas Instruments OHCI Compliant IEEE 1394 Host Controller
06:04.3 Mass storage controller: Texas Instruments PCIxx21 Integrated FlashMedia Controller
06:04.4 SD Host controller: Texas Instruments PCI6411/6421/6611/6621/7411/7421/7611/7621 Secure Digital Controller
06:06.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)

To fix the problem run the following commands:
$ sudo apt-get install b43-fwcutter
$ wget http://mirror2.openwrt.org/sources/broadcom-wl-4.150.10.5.tar.bz2
$ tar xf broadcom-wl-4.150.10.5.tar.bz2
$ cd broadcom-wl-4.150.10.5/driver/
$ sudo b43-fwcutter -w /lib/firmware/ wl_apsta_mimo.o
$ sudo modprobe b43
$ sudo echo "b43" >> /etc/modules

With this we've installed the proper driver and added it at boot time.

Bottom line: there's so much a pretty GUI can do ;)

Tip: Fix Enemy Territory empty server list

Ever since my desktop's northbridge fan died I stopped playing Enemy Territory. Luckily I've finally replaced the fan so fired ET up and noticed that no server was listed.

It seems that as of late the Enemy Territory's masterlist is down. As a workaround edit the hosts file and add a new masterlist provided by etmaster.net.

In FreeBSD and Linux distributions, run the following command:
# echo "91.220.53.73 etmaster.idsoftware.com" >> /etc/hosts

Fire up ET as a new list of servers will be available.

Major thanks Paul at the Splash Damage forums for providing a solution ;)

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.