10alsa 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/sh
  2. #Barry Kauler april 2009, puppylinux.com
  3. #called from /etc/rc.d/rc.services at bootup, with 'start' param.
  4. #called from /etc/rc.d/rc.shutdown at shutdown, with 'stop' param.
  5. #101120, 101121 simplification.
  6. #110111 shinobar: for reliable sound detection on HP Compac nc4010.
  7. #110113 tweak delay. 110216 tweak delay.
  8. #110506 /usr/sbin/alsaconf has 'restart' option, might need to reprobe modules. for now, just 'start|restart'.
  9. #111229 add test file /etc/asound.state exists.
  10. #120103 karl godt: fix unloading modules. refer: http://www.murga-linux.com/puppy/viewtopic.php?t=71767&start=390
  11. #120222 revert 111229. 120223 shinobar: better fix.
  12. #120226 01micko: added 'Master Front' entries. 120318 bumped it up, 75% to 100%.
  13. case "$1" in
  14. start|restart)
  15. #110217 remove this test, seems to be a problem some people report file not created but snd ok...
  16. #if [ -f /tmp/rc_d_rc_services_alsa_ok ];then #101121 see rc.services.
  17. #if [ "`lsmod | grep '^snd_'`" != "" ];then
  18. rm -f /var/lock/subsys/alsasound 2> /dev/null #or alsa will not start.
  19. #sometimes these don't all load...
  20. modprobe snd-mixer-oss
  21. modprobe snd-seq-oss
  22. modprobe snd-pcm-oss
  23. for I in $(seq 4); do #110111 shinobar: for reliable sound detection on HP Compac nc4010.
  24. sleep 0.5 #110113 reduce 1 to 0.5. 110216 move up.
  25. [ -c /dev/mixer ] && break #note, /dev/mixer is deleted in /etc/rc.d/rc.sysinit.
  26. done
  27. if [ ! -f /etc/asound.state ];then
  28. #try and set all levels workable...
  29. #set_mixers #in functions4puppy4
  30. #101015 BK had to add ,0 after Front...
  31. #110823 pemasu: add this set Speaker 75 % unmute
  32. #120226 01micko: added 'Master Front' entries...
  33. amixer -s -q <<EOF
  34. set Master 75% unmute
  35. set Master -12dB
  36. set 'Master Mono' 75% unmute
  37. set 'Master Mono' -12dB
  38. set 'Master Front' 100% unmute
  39. set 'Master Front' -12dB
  40. set Front,0 75% unmute
  41. set Front,0 -12dB
  42. set PCM 90% unmute
  43. set PCM 0dB
  44. set Synth 90% unmute
  45. set Synth 0dB
  46. set CD 90% unmute
  47. set CD 0dB
  48. set Mic 0% mute
  49. set PCM,1 90% unmute
  50. set PCM,1 0dB
  51. set Wave 100% unmute
  52. set Music 100% unmute
  53. set AC97 100% unmute
  54. set 'Master Digital' 75% unmute
  55. set DAC 90% unmute
  56. set DAC -12dB
  57. set DAC,0 90% unmute
  58. set DAC,0 -12dB
  59. set DAC,1 90% unmute
  60. set DAC,1 -12dB
  61. set Headphone 75% unmute
  62. set Headphone -12dB
  63. set Playback 100% unmute
  64. set "SB Live Analog/Digital Output Jack" off
  65. set "Audigy Analog/Digital Output Jack" off
  66. set Speaker 75% unmute
  67. EOF
  68. [ $? -eq 0 ] && alsactl -f /etc/asound.state store #120223 shinobar
  69. else
  70. alsactl -f /etc/asound.state restore #from /etc/asound.state.
  71. fi
  72. #fi
  73. ;;
  74. stop)
  75. [ -f /etc/asound.state ] && alsactl -f /etc/asound.state store #saves to /etc/asound.state. 111229 add test file exists. 120222 revert. 120223 restore.
  76. # Kill processes holding open sound devices...
  77. fuser -k /dev/admmidi? /dev/adsp? /dev/amidi? /dev/audio* /dev/dmfm* /dev/dmmidi? /dev/dsp* /dev/dspW* /dev/midi0? /dev/mixer? /dev/music /dev/patmgr? /dev/sequencer* /dev/sndstat >/dev/null 2>&1
  78. [ -d /proc/asound/dev ] && fuser -k /proc/asound/dev/* >/dev/null 2>&1
  79. [ -d /dev/snd ] && fuser -k /dev/snd/* >/dev/null 2>&1
  80. # remove all sequencer connections if any
  81. [ -f /proc/asound/seq/clients -a -x aconnect ] && aconnect --removeall
  82. # mute master to avoid clicks at unload
  83. amixer set Master mute >/dev/null 2>&1
  84. # remove all sound modules... 120103...
  85. #lsmod | grep "^snd" | grep -Ev "(snd-page-alloc|snd_page_alloc)" |
  86. c=0
  87. while [ "`lsmod | grep 'snd_'`" ];do
  88. lsmod | grep "^snd" | grep '0 $' | grep -Ev "(snd-page-alloc|snd_page_alloc)" |
  89. while read line
  90. do
  91. #rmmod `echo $line | cut -d ' ' -f 1`
  92. modprobe -rv `echo $line | cut -d ' ' -f 1`
  93. done
  94. c=$((c+1));[ "$c" = '6' ] && break #precaution if neverending loop
  95. done
  96. # remove the 2.2 soundcore module (if possible)
  97. rmmod soundcore 2> /dev/null
  98. rmmod gameport 2> /dev/null
  99. # remove lockfile if lockdir exists
  100. [ -d /var/lock/subsys ] && rm -f /var/lock/subsys/alsasound
  101. ;;
  102. esac
  103. ###END###