Skip to content

Instantly share code, notes, and snippets.

@fsLeg
Created July 20, 2024 17:15
Show Gist options
  • Save fsLeg/d94894d2f84a14f1b86b20e002b9176c to your computer and use it in GitHub Desktop.
Save fsLeg/d94894d2f84a14f1b86b20e002b9176c to your computer and use it in GitHub Desktop.
A script to boost peformance of ASUS Eee PC 901 by using Super Hybrid Engine and GMABooster techniques
#!/bin/sh
function doc {
# The formatting here is weird but an output is correct
cat << EOF
This script can be used to display current Super Hybrid Engine CPU mode
for ASUS Eee PC netbooks and frequency of GMA950 video chip as well as
change them. This version of the script is written specifically for
ASUS Eee PC 901.
This script must be run as root since only one function (getting CPU
mode) can normally be performed as unpriviledged user and it's easier
to perform the check only once.
Usage:
${0} Display current CPU mode and GPU frequency
${0} cpu Display current CPU mode
${0} cpu MODE Change CPU mode to MODE. Available modes:
powersave, normal, performance
${0} gpu Display current GPU frequency
${0} gpu FREQ Change GPU frequency to FREQ. Available
frequencies: 200, 250, 400
${0} powersave Shorthand for 'cpu powersave' and 'gpu 200'
${0} normal Shorthand for 'cpu normal' and 'gpu 250';
note that default GPU frequency is actually
200 MHz, but 250 MHz provides good balance
${0} performance Shorthand for 'cpu performance' and
'gpu 400'
EOF
}
function usage {
cat << EOF
${0} [cpu [powersave|normal|performance]]
${0} [gpu [200|250|400]]
${0} [powersave|normal|performance]
${0} help
EOF
}
function check_root {
if [ ${UID} -ne 0 ]; then
echo "This script must be run as root." >&2
exit 1
fi
}
function get_cpu_mode {
CURRENT_VALUE=$(</sys/devices/platform/eeepc/cpufv)
case "${CURRENT_VALUE}" in
0x302) echo "powersave" ;;
0x301) echo "normal" ;;
0x300) echo "performance" ;;
*)
echo "Can't decipher VGA bus speed." >&2
exit 1
;;
esac
}
function set_cpu_mode {
case "${1}" in
powersave) VALUE="2" ;;
normal) VALUE="1" ;;
performance) VALUE="0" ;;
*)
echo "Illegal argument! Possible values are: powersave, normal, performance." >&2
exit 1
;;
esac
echo ${VALUE} > /sys/devices/platform/eeepc/cpufv
echo "CPU mode is set to ${1}"
}
function get_gpu_frequency {
CURRENT_VALUE=$(/sbin/setpci -s 02.0 f0.b)
case "${CURRENT_VALUE}" in
00) echo "200 MHz" ;;
01) echo "250 MHz" ;;
03) echo "400 MHz" ;;
*)
echo "Can't decipher VGA bus speed." >&2
exit 1
;;
esac
}
function set_gpu_frequency {
case "${1}" in
200) VALUE=34 ;;
250) VALUE=31 ;;
400) VALUE=33 ;;
*)
echo "Illegal argument! Possible values are: 200, 250, 400." >&2
exit 1
;;
esac
/sbin/setpci -s 02.0 f0.b=00,60
/sbin/setpci -s 02.0 f0.b=${VALUE},05
echo "GPU frequency is set to ${1} MHz"
}
# Only get_cpu_mode() works as a regular user, so just demand root for everyting
check_root
case ${1} in
cpu)
if [ -z ${2} ]; then
get_cpu_mode
else
set_cpu_mode ${2}
fi
;;
gpu)
if [ -z ${2} ]; then
get_gpu_frequency
else
set_gpu_frequency ${2}
fi
;;
powersave)
set_cpu_mode powersave
set_gpu_frequency 200
;;
normal)
set_cpu_mode normal
set_gpu_frequency 250
;;
performance)
set_cpu_mode performance
set_gpu_frequency 400
;;
"")
echo "CPU mode is: $(get_cpu_mode)"
echo "GPU frequency is: $(get_gpu_frequency)"
;;
help) doc ;;
*) usage ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment