2011-04-27 19:57:03 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# sound - sound configuration plugin for postplug
|
|
|
|
# Copyright (c) 2005-2007 by Davide Madrisan <davide.madrisan@gmail.com>
|
2011-11-06 23:40:58 +01:00
|
|
|
# Copyright (c) 2005-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
2011-04-27 19:57:03 +02:00
|
|
|
|
|
|
|
# Note: Some code has been stolen from /usr/sbin/alsaconf version 1.0.13
|
|
|
|
|
|
|
|
if [ $UID != 0 ]; then
|
|
|
|
echo "$0: must be superuser." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
me="sound"
|
|
|
|
|
|
|
|
[ -r /etc/sysconfig/machine ] && . /etc/sysconfig/machine
|
|
|
|
|
|
|
|
. /etc/postplug/postplug.defs
|
|
|
|
|
|
|
|
[ -r /etc/sysconfig/postplug ] && . /etc/sysconfig/postplug
|
|
|
|
|
|
|
|
SYSCONFIG_SOUNDCARDS=/etc/sysconfig/soundcards
|
|
|
|
|
2011-11-06 23:46:42 +01:00
|
|
|
[ -e /etc/asound.state ] && rm -f /etc/asound.state
|
|
|
|
|
2011-04-27 19:57:03 +02:00
|
|
|
# set default mixer volumes
|
|
|
|
function set_mixers() {
|
|
|
|
[ -x /usr/bin/amixer ] || return
|
2011-11-07 00:09:04 +01:00
|
|
|
channel=$1
|
|
|
|
[ "$channel" ] || channel=0
|
2011-04-27 19:57:03 +02:00
|
|
|
|
2011-11-07 00:09:04 +01:00
|
|
|
/usr/bin/amixer -s -c $channel -q <<_EOF
|
|
|
|
# Playback channels
|
|
|
|
set 'Master' 90% unmute
|
|
|
|
# some notebooks use headphone instead of master
|
|
|
|
set 'Headphone' 75% unmute
|
|
|
|
set 'Playback' 100% unmute
|
2011-04-27 19:57:03 +02:00
|
|
|
set 'Master Mono' 75% unmute
|
2011-11-07 00:09:04 +01:00
|
|
|
set 'Front' 90% unmute
|
|
|
|
set 'Speaker' 90% unmute
|
|
|
|
set 'PCM' 90% unmute
|
|
|
|
set 'Surround' 90% unmute
|
|
|
|
set 'Center' 90% unmute
|
|
|
|
set 'LFE' 90% unmute
|
|
|
|
set 'Line' 75% unmute
|
|
|
|
set 'CD' 90% unmute
|
|
|
|
set 'Synth' 90% unmute
|
2011-04-27 19:57:03 +02:00
|
|
|
# mute mic
|
2011-11-07 00:09:04 +01:00
|
|
|
set 'Front Mic' 75% mute
|
|
|
|
set 'Mic' 75% mute
|
2011-04-27 19:57:03 +02:00
|
|
|
# ESS 1969 chipset has 2 PCM channels
|
2011-11-07 00:09:04 +01:00
|
|
|
set 'PCM,1' 90% unmute
|
2011-04-27 19:57:03 +02:00
|
|
|
# Trident/YMFPCI/emu10k1
|
2011-11-07 00:09:04 +01:00
|
|
|
set 'Wave' 100% unmute
|
|
|
|
set 'Music' 100% unmute
|
|
|
|
set 'AC97' 100% unmute
|
2011-04-27 19:57:03 +02:00
|
|
|
# CS4237B chipset:
|
|
|
|
set 'Master Digital' 75% unmute
|
|
|
|
# Envy24 chips with analog outs
|
2011-11-07 00:09:04 +01:00
|
|
|
set 'DAC' 90% unmute
|
|
|
|
set 'DAC,0' 90% unmute
|
|
|
|
set 'DAC,1' 90% unmute
|
|
|
|
# Capture channels
|
|
|
|
set 'Capture' 90% unmute
|
|
|
|
set 'Capture 1' 90% unmute
|
|
|
|
set 'Capture 2' 90% unmute
|
|
|
|
# virtual channels
|
|
|
|
set 'Capture Gain' 50% unmute
|
|
|
|
set 'Output Gain' 75% unmute
|
2011-04-27 19:57:03 +02:00
|
|
|
# turn off digital switches
|
2011-11-07 00:09:04 +01:00
|
|
|
set 'SB Live Analog/Digital Output Jack' off
|
|
|
|
set 'Audigy Analog/Digital Output Jack' off
|
2011-04-27 19:57:03 +02:00
|
|
|
_EOF
|
|
|
|
}
|
|
|
|
|
2012-03-02 15:11:40 +01:00
|
|
|
if [ -e /proc/bus/pci ]; then
|
|
|
|
SOUND_DEV="`lspci -n | grep " 04[0-9][0-9]: "`"
|
|
|
|
fi
|
|
|
|
if [ ! "$SOUND_DEV" ]; then
|
|
|
|
if [ -e /proc/asound/cards ]; then
|
|
|
|
SOUND_DEV="`md5sum /proc/asound/cards 2>/dev/null`"
|
|
|
|
else
|
|
|
|
SOUND_DEV="missing"
|
|
|
|
fi
|
|
|
|
fi
|
2011-04-27 19:57:03 +02:00
|
|
|
|
2011-11-06 23:40:58 +01:00
|
|
|
if [ "$SOUND_FORCE_RESCAN" != "on" -a "$SOUND_FORCE_RESCAN" != "1" ]; then
|
|
|
|
if [ -e $postpluglibdir/sound.cache ]; then
|
|
|
|
SOUND_DEV_CACHED="`cat $postpluglibdir/sound.cache`"
|
|
|
|
[ "$SOUND_DEV" = "$SOUND_DEV_CACHED" ] && exit 0
|
|
|
|
logmsg "$me" "warning: audio device appears to have changed; re-probing"
|
|
|
|
mv $SYSCONFIG_SOUNDCARDS $SYSCONFIG_SOUNDCARDS.postplug.save
|
2011-04-27 19:57:03 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-06-06 19:02:23 +02:00
|
|
|
# WORKAROUND: custom softvol controls are not actived until a play/rec is done
|
|
|
|
# this also triggers kmix crash problem at first boot
|
|
|
|
aplay -q -d1 < /dev/zero
|
|
|
|
arecord -q -d1 > /dev/null
|
|
|
|
|
2011-11-06 23:40:58 +01:00
|
|
|
for c in /proc/asound/card[0-9]*; do
|
|
|
|
id=`cat $c/id`
|
2012-03-02 15:11:40 +01:00
|
|
|
codec=`grep Codec: $c/codec* 2>/dev/null | head -n1`
|
2011-11-06 23:40:58 +01:00
|
|
|
logmsg "$me" $"setting volumes for $id sound card ($codec)"
|
|
|
|
index=${d1/*card}
|
|
|
|
set_mixers $index
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -x /usr/sbin/alsactl ]; then
|
|
|
|
logmsg "$me" $"saving the mixer setup (/var/lib/sound/asound.state)"
|
2012-06-06 19:02:23 +02:00
|
|
|
/usr/sbin/alsactl store > /dev/null
|
2011-04-27 19:57:03 +02:00
|
|
|
fi
|
|
|
|
echo "$SOUND_DEV" > $postpluglibdir/sound.cache
|
|
|
|
exit 0
|