summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-12-05 16:07:43 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-12-05 16:07:43 +0000
commit690c0c5602db9bf3ff954a9846a6766aa3a8e8cf (patch)
treeb8f5b3ba1da87a25b1e8cd2f9c13ea1803890a99
parentd7635f540b77d89d1e0f98b438445b60a78b38fd (diff)
downloaddrakx-backup-do-not-use-690c0c5602db9bf3ff954a9846a6766aa3a8e8cf.tar
drakx-backup-do-not-use-690c0c5602db9bf3ff954a9846a6766aa3a8e8cf.tar.gz
drakx-backup-do-not-use-690c0c5602db9bf3ff954a9846a6766aa3a8e8cf.tar.bz2
drakx-backup-do-not-use-690c0c5602db9bf3ff954a9846a6766aa3a8e8cf.tar.xz
drakx-backup-do-not-use-690c0c5602db9bf3ff954a9846a6766aa3a8e8cf.zip
titi fixes sound initscript for some alsa devices
-rw-r--r--move/Makefile3
-rwxr-xr-xmove/tree/alsa_default.pl19
-rwxr-xr-xmove/tree/sound.initscript116
3 files changed, 137 insertions, 1 deletions
diff --git a/move/Makefile b/move/Makefile
index 871659c6e..2c2da4d53 100644
--- a/move/Makefile
+++ b/move/Makefile
@@ -7,7 +7,7 @@ ISO = /BIG/mdkmove.iso
DATA_FILES = devices symlinks directories-to-create etcfiles all-etcfiles keyfiles \
BOOT-800-MOVE.jpg BOOT-1024-MOVE.jpg BOOT-1280-MOVE.jpg BOOT-1600-MOVE.jpg
-PROGRAM_FILES = etc-monitorer.pl tree/startkde_move tree/wait4x tree/netscape
+PROGRAM_FILES = etc-monitorer.pl tree/startkde_move tree/wait4x tree/netscape tree/alsa_default.pl
LANG_FILES = $(shell perl -ne 'print $$1 if /ALLOWED_LANGS = qw\((.*)\)/' move.pm)
STAGE1 = ../mdk-stage1
@@ -53,6 +53,7 @@ install: build
sudo rm -f $(DEST_LIVETREE)/usr/bin/{halt,reboot} #- symlinks to consolehelper
sudo cp -f tree/{halt,reboot} $(DEST_LIVETREE)/usr/bin
sudo cp -f tree/X_move $(DEST_LIVETREE)/usr/X11R6/bin
+ sudo cp -f tree/sound.initscript $(DEST_LIVETREE)/etc/init.d/sound
sudo rm -rf $(DEST_LIVETREE)/usr/share/langs
sudo mkdir -p $(DEST_LIVETREE)/usr/share/langs
diff --git a/move/tree/alsa_default.pl b/move/tree/alsa_default.pl
new file mode 100755
index 000000000..927c8c1d3
--- /dev/null
+++ b/move/tree/alsa_default.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+
+# state machine:
+if (/\s*control\./) {
+ ($min, $max) = (0, 0);
+} elsif (/\s*name '/) {
+ # skip masks
+ $ignore = /\s*name '.*(3D Control|mask|Exchange DAC|Output Jack)/;
+} elsif (!$ignore) {
+ if (/s*comment.range '(\d+) - (\d+)'/) {
+ ($min, $max) = ($1, $2);
+ } elsif (/s*value/) {
+ # enable switches (we should really blacklist sb live and the like):
+ s/(value\w*\S*)\s* false/\1 true/;
+ # set volume to 67%:
+ my $val = $max*0.6;
+ s/(value\w*\S*)\s* 0/\1 $val/
+ }
+}
diff --git a/move/tree/sound.initscript b/move/tree/sound.initscript
new file mode 100755
index 000000000..756f22398
--- /dev/null
+++ b/move/tree/sound.initscript
@@ -0,0 +1,116 @@
+#!/bin/sh
+# (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
+# $Id$
+#
+# sound: This shell script launch the sound on your system.
+#
+# chkconfig: 2345 18 69
+# description: This shell script launch the sound on your system.
+
+. /etc/rc.d/init.d/functions
+
+PKLVL=$(cut -f1 /proc/sys/kernel/printk)
+sysctl -n -w kernel.printk=0
+
+function start_mixer () {
+ # ALSA
+ if [ -d /proc/asound ] && [ -x /usr/sbin/alsactl ]; then
+ # is ALSA already configured ?
+ if [[ ! -r /etc/asound.state ]]; then
+ # provide decent default sound level for alsa drivers
+ if [ -d /proc/asound ] && [ -x /usr/sbin/alsactl ];then
+ MIXER_SETTINGS=/root/tmp/asound.state_tmp
+ alsactl -f $MIXER_SETTINGS store
+ # set sensible defaults:
+ perl -pi /usr/bin/alsa_default.pl $MIXER_SETTINGS
+ action "Setting mixer settings" alsactl -f $MIXER_SETTINGS restore
+ rm -f $MIXER_SETTINGS
+ return 0
+ fi
+ # if we've not alsa-utils, we'll fallback on OSS initialization below
+ else
+ # Not first boot:
+ # Done by alsa service but only if sound service is not
+ # enabled (hance this code path).
+ # We'll merge in back aksa service once mdk9.2 is released.
+ # [but we'll still handle both aumix & alsactl in order
+ # to manage packages removing / driver switch]
+ action "Loading mixer settings" /usr/sbin/alsactl restore
+ return 0
+ fi
+ fi
+ # OSS
+ if egrep -q '(sparcaudio|sound)' /proc/devices 2>/dev/null && \
+ [ "$retval" -eq 0 ] && [ -x /usr/bin/aumix ];then
+ if [ ! -r /etc/.aumixrc ];then
+ action "Setting mixer settings" /usr/bin/aumix -v80 -w80 -c80
+ else
+ action "Loading mixer settings" /usr/bin/aumix -f /etc/.aumixrc -L
+ fi
+ fi
+}
+
+function stop_mixer () {
+ if [ -d /proc/asound ] && [ -x /usr/sbin/alsactl ];then
+ # done by alsa service (to merge back after mdk9.2 release)
+ #action "Saving mixer settings" /usr/sbin/alsactl store
+ return 0;
+ fi
+ if egrep -q '(sparcaudio|sound)' /proc/devices 2>/dev/null && [ -x /usr/bin/aumix ];then
+ action "Saving mixer settings" /usr/bin/aumix -f /etc/.aumixrc -S
+ fi
+}
+
+function module () {
+ opt=""
+ phrase=$1
+ alias=$2
+ [ -n "$3" ] && opt="-r"
+ module=`/sbin/modprobe -c | egrep -s "^alias( |\t)+"$alias"( |\t)+" | awk '{ print $3 }'`
+ if [ -n "$module" ] && [ "$module" != "off" ];then
+ action "$phrase ($module)" modprobe "$opt" $module
+ return $?
+ fi
+}
+
+case $1 in
+ start)
+ retval=0
+ if [ ! -d /proc/asound ];then
+ module "Loading sound module" sound || retval=1
+ /sbin/modprobe -c | awk '/^((alias)|(probe)) +sound-slot-[0-9]/ {print $2}' | ( \
+ while read line; do
+ [[ $line = snd-card-* ]] && continue #we do it via alsa script
+ module "Loading sound module" $line || retval=1
+ done
+ )
+ module "Loading midi module" midi
+ fi
+ start_mixer;
+ touch /var/lock/subsys/sound
+ ;;
+ stop)
+ # i should have the same semantic of alsa script than oss script,
+ # but i do not :-(, patches welcome.
+ stop_mixer;
+ rm -f /var/lock/subsys/sound
+ ;;
+ status)
+ if egrep -q '(sparcaudio|sound)' /proc/devices;then
+ gprintf "Sound loaded"
+ echo
+ fi
+ ;;
+ reload)
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "Usage: %s\n" "$(basename $0) {start|stop|restart|status}"
+ exit 0
+esac
+
+sysctl -n -w kernel.printk=$PKLVL
+exit 0