00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 function myval ($s) {
00046 $s=trim($s,"\" ");
00047 if (strtoupper(substr($s,0,2))=="0X") return intval(hexdec($s));
00048 else return intval($s);
00049 }
00050
00051 function read_latencies() {
00052 global $elp_const;
00053 $elphel_onchange= 'ELPHEL_ONCHANGE_';
00054 $elphel_onchange_len=strlen('ELPHEL_ONCHANGE_');
00055 $l_iarr=array(
00056 'CALLNASAP'=>elphel_get_P_value(ELPHEL_CALLNASAP),
00057 'CALLNEXT1'=>elphel_get_P_value(ELPHEL_CALLNEXT+1),
00058 'CALLNEXT2'=>elphel_get_P_value(ELPHEL_CALLNEXT+2),
00059 'CALLNEXT3'=>elphel_get_P_value(ELPHEL_CALLNEXT+3),
00060 'CALLNEXT4'=>elphel_get_P_value(ELPHEL_CALLNEXT+4));
00061
00062
00063
00064
00065
00066
00067
00068 $larr=array();
00069 for ($i=0;$i<32;$i++) {
00070 $lat=0;
00071 if ($l_iarr['CALLNEXT1'] & (1<<$i)) $lat++;
00072 if ($l_iarr['CALLNEXT2'] & (1<<$i)) $lat++;
00073 if ($l_iarr['CALLNEXT3'] & (1<<$i)) $lat++;
00074 if ($l_iarr['CALLNEXT4'] & (1<<$i)) $lat++;
00075 $larr[$i]=array('name'=>'','seqen'=>($l_iarr['CALLNASAP'] & (1<<$i))?true:false,'latency'=>$lat);
00076 }
00077 foreach ($elp_const as $key=>$value) if (substr($key,0,$elphel_onchange_len)==$elphel_onchange) {
00078 $larr[$value]['name']=substr($key,$elphel_onchange_len);
00079 }
00080 return $larr;
00081 }
00082
00083 function apply_latencies() {
00084 $l_iarr=array(
00085 'CALLNASAP'=>0,
00086 'CALLNEXT1'=>0,
00087 'CALLNEXT2'=>0,
00088 'CALLNEXT3'=>0,
00089 'CALLNEXT4'=>0);
00090 for ($i=0;$i<32;$i++) {
00091 if ($_POST["seqen_".$i]) $l_iarr['CALLNASAP'] |= (1 << $i);
00092 switch ($_POST["latency_".$i]) {
00093 case "4":
00094 $l_iarr['CALLNEXT4'] |= (1 << $i);
00095 case "3":
00096 $l_iarr['CALLNEXT3'] |= (1 << $i);
00097 case "2":
00098 $l_iarr['CALLNEXT2'] |= (1 << $i);
00099 case "1":
00100 $l_iarr['CALLNEXT1'] |= (1 << $i);
00101 }
00102 }
00103 elphel_set_P_value(ELPHEL_CALLNASAP, $l_iarr['CALLNASAP'], 0, ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO);
00104 elphel_set_P_value(ELPHEL_CALLNEXT+1, $l_iarr['CALLNEXT1'], 0, ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO);
00105 elphel_set_P_value(ELPHEL_CALLNEXT+2, $l_iarr['CALLNEXT2'], 0, ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO);
00106 elphel_set_P_value(ELPHEL_CALLNEXT+3, $l_iarr['CALLNEXT3'], 0, ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO);
00107 elphel_set_P_value(ELPHEL_CALLNEXT+4, $l_iarr['CALLNEXT4'], 0, ELPHEL_CONST_FRAMEPAIR_FRAME_ZERO);
00108
00109
00110
00111
00112
00113
00114 }
00115
00116 function print_latencies() {
00117 $larr=read_latencies();
00118 printf ("<form action=\"$self\" method=\"post\">");
00119 printf ("<table border='1'><thead><td>bit#</td><td>Name</td><td>Enable<br/>sequencer</td><td>Latency</td></thead><tbody>\n");
00120 for ($i=0;$i<32;$i++) {
00121 printf ("<tr><td>%d</td><td>%s</td><td> <input type=\"checkbox\" name=\"seqen_%d\" value=\"1\" %s /> </td><td><input name=\"latency_%d\" type=\"text\" size=\"1\" value=\"%s\"/></td></tr>\n",
00122 $i,$larr[$i]['name']?$larr[$i]['name']:' ',
00123 $i, $larr[$i]['seqen']?'checked':'',$i,$larr[$i]['latency']);
00124 }
00125 printf ("</tbody></table>\n");
00126 printf ("<input type=\"submit\" value=\"Apply\"/></form>\n");
00127 }
00128
00129
00130 function read_triggers() {
00131 global $elp_const;
00132 $elphel_onchange= 'ELPHEL_ONCHANGE_';
00133 $elphel_onchange_len=strlen('ELPHEL_ONCHANGE_');
00134 $elphel_lseek= 'ELPHEL_LSEEK_';
00135 $elphel_lseek_len= strlen('ELPHEL_LSEEK_');
00136 $elphel_const= 'ELPHEL_CONST_';
00137 $elphel_const_len= strlen('ELPHEL_CONST_');
00138
00139 $elphel_len= strlen('ELPHEL_');
00140
00141 $fp_raw=elphel_framepars_get_raw(-1);
00142 $fp_raw_ul=unpack('V*',$fp_raw);
00143 $p_params=array_fill ( 0, 927, array('name'=>"",'value'=>0));
00144 for ($i=0;$i<927;$i++) $p_params[$i]['value']=$fp_raw_ul[$i+1];
00146 foreach ($elp_const as $key=>$value) {
00147 if ((substr($key,0,$elphel_onchange_len)!=$elphel_onchange) &&
00148 (substr($key,0,$elphel_lseek_len)!=$elphel_lseek) &&
00149 (substr($key,0,$elphel_const_len)!=$elphel_const)) {
00150 if (($value>=0) && ($value<count($p_params))) {
00151 if (!$p_params[$value]['name'] ) $p_params[$value]['name']=substr($key,$elphel_len);
00152 }
00153 }
00154 }
00155 for ($i=0; $i <ELPHEL_SENSOR_NUMREGS; $i++ ) !$p_params[ELPHEL_SENSOR_REGS+$i]['name']="SENSOR_REGS".$i;
00156 return $p_params;
00157 }
00158
00159
00160 function print_triggers_head($names) {
00161 printf ("<td>Num</td><td>Hex</td><td>Name</td><td>Value</td>\n");
00162 for ($i=0;$i<32;$i++) {
00163 printf("<td>");
00164 if ( count($names[$i])) foreach ($names[$i] as $char) printf("%s<br/>",$char);
00165 else printf(" ");
00166 printf("</td>");
00167 }
00168
00169 }
00170
00171
00172 function print_triggers($filter=0,$minnum=0, $maxnum=926, $rephead=50) {
00173 global $elp_const;
00174 $elphel_onchange= 'ELPHEL_ONCHANGE_';
00175 $elphel_onchange_len=strlen('ELPHEL_ONCHANGE_');
00176
00177
00178 $bit_names=array_fill ( 0, 32, "");
00179 foreach ($elp_const as $key=>$value) if (substr($key,0,$elphel_onchange_len)==$elphel_onchange) {
00180 $bit_names[$value]=substr($key,$elphel_onchange_len);
00181 }
00182 for ($i=0;$i<32;$i++) $bit_names[$i]=str_split($bit_names[$i]);
00183
00184
00185 $pars=read_triggers();
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 printf ("<form action=\"$self\" method=\"post\">");
00196 printf ("<table border='1'><thead>\n");
00197 print_triggers_head($bit_names);
00198 printf ("<tbody>\n");
00199 $tohead=$rephead;
00200 if ($maxnum>926) $maxnum=926;
00201 for ($parnum=$minnum;$parnum<=$maxnum;$parnum++) {
00202 if ((!($filter & 1) || ($pars[$parnum]['name'])) && (!($filter & 2) || ($pars[$parnum]['value']))) {
00203 printf ("<tr>\n");
00204 printf ("<td><input type=\"hidden\" name=\"par_%d\" value=\"%d\"/>%d</td><td>0x%x</td><td>%s</td><td>%08x</td>",$parnum,$parnum,$parnum,$parnum,($pars[$parnum]['name'])?($pars[$parnum]['name']):" ",$pars[$parnum]['value']);
00205 for ($b=0;$b<32;$b++) {
00206 printf ("<td><input type=\"checkbox\" name=\"trig_%d_%d\" value=\"1\" %s /></td>",$parnum,$b,($pars[$parnum]['value'] & (1 << $b))?'checked':'');
00207 }
00208 printf ("</tr>\n");
00209 if (($tohead--)<=0) {
00210 printf ("<tr>\n");
00211 print_triggers_head($bit_names);
00212 printf ("</tr>\n");
00213 $tohead=$rephead;
00214 }
00215 }
00216 }
00217 printf ("</tbody></table>\n");
00218
00219 printf ("<input type=\"submit\" value=\"Apply\"/></form>\n");
00220 }
00221
00222
00223 function apply_triggers() {
00224 $pars=array();
00225 foreach ($_POST as $key=>$value) if (substr($key,0,4)=="par_") $pars[$value]=0;
00226
00227 foreach ($_POST as $key=>$value) if (substr($key,0,5)=="trig_") {
00228 list ($s,$i,$j)= split('_',$key);
00229 $pars[$i] |= (1<<$j);
00230 }
00231 foreach ($pars as $key=>$value) {
00232 elphel_set_P_value(intval($key), intval($value), 0, ELPHEL_CONST_FRAMEPAIR_FRAME_FUNC);
00233 }
00234
00235
00236
00237
00238
00239 }
00240
00242
00243 $elp_const=get_defined_constants(true);
00244 $elp_const=$elp_const["elphel"];
00245
00246 switch ($_GET["mode"]) {
00247 case "triggers":
00248 case "functions":
00249 $filter=0;
00250 $minnum=0;
00251 $maxnum=512;
00252 $rephead=50;
00253 if ($_GET["filter"]) {
00254 $filter=$_GET["filter"];
00255 }
00256 if ($_GET["min"]) {
00257 $minnum=$_GET["min"];
00258 }
00259 if ($_GET["max"]) {
00260 $maxnum=$_GET["max"];
00261 }
00262 if ($_GET["rephead"]) {
00263 $rephead=$_GET["rephead"];
00264 }
00265
00266
00267 if ($_SERVER["REQUEST_METHOD"]=="POST") {
00268 apply_triggers();
00269 }
00270 print_triggers($filter, $minnum, $maxnum,$rephead);
00271 exit (0);
00272 case "latency":
00273 case "latencies":
00274 if ($_SERVER["REQUEST_METHOD"]=="POST") {
00275 apply_latencies();
00276 }
00277 print_latencies();
00278 exit (0);
00279 default:
00280
00281 echo <<<USAGE
00282 <p>This page allows to tune camera sequencer at run time, those adjustments to be applied to C headers of the drivers:
00283 <a href="http://elphel.cvs.sourceforge.net/viewvc/elphel/elphel353-7.2/os/linux-2.6-tag--devboard-R2_10-4/arch/cris/arch-v32/drivers/elphel/param_depend.h?view=markup">latency.h</a> and
00284 <a href="http://elphel.cvs.sourceforge.net/viewvc/elphel/elphel353-7.2/os/linux-2.6-tag--devboard-R2_10-4/arch/cris/arch-v32/drivers/elphel/param_depend.h?view=markup">param_depend.h</a></p>
00285 <p>First mode is used to specify latency (in frames) for different actions, additionally it specifies which actions can use hardware sequencer (some, like writing gamma tables to FPGA
00286 can only be performed in "ASAP" mode, bypassing the sequencer)</p>
00287 <h4> <a href="$self?mode=latency">mode=latency</a></h4>
00288 <p>The second one can be used to specify which functions are triggered by chnage in which parameters (either from user program or sometimes by actions of other functions).</p>
00289 <h4> <a href="$self?mode=triggers">mode=triggers</a></h4>
00290 <p>This mode can generate large tables, so it is possible to limit number of parameters shown,/p>
00291 <ul>
00292 <li><b>filter=N</b> (N=0..3), where 1 means "ignore unnamed parameters", 2 - "ignore parameters with a value 0", 3 - ignore both and 0 - show all<b></li>
00293 <li><b>min=N</b> - start with parameter number <b>N</b></li>
00294 <li><b>max=N</b> - end with parameter number <b>N</b></li>
00295 <li><b>rephead=N</b> - repeat table header each <b>N</b> lines.</li>
00296 </ul>
00297 <p>Example: <a href="$self?mode=triggers&filter=1&min=40&max=60">?mode=triggers&filter=1&min=40&max=60</a></p>
00298 USAGE;
00299 exit (0);
00300 }
00301
00302 ?>