The sound story

OpenBSD rocks! Secure by default .. thats what i liked about it. Installation was a breeze. Got all hardware and X running. But audio did not seem to work! I have a Intel 865 mother board and dmesg showed that the on board audio device was detected.

"Intel 82801EB/ER SMBus" rev 0x02 at pci0 dev 31 function 3 not configured
auich0 at pci0 dev 31 function 5 "Intel 82801EB/ER AC97" rev 0x02: apic 2 int 17 (irq 3), ICH5 AC97
ac97: codec id 0x41445375 (Analog Devices AD1985)
ac97: codec features headphone, 20 bit DAC, No 3D Stereo
audio0 at auich0

mpg123, xmms all players seemed to play songs but there was no sound. I tried unmuting the ouput master and a few other with mixerctl but yet there was no audio.

Googling too did not gimme any solution until i found this link Patch for broken ICH5 audio on 865PERL board.

To cut the long story short, the register reads in /usr/src/sys/dev/ic/ac97.c needs to be reorderd. Its just about replacing 1 line. For this, u will need the kernel source which can be found on the CDROM or openbsd ftp sites as src.tar.gz and sys.tar.gz.

Assuming that u are root and your kernel sources are in /usr/src, depending on your platform (i386,alpha,macppc etc), do the following

vinay$ cd /usr/src/sys/arch/i386/conf
vinay$ config GENERIC

If u check from line 745 of ac97.c u will see something like

vinay$ less +745 /usr/src/sys/dev/ic/ac97.c

        ac97_setup_defaults(as);
        ac97_read(as, AC97_REG_VENDOR_ID1, &id1);
        ac97_read(as, AC97_REG_VENDOR_ID2, &id2);
        ac97_read(as, AC97_REG_RESET, &as->caps);   //<------ this line

The last line AC97_REG_RESET needs to be the first of the ac97_read(s). So, change the above to

        ac97_setup_defaults(as);
        ac97_read(as, AC97_REG_RESET, &as->caps);
        ac97_read(as, AC97_REG_VENDOR_ID1, &id1);
        ac97_read(as, AC97_REG_VENDOR_ID2, &id2);

Now recompile the kernel

vinay$ cd /usr/src/sys/arch/i386/compile/GENERIC && make clean && make depend && make
#Backup old kernel and install new kernel
vinay$ cp /bsd /bsd.old; cp /usr/src/sys/arch/i386/compile/GENERIC/bsd /bsd

Reboot, and u will have to do

vinay$ mixerctl -w outputs.surround.mute=off 

Thats it! Audio works.