How to use monitor_modes method of phodevi_monitor class

Best Phoronix-test-suite code snippet using phodevi_monitor.monitor_modes

phodevi_monitor.php

Source:phodevi_monitor.php Github

copy

Full Screen

...23 return array(24 'identifier' => new phodevi_device_property('monitor_string', phodevi::smart_caching),25 'count' => new phodevi_device_property('monitor_count', phodevi::std_caching),26 'layout' => new phodevi_device_property('monitor_layout', phodevi::std_caching),27 'modes' => new phodevi_device_property('monitor_modes', phodevi::std_caching)28 );29 }30 public static function monitor_string()31 {32 $monitor = array();33 if(phodevi::is_macosx())34 {35 $system_profiler = shell_exec('system_profiler SPDisplaysDataType 2>&1');36 $system_profiler = substr($system_profiler, strrpos($system_profiler, 'Displays:'));37 $system_profiler = substr($system_profiler, strpos($system_profiler, "\n"));38 $monitor = trim(substr($system_profiler, 0, strpos($system_profiler, ':')));39 if($monitor == 'Display Connector')40 {41 $monitor = null;42 }43 else44 {45 $monitor = array($monitor);46 }47 }48 else if(phodevi::is_nvidia_graphics() && isset(phodevi::$vfs->xorg_log))49 {50 $log_parse = phodevi::$vfs->xorg_log;51 $offset = 0;52 /* e.g.53 $ cat /var/log/Xorg.0.log | grep -i connected54 [ 18.174] (--) NVIDIA(0): Acer P243W (DFP-0) (connected)55 [ 18.174] (--) NVIDIA(0): Acer AL2223W (DFP-1) (connected)56 */57 while(($monitor_pos = strpos($log_parse, ') (connected)', $offset)) !== false || ($monitor_pos = strpos($log_parse, ') (boot, connected)', $offset)) !== false)58 {59 $m = substr($log_parse, 0, $monitor_pos);60 $m = substr($m, strrpos($m, '): ') + 2);61 $m = trim(substr($m, 0, strpos($m, ' (')));62 if(!empty($m) && !isset($m[32]) && isset($m[6]))63 {64 array_push($monitor, $m);65 }66 $offset = $monitor_pos + 2;67 }68 }69 if($monitor == null && phodevi::is_linux())70 {71 // Attempt to find the EDID over sysfs and then decode it for monitor name (0xFC)72 // For at least Intel DRM drivers there is e.g. /sys/class/drm/card0-HDMI-A-2/edid73 // Also works at least for Radeon DRM driver too74 foreach(glob('/sys/class/drm/*/edid') as $edid_file)75 {76 $edid_file = pts_file_io::file_get_contents($edid_file);77 if($edid_file == null)78 {79 continue;80 }81 $edid = bin2hex($edid_file);82 $monitor[] = self::edid_monitor_parse($edid);83 }84 }85 if($monitor == null && pts_client::executable_in_path('xrandr'))86 {87 $xrandr_props = shell_exec('xrandr --prop 2>&1');88 if(($x = strpos($xrandr_props, 'EDID:')) !== false)89 {90 $xrandr_props = substr($xrandr_props, $x + 5);91 $xrandr_props = substr($xrandr_props, 0, strpos($xrandr_props, ':'));92 $xrandr_props = substr($xrandr_props, 0, strrpos($xrandr_props, PHP_EOL));93 $xrandr_props = str_replace(array(' ', "\t", PHP_EOL), '', $xrandr_props);94 $monitor[] = self::edid_monitor_parse($xrandr_props);95 }96 }97 $monitor = pts_arrays::array_to_cleansed_item_string($monitor);98 return empty($monitor) ? false : $monitor;99 }100 protected static function edid_monitor_parse($edid)101 {102 $x = 0;103 $monitor = null;104 while($x = strpos($edid, '00fc', $x))105 {106 // 00fc indicates start of EDID monitor descriptor block107 $encoded = substr($edid, $x + 4, 36);108 $edid_monitor_name_block = null;109 for($i = 0; $i < strlen($encoded); $i += 2)110 {111 $hex = substr($encoded, $i, 2);112 if($hex == 15 || $hex == '0a')113 {114 break;115 }116 $ch = chr(hexdec($hex));117 $edid_monitor_name_block .= $ch;118 }119 $edid_monitor_name_block = trim($edid_monitor_name_block);120 if(pts_strings::string_only_contains($edid_monitor_name_block, (pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_DASH)))121 {122 $monitor = $edid_monitor_name_block;123 break;124 }125 $x++;126 }127 return $monitor;128 }129 public static function monitor_count()130 {131 // Report number of connected/enabled monitors132 $monitor_count = 0;133 // First try reading number of monitors from xdpyinfo134 $monitor_count = count(phodevi_parser::read_xdpy_monitor_info());135 if($monitor_count == 0)136 {137 // Fallback support for ATI and NVIDIA if phodevi_parser::read_xdpy_monitor_info() fails138 if(phodevi::is_nvidia_graphics())139 {140 $enabled_displays = phodevi_parser::read_nvidia_extension('EnabledDisplays');141 switch($enabled_displays)142 {143 case '0x00010000':144 $monitor_count = 1;145 break;146 case '0x00010001':147 $monitor_count = 2;148 break;149 default:150 $monitor_count = 1;151 break;152 }153 }154 else155 {156 $monitor_count = 1;157 }158 }159 return $monitor_count;160 }161 public static function monitor_layout()162 {163 // Determine layout for multiple monitors164 $monitor_layout = array('CENTER');165 if(phodevi::read_property('monitor', 'count') > 1)166 {167 $xdpy_monitors = phodevi_parser::read_xdpy_monitor_info();168 $hit_0_0 = false;169 for($i = 0; $i < count($xdpy_monitors); $i++)170 {171 $monitor_position = explode('@', $xdpy_monitors[$i]);172 $monitor_position = trim($monitor_position[1]);173 $monitor_position_x = substr($monitor_position, 0, strpos($monitor_position, ','));174 $monitor_position_y = substr($monitor_position, strpos($monitor_position, ',') + 1);175 if($monitor_position == '0,0')176 {177 $hit_0_0 = true;178 }179 else if($monitor_position_x > 0 && $monitor_position_y == 0)180 {181 array_push($monitor_layout, ($hit_0_0 ? 'RIGHT' : 'LEFT'));182 }183 else if($monitor_position_x == 0 && $monitor_position_y > 0)184 {185 array_push($monitor_layout, ($hit_0_0 ? 'LOWER' : 'UPPER'));186 }187 }188 }189 return implode(',', $monitor_layout);190 }191 public static function monitor_modes()192 {193 // Determine resolutions for each monitor194 $resolutions = array();195 if(phodevi::read_property('monitor', 'count') == 1)196 {197 array_push($resolutions, phodevi::read_property('gpu', 'screen-resolution-string'));198 }199 else200 {201 foreach(phodevi_parser::read_xdpy_monitor_info() as $monitor_line)202 {203 $this_resolution = substr($monitor_line, strpos($monitor_line, ':') + 2);204 $this_resolution = substr($this_resolution, 0, strpos($this_resolution, ' '));205 array_push($resolutions, $this_resolution);...

Full Screen

Full Screen

monitor_modes

Using AI Code Generation

copy

Full Screen

1require_once('phodevi_monitor.php');2$phodevi_monitor = new phodevi_monitor();3$phodevi_monitor->monitor_modes();4require_once('phodevi_monitor.php');5$phodevi_monitor = new phodevi_monitor();6$phodevi_monitor->monitor_modes();7require_once('phodevi_monitor.php');8$phodevi_monitor = new phodevi_monitor();9$phodevi_monitor->monitor_modes();10require_once('phodevi_monitor.php');11$phodevi_monitor = new phodevi_monitor();12$phodevi_monitor->monitor_modes();13require_once('phodevi_monitor.php');14$phodevi_monitor = new phodevi_monitor();15$phodevi_monitor->monitor_modes();16require_once('phodevi_monitor.php');17$phodevi_monitor = new phodevi_monitor();18$phodevi_monitor->monitor_modes();19require_once('phodevi_monitor.php');20$phodevi_monitor = new phodevi_monitor();21$phodevi_monitor->monitor_modes();22require_once('phodevi_monitor.php');23$phodevi_monitor = new phodevi_monitor();24$phodevi_monitor->monitor_modes();25require_once('phodevi_monitor.php');26$phodevi_monitor = new phodevi_monitor();27$phodevi_monitor->monitor_modes();28require_once('phodevi_monitor.php');29$phodevi_monitor = new phodevi_monitor();30$phodevi_monitor->monitor_modes();

Full Screen

Full Screen

monitor_modes

Using AI Code Generation

copy

Full Screen

1require_once('phodevi.php');2$phodevi = new phodevi_monitor();3$phodevi->monitor_modes();4require_once('phodevi.php');5$phodevi = new phodevi_monitor();6$phodevi->monitor_modes();7require_once('phodevi.php');8$phodevi = new phodevi_monitor();9$phodevi->monitor_modes();10require_once('phodevi.php');11$phodevi = new phodevi_monitor();12$phodevi->monitor_modes();13require_once('phodevi.php');14$phodevi = new phodevi_monitor();15$phodevi->monitor_modes();16require_once('phodevi.php');17$phodevi = new phodevi_monitor();18$phodevi->monitor_modes();19require_once('phodevi.php');20$phodevi = new phodevi_monitor();21$phodevi->monitor_modes();22require_once('phodevi.php');23$phodevi = new phodevi_monitor();24$phodevi->monitor_modes();25require_once('phodevi.php');26$phodevi = new phodevi_monitor();27$phodevi->monitor_modes();28require_once('phodevi.php');29$phodevi = new phodevi_monitor();30$phodevi->monitor_modes();31require_once('phodevi.php');

Full Screen

Full Screen

monitor_modes

Using AI Code Generation

copy

Full Screen

1require_once 'phodevi_monitor.php';2$monitor = new phodevi_monitor();3$monitor_modes = $monitor->monitor_modes();4print_r($monitor_modes);5require_once 'phodevi_monitor.php';6$monitor = new phodevi_monitor();7$monitor_modes = $monitor->monitor_modes();8print_r($monitor_modes);9require_once 'phodevi_monitor.php';10$monitor = new phodevi_monitor();11$monitor_modes = $monitor->monitor_modes();12print_r($monitor_modes);13require_once 'phodevi_monitor.php';14$monitor = new phodevi_monitor();15$monitor_modes = $monitor->monitor_modes();16print_r($monitor_modes);17require_once 'phodevi_monitor.php';18$monitor = new phodevi_monitor();19$monitor_modes = $monitor->monitor_modes();20print_r($monitor_modes);21require_once 'phodevi_monitor.php';22$monitor = new phodevi_monitor();23$monitor_modes = $monitor->monitor_modes();24print_r($monitor_modes);25require_once 'phodevi_monitor.php';26$monitor = new phodevi_monitor();27$monitor_modes = $monitor->monitor_modes();28print_r($monitor_modes);29require_once 'phodevi_monitor.php';30$monitor = new phodevi_monitor();31$monitor_modes = $monitor->monitor_modes();32print_r($monitor_modes);33require_once 'phodevi_monitor.php';34$monitor = new phodevi_monitor();35$monitor_modes = $monitor->monitor_modes();36print_r($monitor_modes);

Full Screen

Full Screen

monitor_modes

Using AI Code Generation

copy

Full Screen

1include 'phodevi_monitor.php';2$phodevi = new phodevi_monitor();3$phodevi->monitor_modes();4include 'phodevi_monitor.php';5$phodevi = new phodevi_monitor();6$phodevi->monitor_modes();7 (8 (9 (10 (11 (12 (

Full Screen

Full Screen

monitor_modes

Using AI Code Generation

copy

Full Screen

1include_once('/usr/share/php/phodevi/phodevi_monitor.php');2$monitor = new phodevi_monitor();3$monitor->monitor_modes();4 (5 (6 (7 (8 (9 (10 (

Full Screen

Full Screen

monitor_modes

Using AI Code Generation

copy

Full Screen

1include_once('/usr/share/php/phodevi/phodevi_monitor.php');2$monitor = new phodevi_monitor();3$monitor_modes = $monitor->monitor_modes();4print_r($monitor_modes);5 (6 (7 (8 (9 (10 (11 (12 (13 (14 (15 (16 (

Full Screen

Full Screen

monitor_modes

Using AI Code Generation

copy

Full Screen

1require_once('phodevi_monitor.php');2$phodevi_monitor = new phodevi_monitor();3$phodevi_monitor->monitor_modes('monitor1');4 (5 (6 (7 (8 (9 (10 (11 (

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger monitor_modes code on LambdaTest Cloud Grid

Execute automation tests with monitor_modes on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful