<?php
$ctype=array('02000000'=>'LVDS','04000000'=>'DDVI','08000000'=>'SVIDEO','10000000'=>'VGA','00020000'=>'SDVI','00040000'=>'DP','00080000'=>'HDMI');
$entry=array('01000000','02050000','03040000','04060000','05030000');
function padHex($d,$l) {return str_pad(dechex($d),$l,'0',STR_PAD_LEFT);}
function toHex($s){$i=0;$t='';while(isset($s[$i])){$t.=padHex(ord($s[$i++]),2);}return $t;}
function toStr($h){$s='';$i=4;while($i-->0){$s.=chr($h>>(8*$i)&0xFF);}return $s;}
$a=file_get_contents('/System/Library/Extensions/AppleIntelFramebufferCapri.kext/Contents/MacOS/AppleIntelFramebufferCapri');
$b=-1;
while($b++<16){
if (($f=$b<<24|0x6601) && ($c=strpos($a,toStr($f)))===false &&
($f=$b<<24|0x6201) && ($c=strpos($a,toStr($f)))===false) continue;
while (ord($a[$c+8]) > 0) $c=strpos($a,toStr($f),$c+1);
echo '0x'.strtoupper(padHex($f,8)).' ('.(ord($a[$c+11])*16)."MiB)\n";
$t='';
$p=array();
foreach(str_split(substr($a,$c,108),12) as $d) {
$d=toHex($d);
if (in_array(substr($d,0,8),$entry)) $p[]=$ctype[substr($d,8,8)];
$t.=$d."\n";
}
if (count($p)) echo implode(', ',$p)."\n";
echo "$t\n";
}