summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Millan <rmh@debian.org>2015-10-04 11:29:14 +0200
committerDamien Zammit <damien@zamaudio.com>2023-06-23 23:33:51 +1000
commita9796f05753d1c7efdce716a65ed75575b84118b (patch)
tree4486d0a199f0f10368295aec05a239a223a0a8bd
parentab273eb4b19e7d4aa4c0ea581b608697b8520417 (diff)
* Add debconf menu to automatically blacklist conflicting Linux audio drivers. * Automatically attempt to enable Linux UIO access to audio devices.
-rw-r--r--debian/changelog3
-rw-r--r--debian/control4
-rw-r--r--debian/librumpdev-audio0.config.linux20
-rwxr-xr-xdebian/librumpdev-audio0.init.linux81
-rw-r--r--debian/librumpdev-audio0.postinst.linux31
-rw-r--r--debian/librumpdev-audio0.postrm.linux20
-rw-r--r--debian/librumpdev-audio0.templates.linux11
7 files changed, 169 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index 2c723ba1..f326dd24 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,9 @@ rumpkernel (0~20150715-2) UNRELEASED; urgency=medium
nr_hugepages.
* Add bug-script to librumpdev-pci0 to include lspci output in bug
reports.
+ * Add debconf menu to automatically blacklist conflicting Linux audio
+ drivers.
+ * Automatically attempt to enable Linux UIO access to audio devices.
-- Robert Millan <rmh@debian.org> Mon, 07 Sep 2015 23:28:35 +0200
diff --git a/debian/control b/debian/control
index f5721ac8..5f15e5af 100644
--- a/debian/control
+++ b/debian/control
@@ -189,7 +189,9 @@ Description: Rump audio device libraries (development files)
Package: librumpdev-audio0
Section: libs
Architecture: linux-any hurd-any
-Depends: ${shlibs:Depends}, ${misc:Depends}, librumpdev-pci0 (= ${binary:Version})
+Depends: ${shlibs:Depends}, ${misc:Depends}, librumpdev-pci0 (= ${binary:Version}),
+# Used by config script
+ pciutils [linux-any],
Description: Rump audio device libraries (runtime)
Rump kernels provide free, portable, componentized, kernel quality drivers
such as file systems, POSIX system call handlers, PCI device drivers, a
diff --git a/debian/librumpdev-audio0.config.linux b/debian/librumpdev-audio0.config.linux
new file mode 100644
index 00000000..c95ebde2
--- /dev/null
+++ b/debian/librumpdev-audio0.config.linux
@@ -0,0 +1,20 @@
+#!/bin/bash
+set -e
+
+. /usr/share/debconf/confmodule
+
+audio_devices=$(lspci -n | awk '{ if ($2 == "0401:" || $2 == "0403:") print $1 }')
+
+first=true
+choices=
+for dev in ${audio_devices} ; do
+ if ! $first ; then
+ choices+=", "
+ fi
+ choices+="$(basename $(readlink /sys/bus/pci/devices/0000:${dev}/driver))"
+ first=false
+done
+
+db_subst librumpdev-audio/linux-modules CHOICES "$choices"
+db_input high librumpdev-audio/linux-modules || true
+db_go
diff --git a/debian/librumpdev-audio0.init.linux b/debian/librumpdev-audio0.init.linux
new file mode 100755
index 00000000..832d8d66
--- /dev/null
+++ b/debian/librumpdev-audio0.init.linux
@@ -0,0 +1,81 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: uio-audio
+# Required-Start:
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: UIO access to audio devices
+# Description: See:
+# https://github.com/rumpkernel/wiki/wiki/Howto%3A-Accessing-PCI-devices-from-userspace
+### END INIT INFO
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/bin
+NAME=uio-audio
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ modprobe uio_pci_generic || return 2
+ lspci_n=$(lspci -n)
+ for busid in $(echo "${lspci_n}" | awk '{ if ($2 == "0401:" || $2 == "0403:") print $1 }') ; do
+ echo "${lspci_n}" | grep "^${busid}\s" | awk '{ print $3 }' | tr ':' ' ' \
+ > /sys/bus/pci/drivers/uio_pci_generic/new_id || return 2
+ done
+ return 0
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ rmmod uio_pci_generic || return 2
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Enabling UIO access to audio devices" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Disabling UIO access to audio devices" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ ;;
+ restart|force-reload)
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/debian/librumpdev-audio0.postinst.linux b/debian/librumpdev-audio0.postinst.linux
new file mode 100644
index 00000000..494aea53
--- /dev/null
+++ b/debian/librumpdev-audio0.postinst.linux
@@ -0,0 +1,31 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ configure)
+ echo "# AUTOMATICALLY GENERATED BY librumpdev-audio0 postinst" \
+ > /etc/modprobe.d/rump_audio_blacklist.conf
+
+ . /usr/share/debconf/confmodule
+
+ db_get librumpdev-audio/linux-modules
+ for module in $(echo "$RET" | tr ',' '\n') ; do
+ echo "blacklist $module"
+ done >> /etc/modprobe.d/rump_audio_blacklist.conf
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/librumpdev-audio0.postrm.linux b/debian/librumpdev-audio0.postrm.linux
new file mode 100644
index 00000000..8b481ba4
--- /dev/null
+++ b/debian/librumpdev-audio0.postrm.linux
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+ rm -f /etc/modprobe.d/rump_audio_blacklist.conf
+ ;;
+
+ *)
+ echo "postrm called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/librumpdev-audio0.templates.linux b/debian/librumpdev-audio0.templates.linux
new file mode 100644
index 00000000..8fed3899
--- /dev/null
+++ b/debian/librumpdev-audio0.templates.linux
@@ -0,0 +1,11 @@
+Template: librumpdev-audio/linux-modules
+Type: multiselect
+Choices: ${CHOICES}
+Description: Linux modules to blacklist:
+ The audio hardware in your system is currently being used by the
+ following Linux audio driver modules. If you want to use your audio
+ hardware with Rump drivers, the corresponding Linux audio modules
+ need to be blacklisted.
+ .
+ The modules you select here will be automatically blacklisted after
+ next system reboot.