alsaconf 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  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. #BK hacked for puppy linux 4.02, may 2008.
  20. #v425 fix for busybox depmod.
  21. #101015 BK various fixes. depmod now full version. config is now /etc/modprobe.d/alsa.conf
  22. #101015, 101017 using Xdialog and gtkdialog-splash instead of dialog and echo.
  23. #110102 shinobar: precaution, check if need to run depmod.
  24. #110405 fix 'free' applet output format different in later versions of busybox.
  25. #110506 /etc/init.d/10alsa name fix, but this fix might break alsaconf as option 'stop' then 'restart' might not be handled properly in 10alsa.
  26. #110509 rerwin: take version from alsacctl.
  27. #110509 rerwin: remove sound card entry in /etc/modprobe.d/alsa.conf before writing it.
  28. #110519 warning msg that reboot may be required.
  29. #120201 rodin.s: update internationalized.
  30. #120329 Xdialog bug --yesno supposed to "yes" "No" buttons, but they are "OK" "Cancel".
  31. #101015 check for low ram, warn full depmod may not work... 110405...
  32. #FREEMEM=`free | tr -s ' ' | grep -o 'Total: [0-9]*' | cut -f 2 -d ' '`
  33. memTOTALK=`free | grep -o 'Mem: .*' | tr -s ' ' | cut -f 2 -d ' '`
  34. swapTOTALK=`free | grep -o 'Swap: .*' | tr -s ' ' | cut -f 2 -d ' '`
  35. TOTALMEM=`expr $memTOTALK + $swapTOTALK`
  36. #rodin.s: removed later in script for i18n
  37. #if [ $TOTALMEM -lt 99000 ];then
  38. # yaf-splash -placement center -bg pink -close box -text "This computer has very little RAM, perhaps not enough to run the 'depmod' utility (which the ALSA Wizard needs to run). Shutdown first, to create a save-file for the session, and you may then have enough working memory at the next boot. Click button to exit Wizard..."
  39. # exit
  40. #fi
  41. cfgfile="/etc/modprobe.d/alsa.conf" #101014
  42. touch /etc/modprobe.d/alsa.conf
  43. MYLANG=$LANG
  44. export LANG=C #to keep Xdialog happy. 120329 this should be removed, then remove all the LANG=$MYLANG prefixes.
  45. export TEXTDOMAIN=alsaconf
  46. export OUTPUT_CHARSET=UTF-8
  47. #export XDIALOG_HIGH_DIALOG_COMPAT=1 #101015 # rodin.s: comment out for better layout in Russian
  48. #DIALOG=dialog
  49. DIALOG='Xdialog' #101015
  50. Yes_lbl="$(LANG=$MYLANG gettext 'Yes')"
  51. No_lbl="$(LANG=$MYLANG gettext 'No')"
  52. prefix=/usr
  53. exec_prefix=${prefix}
  54. bindir=${exec_prefix}/bin
  55. sbindir=${exec_prefix}/sbin
  56. #version=1.0.23 #
  57. version="`alsactl --version | cut -f 3 -d ' '`" #110509 rerwin
  58. USE_NLS=yes
  59. # Useful for debugging
  60. PROCFS="/proc"
  61. SYSFS="/sys"
  62. # i18n stuff
  63. if test "$USE_NLS" = "yes" && which gettext > /dev/null; then
  64. xecho() {
  65. LANG=$MYLANG gettext -s "$*"
  66. }
  67. else
  68. xecho() {
  69. echo "$*"
  70. }
  71. gettext() {
  72. echo -n "$*"
  73. }
  74. fi
  75. xmsg() {
  76. msg=$(LANG=$MYLANG gettext "$1")
  77. shift
  78. printf "$msg" $*
  79. }
  80. # moved it here for gettext to work - rodin.s
  81. if [ $TOTALMEM -lt 99000 ];then
  82. yaf-splash -placement center -bg pink -close box -text "$(xmsg 'This computer has very little RAM, perhaps not enough to run the "depmod" utility (which the ALSA Wizard needs to run). Shutdown first, to create a save-file for the session, and you may then have enough working memory at the next boot. Click button to exit Wizard...')"
  83. exit
  84. fi
  85. # Check for GNU/Linux distributions BK...
  86. distribution="unknown"
  87. for prog in lspci lsmod; do
  88. for path in /sbin /usr/sbin /bin /usr/bin;do
  89. test -x $path/$prog && eval $prog=$path/$prog
  90. done
  91. done
  92. unset prog path
  93. usage() {
  94. xecho "ALSA configurator"
  95. echo " version $version"
  96. xecho "usage: alsaconf [options]
  97. -l|--legacy check only legacy non-isapnp cards
  98. -m|--modinfo read module descriptions instead of reading card db
  99. -s|--sound wav-file
  100. use the specified wav file as a test sound
  101. -u|--uid uid set the uid for the ALSA devices (default = 0) [obsoleted]
  102. -g|--gid gid set the gid for the ALSA devices (default = 0) [obsoleted]
  103. -d|--devmode mode
  104. set the permission for ALSA devices (default = 0666) [obs.]
  105. -r|--strict set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]
  106. -L|--log file logging on the specified file (for debugging purpose only)
  107. -p|--probe card-name
  108. probe a legacy non-isapnp card and print module options
  109. -P|--listprobe list the supported legacy card modules
  110. -c|--config file
  111. specify the module config file
  112. -R|--resources list available DMA and IRQ resources with debug for legacy
  113. -h|--help what you're reading"
  114. }
  115. 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
  116. eval set -- "$OPTS"
  117. do_legacy_only=0
  118. use_modinfo_db=0
  119. alsa_uid=0
  120. alsa_gid=0
  121. alsa_mode=0666
  122. legacy_probe_card=""
  123. LOGFILE=""
  124. TESTSOUND="/usr/share/audio/2barks.au" #BK
  125. try_all_combination=0
  126. resources="false"
  127. # legacy support
  128. LEGACY_CARDS="opl3sa2 cs4236 cs4232 cs4231 es18xx es1688 sb16 sb8"
  129. while true ; do
  130. case "$1" in
  131. -l|--legacy)
  132. do_legacy_only=1; shift ;;
  133. -m|--modinfo)
  134. use_modinfo_db=1; shift ;;
  135. -s|--sound)
  136. TESTSOUND=$2; shift 2;;
  137. -h|--help)
  138. usage; exit 0 ;;
  139. -L|--log)
  140. LOGFILE="$2"; shift 2;;
  141. -p|--probe)
  142. legacy_probe_card="$2"; shift 2;;
  143. -P|--listprobe)
  144. echo "$LEGACY_CARDS"; exit 0;;
  145. -u|--uid)
  146. alsa_uid="$2"; shift 2;;
  147. -g|--gid)
  148. alsa_gid="$2"; shift 2;;
  149. -d|--devmode)
  150. alsa_mode="$2"; shift 2;;
  151. -r|--strict)
  152. alsa_uid=0; alsa_gid=17; alsa_mode=0660; shift;;
  153. -c|--config)
  154. cfgfile="$2"; shift 2;;
  155. -R|--resources)
  156. resources="true"; shift;;
  157. --) shift ; break ;;
  158. *) usage ; exit 1 ;;
  159. esac
  160. done
  161. #
  162. # probe legacy ISA cards
  163. #
  164. check_dma_avail () {
  165. list=""
  166. if [ -d $SYSFS/bus/pnp/devices ]; then
  167. for dma in $*; do
  168. ok="true"
  169. for i in $SYSFS/bus/pnp/devices/??:* ; do
  170. if grep -q "state = active" $i/resources ; then
  171. if grep -q '^dma '$dma'$' $i/resources; then
  172. ok="false"
  173. fi
  174. fi
  175. done
  176. if [ -r $PROCFS/dma ]; then
  177. if grep -q '^ *'$dma': ' $PROCFS/dma ; then
  178. ok="false"
  179. fi
  180. fi
  181. if [ "$ok" = "true" ]; then
  182. list="$list $dma"
  183. fi
  184. done
  185. else
  186. if [ -r $PROCFS/dma ]; then
  187. for dma in $*; do
  188. grep -q '^ *'$dma': ' $PROCFS/dma || list="$list $dma"
  189. done
  190. fi
  191. fi
  192. if [ ! -z "$list" ]; then
  193. echo $list
  194. fi
  195. }
  196. check_irq_avail () {
  197. list=""
  198. if [ -d $SYSFS/bus/pnp/devices ]; then
  199. for irq in $*; do
  200. ok="true"
  201. for i in $SYSFS/bus/pnp/devices/??:* ; do
  202. if grep -q "state = active" $i/resources ; then
  203. if grep -q '^irq '$irq'$' $i/resources; then
  204. ok="false"
  205. fi
  206. fi
  207. done
  208. if [ -r $PROCFS/interrupts ]; then
  209. if grep -q '^ *'$irq': ' $PROCFS/interrupts ; then
  210. ok="false"
  211. fi
  212. fi
  213. if [ "$ok" = "true" ]; then
  214. list="$list $irq"
  215. fi
  216. done
  217. else
  218. if [ -r $PROCFS/interrupts ]; then
  219. for irq in $*; do
  220. grep -q '^ *'$irq': ' $PROCFS/interrupts || list="$list $irq"
  221. done
  222. fi
  223. fi
  224. if [ ! -z "$list" ]; then
  225. echo $list
  226. fi
  227. }
  228. #
  229. #
  230. #
  231. if [ "$resources" = "true" ]; then
  232. if [ -d $SYSFS/bus/pnp/devices ]; then
  233. for i in $SYSFS/bus/pnp/devices/??:* ; do
  234. if [ "$resources" = "true" ]; then
  235. echo ">>>>> PnP file: $i/resources"
  236. cat $i/resources
  237. fi
  238. done
  239. fi
  240. if [ -r $PROCFS/dma ]; then
  241. echo ">>>>> Allocated dma channels:"
  242. cat $PROCFS/dma
  243. fi
  244. if [ -r $PROCFS/interrupts ]; then
  245. echo ">>>>> Allocated interrupt channels:"
  246. cat $PROCFS/interrupts
  247. fi
  248. echo -n "Valid DMA channels: "
  249. check_dma_avail 0 1 2 3 4 5 6 7
  250. echo -n "Valid IRQ channels: "
  251. check_irq_avail 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  252. exit 0
  253. fi
  254. # Check for root privileges
  255. if [ `id -u` -ne 0 ]; then
  256. xecho "You must be root to use this script."
  257. yaf-splash -placement center -bg pink -close box -text "$(xmsg 'You must be root to use this script.')"
  258. exit 1
  259. fi
  260. #
  261. # check the snd_ prefix for ALSA module options
  262. # snd_ prefix is obsoleted since 0.9.0rc4.
  263. #
  264. if /sbin/modinfo -p snd | grep -q snd_ ; then
  265. mpfx="snd_"
  266. else
  267. mpfx=""
  268. fi
  269. alsa_device_opts=""
  270. if /sbin/modinfo -p snd | grep -q uid ; then
  271. if [ x"$alsa_uid" != x0 ]; then
  272. alsa_device_opts="$alsa_device_opts ${mpfx}device_uid=$alsa_uid"
  273. fi
  274. if [ x"$alsa_gid" != x0 ]; then
  275. alsa_device_opts="$alsa_device_opts ${mpfx}device_gid=$alsa_gid"
  276. fi
  277. fi
  278. if /sbin/modinfo -p snd | grep -q device_mode ; then
  279. if [ x"$alsa_mode" != x0 ]; then
  280. alsa_device_opts="$alsa_device_opts ${mpfx}device_mode=$alsa_mode"
  281. fi
  282. fi
  283. #
  284. # remove the previous configuration by alsaconf
  285. #
  286. #remove_ac_block() {
  287. # awk '/^'"$ACB"'$/,/^'"$ACE"'$/ { next } { print }'
  288. #}
  289. remove_ac_block() {
  290. awk '/^'"$ACB"'$/,/^'"$ACE"'$/ { next }
  291. /^'"alias snd-card-0"'/ { next }
  292. /^'"alias sound-slot-0"'/ { next }
  293. { print }'
  294. } #110509 rerwin: remove sound card entry in /etc/modprobe.d/alsa.conf before writing it.
  295. #
  296. # set default mixer volumes
  297. #101015 BK had to add ,0 after Front...
  298. set_mixers() {
  299. amixer -s -q <<EOF
  300. set Master 75% unmute
  301. set Master -12dB
  302. set 'Master Mono' 75% unmute
  303. set 'Master Mono' -12dB
  304. set Front,0 75% unmute
  305. set Front,0 -12dB
  306. set PCM 90% unmute
  307. set PCM 0dB
  308. mixer Synth 90% unmute
  309. mixer Synth 0dB
  310. mixer CD 90% unmute
  311. mixer CD 0dB
  312. # mute mic
  313. set Mic 0% mute
  314. # ESS 1969 chipset has 2 PCM channels
  315. set PCM,1 90% unmute
  316. set PCM,1 0dB
  317. # Trident/YMFPCI/emu10k1
  318. set Wave 100% unmute
  319. set Music 100% unmute
  320. set AC97 100% unmute
  321. # CS4237B chipset:
  322. set 'Master Digital' 75% unmute
  323. # Envy24 chips with analog outs
  324. set DAC 90% unmute
  325. set DAC -12dB
  326. set DAC,0 90% unmute
  327. set DAC,0 -12dB
  328. set DAC,1 90% unmute
  329. set DAC,1 -12dB
  330. # some notebooks use headphone instead of master
  331. set Headphone 75% unmute
  332. set Headphone -12dB
  333. set Playback 100% unmute
  334. # turn off digital switches
  335. set "SB Live Analog/Digital Output Jack" off
  336. set "Audigy Analog/Digital Output Jack" off
  337. EOF
  338. }
  339. # INTRO BK...
  340. intro() {
  341. local msg=$(xmsg "
  342. ALSA WIZARD
  343. version %s
  344. This Wizard is a configurator for
  345. Advanced Linux Sound Architecture (ALSA) driver.
  346. (with some modifications for Puppy Linux)
  347. If any are running, you should close all sound
  348. apps now (like Mplayer, mhWaveEdit, etc.).
  349. " $version)
  350. echo "Getting started..." #101017
  351. $DIALOG --title "ALSA Sound Wizard" --cr-wrap --msgbox "$msg" 20 63 || acex 0
  352. }
  353. # FAREWELL BK...
  354. farewell() {
  355. local msg=$(xmsg "
  356. OK, sound driver is configured.
  357. ALSA WIZARD
  358. will prepare the card for playing now.
  359. Technical: \"/etc/init.d/10alsa start\" will be used to
  360. initialise ALSA, amixer used to raise volume.
  361. You can change the volume later via a mixer
  362. program such as Retrovol (Multimedia menu), or
  363. click on speaker icon in tray for volume slider.
  364. ")
  365. echo "Sound driver configured." #101017
  366. $DIALOG --title "ALSA Sound Wizard" --cr-wrap --msgbox "$msg" 20 60 || acex 0
  367. }
  368. # Exit function
  369. acex() {
  370. cleanup
  371. clear
  372. exit $1
  373. }
  374. #
  375. # search for alsasound init script
  376. #
  377. #BK...
  378. #rcalsasound="/etc/rc.d/rc.alsa"
  379. #w468...
  380. rcalsasound="/etc/init.d/10alsa" #110506
  381. # MAIN
  382. if [ -d $PROCFS/asound ]; then
  383. $rcalsasound stop >/dev/null 2>&1
  384. $rcalsasound unload >/dev/null 2>&1
  385. /sbin/rmmod dmasound dmasound_awacs 2>/dev/null
  386. fi
  387. cleanup () {
  388. killall -9 aplay arecord >/dev/null 2>&1
  389. /sbin/modprobe -r isapnp >/dev/null 2>&1
  390. /sbin/modprobe -r isa-pnp >/dev/null 2>&1
  391. rm -f "$TMP" "$addcfg" "$FOUND" "$DUMP"
  392. }
  393. trap cleanup 0
  394. TMP=`mktemp -q /tmp/alsaconf.XXXXXX`
  395. if [ $? -ne 0 ]; then
  396. xecho "Can't create temp file, exiting..."
  397. exit 1
  398. fi
  399. addcfg=`mktemp -q /tmp/alsaconf.XXXXXX`
  400. if [ $? -ne 0 ]; then
  401. xecho "Can't create temp file, exiting..."
  402. exit 1
  403. fi
  404. FOUND=`mktemp -q /tmp/alsaconf.XXXXXX`
  405. if [ $? -ne 0 ]; then
  406. xecho "Can't create temp file, exiting..."
  407. exit 1
  408. fi
  409. DUMP=`mktemp -q /tmp/alsaconf.XXXXXX`
  410. if [ $? -ne 0 ]; then
  411. xecho "Can't create temp file, exiting..."
  412. exit 1
  413. fi
  414. # convert ISA PnP id number to string 'ABC'
  415. convert_isapnp_id () {
  416. if [ -z "$1" ]; then
  417. echo "XXXX"
  418. return
  419. fi
  420. let a='('$1'>>2) & 0x3f'
  421. let b='(('$1' & 0x03) << 3) | (('$1' >> 13) & 0x07)'
  422. let c='('$1'>> 8) & 0x1f'
  423. strs='@ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  424. echo ${strs:$a:1}${strs:$b:1}${strs:$c:1}
  425. }
  426. # swap high & low bytes
  427. swap_number () {
  428. if [ -z "$1" ]; then
  429. echo "0000"
  430. return
  431. fi
  432. let v='(('$1'>>8)&0xff)|(('$1'&0xff)<<8)'
  433. printf "%04x" $v
  434. }
  435. # build card database
  436. # build_card_db filename
  437. build_card_db () {
  438. MODDIR=/lib/modules/`uname -r`
  439. last_driver=""
  440. echo -n > $1
  441. [ -f $MODDIR/modules.pcimap ] || depmod # 2jan2010 shinobar: precaution.
  442. # list pci cards
  443. while read driver vendor device dummy; do
  444. if expr $driver : 'snd-.*' >/dev/null ; then
  445. if [ "$last_driver" != "$driver" ]; then
  446. echo $driver.o
  447. last_driver=$driver
  448. fi
  449. id1=`printf '0x%04x' $vendor`
  450. id2=`printf '0x%04x' $device`
  451. echo "PCI: $id1=$id2"
  452. fi
  453. done < $MODDIR/modules.pcimap >> $1
  454. # list isapnp cards
  455. while read driver cardvendor carddevice data vendor func; do
  456. if expr $driver : 'snd-.*' >/dev/null ; then
  457. if [ "$last_driver" != "$driver" ]; then
  458. echo $driver.o
  459. last_driver=$driver
  460. fi
  461. id1=`convert_isapnp_id $cardvendor`
  462. dev1=`swap_number $carddevice`
  463. id2=`convert_isapnp_id $vendor`
  464. dev2=`swap_number $func`
  465. echo "ISAPNP: $id1$dev1=$id2$dev2"
  466. fi
  467. done < $MODDIR/modules.isapnpmap >> $1
  468. }
  469. #
  470. # probe cards
  471. #
  472. probe_cards () {
  473. found="0"
  474. test -r $PROCFS/isapnp || /sbin/modprobe isapnp >/dev/null 2>&1
  475. test -r $PROCFS/isapnp || /sbin/modprobe isa-pnp >/dev/null 2>&1
  476. if [ -r $PROCFS/isapnp ]; then
  477. cat $PROCFS/isapnp >"$DUMP"
  478. found="1"
  479. elif [ -d $SYSFS/bus/pnp/devices ]; then
  480. # use 2.6 kernel's sysfs output
  481. # fake the isapnp dump
  482. index=0
  483. bindex=0
  484. for d1 in $SYSFS/devices/pnp* ; do
  485. for d2 in $d1/*:* ; do
  486. if [ -r $d2/card_id ]; then
  487. id=`cat $d2/card_id`
  488. name=`cat $d2/name`
  489. echo "Card $index '$id:$name' " >> "$DUMP"
  490. index=$[$index+1]
  491. found="1"
  492. else if [ -r $d2/id ]; then
  493. # FIXME: multiple id might be present (separated with new-line)
  494. id=`head -n 1 $d2/id`
  495. echo "BIOS $bindex '$id' " >> "$DUMP"
  496. bindex=$[$bindex+1]
  497. found="1"
  498. fi
  499. fi
  500. done
  501. done
  502. fi
  503. if [ "$found" = "0" ]; then
  504. echo -n >"$DUMP"
  505. fi
  506. CARDID_DB=/var/tmp/alsaconf.cards
  507. if [ ! -r $CARDID_DB ]; then
  508. use_modinfo_db=1
  509. fi
  510. if [ $use_modinfo_db != 1 ]; then
  511. if [ $CARDID_DB -ot /lib/modules/`uname -r`/modules.dep ]; then
  512. use_modinfo_db=1
  513. fi
  514. fi
  515. if [ $use_modinfo_db = 1 ]; then
  516. xecho "Building card database, please wait..."
  517. #yaf-splash -placement center -bg orange -close never -text "Building card database, please wait..." &
  518. #YAFPID=$!
  519. build_card_db $CARDID_DB
  520. #kill $YAFPID
  521. fi
  522. if [ ! -r $CARDID_DB ]; then
  523. xecho "No card database is found."
  524. yaf-splash -placement center -bg pink -close box -text "No card database is found."
  525. exit 1
  526. fi
  527. ncards=`grep '^snd-.*\.o$' $CARDID_DB | wc -w`
  528. msg=$(xmsg "Searching sound cards")
  529. awk '
  530. BEGIN {
  531. format="%-40s %s\n";
  532. ncards='"$ncards"';
  533. idx=0;
  534. }
  535. /^snd-.*\.o$/{
  536. sub(/.o$/, "");
  537. driver=$0;
  538. perc=(idx * 100) / (ncards + 1);
  539. print int(perc);
  540. idx++;
  541. }
  542. /^[<literal space><literal tab>]*PCI: /{
  543. gsub(/0x/, "");
  544. gsub(/=/, ":");
  545. x = sprintf ("'$lspci' -n 2>/dev/null| grep '"' 04..: '"' | grep %s", $2);
  546. if (system (x) == 0)
  547. printf "%s %s\n", $2, driver >>"'"$FOUND"'"
  548. }
  549. /^[<literal space><literal tab>]*ISAPNP: /{
  550. id2 = substr($0, index($0, "=")+1);
  551. gsub(/=.*/, "");
  552. x = sprintf ("grep '\''^Card [0-9] .%s:'\'' '"$DUMP"'", $2);
  553. if (system (x) == 0)
  554. printf "%s %s\n", $2, driver >>"'"$FOUND"'"
  555. else if (index($2, "ffff") > 0) {
  556. x = sprintf ("grep '\''^BIOS [0-9]* .%s.'\'' '"$DUMP"'", id2);
  557. if (system (x) == 0)
  558. printf "%s %s\n", id2, driver >>"'"$FOUND"'"
  559. }
  560. }' < $CARDID_DB |\
  561. $DIALOG --title "ALSA Wizard" --gauge "$msg" 6 40 0
  562. #
  563. # PowerMac
  564. #
  565. if grep -q MacRISC $PROCFS/cpuinfo; then
  566. MODDIR=/lib/modules/`uname -r`
  567. find $MODDIR -name 'snd-powermac*' -print | \
  568. while read i; do
  569. i=${i##*/}
  570. i=${i%%.o}
  571. i=${i%%.ko}
  572. echo "PowerMac $i" >> $FOUND
  573. done
  574. fi
  575. #
  576. # Sparc
  577. #
  578. if grep -q Sparc $PROCFS/cpuinfo; then
  579. test -r $PROCFS/openprom/name || /bin/mount -t openpromfs none $PROCFS/openprom >/dev/null 2>&1
  580. # Check for an "audio" device
  581. audio=
  582. compat=
  583. if test -r $PROCFS/openprom; then
  584. audio=`find $PROCFS/openprom -follow -type d -name "audio*" -print`
  585. fi
  586. if test -n "$audio"; then
  587. compat=`cat $audio/compatible`
  588. compat=${compat#\'}
  589. compat=${compat%\'}
  590. compat=${compat#SUNW,}
  591. fi
  592. # Go through all cards we have
  593. MODDIR=/lib/modules/`uname -r`
  594. find $MODDIR -name 'snd-sun-*' -print | \
  595. while read i; do
  596. i=${i##*/}
  597. i=${i%%.o}
  598. i=${i%%.ko}
  599. sdev=`echo ${i#snd-sun-} | tr "[a-z]" "[A-Z]"`
  600. if test "$sdev" = "$compat"; then
  601. echo "$sdev $i" >> $FOUND
  602. elif test -r $PROCFS/openprom; then
  603. find $PROCFS/openprom -follow -type d -name "SUNW,${sdev}*" \
  604. -exec echo "$sdev $i" \; 2>/dev/null >> $FOUND
  605. else
  606. echo "$sdev $i" >> $FOUND
  607. fi
  608. done
  609. fi
  610. }
  611. #
  612. # look for a descriptive device name from the given device id
  613. #
  614. find_device_name () {
  615. 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
  616. $lspci -d $1 2>/dev/null| sed -e 's/^.*:..\.. [^:]*: //g'
  617. return
  618. elif expr "$1" : '[A-Z@][A-Z@][A-Z@][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then
  619. cardname=`grep '^Card [0-9]\+ .'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`
  620. echo $cardname
  621. else
  622. echo $1
  623. fi
  624. }
  625. # get hwcfg file type from the given driver name
  626. get_hwcfg_type () {
  627. while read dev driver; do
  628. if [ "$driver" = "$1" ]; then
  629. case "$dev" in
  630. *:*)
  631. # FIXME: need to look around /sys/bus/pci/* (or use vpid-* ?)
  632. devid=`$lspci -d "$dev" | head -n 1 | sed -e 's/ .*$//'`
  633. case "$devid" in
  634. *:*:*.*) ;;
  635. *) devid="0000:$devid" ;;
  636. esac
  637. echo bus-pci-$devid
  638. ;;
  639. *)
  640. echo $driver
  641. ;;
  642. esac
  643. break
  644. fi
  645. done
  646. }
  647. # clean up all hwcfg-* files containing ALSA modules
  648. # alsaconf sets up exclusively
  649. cleanup_hwcfg () {
  650. for i in /etc/sysconfig/hardware/hwcfg-*; do
  651. grep -q "MODULE='snd-" $i && rm -f $i
  652. done
  653. }
  654. #
  655. # set up /etc/sysconfig/hardware/hwcfg-* stuff
  656. #
  657. setup_hwcfg () {
  658. card=$1
  659. cleanup_hwcfg
  660. cfg=`echo "$devs_olist" | get_hwcfg_type $card`
  661. echo "MODULE='$card'" > /etc/sysconfig/hardware/hwcfg-$cfg
  662. echo "STARTMODE='auto'" >> /etc/sysconfig/hardware/hwcfg-$cfg
  663. }
  664. #
  665. # configure and try test sound
  666. # BK inserted line, changed width from 50 to 70...
  667. ac_config_card () {
  668. CARD_DRIVER=snd-$1
  669. CARD_OPTS="${*:2}"
  670. msg=$(xmsg "
  671. Configuring %s
  672. PLEASE ANSWER YES HERE SO PUPPY WILL USE DRIVER ON NEXT BOOT
  673. Do you want to modify %s?" $CARD_DRIVER $cfgfile)
  674. echo "Configure driver ${CARD_DRIVER}..." #101017
  675. $DIALOG --title "ALSA Wizard" --cr-wrap --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$msg" 10 80 || acex 0
  676. clear
  677. # Copy conf.modules and make changes.
  678. ACB="# --- BEGIN: Generated by ALSACONF, do not edit. ---"
  679. ACE="# --- END: Generated by ALSACONF, do not edit. ---"
  680. # Detect 2.2.X kernel
  681. KVER=`uname -r | tr ".-" " "`
  682. KVER1=`echo $KVER | cut -d" " -f1`
  683. KVER2=`echo $KVER | cut -d" " -f2`
  684. if [ $KVER1 -ge 2 ] && [ $KVER2 -ge 2 ]; then
  685. SOUND_CORE="soundcore"
  686. else
  687. SOUND_CORE="snd"
  688. fi
  689. if [ -r $cfgfile ] ; then
  690. #remove_ac_block < $cfgfile | remove_sndconfig_block | uniq > $TMP
  691. #remove_ac_block < $cfgfile | remove_y2_block | uniq > $TMP
  692. remove_ac_block < $cfgfile | uniq > $TMP #101015
  693. fi
  694. if [ -z "$have_alias" ]; then
  695. if grep -q char-major-116 /lib/modules/`uname -r`/modules.alias; then
  696. have_alias="yes"
  697. fi
  698. fi
  699. if [ -z "$have_alias" ]; then
  700. echo "alias char-major-116 snd
  701. alias char-major-14 $SOUND_CORE
  702. alias sound-service-0-0 snd-mixer-oss
  703. alias sound-service-0-1 snd-seq-oss
  704. alias sound-service-0-3 snd-pcm-oss
  705. alias sound-service-0-8 snd-seq-oss
  706. alias sound-service-0-12 snd-pcm-oss" >> $addcfg
  707. fi
  708. if [ -n "$alsa_device_opts" ]; then
  709. echo "options snd $alsa_device_opts" >> $addcfg
  710. fi
  711. echo "alias snd-card-0 $CARD_DRIVER
  712. alias sound-slot-0 $CARD_DRIVER" >> $addcfg
  713. if [ -n "$CARD_OPTS" ]; then
  714. echo "options $CARD_DRIVER $CARD_OPTS" >> $addcfg
  715. fi
  716. echo "$ACB
  717. # --- ALSACONF version $version ---" >> $TMP
  718. cat "$addcfg" >> "$TMP"
  719. echo "$ACE
  720. " >> $TMP
  721. cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile"
  722. /sbin/depmod -a 2>/dev/null
  723. farewell
  724. clear
  725. if [ -x $rcalsasound ] ; then
  726. echo Loading driver...
  727. $rcalsasound restart
  728. fi
  729. #101015 need to restart volume tray applet...
  730. if [ -f /root/Startup/obmixer_tray ];then
  731. [ "`pidof obmixer_tray`" = "" ] && nohup /root/Startup/obmixer_tray >/dev/null &
  732. fi
  733. if [ -f /root/Startup/retrovol_tray ];then
  734. [ "`pidof retrovol`" = "" ] && nohup /root/Startup/retrovol_tray >/dev/null &
  735. fi
  736. echo Setting default volumes...
  737. if [ -x $bindir/set_default_volume ]; then
  738. $bindir/set_default_volume -f
  739. else
  740. set_mixers
  741. fi
  742. if [ -f $TESTSOUND ]; then
  743. #BK...
  744. msg=$(xmsg "
  745. The mixer is set up now for for playing.
  746. Shall I try to play a sound sample now?
  747. NOTE:
  748. If you have a big amplifier, lower your volumes or say no.
  749. Otherwise check that your speaker volume is wound up,
  750. then select <Yes> to play test sound...
  751. ")
  752. if $DIALOG --title "ALSA Wizard" --cr-wrap --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$msg" 14 70
  753. then
  754. clear
  755. echo
  756. #aplay -N $TESTSOUND
  757. #BK two-barks gets truncated, -N option causes it...
  758. aplay $TESTSOUND & #101015
  759. sleep 2 #101015
  760. killall aplay #101015
  761. fi
  762. fi
  763. if [ ! -r /etc/asound.state ]; then
  764. xecho "Saving the mixer setup used for this in /etc/asound.state."
  765. $sbindir/alsactl store
  766. fi
  767. clear
  768. xecho "
  769. ===============================================================================
  770. Now ALSA is ready to use.
  771. For adjustment of volumes, use your favorite mixer.
  772. Have a lot of fun!
  773. "
  774. }
  775. # check playback
  776. # return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
  777. ac_try_load () {
  778. test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
  779. /sbin/modprobe snd-$1 ${*:2} >/dev/null 2>&1
  780. if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then
  781. : ;
  782. else
  783. /sbin/modprobe -r snd-$1 >/dev/null 2>&1
  784. return 1
  785. fi
  786. # mute mixers
  787. amixer set Master 0% mute >/dev/null 2>&1
  788. amixer set PCM 0% mute >/dev/null 2>&1
  789. # output 0.5 sec
  790. head -c 4000 < /dev/zero | aplay -N -r8000 -fS16_LE -traw -c1 > /dev/null 2>&1 &
  791. # remember pid
  792. pp=$!
  793. # sleep for 2 seconds (to be sure -- 1 sec would be enough)
  794. sleep 2
  795. # kill the child process if still exists.
  796. kill -9 $pp > /dev/null 2>&1
  797. st=$?
  798. ac_cardname=`head -n 1 $PROCFS/asound/cards | sed -e 's/^[0-9].* - \(.*\)$/\1/'`
  799. /sbin/modprobe -r snd-$1 >/dev/null 2>&1
  800. if [ $st = 0 ]; then
  801. # irq problem?
  802. test -n "$LOGFILE" && echo "no playback return" >> "$LOGFILE"
  803. return 2
  804. else
  805. # seems ok!
  806. test -n "$LOGFILE" && echo "playback OK" >> "$LOGFILE"
  807. return 0
  808. fi
  809. }
  810. # check capture
  811. # return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
  812. # ac_try_capture card duplex opts
  813. ac_try_capture () {
  814. test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
  815. /sbin/modprobe snd-$1 ${*:3} >/dev/null 2>&1
  816. if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then
  817. : ;
  818. else
  819. /sbin/modprobe -r snd-$1 >/dev/null 2>&1
  820. return 1
  821. fi
  822. # mute mixers
  823. amixer set Master 0% mute >/dev/null 2>&1
  824. amixer set PCM 0% mute >/dev/null 2>&1
  825. play_pid=0
  826. if [ $2 = yes ]; then
  827. # try duplex - start dummy playing
  828. aplay -N -r8000 -fS16_LE -traw -c1 < /dev/zero > /dev/null 2>&1 &
  829. play_pid=$!
  830. fi
  831. # record 1sec
  832. arecord -N -d1 > /dev/null 2>&1 &
  833. # remember pid
  834. pp=$!
  835. # sleep for 2 seconds
  836. sleep 2
  837. # kill the child process if still exists.
  838. kill -9 $pp > /dev/null 2>&1
  839. st=$?
  840. # kill playback process if any
  841. test $play_pid != 0 && kill -9 $play_pid
  842. /sbin/modprobe -r snd-$1 >/dev/null 2>&1
  843. if [ $st = 0 ]; then
  844. test -n "$LOGFILE" && echo "capture no return" >> "$LOGFILE"
  845. return 2
  846. else
  847. test -n "$LOGFILE" && echo "capture OK" >> "$LOGFILE"
  848. return 0
  849. fi
  850. }
  851. get_dma_pair () {
  852. case $1 in
  853. 0)
  854. echo 1 3 5;;
  855. 1)
  856. echo 0 3 5;;
  857. 3)
  858. echo 1 0 5;;
  859. 5)
  860. echo 3 1 0;;
  861. esac
  862. }
  863. #
  864. # check playback on specified irqs
  865. #
  866. # ac_try_irq card opts irqs...
  867. # return 0 - OK, 1 - NG, 2 - not working (dma problem?)
  868. #
  869. ac_try_irq () {
  870. card=$1
  871. opts="$2 ${mpfx}irq=$3"
  872. ac_try_load $card $opts >/dev/null 2>&1
  873. result=$?
  874. case $result in
  875. 0)
  876. ac_opts="$opts"
  877. return 0
  878. ;;
  879. 2)
  880. for irq in ${*:4}; do
  881. opts="$2 ${mpfx}irq=$irq"
  882. ac_try_load $card $opts >/dev/null 2>&1
  883. if [ $? = 0 ]; then
  884. ac_opts="$opts"
  885. return 0
  886. fi
  887. done
  888. return 2
  889. ;;
  890. esac
  891. return 1
  892. }
  893. #
  894. # check playback/capture on dma1 & dma2 & specified irqs
  895. #
  896. # ac_try_dmas card opts irqs...
  897. # return 0 - OK, 1 - NG
  898. #
  899. ac_try_dmas () {
  900. dma_list=`check_dma_avail 1 0 3 5`
  901. for irq in ${*:3}; do
  902. for dma1 in $dma_list; do
  903. for dma2 in `get_dma_pair $dma1`; do
  904. opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq"
  905. ac_try_load $1 $opts >/dev/null 2>&1
  906. result=$?
  907. if [ $result = 1 ]; then
  908. if [ $try_all_combination = 1 ]; then
  909. continue
  910. else
  911. return 1
  912. fi
  913. elif [ $result = 0 ]; then
  914. test -n "$LOGFILE" && echo "Now checking capture..." >> "$LOGFILE"
  915. ac_opts="$opts"
  916. ac_try_capture $1 yes $opts >/dev/null 2>&1 && return 0
  917. for d in yes no; do
  918. for dma2 in $dma_list; do
  919. if [ $dma1 != $dma2 ]; then
  920. opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq"
  921. ac_opts="$opts"
  922. ac_try_capture $1 $d $opts >/dev/null 2>&1 && return 0
  923. fi
  924. done
  925. done
  926. return 0
  927. fi
  928. done
  929. done
  930. done
  931. return 1
  932. }
  933. # check if the option $2 exists in card $1: set value $3
  934. ac_check_option () {
  935. if /sbin/modinfo -p snd-$1 | grep -q $2; then
  936. echo "$2=$3"
  937. fi
  938. }
  939. ac_try_card_sb8 () {
  940. card=sb8
  941. irq_list=`check_irq_avail 5 3 9 10 7`
  942. for dma8 in `check_dma_avail 1 3`; do
  943. opts="${mpfx}dma8=$dma8"
  944. ac_try_irq $card "$opts" $irq_list && return 0
  945. done
  946. return 1
  947. }
  948. ac_try_card_sb16 () {
  949. card=sb16
  950. isapnp=`ac_check_option $card ${mpfx}isapnp 0`
  951. opts="$isapnp"
  952. irq_list=`check_irq_avail 5 9 10 7 3`
  953. dma_list=`check_dma_avail 0 1 3`
  954. dma16_list=`check_dma_avail 5 6 7`
  955. # at first try auto-probing by driver itself
  956. ac_try_load $card $opts >/dev/null 2>&1
  957. result=$?
  958. case $result in
  959. 0)
  960. ac_opts="$opts"
  961. ac_try_capture $card yes $opts >/dev/null 2>&1 && return 0
  962. for d in yes no; do
  963. for dma8 in $dma_list; do
  964. for irq in $irq_list; do
  965. opts="${mpfx}dma8=$dma8 ${mpfx}irq=$irq $isapnp"
  966. ac_try_capture $card $d $opts >/dev/null 2>&1 && return 0
  967. done
  968. done
  969. done
  970. return 0
  971. ;;
  972. 2)
  973. for dma16 in $dma16_list; do
  974. opts="${mpfx}dma16=$dma16 $isapnp"
  975. if ac_try_irq $card "$opts" $irq_list ; then
  976. ac_try_capture $card yes $ac_opts >/dev/null 2>&1 && return 0
  977. ac_opts_saved="$ac_opts"
  978. for d in yes no; do
  979. for dma8 in $dma_list; do
  980. ac_opts="$ac_opts_saved ${mpfx}dma8=$dma8"
  981. ac_try_capture $card $d $ac_opts >/dev/null 2>&1 && return 0
  982. done
  983. done
  984. # return anyway here..
  985. return 0
  986. fi
  987. done
  988. ;;
  989. esac
  990. return 1
  991. }
  992. ac_try_card_es1688 () {
  993. card=es1688
  994. opts=""
  995. irq_list=`check_irq_avail 5 9 10 7`
  996. for dma8 in `check_dma_avail 1 3 0`; do
  997. opts="${mpfx}dma8=$dma8 ${mpfx}mpu_irq=-1"
  998. ac_try_irq $card "$opts" $irq_list && return 0
  999. done
  1000. return 1
  1001. }
  1002. ac_try_card_es18xx () {
  1003. card=es18xx
  1004. opts=`ac_check_option $card ${mpfx}isapnp 0`
  1005. ac_try_dmas $card "$opts" `check_irq_avail 5 9 10 7` && return 0
  1006. return 1
  1007. }
  1008. ac_try_card_cs4236 () {
  1009. card=cs4236
  1010. irq_list=`check_irq_avail 5 7 9 11 12 15`
  1011. isapnp=`ac_check_option $card ${mpfx}isapnp 0`
  1012. for cport in 0x538 0x210 0xf00; do
  1013. for port in 0x530 0x534; do
  1014. opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp"
  1015. ac_try_dmas $card "$opts" $irq_list && return 0
  1016. done
  1017. done
  1018. return 1
  1019. }
  1020. ac_try_card_cs4232 () {
  1021. card=cs4232
  1022. irq_list=`check_irq_avail 5 7 9 11 12 15`
  1023. isapnp=`ac_check_option $card ${mpfx}isapnp 0`
  1024. for cport in 0x538 0x210 0xf00; do
  1025. for port in 0x530 0x534; do
  1026. opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp"
  1027. ac_try_dmas $card "$opts" $irq_list && return 0
  1028. done
  1029. done
  1030. return 1
  1031. }
  1032. ac_try_card_cs4231 () {
  1033. card=cs4231
  1034. irq_list=`check_irq_avail 5 7 9 11 12 15`
  1035. for port in 0x530 0x534; do
  1036. opts="${mpfx}port=$port"
  1037. ac_try_dmas $card "$opts" $irq_list && return 0
  1038. done
  1039. return 1
  1040. }
  1041. ac_try_card_opl3sa2 () {
  1042. card=opl3sa2
  1043. irq_list=`check_irq_avail 5 9 3 1 11 12 15 0`
  1044. isapnp=`ac_check_option $card ${mpfx}isapnp 0`
  1045. for port in 0x370 0x538 0xf86 0x100; do
  1046. for wss_port in 0x530 0xe80 0xf40 0x604; do
  1047. opts="${mpfx}fm_port=-1 ${mpfx}midi_port=-1 ${mpfx}port=$port ${mpfx}wss_port=$wss_port $isapnp"
  1048. ac_try_dmas $card "$opts" $irq_list && return 0
  1049. done
  1050. done
  1051. return 1
  1052. }
  1053. ac_config_legacy () {
  1054. title=$(xmsg "WARNING")
  1055. msg=$(xmsg "
  1056. Probing legacy ISA cards might make
  1057. your system unstable.
  1058. Do you want to proceed?
  1059. ")
  1060. $DIALOG --title "$title" --cr-wrap --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$msg" 10 50 || acex 0
  1061. if [ x"$1" = x ]; then
  1062. probe_list="$LEGACY_CARDS"
  1063. else
  1064. probe_list=$*
  1065. fi
  1066. menu_args=()
  1067. for card in $probe_list; do
  1068. cardname=`/sbin/modinfo -d snd-$card | sed -e 's/^\"\(.*\)\"$/\1/g'`
  1069. if [ x"$cardname" != x ]; then
  1070. menu_args=("${menu_args[@]}" "$card" "$cardname" "on")
  1071. fi
  1072. done
  1073. if [ x$menu_args = x ]; then
  1074. msg=$(xmsg "No legacy drivers are available
  1075. for your machine")
  1076. $DIALOG --title "ALSA Wizard" --msgbox "$msg" 5 50
  1077. return 1
  1078. fi
  1079. title=$(xmsg "Driver Selection")
  1080. msg=$(xmsg " Probing legacy ISA cards
  1081. Please select the drivers to probe:")
  1082. $DIALOG --title "$title" --cr-wrap --checklist "$msg" \
  1083. 17 64 8 "${menu_args[@]}" 2> $FOUND || acex 0
  1084. if [ $try_all_combination != 1 ]; then
  1085. msg=$(xmsg "
  1086. Shall I try all possible DMA and IRQ combinations?
  1087. With this option, some unconventional configuration
  1088. might be found, but it will take much longer time.")
  1089. if $DIALOG --title "ALSA Wizard" --cr-wrap --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$msg" 10 60
  1090. then
  1091. try_all_combination=1
  1092. fi
  1093. fi
  1094. xecho "Probing legacy cards.. This may take a few minutes.."
  1095. echo -n $(xmsg "Probing: ")
  1096. cards=`cat $FOUND | tr -d \"`
  1097. for card in $cards; do
  1098. echo -n " $card"
  1099. ac_opts=""
  1100. if eval ac_try_card_$card ; then
  1101. xecho " : FOUND!!"
  1102. ac_config_card $card $ac_opts
  1103. return 0
  1104. fi
  1105. done
  1106. echo
  1107. title=$(xmsg "Result")
  1108. msg=$(xmsg "No legacy cards found")
  1109. $DIALOG --title "$title" --msgbox "$msg" 5 50
  1110. return 1
  1111. }
  1112. #
  1113. # main part continued..
  1114. #
  1115. if test -n "$LOGFILE" ; then
  1116. touch "$LOGFILE"
  1117. echo -n "Starting alsaconf: " >> "$LOGFILE"
  1118. date >> "$LOGFILE"
  1119. fi
  1120. if [ x"$legacy_probe_card" != x ]; then
  1121. ac_opts=""
  1122. if eval ac_try_card_$legacy_probe_card >/dev/null 2>&1; then
  1123. echo "$ac_opts"
  1124. echo "$ac_cardname"
  1125. exit 0
  1126. else
  1127. echo "FAILED"
  1128. exit 1
  1129. fi
  1130. fi
  1131. #script execution starts here...
  1132. #110519 warning msg that reboot may be required...
  1133. msg0=''$(xmsg 'The ALSA Wizard unloads any sound drivers and then starts again.
  1134. This causes a problem if you decide to exit anywhere before the
  1135. Wizard has gone right to the end -- if you previously had working
  1136. sound, it will then not be working -- but a reboot will fix it.
  1137. Also, unloading of the audio drivers may affect some dialup modems,
  1138. and they may not work after running this Wizard -- again, a reboot
  1139. will fix it.')'
  1140. '$(xmsg 'Do you want to continue and run the Wizard?...')''
  1141. $DIALOG --title "$(xmsg 'ALSA Sound Wizard: NOTICE')" --cr-wrap --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$msg0" 0 0 || exit 0
  1142. #welcome window...
  1143. intro
  1144. if [ $do_legacy_only = 1 ]; then
  1145. ac_config_legacy
  1146. exit 0
  1147. fi
  1148. probe_cards
  1149. devs_found=()
  1150. devs_olist=""
  1151. if [ -s "$FOUND" ]; then
  1152. while read dev card ; do
  1153. MODDIR=/lib/modules/`uname -r`
  1154. find $MODDIR -type f | grep -q -E $card'\.(o|ko)' || continue
  1155. cardname=`find_device_name $dev | cut -c 1-64`
  1156. if [ -z "$cardname" ]; then
  1157. cardname="$card"
  1158. fi
  1159. card=${card##snd-}
  1160. devs_found=("${devs_found[@]}" "$card" "$cardname")
  1161. devs_devs=("${devs_devs[@]}" "$card" "$dev")
  1162. done <"$FOUND"
  1163. devs_olist=`cat $FOUND`
  1164. fi
  1165. if [ x$devs_found != x ]; then
  1166. echo "...device found" #101017
  1167. #
  1168. # check for TP600E
  1169. #
  1170. if [ ${devs_found[0]} = cs46xx ]; then
  1171. if $lspci -nv 2>/dev/null| grep -q "Subsystem: 1014:1010"; then
  1172. msg=$(xmsg "
  1173. Looks like you having a Thinkpad 600E or 770 notebook.
  1174. On this notebook, CS4236 driver should be used
  1175. although CS46xx chip is detected.
  1176. Shall I try to snd-cs4236 driver and probe
  1177. the legacy ISA configuration?")
  1178. if $DIALOG --title "ALSA Wizard" --cr-wrap --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$msg" 13 60
  1179. then
  1180. try_all_combination=1
  1181. ac_config_legacy cs4236
  1182. exit 0
  1183. fi
  1184. elif $lspci -nv 2>/dev/null| grep -q "Subsystem: 8086:8080"; then
  1185. msg=$(xmsg "
  1186. Looks like you having a Dell Dimension machine.
  1187. On this machine, CS4232 driver should be used
  1188. although CS46xx chip is detected.
  1189. Shall I try to snd-cs4232 driver and probe
  1190. the legacy ISA configuration?")
  1191. if $DIALOG --title "ALSA Wizard" --cr-wrap --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$msg" 13 60
  1192. then
  1193. try_all_combination=1
  1194. ac_config_legacy cs4232
  1195. exit 0
  1196. fi
  1197. fi
  1198. fi
  1199. #BK john doe submitted this...
  1200. #devs_found=("${devs_found[@]}" "legacy" "Probe legacy ISA (non-PnP) chips")
  1201. devs_found=("${devs_found[@]}" "legacy" "Probe: legacy ISA (non-PnP) chips" "usb-audio" "Override: USB Sound Device" "aoa" "Override: Apple Onboard Audio")
  1202. title=$(xmsg "Soundcard Selection")
  1203. msg=$(xmsg "
  1204. Following card(s) are found on your system.
  1205. Choose a soundcard to configure:
  1206. ")
  1207. $DIALOG --title "$title" --cr-wrap --menu "$msg" 17 76 8 "${devs_found[@]}" 2> $FOUND || acex 0
  1208. card=`head -n 1 $FOUND`
  1209. if [ "$card" = "legacy" ]; then
  1210. ac_config_legacy
  1211. else
  1212. ac_config_card "$card"
  1213. fi
  1214. exit 0
  1215. else
  1216. echo "...no device found" #101017
  1217. msg=$(xmsg "
  1218. No supported PnP or PCI card found.
  1219. Would you like to probe legacy ISA sound cards/chips?
  1220. ")
  1221. if $DIALOG --title "ALSA Wizard" --cr-wrap --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$msg" 9 60 ; then
  1222. ac_config_legacy
  1223. exit 0
  1224. fi
  1225. fi
  1226. rm -f "$FOUND" "$DUMP"
  1227. exit 0