Commit 1222ee72 authored by Andrey Filippov's avatar Andrey Filippov

added debugfs-webgui

parent a2e29be3
# Runs 'make', 'make install', and 'make clean' in specified subdirectories
SUBDIRS := src/php_top src/python_tests # src1
SUBDIRS := src/php_top src/python_tests src/debugfs-webgui # src1
INSTALLDIRS = $(SUBDIRS:%=install-%)
CLEANDIRS = $(SUBDIRS:%=clean-%)
......
DOCUMENTROOT=$(DESTDIR)/www/pages
OWN = -o root -g root
INSTDOCS = 0644
INSTALL = install
DOCS= debugfs.html \
debugfs.css \
debugfs.js
PHP_SCRIPTS=debugfs.php
all:
@echo "make all in src"
install:
@echo "make install in src"
$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(PHP_SCRIPTS) $(DOCUMENTROOT)
clean:
@echo "make clean in src"
html{
font-family: Arial;
font-size: 0.8em;
}
body{
padding: 10px;
}
table{
border-collapse:collapse;
border-radius: 3px;
}
th, td{
text-align: left;
padding: 3px 10px 3px 10px;
border-radius: 0px;
border: 1px solid rgba(180,180,180,0.5)
}
th {
background-color: rgba(200,200,200,0.5);
}
.even {
background-color: rgba(235,235,235,0.5);
}
.odd {
background-color: rgba(255,255,255,0.5);
}
.special {
background-color: rgba(100,200,100,0.5);
}
select {
border: 1px solid rgba(200,200,200,1);
border-radius: 2px;
font-family: Arial;
font-size: 1em;
background-color: rgba(200,200,200,0.5);
margin: 0px;
padding: 1px;
}
input {
-moz-appearance: none;
border: 1px solid rgba(200,200,200,1);
}
.tp{
width:20px;
height:20px;
}
\ No newline at end of file
<html>
<head>
<script src="js/jquery-2.2.3.min.js"></script>
<script src="debugfs.js"></script>
<script src="js/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="js/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" href="debugfs.css"/>
</head>
<body onload='init()'>
</body>
</html>
\ No newline at end of file
var debugfs_data;
function init(){
$("body").html("<h3>DebugFS:</h3>");
var b0 = $("<button>",{id:"b0"}).html("toggle hidden");
b0.prop("state",0);
b0.click(function(){
if ($(this).prop("state")==0){
$(this).prop("state",1)
$(".hidden_rows").show();
}else{
$(this).prop("state",0)
$(".hidden_rows").hide();
}
});
$("body").append($("<div>").css({padding:"0px 0px 10px 0px"}).append(b0));
var t = $("<table border=\"1\">").html("\
<tr>\
<th style='display:none;' class='hidden_rows'>Show</th>\
<th>File</th>\
</tr>\
");
$("body").append(t);
$.ajax({
url: "debugfs.php",
success: function(data){
var r = jQuery.parseJSON(data);
//global
debugfs_data = r;
for(var i=0;i<r.length;i++){
l = $("<tr>",{id:"row_"+i}).html("\
<td class='hidden_rows' style='text-align:center;display:none' >\
<input id='cb_"+i+"' class='tp visibility_cb' type='checkbox'>\
</td>\
<td class='special filename' id='header_"+i+" '>"+r[i].file+"</td>\
");
if (r[i].state==0){
l.addClass("hidden_rows").hide();
l.find("input").prop("checked",false);
}else{
l.removeClass("hidden_rows").show();
l.find("input").prop("checked",true);
}
content = $("<tr>",{
id: "content_"+i
}).css({
display: "none",
border: "0px solid rgba(255,255,255,0)"
});
content.append(
$("<td>").addClass("hidden_rows").hide()
).append(
$("<td>").append(
$("<table>").css({margin:"5px"})
)
);
//.append($("<td>").addClass("hidden_rows").css({display:"none"}))
t.append(l).append(content);
var r1 = r[i].configs[0].lines;
for (var j=0;j<r1.length;j++){
ttl = "module: "+r1[j].module+"\n";
ttl += "function: "+r1[j].function+"\n";
ttl += "format: "+r1[j].format;
if (r1[j].flags=="p"){
checked = "checked";
}else{
checked = "";
}
l = "<tr>";
l += " <td style='text-align:center' title='"+ttl+"'>"+r1[j].lineno+"</td>";
l += " <td style='text-align:center'><input type='checkbox' class='tp debug' "+checked+" file='"+r1[j].file+"' line='"+r1[j].lineno+"' /></td>";
l += "</tr>";
content.find("table").append(l);
}
}
//init actions
$(".debug").change(function(){
console.log($(this).attr("file")+", "+$(this).attr("line")+", "+$(this).prop("checked"));
$.ajax({
url: "debugfs.php?cmd=echo&file="+$(this).attr("file")+"&line="+$(this).attr("line")+"&pflag="+$(this).prop("checked")
});
});
$(".filename").click(function(){
var id = $(this).attr("id");
id = id.substr(id.indexOf("_")+1);
console.log(id);
$("#content_"+id).toggle();
});
$(".visibility_cb").change(function(){
var id = $(this).attr("id");
id = id.substr(id.indexOf("_")+1);
if ($(this).prop("checked")){
$("#row_"+id).removeClass("hidden_rows");
debugfs_data[id].state = 1;
}else{
$("#row_"+id).addClass("hidden_rows");
$("#content_"+id).hide();
debugfs_data[id].state = 0;
}
update_debugfs_config();
});
//when everything is parsed. do something.
// unique IDs
// save config
}
});
}
function update_debugfs_config(){
console.log("syncing debugfs config");
console.log(debugfs_data);
$.ajax({
type: "POST",
url: "debugfs.php?cmd=sync",
data: JSON.stringify(debugfs_data),
dataType: "json"
});
}
<?php
if (isset($_GET['cmd']))
$cmd = $_GET['cmd'];
else
$cmd = "do_nothing";
function get_control($f){
$res = Array();
$results = trim(file_get_contents($f));
//print("<pre>");
$ress = explode("\n",$results);
//filename - find first ":"
//lineno - between ":" and " "
//then [module] inside brackets
//function from "]" to " "
$oldfile = "";
foreach($ress as $line){
if ($line[0]=="#") continue;
$d0 = 0;
$d1 = strpos($line,":");
$d2 = strpos($line,"[");
$d3 = strpos($line,"]");
preg_match("/=[flmpt_]+/",$line,$matches,PREG_OFFSET_CAPTURE);
$d4 = $matches[0][1];
$d5 = strpos($line,"\"");
$subarr = Array();
$subarr['file'] = substr($line,0,$d1);
$subarr['lineno'] = substr($line,$d1+1,($d2-1)-$d1-1);
$subarr['module'] = substr($line,$d2+1,($d3-1)-$d2);
$subarr['function'] = substr($line,$d3+1,($d4-1)-$d3);
$subarr['flags'] = substr($line,$d4+1,1);
$subarr['format'] = substr($line,$d5+1,-1);
if ($subarr['file']!=$oldfile){
echo "processing ".$subarr['file']."\n";
if ($oldfile!="") array_push($res,$sub);
$oldfile = $subarr['file'];
$sub = Array(
"file" => $subarr['file'],
"state" => 0,
"configs" => Array(
Array(
"name" => "default",
"state" => 1,
"lines" => Array()
)
)
);
}
array_push($sub['configs'][0]['lines'],$subarr);
}
//last
array_push($res,$sub);
return $res;
}
function update_config($data){
// debugfs.json
file_put_contents("debugfs.json",$data);
}
function sync_to_config($file,$line,$flag){
//$arr_debugfs = get_control("/sys/kernel/debug/dynamic_debug/control");
$arr_config = json_decode(file_get_contents("debugfs.json"),true);
foreach($arr_config as $k => $v){
if ($v['file']==$file) $dc = $k;
}
echo "DC=$dc\n";
$tmp_arr1 = $arr_config[$dc]['configs'];
foreach($tmp_arr1 as $k => $v){
if ($v['state']==1) $dcc = $k;
}
$tmp_arr2 = $arr_config[$dc]['configs'][$dcc]['lines'];
foreach($tmp_arr2 as $k => $v){
if ($v['lineno']==$line) $dccc = $k;
}
if ($flag=="+") $flag = "p";
else $flag = "_";
$arr_config[$dc]['configs'][$dcc]['lines'][$dccc]['flags'] = $flag;
print_r($arr_config);
update_config(json_encode($arr_config));
}
if (($cmd=="do_nothing")||($cmd=="restore")){
if (isset($_GET['file'])) $file = $_GET['file'];
else $file = "/sys/kernel/debug/dynamic_debug/control";
//echo json_encode(get_control($file));
//echo "<pre>";
if (!is_file("debugfs.json")) {
$arr = get_control($file);
print_r($arr);
update_config(json_encode($arr));
echo "debugfs.json was missing, refresh page\n";
}else{
$json_data = file_get_contents("debugfs.json");
//print_r(json_decode($json_data));
echo $json_data;
}
}
if ($cmd=="echo") {
$file = $_GET['file'];
$line = $_GET['line'];
$flag = $_GET['pflag'];
//$config name
if ($flag=="true"){
$flag="+";
}else{
$flag="-";
}
exec("echo -n 'file $file line $line ${flag}p' > /sys/kernel/debug/dynamic_debug/control");
sync_to_config($file,$line,$flag);
}
$debugfs_configs = "debugfs_configs";
if ($cmd=="save"){
$file = $_GET['file'];
if (!is_dir($debugfs_configs)) mkdir($debugfs_configs);
file_put_contents("$debugfs_configs/$file", file_get_contents("/sys/kernel/debug/dynamic_debug/control"));
}
if ($cmd=="sync"){
//list saved configs here
$data = file_get_contents("php://input");
update_config($data);
}
//single line: echo -n 'file gamma_tables.c +p' > /sys/kernel/debug/dynamic_debug/control
?>
......@@ -161,18 +161,42 @@ $elp_const = get_defined_constants ( true );
$elp_const = $elp_const ["elphel"];
$test = 0;
$hist_needed = 0;
$port_mask = 0;
$SENSOR_PORTS = 4;
$framepars_paths = array ("/dev/frameparsall0",
"/dev/frameparsall1",
"/dev/frameparsall2",
"/dev/frameparsall3");
// Next is just to turn on/off compressor interrupts (new in NC393)
//circbuf0
$circbuf_paths = array ("/dev/circbuf0",
"/dev/circbuf1",
"/dev/circbuf2",
"/dev/circbuf3");
if (array_key_exists ( 'sensor_port', $_GET )) {
$sensor_port = (myval($_GET ['sensor_port'])) & 3;
$sensor_port = (myval($_GET ['sensor_port']));
}
if (array_key_exists ( 'sensor_subchn', $_GET )) {
$sensor_port = (myval($_GET ['sensor_subchn'])) & 3;
$sensor_port = (myval($_GET ['sensor_subchn']));
}
if ($sensor_port >= 0){
$sensor_port &= $SENSOR_PORTS-1;
$port_mask = 1 << $sensor_port;
} else {
$port_mask = (-$sensor_port);
if ($port_mask >= (1 << $SENSOR_PORTS)) $port_mask = (1 << $SENSOR_PORTS) -1;
$sensor_port = 0;
for ($i = 0; $i< $SENSOR_PORTS; $i++) if ($port_mask & (1<<i)){
$sensor_port = $i;
break;
}
}
$framepars_path = $framepars_paths[$sensor_port];
$circbuf_path = $circbuf_paths[$sensor_port];
foreach ( $_GET as $key => $value ) {
switch ($key) {
case "profile" :
......@@ -255,32 +279,34 @@ CAPTION;
case "gamma_reverse" :
$xml = new SimpleXMLElement ( "<?xml version='1.0'?><framepars/>" );
$value = floatval ( $value );
for ($sensor_port = 0; $sensor_port < $GLOBALS['SENSOR_PORTS'];$sensor_port++) if ($GLOBALS['port_mask'] & (1 << $sensor_port)) {
switch ($key) {
case "histogram_direct" :
$xml->addChild ( 'histogram_direct_r', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ( 'histogram_direct_g', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ( 'histogram_direct_gb', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
$xml->addChild ( 'histogram_direct_b', elphel_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
$xml->addChild ( 'histogram_direct_r'.strval($sensor_port), elphel_histogram ( $sensor_port, $GLOBALS ['$sensor_subchn'], 0, $value ) );
$xml->addChild ( 'histogram_direct_g'.strval($sensor_port), elphel_histogram ( $sensor_port, $GLOBALS ['$sensor_subchn'], 1, $value ) );
$xml->addChild ( 'histogram_direct_gb'.strval($sensor_port), elphel_histogram ( $sensor_port, $GLOBALS ['$sensor_subchn'], 2, $value ) );
$xml->addChild ( 'histogram_direct_b'.strval($sensor_port), elphel_histogram ( $sensor_port, $GLOBALS ['$sensor_subchn'], 3, $value ) );
break;
case "histogram_reverse" :
$xml->addChild ( 'histogram_reverse_r', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ( 'histogram_reverse_g', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ( 'histogram_reverse_gb', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
$xml->addChild ( 'histogram_reverse_b', elphel_reverse_histogram ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
$xml->addChild ( 'histogram_reverse_r'.strval($sensor_port), elphel_reverse_histogram ( $sensor_port, $GLOBALS ['$sensor_subchn'], 0, $value ) );
$xml->addChild ( 'histogram_reverse_g'.strval($sensor_port), elphel_reverse_histogram ( $sensor_port, $GLOBALS ['$sensor_subchn'], 1, $value ) );
$xml->addChild ( 'histogram_reverse_gb'.strval($sensor_port), elphel_reverse_histogram ( $sensor_port, $GLOBALS ['$sensor_subchn'], 2, $value ) );
$xml->addChild ( 'histogram_reverse_b'.strval($sensor_port), elphel_reverse_histogram ( $sensor_port, $GLOBALS ['$sensor_subchn'], 3, $value ) );
break;
case "gamma_direct" :
$xml->addChild ( 'gamma_direct_r', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ( 'gamma_direct_g', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ( 'gamma_direct_gb', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
$xml->addChild ( 'gamma_direct_b', elphel_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
$xml->addChild ( 'gamma_direct_r'.strval($sensor_port), elphel_gamma ( $sensor_port, $GLOBALS ['$sensor_subchn'], 0, $value ) );
$xml->addChild ( 'gamma_direct_g'.strval($sensor_port), elphel_gamma ( $sensor_port, $GLOBALS ['$sensor_subchn'], 1, $value ) );
$xml->addChild ( 'gamma_direct_gb'.strval($sensor_port), elphel_gamma ( $sensor_port, $GLOBALS ['$sensor_subchn'], 2, $value ) );
$xml->addChild ( 'gamma_direct_b'.strval($sensor_port), elphel_gamma ( $sensor_port, $GLOBALS ['$sensor_subchn'], 3, $value ) );
break;
case "gamma_reverse" :
$xml->addChild ( 'gamma_reverse_r', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 0, $value ) );
$xml->addChild ( 'gamma_reverse_g', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 1, $value ) );
$xml->addChild ( 'gamma_reverse_gb', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 2, $value ) );
$xml->addChild ( 'gamma_reverse_b', elphel_reverse_gamma ($GLOBALS['sensor_port'],$GLOBALS['$sensor_subchn'], 3, $value ) );
$xml->addChild ( 'gamma_reverse_r'.strval($sensor_port), elphel_reverse_gamma ( $sensor_port, $GLOBALS ['$sensor_subchn'], 0, $value ) );
$xml->addChild ( 'gamma_reverse_g'.strval($sensor_port), elphel_reverse_gamma ( $sensor_port, $GLOBALS ['$sensor_subchn'], 1, $value ) );
$xml->addChild ( 'gamma_reverse_gb'.strval($sensor_port), elphel_reverse_gamma ( $sensor_port, $GLOBALS ['$sensor_subchn'], 2, $value ) );
$xml->addChild ( 'gamma_reverse_b'.strval($sensor_port), elphel_reverse_gamma ( $sensor_port, $GLOBALS ['$sensor_subchn'], 3, $value ) );
break;
}
}
$rslt = $xml->asXML ();
header ( "Content-Type: text/xml" );
header ( "Content-Length: " . strlen ( $rslt ) . "\n" );
......@@ -290,67 +316,9 @@ CAPTION;
case "cmd" :
case "seek" :
case "fseek" :
case "lseek" :
case "lseek":
$xml = new SimpleXMLElement ( "<?xml version='1.0'?><framepars/>" );
if (! $value) {
$xml->addChild ( 'frame', elphel_get_frame ($GLOBALS['sensor_port']) );
// $xml->addChild ( 'frame8', elphel_fpga_read ( 0x16 ) & 7 );
} else if ($value == "time") {
$xml->addChild ( 'fpga_time', elphel_get_fpga_time ($GLOBALS['sensor_port']) );
} else if ($value == "irqoff") {
$framepars_file = fopen ( $framepars_path, "r" );
$xml->addChild ( 'irqoff_result', fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_OFF, SEEK_END ) ); // #define LSEEK_INTERRUPT_OFF 0x23 /// disable camera interrupts
fclose ( $framepars_file );
} else if ($value == "irqon") {
// / wait for frame8=0
// while ( elphel_fpga_read ( 0x16 ) & 7 )
// usleep ( 1000 ); // / Maybe needed to wait for 7, then 0?
$framepars_file = fopen ( $framepars_path, "r" );
$xml->addChild ( 'irqon_result', fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_ON, SEEK_END ) ); // #define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts
fclose ( $framepars_file );
} else if ($value == "init") {
$framepars_file = fopen ( $framepars_path, "r" );
$xml->addChild ( 'LSEEK_FRAMEPARS_INIT', fseek ( $framepars_file, ELPHEL_LSEEK_FRAMEPARS_INIT, SEEK_END ) );
$xml->addChild ( 'elphel_set_P_value', elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_SENSOR, 0x00, 0, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ) ); // / will start detection
$xml->addChild ( 'LSEEK_SENSORPROC', fseek ( $framepars_file, ELPHEL_LSEEK_SENSORPROC, SEEK_END ) );
$frame = 0;
// gets half-frame
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_MAXAHEAD, 2, 0, 8 ); // / When servicing interrupts, try programming up to 2 frames ahead of due time)
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_FPGA_XTRA, 1000, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // /compressor needs extra 1000 cycles to compress a frame (estimate)
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_EXTERN_TIMESTAMP, 1, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / only used with async trigger
// / good (latency should be changed, but for now that will make a correct initialization - maybe obsolete)
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_BITS, 8, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_QUALITY, 80, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_COLOR, 1, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_COLOR_SATURATION_BLUE, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_COLOR_SATURATION_RED, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_BAYER, 0, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_SENSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ($GLOBALS['sensor_port'], ELPHEL_COMPRESSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / run compressor
fclose ( $framepars_file );
$gamma = 57;
$black = 10;
$scale_r = ( int ) (1.0 * 1024);
$scale_g = ( int ) (0.9 * 1024);
$scale_b = ( int ) (1.1 * 1024);
$scale_gb = ( int ) (0.9 * 1024);
elphel_gamma_add ( 0.01 * $gamma, $black ); // does not depend on $GLOBALS['sensor_port']
// define P_GTAB_R 138 // combines (P_PIXEL_LOW<<24) | (P_GAMMA <<16) and 16-bit (6.10) scale for gamma tables, individually for each color.
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniqualy identify the table for applications
$gamma_pars = array (
"GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
);
$frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
} else if ($value == "gamma57") {
if ($value == "gamma57") {
$gamma = 57;
$black = 10;
$scale_r = ( int ) (1.0 * 1024);
......@@ -366,8 +334,11 @@ CAPTION;
"GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
);
$frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
for($sensor_port = 0; $sensor_port < $GLOBALS ['SENSOR_PORTS']; $sensor_port ++)
if ($GLOBALS ['port_mask'] & (1 << $sensor_port)) {
$frame = elphel_get_frame ( $sensor_port ); // 0
elphel_set_P_arr ( $sensor_port, $gamma_pars, $frame + 3, 0 );
}
} else if ($value == "gamma") {
$gamma = 60;
$black = 10;
......@@ -384,8 +355,11 @@ CAPTION;
"GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
);
$frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
for($sensor_port = 0; $sensor_port < $GLOBALS ['SENSOR_PORTS']; $sensor_port ++)
if ($GLOBALS ['port_mask'] & (1 << $sensor_port)) {
$frame = elphel_get_frame ( $sensor_port ); // 0
elphel_set_P_arr ( $sensor_port, $gamma_pars, $frame + 3, 0 );
}
} else if ($value == "linear") {
$gamma = 100;
$black = 0;
......@@ -402,52 +376,122 @@ CAPTION;
"GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
);
$frame = elphel_get_frame ($GLOBALS['sensor_port']); // 0
elphel_set_P_arr ($GLOBALS['sensor_port'], $gamma_pars, $frame + 3, 0 );
for($sensor_port = 0; $sensor_port < $GLOBALS ['SENSOR_PORTS']; $sensor_port ++)
if ($GLOBALS ['port_mask'] & (1 << $sensor_port)) {
$frame = elphel_get_frame ( $sensor_port ); // 0
elphel_set_P_arr ( $sensor_port, $gamma_pars, $frame + 3, 0 );
}
} else if ($value == "constants") {
echo "<pre>\n";
print_r ( $elp_const );
echo "</pre>\n";
exit ( 0 );
} else
for($sensor_port = 0; $sensor_port < $GLOBALS ['SENSOR_PORTS']; $sensor_port ++)
if ($GLOBALS ['port_mask'] & (1 << $sensor_port)) {
if (! $value) {
$xml->addChild ( 'frame' . strval ( $sensor_port ), elphel_get_frame ( $sensor_port ) );
$xml->addChild ( 'compressed' . strval ( $sensor_port ), elphel_get_compressed_frame ( $sensor_port ) );
} else if ($value == "time") {
$xml->addChild ( 'fpga_time' . strval ( $sensor_port ), elphel_get_fpga_time ( $sensor_port ) );
} else if ($value == "irqoff") {
$framepars_file = fopen ( $GLOBALS ['framepars_paths'] [$sensor_port], "w+" );
$xml->addChild ( 'irqoff_result' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_OFF, SEEK_END ) ); // #define LSEEK_INTERRUPT_OFF 0x23 /// disable camera interrupts
fclose ( $framepars_file );
} else if ($value == "irqon") {
$framepars_file = fopen ( $GLOBALS ['framepars_paths'] [$sensor_port], "w+" );
$xml->addChild ( 'irqon_result' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_ON, SEEK_END ) ); // #define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts
fclose ( $framepars_file );
} else if ($value == "compressor_irqoff") {
$framepars_file = fopen ( $GLOBALS ['circbuf_paths'] [$sensor_port], "w+" );
$xml->addChild ( 'compressor_irqoff_result' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_OFF, SEEK_END ) ); // #define LSEEK_INTERRUPT_OFF 0x23 /// disable camera interrupts
fclose ( $framepars_file );
} else if ($value == "compressor_irqon") {
$framepars_file = fopen ( $GLOBALS ['circbuf_paths'] [$sensor_port], "w+" );
$xml->addChild ( 'compressor_irqon_result', fseek ( $framepars_file, ELPHEL_LSEEK_INTERRUPT_ON, SEEK_END ) ); // #define LSEEK_INTERRUPT_ON 0x24 /// enable camera interrupts
fclose ( $framepars_file );
} else if ($value == "init") {
$framepars_file = fopen ( $GLOBALS ['framepars_paths'] [$sensor_port], "w+"); //r" );
$xml->addChild ('DEBUG_01_'. strval ( $sensor_port ), $GLOBALS ['framepars_paths'] [$sensor_port]);
$xml->addChild ( 'LSEEK_FRAMEPARS_INIT' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_FRAMEPARS_INIT, SEEK_END ) );
$xml->addChild ( 'elphel_set_P_value' . strval ( $sensor_port ), elphel_set_P_value ( $sensor_port, ELPHEL_SENSOR, 0x00, 0, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ) ); // / will start detection
$xml->addChild ( 'LSEEK_SENSORPROC' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_SENSORPROC, SEEK_END ) );
$frame = 0;
// gets half-frame
elphel_set_P_value ( $sensor_port, ELPHEL_MAXAHEAD, 2, 0, 8 ); // / When servicing interrupts, try programming up to 2 frames ahead of due time)
elphel_set_P_value ( $sensor_port, ELPHEL_FPGA_XTRA, 1000, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // /compressor needs extra 1000 cycles to compress a frame (estimate)
elphel_set_P_value ( $sensor_port, ELPHEL_EXTERN_TIMESTAMP, 1, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / only used with async trigger
// / good (latency should be changed, but for now that will make a correct initialization - maybe obsolete)
elphel_set_P_value ( $sensor_port, ELPHEL_BITS, 8, $frame + 3, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_QUALITY, 80, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR, 1, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR_SATURATION_BLUE, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COLOR_SATURATION_RED, 200, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_BAYER, 0, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_SENSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC );
elphel_set_P_value ( $sensor_port, ELPHEL_COMPRESSOR_RUN, 2, $frame + 4, ELPHEL_CONST_FRAMEPAIR_FORCE_NEWPROC ); // / run compressor
fclose ( $framepars_file );
$gamma = 57;
$black = 10;
$scale_r = ( int ) (1.0 * 1024);
$scale_g = ( int ) (0.9 * 1024);
$scale_b = ( int ) (1.1 * 1024);
$scale_gb = ( int ) (0.9 * 1024);
elphel_gamma_add ( 0.01 * $gamma, $black ); // does not depend on $GLOBALS['sensor_port']
// define P_GTAB_R 138 // combines (P_PIXEL_LOW<<24) | (P_GAMMA <<16) and 16-bit (6.10) scale for gamma tables, individually for each color.
// 16Msbs are also "hash16" and do not need to be black level/gamma, just uniqualy identify the table for applications
$gamma_pars = array (
"GTAB_R" => ($black << 24) | ($gamma << 16) | ($scale_r & 0xffff),
"GTAB_G" => ($black << 24) | ($gamma << 16) | ($scale_g & 0xffff),
"GTAB_B" => ($black << 24) | ($gamma << 16) | ($scale_b & 0xffff),
"GTAB_GB" => ($black << 24) | ($gamma << 16) | ($scale_gb & 0xffff)
);
$frame = elphel_get_frame ( $sensor_port ); // 0
elphel_set_P_arr ( $sensor_port, $gamma_pars, $frame + 3, 0 );
} else if ($value == "initgamma") {
$gammas_file = fopen ( "/dev/gamma_cache", "r" );
$xml->addChild ( 'LSEEK_GAMMA_INIT', fseek ( $gammas_file, ELPHEL_LSEEK_GAMMA_INIT, SEEK_END ) );
$gammas_file = fopen ( "/dev/gamma_cache", "w+" );
$xml->addChild ( 'LSEEK_GAMMA_INIT' . strval ( $sensor_port ), fseek ( $gammas_file, ELPHEL_LSEEK_GAMMA_INIT, SEEK_END ) );
fclose ( $gammas_file );
} else if ($value == "jpegheader") {
$circbuf_file = fopen ( "/dev/circbuf", "r" );
$circbuf_file = fopen ( "/dev/circbuf", "w+" );
fseek ( $circbuf_file, ELPHEL_LSEEK_CIRC_LAST, SEEK_END );
$jpeg_start = ftell ( $circbuf_file );
$xml->addChild ( 'circbuf_pointer', sprintf ( "0x%x (0x%x)", $jpeg_start, $jpeg_start >> 2 ) );
$xml->addChild ( 'circbuf_pointer' . strval ( $sensor_port ), sprintf ( "0x%x (0x%x)", $jpeg_start, $jpeg_start >> 2 ) );
fclose ( $circbuf_file );
$header_file = fopen ( "/dev/jpeghead", "r" );
$header_file = fopen ( "/dev/jpeghead", "w+" );
// / Now select right frame (different frames may have different header sizes)
fseek ( $header_file, $jpeg_start + 1, SEEK_END ); // / selects frame, creates header
fseek ( $header_file, 0, SEEK_END ); // / positions to the end
$header_size = ftell ( $header_file ); // /
$xml->addChild ( 'header_size', $header_size );
$xml->addChild ( 'header_size' . strval ( $sensor_port ), $header_size );
fseek ( $header_file, 0, SEEK_SET ); // / positions to the beginning
$header = fread ( $header_file, 8192 );
$xml->addChild ( 'header_read_length', strlen ( $header ) );
$xml->addChild ( 'header_read_length' . strval ( $sensor_port ), strlen ( $header ) );
fclose ( $header_file );
$aheader = unpack ( 'C*', $header );
for($i = 0; $i < count ( $aheader ); $i += 16) {
$d = "";
for($j = $i; ($j < $i + 16) && ($j < count ( $aheader )); $j ++)
$d .= sprintf ( " %02x", $aheader [$j + 1] );
$xml->addChild ( sprintf ( 'header%03x', $i ), $d );
$xml->addChild ( sprintf ( 'header%03x' . strval ( $sensor_port ), $i ), $d );
}
} else if ($value == "reset") {
$framepars_file = fopen ( $framepars_path, "r" );
$xml->addChild ( 'LSEEK_DMA_STOP', fseek ( $framepars_file, ELPHEL_LSEEK_DMA_STOP, SEEK_END ) );
$xml->addChild ( 'LSEEK_DMA_INIT', fseek ( $framepars_file, ELPHEL_LSEEK_DMA_INIT, SEEK_END ) );
$xml->addChild ( 'LSEEK_COMPRESSOR_RESET', fseek ( $framepars_file, ELPHEL_LSEEK_COMPRESSOR_RESET, SEEK_END ) );
$framepars_file = fopen ( $GLOBALS ['framepars_paths'] [$sensor_port], "w+" );
$xml->addChild ( 'LSEEK_DMA_STOP' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_DMA_STOP, SEEK_END ) );
$xml->addChild ( 'LSEEK_DMA_INIT' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_DMA_INIT, SEEK_END ) );
$xml->addChild ( 'LSEEK_COMPRESSOR_RESET' . strval ( $sensor_port ), fseek ( $framepars_file, ELPHEL_LSEEK_COMPRESSOR_RESET, SEEK_END ) );
fclose ( $framepars_file );
} else if ($value == "constants") {
echo "<pre>\n";
print_r ( $elp_const );
echo "</pre>\n";
exit ( 0 );
} else {
$framepars_file = fopen ( $framepars_path, "r" );
$xml->addChild ( 'lseek_' . $value, fseek ( $framepars_file, $value, SEEK_END ) );
$framepars_file = fopen ( $GLOBALS ['framepars_paths'] [$sensor_port], "w+" );
$xml->addChild ( 'lseek_' . $value . "_" . strval ( $sensor_port ), fseek ( $framepars_file, $value, SEEK_END ) );
fclose ( $framepars_file );
}
}
$rslt = $xml->asXML ();
header ( "Content-Type: text/xml" );
header ( "Content-Length: " . strlen ( $rslt ) . "\n" );
......@@ -641,7 +685,7 @@ if ($data === "") {
printf ( "<p><a href=\"%s/prev/prev/prev/prev/prev/prev/prev/prev/meta/next/meta/next/meta/next/meta/next/meta/next/meta/next/meta/next/meta/next/meta\">meta data for the last 9 frames</a></p>\n", $imgsrv );
ob_flush ();
flush (); // /OK here
$circbuf_file = fopen ( "/dev/circbuf", "r" );
$circbuf_file = fopen ( "/dev/circbuf", "w+" );
$current_frame = $frame;
printf ( "<p>frame=%d (0x%x), time=%d </p>\n", elphel_get_frame ($GLOBALS['sensor_port']), elphel_get_frame ($GLOBALS['sensor_port']), time () );
ob_flush ();
......@@ -781,7 +825,7 @@ function printGammaStructure() {
printf ( "</table>\n" );
}
function getGammaStructure() {
$gammas_file = fopen ( "/dev/gamma_cache", "r" );
$gammas_file = fopen ( "/dev/gamma_cache", "w+" );
fseek ( $gammas_file, 0, SEEK_END );
$numberOfEntries = ftell ( $gammas_file );
fclose ( $gammas_file );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment