slitaz-tools rev 7

Add 'soundconf' a modified version of alsaconf
author Christophe Lincoln <pankso@slitaz.org>
date Sun Dec 02 20:57:13 2007 +0100 (2007-12-02)
parents 023d747fe913
children cae682bb6b06
files tinyutils/soundconf
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tinyutils/soundconf	Sun Dec 02 20:57:13 2007 +0100
     1.3 @@ -0,0 +1,1178 @@
     1.4 +#!/bin/bash
     1.5 +#
     1.6 +#  ALSA Configurator - Modified for SliTaz GNU/Linux
     1.7 +#  Last modif : 20071202
     1.8 +#
     1.9 +#  Copyright (c) 1999-2002  SuSE GmbH
    1.10 +#                           Jan ONDREJ
    1.11 +#
    1.12 +#  written by Takashi Iwai <tiwai@suse.de>
    1.13 +#             Bernd Kaindl <bk@suse.de>
    1.14 +#             Jan ONDREJ (SAL) <ondrejj@salstar.sk>
    1.15 +#
    1.16 +#  based on the original version of Jan ONDREJ's alsaconf for ALSA 0.4.
    1.17 +#
    1.18 +#  This program is free software; you can redistribute it and/or modify
    1.19 +#  it under the terms of the GNU General Public License as published by
    1.20 +#  the Free Software Foundation; either version 2 of the License, or
    1.21 +#  (at your option) any later version.
    1.22 +#
    1.23 +. /etc/init.d/rc.functions
    1.24 +
    1.25 +export TEXTDOMAIN=alsaconf
    1.26 +
    1.27 +prefix=/usr
    1.28 +exec_prefix=${prefix}
    1.29 +bindir=${exec_prefix}/bin
    1.30 +sbindir=${exec_prefix}/sbin
    1.31 +version=1.0.15
    1.32 +USE_NLS=no
    1.33 +
    1.34 +# Useful for debugging
    1.35 +PROCFS="/proc"
    1.36 +SYSFS="/sys"
    1.37 +
    1.38 +# i18n stuff
    1.39 +if test "$USE_NLS" = "yes" && which gettext > /dev/null; then
    1.40 +  xecho() {
    1.41 +    gettext -s "$*"
    1.42 +  }
    1.43 +else
    1.44 +  xecho() {
    1.45 +    echo "$*"
    1.46 +  }
    1.47 +  gettext() {
    1.48 +    echo -n "$*"
    1.49 +  }
    1.50 +fi
    1.51 +xmsg() {
    1.52 +  msg=$(gettext "$1")
    1.53 +  shift
    1.54 +  printf "$msg" $*
    1.55 +}
    1.56 +
    1.57 +distribution="unknown"
    1.58 +
    1.59 +for prog in lspci lsmod; do
    1.60 +	for path in /sbin /usr/sbin /bin /usr/bin;do
    1.61 +		test -x $path/$prog && eval $prog=$path/$prog
    1.62 +	done
    1.63 +done
    1.64 +unset prog path
    1.65 +
    1.66 +usage() {
    1.67 +    xecho "ALSA configurator (modified for SliTaz GNU/Linux)"
    1.68 +    echo "  version $version"
    1.69 +    xecho "usage: alsaconf [options]
    1.70 +  -l|--legacy    check only legacy non-isapnp cards
    1.71 +  -m|--modinfo   read module descriptions instead of reading card db
    1.72 +  -s|--sound wav-file
    1.73 +                 use the specified wav file as a test sound
    1.74 +  -u|--uid uid   set the uid for the ALSA devices (default = 0) [obsoleted]
    1.75 +  -g|--gid gid   set the gid for the ALSA devices (default = 0) [obsoleted]
    1.76 +  -d|--devmode mode
    1.77 +                 set the permission for ALSA devices (default = 0666) [obs.]
    1.78 +  -r|--strict    set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]
    1.79 +  -L|--log file  logging on the specified file (for debugging purpose only)
    1.80 +  -p|--probe card-name
    1.81 +                 probe a legacy non-isapnp card and print module options
    1.82 +  -P|--listprobe list the supported legacy card modules
    1.83 +  -c|--config file
    1.84 +                 specify the module config file
    1.85 +  -R|--resources list available DMA and IRQ resources with debug for legacy
    1.86 +  -h|--help      what you're reading"
    1.87 +}
    1.88 +
    1.89 +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
    1.90 +eval set -- "$OPTS"
    1.91 +
    1.92 +do_legacy_only=0
    1.93 +use_modinfo_db=0
    1.94 +alsa_uid=0
    1.95 +alsa_gid=0
    1.96 +alsa_mode=0666
    1.97 +legacy_probe_card=""
    1.98 +LOGFILE=""
    1.99 +TESTSOUND="/usr/share/sounds/alsa/test.wav"
   1.100 +try_all_combination=0
   1.101 +resources="false"
   1.102 +
   1.103 +# legacy support
   1.104 +LEGACY_CARDS="opl3sa2 cs4236 cs4232 cs4231 es18xx es1688 sb16 sb8"
   1.105 +
   1.106 +while true ; do
   1.107 +    case "$1" in
   1.108 +    -l|--legacy)
   1.109 +	do_legacy_only=1; shift ;;
   1.110 +    -m|--modinfo)
   1.111 +	use_modinfo_db=1; shift ;;
   1.112 +    -s|--sound)
   1.113 +	TESTSOUND=$2; shift 2;;
   1.114 +    -h|--help)
   1.115 +	usage; exit 0 ;;
   1.116 +    -L|--log)
   1.117 +	LOGFILE="$2"; shift 2;;
   1.118 +    -p|--probe)
   1.119 +	legacy_probe_card="$2"; shift 2;;
   1.120 +    -P|--listprobe)
   1.121 +	echo "$LEGACY_CARDS"; exit 0;;
   1.122 +    -u|--uid)
   1.123 +	alsa_uid="$2"; shift 2;;
   1.124 +    -g|--gid)
   1.125 +	alsa_gid="$2"; shift 2;;
   1.126 +    -d|--devmode)
   1.127 +	alsa_mode="$2"; shift 2;;
   1.128 +    -r|--strict)
   1.129 +	alsa_uid=0; alsa_gid=17; alsa_mode=0660; shift;;
   1.130 +    -c|--config)
   1.131 +	cfgfile="$2"; shift 2;;
   1.132 +    -R|--resources)
   1.133 +        resources="true"; shift;;
   1.134 +    --) shift ; break ;;
   1.135 +    *) usage ; exit 1 ;;
   1.136 +    esac
   1.137 +done
   1.138 +
   1.139 +#
   1.140 +# probe legacy ISA cards
   1.141 +#
   1.142 +
   1.143 +check_dma_avail () {
   1.144 +    list=""
   1.145 +    if [ -d $SYSFS/bus/pnp/devices ]; then
   1.146 +      for dma in $*; do
   1.147 +        ok="true"
   1.148 +        for i in $SYSFS/bus/pnp/devices/??:* ; do
   1.149 +          if grep -q "state = active" $i/resources ; then
   1.150 +            if grep -q '^dma '$dma'$' $i/resources; then
   1.151 +              ok="false"
   1.152 +            fi
   1.153 +          fi
   1.154 +        done
   1.155 +        if [ -r $PROCFS/dma ]; then
   1.156 +	  if grep -q '^ *'$dma': ' $PROCFS/dma ; then
   1.157 +            ok="false"
   1.158 +          fi
   1.159 +	fi
   1.160 +        if [ "$ok" = "true" ]; then
   1.161 +          list="$list $dma"
   1.162 +        fi
   1.163 +      done
   1.164 +    else
   1.165 +      if [ -r $PROCFS/dma ]; then
   1.166 +  	for dma in $*; do
   1.167 +	    grep -q '^ *'$dma': ' $PROCFS/dma || list="$list $dma"
   1.168 +	done
   1.169 +      fi
   1.170 +    fi
   1.171 +    if [ ! -z "$list" ]; then
   1.172 +      echo $list
   1.173 +    fi
   1.174 +}
   1.175 +
   1.176 +check_irq_avail () {
   1.177 +    list=""
   1.178 +    if [ -d $SYSFS/bus/pnp/devices ]; then
   1.179 +      for irq in $*; do
   1.180 +        ok="true"
   1.181 +        for i in $SYSFS/bus/pnp/devices/??:* ; do
   1.182 +          if grep -q "state = active" $i/resources ; then
   1.183 +            if grep -q '^irq '$irq'$' $i/resources; then
   1.184 +              ok="false"
   1.185 +            fi
   1.186 +          fi
   1.187 +        done
   1.188 +        if [ -r $PROCFS/interrupts ]; then
   1.189 +	  if grep -q '^ *'$irq': ' $PROCFS/interrupts ; then
   1.190 +            ok="false"
   1.191 +          fi
   1.192 +	fi
   1.193 +        if [ "$ok" = "true" ]; then
   1.194 +          list="$list $irq"
   1.195 +        fi
   1.196 +      done
   1.197 +    else
   1.198 +      if [ -r $PROCFS/interrupts ]; then
   1.199 +	for irq in $*; do
   1.200 +	    grep -q '^ *'$irq': ' $PROCFS/interrupts || list="$list $irq"
   1.201 +	done
   1.202 +      fi
   1.203 +    fi
   1.204 +    if [ ! -z "$list" ]; then
   1.205 +      echo $list
   1.206 +    fi
   1.207 +}
   1.208 +
   1.209 +#
   1.210 +#
   1.211 +#
   1.212 +
   1.213 +if [ "$resources" = "true" ]; then
   1.214 +  if [ -d $SYSFS/bus/pnp/devices ]; then
   1.215 +    for i in $SYSFS/bus/pnp/devices/??:* ; do
   1.216 +      if [ "$resources" = "true" ]; then
   1.217 +        echo ">>>>> PnP file: $i/resources"
   1.218 +        cat $i/resources
   1.219 +      fi
   1.220 +    done
   1.221 +  fi
   1.222 +  if [ -r $PROCFS/dma ]; then
   1.223 +    echo ">>>>> Allocated dma channels:"
   1.224 +    cat $PROCFS/dma
   1.225 +  fi
   1.226 +  if [ -r $PROCFS/interrupts ]; then
   1.227 +    echo ">>>>> Allocated interrupt channels:"
   1.228 +    cat $PROCFS/interrupts
   1.229 +  fi
   1.230 +  echo -n "Valid DMA channels: "
   1.231 +  check_dma_avail 0 1 2 3 4 5 6 7
   1.232 +  echo -n "Valid IRQ channels: "
   1.233 +  check_irq_avail 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
   1.234 +  exit 0
   1.235 +fi
   1.236 +
   1.237 +# Check for root privileges
   1.238 +if [ `id -u` -ne 0 ]; then
   1.239 +  xecho "You must be root to use this script."
   1.240 +  exit 1
   1.241 +fi
   1.242 +
   1.243 +#
   1.244 +# check the snd_ prefix for ALSA module options
   1.245 +# snd_ prefix is obsoleted since 0.9.0rc4.
   1.246 +#
   1.247 +if /sbin/modinfo -p snd | grep -q snd_ ; then
   1.248 +  mpfx="snd_"
   1.249 +else
   1.250 +  mpfx=""
   1.251 +fi
   1.252 +
   1.253 +alsa_device_opts=""
   1.254 +if /sbin/modinfo -p snd | grep -q uid ; then
   1.255 +  if [ x"$alsa_uid" != x0 ]; then
   1.256 +    alsa_device_opts="$alsa_device_opts ${mpfx}device_uid=$alsa_uid"
   1.257 +  fi
   1.258 +  if [ x"$alsa_gid" != x0 ]; then
   1.259 +    alsa_device_opts="$alsa_device_opts ${mpfx}device_gid=$alsa_gid"
   1.260 +  fi
   1.261 +fi
   1.262 +if /sbin/modinfo -p snd | grep -q device_mode ; then
   1.263 +  if [ x"$alsa_mode" != x0 ]; then
   1.264 +    alsa_device_opts="$alsa_device_opts ${mpfx}device_mode=$alsa_mode"
   1.265 +  fi
   1.266 +fi
   1.267 +
   1.268 +case `uname -r` in
   1.269 +2.6.*)
   1.270 +  kernel="new"
   1.271 +  ;;
   1.272 +*)
   1.273 +  kernel="old"
   1.274 +  ;;
   1.275 +esac
   1.276 +
   1.277 +# cfgfile = base config file to remove/update the sound setting
   1.278 +cfgfile="/etc/modprobe.conf"
   1.279 +
   1.280 +# Check for dialog
   1.281 +if which dialog > /dev/null; then
   1.282 +    DIALOG=dialog
   1.283 +else
   1.284 +	xecho "Error, dialog or whiptail not found."
   1.285 +    exit 1
   1.286 +fi
   1.287 +
   1.288 +#
   1.289 +# remove the previous configuration by alsaconf
   1.290 +#
   1.291 +remove_ac_block() {
   1.292 +    awk '/^'"$ACB"'$/,/^'"$ACE"'$/ { next } { print }'
   1.293 +}
   1.294 +
   1.295 +#
   1.296 +# set default mixer volumes
   1.297 +#
   1.298 +set_mixers() {
   1.299 +    amixer -s -q <<EOF
   1.300 +set Master 75% unmute
   1.301 +set Master -12dB
   1.302 +set 'Master Mono' 75% unmute
   1.303 +set 'Master Mono' -12dB
   1.304 +set Front 75% unmute
   1.305 +set Front -12dB
   1.306 +set PCM 90% unmute
   1.307 +set PCM 0dB
   1.308 +mixer Synth 90% unmute
   1.309 +mixer Synth 0dB
   1.310 +mixer CD 90% unmute
   1.311 +mixer CD 0dB
   1.312 +# mute mic
   1.313 +set Mic 0% mute
   1.314 +# ESS 1969 chipset has 2 PCM channels
   1.315 +set PCM,1 90% unmute
   1.316 +set PCM,1 0dB
   1.317 +# Trident/YMFPCI/emu10k1
   1.318 +set Wave 100% unmute
   1.319 +set Music 100% unmute
   1.320 +set AC97 100% unmute
   1.321 +# CS4237B chipset:
   1.322 +set 'Master Digital' 75% unmute
   1.323 +# Envy24 chips with analog outs
   1.324 +set DAC 90% unmute
   1.325 +set DAC -12dB
   1.326 +set DAC,0 90% unmute
   1.327 +set DAC,0 -12dB
   1.328 +set DAC,1 90% unmute
   1.329 +set DAC,1 -12dB
   1.330 +# some notebooks use headphone instead of master
   1.331 +set Headphone 75% unmute
   1.332 +set Headphone -12dB
   1.333 +set Playback 100% unmute
   1.334 +# turn off digital switches
   1.335 +set "SB Live Analog/Digital Output Jack" off
   1.336 +set "Audigy Analog/Digital Output Jack" off
   1.337 +EOF
   1.338 +}
   1.339 +
   1.340 +# FAREWELL
   1.341 +farewell() {
   1.342 +  local msg=$(gettext "
   1.343 +
   1.344 +     OK, sound driver is configured.
   1.345 +
   1.346 +                  ALSA  CONFIGURATOR
   1.347 +
   1.348 +          will prepare the card for playing now.
   1.349 +
   1.350 +     Now I'll run alsasound init script, then I'll use
   1.351 +     amixer to raise the default volumes.
   1.352 +     You can change the volume later via a mixer
   1.353 +     program such as alsamixer or gamix.
   1.354 +  
   1.355 +  ")
   1.356 +  $DIALOG --msgbox "$msg" 17 60 || acex 0
   1.357 +}
   1.358 +
   1.359 +# Exit function
   1.360 +acex() {
   1.361 +  cleanup
   1.362 +  clear
   1.363 +  exit $1
   1.364 +}
   1.365 +
   1.366 +#
   1.367 +# alsasound init script
   1.368 +#
   1.369 +
   1.370 +#rcalsasound=/etc/init.d/alsa
   1.371 +rcalsasound=rcalsasound
   1.372 +
   1.373 +# MAIN
   1.374 +if [ -d $PROCFS/asound ]; then
   1.375 +  $rcalsasound stop >/dev/null 2>&1
   1.376 +  $rcalsasound unload >/dev/null 2>&1
   1.377 +  /sbin/rmmod dmasound dmasound_awacs 2>/dev/null
   1.378 +fi
   1.379 +
   1.380 +
   1.381 +cleanup () {
   1.382 +    killall -9 aplay arecord >/dev/null 2>&1
   1.383 +    /sbin/modprobe -r isapnp >/dev/null 2>&1
   1.384 +    /sbin/modprobe -r isa-pnp >/dev/null 2>&1
   1.385 +    rm -f "$TMP" "$addcfg" "$FOUND" "$DUMP"
   1.386 +}
   1.387 +trap cleanup 0 
   1.388 +
   1.389 +TMP=`mktemp -q /tmp/alsaconf.XXXXXX`
   1.390 +if [ $? -ne 0 ]; then
   1.391 +	xecho "Can't create temp file, exiting..."
   1.392 +        exit 1
   1.393 +fi
   1.394 +addcfg=`mktemp -q /tmp/alsaconf.XXXXXX`
   1.395 +if [ $? -ne 0 ]; then
   1.396 +	xecho "Can't create temp file, exiting..."
   1.397 +        exit 1
   1.398 +fi
   1.399 +FOUND=`mktemp -q /tmp/alsaconf.XXXXXX`
   1.400 +if [ $? -ne 0 ]; then
   1.401 +	xecho "Can't create temp file, exiting..."
   1.402 +        exit 1
   1.403 +fi
   1.404 +DUMP=`mktemp -q /tmp/alsaconf.XXXXXX`
   1.405 +if [ $? -ne 0 ]; then
   1.406 +	xecho "Can't create temp file, exiting..."
   1.407 +        exit 1
   1.408 +fi
   1.409 +
   1.410 +# convert ISA PnP id number to string 'ABC'
   1.411 +convert_isapnp_id () {
   1.412 +    if [ -z "$1" ]; then
   1.413 +	echo "XXXX"
   1.414 +	return
   1.415 +    fi
   1.416 +    let a='('$1'>>2) & 0x3f'
   1.417 +    let b='(('$1' & 0x03) << 3) | (('$1' >> 13) & 0x07)'
   1.418 +    let c='('$1'>> 8) & 0x1f'
   1.419 +    strs='@ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   1.420 +    echo ${strs:$a:1}${strs:$b:1}${strs:$c:1}
   1.421 +}
   1.422 +
   1.423 +# swap high & low bytes
   1.424 +swap_number () {
   1.425 +    if [ -z "$1" ]; then
   1.426 +	echo "0000"
   1.427 +	return
   1.428 +    fi
   1.429 +    let v='(('$1'>>8)&0xff)|(('$1'&0xff)<<8)'
   1.430 +    printf "%04x" $v
   1.431 +}
   1.432 +
   1.433 +# build card database
   1.434 +# build_card_db filename
   1.435 +build_card_db () {
   1.436 +    MODDIR=/lib/modules/`uname -r`
   1.437 +    last_driver=""
   1.438 +    echo -n > $1
   1.439 +
   1.440 +    # list pci cards
   1.441 +    while read driver vendor device dummy; do
   1.442 +	if expr $driver : 'snd-.*' >/dev/null ; then
   1.443 +	    if [ "$last_driver" != "$driver" ]; then
   1.444 +		echo $driver.o
   1.445 +		last_driver=$driver
   1.446 +	    fi
   1.447 +	    id1=`printf '0x%04x' $vendor`
   1.448 +	    id2=`printf '0x%04x' $device`
   1.449 +	    echo "PCI: $id1=$id2"
   1.450 +	fi
   1.451 +    done < $MODDIR/modules.pcimap >> $1
   1.452 +
   1.453 +    # list isapnp cards
   1.454 +    while read driver cardvendor carddevice data vendor func; do
   1.455 +	if expr $driver : 'snd-.*' >/dev/null ; then
   1.456 +	    if [ "$last_driver" != "$driver" ]; then
   1.457 +		echo $driver.o
   1.458 +		last_driver=$driver
   1.459 +	    fi
   1.460 +	    id1=`convert_isapnp_id $cardvendor`
   1.461 +	    dev1=`swap_number $carddevice`
   1.462 +	    id2=`convert_isapnp_id $vendor`
   1.463 +	    dev2=`swap_number $func`
   1.464 +	    echo "ISAPNP: $id1$dev1=$id2$dev2"
   1.465 +	fi
   1.466 +    done < $MODDIR/modules.isapnpmap >> $1
   1.467 +}
   1.468 +
   1.469 +#
   1.470 +# probe cards
   1.471 +#
   1.472 +probe_cards () {
   1.473 +    found="0"
   1.474 +    test -r $PROCFS/isapnp || /sbin/modprobe isapnp >/dev/null 2>&1
   1.475 +    test -r $PROCFS/isapnp || /sbin/modprobe isa-pnp >/dev/null 2>&1
   1.476 +    if [ -r $PROCFS/isapnp ]; then
   1.477 +	cat $PROCFS/isapnp >"$DUMP"
   1.478 +	found="1"
   1.479 +    elif [ -d $SYSFS/bus/pnp/devices ]; then
   1.480 +	# use 2.6 kernel's sysfs output
   1.481 +	# fake the isapnp dump
   1.482 +	index=0
   1.483 +	bindex=0
   1.484 +	for d1 in $SYSFS/devices/pnp* ; do
   1.485 +	  for d2 in $d1/*:* ; do
   1.486 +	    if [ -r $d2/card_id ]; then
   1.487 +	      id=`cat $d2/card_id`
   1.488 +	      name=`cat $d2/name`
   1.489 +	      echo "Card $index '$id:$name' " >> "$DUMP"
   1.490 +	      index=$[$index+1]
   1.491 +	      found="1"
   1.492 +	    else if [ -r $d2/id ]; then
   1.493 +	      # FIXME: multiple id might be present (separated with new-line)
   1.494 +	      id=`head -n 1 $d2/id`
   1.495 +	      echo "BIOS $bindex '$id' " >> "$DUMP"
   1.496 +	      bindex=$[$bindex+1]
   1.497 +	      found="1"
   1.498 +	    fi
   1.499 +	    fi
   1.500 +	  done
   1.501 +	done
   1.502 +    fi
   1.503 +    if [ "$found" = "0" ]; then
   1.504 +      echo -n >"$DUMP"
   1.505 +    fi 
   1.506 +    CARDID_DB=/var/tmp/alsaconf.cards
   1.507 +    if [ ! -r $CARDID_DB ]; then
   1.508 +        use_modinfo_db=1
   1.509 +    fi
   1.510 +    if [ $use_modinfo_db != 1 ]; then
   1.511 +	if [ $CARDID_DB -ot /lib/modules/`uname -r`/modules.dep ]; then
   1.512 +	    use_modinfo_db=1
   1.513 +	fi
   1.514 +    fi
   1.515 +    if [ $use_modinfo_db = 1 ]; then
   1.516 +	xecho "Building card database.."
   1.517 +	build_card_db $CARDID_DB
   1.518 +    fi
   1.519 +    if [ ! -r $CARDID_DB ]; then
   1.520 +	xecho "No card database is found.."
   1.521 +	exit 1
   1.522 +    fi
   1.523 +    ncards=`grep '^snd-.*\.o$' $CARDID_DB | wc -w`
   1.524 +
   1.525 +    msg=$(gettext "Searching sound cards")
   1.526 +    awk '
   1.527 +BEGIN {
   1.528 +	format="%-40s %s\n";
   1.529 +	ncards='"$ncards"';
   1.530 +	idx=0;
   1.531 +}
   1.532 +/^snd-.*\.o$/{
   1.533 +	sub(/.o$/, "");
   1.534 +	driver=$0;
   1.535 +	perc=(idx * 100) / (ncards + 1);
   1.536 +	print int(perc);
   1.537 +	idx++;
   1.538 +}
   1.539 +/^[<literal space><literal tab>]*PCI: /{
   1.540 +	gsub(/0x/, "");
   1.541 +	gsub(/=/, ":");
   1.542 +	x = sprintf ("'$lspci' -n 2>/dev/null| grep '"' 04..: '"' | grep %s", $2);
   1.543 +	if (system (x) == 0)
   1.544 +		printf "%s %s\n", $2, driver >>"'"$FOUND"'"
   1.545 +}
   1.546 +/^[<literal space><literal tab>]*ISAPNP: /{
   1.547 +	id2 = substr($0, index($0, "=")+1);
   1.548 +	gsub(/=.*/, "");
   1.549 +	x = sprintf ("grep '\''^Card [0-9] .%s:'\'' '"$DUMP"'", $2);
   1.550 +	if (system (x) == 0)
   1.551 +		printf "%s %s\n", $2, driver >>"'"$FOUND"'"
   1.552 +	else if (index($2, "ffff") > 0) {
   1.553 +		x = sprintf ("grep '\''^BIOS [0-9]* .%s.'\'' '"$DUMP"'", id2);
   1.554 +		if (system (x) == 0)
   1.555 +			printf "%s %s\n", id2, driver >>"'"$FOUND"'"
   1.556 +	}
   1.557 +}' < $CARDID_DB |\
   1.558 +    $DIALOG --gauge "$msg" 6 40 0
   1.559 +
   1.560 +    #
   1.561 +    # PowerMac
   1.562 +    #
   1.563 +    if grep -q MacRISC $PROCFS/cpuinfo; then
   1.564 +	MODDIR=/lib/modules/`uname -r`
   1.565 +	find $MODDIR -name 'snd-powermac*' -print | \
   1.566 +	while read i; do
   1.567 +	    i=${i##*/}
   1.568 +	    i=${i%%.o}
   1.569 +	    i=${i%%.ko}
   1.570 +	    echo "PowerMac $i" >> $FOUND
   1.571 +	done
   1.572 +    fi
   1.573 +
   1.574 +    #
   1.575 +    # Sparc
   1.576 +    #
   1.577 +    if grep -q Sparc $PROCFS/cpuinfo; then
   1.578 +	test -r $PROCFS/openprom/name || /bin/mount -t openpromfs none $PROCFS/openprom >/dev/null 2>&1
   1.579 +	# Check for an "audio" device
   1.580 +	audio=
   1.581 +	compat=
   1.582 +	if test -r $PROCFS/openprom; then
   1.583 +	    audio=`find $PROCFS/openprom -follow -type d -name "audio*" -print`
   1.584 +	fi
   1.585 +	if test -n "$audio"; then
   1.586 +	    compat=`cat $audio/compatible`
   1.587 +	    compat=${compat#\'}
   1.588 +	    compat=${compat%\'}
   1.589 +	    compat=${compat#SUNW,}
   1.590 +	fi
   1.591 +	# Go through all cards we have
   1.592 +	MODDIR=/lib/modules/`uname -r`
   1.593 +	find $MODDIR -name 'snd-sun-*' -print | \
   1.594 +	while read i; do
   1.595 +	    i=${i##*/}
   1.596 +	    i=${i%%.o}
   1.597 +	    i=${i%%.ko}
   1.598 +	    sdev=`echo ${i#snd-sun-} | tr "[a-z]" "[A-Z]"`
   1.599 +
   1.600 +	    if test "$sdev" = "$compat"; then
   1.601 +		echo "$sdev $i" >> $FOUND
   1.602 +	    elif test -r $PROCFS/openprom; then
   1.603 +		find $PROCFS/openprom -follow -type d -name "SUNW,${sdev}*" \
   1.604 +		    -exec echo "$sdev $i" \; 2>/dev/null >> $FOUND
   1.605 +	    else
   1.606 +		echo "$sdev $i" >> $FOUND
   1.607 +	    fi
   1.608 +	done
   1.609 +    fi
   1.610 +}
   1.611 +
   1.612 +#
   1.613 +# look for a descriptive device name from the given device id
   1.614 +#
   1.615 +find_device_name () {
   1.616 +    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
   1.617 +	$lspci -d $1 2>/dev/null| sed -e 's/^.*:..\.. [^:]*: //g'
   1.618 +	return
   1.619 +    elif expr "$1" : '[A-Z@][A-Z@][A-Z@][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then
   1.620 +	cardname=`grep '^Card [0-9]\+ .'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`
   1.621 +	echo $cardname
   1.622 +    else
   1.623 +	echo $1
   1.624 +    fi
   1.625 +}
   1.626 +
   1.627 +# get hwcfg file type from the given driver name
   1.628 +get_hwcfg_type () {
   1.629 +    while read dev driver; do
   1.630 +	if [ "$driver" = "$1" ]; then
   1.631 +	    case "$dev" in
   1.632 +	    *:*)
   1.633 +		# FIXME: need to look around /sys/bus/pci/* (or use vpid-* ?)
   1.634 +		devid=`$lspci -d "$dev" | head -n 1 | sed -e 's/ .*$//'`
   1.635 +		case "$devid" in
   1.636 +		*:*:*.*) ;;
   1.637 +		*) devid="0000:$devid" ;;
   1.638 +		esac
   1.639 +		echo bus-pci-$devid
   1.640 +		;;
   1.641 +	    *)
   1.642 +		echo $driver
   1.643 +		;;
   1.644 +	    esac
   1.645 +	    break
   1.646 +	fi
   1.647 +    done
   1.648 +}
   1.649 +
   1.650 +# clean up all hwcfg-* files containing ALSA modules
   1.651 +# alsaconf sets up exclusively
   1.652 +cleanup_hwcfg () {
   1.653 +    for i in /etc/sysconfig/hardware/hwcfg-*; do
   1.654 +	grep -q "MODULE='snd-" $i && rm -f $i
   1.655 +    done
   1.656 +}
   1.657 +
   1.658 +#
   1.659 +# set up /etc/sysconfig/hardware/hwcfg-* stuff
   1.660 +#
   1.661 +setup_hwcfg () {
   1.662 +    card=$1
   1.663 +    cleanup_hwcfg
   1.664 +    cfg=`echo "$devs_olist" | get_hwcfg_type $card`
   1.665 +    echo "MODULE='$card'" > /etc/sysconfig/hardware/hwcfg-$cfg
   1.666 +    echo "STARTMODE='auto'" >> /etc/sysconfig/hardware/hwcfg-$cfg
   1.667 +}
   1.668 +
   1.669 +
   1.670 +#
   1.671 +# Configure sound card and set mixer for SliTaz Live mode
   1.672 +#
   1.673 +ac_config_card () {
   1.674 +
   1.675 +    CARD_DRIVER=snd-$1
   1.676 +    CARD_OPTS="${*:2}"
   1.677 +	SOUND_CORE="snd"
   1.678 +
   1.679 +	# Keep card driver name in /var/lib to be used by boot scripts.
   1.680 +	echo $CARD_DRIVER > /var/lib/sound-card-driver
   1.681 +
   1.682 +	echo -n "Loading drivers : $CARD_DRIVER"
   1.683 +	modprobe $CARD_DRIVER
   1.684 +	sleep 1 && status
   1.685 +	
   1.686 +	# Sed /etc/rcS.conf to add driver in LOAD_MODULES
   1.687 +	. /etc/rcS.conf
   1.688 +	modules=`echo "$LOAD_MODULES" | sed s/$CARD_DRIVER//`
   1.689 +	newmods="$modules $CARD_DRIVER"
   1.690 +	sed -i s/"LOAD_MODULES=\"$LOAD_MODULES\""/"LOAD_MODULES=\"$newmods\""/ \
   1.691 +		/etc/rcS.conf
   1.692 +	
   1.693 +	# Set default mixer volumes
   1.694 +	echo -n "Setting default mixers volumes..."
   1.695 +	set_mixers
   1.696 +	status
   1.697 +
   1.698 +	# Store
   1.699 +	alsactl store
   1.700 +	
   1.701 +    echo -e "
   1.702 +* Now ALSA is ready to use.
   1.703 +* For adjustment of volumes, use your favorite mixer.
   1.704 +* Have a lot of fun!\n"
   1.705 +}
   1.706 +
   1.707 +# check playback
   1.708 +# return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
   1.709 +ac_try_load () {
   1.710 +    test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
   1.711 +    /sbin/modprobe snd-$1 ${*:2} >/dev/null 2>&1
   1.712 +    if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then
   1.713 +	: ;
   1.714 +    else
   1.715 +	/sbin/modprobe -r snd-$1 >/dev/null 2>&1
   1.716 +	return 1
   1.717 +    fi
   1.718 +
   1.719 +    # mute mixers
   1.720 +    amixer set Master 0% mute >/dev/null 2>&1
   1.721 +    amixer set PCM 0% mute >/dev/null 2>&1
   1.722 +    
   1.723 +    # output 0.5 sec
   1.724 +    head -c 4000 < /dev/zero | aplay -N -r8000 -fS16_LE -traw -c1 > /dev/null 2>&1 &
   1.725 +    # remember pid
   1.726 +    pp=$!
   1.727 +    # sleep for 2 seconds (to be sure -- 1 sec would be enough)
   1.728 +    sleep 2
   1.729 +    # kill the child process if still exists.
   1.730 +    kill -9 $pp > /dev/null 2>&1
   1.731 +    st=$?
   1.732 +    ac_cardname=`head -n 1 $PROCFS/asound/cards | sed -e 's/^[0-9].* - \(.*\)$/\1/'`
   1.733 +    /sbin/modprobe -r snd-$1 >/dev/null 2>&1
   1.734 +    if [ $st = 0 ]; then
   1.735 +	# irq problem?
   1.736 +	test -n "$LOGFILE" && echo "no playback return" >> "$LOGFILE"
   1.737 +	return 2
   1.738 +    else
   1.739 +	# seems ok!
   1.740 +	test -n "$LOGFILE" && echo "playback OK" >> "$LOGFILE"
   1.741 +	return 0
   1.742 +    fi
   1.743 +}
   1.744 +
   1.745 +# check capture
   1.746 +# return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
   1.747 +# ac_try_capture card duplex opts
   1.748 +ac_try_capture () {
   1.749 +    test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
   1.750 +    /sbin/modprobe snd-$1 ${*:3} >/dev/null 2>&1
   1.751 +    if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then
   1.752 +	: ;
   1.753 +    else
   1.754 +	/sbin/modprobe -r snd-$1 >/dev/null 2>&1
   1.755 +	return 1
   1.756 +    fi
   1.757 +
   1.758 +    # mute mixers
   1.759 +    amixer set Master 0% mute >/dev/null 2>&1
   1.760 +    amixer set PCM 0% mute >/dev/null 2>&1
   1.761 +
   1.762 +    play_pid=0
   1.763 +    if [ $2 = yes ]; then
   1.764 +	# try duplex - start dummy playing
   1.765 +	aplay -N -r8000 -fS16_LE -traw -c1 < /dev/zero > /dev/null 2>&1 &
   1.766 +	play_pid=$!
   1.767 +    fi
   1.768 +    # record 1sec
   1.769 +    arecord -N -d1 > /dev/null 2>&1 &
   1.770 +    # remember pid
   1.771 +    pp=$!
   1.772 +    # sleep for 2 seconds
   1.773 +    sleep 2
   1.774 +    # kill the child process if still exists.
   1.775 +    kill -9 $pp > /dev/null 2>&1
   1.776 +    st=$?
   1.777 +    # kill playback process if any
   1.778 +    test $play_pid != 0 && kill -9 $play_pid
   1.779 +    /sbin/modprobe -r snd-$1 >/dev/null 2>&1
   1.780 +    if [ $st = 0 ]; then
   1.781 +	test -n "$LOGFILE" && echo "capture no return" >> "$LOGFILE"
   1.782 +	return 2
   1.783 +    else
   1.784 +	test -n "$LOGFILE" && echo "capture OK" >> "$LOGFILE"
   1.785 +	return 0
   1.786 +    fi
   1.787 +}
   1.788 +
   1.789 +get_dma_pair () {
   1.790 +    case $1 in
   1.791 +    0)
   1.792 +	echo 1 3 5;;
   1.793 +    1)
   1.794 +	echo 0 3 5;;
   1.795 +    3)
   1.796 +	echo 1 0 5;;
   1.797 +    5)
   1.798 +	echo 3 1 0;;
   1.799 +    esac
   1.800 +}
   1.801 +
   1.802 +#
   1.803 +# check playback on specified irqs
   1.804 +#
   1.805 +# ac_try_irq card opts irqs...
   1.806 +# return 0 - OK, 1 - NG, 2 - not working (dma problem?)
   1.807 +#
   1.808 +ac_try_irq () {
   1.809 +    card=$1
   1.810 +    opts="$2 ${mpfx}irq=$3"
   1.811 +    ac_try_load $card $opts >/dev/null 2>&1
   1.812 +    result=$?
   1.813 +    case $result in
   1.814 +    0)
   1.815 +	ac_opts="$opts"
   1.816 +	return 0
   1.817 +	;;
   1.818 +    2)
   1.819 +	for irq in ${*:4}; do
   1.820 +	    opts="$2 ${mpfx}irq=$irq"
   1.821 +	    ac_try_load $card $opts >/dev/null 2>&1
   1.822 +	    if [ $? = 0 ]; then
   1.823 +		ac_opts="$opts"
   1.824 +		return 0
   1.825 +	    fi
   1.826 +	done
   1.827 +	return 2
   1.828 +	;;
   1.829 +    esac
   1.830 +    return 1
   1.831 +}
   1.832 +
   1.833 +#
   1.834 +# check playback/capture on dma1 & dma2 & specified irqs
   1.835 +#
   1.836 +# ac_try_dmas card opts irqs...
   1.837 +# return 0 - OK, 1 - NG
   1.838 +#
   1.839 +ac_try_dmas () {
   1.840 +    dma_list=`check_dma_avail 1 0 3 5`
   1.841 +    for irq in ${*:3}; do
   1.842 +	for dma1 in $dma_list; do
   1.843 +	    for dma2 in `get_dma_pair $dma1`; do
   1.844 +		opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq"
   1.845 +		ac_try_load $1 $opts >/dev/null 2>&1
   1.846 +		result=$?
   1.847 +		if [ $result = 1 ]; then
   1.848 +		    if [ $try_all_combination = 1 ]; then
   1.849 +			continue
   1.850 +		    else
   1.851 +			return 1
   1.852 +		    fi
   1.853 +		elif [ $result = 0 ]; then
   1.854 +		    test -n "$LOGFILE" && echo "Now checking capture..." >> "$LOGFILE"
   1.855 +		    ac_opts="$opts"
   1.856 +		    ac_try_capture $1 yes $opts >/dev/null 2>&1 && return 0
   1.857 +		    for d in yes no; do
   1.858 +			for dma2 in $dma_list; do
   1.859 +			    if [ $dma1 != $dma2 ]; then
   1.860 +				opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq"
   1.861 +				ac_opts="$opts"
   1.862 +				ac_try_capture $1 $d $opts >/dev/null 2>&1 && return 0
   1.863 +			    fi
   1.864 +			done
   1.865 +		    done
   1.866 +		    return 0
   1.867 +		fi
   1.868 +	    done
   1.869 +	done
   1.870 +    done
   1.871 +    return 1
   1.872 +}
   1.873 +
   1.874 +# check if the option $2 exists in card $1: set value $3
   1.875 +ac_check_option () {
   1.876 +    if /sbin/modinfo -p snd-$1 | grep -q $2; then
   1.877 +      echo "$2=$3"
   1.878 +    fi
   1.879 +}
   1.880 +
   1.881 +ac_try_card_sb8 () {
   1.882 +    card=sb8
   1.883 +    irq_list=`check_irq_avail 5 3 9 10 7`
   1.884 +    for dma8 in `check_dma_avail 1 3`; do
   1.885 +	opts="${mpfx}dma8=$dma8"
   1.886 +	ac_try_irq $card "$opts" $irq_list && return 0
   1.887 +    done
   1.888 +    return 1
   1.889 +}
   1.890 +
   1.891 +ac_try_card_sb16 () {
   1.892 +    card=sb16
   1.893 +    isapnp=`ac_check_option $card ${mpfx}isapnp 0`
   1.894 +    opts="$isapnp"
   1.895 +    irq_list=`check_irq_avail 5 9 10 7 3`
   1.896 +    dma_list=`check_dma_avail 0 1 3`
   1.897 +    dma16_list=`check_dma_avail 5 6 7`
   1.898 +    # at first try auto-probing by driver itself
   1.899 +    ac_try_load $card $opts >/dev/null 2>&1
   1.900 +    result=$?
   1.901 +    case $result in
   1.902 +    0)
   1.903 +	ac_opts="$opts"
   1.904 +	ac_try_capture $card yes $opts >/dev/null 2>&1 && return 0
   1.905 +	for d in yes no; do
   1.906 +	    for dma8 in $dma_list; do
   1.907 +		for irq in $irq_list; do
   1.908 +		    opts="${mpfx}dma8=$dma8 ${mpfx}irq=$irq $isapnp"
   1.909 +		    ac_try_capture $card $d $opts >/dev/null 2>&1 && return 0
   1.910 +		done
   1.911 +	    done
   1.912 +	done
   1.913 +	return 0
   1.914 +	;;
   1.915 +    2)
   1.916 +	for dma16 in $dma16_list; do
   1.917 +	    opts="${mpfx}dma16=$dma16 $isapnp"
   1.918 +	    if ac_try_irq $card "$opts" $irq_list ; then
   1.919 +		ac_try_capture $card yes $ac_opts >/dev/null 2>&1 && return 0
   1.920 +		ac_opts_saved="$ac_opts"
   1.921 +		for d in yes no; do
   1.922 +		    for dma8 in $dma_list; do
   1.923 +			ac_opts="$ac_opts_saved ${mpfx}dma8=$dma8"
   1.924 +			ac_try_capture $card $d $ac_opts >/dev/null 2>&1 && return 0
   1.925 +		    done
   1.926 +		done
   1.927 +		# return anyway here..
   1.928 +		return 0
   1.929 +	    fi
   1.930 +	done
   1.931 +	;;
   1.932 +    esac
   1.933 +    return 1
   1.934 +}
   1.935 +
   1.936 +ac_try_card_es1688 () {
   1.937 +    card=es1688
   1.938 +    opts=""
   1.939 +    irq_list=`check_irq_avail 5 9 10 7`
   1.940 +    for dma8 in `check_dma_avail 1 3 0`; do
   1.941 +	opts="${mpfx}dma8=$dma8 ${mpfx}mpu_irq=-1"
   1.942 +	ac_try_irq $card "$opts" $irq_list && return 0
   1.943 +    done
   1.944 +    return 1
   1.945 +}
   1.946 +
   1.947 +ac_try_card_es18xx () {
   1.948 +    card=es18xx
   1.949 +    opts=`ac_check_option $card ${mpfx}isapnp 0`
   1.950 +    ac_try_dmas $card "$opts" `check_irq_avail 5 9 10 7` && return 0
   1.951 +    return 1
   1.952 +}
   1.953 +
   1.954 +ac_try_card_cs4236 () {
   1.955 +    card=cs4236
   1.956 +    irq_list=`check_irq_avail 5 7 9 11 12 15`
   1.957 +    isapnp=`ac_check_option $card ${mpfx}isapnp 0`
   1.958 +    for cport in 0x538 0x210 0xf00; do
   1.959 +	for port in 0x530 0x534; do
   1.960 +	    opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp"
   1.961 +	    ac_try_dmas $card "$opts" $irq_list && return 0
   1.962 +	done
   1.963 +    done
   1.964 +    return 1
   1.965 +}
   1.966 +
   1.967 +ac_try_card_cs4232 () {
   1.968 +    card=cs4232
   1.969 +    irq_list=`check_irq_avail 5 7 9 11 12 15`
   1.970 +    isapnp=`ac_check_option $card ${mpfx}isapnp 0`
   1.971 +    for cport in 0x538 0x210 0xf00; do
   1.972 +	for port in 0x530 0x534; do
   1.973 +	    opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp"
   1.974 +	    ac_try_dmas $card "$opts" $irq_list && return 0
   1.975 +	done
   1.976 +    done
   1.977 +    return 1
   1.978 +}
   1.979 +
   1.980 +ac_try_card_cs4231 () {
   1.981 +    card=cs4231
   1.982 +    irq_list=`check_irq_avail 5 7 9 11 12 15`
   1.983 +    for port in 0x530 0x534; do
   1.984 +	opts="${mpfx}port=$port"
   1.985 +	ac_try_dmas $card "$opts" $irq_list && return 0
   1.986 +    done
   1.987 +    return 1
   1.988 +}
   1.989 +
   1.990 +ac_try_card_opl3sa2 () {
   1.991 +    card=opl3sa2
   1.992 +    irq_list=`check_irq_avail 5 9 3 1 11 12 15 0`
   1.993 +    isapnp=`ac_check_option $card ${mpfx}isapnp 0`
   1.994 +    for port in 0x370 0x538 0xf86 0x100; do
   1.995 +	for wss_port in 0x530 0xe80 0xf40 0x604; do
   1.996 +	    opts="${mpfx}fm_port=-1 ${mpfx}midi_port=-1 ${mpfx}port=$port ${mpfx}wss_port=$wss_port $isapnp"
   1.997 +	    ac_try_dmas $card "$opts" $irq_list && return 0
   1.998 +	done
   1.999 +    done
  1.1000 +    return 1
  1.1001 +}
  1.1002 +
  1.1003 +ac_config_legacy () {
  1.1004 +   title=$(gettext "WARNING")
  1.1005 +   msg=$(gettext "
  1.1006 +   Probing legacy ISA cards might make
  1.1007 +   your system unstable.
  1.1008 +
  1.1009 +        Do you want to proceed?
  1.1010 +
  1.1011 +")
  1.1012 +    $DIALOG --title "$title" --yesno "$msg" 10 50 || acex 0
  1.1013 +
  1.1014 +    if [ x"$1" = x ]; then
  1.1015 +	probe_list="$LEGACY_CARDS"
  1.1016 +    else
  1.1017 +	probe_list=$*
  1.1018 +    fi
  1.1019 +    menu_args=()
  1.1020 +
  1.1021 +    for card in $probe_list; do
  1.1022 +	cardname=`/sbin/modinfo -d snd-$card | sed -e 's/^\"\(.*\)\"$/\1/g'`
  1.1023 +	if [ x"$cardname" != x ]; then
  1.1024 +	    menu_args=("${menu_args[@]}" "$card" "$cardname" "on")
  1.1025 +	fi
  1.1026 +    done
  1.1027 +    if [ x$menu_args = x ]; then
  1.1028 +	msg=$(gettext "No legacy drivers are available
  1.1029 +   for your machine")
  1.1030 +	$DIALOG --msgbox "$msg" 5 50
  1.1031 +	return 1
  1.1032 +    fi
  1.1033 +    title=$(gettext "Driver Selection")
  1.1034 +    msg=$(gettext "           Probing legacy ISA cards
  1.1035 +
  1.1036 +        Please select the drivers to probe:")
  1.1037 +    $DIALOG --title "$title" --checklist "$msg" \
  1.1038 +	17 64 8 "${menu_args[@]}" 2> $FOUND || acex 0
  1.1039 +
  1.1040 +    if [ $try_all_combination != 1 ]; then
  1.1041 +	msg=$(gettext "
  1.1042 + Shall I try all possible DMA and IRQ combinations?
  1.1043 + With this option, some unconventional configuration
  1.1044 + might be found, but it will take much longer time.")
  1.1045 +	if $DIALOG --yesno "$msg" 10 60
  1.1046 +	    then
  1.1047 +	    try_all_combination=1
  1.1048 +	fi
  1.1049 +    fi
  1.1050 +
  1.1051 +    xecho "Probing legacy cards..   This may take a few minutes.."
  1.1052 +    echo -n $(gettext "Probing: ")
  1.1053 +    cards=`cat $FOUND | tr -d \"`
  1.1054 +    for card in $cards; do
  1.1055 +	echo -n " $card"
  1.1056 +	ac_opts=""
  1.1057 +	if eval ac_try_card_$card ; then
  1.1058 +	    xecho " : FOUND!!"
  1.1059 +	    ac_config_card $card $ac_opts
  1.1060 +	    return 0
  1.1061 +	fi
  1.1062 +    done
  1.1063 +    echo
  1.1064 +    title=$(gettext "Result")
  1.1065 +    msg=$(gettext "No legacy cards found")
  1.1066 +    $DIALOG --title "$title" --msgbox "$msg" 5 50
  1.1067 +    return 1
  1.1068 +}
  1.1069 +
  1.1070 +#
  1.1071 +# main part continued..
  1.1072 +#
  1.1073 +
  1.1074 +if test -n "$LOGFILE" ; then
  1.1075 +    touch "$LOGFILE"
  1.1076 +    echo -n "Starting alsaconf: " >> "$LOGFILE"
  1.1077 +    date >> "$LOGFILE"
  1.1078 +fi
  1.1079 +
  1.1080 +if [ x"$legacy_probe_card" != x ]; then
  1.1081 +    ac_opts=""
  1.1082 +    if eval ac_try_card_$legacy_probe_card >/dev/null 2>&1; then
  1.1083 +	echo "$ac_opts"
  1.1084 +	echo "$ac_cardname"
  1.1085 +	exit 0
  1.1086 +    else
  1.1087 +	echo "FAILED"
  1.1088 +	exit 1
  1.1089 +    fi
  1.1090 +fi
  1.1091 +
  1.1092 +
  1.1093 +if [ $do_legacy_only = 1 ]; then
  1.1094 +    ac_config_legacy
  1.1095 +    exit 0
  1.1096 +fi
  1.1097 +    
  1.1098 +probe_cards
  1.1099 +
  1.1100 +devs_found=()
  1.1101 +devs_olist=""
  1.1102 +
  1.1103 +if [ -s "$FOUND" ]; then
  1.1104 +    while read dev card ; do
  1.1105 +	MODDIR=/lib/modules/`uname -r`
  1.1106 +	find $MODDIR -type f | grep -q -E $card'\.(o|ko)' || continue
  1.1107 +	cardname=`find_device_name $dev | cut -c 1-64`
  1.1108 +	if [ -z "$cardname" ]; then
  1.1109 +	    cardname="$card"
  1.1110 +	fi
  1.1111 +	card=${card##snd-}
  1.1112 +	devs_found=("${devs_found[@]}" "$card" "$cardname")
  1.1113 +	devs_devs=("${devs_devs[@]}" "$card" "$dev")
  1.1114 +    done <"$FOUND"
  1.1115 +    devs_olist=`cat $FOUND`
  1.1116 +fi
  1.1117 +if [ x$devs_found != x ]; then
  1.1118 +    #
  1.1119 +    # check for TP600E
  1.1120 +    #
  1.1121 +    if [ ${devs_found[0]} = cs46xx ]; then
  1.1122 +	if $lspci -nv 2>/dev/null| grep -q "Subsystem: 1014:1010"; then
  1.1123 +	    msg=$(gettext "
  1.1124 + Looks like you having a Thinkpad 600E or 770 notebook.
  1.1125 + On this notebook, CS4236 driver should be used
  1.1126 + although CS46xx chip is detected.
  1.1127 +
  1.1128 + Shall I try to snd-cs4236 driver and probe
  1.1129 + the legacy ISA configuration?")
  1.1130 +	    if $DIALOG --yesno "$msg" 13 60
  1.1131 +	    then
  1.1132 +		try_all_combination=1
  1.1133 +		ac_config_legacy cs4236
  1.1134 +		exit 0
  1.1135 +	    fi
  1.1136 +	elif $lspci -nv 2>/dev/null| grep -q "Subsystem: 8086:8080"; then
  1.1137 +	    msg=$(gettext "
  1.1138 + Looks like you having a Dell Dimension machine.
  1.1139 + On this machine, CS4232 driver should be used
  1.1140 + although CS46xx chip is detected.
  1.1141 +
  1.1142 + Shall I try to snd-cs4232 driver and probe
  1.1143 + the legacy ISA configuration?")
  1.1144 +	    if $DIALOG --yesno "$msg" 13 60
  1.1145 +	    then
  1.1146 +		try_all_combination=1
  1.1147 +		ac_config_legacy cs4232
  1.1148 +		exit 0
  1.1149 +	    fi
  1.1150 +        fi	
  1.1151 +    fi
  1.1152 +   
  1.1153 +    devs_found=("${devs_found[@]}" "legacy" "Probe legacy ISA (non-PnP) chips")
  1.1154 +    title=$(gettext "Soundcard Selection")
  1.1155 +    msg=$(gettext "
  1.1156 +         Following card(s) are found on your system.
  1.1157 +         Please skip or choose a soundcard to configure :
  1.1158 +")
  1.1159 +    $DIALOG --title "$title" --menu "$msg" 17 76 8 "${devs_found[@]}" 2> $FOUND || acex 0
  1.1160 +    card=`head -n 1 $FOUND`
  1.1161 +    if [ "$card" = "legacy" ]; then
  1.1162 +	ac_config_legacy
  1.1163 +    else
  1.1164 +	ac_config_card "$card"
  1.1165 +    fi
  1.1166 +    exit 0
  1.1167 +else
  1.1168 +    msg=$(gettext "
  1.1169 +        No supported PnP or PCI card found.
  1.1170 +
  1.1171 + Would you like to probe legacy ISA sound cards/chips?
  1.1172 +
  1.1173 +")
  1.1174 +    if $DIALOG --yesno "$msg" 9 60 ; then
  1.1175 +	ac_config_legacy
  1.1176 +	exit 0
  1.1177 +    fi
  1.1178 +fi
  1.1179 +
  1.1180 +rm -f "$FOUND" "$DUMP"
  1.1181 +exit 0