freebsd-ports/audio/aureal-kmod/files/aureal.in
Doug Barton 83eb2c3700 In the rc.d scripts, change assignments to rcvar to use the
literal name_enable wherever possible, and ${name}_enable
when it's not, to prepare for the demise of set_rcvar().

In cases where I had to hand-edit unusual instances also
modify formatting slightly to be more uniform (and in
some cases, correct). This includes adding some $FreeBSD$
tags, and most importantly moving rcvar= to right after
name= so it's clear that one is derived from the other.
2012-01-14 08:57:23 +00:00

95 lines
2.3 KiB
Bash

#!/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=aureal_enable
start_cmd="aureal_start"
stop_cmd="aureal_stop"
load_rc_config $name
: ${aureal_enable="NO"}
: ${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 pci/snd_au88x0; 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 pci/snd_au88x0 && kldunload ${DRIVERFILE}
return 0
}
run_rc_command "$1"