#!/bin/sh # PROVIDE: aureal # BEFORE: hald # KEYWORD: nojail # # Add the following line to /etc/rc.conf[.local] to enable aureal # # aureal_enable="YES" # # By default the script automatically detects the right kernel module # to load, if this fails, you can set "aureal_card" to the right value. # Possible values are 8810, 8820, and 8830. # # If your AMD Athlon system is based on a VIA Apollo KX133 motherboard # chipset, your system will most certainly lock up shortly after # you start a playback. To work around this issue please add this following # line to /etc/rc.conf[.local]: # # aureal_viakx133fix="YES" # . /etc/rc.subr name="aureal" rcvar=${name}_enable start_cmd="aureal_start" stop_cmd="aureal_stop" load_rc_config $name : ${aureal_enable="NO"} : ${aureal_card=""} : ${aureal_viakx133fix="NO"} aureal_detect() { PCICONF="/usr/sbin/pciconf" if [ -z "${aureal_card}" -a -x ${PCICONF} ]; then if [ "`${PCICONF} -l 2>&- | grep 0x000312eb`" ]; then aureal_card=8810 elif [ "`${PCICONF} -l 2>&- | grep 0x000112eb`" ]; then aureal_card=8820 elif [ "`${PCICONF} -l 2>&- | grep 0x000212eb`" ]; then aureal_card=8830 fi fi if [ -z "${aureal_card}" ]; then err 1 "Unable to determine your Aureal car type - override it by aureal_card rc variable" fi PREFIX=%%PREFIX%% KMODDIR=%%KMODDIR%% DRIVERFILE=snd_au${aureal_card} } aureal_start() { aureal_detect if [ ! -f ${KMODDIR}/${DRIVERFILE}.ko ]; then err 64 "${KMODDIR}/${DRIVERFILE} for ${aureal_card} not found!" fi if ! kldstat -qm ${DRIVERFILE}; then if ! kldload ${KMODDIR}/${DRIVERFILE}.ko; then warn 'aureal module failed to load' return 1 fi fi if checkyesno aureal_viakx133fix; then pcisel=`${PCICONF} -l 2>&- | grep ^pcm0 | awk -F: '{ gsub("^[^@]*@", ""); print $1":"$2":"$3 }'` if [ -z "$pcisel" ]; then warn "Soundcard PCI selector undetermined. Unable to install VIA KX133 workaround. Starting a playback will likely to lock-up your system!" return 0 fi oldvalue=`${PCICONF} -r -b $pcisel 0x40 2>&- | sed 's/ *$//'` ${PCICONF} -w -b $pcisel 0x40 0xff newvalue=`${PCICONF} -r -b $pcisel 0x40 2>&- | sed 's/ *$//'` info "with VIA KX133 workaround: ${pcisel},0x40: ${oldvalue} -> ${newvalue}" fi return 0 } aureal_stop() { aureal_detect kldstat -qm ${DRIVERFILE} && kldunload ${DRIVERFILE} return 0 } run_rc_command "$1"