Skip to content

Commit

Permalink
Merge "Add thermal tuning service." into mnc-dr-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Broch authored and Android (Google) Code Review committed Sep 24, 2015
2 parents 58d80d1 + 67be3a1 commit 919b0a4
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions device.mk
Expand Up @@ -38,6 +38,7 @@ PRODUCT_COPY_FILES := \
$(LOCAL_PATH)/init.dragon.usb.rc:root/init.dragon.usb.rc \
$(LOCAL_PATH)/init.recovery.dragon.rc:root/init.recovery.dragon.rc \
$(LOCAL_PATH)/init_regions.sh:system/bin/init_regions.sh \
$(LOCAL_PATH)/tune-thermal-gov.sh:system/bin/tune-thermal-gov.sh \
$(LOCAL_FSTAB):root/fstab.dragon \
$(LOCAL_PATH)/ueventd.dragon.rc:root/ueventd.dragon.rc \
$(LOCAL_PATH)/speakerdsp.ini:system/etc/cras/speakerdsp.ini \
Expand Down
6 changes: 6 additions & 0 deletions init.dragon.rc
Expand Up @@ -174,6 +174,12 @@ on boot
on fs
mount_all /fstab.dragon

# tune thermal governor
service tune_therm_gov /system/bin/tune-thermal-gov.sh skin-therm pd_thermal_gov \
max_err_temp 5000
class main
oneshot

service battery_charger /charger
class charger
seclabel u:r:healthd:s0
Expand Down
88 changes: 88 additions & 0 deletions tune-thermal-gov.sh
@@ -0,0 +1,88 @@
#!/system/bin/sh

ORIG_ARGS="$@"

if [ ! -n "$1" ]
then
echo "Usage: $0 tz-name gov-name par1 v1 par2 v2 ..."
echo "Example: $0 skin-therm pd_thermal_gov max_err_temp 5000"
exit 0;
fi

# find thermal zone
for tz in $(ls -d /sys/class/thermal/thermal_zone?)
do
type=$(cat $tz/type)
if [ "$type" = "$1" ]
then
break
fi
tz=""
done

if [ ! -n "$tz" ]
then
echo "can't find thermal zone "$1
exit 0;
fi

# set governor
for gov in $(cat $tz/available_policies)
do
if [ "$gov" = "$2" ]
then
echo "$2" > $tz/policy
break
fi
gov=""
done

if [ ! -n "$gov" ]
then
echo $2 "is not a available policy"
exit 0
fi

update_par() {
if [ ! -f "$tz/$gov/$1" ]
then
echo $gov "doesn't have" $1
return 1;
fi

echo $2 > $tz/$gov/$1
echo "set $tz/$gov/$1 to $2"
return 0
}

shift
shift
if [ ! -n "$1" ]
then
exit 0
fi

if [ -n "$2" ]
then
if [ -d "$tz/$gov" ]
then
while [ -n "$2" ]
do
update_par $1 $2
if [ $? -eq 1 ]
then
exit 0
fi

shift
shift
done
else
echo $gov "doesn't support setting parameters"
exit 0
fi
else
echo "wrong governor parameters"
fi

exit 0

0 comments on commit 919b0a4

Please sign in to comment.