作者 caleb- alsaconf [bash] 2006-08-17 13:36 (点击下载)

  1. #!/bin/bash
  2. #
  3. # ALSA Configurator
  4. #
  5. # Copyright (c) 1999-2002 SuSE GmbH
  6. # Jan ONDREJ
  7. #
  8. # written by Takashi Iwai <tiwai@suse.de>
  9. # Bernd Kaindl <bk@suse.de>
  10. # Jan ONDREJ (SAL) <ondrejj@salstar.sk>
  11. #
  12. # based on the original version of Jan ONDREJ's alsaconf for ALSA 0.4.
  13. #
  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.
  18. #
  19.  
  20. export TEXTDOMAIN=alsaconf
  21.  
  22. prefix=/usr
  23. exec_prefix=${prefix}
  24. bindir=${exec_prefix}/bin
  25. sbindir=${exec_prefix}/sbin
  26. version=1.0.11
  27. USE_NLS=yes
  28.  
  29. # Useful for debugging
  30. PROCFS="/proc"
  31. SYSFS="/sys"
  32.  
  33. # i18n stuff
  34. if test "$USE_NLS" = "yes" && which gettext > /dev/null; then
  35. xecho() {
  36. gettext -s "$*"
  37. }
  38. else
  39. xecho() {
  40. echo "$*"
  41. }
  42. gettext() {
  43. echo -n "$*"
  44. }
  45. fi
  46. xmsg() {
  47. msg=$(gettext "$1")
  48. shift
  49. printf "$msg" $*
  50. }
  51.  
  52. # Check for GNU/Linux distributions
  53. if [ -f /etc/SuSE-release ]; then
  54. distribution="suse"
  55. suse_version=$(grep 'VERSION = ' /etc/SuSE-release | sed -e s/'VERSION = '//)
  56. elif [ -f /etc/UnitedLinux-release ]; then
  57. distribution="suse"
  58. elif [ -f /etc/gentoo-release ]; then
  59. distribution="gentoo"
  60. elif [ -f /etc/debian_version ]; then
  61. distribution="debian"
  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
  65. distribution="redhat"
  66. elif test -f /etc/fedora-release && grep -q "Fedora" /etc/fedora-release; then
  67. distribution="fedora"
  68. else
  69. distribution="unknown"
  70. fi
  71.  
  72. if false; then
  73. for prog in lspci lsmod; do
  74. for path in /sbin /usr/sbin /bin /usr/bin;do
  75. test -x $path/$prog && eval $prog=$path/$prog
  76. done
  77. done
  78. unset prog path
  79. else
  80. # debian patch
  81. lspci=lspci
  82. lsmod=lsmod
  83. fi
  84.  
  85. usage() {
  86. xecho "ALSA configurator"
  87. echo " version $version"
  88. xecho "usage: alsaconf [options]
  89. -l|--legacy check only legacy non-isapnp cards
  90. -s|--sound wav-file
  91. use the specified wav file as a test sound
  92. -u|--uid uid set the uid for the ALSA devices (default = 0) [obsoleted]
  93. -g|--gid gid set the gid for the ALSA devices (default = 0) [obsoleted]
  94. -d|--devmode mode
  95. set the permission for ALSA devices (default = 0666) [obs.]
  96. -r|--strict set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]
  97. -L|--log file logging on the specified file (for debugging purpose only)
  98. -p|--probe card-name
  99. probe a legacy non-isapnp card and print module options
  100. -P|--listprobe list the supported legacy card modules
  101. -c|--config file
  102. specify the module config file
  103. -R|--resources list available DMA and IRQ resources with debug for legacy
  104. -h|--help what you're reading"
  105. }
  106.  
  107. 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
  108. eval set -- "$OPTS"
  109.  
  110. do_legacy_only=0
  111. use_modinfo_db=0
  112. alsa_uid=0
  113. alsa_gid=29
  114. alsa_mode=0660
  115. legacy_probe_card=""
  116. LOGFILE=""
  117. TESTSOUND="/usr/share/sounds/alsa/test.wav"
  118. try_all_combination=0
  119. resources="false"
  120.  
  121. # legacy support
  122. LEGACY_CARDS="opl3sa2 cs4236 cs4232 cs4231 es18xx es1688 sb16 sb8"
  123.  
  124. while true ; do
  125. case "$1" in
  126. -l|--legacy)
  127. do_legacy_only=1; shift ;;
  128. # In Debian the tool always operates in modinfo mode
  129. # -m|--modinfo)
  130. # use_modinfo_db=1; shift ;;
  131. -s|--sound)
  132. TESTSOUND=$2; shift 2;;
  133. -h|--help)
  134. usage; exit 0 ;;
  135. -L|--log)
  136. LOGFILE="$2"; shift 2;;
  137. -p|--probe)
  138. legacy_probe_card="$2"; shift 2;;
  139. -P|--listprobe)
  140. echo "$LEGACY_CARDS"; exit 0;;
  141. -u|--uid)
  142. alsa_uid="$2"; shift 2;;
  143. -g|--gid)
  144. alsa_gid="$2"; shift 2;;
  145. -d|--devmode)
  146. alsa_mode="$2"; shift 2;;
  147. -r|--strict)
  148. alsa_uid=0; alsa_gid=17; alsa_mode=0660; shift;;
  149. -c|--config)
  150. cfgfile="$2"; shift 2;;
  151. -R|--resources)
  152. resources="true"; shift;;
  153. --) shift ; break ;;
  154. *) usage ; exit 1 ;;
  155. esac
  156. done
  157.  
  158. #
  159. # probe legacy ISA cards
  160. #
  161.  
  162. check_dma_avail () {
  163. list=""
  164. if [ -d $SYSFS/bus/pnp/devices ]; then
  165. for dma in $*; do
  166. ok="true"
  167. for i in $SYSFS/bus/pnp/devices/??:* ; do
  168. if grep -q "state = active" $i/resources ; then
  169. if grep -q '^dma '$dma'$' $i/resources; then
  170. ok="false"
  171. fi
  172. fi
  173. done
  174. if [ -r $PROCFS/dma ]; then
  175. if grep -q '^ *'$dma': ' $PROCFS/dma ; then
  176. ok="false"
  177. fi
  178. fi
  179. if [ "$ok" = "true" ]; then
  180. list="$list $dma"
  181. fi
  182. done
  183. else
  184. if [ -r $PROCFS/dma ]; then
  185. for dma in $*; do
  186. grep -q '^ *'$dma': ' $PROCFS/dma || list="$list $dma"
  187. done
  188. fi
  189. fi
  190. if [ ! -z "$list" ]; then
  191. echo $list
  192. fi
  193. }
  194.  
  195. check_irq_avail () {
  196. list=""
  197. if [ -d $SYSFS/bus/pnp/devices ]; then
  198. for irq in $*; do
  199. ok="true"
  200. for i in $SYSFS/bus/pnp/devices/??:* ; do
  201. if grep -q "state = active" $i/resources ; then
  202. if grep -q '^irq '$irq'$' $i/resources; then
  203. ok="false"
  204. fi
  205. fi
  206. done
  207. if [ -r $PROCFS/interrupts ]; then
  208. if grep -q '^ *'$irq': ' $PROCFS/interrupts ; then
  209. ok="false"
  210. fi
  211. fi
  212. if [ "$ok" = "true" ]; then
  213. list="$list $irq"
  214. fi
  215. done
  216. else
  217. if [ -r $PROCFS/interrupts ]; then
  218. for irq in $*; do
  219. grep -q '^ *'$irq': ' $PROCFS/interrupts || list="$list $irq"
  220. done
  221. fi
  222. fi
  223. if [ ! -z "$list" ]; then
  224. echo $list
  225. fi
  226. }
  227.  
  228. #
  229. #
  230. #
  231.  
  232. if [ "$resources" = "true" ]; then
  233. if [ -d $SYSFS/bus/pnp/devices ]; then
  234. for i in $SYSFS/bus/pnp/devices/??:* ; do
  235. if [ "$resources" = "true" ]; then
  236. echo ">>>>> PnP file: $i/resources"
  237. cat $i/resources
  238. fi
  239. done
  240. fi
  241. if [ -r $PROCFS/dma ]; then
  242. echo ">>>>> Allocated dma channels:"
  243. cat $PROCFS/dma
  244. fi
  245. if [ -r $PROCFS/interrupts ]; then
  246. echo ">>>>> Allocated interrupt channels:"
  247. cat $PROCFS/interrupts
  248. fi
  249. echo -n "Valid DMA channels: "
  250. check_dma_avail 0 1 2 3 4 5 6 7
  251. echo -n "Valid IRQ channels: "
  252. check_irq_avail 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  253. exit 0
  254. fi
  255.  
  256. # Check for root privileges
  257. if [ `id -u` -ne 0 ]; then
  258. xecho "You must be root to use this script."
  259. exit 1
  260. fi
  261.  
  262. #
  263. # check the snd_ prefix for ALSA module options
  264. # snd_ prefix is obsoleted since 0.9.0rc4.
  265. #
  266. if /sbin/modinfo -p snd | grep -q snd_ ; then
  267. mpfx="snd_"
  268. else
  269. mpfx=""
  270. fi
  271.  
  272. alsa_device_opts=""
  273. if /sbin/modinfo -p snd | grep -q uid ; then
  274. if [ x"$alsa_uid" != x0 ]; then
  275. alsa_device_opts="$alsa_device_opts ${mpfx}device_uid=$alsa_uid"
  276. fi
  277. if [ x"$alsa_gid" != x0 ]; then
  278. alsa_device_opts="$alsa_device_opts ${mpfx}device_gid=$alsa_gid"
  279. fi
  280. fi
  281. if /sbin/modinfo -p snd | grep -q device_mode ; then
  282. if [ x"$alsa_mode" != x0 ]; then
  283. alsa_device_opts="$alsa_device_opts ${mpfx}device_mode=$alsa_mode"
  284. fi
  285. fi
  286.  
  287. case `uname -r` in
  288. 2.6.*)
  289. kernel="new"
  290. ;;
  291. *)
  292. kernel="old"
  293. ;;
  294. esac
  295.  
  296. # cfgfile = base config file to remove/update the sound setting
  297. # cfgout = new config file to write the sound setting (if different from $cfgfile)
  298. if [ -n "$cfgfile" ]; then
  299. if [ ! -r "$cfgfile" ]; then
  300. xecho "ERROR: The config file doesn't exist: "
  301. echo $cfgfile
  302. exit 1
  303. fi
  304. else
  305. if [ "$distribution" = "gentoo" ]; then
  306. cfgfile="/etc/modules.d/alsa"
  307. elif [ "$kernel" = "new" ]; then
  308. if [ -d /etc/modprobe.d ]; then
  309. cfgout="/etc/modprobe.d/sound"
  310. fi
  311. cfgfile="/etc/modprobe.conf"
  312. elif [ "$distribution" = "debian" ]; then
  313. cfgfile="/etc/modutils/sound"
  314. elif [ -e /etc/modules.conf ]; then
  315. cfgfile="/etc/modules.conf"
  316. elif [ -e /etc/conf.modules ]; then
  317. cfgfile="/etc/conf.modules"
  318. else
  319. cfgfile="/etc/modules.conf"
  320. touch /etc/modules.conf
  321. fi
  322. fi
  323.  
  324. # Check for dialog, whiptail, gdialog, awk, ... ?
  325. if which dialog > /dev/null; then
  326. DIALOG=dialog
  327. else
  328. if which whiptail > /dev/null; then
  329. whiptail_wrapper() {
  330. X1="$1"
  331. X2="$2"
  332. if [ $1 = --yesno ]; then
  333. X3=`expr $3 + 2`
  334. else
  335. X3=$3
  336. fi
  337. shift 3
  338. whiptail "$X1" "$X2" $X3 "$@"
  339. }
  340. DIALOG=whiptail_wrapper
  341. else
  342. xecho "Error, dialog or whiptail not found."
  343. exit 1
  344. fi
  345. fi
  346. if which awk > /dev/null; then :
  347. else
  348. xecho "Error, awk not found. Can't continue."
  349. exit 1
  350. fi
  351.  
  352. #
  353. # remove entries by yast2 sound configurator
  354. #
  355. remove_y2_block() {
  356. awk '
  357. /^alias sound-slot-[0-9]/ { next }
  358. /^alias char-major-116 / { next }
  359. /^alias char-major-14 / { next }
  360. /^alias snd-card-[0-9] / { next }
  361. /^options snd / { next }
  362. /^options snd-/ { next }
  363. /^options off / { next }
  364. /^alias sound-service-[0-9]/ { next }
  365. /^# YaST2: sound / { next }
  366. { print }'
  367. }
  368.  
  369. #
  370. # remove entries by sndconfig sound configurator
  371. #
  372. # found strings to search for in WriteConfModules,
  373. # from sndconfig 0.68-4 (rawhide version)
  374.  
  375. remove_sndconfig_block() {
  376. awk '
  377. /^alias sound-slot-0/ { modulename = $3 ; next }
  378. /^alias sound-slot-[0-9]/ { next }
  379. /^post-install sound-slot-[0-9] / { next }
  380. /^pre-remove sound-slot-[0-9] / { next }
  381. /^options sound / { next }
  382. /^alias synth0 opl3/ { next }
  383. /^options opl3 / { next }
  384. /^alias midi / { mididev = $3 ; next }
  385. /^options / { if ($2 == mididev) next }
  386. /^pre-install / { if ($2 == mididev) next }
  387. /^alias synth0 / { synth = $3 ; next }
  388. /^post-install / { if ($2 == synth) next }
  389. /^options sb / { next }
  390. /^post-install .+ \/bin\/modprobe "aci"/ { if ($2 == modulename) next }
  391. /^options adlib_card / { next }
  392. /^options .+ isapnp=1/ { if ($2 == modulename) next }
  393. /^options i810_audio / { next }
  394. /^options / {if ($2 == modulename) next }
  395. { print }'
  396. }
  397.  
  398. #
  399. # remove the previous configuration by alsaconf
  400. #
  401. remove_ac_block() {
  402. awk '/^'"$ACB"'$/,/^'"$ACE"'$/ { next } { print }'
  403. }
  404.  
  405. #
  406. # set default mixer volumes
  407. #
  408. set_mixers() {
  409. amixer -s -q <<EOF
  410. set Master 75% unmute
  411. set 'Master Mono' 75% unmute
  412. set Front 75% unmute
  413. set PCM 90% unmute
  414. mixer Synth 90% unmute
  415. mixer CD 90% unmute
  416. # mute mic
  417. set Mic 0% mute
  418. # ESS 1969 chipset has 2 PCM channels
  419. set PCM,1 90% unmute
  420. # Trident/YMFPCI/emu10k1
  421. set Wave 100% unmute
  422. set Music 100% unmute
  423. set AC97 100% unmute
  424. # CS4237B chipset:
  425. set 'Master Digital' 75% unmute
  426. # Envy24 chips with analog outs
  427. set DAC 90% unmute
  428. set DAC,0 90% unmute
  429. set DAC,1 90% unmute
  430. # some notebooks use headphone instead of master
  431. set Headphone 75% unmute
  432. set Playback 100% unmute
  433. # turn off digital switches
  434. set "SB Live Analog/Digital Output Jack" off
  435. set "Audigy Analog/Digital Output Jack" off
  436. EOF
  437. }
  438.  
  439.  
  440. # INTRO
  441. intro() {
  442. local msg=$(xmsg "
  443. ALSA CONFIGURATOR
  444. version %s
  445. This script is a configurator for
  446. Advanced Linux Sound Architecture (ALSA) driver.
  447. You should stop all sound applications now." $version)
  448. $DIALOG --msgbox "$msg" 20 63 || acex 0
  449. }
  450.  
  451. # FAREWELL
  452. farewell() {
  453. local msg=$(gettext "
  454. OK, sound driver is configured.
  455. ALSA CONFIGURATOR
  456. will prepare the card for playing now.
  457. Now I will load the ALSA sound driver and use
  458. amixer to raise the default volumes.
  459. You can change the volume later via a mixer
  460. program such as alsamixer or gamix.
  461. ")
  462. $DIALOG --msgbox "$msg" 17 60 || acex 0
  463. }
  464.  
  465. clear() {
  466. echo
  467. }
  468.  
  469. # Exit function
  470. acex() {
  471. cleanup
  472. if [ "$1" = 0 ] ; then
  473. clear
  474. else
  475. # Don't clear error messages
  476. echo
  477. fi
  478. exit $1
  479. }
  480.  
  481. #
  482. # search for alsasound init script
  483. #
  484.  
  485. if [ "$distribution" = "debian" ]; then
  486. rcalsasound=/etc/init.d/alsa
  487. elif [ -x /etc/init.d/alsasound ]; then
  488. rcalsasound=/etc/init.d/alsasound
  489. elif [ -x /usr/sbin/rcalsasound ]; then
  490. rcalsasound=/usr/sbin/rcalsasound
  491. elif [ -x /sbin/rcalsasound ]; then
  492. rcalsasound=/sbin/rcalsasound
  493. elif [ -x /etc/rc.d/init.d/alsasound ]; then
  494. rcalsasound=/etc/rc.d/init.d/alsasound
  495. elif [ -x /etc/init.d/alsa ]; then
  496. rcalsasound=/etc/init.d/alsa
  497. else
  498. rcalsasound=rcalsasound
  499. fi
  500.  
  501. # MAIN
  502. if false; then # In Debian don't do this
  503. if [ -d $PROCFS/asound ]; then
  504. $rcalsasound stop >/dev/null 2>&1
  505. $rcalsasound unload >/dev/null 2>&1
  506. /sbin/rmmod dmasound dmasound_awacs 2>/dev/null
  507. fi
  508. fi
  509.  
  510.  
  511. cleanup () {
  512. killall -9 aplay arecord >/dev/null 2>&1
  513. /sbin/modprobe -r isapnp >/dev/null 2>&1
  514. /sbin/modprobe -r isa-pnp >/dev/null 2>&1
  515. rm -f "$CARDID_DB" "$TMP" "$addcfg" "$FOUND" "$DUMP"
  516. }
  517. trap cleanup 0
  518.  
  519. CARDID_DB=`mktemp -q /tmp/alsaconf.cards.XXXXXX`
  520. if [ $? -ne 0 ]; then
  521. xecho "Can't create temp file, exiting..."
  522. exit 1
  523. fi
  524. TMP=`mktemp -q /tmp/alsaconf.XXXXXX`
  525. if [ $? -ne 0 ]; then
  526. xecho "Can't create temp file, exiting..."
  527. exit 1
  528. fi
  529. addcfg=`mktemp -q /tmp/alsaconf.XXXXXX`
  530. if [ $? -ne 0 ]; then
  531. xecho "Can't create temp file, exiting..."
  532. exit 1
  533. fi
  534. FOUND=`mktemp -q /tmp/alsaconf.XXXXXX`
  535. if [ $? -ne 0 ]; then
  536. xecho "Can't create temp file, exiting..."
  537. exit 1
  538. fi
  539. DUMP=`mktemp -q /tmp/alsaconf.XXXXXX`
  540. if [ $? -ne 0 ]; then
  541. xecho "Can't create temp file, exiting..."
  542. exit 1
  543. fi
  544.  
  545. # convert ISA PnP id number to string 'ABC'
  546. convert_isapnp_id () {
  547. if [ -z "$1" ]; then
  548. echo "XXXX"
  549. return
  550. fi
  551. let a='('$1'>>2) & 0x3f'
  552. let b='(('$1' & 0x03) << 3) | (('$1' >> 13) & 0x07)'
  553. let c='('$1'>> 8) & 0x1f'
  554. strs='@ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  555. echo ${strs:$a:1}${strs:$b:1}${strs:$c:1}
  556. }
  557.  
  558. # swap high & low bytes
  559. swap_number () {
  560. if [ -z "$1" ]; then
  561. echo "0000"
  562. return
  563. fi
  564. let v='(('$1'>>8)&0xff)|(('$1'&0xff)<<8)'
  565. printf "%04x" $v
  566. }
  567.  
  568. # build card database
  569. # build_card_db filename
  570. build_card_db () {
  571. MODDIR=/lib/modules/`uname -r`
  572. last_driver=""
  573. echo -n > $1
  574.  
  575. # list pci cards
  576. while read driver vendor device dummy; do
  577. if expr $driver : 'snd-.*' >/dev/null ; then
  578. if [ "$last_driver" != "$driver" ]; then
  579. echo $driver.o
  580. last_driver=$driver
  581. fi
  582. id1=`printf '0x%04x' $vendor`
  583. id2=`printf '0x%04x' $device`
  584. echo "PCI: $id1=$id2"
  585. fi
  586. done < $MODDIR/modules.pcimap >> $1
  587.  
  588. # list isapnp cards
  589. while read driver cardvendor carddevice data vendor func; do
  590. if expr $driver : 'snd-.*' >/dev/null ; then
  591. if [ "$last_driver" != "$driver" ]; then
  592. echo $driver.o
  593. last_driver=$driver
  594. fi
  595. id1=`convert_isapnp_id $cardvendor`
  596. dev1=`swap_number $carddevice`
  597. id2=`convert_isapnp_id $vendor`
  598. dev2=`swap_number $func`
  599. echo "ISAPNP: $id1$dev1=$id2$dev2"
  600. fi
  601. done < $MODDIR/modules.isapnpmap >> $1
  602. }
  603.  
  604. #
  605. # probe cards
  606. #
  607. probe_cards () {
  608. found="0"
  609. test -r $PROCFS/isapnp || /sbin/modprobe isapnp >/dev/null 2>&1
  610. test -r $PROCFS/isapnp || /sbin/modprobe isa-pnp >/dev/null 2>&1
  611. if [ -r $PROCFS/isapnp ]; then
  612. cat $PROCFS/isapnp >"$DUMP"
  613. found="1"
  614. elif [ -d $SYSFS/bus/pnp/devices ]; then
  615. # use 2.6 kernel's sysfs output
  616. # fake the isapnp dump
  617. index=0
  618. bindex=0
  619. for d1 in $SYSFS/devices/pnp* ; do
  620. for d2 in $d1/*:* ; do
  621. if [ -r $d2/card_id ]; then
  622. id=`cat $d2/card_id`
  623. name=`cat $d2/name`
  624. echo "Card $index '$id:$name' " >> "$DUMP"
  625. index=$[$index+1]
  626. found="1"
  627. else if [ -r $d2/id ]; then
  628. # FIXME: multiple id might be present (separated with new-line)
  629. id=`head -n 1 $d2/id`
  630. echo "BIOS $bindex '$id' " >> "$DUMP"
  631. bindex=$[$bindex+1]
  632. found="1"
  633. fi
  634. fi
  635. done
  636. done
  637. fi
  638. if [ "$found" = "0" ]; then
  639. echo -n >"$DUMP"
  640. fi
  641. if true; then
  642. # Debian code
  643. # CARDID_DB was set earlier
  644. xecho "Building card database..."
  645. build_card_db $CARDID_DB
  646. if [ ! -e $CARDID_DB ]; then
  647. xecho "No card database. Aborting."
  648. exit 1
  649. fi
  650. else
  651. CARDID_DB=/var/tmp/alsaconf.cards
  652. if [ ! -r $CARDID_DB ]; then
  653. use_modinfo_db=1
  654. fi
  655. if [ $use_modinfo_db != 1 ]; then
  656. if [ $CARDID_DB -ot /lib/modules/`uname -r`/modules.dep ]; then
  657. use_modinfo_db=1
  658. fi
  659. fi
  660. if [ $use_modinfo_db = 1 ]; then
  661. xecho "Building card database.."
  662. build_card_db $CARDID_DB
  663. fi
  664. if [ ! -r $CARDID_DB ]; then
  665. xecho "No card database is found.."
  666. exit 1
  667. fi
  668. fi
  669. ncards=`grep '^snd-.*\.o$' $CARDID_DB | wc -w`
  670.  
  671. msg=$(gettext "Searching sound cards")
  672. awk '
  673. BEGIN {
  674. format="%-40s %s\n";
  675. ncards='"$ncards"';
  676. idx=0;
  677. }
  678. /^snd-.*\.o$/{
  679. sub(/.o$/, "");
  680. driver=$0;
  681. perc=(idx * 100) / (ncards + 1);
  682. print int(perc);
  683. idx++;
  684. }
  685. /^[<literal space><literal tab>]*PCI: /{
  686. gsub(/0x/, "");
  687. gsub(/=/, ":");
  688. x = sprintf ("'$lspci' -n 2>/dev/null| grep '"' 04..: '"' | grep %s", $2);
  689. if (system (x) == 0)
  690. printf "%s %s\n", $2, driver >>"'"$FOUND"'"
  691. }
  692. /^[<literal space><literal tab>]*ISAPNP: /{
  693. id2 = substr($0, index($0, "=")+1);
  694. gsub(/=.*/, "");
  695. x = sprintf ("grep '\''^Card [0-9] .%s:'\'' '"$DUMP"'", $2);
  696. if (system (x) == 0)
  697. printf "%s %s\n", $2, driver >>"'"$FOUND"'"
  698. else if (index($2, "ffff") > 0) {
  699. x = sprintf ("grep '\''^BIOS [0-9]* .%s.'\'' '"$DUMP"'", id2);
  700. if (system (x) == 0)
  701. printf "%s %s\n", id2, driver >>"'"$FOUND"'"
  702. }
  703. }' < $CARDID_DB |\
  704. $DIALOG --gauge "$msg" 6 40 0
  705. #
  706. # PowerMac
  707. #
  708. if grep -q MacRISC $PROCFS/cpuinfo; then
  709. MODDIR=/lib/modules/`uname -r`
  710. find $MODDIR -name 'snd-powermac*' -print | \
  711. while read i; do
  712. i=${i##*/}
  713. i=${i%%.o}
  714. i=${i%%.ko}
  715. echo "PowerMac $i" >> $FOUND
  716. done
  717. fi
  718. #
  719. # Sparc
  720. #
  721. if grep -q Sparc $PROCFS/cpuinfo; then
  722. test -r $PROCFS/openprom/name || /bin/mount -t openpromfs none $PROCFS/openprom >/dev/null 2>&1
  723. # Check for an "audio" device
  724. audio=
  725. compat=
  726. if test -r $PROCFS/openprom; then
  727. audio=`find $PROCFS/openprom -follow -type d -name "audio*" -print`
  728. fi
  729. if test -n "$audio"; then
  730. compat=`cat $audio/compatible`
  731. compat=${compat#\'}
  732. compat=${compat%\'}
  733. compat=${compat#SUNW,}
  734. fi
  735. # Go through all cards we have
  736. MODDIR=/lib/modules/`uname -r`
  737. find $MODDIR -name 'snd-sun-*' -print | \
  738. while read i; do
  739. i=${i##*/}
  740. i=${i%%.o}
  741. i=${i%%.ko}
  742. sdev=`echo ${i#snd-sun-} | tr "[a-z]" "[A-Z]"`
  743. if test "$sdev" = "$compat"; then
  744. echo "$sdev $i" >> $FOUND
  745. elif test -r $PROCFS/openprom; then
  746. find $PROCFS/openprom -follow -type d -name "SUNW,${sdev}*" \
  747. -exec echo "$sdev $i" \; 2>/dev/null >> $FOUND
  748. else
  749. echo "$sdev $i" >> $FOUND
  750. fi
  751. done
  752. fi
  753. }
  754. #
  755. # look for a descriptive device name from the given device id
  756. #
  757. find_device_name () {
  758. 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
  759. $lspci -d $1 2>/dev/null| sed -e 's/^.*:..\.. [^:]*: //g'
  760. return
  761. elif expr "$1" : '[A-Z@][A-Z@][A-Z@][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then
  762. cardname=`grep '^Card [0-9]\+ .'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`
  763. echo $cardname
  764. else
  765. echo $1
  766. fi
  767. }
  768. # get hwcfg file type from the given driver name
  769. get_hwcfg_type () {
  770. while read dev driver; do
  771. if [ "$driver" = "$1" ]; then
  772. case "$dev" in
  773. *:*)
  774. # FIXME: need to look around /sys/bus/pci/* (or use vpid-* ?)
  775. devid=`$lspci -d "$dev" | head -n 1 | sed -e 's/ .*$//'`
  776. case "$devid" in
  777. *:*:*.*) ;;
  778. *) devid="0000:$devid" ;;
  779. esac
  780. echo bus-pci-$devid
  781. ;;
  782. *)
  783. echo $driver
  784. ;;
  785. esac
  786. break
  787. fi
  788. done
  789. }
  790. # clean up all hwcfg-* files containing ALSA modules
  791. # alsaconf sets up exclusively
  792. cleanup_hwcfg () {
  793. for i in /etc/sysconfig/hardware/hwcfg-*; do
  794. grep -q "MODULE='snd-" $i && rm -f $i
  795. done
  796. }
  797. #
  798. # set up /etc/sysconfig/hardware/hwcfg-* stuff
  799. #
  800. setup_hwcfg () {
  801. card=$1
  802. cleanup_hwcfg
  803. cfg=`echo "$devs_olist" | get_hwcfg_type $card`
  804. echo "MODULE='$card'" > /etc/sysconfig/hardware/hwcfg-$cfg
  805. echo "STARTMODE='auto'" >> /etc/sysconfig/hardware/hwcfg-$cfg
  806. }
  807. #
  808. # configure and try test sound
  809. #
  810. ac_config_card () {
  811. CARD_DRIVER=snd-$1
  812. CARD_OPTS="${*:2}"
  813. if [ -n "$cfgout" ]; then
  814. msg=$(xmsg "
  815. Configuring %s
  816. Do you want to modify %s (and %s if present)?" $CARD_DRIVER $cfgout $cfgfile)
  817. $DIALOG --yesno "$msg" 8 50 || acex 0
  818. else
  819. msg=$(xmsg "
  820. Configuring %s
  821. Do you want to modify %s?" $CARD_DRIVER $cfgfile)
  822. $DIALOG --yesno "$msg" 8 50 || acex 0
  823. fi
  824. clear
  825. # Copy conf.modules and make changes.
  826. ACB="# --- BEGIN: Generated by ALSACONF, do not edit. ---"
  827. ACE="# --- END: Generated by ALSACONF, do not edit. ---"
  828. # Detect 2.2.X kernel
  829. KVER=`uname -r | tr ".-" " "`
  830. KVER1=`echo $KVER | cut -d" " -f1`
  831. KVER2=`echo $KVER | cut -d" " -f2`
  832. if [ $KVER1 -ge 2 ] && [ $KVER2 -ge 2 ]; then
  833. SOUND_CORE="soundcore"
  834. else
  835. SOUND_CORE="snd"
  836. fi
  837. if [ -r $cfgfile ] ; then
  838. if [ "$distribution" = "redhat" -o "$distribution" = "fedora" ] ; then
  839. remove_ac_block < $cfgfile | remove_sndconfig_block | uniq > $TMP
  840. else
  841. remove_ac_block < $cfgfile | remove_y2_block | uniq > $TMP
  842. fi
  843. fi
  844. if [ -z "$have_alias" -a "$kernel" = "new" ]; then
  845. if grep -q char-major-116 /lib/modules/`uname -r`/modules.alias; then
  846. have_alias="yes"
  847. fi
  848. fi
  849. if false ; then
  850. if [ -z "$have_alias" ]; then
  851. echo "alias char-major-116 snd
  852. alias char-major-14 $SOUND_CORE
  853. alias sound-service-0-0 snd-mixer-oss
  854. alias sound-service-0-1 snd-seq-oss
  855. alias sound-service-0-3 snd-pcm-oss
  856. alias sound-service-0-8 snd-seq-oss
  857. alias sound-service-0-12 snd-pcm-oss" >> $addcfg
  858. fi
  859. if [ -n "$alsa_device_opts" ]; then
  860. echo "options snd $alsa_device_opts" >> $addcfg
  861. fi
  862. echo "alias snd-card-0 $CARD_DRIVER
  863. alias sound-slot-0 $CARD_DRIVER" >> $addcfg
  864. if [ -n "$CARD_OPTS" ]; then
  865. echo "options $CARD_DRIVER $CARD_OPTS" >> $addcfg
  866. fi
  867. else
  868. # For Debian
  869. echo "alias snd-card-0 $CARD_DRIVER
  870. options $CARD_DRIVER index=0${CARD_OPTS:+ $CARD_OPTS}" >> $addcfg
  871. fi
  872. if [ -n "$cfgout" ]; then
  873. [ ! -r "$cfgfile" ] || cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile"
  874. if false ; then
  875. cmp -s "$addcfg" "$cfgout" || cat "$addcfg" > "$cfgout"
  876. else
  877. # For Debian
  878. if [ "$kernel" = old ] ; then
  879. if [ -f /etc/modutils/alsa-base ] ; then
  880. # Don't duplicate any lines already in /etc/modutils/alsa-base
  881. grep -Fv -f /etc/modutils/alsa-base "$addcfg" > "$TMP"
  882. else
  883. cat "$addcfg" > "$TMP"
  884. fi
  885. else
  886. if [ -f /etc/modprobe.d/alsa-base ] ; then
  887. # Don't duplicate any lines already in /etc/modprobe.d/alsa-base
  888. grep -Fv -f /etc/modprobe.d/alsa-base "$addcfg" > "$TMP"
  889. else
  890. cat "$addcfg" > "$TMP"
  891. fi
  892. fi
  893. cmp -s "$TMP" "$cfgout" || cat "$TMP" > "$cfgout"
  894. fi
  895. else
  896. if false ; then
  897. echo "$ACB
  898. # --- ALSACONF version $version ---" >> $TMP
  899. cat "$addcfg" >> "$TMP"
  900. echo "$ACE
  901. " >> $TMP
  902. else
  903. # For Debian
  904. if [ "$kernel" = old ] ; then
  905. if [ -f /etc/modutils/alsa-base ] ; then
  906. # Don't duplicate any lines already in /etc/modutils/alsa-base
  907. grep -Fv -f /etc/modutils/alsa-base "$addcfg" >> "$TMP"
  908. else
  909. cat "$addcfg" >> "$TMP"
  910. fi
  911. else
  912. if [ -f /etc/modprobe.d/alsa-base ] ; then
  913. # Don't duplicate any lines already in /etc/modprobe.d/alsa-base
  914. grep -Fv -f /etc/modprobe.d/alsa-base "$addcfg" >> "$TMP"
  915. else
  916. cat "$addcfg" >> "$TMP"
  917. fi
  918. fi
  919. fi
  920. cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile"
  921. fi
  922.  
  923. /sbin/depmod -a 2>/dev/null
  924.  
  925. # remove yast2 entries (- only for suse distro)
  926. if [ -f /var/lib/YaST/unique.inf ]; then
  927. awk '
  928. BEGIN { in_sound=0; }
  929. /^\[sound\]$/ { print; in_sound=1; next; }
  930. /^\[.+\]$/ { print; in_sound=0; next; }
  931. { if (in_sound == 0) { print; } }
  932. ' < /var/lib/YaST/unique.inf > $TMP
  933. cp -f $TMP /var/lib/YaST/unique.inf
  934. fi
  935.  
  936. # set up /etc/sysconfig/hardware/*
  937. if [ "$distribution" = "suse" ]; then
  938. case "$suse_version" in
  939. 10.*)
  940. setup_hwcfg $CARD_DRIVER
  941. ;;
  942. esac
  943. fi
  944.  
  945. farewell
  946. clear
  947. if [ "$distribution" = "gentoo" ]; then
  948. xecho "Running modules-update..."
  949. modules-update
  950. elif [ "$distribution" = "debian" ]; then
  951. xecho "Running update-modules..."
  952. update-modules
  953. fi
  954. echo Loading driver...
  955. if false; then
  956. $rcalsasound restart
  957. else
  958. /sbin/modprobe $CARD_DRIVER
  959. sleep 4 # Wait for automatic "alsactl restore" to finish
  960. fi
  961. echo Setting default volumes...
  962. if [ -x $bindir/set_default_volume ]; then
  963. $bindir/set_default_volume -f
  964. else
  965. set_mixers
  966. fi
  967. if [ -f $TESTSOUND ]; then
  968. msg=$(gettext "
  969. The mixer is set up now for for playing.
  970. Shall I try to play a sound sample now?
  971. NOTE:
  972. If you have a big amplifier, lower your volumes or say no.
  973. Otherwise check that your speaker volume is open,
  974. and look if you can hear test sound.
  975. ")
  976. if $DIALOG --yesno "$msg" 13 65
  977. then
  978. clear
  979. echo
  980. aplay -N $TESTSOUND
  981. fi
  982. fi
  983. if [ ! -r /var/lib/alsa/asound.state ]; then
  984. xecho "Saving the mixer setup used for this in /var/lib/alsa/asound.state."
  985. $sbindir/alsactl store
  986. fi
  987. clear
  988. xecho "
  989. ===============================================================================
  990. Now ALSA is ready to use.
  991. For adjustment of volumes, use your favorite mixer.
  992. Have a lot of fun!
  993. "
  994. }
  995.  
  996. # check playback
  997. # return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
  998. ac_try_load () {
  999. test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
  1000. if [ "$kernel" = old ] ; then
  1001. /sbin/modprobe snd-$1 ${*:2} >/dev/null 2>&1
  1002. else
  1003. /sbin/modprobe --ignore-install snd-$1 ${*:2} >/dev/null 2>&1
  1004. fi
  1005. if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then
  1006. : ;
  1007. else
  1008. /sbin/modprobe -r snd-$1 >/dev/null 2>&1
  1009. return 1
  1010. fi
  1011.  
  1012. # mute mixers
  1013. amixer set Master 0% mute >/dev/null 2>&1
  1014. amixer set PCM 0% mute >/dev/null 2>&1
  1015. # output 0.5 sec
  1016. head -c 4000 < /dev/zero | aplay -N -r8000 -fS16_LE -traw -c1 > /dev/null 2>&1 &
  1017. # remember pid
  1018. pp=$!
  1019. # sleep for 2 seconds (to be sure -- 1 sec would be enough)
  1020. sleep 2
  1021. # kill the child process if still exists.
  1022. kill -9 $pp > /dev/null 2>&1
  1023. st=$?
  1024. ac_cardname=`head -n 1 $PROCFS/asound/cards | sed -e 's/^[0-9].* - \(.*\)$/\1/'`
  1025. /sbin/modprobe -r snd-$1 >/dev/null 2>&1
  1026. if [ $st = 0 ]; then
  1027. # irq problem?
  1028. test -n "$LOGFILE" && echo "no playback return" >> "$LOGFILE"
  1029. return 2
  1030. else
  1031. # seems ok!
  1032. test -n "$LOGFILE" && echo "playback OK" >> "$LOGFILE"
  1033. return 0
  1034. fi
  1035. }
  1036.  
  1037. # check capture
  1038. # return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
  1039. # ac_try_capture card duplex opts
  1040. ac_try_capture () {
  1041. test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
  1042. if [ "$kernel" = old ] ; then
  1043. /sbin/modprobe snd-$1 ${*:3} >/dev/null 2>&1
  1044. else
  1045. /sbin/modprobe --ignore-install snd-$1 ${*:3} >/dev/null 2>&1
  1046. fi
  1047. if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then
  1048. : ;
  1049. else
  1050. /sbin/modprobe -r snd-$1 >/dev/null 2>&1
  1051. return 1
  1052. fi
  1053.  
  1054. # mute mixers
  1055. amixer set Master 0% mute >/dev/null 2>&1
  1056. amixer set PCM 0% mute >/dev/null 2>&1
  1057.  
  1058. play_pid=0
  1059. if [ $2 = yes ]; then
  1060. # try duplex - start dummy playing
  1061. aplay -N -r8000 -fS16_LE -traw -c1 < /dev/zero > /dev/null 2>&1 &
  1062. play_pid=$!
  1063. fi
  1064. # record 1sec
  1065. arecord -N -d1 > /dev/null 2>&1 &
  1066. # remember pid
  1067. pp=$!
  1068. # sleep for 2 seconds
  1069. sleep 2
  1070. # kill the child process if still exists.
  1071. kill -9 $pp > /dev/null 2>&1
  1072. st=$?
  1073. # kill playback process if any
  1074. test $play_pid != 0 && kill -9 $play_pid
  1075. /sbin/modprobe -r snd-$1 >/dev/null 2>&1
  1076. if [ $st = 0 ]; then
  1077. test -n "$LOGFILE" && echo "capture no return" >> "$LOGFILE"
  1078. return 2
  1079. else
  1080. test -n "$LOGFILE" && echo "capture OK" >> "$LOGFILE"
  1081. return 0
  1082. fi
  1083. }
  1084.  
  1085. get_dma_pair () {
  1086. case $1 in
  1087. 0)
  1088. echo 1 3 5;;
  1089. 1)
  1090. echo 0 3 5;;
  1091. 3)
  1092. echo 1 0 5;;
  1093. 5)
  1094. echo 3 1 0;;
  1095. esac
  1096. }
  1097.  
  1098. #
  1099. # check playback on specified irqs
  1100. #
  1101. # ac_try_irq card opts irqs...
  1102. # return 0 - OK, 1 - NG, 2 - not working (dma problem?)
  1103. #
  1104. ac_try_irq () {
  1105. card=$1
  1106. opts="$2 ${mpfx}irq=$3"
  1107. ac_try_load $card $opts >/dev/null 2>&1
  1108. result=$?
  1109. case $result in
  1110. 0)
  1111. ac_opts="$opts"
  1112. return 0
  1113. ;;
  1114. 2)
  1115. for irq in ${*:4}; do
  1116. opts="$2 ${mpfx}irq=$irq"
  1117. ac_try_load $card $opts >/dev/null 2>&1
  1118. if [ $? = 0 ]; then
  1119. ac_opts="$opts"
  1120. return 0
  1121. fi
  1122. done
  1123. return 2
  1124. ;;
  1125. esac
  1126. return 1
  1127. }
  1128.  
  1129. #
  1130. # check playback/capture on dma1 & dma2 & specified irqs
  1131. #
  1132. # ac_try_dmas card opts irqs...
  1133. # return 0 - OK, 1 - NG
  1134. #
  1135. ac_try_dmas () {
  1136. dma_list=`check_dma_avail 1 0 3 5`
  1137. for irq in ${*:3}; do
  1138. for dma1 in $dma_list; do
  1139. for dma2 in `get_dma_pair $dma1`; do
  1140. opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq"
  1141. ac_try_load $1 $opts >/dev/null 2>&1
  1142. result=$?
  1143. if [ $result = 1 ]; then
  1144. if [ $try_all_combination = 1 ]; then
  1145. continue
  1146. else
  1147. return 1
  1148. fi
  1149. elif [ $result = 0 ]; then
  1150. test -n "$LOGFILE" && echo "Now checking capture..." >> "$LOGFILE"
  1151. ac_opts="$opts"
  1152. ac_try_capture $1 yes $opts >/dev/null 2>&1 && return 0
  1153. for d in yes no; do
  1154. for dma2 in $dma_list; do
  1155. if [ $dma1 != $dma2 ]; then
  1156. opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq"
  1157. ac_opts="$opts"
  1158. ac_try_capture $1 $d $opts >/dev/null 2>&1 && return 0
  1159. fi
  1160. done
  1161. done
  1162. return 0
  1163. fi
  1164. done
  1165. done
  1166. done
  1167. return 1
  1168. }
  1169.  
  1170. # check if the option $2 exists in card $1: set value $3
  1171. ac_check_option () {
  1172. if /sbin/modinfo -p snd-$1 | grep -q $2; then
  1173. echo "$2=$3"
  1174. fi
  1175. }
  1176.  
  1177. ac_try_card_sb8 () {
  1178. card=sb8
  1179. irq_list=`check_irq_avail 5 3 9 10 7`
  1180. for dma8 in `check_dma_avail 1 3`; do
  1181. opts="${mpfx}dma8=$dma8"
  1182. ac_try_irq $card "$opts" $irq_list && return 0
  1183. done
  1184. return 1
  1185. }
  1186.  
  1187. ac_try_card_sb16 () {
  1188. card=sb16
  1189. isapnp=`ac_check_option $card ${mpfx}isapnp 0`
  1190. opts="$isapnp"
  1191. irq_list=`check_irq_avail 5 9 10 7 3`
  1192. dma_list=`check_dma_avail 0 1 3`
  1193. dma16_list=`check_dma_avail 5 6 7`
  1194. # at first try auto-probing by driver itself
  1195. ac_try_load $card $opts >/dev/null 2>&1
  1196. result=$?
  1197. case $result in
  1198. 0)
  1199. ac_opts="$opts"
  1200. ac_try_capture $card yes $opts >/dev/null 2>&1 && return 0
  1201. for d in yes no; do
  1202. for dma8 in $dma_list; do
  1203. for irq in $irq_list; do
  1204. opts="${mpfx}dma8=$dma8 ${mpfx}irq=$irq $isapnp"
  1205. ac_try_capture $card $d $opts >/dev/null 2>&1 && return 0
  1206. done
  1207. done
  1208. done
  1209. return 0
  1210. ;;
  1211. 2)
  1212. for dma16 in $dma16_list; do
  1213. opts="${mpfx}dma16=$dma16 $isapnp"
  1214. if ac_try_irq $card "$opts" $irq_list ; then
  1215. ac_try_capture $card yes $ac_opts >/dev/null 2>&1 && return 0
  1216. ac_opts_saved="$ac_opts"
  1217. for d in yes no; do
  1218. for dma8 in $dma_list; do
  1219. ac_opts="$ac_opts_saved ${mpfx}dma8=$dma8"
  1220. ac_try_capture $card $d $ac_opts >/dev/null 2>&1 && return 0
  1221. done
  1222. done
  1223. # return anyway here..
  1224. return 0
  1225. fi
  1226. done
  1227. ;;
  1228. esac
  1229. return 1
  1230. }
  1231.  
  1232. ac_try_card_es1688 () {
  1233. card=es1688
  1234. opts=""
  1235. irq_list=`check_irq_avail 5 9 10 7`
  1236. for dma8 in `check_dma_avail 1 3 0`; do
  1237. opts="${mpfx}dma8=$dma8 ${mpfx}mpu_irq=-1"
  1238. ac_try_irq $card "$opts" $irq_list && return 0
  1239. done
  1240. return 1
  1241. }
  1242.  
  1243. ac_try_card_es18xx () {
  1244. card=es18xx
  1245. opts=`ac_check_option $card ${mpfx}isapnp 0`
  1246. ac_try_dmas $card "$opts" `check_irq_avail 5 9 10 7` && return 0
  1247. return 1
  1248. }
  1249.  
  1250. ac_try_card_cs4236 () {
  1251. card=cs4236
  1252. irq_list=`check_irq_avail 5 7 9 11 12 15`
  1253. isapnp=`ac_check_option $card ${mpfx}isapnp 0`
  1254. for cport in 0x538 0x210 0xf00; do
  1255. for port in 0x530 0x534; do
  1256. opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp"
  1257. ac_try_dmas $card "$opts" $irq_list && return 0
  1258. done
  1259. done
  1260. return 1
  1261. }
  1262.  
  1263. ac_try_card_cs4232 () {
  1264. card=cs4232
  1265. irq_list=`check_irq_avail 5 7 9 11 12 15`
  1266. isapnp=`ac_check_option $card ${mpfx}isapnp 0`
  1267. for cport in 0x538 0x210 0xf00; do
  1268. for port in 0x530 0x534; do
  1269. opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp"
  1270. ac_try_dmas $card "$opts" $irq_list && return 0
  1271. done
  1272. done
  1273. return 1
  1274. }
  1275.  
  1276. ac_try_card_cs4231 () {
  1277. card=cs4231
  1278. irq_list=`check_irq_avail 5 7 9 11 12 15`
  1279. for port in 0x530 0x534; do
  1280. opts="${mpfx}port=$port"
  1281. ac_try_dmas $card "$opts" $irq_list && return 0
  1282. done
  1283. return 1
  1284. }
  1285.  
  1286. ac_try_card_opl3sa2 () {
  1287. card=opl3sa2
  1288. irq_list=`check_irq_avail 5 9 3 1 11 12 15 0`
  1289. isapnp=`ac_check_option $card ${mpfx}isapnp 0`
  1290. for port in 0x370 0x538 0xf86 0x100; do
  1291. for wss_port in 0x530 0xe80 0xf40 0x604; do
  1292. opts="${mpfx}fm_port=-1 ${mpfx}midi_port=-1 ${mpfx}port=$port ${mpfx}wss_port=$wss_port $isapnp"
  1293. ac_try_dmas $card "$opts" $irq_list && return 0
  1294. done
  1295. done
  1296. return 1
  1297. }
  1298.  
  1299. ac_config_legacy () {
  1300. title=$(gettext "WARNING")
  1301. msg=$(gettext "
  1302. Probing legacy ISA cards might make
  1303. your system unstable.
  1304. Do you want to proceed?
  1305. ")
  1306. $DIALOG --title "$title" --yesno "$msg" 10 50 || acex 0
  1307.  
  1308. if [ x"$1" = x ]; then
  1309. probe_list="$LEGACY_CARDS"
  1310. else
  1311. probe_list=$*
  1312. fi
  1313. menu_args=()
  1314.  
  1315. for card in $probe_list; do
  1316. cardname=`/sbin/modinfo -d snd-$card | sed -e 's/^\"\(.*\)\"$/\1/g'`
  1317. if [ x"$cardname" != x ]; then
  1318. menu_args=("${menu_args[@]}" "$card" "$cardname" "on")
  1319. fi
  1320. done
  1321. if [ x$menu_args = x ]; then
  1322. msg=$(gettext "No legacy drivers are available
  1323. for your machine")
  1324. $DIALOG --msgbox "$msg" 5 50
  1325. return 1
  1326. fi
  1327. title=$(gettext "Driver Selection")
  1328. msg=$(gettext " Probing legacy ISA cards
  1329. Please select the drivers to probe:")
  1330. $DIALOG --title "$title" --checklist "$msg" \
  1331. 17 64 8 "${menu_args[@]}" 2> $FOUND || acex 0
  1332.  
  1333. if [ $try_all_combination != 1 ]; then
  1334. msg=$(gettext "
  1335. Shall I try all possible DMA and IRQ combinations?
  1336. With this option, some unconventional configuration
  1337. might be found, but it will take much longer time.")
  1338. if $DIALOG --yesno "$msg" 10 60
  1339. then
  1340. try_all_combination=1
  1341. fi
  1342. fi
  1343.  
  1344. xecho "Probing legacy cards.. This may take a few minutes.."
  1345. echo -n $(gettext "Probing: ")
  1346. cards=`cat $FOUND | tr -d \"`
  1347. for card in $cards; do
  1348. echo -n " $card"
  1349. ac_opts=""
  1350. if eval ac_try_card_$card ; then
  1351. xecho " : FOUND!!"
  1352. ac_config_card $card $ac_opts
  1353. return 0
  1354. fi
  1355. done
  1356. echo
  1357. title=$(gettext "Result")
  1358. msg=$(gettext "No legacy cards found")
  1359. $DIALOG --title "$title" --msgbox "$msg" 5 50
  1360. return 1
  1361. }
  1362. #
  1363. # main part continued..
  1364. #
  1365. if test -n "$LOGFILE" ; then
  1366. touch "$LOGFILE"
  1367. echo -n "Starting alsaconf: " >> "$LOGFILE"
  1368. date >> "$LOGFILE"
  1369. fi
  1370. intro
  1371. [ -x /etc/init.d/alsa ] && /etc/init.d/alsa force-unload
  1372. if [ -d /proc/asound ]; then
  1373. /sbin/rmmod dmasound dmasound_awacs 2>/dev/null
  1374. fi
  1375. # Try to unload all sound modules
  1376. for S in OSS ALSA ; do
  1377. L="/usr/share/linux-sound-base/${S}-module-list"
  1378. if [ -r "$L" ] ; then
  1379. for M in $(sed -e 's/#.*//' -e '/^[[:space:]]*$/d' "$L") ; do
  1380. [ "$M" ] && /sbin/modprobe -r "$M" >/dev/null 2>&1 || :
  1381. done
  1382. fi
  1383. done
  1384. if [ x"$legacy_probe_card" != x ]; then
  1385. ac_opts=""
  1386. if eval ac_try_card_$legacy_probe_card >/dev/null 2>&1; then
  1387. echo "$ac_opts"
  1388. echo "$ac_cardname"
  1389. exit 0
  1390. else
  1391. echo "FAILED"
  1392. exit 1
  1393. fi
  1394. fi
  1395. if [ $do_legacy_only = 1 ]; then
  1396. ac_config_legacy
  1397. exit 0
  1398. fi
  1399. probe_cards
  1400. devs_found=()
  1401. devs_olist=""
  1402. if [ -s "$FOUND" ]; then
  1403. while read dev card ; do
  1404. MODDIR=/lib/modules/`uname -r`
  1405. find $MODDIR -type f | grep -q -E $card'\.(o|ko)' || continue
  1406. cardname=`find_device_name $dev | cut -c 1-64`
  1407. if [ -z "$cardname" ]; then
  1408. cardname="$card"
  1409. fi
  1410. card=${card##snd-}
  1411. devs_found=("${devs_found[@]}" "$card" "$cardname")
  1412. devs_devs=("${devs_devs[@]}" "$card" "$dev")
  1413. done <"$FOUND"
  1414. devs_olist=`cat $FOUND`
  1415. fi
  1416. if [ x$devs_found != x ]; then
  1417. #
  1418. # check for TP600E
  1419. #
  1420. if [ ${devs_found[0]} = cs46xx ]; then
  1421. if $lspci -nv 2>/dev/null| grep -q "Subsystem: 1014:1010"; then
  1422. msg=$(gettext "
  1423. Looks like you having a Thinkpad 600E or 770 notebook.
  1424. On this notebook, CS4236 driver should be used
  1425. although CS46xx chip is detected.
  1426.  
  1427. Shall I try to snd-cs4236 driver and probe
  1428. the legacy ISA configuration?")
  1429. if $DIALOG --yesno "$msg" 13 60
  1430. then
  1431. try_all_combination=1
  1432. ac_config_legacy cs4236
  1433. exit 0
  1434. fi
  1435. elif $lspci -nv 2>/dev/null| grep -q "Subsystem: 8086:8080"; then
  1436. msg=$(gettext "
  1437. Looks like you having a Dell Dimension machine.
  1438. On this machine, CS4232 driver should be used
  1439. although CS46xx chip is detected.
  1440.  
  1441. Shall I try to snd-cs4232 driver and probe
  1442. the legacy ISA configuration?")
  1443. if $DIALOG --yesno "$msg" 13 60
  1444. then
  1445. try_all_combination=1
  1446. ac_config_legacy cs4232
  1447. exit 0
  1448. fi
  1449. fi
  1450. fi
  1451. devs_found=("${devs_found[@]}" "legacy" "Probe legacy ISA (non-PnP) chips")
  1452. title=$(gettext "Soundcard Selection")
  1453. msg=$(gettext "
  1454. Following card(s) are found on your system.
  1455. Choose a soundcard to configure:
  1456. ")
  1457. $DIALOG --title "$title" --menu "$msg" 17 76 8 "${devs_found[@]}" 2> $FOUND || acex 0
  1458. card=`head -n 1 $FOUND`
  1459. if [ "$card" = "legacy" ]; then
  1460. ac_config_legacy
  1461. else
  1462. ac_config_card "$card"
  1463. fi
  1464. exit 0
  1465. else
  1466. msg=$(gettext "
  1467. No supported PnP or PCI card found.
  1468.  
  1469. Would you like to probe legacy ISA sound cards/chips?
  1470.  
  1471. ")
  1472. if $DIALOG --yesno "$msg" 9 60 ; then
  1473. ac_config_legacy
  1474. exit 0
  1475. fi
  1476. fi
  1477. rm -f "$FOUND" "$DUMP"
  1478. exit 0

提交下面的校正或者修改. (点击这里开始一个新的帖子)
姓名: 在 cookie 中记住我的名字

屏幕抓图:(jpeg 或 png)