Add madufufw, Userland scripts to load the M-Audio firmware into supported

sound devices upon attachment.

PR:		148411
Submitted by:	Aragon Gouveia
Feature safe:	yes
This commit is contained in:
Tilman Keskinoz 2011-02-03 12:07:12 +00:00
parent 429b2b404d
commit 7e42ea2dd6
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=268576
7 changed files with 186 additions and 0 deletions

View File

@ -458,6 +458,7 @@
SUBDIR += lv2core
SUBDIR += mac
SUBDIR += mad
SUBDIR += madfufw
SUBDIR += madman
SUBDIR += madplay
SUBDIR += malint

50
audio/madfufw/Makefile Normal file
View File

@ -0,0 +1,50 @@
# New ports collection makefile for: madfufw
# Date created: July 6, 2010
# Whom: Aragon Gouveia <aragon@phat.za.net>
#
# $FreeBSD$
#
PORTNAME= madfufw
PORTVERSION= 1.0
CATEGORIES= audio
MASTER_SITES= SF/usb-midi-fw/madfu-firmware/1.2/
DISTNAME= madfuload-1.2
MAINTAINER= aragon@phat.za.net
COMMENT= M-Audio DFU Firmware for Transit, Ozone, Sonica, MobilePre
RUN_DEPENDS= ${LOCALBASE}/bin/dfu-util:${PORTSDIR}/comms/dfu-util
WRKSRC= ${WRKDIR}/madfuload-1.2
PLIST_FILES= share/maudio/ma003101.bin \
share/maudio/ma004103.bin \
share/maudio/ma005101.bin \
share/maudio/ma006100.bin \
share/maudio/ma008100.bin \
etc/devd/maudio-devd.conf
PLIST_DIRS= share/maudio
USE_RC_SUBR= maudio
SUB_FILES= maudio-devd.conf pkg-message
NO_BUILD= yes
NO_PACKAGE= redistribution of firmware files not permitted
.include <bsd.port.pre.mk>
.if ${OSVERSION} < 800064
BROKEN= port requires FreeBSD 8.x
.endif
do-install:
@${MKDIR} ${LOCALBASE}/share/maudio && \
${INSTALL_DATA} ${WRKSRC}/ma003101.bin ${WRKSRC}/ma004103.bin \
${WRKSRC}/ma005101.bin ${WRKSRC}/ma006100.bin \
${WRKSRC}/ma008100.bin ${LOCALBASE}/share/maudio
@${INSTALL_DATA} ${WRKDIR}/maudio-devd.conf ${LOCALBASE}/etc/devd
post-install:
@${ECHO_MSG} ""
@${CAT} ${PKGMESSAGE}
@${ECHO_MSG} ""
.include <bsd.port.post.mk>

2
audio/madfufw/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (madfuload-1.2.tar.gz) = 324d0a55f73c82ad48635a94a8d72277a2280030df6d036eafe3498c933dee6d
SIZE (madfuload-1.2.tar.gz) = 78506

View File

@ -0,0 +1,13 @@
attach 100 {
match "device-name" "ugen[0-9]+\.[0-9]+";
match "vendor" "0x0763";
match "product" "0x280[34568]";
action "%%PREFIX%%/etc/rc.d/maudio start $device-name $product";
};
attach 100 {
match "device-name" "uaudio[0-9]+";
match "vendor" "0x0763";
match "product" "0x2006";
action "/usr/local/etc/rc.d/maudio mixer $device-name";
};

View File

@ -0,0 +1,98 @@
#!/bin/sh
#
# PROVIDE: maudio
# REQUIRE: LOGIN
# KEYWORD: nojail
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# maudio_enable (bool): Set to NO by default.
# Set it to YES to enable maudio.
# Usage:
# maudio start [<device> <product id>] # load firmware to device with specified product ID
# disable at boot time and prevent simultaneous runs
if [ -n "${_boot}" -o -f /var/run/maudio.pid ]; then
exit 0
fi
trap "rm -f /var/run/maudio.pid" 1 2 10 13 14 15 EXIT
echo $$ >/var/run/maudio.pid
. /etc/rc.subr
name="maudio"
rcvar=`set_rcvar`
load_rc_config $name
: ${maudio_enable="NO"}
command="%%PREFIX%%/bin/dfu-util"
start_cmd="maudio_start"
firmware_dir="%%PREFIX%%/share/maudio"
required_modules="uhub/uaudio"
required_dirs=$firmware_dir
required_files=$command
extra_commands="mixer"
mixer_cmd="maudio_mixer"
maudio_start()
{
local firmware dev idVendor idProduct
if [ -n "${1}" -a -n "${2}" ]; then
idProduct=${2}
dev=${1}
else
for dev in /dev/ugen*; do
dev=${dev#/dev/*}
eval $( /usr/sbin/usbconfig -d ${dev} dump_device_desc \
|grep -E "idVendor = 0x0763|idProduct = 0x280[34568]" |tr -d " " )
if [ -n "${idVendor}" -a -n "${idProduct}" ]; then
break;
fi
idVendor=""
idProduct=""
done
fi
case "${idProduct}" in
0x2803)
firmware=${firmware_dir}/ma003101.bin
;;
0x2804)
firmware=${firmware_dir}/ma004103.bin
;;
0x2805)
firmware=${firmware_dir}/ma005101.bin
;;
0x2806)
firmware=${firmware_dir}/ma006100.bin
;;
0x2808)
firmware=${firmware_dir}/ma008100.bin
;;
*)
err 1 "Unknown product ID"
;;
esac
${command} -R -t 64 -d 0x0763:${idProduct} -D ${firmware} 2>/dev/null 1>&2
/usr/sbin/usbconfig -d ${dev} reset
}
maudio_mixer()
{
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/' )"
if [ -r ${dev} ]; then
mixer -f ${dev} vol 100 pcm 100
fi
}
run_rc_command $*

View File

@ -0,0 +1,11 @@
A devd(8) configuration has been installed at:
%%PREFIX%%/etc/devd/maudio-devd.conf.
You must add 'maudio_enable="YES"' to rc.conf
and restart devd(8) for this port to work.
Some devices (eg. Transit) may also require
sysctl modifications:
hw.usb.uaudio.default_bits=16
hw.usb.uaudio.default_rate=48000

11
audio/madfufw/pkg-descr Normal file
View File

@ -0,0 +1,11 @@
Userland scaffolding to load M-Audio firmware into supported
sound devices upon attachment. Supported devices:
* Sonica
* Ozone
* MobilePre USB (some newer models don't need this port)
* Transit
Based upon the madfuload package.
WWW: http://usb-midi-fw.sourceforge.net/