1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
# -*- sh -*-
# vim:ft=sh:ts=8:sw=4:noet
# VideoBumo scriptlet
#
# This scriptlet Copyright (C) Cameron Patrick, 2005, Joey Hess 2007 and may be
# used under the same terms as hibernate-script itself.
AddConfigHandler VideoDumpOptions
AddConfigHelp "EnableVideoDump <boolean>" "Dump and load video card memory before and after suspending."
# hopefully this is a good choice and nothing else uses it :-/
VIDEODUMP_VT=62
VIDEODUMP_ENABLED=
VIDEODUMP_ID=
VideoDumpSaveState() {
# if we're switched off, don't do nuffin
[ x"$VIDEODUMP_ENABLED" = "x1" ] || return 0
# save our previous VT and switch to a new one
VIDEODUMP_ORIG_VT=`fgconsole 2>/dev/null` || VIDEODUMP_ORIG_VT=1
chvt $VIDEODUMP_VT
TERM=linux tput clear
VIDEODUMP_FILE=`mktemp /tmp/tmp.hibernate.XXXXXX`
VIDEODUMP_ID=`lspci | grep VGA | awk '{ print $1 }' | sed -e 's@0000:@@' -e 's@:@/@'` || true
if [ -e "/proc/bus/pci/$VIDEODUMP_ID" ]; then
cat "/proc/bus/pci/$VIDEODUMP_ID" > "$VIDEODUMP_FILE"
fi
echo $VIDEODUMP_ID
echo $VIDEODUMP_FILE
return 0
}
VideoDumpRestoreState() {
# if we're switched off, don't do nuffin
[ x"$VIDEODUMP_ENABLED" = "x1" ] || return 0
# Restore a saved state.
if [ -n "$VIDEODUMP_FILE" ] && [ -e "/proc/bus/pci/$VIDEODUMP_ID" ]; then
cat "$VIDEODUMP_FILE" > /proc/bus/pci/$VIDEODUMP_ID
rm -f "$VIDEODUMP_FILE"
fi
# change back to our original VT
chvt $VIDEODUMP_ORIG_VT
}
VideoDumpOptions() {
case $1 in
enablevideodump)
BoolIsOn "$1" "$2" && VIDEODUMP_ENABLED=1 || return 0
;;
*)
return 1
esac
if [ -z "$VIDEODUMP_HOOKED" ] ; then
AddSuspendHook 97 VideoDumpSaveState
AddResumeHook 97 VideoDumpRestoreState
VIDEODUMP_HOOKED=1
fi
return 0
}
# $Id: $
|