Alsa & suspend...

Rob Mayoff linux-thinkpad@www.bm-soft.com
Wed, 4 Aug 1999 10:03:57 -0500 (CDT)


| Does someone have an idea?

You need apmd 3.0beta8 or later, so it can run a script on APM events.
Here's my script. You'll probably have to change at least the first line
to use bash, unless you have ksh installed. You also need to either
install tpctl, or remove the part of the script that relies on it.

/*--------------------------------------------------------------------*/
#!/bin/ksh

logger "apmd_proxy: $*"

case "$*" in

	suspend*)
		cardctl eject & # may take a moment
		lsof -t /dev/{audio,dsp,midi,mixer,music,sequencer,sndstat} | xargs kill
		sleep 1
		rmmod -s cs4232
		rmmod -s ad1848 uart401
		rmmod -s sound
		rmmod -s soundcore
		wait # for cardctl
		lid="$(/usr/local/bin/tpctl --is | grep Lid)"
		case "$lid" in
			*Y)
				# Lid is closed - possibly unsafe to resume if X is running.
				# Try to dodge the problem.
				chvt 1
				;;
		esac
		;;

	resume*)
		cardctl insert
		modprobe sound
		;;

esac

exit 0