Commit 7869cf5a authored by Mikhail Karpenko's avatar Mikhail Karpenko

Merge remote-tracking branch 'origin/framepars'

parents 4ae324c3 d8b4639d
...@@ -16,16 +16,6 @@ ...@@ -16,16 +16,6 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder (1).launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.cdt.core.cnature</nature> <nature>org.eclipse.cdt.core.cnature</nature>
......
...@@ -210,6 +210,7 @@ ...@@ -210,6 +210,7 @@
#include <errno.h> #include <errno.h>
#include "php.h" #include "php.h"
#include "php_ini.h" /* for php.ini processing */ #include "php_ini.h" /* for php.ini processing */
#include "ext/standard/info.h" /* for php_info_print_table_* */
#include "elphel_php.h" #include "elphel_php.h"
...@@ -1266,15 +1267,20 @@ PHP_FUNCTION(elphel_histogram_get_raw) ...@@ -1266,15 +1267,20 @@ PHP_FUNCTION(elphel_histogram_get_raw)
long frame=-1; long frame=-1;
long needed=0xfff; long needed=0xfff;
long index; long index;
long total_hist_entries;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|ll", &port, &sub_chn, &needed, &frame) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|ll", &port, &sub_chn, &needed, &frame) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Wrong index"); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Wrong index");
RETURN_NULL (); RETURN_NULL ();
} }
if ((port <0) || (port >= SENSOR_PORTS)) RETURN_NULL (); if ((port <0) || (port >= SENSOR_PORTS)) RETURN_NULL ();
if ((sub_chn <0) || (sub_chn >= MAX_SENSORS)) RETURN_NULL (); if ((sub_chn <0) || (sub_chn >= MAX_SENSORS)) RETURN_NULL ();
if (frame<0) frame=lseek((int) ELPHEL_G( fd_fparmsall[port]), 0, SEEK_CUR ); // if (frame<0) frame=lseek((int) ELPHEL_G( fd_fparmsall[port]), 0, SEEK_CUR );
if (frame <0) {
frame=ELPHEL_GLOBALPARS(port, G_THIS_FRAME)-1;
}
needed &= 0xfff; needed &= 0xfff;
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_SET_CHN + (4 << port) + (1 << sub_chn), SEEK_END); /// specify port/sub-channel is needed total_hist_entries = lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_SET_CHN + (4 * port) + sub_chn, SEEK_END); /// specify port/sub-channel is needed
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_WAIT_C, SEEK_END); /// wait for all histograms, not just Y (G1) lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_WAIT_C, SEEK_END); /// wait for all histograms, not just Y (G1)
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_NEEDED + (needed & 0xff0), SEEK_END); /// mask out needed raw (fpga) bits lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_NEEDED + (needed & 0xff0), SEEK_END); /// mask out needed raw (fpga) bits
index=lseek(ELPHEL_G(fd_histogram_cache), frame, SEEK_SET); /// request histograms for frame=frame, wait until available if needed index=lseek(ELPHEL_G(fd_histogram_cache), frame, SEEK_SET); /// request histograms for frame=frame, wait until available if needed
...@@ -1282,11 +1288,10 @@ PHP_FUNCTION(elphel_histogram_get_raw) ...@@ -1282,11 +1288,10 @@ PHP_FUNCTION(elphel_histogram_get_raw)
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Requested histograms are not available (frame=%d, needed=0x%x)",frame,needed); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Requested histograms are not available (frame=%d, needed=0x%x)",frame,needed);
RETURN_NULL (); RETURN_NULL ();
} }
if (index >= HISTOGRAM_CACHE_NUMBER) { if (index >= total_hist_entries) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: frame=%d, index=%d",frame, index); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: frame=%d, index=%d >= %d (total_hist_entries)",frame, index, total_hist_entries);
RETURN_NULL (); RETURN_NULL ();
} }
// index &= (HISTOGRAM_CACHE_NUMBER -1);
packed_histogram_structure= (char*) emalloc (sizeof(struct histogram_stuct_t)); packed_histogram_structure= (char*) emalloc (sizeof(struct histogram_stuct_t));
if (!packed_histogram_structure) { if (!packed_histogram_structure) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "emalloc error"); php_error_docref(NULL TSRMLS_CC, E_ERROR, "emalloc error");
...@@ -1319,6 +1324,7 @@ PHP_FUNCTION(elphel_histogram_get) ...@@ -1319,6 +1324,7 @@ PHP_FUNCTION(elphel_histogram_get)
long frame=-1; long frame=-1;
long needed=0xfff; long needed=0xfff;
long index; long index;
long total_hist_entries;
int i; int i;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|ll", &port, &sub_chn, &needed, &frame) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|ll", &port, &sub_chn, &needed, &frame) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Wrong index"); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Wrong index");
...@@ -1327,17 +1333,22 @@ PHP_FUNCTION(elphel_histogram_get) ...@@ -1327,17 +1333,22 @@ PHP_FUNCTION(elphel_histogram_get)
if ((port <0) || (port >= SENSOR_PORTS)) RETURN_NULL (); if ((port <0) || (port >= SENSOR_PORTS)) RETURN_NULL ();
if ((sub_chn <0) || (sub_chn >= MAX_SENSORS)) RETURN_NULL (); if ((sub_chn <0) || (sub_chn >= MAX_SENSORS)) RETURN_NULL ();
// if (frame<0) frame=lseek((int) ELPHEL_G( fd_fparmsall[port]), 0, SEEK_CUR );
if (frame <0) {
frame=ELPHEL_GLOBALPARS(port, G_THIS_FRAME)-1;
}
needed &= 0xfff; needed &= 0xfff;
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_SET_CHN + (4 << port) + (1 << sub_chn), SEEK_END); /// specify port/sub-channel is needed total_hist_entries= lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_SET_CHN + (4 * port) + sub_chn, SEEK_END); /// specify port/sub-channel is needed
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_WAIT_C, SEEK_END); /// wait for all histograms, not just Y (G1)
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_NEEDED + (needed & 0xff0), SEEK_END); /// mask out needed raw (fpga) bits lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_WAIT_C, SEEK_END); // / wait for all histograms, not just Y (G1)
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_NEEDED + (needed & 0xff0), SEEK_END); // / mask out needed raw (fpga) bits
index=lseek(ELPHEL_G(fd_histogram_cache), frame, SEEK_SET); /// request histograms for frame=frame, wait until available if needed index=lseek(ELPHEL_G(fd_histogram_cache), frame, SEEK_SET); /// request histograms for frame=frame, wait until available if needed
if (index <0) { if (index <0) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Requested histograms are not available (frame=%d, needed=0x%x)",frame,needed); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Requested histograms are not available (frame=%d, needed=0x%x)",frame,needed);
RETURN_NULL (); RETURN_NULL ();
} }
if (index >= HISTOGRAM_CACHE_NUMBER) { if (index >= total_hist_entries) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: frame=%d, index=%d",frame, index); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: frame=%d, index=%d >= %d (total_hist_entries)",frame, index, total_hist_entries);
RETURN_NULL (); RETURN_NULL ();
} }
...@@ -1350,8 +1361,8 @@ PHP_FUNCTION(elphel_histogram_get) ...@@ -1350,8 +1361,8 @@ PHP_FUNCTION(elphel_histogram_get)
memcpy((void *) frame_histogram_structure, &(((struct histogram_stuct_t *) ELPHEL_G(histogram_cache))[index]),sizeof(struct histogram_stuct_t)); memcpy((void *) frame_histogram_structure, &(((struct histogram_stuct_t *) ELPHEL_G(histogram_cache))[index]),sizeof(struct histogram_stuct_t));
/// verify that histogram is still valid /// verify that histogram is still valid
if (frame != ((struct histogram_stuct_t *) ELPHEL_G(histogram_cache))[index].frame ) { if (frame != ((struct histogram_stuct_t *) ELPHEL_G(histogram_cache))[index].frame ) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Frame changed while retrieving histograms (frame requested=%d, current=%d)", php_error_docref(NULL TSRMLS_CC, E_ERROR, "Frame changed while retrieving histograms (frame requested=%d, received=%d, index=%d)",
frame, (int)((struct histogram_stuct_t *) ELPHEL_G(histogram_cache))[index].frame); frame, (int)((struct histogram_stuct_t *) ELPHEL_G(histogram_cache))[index].frame, index);
RETURN_NULL (); RETURN_NULL ();
efree (frame_histogram_structure); efree (frame_histogram_structure);
} }
...@@ -1497,7 +1508,18 @@ PHP_FUNCTION(elphel_get_circbuf_pointers) { ...@@ -1497,7 +1508,18 @@ PHP_FUNCTION(elphel_get_circbuf_pointers) {
read(ELPHEL_G(fd_exif[port]), &frame_be, 4); read(ELPHEL_G(fd_exif[port]), &frame_be, 4);
///... and add it to the output array ///... and add it to the output array
add_assoc_long(image_pointers, "frame", (long) __cpu_to_be32(frame_be)); add_assoc_long(image_pointers, "frame", (long) __cpu_to_be32(frame_be));
#define DEBUG_BYRSH
#ifdef DEBUG_BYRSH
int frame= (int) __cpu_to_be32(frame_be);
int past_index= frame & PASTPARS_SAVE_ENTRIES_MASK;
add_assoc_long(image_pointers, "dbg_comp_frame16", ((struct framepars_past_t *) ELPHEL_G(pastPars[port]))[past_index].past_pars[PARS_SAVE_COPY + 0]);
add_assoc_long(image_pointers, "dbg_comp_aframe", ((struct framepars_past_t *) ELPHEL_G(pastPars[port]))[past_index].past_pars[PARS_SAVE_COPY + 1]);
add_assoc_long(image_pointers, "dbg_cmprs_mode", ((struct framepars_past_t *) ELPHEL_G(pastPars[port]))[past_index].past_pars[PARS_SAVE_COPY + 2]);
add_assoc_long(image_pointers, "dbg_past_pars", ((struct framepars_past_t *) ELPHEL_G(pastPars[port]))[past_index].past_pars[PARS_SAVE_COPY + 3]);
add_assoc_long(image_pointers, "dbg_frame", frame);
add_assoc_long(image_pointers, "dbg_past_index", past_index);
add_assoc_long(image_pointers, "dbg_past_pars_0", ((struct framepars_past_t *) ELPHEL_G(pastPars[port]))[past_index].past_pars[0]);
#endif
// add_assoc_long(image_pointers, "dbg_exifPageStart", exifPageStart); // add_assoc_long(image_pointers, "dbg_exifPageStart", exifPageStart);
// add_assoc_long(image_pointers, "dbg_displacementInPage", displacementInPage); // add_assoc_long(image_pointers, "dbg_displacementInPage", displacementInPage);
// add_assoc_long(image_pointers, "dbg_frame_be", frame_be); // add_assoc_long(image_pointers, "dbg_frame_be", frame_be);
...@@ -2066,12 +2088,12 @@ PHP_FUNCTION(elphel_reverse_gamma) ...@@ -2066,12 +2088,12 @@ PHP_FUNCTION(elphel_reverse_gamma)
* @param needreverse 0 if only cumulative histogram is needed, >0 if the reverse is also needed * @param needreverse 0 if only cumulative histogram is needed, >0 if the reverse is also needed
* @return <0 if histogram can not be found fo the specified frame (i.e. too late), otherwise it is an index in histogram cache. * @return <0 if histogram can not be found fo the specified frame (i.e. too late), otherwise it is an index in histogram cache.
*/ */
int get_histogram_index (long port, long sub_chn, long color,long frame, long needreverse) { /// histogram is availble for previous frame, not for the current one int get_histogram_index (long port, long sub_chn, long color,long frame, long needreverse) { /// histogram is available for previous frame, not for the current one
long hist_index; long hist_index;
if ((color<0) || (color >= 4)) return -1; /// wrong color if ((color<0) || (color >= 4)) return -1; /// wrong color
if ((port <0) || (port >= SENSOR_PORTS)) return -1; if ((port <0) || (port >= SENSOR_PORTS)) return -1;
if ((sub_chn <0) || (sub_chn >= MAX_SENSORS)) return -1; if ((sub_chn <0) || (sub_chn >= MAX_SENSORS)) return -1;
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_SET_CHN + (4 << port) + (1 << sub_chn), SEEK_END); /// specify port/sub-channel is needed lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_SET_CHN + (4 * port) + sub_chn, SEEK_END); /// specify port/sub-channel is needed
if (color == COLOR_Y_NUMBER) lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_WAIT_Y, SEEK_END); /// wait for just Y (G1) if (color == COLOR_Y_NUMBER) lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_WAIT_Y, SEEK_END); /// wait for just Y (G1)
else lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_WAIT_C, SEEK_END); /// wait for all histograms, not just Y (G1) else lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_WAIT_C, SEEK_END); /// wait for all histograms, not just Y (G1)
lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_NEEDED + ((1 << color) << (needreverse? 8:4)), SEEK_END); /// specify what color is needed and if reverse is needed lseek(ELPHEL_G(fd_histogram_cache), LSEEK_HIST_NEEDED + ((1 << color) << (needreverse? 8:4)), SEEK_END); /// specify what color is needed and if reverse is needed
...@@ -2231,7 +2253,9 @@ PHP_FUNCTION(elphel_fpga_read) ...@@ -2231,7 +2253,9 @@ PHP_FUNCTION(elphel_fpga_read)
} }
RETURN_LONG(data); RETURN_LONG(data);
#else #else
RETURN_LONG(-1); php_error_docref(NULL TSRMLS_CC, E_ERROR, "elphel_fpga_read() not implemented");
return ;
// RETURN_LONG(-1);
#endif #endif
} }
...@@ -2255,7 +2279,10 @@ PHP_FUNCTION(elphel_fpga_write) ...@@ -2255,7 +2279,10 @@ PHP_FUNCTION(elphel_fpga_write)
return ; return ;
} }
#endif #endif
RETURN_NULL(); php_error_docref(NULL TSRMLS_CC, E_ERROR, "elphel_fpga_write() not implemented");
return ;
//
// RETURN_NULL();
} }
...@@ -2342,6 +2369,8 @@ static void php_elphel_init_globals(zend_elphel_globals *elphel_globals) ...@@ -2342,6 +2369,8 @@ static void php_elphel_init_globals(zend_elphel_globals *elphel_globals)
const char *exifMetaPaths[] = { DEV393_PATH(DEV393_EXIF_META0), DEV393_PATH(DEV393_EXIF_META1), const char *exifMetaPaths[] = { DEV393_PATH(DEV393_EXIF_META0), DEV393_PATH(DEV393_EXIF_META1),
DEV393_PATH(DEV393_EXIF_META2), DEV393_PATH(DEV393_EXIF_META3)}; DEV393_PATH(DEV393_EXIF_META2), DEV393_PATH(DEV393_EXIF_META3)};
//DEV393_PATH(DEV393_CIRCBUF0 //DEV393_PATH(DEV393_CIRCBUF0
int total_hist_entries;
int port; int port;
//! open "/dev/sensorpars" and mmap array - only once //! open "/dev/sensorpars" and mmap array - only once
for (port = 0; port < SENSOR_PORTS; port++){ for (port = 0; port < SENSOR_PORTS; port++){
...@@ -2398,8 +2427,9 @@ static void php_elphel_init_globals(zend_elphel_globals *elphel_globals) ...@@ -2398,8 +2427,9 @@ static void php_elphel_init_globals(zend_elphel_globals *elphel_globals)
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Can not open file %s",DEV393_PATH(DEV393_HISTOGRAM)); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Can not open file %s",DEV393_PATH(DEV393_HISTOGRAM));
return ; return ;
} }
total_hist_entries = lseek(elphel_globals->fd_histogram_cache, LSEEK_HIST_SET_CHN + 0, SEEK_END); /// specify port/sub-channel is needed
//! now try to mmap //! now try to mmap
elphel_globals->histogram_cache = (struct histogram_stuct_t *) mmap(0, sizeof (struct histogram_stuct_t) * HISTOGRAM_CACHE_NUMBER , PROT_READ, MAP_SHARED, elphel_globals->fd_histogram_cache, 0); elphel_globals->histogram_cache = (struct histogram_stuct_t *) mmap(0, sizeof (struct histogram_stuct_t) * total_hist_entries, PROT_READ, MAP_SHARED, elphel_globals->fd_histogram_cache, 0);
if((int)elphel_globals->histogram_cache == -1) { if((int)elphel_globals->histogram_cache == -1) {
elphel_globals->histogram_cache=NULL; elphel_globals->histogram_cache=NULL;
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error in mmap histogram_cache"); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error in mmap histogram_cache");
......
...@@ -8,10 +8,11 @@ ...@@ -8,10 +8,11 @@
#warning Not using TSRM.h #warning Not using TSRM.h
#endif #endif
#include "elphel/c313a.h" #include <elphel/c313a.h>
#include "elphel/exifa.h" #include <elphel/exifa.h>
#include <autoexp.h>
#include <elphel/x393_devices.h> #include <elphel/x393_devices.h>
//#include <autoexp.h>
//#include <elphel/x393_devices.h>
ZEND_BEGIN_MODULE_GLOBALS(elphel) ZEND_BEGIN_MODULE_GLOBALS(elphel)
int fd_exif[SENSOR_PORTS]; int fd_exif[SENSOR_PORTS];
......
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