5 # Copyright (c) 1999-2002 SuSE GmbH
8 # written by Takashi Iwai <tiwai@suse.de>
9 # Bernd Kaindl <bk@suse.de>
10 # Jan ONDREJ (SAL) <ondrejj@salstar.sk>
12 # based on the original version of Jan ONDREJ's alsaconf for ALSA 0.4.
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
20 export TEXTDOMAIN=alsaconf
23 exec_prefix=@exec_prefix@
29 # Useful for debugging
34 if test "$USE_NLS" = "yes" && type -p gettext > /dev/null; then
52 # Check for GNU/Linux distributions
53 if [ -f /etc/SuSE-release ]; then
55 suse_version=$(grep 'VERSION = ' /etc/SuSE-release | sed -e s/'VERSION = '//)
56 elif [ -f /etc/UnitedLinux-release ]; then
58 elif [ -f /etc/gentoo-release ]; then
60 elif [ -f /etc/debian_version ]; then
62 elif [ -f /etc/mandrake-release ]; then
63 distribution="mandrake"
64 elif test -f /etc/redhat-release && grep -q "Red Hat" /etc/redhat-release; then
66 elif test -f /etc/fedora-release && grep -q "Fedora" /etc/fedora-release; then
68 elif [ -f /etc/slackware-version -o -f /etc/slamd64-version ]; then
69 distribution="slackware"
71 distribution="unknown"
74 for prog in lspci lsmod; do
75 for path in /sbin /usr/sbin /bin /usr/bin;do
76 test -x $path/$prog && eval $prog=$path/$prog
82 xecho "ALSA configurator"
83 echo " version $version"
84 xecho "usage: alsaconf [options]
85 -l|--legacy check only legacy non-isapnp cards
86 -m|--modinfo read module descriptions instead of reading card db
88 use the specified wav file as a test sound
89 -u|--uid uid set the uid for the ALSA devices (default = 0) [obsoleted]
90 -g|--gid gid set the gid for the ALSA devices (default = 0) [obsoleted]
92 set the permission for ALSA devices (default = 0666) [obs.]
93 -r|--strict set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]
94 -L|--log file logging on the specified file (for debugging purpose only)
96 probe a legacy non-isapnp card and print module options
97 -P|--listprobe list the supported legacy card modules
99 specify the module config file
100 -R|--resources list available DMA and IRQ resources with debug for legacy
101 -h|--help what you're reading"
104 OPTS=`getopt -o lmL:hp:Pu:g:d:rs:c:R --long legacy,modinfo,log:,help,probe:,listprobe,uid:,gid:,devmode:,strict,sound:,config:,resources -n alsaconf -- "$@"` || exit 1
114 TESTSOUND="@TESTSOUND@"
115 try_all_combination=0
119 LEGACY_CARDS="opl3sa2 cs4236 cs4232 cs4231 es18xx es1688 sb16 sb8"
124 do_legacy_only=1; shift ;;
126 use_modinfo_db=1; shift ;;
128 TESTSOUND=$2; shift 2;;
132 LOGFILE="$2"; shift 2;;
134 legacy_probe_card="$2"; shift 2;;
136 echo "$LEGACY_CARDS"; exit 0;;
138 alsa_uid="$2"; shift 2;;
140 alsa_gid="$2"; shift 2;;
142 alsa_mode="$2"; shift 2;;
144 alsa_uid=0; alsa_gid=17; alsa_mode=0660; shift;;
146 cfgfile="$2"; shift 2;;
148 resources="true"; shift;;
155 # probe legacy ISA cards
160 if [ -d $SYSFS/bus/pnp/devices ]; then
163 for i in $SYSFS/bus/pnp/devices/??:* ; do
164 if grep -q "state = active" $i/resources ; then
165 if grep -q '^dma '$dma'$' $i/resources; then
170 if [ -r $PROCFS/dma ]; then
171 if grep -q '^ *'$dma': ' $PROCFS/dma ; then
175 if [ "$ok" = "true" ]; then
180 if [ -r $PROCFS/dma ]; then
182 grep -q '^ *'$dma': ' $PROCFS/dma || list="$list $dma"
186 if [ ! -z "$list" ]; then
193 if [ -d $SYSFS/bus/pnp/devices ]; then
196 for i in $SYSFS/bus/pnp/devices/??:* ; do
197 if grep -q "state = active" $i/resources ; then
198 if grep -q '^irq '$irq'$' $i/resources; then
203 if [ -r $PROCFS/interrupts ]; then
204 if grep -q '^ *'$irq': ' $PROCFS/interrupts ; then
208 if [ "$ok" = "true" ]; then
213 if [ -r $PROCFS/interrupts ]; then
215 grep -q '^ *'$irq': ' $PROCFS/interrupts || list="$list $irq"
219 if [ ! -z "$list" ]; then
228 if [ "$resources" = "true" ]; then
229 if [ -d $SYSFS/bus/pnp/devices ]; then
230 for i in $SYSFS/bus/pnp/devices/??:* ; do
231 if [ "$resources" = "true" ]; then
232 echo ">>>>> PnP file: $i/resources"
237 if [ -r $PROCFS/dma ]; then
238 echo ">>>>> Allocated dma channels:"
241 if [ -r $PROCFS/interrupts ]; then
242 echo ">>>>> Allocated interrupt channels:"
243 cat $PROCFS/interrupts
245 echo -n "Valid DMA channels: "
246 check_dma_avail 0 1 2 3 4 5 6 7
247 echo -n "Valid IRQ channels: "
248 check_irq_avail 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
252 # Check for root privileges
253 if [ `id -u` -ne 0 ]; then
254 xecho "You must be root to use this script."
259 # check the snd_ prefix for ALSA module options
260 # snd_ prefix is obsoleted since 0.9.0rc4.
262 if /sbin/modinfo -p snd | grep -q snd_ ; then
269 if /sbin/modinfo -p snd | grep -q uid ; then
270 if [ x"$alsa_uid" != x0 ]; then
271 alsa_device_opts="$alsa_device_opts ${mpfx}device_uid=$alsa_uid"
273 if [ x"$alsa_gid" != x0 ]; then
274 alsa_device_opts="$alsa_device_opts ${mpfx}device_gid=$alsa_gid"
277 if /sbin/modinfo -p snd | grep -q device_mode ; then
278 if [ x"$alsa_mode" != x0 ]; then
279 alsa_device_opts="$alsa_device_opts ${mpfx}device_mode=$alsa_mode"
292 # cfgfile = base config file to remove/update the sound setting
293 # cfgout = new config file to write the sound setting (if different from $cfgfile)
296 if [ -n "$cfgfile" ]; then
297 if [ ! -r "$cfgfile" ]; then
298 xecho "ERROR: The config file doesn't exist: "
303 if [ "$distribution" = "gentoo" ]; then
304 cfgfile="/etc/modules.d/alsa"
305 elif [ "$kernel" = "new" ]; then
306 cfgfile="/etc/modprobe.conf"
307 if [ -d /etc/modprobe.d ]; then
308 cfgout="/etc/modprobe.d/50-sound.conf"
309 cfgoldout="/etc/modprobe.d/sound"
310 if [ ! -f $cfgout ]; then
311 modver=$(modprobe -V | sed -e's/^module-init-tools version //')
316 cfgout="/etc/modprobe.d/sound"
322 elif [ "$distribution" = "debian" ]; then
323 cfgfile="/etc/modutils/sound"
324 elif [ -e /etc/modules.conf ]; then
325 cfgfile="/etc/modules.conf"
326 elif [ -e /etc/conf.modules ]; then
327 cfgfile="/etc/conf.modules"
329 cfgfile="/etc/modules.conf"
330 touch /etc/modules.conf
334 # Check for dialog, whiptail, gdialog, awk, ... ?
335 if type -p dialog > /dev/null; then
338 if type -p whiptail > /dev/null; then
342 if [ $1 = --yesno ]; then
348 whiptail "$X1" "$X2" $X3 "$@"
350 DIALOG=whiptail_wrapper
352 xecho "Error, dialog or whiptail not found."
356 if type -p awk > /dev/null; then :
358 xecho "Error, awk not found. Can't continue."
363 # remove entries by yast2 sound configurator
367 /^alias sound-slot-[0-9]/ { next }
368 /^alias char-major-116 / { next }
369 /^alias char-major-14 / { next }
370 /^alias snd-card-[0-9] / { next }
371 /^options snd / { next }
372 /^options snd-/ { next }
373 /^options off / { next }
374 /^alias sound-service-[0-9]/ { next }
375 /^# YaST2: sound / { next }
380 # remove entries by sndconfig sound configurator
382 # found strings to search for in WriteConfModules,
383 # from sndconfig 0.68-4 (rawhide version)
385 remove_sndconfig_block() {
387 /^alias sound-slot-0/ { modulename = $3 ; next }
388 /^alias sound-slot-[0-9]/ { next }
389 /^post-install sound-slot-[0-9] / { next }
390 /^pre-remove sound-slot-[0-9] / { next }
391 /^options sound / { next }
392 /^alias synth0 opl3/ { next }
393 /^options opl3 / { next }
394 /^alias midi / { mididev = $3 ; next }
395 /^options / { if ($2 == mididev) next }
396 /^pre-install / { if ($2 == mididev) next }
397 /^alias synth0 / { synth = $3 ; next }
398 /^post-install / { if ($2 == synth) next }
399 /^options sb / { next }
400 /^post-install .+ \/bin\/modprobe "aci"/ { if ($2 == modulename) next }
401 /^options adlib_card / { next }
402 /^options .+ isapnp=1/ { if ($2 == modulename) next }
403 /^options i810_audio / { next }
404 /^options / {if ($2 == modulename) next }
409 # remove the previous configuration by alsaconf
412 awk '/^'"$ACB"'$/,/^'"$ACE"'$/ { next } { print }'
416 # set default mixer volumes
420 set Master 75% unmute
422 set 'Master Mono' 75% unmute
423 set 'Master Mono' -12dB
428 mixer Synth 90% unmute
434 # ESS 1969 chipset has 2 PCM channels
437 # Trident/YMFPCI/emu10k1
439 set Music 100% unmute
442 set 'Master Digital' 75% unmute
443 # Envy24 chips with analog outs
450 # some notebooks use headphone instead of master
451 set Headphone 75% unmute
453 set Playback 100% unmute
454 # turn off digital switches
455 set "SB Live Analog/Digital Output Jack" off
456 set "Audigy Analog/Digital Output Jack" off
467 This script is a configurator for
468 Advanced Linux Sound Architecture (ALSA) driver.
471 If ALSA is already running, you should close all sound
472 apps now and stop the sound driver.
473 alsaconf will try to do this, but it's not 100%% sure." $version)
474 $DIALOG --msgbox "$msg" 20 63 || acex 0
479 local msg=$(gettext "
481 OK, sound driver is configured.
485 will prepare the card for playing now.
487 Now I'll run alsasound init script, then I'll use
488 amixer to raise the default volumes.
489 You can change the volume later via a mixer
490 program such as alsamixer or gamix.
493 $DIALOG --msgbox "$msg" 17 60 || acex 0
504 # search for alsasound init script
507 if [ "$distribution" = "debian" ]; then
508 rcalsasound=/etc/init.d/alsa
509 elif [ -x /etc/rc.d/rc.alsa ]; then
510 rcalsasound=/etc/rc.d/rc.alsa
511 elif [ -x /etc/init.d/alsasound ]; then
512 rcalsasound=/etc/init.d/alsasound
513 elif [ -x /usr/sbin/rcalsasound ]; then
514 rcalsasound=/usr/sbin/rcalsasound
515 elif [ -x /sbin/rcalsasound ]; then
516 rcalsasound=/sbin/rcalsasound
517 elif [ -x /etc/rc.d/init.d/alsasound ]; then
518 rcalsasound=/etc/rc.d/init.d/alsasound
519 elif [ -x /etc/init.d/alsa ]; then
520 rcalsasound=/etc/init.d/alsa
522 rcalsasound=rcalsasound
527 if [ -d $PROCFS/asound ]; then
528 $rcalsasound stop >/dev/null 2>&1
529 $rcalsasound unload >/dev/null 2>&1
530 /sbin/rmmod dmasound dmasound_awacs 2>/dev/null
535 killall -9 aplay arecord >/dev/null 2>&1
536 /sbin/modprobe -r isapnp >/dev/null 2>&1
537 /sbin/modprobe -r isa-pnp >/dev/null 2>&1
538 rm -f "$TMP" "$addcfg" "$FOUND" "$DUMP"
542 TMP=`mktemp -q /tmp/alsaconf.XXXXXX`
543 if [ $? -ne 0 ]; then
544 xecho "Can't create temp file, exiting..."
547 addcfg=`mktemp -q /tmp/alsaconf.XXXXXX`
548 if [ $? -ne 0 ]; then
549 xecho "Can't create temp file, exiting..."
552 FOUND=`mktemp -q /tmp/alsaconf.XXXXXX`
553 if [ $? -ne 0 ]; then
554 xecho "Can't create temp file, exiting..."
557 DUMP=`mktemp -q /tmp/alsaconf.XXXXXX`
558 if [ $? -ne 0 ]; then
559 xecho "Can't create temp file, exiting..."
563 # convert ISA PnP id number to string 'ABC'
564 convert_isapnp_id () {
569 let a='('$1'>>2) & 0x3f'
570 let b='(('$1' & 0x03) << 3) | (('$1' >> 13) & 0x07)'
571 let c='('$1'>> 8) & 0x1f'
572 strs='@ABCDEFGHIJKLMNOPQRSTUVWXYZ'
573 echo ${strs:$a:1}${strs:$b:1}${strs:$c:1}
576 # swap high & low bytes
582 let v='(('$1'>>8)&0xff)|(('$1'&0xff)<<8)'
586 # build card database
587 # build_card_db filename
589 MODDIR=/lib/modules/`uname -r`
594 while read driver vendor device dummy; do
595 if expr $driver : 'snd-.*' >/dev/null ; then
596 if [ "$last_driver" != "$driver" ]; then
600 id1=`printf '0x%04x' $vendor`
601 id2=`printf '0x%04x' $device`
602 echo "PCI: $id1=$id2"
604 done < $MODDIR/modules.pcimap >> $1
607 while read driver cardvendor carddevice data vendor func; do
608 if expr $driver : 'snd-.*' >/dev/null ; then
609 if [ "$last_driver" != "$driver" ]; then
613 id1=`convert_isapnp_id $cardvendor`
614 dev1=`swap_number $carddevice`
615 id2=`convert_isapnp_id $vendor`
616 dev2=`swap_number $func`
617 echo "ISAPNP: $id1$dev1=$id2$dev2"
619 done < $MODDIR/modules.isapnpmap >> $1
627 test -r $PROCFS/isapnp || /sbin/modprobe isapnp >/dev/null 2>&1
628 test -r $PROCFS/isapnp || /sbin/modprobe isa-pnp >/dev/null 2>&1
629 if [ -r $PROCFS/isapnp ]; then
630 cat $PROCFS/isapnp >"$DUMP"
632 elif [ -d $SYSFS/bus/pnp/devices ]; then
633 # use 2.6 kernel's sysfs output
634 # fake the isapnp dump
637 for d1 in $SYSFS/devices/pnp* ; do
638 for d2 in $d1/*:* ; do
639 if [ -r $d2/card_id ]; then
642 echo "Card $index '$id:$name' " >> "$DUMP"
645 else if [ -r $d2/id ]; then
646 # FIXME: multiple id might be present (separated with new-line)
647 id=`head -n 1 $d2/id`
648 echo "BIOS $bindex '$id' " >> "$DUMP"
656 if [ "$found" = "0" ]; then
659 CARDID_DB=/var/tmp/alsaconf.cards
660 if [ ! -r $CARDID_DB ]; then
663 if [ $use_modinfo_db != 1 ]; then
664 if [ $CARDID_DB -ot /lib/modules/`uname -r`/modules.dep ]; then
668 if [ $use_modinfo_db = 1 ]; then
669 xecho "Building card database.."
670 build_card_db $CARDID_DB
672 if [ ! -r $CARDID_DB ]; then
673 xecho "No card database is found.."
676 ncards=`grep '^snd-.*\.o$' $CARDID_DB | wc -w`
678 msg=$(gettext "Searching sound cards")
688 perc=(idx * 100) / (ncards + 1);
692 /^[<literal space><literal tab>]*PCI: /{
695 x = sprintf ("'$lspci' -n 2>/dev/null| grep '"' 04..: '"' | grep %s", $2);
697 printf "%s %s\n", $2, driver >>"'"$FOUND"'"
699 /^[<literal space><literal tab>]*ISAPNP: /{
700 id2 = substr($0, index($0, "=")+1);
702 x = sprintf ("grep '\''^Card [0-9] .%s:'\'' '"$DUMP"'", $2);
704 printf "%s %s\n", $2, driver >>"'"$FOUND"'"
705 else if (index($2, "ffff") > 0) {
706 x = sprintf ("grep '\''^BIOS [0-9]* .%s.'\'' '"$DUMP"'", id2);
708 printf "%s %s\n", id2, driver >>"'"$FOUND"'"
711 $DIALOG --gauge "$msg" 6 40 0
716 if grep -q MacRISC $PROCFS/cpuinfo; then
717 MODDIR=/lib/modules/`uname -r`
718 find $MODDIR -name 'snd-powermac*' -print | \
723 echo "PowerMac $i" >> $FOUND
730 if grep -q Sparc $PROCFS/cpuinfo; then
731 test -r $PROCFS/openprom/name || /bin/mount -t openpromfs none $PROCFS/openprom >/dev/null 2>&1
732 # Check for an "audio" device
735 if test -r $PROCFS/openprom; then
736 audio=`find $PROCFS/openprom -follow -type d -name "audio*" -print`
738 if test -n "$audio"; then
739 compat=`cat $audio/compatible`
742 compat=${compat#SUNW,}
744 # Go through all cards we have
745 MODDIR=/lib/modules/`uname -r`
746 find $MODDIR -name 'snd-sun-*' -print | \
751 sdev=`echo ${i#snd-sun-} | tr "[a-z]" "[A-Z]"`
753 if test "$sdev" = "$compat"; then
754 echo "$sdev $i" >> $FOUND
755 elif test -r $PROCFS/openprom; then
756 find $PROCFS/openprom -follow -type d -name "SUNW,${sdev}*" \
757 -exec echo "$sdev $i" \; 2>/dev/null >> $FOUND
759 echo "$sdev $i" >> $FOUND
766 # look for a descriptive device name from the given device id
768 find_device_name () {
769 if expr "$1" : '[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then
770 $lspci -d $1 2>/dev/null| sed -e 's/^.*:..\.. [^:]*: //g'
772 elif expr "$1" : '[A-Z@][A-Z@][A-Z@][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then
773 cardname=`grep '^Card [0-9]\+ .'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`
780 # get hwcfg file type from the given driver name
782 while read dev driver; do
783 if [ "$driver" = "$1" ]; then
786 # FIXME: need to look around /sys/bus/pci/* (or use vpid-* ?)
787 devid=`$lspci -d "$dev" | head -n 1 | sed -e 's/ .*$//'`
790 *) devid="0000:$devid" ;;
803 # clean up all hwcfg-* files containing ALSA modules
804 # alsaconf sets up exclusively
806 for i in /etc/sysconfig/hardware/hwcfg-*; do
807 grep -q "MODULE='snd-" $i && rm -f $i
812 # set up /etc/sysconfig/hardware/hwcfg-* stuff
817 cfg=`echo "$devs_olist" | get_hwcfg_type $card`
818 echo "MODULE='$card'" > /etc/sysconfig/hardware/hwcfg-$cfg
819 echo "STARTMODE='auto'" >> /etc/sysconfig/hardware/hwcfg-$cfg
824 # configure and try test sound
831 if [ -n "$cfgout" ]; then
834 Do you want to modify %s (and %s if present)?" $CARD_DRIVER $cfgout $cfgfile)
835 $DIALOG --yesno "$msg" 10 50 || acex 0
839 Do you want to modify %s?" $CARD_DRIVER $cfgfile)
840 $DIALOG --yesno "$msg" 8 50 || acex 0
844 # Copy conf.modules and make changes.
845 ACB="# --- BEGIN: Generated by ALSACONF, do not edit. ---"
846 ACE="# --- END: Generated by ALSACONF, do not edit. ---"
848 # Detect 2.2.X kernel
849 KVER=`uname -r | tr ".-" " "`
850 KVER1=`echo $KVER | cut -d" " -f1`
851 KVER2=`echo $KVER | cut -d" " -f2`
852 if [ $KVER1 -ge 2 ] && [ $KVER2 -ge 2 ]; then
853 SOUND_CORE="soundcore"
858 if [ -r $cfgfile ] ; then
859 if [ "$distribution" = "redhat" -o "$distribution" = "fedora" ] ; then
860 remove_ac_block < $cfgfile | remove_sndconfig_block | uniq > $TMP
862 remove_ac_block < $cfgfile | remove_y2_block | uniq > $TMP
866 if [ -z "$have_alias" -a "$kernel" = "new" ]; then
867 if grep -q char-major-116 /lib/modules/`uname -r`/modules.alias; then
871 if [ -z "$have_alias" ]; then
872 echo "alias char-major-116 snd
873 alias char-major-14 $SOUND_CORE
874 alias sound-service-0-0 snd-mixer-oss
875 alias sound-service-0-1 snd-seq-oss
876 alias sound-service-0-3 snd-pcm-oss
877 alias sound-service-0-8 snd-seq-oss
878 alias sound-service-0-12 snd-pcm-oss" >> $addcfg
880 if [ -n "$alsa_device_opts" ]; then
881 echo "options snd $alsa_device_opts" >> $addcfg
883 echo "alias snd-card-0 $CARD_DRIVER
884 alias sound-slot-0 $CARD_DRIVER" >> $addcfg
885 if [ -n "$CARD_OPTS" ]; then
886 echo "options $CARD_DRIVER $CARD_OPTS" >> $addcfg
889 if [ -n "$cfgout" ]; then
890 [ ! -r "$cfgfile" ] || cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile"
891 cmp -s "$addcfg" "$cfgout" || cat "$addcfg" > "$cfgout"
892 test -n "$cfgoldout" && rm -f "$cfgoldout"
895 # --- ALSACONF version $version ---" >> $TMP
896 cat "$addcfg" >> "$TMP"
899 cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile"
902 /sbin/depmod -a 2>/dev/null
904 # remove yast2 entries (- only for suse distro)
905 if [ -f /var/lib/YaST/unique.inf ]; then
907 BEGIN { in_sound=0; }
908 /^\[sound\]$/ { print; in_sound=1; next; }
909 /^\[.+\]$/ { print; in_sound=0; next; }
910 { if (in_sound == 0) { print; } }
911 ' < /var/lib/YaST/unique.inf > $TMP
912 cp -f $TMP /var/lib/YaST/unique.inf
915 # set up /etc/sysconfig/hardware/*
916 if [ "$distribution" = "suse" ]; then
917 case "$suse_version" in
919 setup_hwcfg $CARD_DRIVER
926 case "$distribution" in
928 xecho "Running update-modules..."
932 if [ -x $rcalsasound ] ; then
933 echo Loading driver...
936 echo Setting default volumes...
937 if [ -x $bindir/set_default_volume ]; then
938 $bindir/set_default_volume -f
942 if [ -f $TESTSOUND ]; then
944 The mixer is set up now for for playing.
945 Shall I try to play a sound sample now?
948 If you have a big amplifier, lower your volumes or say no.
949 Otherwise check that your speaker volume is open,
950 and look if you can hear test sound.
952 if $DIALOG --yesno "$msg" 13 65
959 mkdir -p -m 0755 @ASOUND_STATE_DIR@
960 if [ ! -r @ASOUND_STATE_DIR@/asound.state ]; then
961 xecho "Saving the mixer setup used for this in @ASOUND_STATE_DIR@/asound.state."
962 $sbindir/alsactl store
966 ===============================================================================
968 Now ALSA is ready to use.
969 For adjustment of volumes, use your favorite mixer.
977 # return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
979 test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
980 /sbin/modprobe snd-$1 ${*:2} >/dev/null 2>&1
981 if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then
984 /sbin/modprobe -r snd-$1 >/dev/null 2>&1
989 amixer set Master 0% mute >/dev/null 2>&1
990 amixer set PCM 0% mute >/dev/null 2>&1
993 head -c 4000 < /dev/zero | aplay -N -r8000 -fS16_LE -traw -c1 > /dev/null 2>&1 &
996 # sleep for 2 seconds (to be sure -- 1 sec would be enough)
998 # kill the child process if still exists.
999 kill -9 $pp > /dev/null 2>&1
1001 ac_cardname=`head -n 1 $PROCFS/asound/cards | sed -e 's/^[0-9].* - \(.*\)$/\1/'`
1002 /sbin/modprobe -r snd-$1 >/dev/null 2>&1
1003 if [ $st = 0 ]; then
1005 test -n "$LOGFILE" && echo "no playback return" >> "$LOGFILE"
1009 test -n "$LOGFILE" && echo "playback OK" >> "$LOGFILE"
1015 # return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
1016 # ac_try_capture card duplex opts
1018 test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
1019 /sbin/modprobe snd-$1 ${*:3} >/dev/null 2>&1
1020 if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then
1023 /sbin/modprobe -r snd-$1 >/dev/null 2>&1
1028 amixer set Master 0% mute >/dev/null 2>&1
1029 amixer set PCM 0% mute >/dev/null 2>&1
1032 if [ $2 = yes ]; then
1033 # try duplex - start dummy playing
1034 aplay -N -r8000 -fS16_LE -traw -c1 < /dev/zero > /dev/null 2>&1 &
1038 arecord -N -d1 > /dev/null 2>&1 &
1041 # sleep for 2 seconds
1043 # kill the child process if still exists.
1044 kill -9 $pp > /dev/null 2>&1
1046 # kill playback process if any
1047 test $play_pid != 0 && kill -9 $play_pid
1048 /sbin/modprobe -r snd-$1 >/dev/null 2>&1
1049 if [ $st = 0 ]; then
1050 test -n "$LOGFILE" && echo "capture no return" >> "$LOGFILE"
1053 test -n "$LOGFILE" && echo "capture OK" >> "$LOGFILE"
1072 # check playback on specified irqs
1074 # ac_try_irq card opts irqs...
1075 # return 0 - OK, 1 - NG, 2 - not working (dma problem?)
1079 opts="$2 ${mpfx}irq=$3"
1080 ac_try_load $card $opts >/dev/null 2>&1
1088 for irq in ${*:4}; do
1089 opts="$2 ${mpfx}irq=$irq"
1090 ac_try_load $card $opts >/dev/null 2>&1
1103 # check playback/capture on dma1 & dma2 & specified irqs
1105 # ac_try_dmas card opts irqs...
1106 # return 0 - OK, 1 - NG
1109 dma_list=`check_dma_avail 1 0 3 5`
1110 for irq in ${*:3}; do
1111 for dma1 in $dma_list; do
1112 for dma2 in `get_dma_pair $dma1`; do
1113 opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq"
1114 ac_try_load $1 $opts >/dev/null 2>&1
1116 if [ $result = 1 ]; then
1117 if [ $try_all_combination = 1 ]; then
1122 elif [ $result = 0 ]; then
1123 test -n "$LOGFILE" && echo "Now checking capture..." >> "$LOGFILE"
1125 ac_try_capture $1 yes $opts >/dev/null 2>&1 && return 0
1127 for dma2 in $dma_list; do
1128 if [ $dma1 != $dma2 ]; then
1129 opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq"
1131 ac_try_capture $1 $d $opts >/dev/null 2>&1 && return 0
1143 # check if the option $2 exists in card $1: set value $3
1144 ac_check_option () {
1145 if /sbin/modinfo -p snd-$1 | grep -q $2; then
1150 ac_try_card_sb8 () {
1152 irq_list=`check_irq_avail 5 3 9 10 7`
1153 for dma8 in `check_dma_avail 1 3`; do
1154 opts="${mpfx}dma8=$dma8"
1155 ac_try_irq $card "$opts" $irq_list && return 0
1160 ac_try_card_sb16 () {
1162 isapnp=`ac_check_option $card ${mpfx}isapnp 0`
1164 irq_list=`check_irq_avail 5 9 10 7 3`
1165 dma_list=`check_dma_avail 0 1 3`
1166 dma16_list=`check_dma_avail 5 6 7`
1167 # at first try auto-probing by driver itself
1168 ac_try_load $card $opts >/dev/null 2>&1
1173 ac_try_capture $card yes $opts >/dev/null 2>&1 && return 0
1175 for dma8 in $dma_list; do
1176 for irq in $irq_list; do
1177 opts="${mpfx}dma8=$dma8 ${mpfx}irq=$irq $isapnp"
1178 ac_try_capture $card $d $opts >/dev/null 2>&1 && return 0
1185 for dma16 in $dma16_list; do
1186 opts="${mpfx}dma16=$dma16 $isapnp"
1187 if ac_try_irq $card "$opts" $irq_list ; then
1188 ac_try_capture $card yes $ac_opts >/dev/null 2>&1 && return 0
1189 ac_opts_saved="$ac_opts"
1191 for dma8 in $dma_list; do
1192 ac_opts="$ac_opts_saved ${mpfx}dma8=$dma8"
1193 ac_try_capture $card $d $ac_opts >/dev/null 2>&1 && return 0
1196 # return anyway here..
1205 ac_try_card_es1688 () {
1208 irq_list=`check_irq_avail 5 9 10 7`
1209 for dma8 in `check_dma_avail 1 3 0`; do
1210 opts="${mpfx}dma8=$dma8 ${mpfx}mpu_irq=-1"
1211 ac_try_irq $card "$opts" $irq_list && return 0
1216 ac_try_card_es18xx () {
1218 opts=`ac_check_option $card ${mpfx}isapnp 0`
1219 ac_try_dmas $card "$opts" `check_irq_avail 5 9 10 7` && return 0
1223 ac_try_card_cs4236 () {
1225 irq_list=`check_irq_avail 5 7 9 11 12 15`
1226 isapnp=`ac_check_option $card ${mpfx}isapnp 0`
1227 for cport in 0x538 0x210 0xf00; do
1228 for port in 0x530 0x534; do
1229 opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp"
1230 ac_try_dmas $card "$opts" $irq_list && return 0
1236 ac_try_card_cs4232 () {
1238 irq_list=`check_irq_avail 5 7 9 11 12 15`
1239 isapnp=`ac_check_option $card ${mpfx}isapnp 0`
1240 for cport in 0x538 0x210 0xf00; do
1241 for port in 0x530 0x534; do
1242 opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp"
1243 ac_try_dmas $card "$opts" $irq_list && return 0
1249 ac_try_card_cs4231 () {
1251 irq_list=`check_irq_avail 5 7 9 11 12 15`
1252 for port in 0x530 0x534; do
1253 opts="${mpfx}port=$port"
1254 ac_try_dmas $card "$opts" $irq_list && return 0
1259 ac_try_card_opl3sa2 () {
1261 irq_list=`check_irq_avail 5 9 3 1 11 12 15 0`
1262 isapnp=`ac_check_option $card ${mpfx}isapnp 0`
1263 for port in 0x370 0x538 0xf86 0x100; do
1264 for wss_port in 0x530 0xe80 0xf40 0x604; do
1265 opts="${mpfx}fm_port=-1 ${mpfx}midi_port=-1 ${mpfx}port=$port ${mpfx}wss_port=$wss_port $isapnp"
1266 ac_try_dmas $card "$opts" $irq_list && return 0
1272 ac_config_legacy () {
1273 title=$(gettext "WARNING")
1275 Probing legacy ISA cards might make
1276 your system unstable.
1278 Do you want to proceed?
1281 $DIALOG --title "$title" --yesno "$msg" 10 50 || acex 0
1283 if [ x"$1" = x ]; then
1284 probe_list="$LEGACY_CARDS"
1290 for card in $probe_list; do
1291 cardname=`/sbin/modinfo -d snd-$card | sed -e 's/^\"\(.*\)\"$/\1/g'`
1292 if [ x"$cardname" != x ]; then
1293 menu_args=("${menu_args[@]}" "$card" "$cardname" "on")
1296 if [ x$menu_args = x ]; then
1297 msg=$(gettext "No legacy drivers are available
1299 $DIALOG --msgbox "$msg" 5 50
1302 title=$(gettext "Driver Selection")
1303 msg=$(gettext " Probing legacy ISA cards
1305 Please select the drivers to probe:")
1306 $DIALOG --title "$title" --checklist "$msg" \
1307 17 64 8 "${menu_args[@]}" 2> $FOUND || acex 0
1309 if [ $try_all_combination != 1 ]; then
1311 Shall I try all possible DMA and IRQ combinations?
1312 With this option, some unconventional configuration
1313 might be found, but it will take much longer time.")
1314 if $DIALOG --yesno "$msg" 10 60
1316 try_all_combination=1
1320 xecho "Probing legacy cards.. This may take a few minutes.."
1321 echo -n $(gettext "Probing: ")
1322 cards=`cat $FOUND | tr -d \"`
1323 for card in $cards; do
1326 if eval ac_try_card_$card ; then
1328 ac_config_card $card $ac_opts
1333 title=$(gettext "Result")
1334 msg=$(gettext "No legacy cards found")
1335 $DIALOG --title "$title" --msgbox "$msg" 5 50
1340 # main part continued..
1343 if test -n "$LOGFILE" ; then
1345 echo -n "Starting alsaconf: " >> "$LOGFILE"
1349 if [ x"$legacy_probe_card" != x ]; then
1351 if eval ac_try_card_$legacy_probe_card >/dev/null 2>&1; then
1363 if [ $do_legacy_only = 1 ]; then
1373 if [ -s "$FOUND" ]; then
1374 while read dev card ; do
1375 MODDIR=/lib/modules/`uname -r`
1376 find $MODDIR -type f | grep -q -E $card'\.(o|ko)' || continue
1377 cardname=`find_device_name $dev | cut -c 1-64`
1378 if [ -z "$cardname" ]; then
1382 devs_found=("${devs_found[@]}" "$card" "$cardname")
1383 devs_devs=("${devs_devs[@]}" "$card" "$dev")
1385 devs_olist=`cat $FOUND`
1387 if [ x$devs_found != x ]; then
1391 if [ ${devs_found[0]} = cs46xx ]; then
1392 if $lspci -nv 2>/dev/null| grep -q "Subsystem: 1014:1010"; then
1394 Looks like you having a Thinkpad 600E or 770 notebook.
1395 On this notebook, CS4236 driver should be used
1396 although CS46xx chip is detected.
1398 Shall I try to snd-cs4236 driver and probe
1399 the legacy ISA configuration?")
1400 if $DIALOG --yesno "$msg" 13 60
1402 try_all_combination=1
1403 ac_config_legacy cs4236
1406 elif $lspci -nv 2>/dev/null| grep -q "Subsystem: 8086:8080"; then
1408 Looks like you having a Dell Dimension machine.
1409 On this machine, CS4232 driver should be used
1410 although CS46xx chip is detected.
1412 Shall I try to snd-cs4232 driver and probe
1413 the legacy ISA configuration?")
1414 if $DIALOG --yesno "$msg" 13 60
1416 try_all_combination=1
1417 ac_config_legacy cs4232
1423 devs_found=("${devs_found[@]}" "legacy" "Probe legacy ISA (non-PnP) chips")
1424 title=$(gettext "Soundcard Selection")
1426 Following card(s) are found on your system.
1427 Choose a soundcard to configure:
1429 $DIALOG --title "$title" --menu "$msg" 17 76 8 "${devs_found[@]}" --output-fd 3 3> $FOUND || acex 0
1430 card=`head -n 1 $FOUND`
1431 if [ "$card" = "legacy" ]; then
1434 ac_config_card "$card"
1439 No supported PnP or PCI card found.
1441 Would you like to probe legacy ISA sound cards/chips?
1444 if $DIALOG --yesno "$msg" 9 60 ; then
1450 rm -f "$FOUND" "$DUMP"