17
17
# (at your option) any later version.
20
export TEXTDOMAIN=alsaconf
21
23
exec_prefix=@exec_prefix@
30
if test "$USE_NLS" = "yes" && which gettext > /dev/null; then
26
48
# Check for GNU/Linux distributions
27
49
if [ -f /etc/SuSE-release -o -f /etc/UnitedLinux-release ]; then
51
echo "ALSA configurator version $version"
52
echo "usage: alsaconf [options]"
53
echo " -l|--legacy check only legacy non-isapnp cards"
54
echo " -m|--modinfo read module descriptions instead of reading card db"
55
echo " -s|--sound wav-file"
56
echo " use the specified wav file as a test sound"
57
echo " -u|--uid uid set the uid for the ALSA devices (default = 0) [obsoleted]"
58
echo " -g|--gid gid set the gid for the ALSA devices (default = 0) [obsoleted]"
59
echo " -d|--devmode mode"
60
echo " set the permission for ALSA devices (default = 0666) [obs.]"
61
echo " -r|--strict set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]"
62
echo " -L|--log file logging on the specified file (for debugging purpose only)"
63
echo " -p|--probe card-name"
64
echo " probe a legacy non-isapnp card and print module options"
65
echo " -P|--listprobe list the supported legacy card modules"
66
echo " -c|--config file"
67
echo " specify the module config file"
68
echo " -h|--help what you're reading"
73
xecho "ALSA configurator"
74
echo " version $version"
75
xecho "usage: alsaconf [options]
76
-l|--legacy check only legacy non-isapnp cards
77
-m|--modinfo read module descriptions instead of reading card db
79
use the specified wav file as a test sound
80
-u|--uid uid set the uid for the ALSA devices (default = 0) [obsoleted]
81
-g|--gid gid set the gid for the ALSA devices (default = 0) [obsoleted]
83
set the permission for ALSA devices (default = 0666) [obs.]
84
-r|--strict set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]
85
-L|--log file logging on the specified file (for debugging purpose only)
87
probe a legacy non-isapnp card and print module options
88
-P|--listprobe list the supported legacy card modules
90
specify the module config file
91
-h|--help what you're reading"
126
149
# check the snd_ prefix for ALSA module options
127
150
# snd_ prefix is obsoleted since 0.9.0rc4.
129
if modinfo -p snd | grep -q snd_ ; then
152
if /sbin/modinfo -p snd | grep -q snd_ ; then
135
158
alsa_device_opts=""
136
if modinfo -p snd | grep -q uid ; then
159
if /sbin/modinfo -p snd | grep -q uid ; then
137
160
if [ x"$alsa_uid" != x0 ]; then
138
161
alsa_device_opts="$alsa_device_opts ${mpfx}device_uid=$alsa_uid"
141
164
alsa_device_opts="$alsa_device_opts ${mpfx}device_gid=$alsa_gid"
144
if modinfo -p snd | grep -q device_mode ; then
167
if /sbin/modinfo -p snd | grep -q device_mode ; then
145
168
if [ x"$alsa_mode" != x0 ]; then
146
169
alsa_device_opts="$alsa_device_opts ${mpfx}device_mode=$alsa_mode"
160
183
# cfgout = new config file to write the sound setting (if different from $cfgfile)
161
184
if [ -n "$cfgfile" ]; then
162
185
if [ ! -r "$cfgfile" ]; then
163
echo "ERROR: The config file $cfgfile doesn't exist."
186
xecho "ERROR: The config file doesn't exist: "
186
210
# Check for dialog, whiptail, gdialog, awk, ... ?
187
211
if which dialog > /dev/null; then
190
214
if which whiptail > /dev/null; then
191
215
whiptail_wrapper() {
202
226
DIALOG=whiptail_wrapper
204
echo "Error, dialog or whiptail not found."
228
xecho "Error, dialog or whiptail not found."
208
232
if which awk > /dev/null; then :
210
echo "Error, awk not found. Can't continue."
234
xecho "Error, awk not found. Can't continue."
313
337
If ALSA is already running, you should close all sound
314
338
apps now and stop the sound driver.
315
alsaconf will try to do this, but it's not 100% sure.
339
alsaconf will try to do this, but it's not 100%% sure." $version)
340
$DIALOG --msgbox "$msg" 20 63 || acex 0
345
local msg=$(gettext "
347
OK, sound driver is configured.
325
349
ALSA CONFIGURATOR
327
351
will prepare the card for playing now.
329
Now I'll run '`basename $rcalsasound` start', then I'll use
353
Now I'll run alsasound init script, then I'll use
330
354
amixer to raise the default volumes.
331
355
You can change the volume later via a mixer
332
356
program such as alsamixer or gamix.
359
$DIALOG --msgbox "$msg" 17 60 || acex 0
380
405
TMP=`mktemp -q /tmp/alsaconf.XXXXXX`
381
406
if [ $? -ne 0 ]; then
382
echo "$0: Can't create temp file, exiting..."
407
xecho "Can't create temp file, exiting..."
385
410
addcfg=`mktemp -q /tmp/alsaconf.XXXXXX`
386
411
if [ $? -ne 0 ]; then
387
echo "$0: Can't create temp file, exiting..."
412
xecho "Can't create temp file, exiting..."
390
415
FOUND=`mktemp -q /tmp/alsaconf.XXXXXX`
391
416
if [ $? -ne 0 ]; then
392
echo "$0: Can't create temp file, exiting..."
417
xecho "Can't create temp file, exiting..."
395
420
DUMP=`mktemp -q /tmp/alsaconf.XXXXXX`
396
421
if [ $? -ne 0 ]; then
397
echo "$0: Can't create temp file, exiting..."
422
xecho "Can't create temp file, exiting..."
490
515
if [ $use_modinfo_db = 1 ]; then
491
echo "Building card database.."
516
xecho "Building card database.."
492
517
build_card_db $CARDID_DB
494
519
if [ ! -r $CARDID_DB ]; then
495
echo "No card database is found.."
520
xecho "No card database is found.."
498
523
ncards=`grep '^snd-.*\.o$' $CARDID_DB | wc -w`
525
msg=$(gettext "Searching sound cards")
502
528
format="%-40s %s\n";
547
573
$lspci -d $1 2>/dev/null| sed -e 's/^.*:..\.. Multimedia audio controller: //g'
549
575
elif expr "$1" : '[A-Z@][A-Z@][A-Z@][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then
550
cardname=`grep '^Card [0-9]\+ '\'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`
576
cardname=`grep '^Card [0-9]\+ .'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`
563
589
CARD_OPTS="${*:2}"
565
591
if [ -n "$cfgout" ]; then
567
Configuring $CARD_DRIVER
568
Do you want to modify ${cfgout} (and ${cfgfile} if present)?" 8 50 || acex 0
594
Do you want to modify %s (and %s if present)?" $CARD_DRIVER $cfgout $cfgfile)
595
$DIALOG --yesno "$msg" 8 50 || acex 0
571
Configuring $CARD_DRIVER
572
Do you want to modify ${cfgfile}?" 8 50 || acex 0
599
Do you want to modify %s?" $CARD_DRIVER $cfgfile)
600
$DIALOG --yesno "$msg" 8 50 || acex 0
643
671
cp -f $TMP /var/lib/YaST/unique.inf
646
farewell "OK, driver $CARD_DRIVER is configured."
648
676
if [ "$distribution" = "gentoo" ]; then
649
echo Running modules-update...
677
xecho "Running modules-update..."
651
679
elif [ "$distribution" = "debian" ]; then
652
echo Running update-modules...
680
xecho "Running update-modules..."
655
683
echo Loading driver...
669
697
If you have a big amplifier, lower your volumes or say no.
670
698
Otherwise check that your speaker volume is open,
671
699
and look if you can hear test sound.
701
if $DIALOG --yesno "$msg" 13 65
679
708
if [ ! -r /etc/asound.state ]; then
680
echo "Saving the mixer setup used for this in /etc/asound.state."
709
xecho "Saving the mixer setup used for this in /etc/asound.state."
681
710
$sbindir/alsactl store
685
714
===============================================================================
687
716
Now ALSA is ready to use.
1016
1044
ac_config_legacy () {
1018
$DIALOG --title "WARNING" --yesno "
1045
title=$(gettext "WARNING")
1019
1047
Probing legacy ISA cards might make
1020
1048
your system unstable.
1022
1050
Are you sure to proceed?
1053
$DIALOG --title "$title" --yesno "$msg" 10 50 || acex 0
1026
1055
if [ x"$1" = x ]; then
1027
1056
probe_list="$LEGACY_CARDS"
1039
1068
if [ x$menu_args = x ]; then
1040
$DIALOG --msgbox "No legacy drivers are available
1041
for your machine" 5 50
1069
msg=$(gettext "No legacy drivers are available
1071
$DIALOG --msgbox "$msg" 5 50
1044
$DIALOG --title "Driver Selection" --checklist \
1045
" Probing legacy ISA cards
1074
title=$(gettext "Driver Selection")
1075
msg=$(gettext " Probing legacy ISA cards
1047
Please select the drivers to probe:" \
1077
Please select the drivers to probe:")
1078
$DIALOG --title "$title" --checklist "$msg" \
1048
1079
17 64 8 "${menu_args[@]}" 2> $FOUND || acex 0
1050
1081
if [ $try_all_combination != 1 ]; then
1051
if $DIALOG --yesno "
1052
1083
Shall I try all possible DMA and IRQ combinations?
1053
1084
With this option, some unconventional configuration
1054
might be found, but it will take much longer time." 10 60
1085
might be found, but it will take much longer time.")
1086
if $DIALOG --yesno "$msg" 10 60
1056
1088
try_all_combination=1
1060
echo "Probing legacy cards.. This may take a few minutes.."
1092
xecho "Probing legacy cards.. This may take a few minutes.."
1093
echo -n $(gettext "Probing: ")
1062
1094
cards=`cat $FOUND | tr -d \"`
1063
1095
for card in $cards; do
1064
1096
echo -n " $card"
1066
1098
if eval ac_try_card_$card ; then
1068
1100
ac_config_card $card $ac_opts
1073
$DIALOG --title "Result" --msgbox "No legacy cards found" 5 50
1105
title=$(gettext "Result")
1106
msg=$(gettext "No legacy cards found")
1107
$DIALOG --title "$title" --msgbox "$msg" 5 50
1125
1159
if [ ${devs_found[0]} = cs46xx ]; then
1126
1160
if $lspci -nv 2>/dev/null| grep -q "Subsystem: 1014:1010"; then
1127
if $DIALOG --yesno "
1128
1162
Looks like you having a Thinkpad 600E or 770 notebook.
1129
1163
On this notebook, CS4236 driver should be used
1130
1164
although CS46xx chip is detected.
1132
1166
Shall I try to snd-cs4236 driver and probe
1133
the legacy ISA configuration?" 13 60
1167
the legacy ISA configuration?")
1168
if $DIALOG --yesno "$msg" 13 60
1135
1170
try_all_combination=1
1136
1171
ac_config_legacy cs4236
1139
1174
elif $lspci -nv 2>/dev/null| grep -q "Subsystem: 8086:8080"; then
1140
if $DIALOG --yesno "
1141
1176
Looks like you having a Dell Dimension machine.
1142
1177
On this machine, CS4232 driver should be used
1143
1178
although CS46xx chip is detected.
1145
1180
Shall I try to snd-cs4232 driver and probe
1146
the legacy ISA configuration?" 13 60
1181
the legacy ISA configuration?")
1182
if $DIALOG --yesno "$msg" 13 60
1148
1184
try_all_combination=1
1149
1185
ac_config_legacy cs4232
1155
1191
devs_found=("${devs_found[@]}" "legacy" "Probe legacy ISA (non-PnP) chips")
1156
$DIALOG --title "Soundcard Selection" --menu "
1192
title=$(gettext "Soundcard Selection")
1157
1194
Following card(s) are found on your system.
1158
1195
Choose a soundcard to configure:
1159
" 17 76 8 "${devs_found[@]}" 2> $FOUND || acex 0
1197
$DIALOG --title "$title" --menu "$msg" 17 76 8 "${devs_found[@]}" 2> $FOUND || acex 0
1160
1198
card=`head -n 1 $FOUND`
1161
1199
if [ "$card" = "legacy" ]; then
1162
1200
ac_config_legacy