public static function network_device_string() { $network = array(); if (phodevi::is_macosx()) { // TODO: implement } else { if (phodevi::is_bsd()) { foreach (array('dev.em.0.%desc', 'dev.wpi.0.%desc', 'dev.mskc.0.%desc') as $controller) { $pci = phodevi_bsd_parser::read_sysctl($controller); if (!empty($pci)) { array_push($network, $pci); } } } else { if (phodevi::is_windows()) { // TODO: implement } else { if (phodevi::is_linux()) { foreach (array('Ethernet controller', 'Network controller') as $controller) { $pci = phodevi_linux_parser::read_pci($controller); if (!empty($pci)) { array_push($network, $pci); } } } } } } return implode(' + ', $network); }
public static function audio_processor_string() { $audio = null; if (phodevi::is_macosx()) { // TODO: implement } else { if (phodevi::is_bsd()) { foreach (array('dev.hdac.0.%desc') as $dev) { $dev = phodevi_bsd_parser::read_sysctl($dev); if (!empty($dev)) { $audio = $dev; } } } else { if (phodevi::is_windows()) { // TODO: implement } else { if (phodevi::is_linux()) { foreach (pts_file_io::glob('/sys/class/sound/card*/hwC0D*/vendor_name') as $vendor_name) { $card_dir = dirname($vendor_name) . '/'; if (!is_readable($card_dir . 'chip_name')) { continue; } $vendor_name = pts_file_io::file_get_contents($vendor_name); $chip_name = pts_file_io::file_get_contents($card_dir . 'chip_name'); $audio = $vendor_name . ' ' . $chip_name; if (strpos($chip_name, 'HDMI') !== false || strpos($chip_name, 'DP') !== false) { // If HDMI is in the audio string, likely the GPU-provided audio, so try to find the mainboard otherwise $audio = null; } else { break; } } if ($audio == null) { $audio = phodevi_linux_parser::read_pci('Multimedia audio controller'); } if ($audio == null) { $audio = phodevi_linux_parser::read_pci('Audio device'); } } } } } return $audio; }
public static function chipset_string() { $info = false; if (phodevi::is_macosx()) { $sb_vendor = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'Vendor'); $sb_product = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'Product'); if ($sb_product == 'SSD') { $sb_product = null; } if (($cut_point = strpos($sb_product, ' ')) > 0) { $sb_product = substr($sb_product, 0, $cut_point); } // TODO: Can't find Northbridge $info = $sb_vendor . ' ' . $sb_product; } else { if (phodevi::is_windows()) { $info = phodevi_windows_parser::read_cpuz('Northbridge', null); if ($info != null) { if (($e = strpos($info, 'rev')) !== false) { $info = substr($info, 0, $e); } $info = trim($info); } } else { if (phodevi::is_solaris()) { // Vendor Detection $vendor_possible_udis = array('/org/freedesktop/Hal/devices/pci_0_0/pci_ide_3_2_0', '/org/freedesktop/Hal/devices/pci_0_0/pci_ide_1f_1_1'); $info = phodevi_solaris_parser::read_hal_property($vendor_possible_udis, 'info.vendor'); // TODO: Northbridge and Southbridge Detection For Solaris } else { if (phodevi::is_linux() || phodevi::is_hurd()) { $info = phodevi_linux_parser::read_pci(array('RAM memory', 'Host bridge')); if (count(explode(' ', $info)) == 1) { $bridge = phodevi_linux_parser::read_pci(array('Bridge', 'PCI bridge')); if (!empty($bridge)) { $match = false; $break_words = array('Ethernet', 'PCI', 'High', 'USB'); for ($i = 0; $i < count($break_words) && !$match; $i++) { if (($pos = strpos($bridge, $break_words[$i])) > 0) { $bridge = trim(substr($bridge, 0, $pos)); $info = $bridge; $match = true; } } } } if (!isset($bridge) || !empty($bridge)) { // Attempt to detect Southbridge (if applicable) $southbridge = phodevi_linux_parser::read_pci(array('ISA bridge', 'SATA controller'), false); $southbridge_clean = null; if (($start_cut = strpos($southbridge, '(')) > 0 && ($end_cut = strpos($southbridge, ')', $start_cut + 1)) > 0) { $southbridge_extract = substr($southbridge, $start_cut + 1, $end_cut - $start_cut - 1); if (strpos($southbridge_extract, 'rev') === false) { $southbridge_extract = explode(' ', $southbridge_extract); $southbridge_clean = $southbridge_extract[0]; } else { if (($s = strpos($southbridge, 'ICH')) > 0) { $southbridge_extract = substr($southbridge, $s); $southbridge_clean = substr($southbridge_extract, 0, strpos($southbridge_extract, ' ')); } } } else { if (($start_cut = strpos($southbridge, 'SB')) !== false) { $southbridge_extract = substr($southbridge, $start_cut); $southbridge_clean = substr($southbridge_extract, 0, strpos($southbridge_extract, ' ')); } } if (!empty($southbridge_clean) && $southbridge_clean != 'SB') { $info .= ' + ' . $southbridge_clean; } } } } } } return $info; }
public static function gpu_model() { // Report graphics processor string $info = phodevi_parser::read_glx_renderer(); $video_ram = phodevi::read_property('gpu', 'memory-capacity'); if (phodevi::is_ati_graphics() && phodevi::is_linux()) { $crossfire_status = phodevi_linux_parser::read_amd_pcsdb('SYSTEM/Crossfire/chain/*,Enable'); $crossfire_status = pts_arrays::to_array($crossfire_status); $crossfire_card_count = 0; for ($i = 0; $i < count($crossfire_status); $i++) { if ($crossfire_status[$i] == '0x00000001') { $crossfire_card_count += 2; // For now assume each chain is 2 cards, but proper way would be NumSlaves + 1 } } $adapters = phodevi_linux_parser::read_amd_graphics_adapters(); if (count($adapters) > 0) { $video_ram = $video_ram > 64 ? ' ' . $video_ram . 'MB' : null; // assume more than 64MB of vRAM if ($crossfire_card_count > 1 && $crossfire_card_count <= count($adapters)) { $unique_adapters = array_unique($adapters); if (count($unique_adapters) == 1) { if (strpos($adapters[0], 'X2') > 0 && $crossfire_card_count > 1) { $crossfire_card_count -= 1; } $info = $crossfire_card_count . ' x ' . $adapters[0] . $video_ram . ' CrossFire'; } else { $info = implode(', ', $unique_adapters) . ' CrossFire'; } } else { $info = $adapters[0] . $video_ram; } } } else { if (phodevi::is_macosx()) { $system_profiler_info = implode(' + ', phodevi_osx_parser::read_osx_system_profiler('SPDisplaysDataType', 'ChipsetModel', true)); if (!empty($system_profiler_info)) { $info = $system_profiler_info; } } else { if (phodevi::is_nvidia_graphics()) { if ($info == null) { if (pts_client::executable_in_path('nvidia-settings')) { $nv_gpus = shell_exec('nvidia-settings -q gpus 2>&1'); // TODO: search for more than one GPU $nv_gpus = substr($nv_gpus, strpos($nv_gpus, '[0]')); $nv_gpus = substr($nv_gpus, strpos($nv_gpus, '(') + 1); $nv_gpus = substr($nv_gpus, 0, strpos($nv_gpus, ')')); if (stripos($nv_gpus, 'GeForce') !== false || stripos($nv_gpus, 'Quadro') !== false) { $info = $nv_gpus; } } } $sli_mode = phodevi_parser::read_nvidia_extension('SLIMode'); if (!empty($sli_mode) && $sli_mode != 'Off') { $info .= ' SLI'; } } else { if (phodevi::is_solaris()) { if (($cut = strpos($info, 'DRI ')) !== false) { $info = substr($info, $cut + 4); } if (($cut = strpos($info, ' Chipset')) !== false) { $info = substr($info, 0, $cut); } if ($info == false && isset(phodevi::$vfs->xorg_log)) { $xorg_log = phodevi::$vfs->xorg_log; if (($x = strpos($xorg_log, '(0): Chipset: ')) !== false) { $xorg_log = substr($xorg_log, $x + 14); $xorg_log = str_replace(array('(R)', '"'), null, substr($xorg_log, 0, strpos($xorg_log, PHP_EOL))); if (($c = strpos($xorg_log, '[')) || ($c = strpos($xorg_log, '('))) { $xorg_log = substr($xorg_log, 0, $c); } if (phodevi::is_product_string($xorg_log)) { $info = $xorg_log; } } } } else { if (phodevi::is_bsd()) { $drm_info = phodevi_bsd_parser::read_sysctl('dev.drm.0.%desc'); if (!$drm_info) { $drm_info = phodevi_bsd_parser::read_sysctl('dev.nvidia.0.%desc'); } if (!$drm_info) { $agp_info = phodevi_bsd_parser::read_sysctl('dev.agp.0.%desc'); if ($agp_info != false) { $info = $agp_info; } } else { $info = $drm_info; } if ($info == null && isset(phodevi::$vfs->xorg_log)) { $xorg_log = phodevi::$vfs->xorg_log; if (($e = strpos($xorg_log, ' at 01@00:00:0')) !== false) { $xorg_log = substr($xorg_log, 0, $e); $info = substr($xorg_log, strrpos($xorg_log, 'Found ') + 6); } } } else { if (phodevi::is_windows()) { $info = phodevi_windows_parser::read_cpuz('Display Adapters', 'Name'); } } } } } } if (empty($info) || strpos($info, 'Mesa ') !== false || strpos($info, 'Gallium ') !== false) { if (phodevi::is_windows() == false) { $info_pci = phodevi_linux_parser::read_pci('VGA compatible controller', false); if (!empty($info_pci)) { $info = $info_pci; if (strpos($info, 'Intel 2nd Generation Core Family') !== false || strpos($info, 'Gen Core') !== false) { // Try to come up with a better non-generic string $was_reset = false; if (isset(phodevi::$vfs->xorg_log)) { /* $ cat /var/log/Xorg.0.log | grep -i Chipset [ 8.421] (II) intel: Driver for Intel Integrated Graphics Chipsets: i810, [ 8.421] (II) VESA: driver for VESA chipsets: vesa [ 8.423] (II) intel(0): Integrated Graphics Chipset: Intel(R) Sandybridge Mobile (GT2+) [ 8.423] (--) intel(0): Chipset: "Sandybridge Mobile (GT2+)" */ $xorg_log = phodevi::$vfs->xorg_log; if (($x = strpos($xorg_log, 'Integrated Graphics Chipset: ')) !== false) { $xorg_log = substr($xorg_log, $x + 29); $xorg_log = str_replace(array('(R)', '"'), null, substr($xorg_log, 0, strpos($xorg_log, PHP_EOL))); if (stripos($xorg_log, 'Intel') === false) { $xorg_log = 'Intel ' . $xorg_log; } // if string is too long, likely not product if (!isset($xorg_log[45])) { $info = $xorg_log; $was_reset = true; } } else { if (($x = strpos($xorg_log, '(0): Chipset: ')) !== false) { $xorg_log = substr($xorg_log, $x + 14); $xorg_log = str_replace(array('(R)', '"'), null, substr($xorg_log, 0, strpos($xorg_log, PHP_EOL))); if (stripos($xorg_log, 'Intel') === false) { $xorg_log = 'Intel ' . $xorg_log; } // if string is too long, likely not product if (!isset($xorg_log[45])) { $info = $xorg_log; $was_reset = true; } } } } if ($was_reset == false && isset(phodevi::$vfs->i915_capabilities)) { $i915_caps = phodevi::$vfs->i915_capabilities; if (($x = strpos($i915_caps, 'gen: ')) !== false) { $gen = substr($i915_caps, $x + 5); $gen = substr($gen, 0, strpos($gen, PHP_EOL)); if (is_numeric($gen)) { $info = 'Intel Gen' . $gen; if (strpos($i915_caps, 'is_mobile: yes') !== false) { $info .= ' Mobile'; } } } } } } } if (($start_pos = strpos($info, ' DRI ')) > 0) { $info = substr($info, $start_pos + 5); } if (empty($info) && isset(phodevi::$vfs->xorg_log)) { $log_parse = phodevi::$vfs->xorg_log; $log_parse = substr($log_parse, strpos($log_parse, 'Chipset') + 8); $log_parse = substr($log_parse, 0, strpos($log_parse, 'found')); if (strpos($log_parse, '(--)') === false && strlen(str_ireplace(array('ATI', 'NVIDIA', 'VIA', 'Intel'), '', $log_parse)) != strlen($log_parse)) { $info = $log_parse; } } if (empty($info) && is_readable('/sys/class/graphics/fb0/name')) { switch (pts_file_io::file_get_contents('/sys/class/graphics/fb0/name')) { case 'omapdrm': $info = 'Texas Instruments OMAP'; // The OMAP DRM driver currently is for OMAP2/3/4 hardware break; case 'exynos': $info = 'Samsung EXYNOS'; // The Exynos DRM driver break; case 'tegra_fb': $info = 'NVIDIA TEGRA'; // The Exynos DRM driver break; default: if (is_file('/dev/mali')) { $info = 'ARM Mali'; // One of the ARM Mali models } break; } } if (substr($info, -1) == ')' && ($open_p = strrpos($info, '(')) != false) { $end_check = strpos($info, ' ', $open_p); $to_check = substr($info, $open_p + 1, $end_check - $open_p - 1); // Don't report card revision from PCI info if ($to_check == 'rev') { $info = substr($info, 0, $open_p - 1); } } } if (($bracket_open = strpos($info, '[')) !== false) { // Report only the information inside the brackets if it's more relevant... // Mainly with Linux systems where the PCI information is reported like 'nVidia GF104 [GeForce GTX 460]' if (($bracket_close = strpos($info, ']', $bracket_open + 1)) !== false) { $inside_bracket = substr($info, $bracket_open + 1, $bracket_close - $bracket_open - 1); if (stripos($inside_bracket, 'Quadro') !== false || stripos($inside_bracket, 'GeForce') !== false) { $info = $inside_bracket . ' ' . substr($info, $bracket_close + 1); } else { if (stripos($inside_bracket, 'Radeon') !== false || stripos($inside_bracket, 'Fire') !== false || stripos($inside_bracket, 'Fusion') !== false) { $info = $inside_bracket . ' ' . substr($info, $bracket_close + 1); } } } } if (stripos($info, 'NVIDIA') === false && (stripos($info, 'Quadro') !== false || stripos($info, 'GeForce') !== false)) { $info = 'NVIDIA' . ' ' . $info; } else { if (stripos($info, 'ATI') === false && stripos($info, 'AMD') === false && (stripos($info, 'Radeon') !== false || stripos($info, 'Fire') !== false || stripos($info, 'Fusion') !== false)) { // Fire would be for FireGL or FirePro hardware $info = 'AMD ' . $info; } } if (phodevi::is_linux() && ($vendor = phodevi_linux_parser::read_pci_subsystem_value('VGA compatible controller')) != null && stripos($info, $vendor) === false && (stripos($info, 'AMD') !== false || stripos($info, 'NVIDIA') !== false)) { $info = $vendor . ' ' . $info; } if ($video_ram > 64 && strpos($info, $video_ram) == false) { $info .= ' ' . $video_ram . 'MB'; } $clean_phrases = array('OpenGL Engine'); $info = str_replace($clean_phrases, null, $info); return $info; }