Commit 439a2007 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

initial and not operational

parent 1b608ba2
elphel
\ No newline at end of file
#ifndef __H_AUTOEXP__
#define __H_AUTOEXP__
#define AUTOEXP_DEV_NAME "/dev/autoexp"
#define TABLES_LEN 8192
#define OFFSET_HIST_C (4096 + 256 * 6 * 2)
#define OFFSET_GAMMA_C (OFFSET_HIST_C + 4)
#define IOC_AUTOEXP_SET 0x01
#define IOC_AUTOEXP_GET 0x02
#define IOC_AUTOEXP_GET_LOG 0x03
#define IOC_AUTOEXP_GAMMA_TABLE 0x10
#ifndef HIST_NOT_CHANGE
#define HIST_NOT_CHANGE 0xFFFF
#endif
//!Moved to c313a.h
#if 0
struct autoexp_t {
unsigned long on;
/*
* in percents: 1 == 1, 100 == 100
*/
unsigned long width;
unsigned long height;
unsigned long left;
unsigned long top;
/*
* start exposure time really not needed...
*/
unsigned long exp_max; /* 100 usec == 1 etc... */
unsigned long overexp_max; /* percentages for overexposured pixels - 1% == 100, 5% == 500, 0.02% == 2 etc... */
/*
* changed chema - balance exposition for set percent of pixels in needed index
*/
unsigned long s_percent;
unsigned long s_index;
/*
* return current state
*/
unsigned long exp;
/*
* "sleep" settings
*/
unsigned long skip_pmin; /* percent of delta for skip changes: 1% == 100 */
unsigned long skip_pmax; /* percent of changes for wait one frame before apply changes: 1% == 100 */
unsigned long skip_t; /* time for skip changes: 100 usec == 1 */
};
#endif
#define LOG_C 200
//#define LOG_C 11
struct autoexp_log_t {
unsigned long tv_sec; /* time of log (fill in driver) */
unsigned long tv_usec;
unsigned long s_index; /* requested in settings index */
unsigned long s_percent; /* requested percent for s_index */
unsigned long n_index; /* searched new index with needed percent - if 0 - index not searched, and use linear scale */
unsigned long n_percent; /* percent in searched index */
unsigned long t_scale; /* scale of exposition - in FFFF.FFFF fixed point format */
unsigned long t_value; /* new time, requested for sensor - w/o real correction, in 0.1ms scale (1ms == 10 etc...) */
}; /* 8 * 4 == 32 bytes in record... */
#endif // __H_AUTOEXP__
This source diff could not be displayed because it is too large. You can view the blob instead.
dnl $Id$
dnl config.m4 for extension elphel
dnl Comments in this file start with the string 'dnl'.
dnl Remove where necessary. This file will not work
dnl without editing.
dnl If your extension references something external, use with:
dnl PHP_ARG_WITH(elphel, for elphel support,
dnl Make sure that the comment is aligned:
dnl [ --with-elphel Include elphel support])
dnl Otherwise use enable:
PHP_ARG_ENABLE(elphel, whether to enable elphel support,
Make sure that the comment is aligned:
[ --enable-elphel Enable elphel support])
if test "$PHP_ELPHEL" != "no"; then
dnl Write more examples of tests here...
dnl # --with-elphel -> check with-path
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
dnl SEARCH_FOR="/include/elphel.h" # you most likely want to change this
dnl if test -r $PHP_ELPHEL/$SEARCH_FOR; then # path given as parameter
dnl ELPHEL_DIR=$PHP_ELPHEL
dnl else # search default path list
dnl AC_MSG_CHECKING([for elphel files in default path])
dnl for i in $SEARCH_PATH ; do
dnl if test -r $i/$SEARCH_FOR; then
dnl ELPHEL_DIR=$i
dnl AC_MSG_RESULT(found in $i)
dnl fi
dnl done
dnl fi
dnl
dnl if test -z "$ELPHEL_DIR"; then
dnl AC_MSG_RESULT([not found])
dnl AC_MSG_ERROR([Please reinstall the elphel distribution])
dnl fi
dnl # --with-elphel -> add include path
dnl PHP_ADD_INCLUDE($ELPHEL_DIR/include)
dnl # --with-elphel -> check for lib and symbol presence
dnl LIBNAME=elphel # you may want to change this
dnl LIBSYMBOL=elphel # you most likely want to change this
dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
dnl [
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $ELPHEL_DIR/$PHP_LIBDIR, ELPHEL_SHARED_LIBADD)
dnl AC_DEFINE(HAVE_ELPHELLIB,1,[ ])
dnl ],[
dnl AC_MSG_ERROR([wrong elphel lib version or lib not found])
dnl ],[
dnl -L$ELPHEL_DIR/$PHP_LIBDIR -lm
dnl ])
dnl
dnl PHP_SUBST(ELPHEL_SHARED_LIBADD)
PHP_NEW_EXTENSION(elphel, elphel_php.c, $ext_shared)
fi
// $Id$
// vim:ft=javascript
// If your extension references something external, use ARG_WITH
// ARG_WITH("elphel", "for elphel support", "no");
// Otherwise, use ARG_ENABLE
// ARG_ENABLE("elphel", "enable elphel support", "no");
if (PHP_ELPHEL != "no") {
EXTENSION("elphel", "elphel.c");
}
This source diff could not be displayed because it is too large. You can view the blob instead.
#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 "c313a.h"
#include "exifa.h"
#include "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_test);
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
/*
exifa.h
*/
#ifndef _ASM_EXIF_H
#define _ASM_EXIF_H
//Major
#define X3X3_EXIF 125
//Minors
#define X3X3_EXIF_EXIF 0 // read encoded Exif data (SEEK_END,
#define X3X3_EXIF_META 1 // write metadata, concurently opened files. All writes atomic
// control/setup devices
#define X3X3_EXIF_TEMPLATE 2 // write Exif template
#define X3X3_EXIF_METADIR 3 // write metadata to Exif header translation (dir_table[MAX_EXIF_FIELDS])
// those 2 files will disable exif_enable and exif_valid, truncate file size to file pointer on release.
#define X3X3_EXIF_TIME 4 // write today/tomorrow date (YYYY:MM:DD) and number of seconds at today/tomorrow
// midnight (00:00:00) in seconds from epoch (long, startting from LSB)
// commands for the overloaded lseek:
//X3X3_EXIF_TIME
#define EXIF_LSEEK_DISABLE 1 // disable Exif (storing of frame meta, generating Exif)
#define EXIF_LSEEK_ENABLE 2 // enable Exif (build buffer if needed)
#define EXIF_LSEEK_INVALIDATE 3 // invalidate (and disable)
#define EXIF_LSEEK_REBUILD 4 // rebuild buffer
#define EXIF_LSEEK_TOMORROW_DATE 5 // file pointer to YYYY:MM:DD (tomorrow) string
#define EXIF_LSEEK_TOMORROW_SEC 6 // file pointer to unsigned long (little endian) tomorrow seconds from epoch
#define EXIF_LSEEK_TODAY_DATE 7 // file pointer to YYYY:MM:DD (today) string
#define EXIF_LSEEK_TODAY_SEC 8 // file pointer to unsigned long (little endian) today seconds from epoch
/*
Exif data in the images is combined from the "static" structure (template), calculated once at startup, and
variable data stored in the buffer for individual frames in the "Exif" form - converted to ASCII strings
or Rational or else. The generated Exif header copies that variable fileds on top of the Exif template.
The compressed data buffer is stored in "meta pages", one per frame
*/
struct exif_dir_table_t {
union {
unsigned long ltag;// tag group and tag combined
struct {
unsigned short tag_group; // tag group: 0 - IFD0, 1 - Exif, 2 - GPS
unsigned short tag; // Exif tag as defined in the standard
};
};
unsigned long len; // Number of bytes to be copied from metadata to Exif
unsigned long src; // offset in meta data page
unsigned long dst; // offset in output Exif page
};
#define MAX_EXIF_FIELDS 256 // number of Exif tags in the header
#define MAX_EXIF_SIZE 4096 // Exif data size
//#define MAX_EXIF_FRAMES 512 // number of frames in the buffer
#define MAX_EXIF_FRAMES 2048 // number of frames in the buffer
//Exif Tags - unsigned long, combining actual Exif tags with tag groups (0 - IFD0, 1 - Exif, 2 - GPS)
#define Exif_Image_ImageDescription 0x0010e
#define Exif_Image_Make 0x0010f
#define Exif_Image_Model 0x00110
#define Exif_Image_Software 0x00131
#define Exif_Image_DateTime 0x00132
#define Exif_Image_Artist 0x0013b
#define Exif_Image_HostComputer 0x0013c
#define Exif_Image_Orientation 0x00112
// hack, reusing field to keep it protected
#define Exif_Image_IPTCNAA 0x083bb
#define Exif_Image_FrameNumber 0x083bb
#define Exif_Image_ExifTag 0x08769
#define Exif_Image_GPSTag 0x08825
//Sub IFD
#define Exif_Photo_ExposureTime 0x1829a
#define Exif_Photo_DateTimeOriginal 0x19003
#define Exif_Photo_MakerNote 0x1927c
#define Exif_Photo_SubSecTime 0x19290
#define Exif_Photo_SubSecTimeOriginal 0x19291
//GPSInfo
#define Exif_GPSInfo_GPSLatitudeRef 0x20001
#define Exif_GPSInfo_GPSLatitude 0x20002
#define Exif_GPSInfo_GPSLongitudeRef 0x20003
#define Exif_GPSInfo_GPSLongitude 0x20004
#define Exif_GPSInfo_GPSAltitudeRef 0x20005
#define Exif_GPSInfo_GPSAltitude 0x20006
#define Exif_GPSInfo_GPSTimeStamp 0x20007
#define Exif_GPSInfo_GPSMeasureMode 0x2000a
#define Exif_GPSInfo_GPSDateStamp 0x2001D
/// used for compass module
#define Exif_GPSInfo_GPSImgDirectionRef 0x20010
#define Exif_GPSInfo_GPSImgDirection 0x20011
#define Exif_GPSInfo_GPSDestLatitudeRef 0x20013
#define Exif_GPSInfo_GPSDestLatitude 0x20014
#define Exif_GPSInfo_GPSDestLongitudeRef 0x20015
#define Exif_GPSInfo_GPSDestLongitude 0x20016
#define Exif_GPSInfo_CompassDirectionRef 0x20010
#define Exif_GPSInfo_CompassDirection 0x20011
#define Exif_GPSInfo_CompassPitchRef 0x20013
#define Exif_GPSInfo_CompassPitch 0x20014
#define Exif_GPSInfo_CompassRollRef 0x20015
#define Exif_GPSInfo_CompassRoll 0x20016
// array(0x9003,2,"2001:06:21 12:00:00","len"=> 20), //date/time original time created, always use 20 bytes (19 ."\0")
// array(0x9291,2,"0 ") //original time sub-second length=10 9 ."\0"
///move back to interframe_params_t?
struct frame_exif_t {
unsigned short meta_index; //! index of the linked meta page
unsigned short signffff; //! should be 0xffff - it will be a signature that JPEG data was not overwritten
unsigned long frame_length; //! frame length
};
struct meta_GPSInfo_t {
unsigned char GPSLatitudeRef; //"N"/"S"
unsigned long GPSLatitude_deg_nom;
unsigned long GPSLatitude_deg_denom;
unsigned long GPSLatitude_min_nom;
unsigned long GPSLatitude_min_denom;
unsigned char GPSLongitudeRef; //"E"/"W"
unsigned long GPSLongitude_deg_nom;
unsigned long GPSLongitude_deg_denom;
unsigned long GPSLongitude_min_nom;
unsigned long GPSLongitude_min_denom;
unsigned char GPSAltitudeRef; //byte, not ascii 0 - above sea level, 1 - below
unsigned long GPSAltitude_nom; //in meters
unsigned long GPSAltitude_denom;
unsigned long GPSTimeStamp_hrs_nom;
unsigned long GPSTimeStamp_hrs_denom;
unsigned long GPSTimeStamp_min_nom;
unsigned long GPSTimeStamp_min_denom;
unsigned long GPSTimeStamp_sec_nom;
unsigned long GPSTimeStamp_sec_denom;
unsigned char GPSDateStamp[11]; //includes '\0'
unsigned char GPSMeasureMode;
};
//hack - use
struct meta_CompassInfo_t {
// unsigned char GPSImgDirectionRef; //"M"/"T" //0x10
unsigned long CompassDirection_nom; //0x11
unsigned long CompassDirection_denom;
unsigned char CompassPitchRef; //"N"/"S"
unsigned long CompassPitch_nom;
unsigned long CompassPitch_denom;
unsigned char CompassRollRef; //"E"/"W"
unsigned long CompassRoll_nom;
unsigned long CompassRoll_denom;
};
#define EXIF_GPS_MIN_DENOM 10000
#define EXIF_GPS_METERS_DENOM 10
#define EXIF_GPS_TIMESEC_DENOM 1000
#define EXIF_GPS_COMPASS_DENOM 10
///hack!
#define EXIF_COMPASS_PITCH_ASCII "NS" // use for pitch +/-
#define EXIF_COMPASS_ROLL_ASCII "EW" // use for roll +/-
/// Exif data (variable, stored with each frame) used for KML (not only)
#define Exif_Image_ImageDescription_Index 0x00
#define Exif_Photo_DateTimeOriginal_Index 0x01
#define Exif_Photo_SubSecTimeOriginal_Index 0x02
#define Exif_Photo_ExposureTime_Index 0x03
#define Exif_GPSInfo_GPSLatitudeRef_Index 0x04
#define Exif_GPSInfo_GPSLatitude_Index 0x05
#define Exif_GPSInfo_GPSLongitudeRef_Index 0x06
#define Exif_GPSInfo_GPSLongitude_Index 0x07
#define Exif_GPSInfo_GPSAltitudeRef_Index 0x08
#define Exif_GPSInfo_GPSAltitude_Index 0x09
#define Exif_GPSInfo_GPSTimeStamp_Index 0x0a
#define Exif_GPSInfo_GPSDateStamp_Index 0x0b
#define Exif_GPSInfo_GPSMeasureMode_Index 0x0c
#define Exif_GPSInfo_CompassDirectionRef_Index 0x0d
#define Exif_GPSInfo_CompassDirection_Index 0x0e
#define Exif_GPSInfo_CompassPitchRef_Index 0x0f
#define Exif_GPSInfo_CompassPitch_Index 0x10
#define Exif_GPSInfo_CompassRollRef_Index 0x11
#define Exif_GPSInfo_CompassRoll_Index 0x12
#define Exif_Image_FrameNumber_Index 0x13
#define Exif_Image_Orientation_Index 0x14
#define Exif_Photo_MakerNote_Index 0x15
/// update ExifKmlNumber to be total number of *_Index entries
#define ExifKmlNumber Exif_Photo_MakerNote_Index+1
#define EXIF_DEV_NAME "/dev/exif_exif"
#define EXIFDIR_DEV_NAME "/dev/exif_metadir"
#define EXIFMETA_DEV_NAME "/dev/exif_meta"
#endif
--TEST--
Check for elphel presence
--SKIPIF--
<?php if (!extension_loaded("elphel")) print "skip"; ?>
--FILE--
<?php
echo "elphel extension is available";
/*
you can add regression tests for your extension here
the output of your test code has to be equal to the
text in the --EXPECT-- section below for the tests
to pass, differences between the output and the
expected text are interpreted as failure
see php5/README.TESTING for further information on
writing regression tests
*/
?>
--EXPECT--
elphel extension is available
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