• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/system/bin/sh
2
3ORIG_ARGS="$@"
4
5if [ ! -n "$1" ]
6then
7	echo "Usage: $0 tz-name gov-name par1 v1 par2 v2 ..."
8	echo "Example: $0 skin-therm pd_thermal_gov max_err_temp 5000"
9	exit 0;
10fi
11
12# find thermal zone
13for tz in $(ls -d /sys/class/thermal/thermal_zone?)
14do
15	type=$(cat $tz/type)
16	if [ "$type" = "$1" ]
17	then
18		break
19	fi
20	tz=""
21done
22
23if [ ! -n "$tz" ]
24then
25	echo "can't find thermal zone "$1
26	exit 0;
27fi
28
29# set governor
30for gov in $(cat $tz/available_policies)
31do
32	if [ "$gov" = "$2" ]
33	then
34		echo "$2" > $tz/policy
35		break
36	fi
37	gov=""
38done
39
40if [ ! -n "$gov" ]
41then
42	echo $2 "is not a available policy"
43	exit 0
44fi
45
46update_par() {
47	if [ ! -f "$tz/$gov/$1" ]
48	then
49		echo $gov "doesn't have" $1
50		return 1;
51	fi
52
53	echo $2 > $tz/$gov/$1
54	echo "set $tz/$gov/$1 to $2"
55	return 0
56}
57
58shift
59shift
60if [ ! -n "$1" ]
61then
62	exit 0
63fi
64
65if [ -n "$2" ]
66then
67	if [ -d "$tz/$gov" ]
68	then
69		while [ -n "$2" ]
70		do
71			update_par $1 $2
72			if [ $? -eq 1 ]
73			then
74				exit 0
75			fi
76
77			shift
78			shift
79		done
80	else
81		echo $gov "doesn't support setting parameters"
82		exit 0
83	fi
84else
85	echo "wrong governor parameters"
86fi
87
88exit 0
89