blob: 7c254acf03222793654508293172fb16ba6d927d [file] [log] [blame]
Chris Dalton34d90552017-10-20 09:58:32 -06001# Copyright 2017 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
Chris Dalton117d9722018-04-27 17:10:39 -06006from _hardware import Expectation
Chris Dalton34d90552017-10-20 09:58:32 -06007from _hardware_android import HardwareAndroid
Chris Dalton34d90552017-10-20 09:58:32 -06008
9CPU_CLOCK_RATE = 1670400
Kevin Lubick08b44fa2018-03-07 08:22:53 -050010GPU_CLOCK_RATE = 315000000
Chris Dalton34d90552017-10-20 09:58:32 -060011
Chris Dalton34d90552017-10-20 09:58:32 -060012class HardwarePixel(HardwareAndroid):
13 def __init__(self, adb):
14 HardwareAndroid.__init__(self, adb)
Chris Dalton34d90552017-10-20 09:58:32 -060015
16 def __enter__(self):
17 HardwareAndroid.__enter__(self)
Chris Dalton34d90552017-10-20 09:58:32 -060018 if not self._adb.is_root():
Chris Dalton49b7ed32017-10-23 17:19:37 -060019 return self
Chris Dalton34d90552017-10-20 09:58:32 -060020
Kevin Lubick4f16db62018-03-01 10:13:44 -050021 self._adb.shell('\n'.join([
Chris Dalton34d90552017-10-20 09:58:32 -060022 # enable and lock the two fast cores.
23 '''
Kevin Lubick08b44fa2018-03-07 08:22:53 -050024 stop thermal-engine
25 stop perfd
26
Chris Dalton34d90552017-10-20 09:58:32 -060027 for N in 3 2; do
28 echo 1 > /sys/devices/system/cpu/cpu$N/online
29 echo userspace > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_governor
30 echo %i > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_max_freq
31 echo %i > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_min_freq
32 echo %i > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_setspeed
33 done''' % tuple(CPU_CLOCK_RATE for _ in range(3)),
34
35 # turn off the two slow cores
36 '''
37 for N in 1 0; do
38 echo 0 > /sys/devices/system/cpu/cpu$N/online
39 done''',
40
Kevin Lubick08b44fa2018-03-07 08:22:53 -050041 # pylint: disable=line-too-long
42
43 # Set GPU bus and idle timer
44 # Set DDR frequency to max
45 # Set GPU to performance mode, 315 MHZ
46 # See https://android.googlesource.com/platform/frameworks/base/+/master/libs/hwui/tests/scripts/prep_marlfish.sh
Chris Dalton34d90552017-10-20 09:58:32 -060047 '''
48 echo 0 > /sys/class/kgsl/kgsl-3d0/bus_split
Chris Dalton34d90552017-10-20 09:58:32 -060049 echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on
Kevin Lubick08b44fa2018-03-07 08:22:53 -050050 echo 10000 > /sys/class/kgsl/kgsl-3d0/idle_timer
51
52 echo 13763 > /sys/class/devfreq/soc:qcom,gpubw/min_freq
53
54 echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor
Chris Dalton34d90552017-10-20 09:58:32 -060055 echo %i > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq
56 echo %i > /sys/class/kgsl/kgsl-3d0/devfreq/min_freq
Chris Dalton34d90552017-10-20 09:58:32 -060057
Kevin Lubick08b44fa2018-03-07 08:22:53 -050058 echo 4 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel
59 echo 4 > /sys/class/kgsl/kgsl-3d0/min_pwrlevel''' %
60 tuple(GPU_CLOCK_RATE for _ in range(2))]))
Chris Dalton34d90552017-10-20 09:58:32 -060061
Chris Dalton49b7ed32017-10-23 17:19:37 -060062 return self
Chris Dalton34d90552017-10-20 09:58:32 -060063
64 def sanity_check(self):
65 HardwareAndroid.sanity_check(self)
66
67 if not self._adb.is_root():
68 return
69
70 result = self._adb.check(' '.join(
71 ['cat',
72 '/sys/class/power_supply/battery/capacity',
73 '/sys/devices/system/cpu/online'] + \
74 ['/sys/devices/system/cpu/cpu%i/cpufreq/scaling_cur_freq' % i
75 for i in range(2, 4)] + \
Kevin Lubick08b44fa2018-03-07 08:22:53 -050076 ['/sys/kernel/debug/clk/bimc_clk/measure',
Chris Dalton34d90552017-10-20 09:58:32 -060077 '/sys/class/thermal/thermal_zone22/temp',
Kevin Lubick08b44fa2018-03-07 08:22:53 -050078 '/sys/class/thermal/thermal_zone23/temp']))
Chris Dalton34d90552017-10-20 09:58:32 -060079
80 expectations = \
81 [Expectation(int, min_value=30, name='battery', sleeptime=30*60),
82 Expectation(str, exact_value='2-3', name='online cpus')] + \
83 [Expectation(int, exact_value=CPU_CLOCK_RATE, name='cpu_%i clock rate' %i)
84 for i in range(2, 4)] + \
Kevin Lubick08b44fa2018-03-07 08:22:53 -050085 [Expectation(long, min_value=902390000, max_value=902409999,
Chris Dalton34d90552017-10-20 09:58:32 -060086 name='measured ddr clock', sleeptime=10),
87 Expectation(int, max_value=41000, name='pm8994_tz temperature'),
Kevin Lubick08b44fa2018-03-07 08:22:53 -050088 Expectation(int, max_value=40, name='msm_therm temperature')]
Chris Dalton34d90552017-10-20 09:58:32 -060089
90 Expectation.check_all(expectations, result.splitlines())