2016-09-23 18:36:11 +00:00
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
from _hardware import HardwareException, Expectation
|
|
|
|
from _hardware_android import HardwareAndroid
|
|
|
|
|
2018-03-14 15:01:03 +00:00
|
|
|
CPU_CLOCK_RATE = 1326000
|
|
|
|
# If you run adb cat /sys/devices/57000000.gpu/pstate it shows all
|
|
|
|
# possible configurations, with a * next to the current one.
|
|
|
|
GPU_EMC_PROFILE = '04: core 307 MHz emc 1065 MHz a A d D *'
|
|
|
|
GPU_EMC_PROFILE_ID = '04'
|
2016-09-23 18:36:11 +00:00
|
|
|
|
|
|
|
class HardwarePixelC(HardwareAndroid):
|
|
|
|
def __init__(self, adb):
|
|
|
|
HardwareAndroid.__init__(self, adb)
|
|
|
|
|
|
|
|
def __enter__(self):
|
2017-10-20 15:58:32 +00:00
|
|
|
HardwareAndroid.__enter__(self)
|
2016-11-09 16:41:23 +00:00
|
|
|
if not self._adb.is_root():
|
2017-10-23 23:19:37 +00:00
|
|
|
return self
|
2016-09-23 18:36:11 +00:00
|
|
|
|
2016-11-09 16:41:23 +00:00
|
|
|
self._adb.shell('\n'.join([
|
2018-03-14 15:01:03 +00:00
|
|
|
# pylint: disable=line-too-long
|
|
|
|
# Based on https://android.googlesource.com/platform/frameworks/base/+/master/libs/hwui/tests/scripts/prep_ryu.sh
|
|
|
|
# All CPUs have the same scaling settings, so we only need to set it once
|
2016-11-09 16:41:23 +00:00
|
|
|
'''
|
2018-03-14 15:01:03 +00:00
|
|
|
stop thermal-engine
|
|
|
|
stop perfd
|
|
|
|
|
|
|
|
echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
|
|
|
echo %i > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
|
|
|
|
echo %i > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
|
|
|
|
echo %i > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
|
|
|
|
''' % tuple(CPU_CLOCK_RATE for _ in range(3)),
|
|
|
|
# turn off the fourth core. This will hopefully produce less heat, allowing
|
|
|
|
# for more consistent results. 3 cores should be enough to run Ganesh,
|
|
|
|
# the graphics driver, and the OS.
|
2016-11-09 20:26:31 +00:00
|
|
|
'''
|
|
|
|
echo 0 > /sys/devices/system/cpu/cpu3/online''',
|
2016-09-23 18:36:11 +00:00
|
|
|
|
2016-11-09 16:41:23 +00:00
|
|
|
# lock gpu/emc clocks.
|
|
|
|
'''
|
2016-09-23 18:36:11 +00:00
|
|
|
chown root:root /sys/devices/57000000.gpu/pstate
|
2016-11-09 16:41:23 +00:00
|
|
|
echo %s > /sys/devices/57000000.gpu/pstate''' % GPU_EMC_PROFILE_ID]))
|
2016-09-23 18:36:11 +00:00
|
|
|
|
2017-10-23 23:19:37 +00:00
|
|
|
return self
|
2016-11-09 20:26:31 +00:00
|
|
|
|
2017-10-23 23:19:37 +00:00
|
|
|
def filter_line(self, line):
|
|
|
|
JUNK = ['NvRmPrivGetChipPlatform: Could not read platform information',
|
|
|
|
'Expected on kernels without fuse support, using silicon']
|
|
|
|
return False if line in JUNK else HardwareAndroid.filter_line(self, line)
|
2016-09-23 18:36:11 +00:00
|
|
|
|
|
|
|
def sanity_check(self):
|
|
|
|
HardwareAndroid.sanity_check(self)
|
|
|
|
|
2016-11-09 16:41:23 +00:00
|
|
|
if not self._adb.is_root():
|
2016-09-23 18:36:11 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
# only issue one shell command in an attempt to minimize interference.
|
2016-11-09 16:41:23 +00:00
|
|
|
result = self._adb.check('''\
|
2016-09-23 18:36:11 +00:00
|
|
|
cat /sys/class/power_supply/bq27742-0/capacity \
|
2016-11-09 20:26:31 +00:00
|
|
|
/sys/devices/system/cpu/online \
|
2016-09-23 18:36:11 +00:00
|
|
|
/sys/class/thermal/thermal_zone7/temp \
|
|
|
|
/sys/class/thermal/thermal_zone0/temp \
|
|
|
|
/sys/class/thermal/thermal_zone1/temp \
|
|
|
|
/sys/class/thermal/thermal_zone7/cdev1/cur_state \
|
|
|
|
/sys/class/thermal/thermal_zone7/cdev0/cur_state
|
2016-11-09 20:26:31 +00:00
|
|
|
for N in 0 1 2; do
|
2016-09-23 18:36:11 +00:00
|
|
|
cat /sys/devices/system/cpu/cpu$N/cpufreq/scaling_cur_freq
|
|
|
|
done
|
|
|
|
cat /sys/devices/57000000.gpu/pstate | grep \*$''')
|
|
|
|
|
|
|
|
expectations = \
|
|
|
|
[Expectation(int, min_value=30, name='battery', sleeptime=30*60),
|
2016-11-09 20:26:31 +00:00
|
|
|
Expectation(str, exact_value='0-2', name='online cpus'),
|
2016-09-23 18:36:11 +00:00
|
|
|
Expectation(int, max_value=40000, name='skin temperature'),
|
|
|
|
Expectation(int, max_value=86000, name='cpu temperature'),
|
|
|
|
Expectation(int, max_value=87000, name='gpu temperature'),
|
|
|
|
Expectation(int, exact_value=0, name='cpu throttle'),
|
|
|
|
Expectation(int, exact_value=0, name='gpu throttle')] + \
|
|
|
|
[Expectation(int, exact_value=CPU_CLOCK_RATE,
|
|
|
|
name='cpu_%i clock rate' % i, sleeptime=30)
|
2016-11-09 20:26:31 +00:00
|
|
|
for i in (0, 1, 2)] + \
|
2016-09-23 18:36:11 +00:00
|
|
|
[Expectation(str, exact_value=GPU_EMC_PROFILE, name='gpu/emc profile')]
|
|
|
|
|
2016-11-09 16:41:23 +00:00
|
|
|
Expectation.check_all(expectations, result.splitlines())
|