elphel_php.h.353 4.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
#ifndef PHP_ELPHEL_H
#define PHP_ELPHEL_H 1

#ifdef ZTS
#include "TSRM.h"
#warning Using TSRM.h
#else
#warning Not using TSRM.h
#endif

#include <asm/elphel/c313a.h>
#include <asm/elphel/exifa.h>
#include <asm/elphel/autoexp.h>

ZEND_BEGIN_MODULE_GLOBALS(elphel)
int fd_exif;
int fd_exifdir;
int fd_exifmeta;
int exif_size; // to see if verify exif directory has changed
struct exif_dir_table_t exif_dir[ExifKmlNumber] ;  //! store locations of the fields needed for KML generations in the Exif block


/// (circbuf.c) access to /dev/circbuf (mmap, lseek)
int             fd_circ;
unsigned long * ccam_dma_buf;
unsigned long   ccam_dma_buf_len; // in bytes
//struct framepars_t *framePars;

/// (framepars.c) access to /dev/frameparsall (write, lseek, mmap)

int fd_fparmsall;
struct framepars_all_t   *frameParsAll;
struct framepars_t       *framePars;
struct framepars_past_t  *pastPars;
unsigned long            *funcs2call; ///   each parameter has a 32-bit mask of what pgm_function to call - other fields not used
unsigned long            *globalPars; /// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both 
unsigned long            *multiSensIndex; /// indexes of individual sensor register shadows (first of 3)
unsigned long            *multiSensRvrsIndex; /// reverse index (to parent) for the multiSensIndex


/// (gamma_tables.c) access to gammas
//static struct gamma_stuct_t gammas[GAMMA_CACHE_NUMBER] __attribute__ ((aligned (PAGE_SIZE)));
//       struct gamma_stuct_t * gammas_p; /// to use with mmap
int fd_gamma_cache;
struct gamma_stuct_t  * gamma_cache; /// array of gamma structures

//static struct histogram_stuct_t histograms[HISTOGRAM_CACHE_NUMBER] __attribute__ ((aligned (PAGE_SIZE)));

int fd_histogram_cache;
struct histogram_stuct_t  * histogram_cache; /// array of histogram

ZEND_END_MODULE_GLOBALS(elphel)
//!currently ZTS is not defined
#ifdef ZTS
#define ELPHEL_G(v) TSRMG(elphel_globals_id, zend_elphel_globals *, v)
#else
#define ELPHEL_G(v) (elphel_globals.v)
#endif

#define PHP_ELPHEL_VERSION "1.0"
#define PHP_ELPHEL_EXTNAME "elphel"
#define ELPHEL_GLOBALPARS(x) (((unsigned long *) ELPHEL_G(globalPars))[x-FRAMEPAR_GLOBALS])

PHP_FUNCTION(elphel_get_frame);      /// current absolute frame number (includes those that are not compressed)
PHP_FUNCTION(elphel_skip_frames);    /// skip some frames (includes those that are not compressed) - will work even if no frames are compressed
PHP_FUNCTION(elphel_wait_frame_abs); /// wait for absolute frame number (includes those that are not compressed)
PHP_FUNCTION(elphel_framepars_get_raw);
PHP_FUNCTION(elphel_parse_P_name);
PHP_FUNCTION(elphel_is_global_par);
PHP_FUNCTION(elphel_is_frame_par);
PHP_FUNCTION(elphel_get_P_value);
PHP_FUNCTION(elphel_set_P_value);
PHP_FUNCTION(elphel_get_P_arr);
PHP_FUNCTION(elphel_set_P_arr);
PHP_FUNCTION(elphel_gamma_add);
PHP_FUNCTION(elphel_gamma_add_custom);
PHP_FUNCTION(elphel_gamma_get);
PHP_FUNCTION(elphel_gamma_get_index);
PHP_FUNCTION(elphel_gamma_get_raw);
PHP_FUNCTION(elphel_histogram_get_raw);
PHP_FUNCTION(elphel_histogram_get);

PHP_FUNCTION(elphel_get_state); /// compatibility with old code

PHP_FUNCTION(elphel_compressor_reset); /// these elphel_compressor_*() functions are for compatibility. Reset will now just stop, not actually reset
PHP_FUNCTION(elphel_compressor_run);
PHP_FUNCTION(elphel_compressor_stop);
PHP_FUNCTION(elphel_compressor_frame);

PHP_FUNCTION(elphel_reset_sensor);
PHP_FUNCTION(elphel_set_fpga_time);
PHP_FUNCTION(elphel_get_fpga_time);
PHP_FUNCTION(elphel_wait_frame);          /// wait for compressed frame in a circular frame buffer - will wait forever if comressor is off
PHP_FUNCTION(elphel_fpga_read);
PHP_FUNCTION(elphel_fpga_write);
PHP_FUNCTION(elphel_gamma);
PHP_FUNCTION(elphel_reverse_gamma);
PHP_FUNCTION(elphel_histogram);
PHP_FUNCTION(elphel_reverse_histogram);
PHP_FUNCTION(elphel_get_exif_field);
PHP_FUNCTION(elphel_set_exif_field);
PHP_FUNCTION(elphel_get_interframe_meta);
PHP_FUNCTION(elphel_get_exif_elphel);
PHP_FUNCTION(elphel_get_circbuf_pointers);
PHP_FUNCTION(elphel_update_exif); // force to rebuild directory after Exif format was changed Usually done automatically


PHP_MINIT_FUNCTION(elphel);
PHP_MSHUTDOWN_FUNCTION(elphel);
PHP_RINIT_FUNCTION(elphel);
PHP_MINFO_FUNCTION(elphel);
extern zend_module_entry elphel_module_entry;
#define phpext_elphel_ptr &elphel_module_entry
//static void init_sens();
int splitConstantName(char * name);
int get_histogram_index (long color,long frame, long needreverse); /// histogram is availble for previous frame, not for the current one
unsigned long get_imageParamsThat     (int indx, unsigned long frame);

#endif