mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-20 04:02:27 +00:00
Modify rc script to allow M-Audio devices to be set up as the default
sound device upon detection. PR: ports/164605 Submitted by: Aragon Gouveia <aragon@phat.za.net> (maintainer)
This commit is contained in:
parent
7cdfadbd71
commit
0b20c4909d
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=290132
@ -7,6 +7,7 @@
|
||||
|
||||
PORTNAME= madfufw
|
||||
PORTVERSION= 1.0
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= audio
|
||||
MASTER_SITES= SF/usb-midi-fw/madfu-firmware/1.2/
|
||||
DISTNAME= madfuload-1.2
|
||||
|
@ -1,13 +1,32 @@
|
||||
attach 100 {
|
||||
match "device-name" "ugen[0-9]+\.[0-9]+";
|
||||
notify 100 {
|
||||
match "system" "USB";
|
||||
match "subsystem" "DEVICE";
|
||||
match "type" "ATTACH";
|
||||
match "vendor" "0x0763";
|
||||
match "product" "0x280[34568]";
|
||||
action "%%PREFIX%%/etc/rc.d/maudio start $device-name $product";
|
||||
action "%%PREFIX%%/etc/rc.d/maudio start $cdev $product";
|
||||
};
|
||||
|
||||
attach 100 {
|
||||
match "device-name" "pcm[0-9]+";
|
||||
action "%%PREFIX%%/etc/rc.d/maudio attach $device-name $bus";
|
||||
};
|
||||
|
||||
attach 100 {
|
||||
match "device-name" "uaudio[0-9]+";
|
||||
match "vendor" "0x0763";
|
||||
match "product" "0x2006";
|
||||
action "/usr/local/etc/rc.d/maudio mixer $device-name";
|
||||
action "%%PREFIX%%/etc/rc.d/maudio attach $device-name";
|
||||
};
|
||||
|
||||
detach 100 {
|
||||
match "device-name" "pcm[0-9]+";
|
||||
action "%%PREFIX%%/etc/rc.d/maudio detach $device-name $bus";
|
||||
};
|
||||
|
||||
detach 100 {
|
||||
match "device-name" "uaudio[0-9]+";
|
||||
match "vendor" "0x0763";
|
||||
match "product" "0x2006";
|
||||
action "%%PREFIX%%/etc/rc.d/maudio detach $device-name";
|
||||
};
|
||||
|
@ -26,20 +26,25 @@ rcvar=maudio_enable
|
||||
load_rc_config $name
|
||||
|
||||
: ${maudio_enable="NO"}
|
||||
: ${maudio_default="NO"}
|
||||
|
||||
command="%%PREFIX%%/bin/dfu-util"
|
||||
start_cmd="maudio_start"
|
||||
firmware_dir="%%PREFIX%%/share/maudio"
|
||||
temp_dir="/tmp/.maudio"
|
||||
required_modules="uhub/uaudio"
|
||||
required_dirs=$firmware_dir
|
||||
required_files=$command
|
||||
extra_commands="mixer"
|
||||
mixer_cmd="maudio_mixer"
|
||||
extra_commands="attach detach"
|
||||
attach_cmd="maudio_attach"
|
||||
detach_cmd="maudio_detach"
|
||||
|
||||
maudio_start()
|
||||
{
|
||||
local firmware dev idVendor idProduct
|
||||
|
||||
mkdir -p ${temp_dir} && touch ${temp_dir}/state
|
||||
|
||||
if [ -n "${1}" -a -n "${2}" ]; then
|
||||
idProduct=${2}
|
||||
dev=${1}
|
||||
@ -81,18 +86,79 @@ maudio_start()
|
||||
/usr/sbin/usbconfig -d ${dev} reset
|
||||
}
|
||||
|
||||
maudio_mixer()
|
||||
maudio_init()
|
||||
{
|
||||
local dev
|
||||
|
||||
if [ -z "${1}" ]; then
|
||||
err 1 "No device specified"
|
||||
fi
|
||||
|
||||
dev="/dev/mixer$( echo ${1} |sed -E 's/^[a-z]+([0-9]+)$/\1/' )"
|
||||
local unit dev
|
||||
unit=${1#pcm*}
|
||||
test -n "${unit}" || return 1
|
||||
dev="/dev/mixer${unit}"
|
||||
if [ -r ${dev} ]; then
|
||||
mixer -f ${dev} vol 100 pcm 100
|
||||
if checkyesno maudio_default; then
|
||||
sysctl -w hw.snd.default_unit=${unit}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
maudio_attach()
|
||||
{
|
||||
local bus pcmdev pcmdevs
|
||||
|
||||
. ${temp_dir}/state
|
||||
|
||||
case "${1}" in
|
||||
pcm*)
|
||||
eval "bus=\$maudio_${2}"
|
||||
if [ "${bus}" = "1" ]; then
|
||||
maudio_init ${1}
|
||||
fi
|
||||
pcmdevs="${pcmdevs:+${pcmdevs} }${1}"
|
||||
echo "pcmdevs=\"${pcmdevs}\"" >${temp_dir}/state
|
||||
for pcmdev in ${pcmdevs}; do
|
||||
echo "pcmbus_${1}=${2}" >>${temp_dir}/state
|
||||
done
|
||||
grep "^maudio_" >>${temp_dir}/state
|
||||
;;
|
||||
uaudio*)
|
||||
for pcmdev in ${pcmdevs}; do
|
||||
eval "bus=\$pcmbus_${pcmdev}"
|
||||
if [ "${bus}" = "${1}" ]; then
|
||||
maudio_init ${pcmdev}
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo "maudio_${1}=1" >>${temp_dir}/state
|
||||
;;
|
||||
*)
|
||||
err 1 "Unknown device specified"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
maudio_detach()
|
||||
{
|
||||
local pcmdev pcmdevs pcmdevs_new
|
||||
|
||||
. ${temp_dir}/state
|
||||
|
||||
case "${1}" in
|
||||
pcm*)
|
||||
for pcmdev in ${pcmdevs}; do
|
||||
if [ "${pcmdev}" = "${1}" ]; then
|
||||
continue
|
||||
fi
|
||||
pcmdevs_new="${pcmdevs_new:+${pcmdevs_new} }${1}"
|
||||
done
|
||||
pcmdevs="${pcmdevs_new}"
|
||||
sed -i "" -e "/^pcmdevs=/ s/=.*$/=\"${pcmdevs}\"/" -e "/^pcmbus_${1}=/ d" ${temp_dir}/state
|
||||
;;
|
||||
uaudio*)
|
||||
sed -i "" "/^maudio_${1}=/ d" ${temp_dir}/state
|
||||
;;
|
||||
*)
|
||||
err 1 "Unknown device specified"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
run_rc_command $*
|
||||
|
@ -4,6 +4,11 @@ A devd(8) configuration has been installed at:
|
||||
You must add 'maudio_enable="YES"' to rc.conf
|
||||
and restart devd(8) for this port to work.
|
||||
|
||||
You can optionally add 'maudio_default="YES"'
|
||||
to rc.conf if you'd like M-Audio devices to
|
||||
be setup as the default sound device upon
|
||||
detection.
|
||||
|
||||
Some devices (eg. Transit) may also require
|
||||
sysctl modifications:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user