Compare commits

..

No commits in common. "f0904133929e343c23988a16d6e616bc4e0c5c76" and "c24039a694628bfeacdf75433c9120b6517f5fc6" have entirely different histories.

1 changed files with 3 additions and 67 deletions

View File

@ -278,26 +278,11 @@ function device_cputop_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 function device_temperature_async(string $atf_host, string $device) : Amp\Promise
{ {
return device_cpu_measure_async($atf_host, $device, "cpuinfo_min_freq", $core_index); return Amp\call(function() use($atf_host, $device) {
}
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/devices/system/cpu/cpu$core_index/cpufreq/$metric", DEPLOY_OPT_ERR_OK, 1); 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);
if($code !== 0) if($code !== 0)
return 0; return 0;
@ -313,52 +298,3 @@ function device_cpu_measure_async(string $atf_host, string $device, string $metr
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;
}