summaryrefslogtreecommitdiffstats
path: root/pts-core/functions/pts-functions_system_graphics.php
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-08-05 16:30:00 -0400
committerMichael Larabel <michael@phx-laptop.(none)>2008-08-05 16:30:00 -0400
commit3bbdeefed9381a7bf3b62f7e908f41a166fa94ee (patch)
treea0abb0e90905658581de3e9ecbcb16b586d02d0b /pts-core/functions/pts-functions_system_graphics.php
parente48ae4692975df8ef09071933baa2ed8cf0fd0d0 (diff)
downloadphoronix-test-suite-upstream-3bbdeefed9381a7bf3b62f7e908f41a166fa94ee.tar.gz
phoronix-test-suite-upstream-3bbdeefed9381a7bf3b62f7e908f41a166fa94ee.tar.xz
phoronix-test-suite-upstream-3bbdeefed9381a7bf3b62f7e908f41a166fa94ee.zip
pts-core: Add support for detecting all available video modes
For doing this, use the xrandr_available_modes() PTS function.
Diffstat (limited to 'pts-core/functions/pts-functions_system_graphics.php')
-rw-r--r--pts-core/functions/pts-functions_system_graphics.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/pts-core/functions/pts-functions_system_graphics.php b/pts-core/functions/pts-functions_system_graphics.php
index f88cd37..489d658 100644
--- a/pts-core/functions/pts-functions_system_graphics.php
+++ b/pts-core/functions/pts-functions_system_graphics.php
@@ -178,6 +178,45 @@ function set_amd_pcsdb($attribute, $value)
$info = shell_exec("DISPLAY=:" . $DISPLAY . " aticonfig --set-pcs-val=" . $attribute . "," . $value . " 2>&1");
}
}
+function xrandr_available_modes()
+{
+ $info = shell_exec("xrandr 2>&1");
+ $xrandr_lines = array_reverse(explode("\n", $info));
+ $available_modes = array();
+
+ foreach($xrandr_lines as $xrandr_mode)
+ {
+ $res = explode("x", $xrandr_mode);
+
+ if(count($res) == 2)
+ {
+ $res[0] = trim($res[0]);
+ $res[1] = trim($res[1]);
+
+ $res[0] = substr($res[0], strpos($res[0], " "));
+ $res[1] = substr($res[1], 0, strpos($res[1], " "));
+
+ if(is_numeric($res[0]) && is_numeric($res[1]) && $res[0] >= 800 && $res[1] >= 600)
+ {
+ $ratio = pts_trim_double($res[0] / $res[1], 2);
+ $this_mode = array($res[0], $res[1]);
+
+ $supported_ratios = array(1.60, 1.25, 1.33);
+ $ignore_modes = array(array(832, 624), array(1152, 864));
+
+ if(in_array($ratio, $supported_ratios) && !in_array($this_mode, $ignore_modes))
+ array_push($available_modes, $this_mode);
+ }
+ }
+ }
+
+ if(count($available_modes) < 2)
+ {
+ $available_modes = array(array(800, 600), array(1024, 768), array(1280, 1024), array(1680, 1050), array(1600, 1200), array(1920, 1080));
+ }
+
+ return $available_modes;
+}
function xrandr_screen_resolution()
{
$info = shell_exec("xrandr 2>&1 | grep \"*\"");