2009-08-26 17:00:38 +02:00
|
|
|
#!/bin/sh
|
2013-11-04 18:08:47 +01:00
|
|
|
# Load the mixer settings and OSS compatibility (if enabled) for ALSA.
|
2009-08-26 17:00:38 +02:00
|
|
|
# (the Advanced Linux Sound Architecture)
|
|
|
|
|
|
|
|
# A function to load the ALSA mixer settings:
|
|
|
|
load_alsa_mixer() {
|
2011-04-25 15:37:00 +02:00
|
|
|
if [ -r /var/lib/alsa/asound.state ]; then
|
2009-08-26 17:00:38 +02:00
|
|
|
echo "Loading ALSA mixer settings: /usr/sbin/alsactl restore"
|
|
|
|
/usr/sbin/alsactl restore
|
|
|
|
else
|
|
|
|
# It's possible a user might not want to set a default sound state.
|
2011-04-25 15:37:00 +02:00
|
|
|
# In that case, do this: touch /var/lib/alsa/no.asound.state
|
|
|
|
if [ ! -r /var/lib/alsa/no.asound.state ]; then
|
2009-08-26 17:00:38 +02:00
|
|
|
echo "Setting default ALSA mixer settings."
|
|
|
|
# set default mixer volumes for ALSA
|
2013-11-04 18:08:47 +01:00
|
|
|
# Taken from the alsaconf script.
|
2009-08-26 17:00:38 +02:00
|
|
|
amixer -s -q <<EOF
|
|
|
|
set Master 75% unmute
|
|
|
|
set Master -12dB
|
|
|
|
set 'Master Mono' 75% unmute
|
|
|
|
set 'Master Mono' -12dB
|
|
|
|
set Front 75% unmute
|
|
|
|
set Front -12dB
|
|
|
|
set PCM 90% unmute
|
|
|
|
set PCM 0dB
|
|
|
|
mixer Synth 90% unmute
|
|
|
|
mixer Synth 0dB
|
|
|
|
mixer CD 90% unmute
|
|
|
|
mixer CD 0dB
|
|
|
|
# mute mic
|
|
|
|
set Mic 0% mute
|
|
|
|
# ESS 1969 chipset has 2 PCM channels
|
|
|
|
set PCM,1 90% unmute
|
|
|
|
set PCM,1 0dB
|
|
|
|
# Trident/YMFPCI/emu10k1
|
|
|
|
set Wave 100% unmute
|
|
|
|
set Music 100% unmute
|
|
|
|
set AC97 100% unmute
|
|
|
|
# CS4237B chipset:
|
|
|
|
set 'Master Digital' 75% unmute
|
|
|
|
# Envy24 chips with analog outs
|
|
|
|
set DAC 90% unmute
|
|
|
|
set DAC -12dB
|
|
|
|
set DAC,0 90% unmute
|
|
|
|
set DAC,0 -12dB
|
|
|
|
set DAC,1 90% unmute
|
|
|
|
set DAC,1 -12dB
|
|
|
|
# some notebooks use headphone instead of master
|
|
|
|
set Headphone 75% unmute
|
|
|
|
set Headphone -12dB
|
|
|
|
set Playback 100% unmute
|
|
|
|
# turn off digital switches
|
|
|
|
set "SB Live Analog/Digital Output Jack" off
|
|
|
|
set "Audigy Analog/Digital Output Jack" off
|
|
|
|
EOF
|
|
|
|
echo "Storing default ALSA mixer settings: /usr/sbin/alsactl store"
|
|
|
|
/usr/sbin/alsactl store
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-11-04 18:08:47 +01:00
|
|
|
# If udev or something else has loaded the ALSA modules, then
|
2009-08-26 17:00:38 +02:00
|
|
|
# simply load the mixer settings and make sure the OSS compat
|
2013-11-04 18:08:47 +01:00
|
|
|
# modules are loaded (if enabled):
|
2009-08-26 17:00:38 +02:00
|
|
|
if [ -d /proc/asound ]; then
|
2013-11-04 18:08:47 +01:00
|
|
|
if [ -x /etc/rc.d/rc.alsa-oss ]; then
|
|
|
|
sh /etc/rc.d/rc.alsa-oss
|
|
|
|
fi
|
2009-08-26 17:00:38 +02:00
|
|
|
load_alsa_mixer
|
|
|
|
else
|
2011-04-25 15:37:00 +02:00
|
|
|
# If there are ALSA modules defined in /etc/modprobe.d/*, but
|
2009-08-26 17:00:38 +02:00
|
|
|
# ALSA is not yet loaded, then load the modules now:
|
|
|
|
DRIVERS=$(modprobe -c | grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | tr -s "[[:blank:]]" " " | cut -d " " -f 3)
|
|
|
|
if [ ! "$DRIVERS" = "" ]; then
|
|
|
|
echo "Loading ALSA kernel modules."
|
|
|
|
for module in $DRIVERS; do
|
|
|
|
modprobe $module
|
|
|
|
done
|
|
|
|
fi
|
2013-11-04 18:08:47 +01:00
|
|
|
# If ALSA is now up, then load the mixer settings and OSS modules (if enabled):
|
2009-08-26 17:00:38 +02:00
|
|
|
if [ -d /proc/asound ]; then
|
2013-11-04 18:08:47 +01:00
|
|
|
if [ -x /etc/rc.d/rc.alsa-oss ]; then
|
|
|
|
sh /etc/rc.d/rc.alsa-oss
|
|
|
|
fi
|
2009-08-26 17:00:38 +02:00
|
|
|
load_alsa_mixer
|
|
|
|
fi
|
|
|
|
fi
|