Advertisement
Guest User

Untitled

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