Compare commits
2 Commits
c24039a694
...
f090413392
Author | SHA1 | Date |
---|---|---|
Alexey Chubar | f090413392 | |
Alexey Chubar | dacaefab40 |
|
@ -278,11 +278,26 @@ function device_cputop_async(string $atf_host, string $device) : Amp\Promise
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function device_temperature_async(string $atf_host, string $device) : Amp\Promise
|
function device_cpu_freq_min_async(string $atf_host, string $device, int $core_index = 0) : Amp\Promise
|
||||||
{
|
{
|
||||||
return Amp\call(function() use($atf_host, $device) {
|
return device_cpu_measure_async($atf_host, $device, "cpuinfo_min_freq", $core_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function device_cpu_freq_max_async(string $atf_host, string $device, int $core_index = 0) : Amp\Promise
|
||||||
|
{
|
||||||
|
return device_cpu_measure_async($atf_host, $device, "cpuinfo_max_freq", $core_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function device_cpu_freq_cur_async(string $atf_host, string $device, int $core_index = 0) : Amp\Promise
|
||||||
|
{
|
||||||
|
return device_cpu_measure_async($atf_host, $device, "scaling_cur_freq", $core_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function device_cpu_measure_async(string $atf_host, string $device, string $metric, int $core_index) : Amp\Promise
|
||||||
|
{
|
||||||
|
return Amp\call(function() use($atf_host, $device, $metric, $core_index) {
|
||||||
//NOTE: on current devices 16 thermal zone are responsible for GPU temperature probing
|
//NOTE: on current devices 16 thermal zone are responsible for GPU temperature probing
|
||||||
list($code, $lines) = yield host_exec_async($atf_host, "%{adb}% -s $device shell cat /sys/class/thermal/thermal_zone16/temp", DEPLOY_OPT_ERR_OK, 1);
|
list($code, $lines) = yield host_exec_async($atf_host, "%{adb}% -s $device shell cat /sys/devices/system/cpu/cpu$core_index/cpufreq/$metric", DEPLOY_OPT_ERR_OK, 1);
|
||||||
|
|
||||||
if($code !== 0)
|
if($code !== 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -298,3 +313,52 @@ function device_temperature_async(string $atf_host, string $device) : Amp\Promis
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function device_temperature_async(string $atf_host, string $device) : Amp\Promise
|
||||||
|
{
|
||||||
|
return Amp\call(function() use($atf_host, $device) {
|
||||||
|
list($code, $lines) = yield host_exec_async($atf_host, "%{adb}% -s $device shell dumpsys thermalservice", DEPLOY_OPT_ERR_OK, 1);
|
||||||
|
|
||||||
|
if($code !== 0)
|
||||||
|
return array();
|
||||||
|
|
||||||
|
return device_parse_soc_temps($lines);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function device_parse_soc_temps($thermal_output_lines)
|
||||||
|
{
|
||||||
|
$cpu_temp = null;
|
||||||
|
$gpu_temp = null;
|
||||||
|
|
||||||
|
$hal_section_found = false;
|
||||||
|
|
||||||
|
foreach($thermal_output_lines as $line)
|
||||||
|
{
|
||||||
|
if(!$hal_section_found)
|
||||||
|
{
|
||||||
|
if(strpos($line, 'Current temperatures from HAL:') !== false)
|
||||||
|
$hal_section_found = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strpos($line, 'mType=0') !== false) //Type 0 indicates CPI
|
||||||
|
$cpu_temp = device_parse_thermal_line($line);
|
||||||
|
|
||||||
|
if(strpos($line, 'mType=1') !== false) //Type 1 indicates GPU
|
||||||
|
$gpu_temp = device_parse_thermal_line($line);
|
||||||
|
|
||||||
|
if($cpu_temp && $gpu_temp)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'cpu_temp' => $cpu_temp,
|
||||||
|
'gpu_temp' => $gpu_temp
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function device_parse_thermal_line($line)
|
||||||
|
{
|
||||||
|
return preg_match('/mValue=([^,]+)/', $line, $matches) ? floatval($matches[1]) : null;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue