apps/php-5.2.1/ext/elphel/elphel_php.h File Reference

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

Include dependency graph for elphel_php.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PHP_ELPHEL_H   1
#define ELPHEL_G(v)   (elphel_globals.v)
 currently ZTS is not defined
#define PHP_ELPHEL_VERSION   "1.0"
#define PHP_ELPHEL_EXTNAME   "elphel"
#define ELPHEL_GLOBALPARS(x)   (((unsigned long *) ELPHEL_G(globalPars))[x-FRAMEPAR_GLOBALS])
#define phpext_elphel_ptr   &elphel_module_entry

Functions

 PHP_FUNCTION (elphel_get_frame)
 Get current frame number.
 PHP_FUNCTION (elphel_skip_frames)
 current absolute frame number (includes those that are not compressed)
 PHP_FUNCTION (elphel_wait_frame_abs)
 skip some frames (includes those that are not compressed) - will work even if no frames are compressed
 PHP_FUNCTION (elphel_framepars_get_raw)
 wait for absolute frame number (includes those that are not compressed)
 PHP_FUNCTION (elphel_parse_P_name)
 Parse P_* /G_* parameter name with modifiers.
 PHP_FUNCTION (elphel_is_global_par)
 Strips integer constant of optional modifiers and finds if it is a valid global parameter number.
 PHP_FUNCTION (elphel_is_frame_par)
 Strips integer constant of optional modifiers and finds if it is a valid frame parameter number.
 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)
 Calculate new gamma table (specified by gamma value and black level) and put it into gamma cache Gamma cache will be used to program gamma tables to FPGA, calculate derivative tables Gamma tables should be loaded before used (gamma/black level/scale) specified as frame parameters gamma - floating point, <=1.0, will be rounded to 0.01. Larger gammas are reseved for custom tables black - floating point, <=1.0 or integer>1 (1..255) - level to subtract from sensor value.
 PHP_FUNCTION (elphel_gamma_add_custom)
 Load custom gamma table, tag it with hash16 (unsigned short). Using lower byte of hash16 larger than 0x64 (100) or high byte of 0xff will prevent hash16 used by gamma/blacklevel pairs.
 PHP_FUNCTION (elphel_gamma_get)
 Read loaded gamma table, optionally scale it and provide "raw" (integer) array.
 PHP_FUNCTION (elphel_gamma_get_index)
 Find loaded gamma table, optionally scale it and provide cache index (0 - not in cache).
 PHP_FUNCTION (elphel_gamma_get_raw)
 return selected (by integer index) cached gamma structure (struct gamma_stuct_t) as a binary string
 PHP_FUNCTION (elphel_histogram_get_raw)
 return selected (by integer index) cached histogram structure (struct histogram_stuct_t) as a binary string
 PHP_FUNCTION (elphel_histogram_get)
 return histograms for selected frame (absolute frame number) as a plain integer array some derivative histograms may be calculated if they do not exist yet (raw FPGA data should be read from IRQ/tasklet - no attemt to re-read FPGA here)
 PHP_FUNCTION (elphel_get_state)
 PHP_FUNCTION (elphel_compressor_reset)
 compatibility with old code
 PHP_FUNCTION (elphel_compressor_run)
 these elphel_compressor_*() functions are for compatibility. Reset will now just stop, not actually reset
 PHP_FUNCTION (elphel_compressor_stop)
 Stop FPGA compressor.
 PHP_FUNCTION (elphel_compressor_frame)
 Acquire one frame to the buffer.
 PHP_FUNCTION (elphel_reset_sensor)
 reset sensor, and re-initialize it
 PHP_FUNCTION (elphel_set_fpga_time)
 PHP_FUNCTION (elphel_get_fpga_time)
 Get current FPGA time as (double) seconds.
 PHP_FUNCTION (elphel_wait_frame)
 wait for the next frame to be compressed (and related parameters updated
 PHP_FUNCTION (elphel_fpga_read)
 wait for compressed frame in a circular frame buffer - will wait forever if comressor is off
 PHP_FUNCTION (elphel_fpga_write)
 PHP_FUNCTION (elphel_gamma)
 Use current (for the specified frame) gamma table to convert input data (fraction <1.0) into output value (used by histograms).
 PHP_FUNCTION (elphel_reverse_gamma)
 Use current (for the specified frame) gamma table to back-translate gamma converter output data (fraction <1.0) into the input (sensor) data.
 PHP_FUNCTION (elphel_histogram)
 Get cumulative histogram (fraction of all pixels below specified level).
 PHP_FUNCTION (elphel_reverse_histogram)
 Get percentile (reverse cumulative histogram) - level (as a fraction 0..1.0) so that specified fraction of all pixels are below it.
 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)
 TODO: make reverse order, specify how many frames wanted. So first will be most reliable.
 PHP_FUNCTION (elphel_update_exif)
 PHP_MINIT_FUNCTION (elphel)
 use gcc -save-temps to debug those macros for constants
 PHP_MSHUTDOWN_FUNCTION (elphel)
 PHP_RINIT_FUNCTION (elphel)
 PHP_MINFO_FUNCTION (elphel)
int splitConstantName (char *name)
 See if the name ands with number, truncate name to remove number and return number value.
int get_histogram_index (long color, long frame, long needreverse)
 common function to get index of the histogram cache for the specified color. May wait for the frame to become available
unsigned long get_imageParamsThat (int indx, unsigned long frame)
 histogram is availble for previous frame, not for the current one

Variables

int fd_exif
int fd_exifdir
int fd_exifmeta
int exif_size
exif_dir_table_t exif_dir [ExifKmlNumber]
int fd_circ
 (circbuf.c) access to /dev/circbuf (mmap, lseek)
unsigned long * ccam_dma_buf
unsigned long ccam_dma_buf_len
int fd_fparmsall
 Global variables.
framepars_all_tframeParsAll
framepars_tframePars
framepars_past_tpastPars
unsigned long * funcs2call
unsigned long * globalPars
 each parameter has a 32-bit mask of what pgm_function to call - other fields not used
int fd_gamma_cache
 (gamma_tables.c) access to gammas
gamma_stuct_tgamma_cache
 gamma cache is needed to re-linearize the data
int fd_histogram_cache
 array of gamma structures
histogram_stuct_thistogram_cache
zend_module_entry elphel_module_entry


Define Documentation

#define ELPHEL_G (  )     (elphel_globals.v)

currently ZTS is not defined

Definition at line 55 of file elphel_php.h.

Referenced by createExifDirectory(), elphel_set_P_value_common(), get_histogram_index(), get_imageParamsThat(), PHP_FUNCTION(), and PHP_MSHUTDOWN_FUNCTION().

#define ELPHEL_GLOBALPARS ( x   )     (((unsigned long *) ELPHEL_G(globalPars))[x-FRAMEPAR_GLOBALS])

Definition at line 60 of file elphel_php.h.

Referenced by elphel_set_P_value_common(), and PHP_FUNCTION().

#define PHP_ELPHEL_EXTNAME   "elphel"

Definition at line 59 of file elphel_php.h.

#define PHP_ELPHEL_H   1

Definition at line 2 of file elphel_php.h.

#define PHP_ELPHEL_VERSION   "1.0"

Definition at line 58 of file elphel_php.h.

Referenced by PHP_MINFO_FUNCTION().

#define phpext_elphel_ptr   &elphel_module_entry

Definition at line 111 of file elphel_php.h.


Function Documentation

int get_histogram_index ( long  color,
long  frame,
long  needreverse 
)

common function to get index of the histogram cache for the specified color. May wait for the frame to become available

Parameters:
color 0..3 - requested color (0 -R, 1 - G (used as Y ), 2 - GB (second green), 3 - blue
frame absolute frame number (histogrames are available for the previous (to current) frame
needreverse 0 if only cumulative histogram is needed, >0 if the reverse is also needed
Returns:
<0 if histogram can not be found fo the specified frame (i.e. too late), otherwise it is an index in histogram cache.

histogram is availble for previous frame, not for the current one

wrong color

wait for just Y (G1)

wait for all histograms, not just Y (G1)

specify what color is needed and if reverse is needed

request histogram for the specified frame

Definition at line 1772 of file elphel_php.c.

References COLOR_Y_NUMBER, ELPHEL_G, fd_histogram_cache, hist_index, LSEEK_HIST_NEEDED, LSEEK_HIST_WAIT_C, LSEEK_HIST_WAIT_Y, SEEK_END, and SEEK_SET.

Referenced by PHP_FUNCTION().

unsigned long get_imageParamsThat ( int  indx,
unsigned long  frame 
)

histogram is availble for previous frame, not for the current one

Parameters:
indx parameter indx
frame absolute frame number
Returns:
parameter value (error will be 0xffffffff, but that could be a legitimate value too)

Locate frame info in framePars

too late, try pastPars

not saved

should be retrieved before checking frame (interrupts)

too late even for pastPars? Or a bug?

Definition at line 224 of file aexp_utils.c.

References ELP_FERR, ELPHEL_G, framePars, P_FRAME, framepars_t::pars, PARS_FRAMES_MASK, PARS_SAVE_FROM, PARS_SAVE_NUM, framepars_past_t::past_pars, pastPars, PASTPARS_SAVE_ENTRIES_MASK, stderr, and value.

PHP_FUNCTION ( elphel_update_exif   ) 

Definition at line 1562 of file elphel_php.c.

References createExifDirectory().

PHP_FUNCTION ( elphel_get_circbuf_pointers   ) 

TODO: make reverse order, specify how many frames wanted. So first will be most reliable.

Frame number is in Exif structure

make sure directory is current

Exif_Image_FrameNumber_Index is present in template

no frame number in Exif

Find out frame number...

select specified Exif page

... and add it to the output array

next frame

Definition at line 1267 of file elphel_php.c.

References buff_size, ccam_dma_buf, createExifDirectory(), ELPHEL_G, exif_dir, Exif_Image_FrameNumber, Exif_Image_FrameNumber_Index, fd_circ, fd_exif, LSEEK_CIRC_FIRST, LSEEK_CIRC_NEXT, LSEEK_CIRC_READY, LSEEK_CIRC_SCND, exif_dir_table_t::ltag, read, SEEK_END, and SEEK_SET.

PHP_FUNCTION ( elphel_get_exif_elphel   ) 

Definition at line 1357 of file elphel_php.c.

References createExifDirectory(), dst, ELPHEL_G, EXIF_COMPASS_PITCH_ASCII, EXIF_COMPASS_ROLL_ASCII, exif_dir, Exif_GPSInfo_CompassDirection, Exif_GPSInfo_CompassDirection_Index, Exif_GPSInfo_CompassPitch, Exif_GPSInfo_CompassPitch_Index, Exif_GPSInfo_CompassPitchRef, Exif_GPSInfo_CompassPitchRef_Index, Exif_GPSInfo_CompassRoll, Exif_GPSInfo_CompassRoll_Index, Exif_GPSInfo_CompassRollRef, Exif_GPSInfo_CompassRollRef_Index, Exif_GPSInfo_GPSAltitude, Exif_GPSInfo_GPSAltitude_Index, Exif_GPSInfo_GPSAltitudeRef, Exif_GPSInfo_GPSAltitudeRef_Index, Exif_GPSInfo_GPSDateStamp, Exif_GPSInfo_GPSDateStamp_Index, Exif_GPSInfo_GPSLatitude, Exif_GPSInfo_GPSLatitude_Index, Exif_GPSInfo_GPSLatitudeRef, Exif_GPSInfo_GPSLatitudeRef_Index, Exif_GPSInfo_GPSLongitude, Exif_GPSInfo_GPSLongitude_Index, Exif_GPSInfo_GPSLongitudeRef, Exif_GPSInfo_GPSLongitudeRef_Index, Exif_GPSInfo_GPSMeasureMode, Exif_GPSInfo_GPSMeasureMode_Index, Exif_GPSInfo_GPSTimeStamp, Exif_GPSInfo_GPSTimeStamp_Index, Exif_Image_FrameNumber, Exif_Image_FrameNumber_Index, Exif_Image_ImageDescription, Exif_Image_ImageDescription_Index, Exif_Photo_DateTimeOriginal, Exif_Photo_DateTimeOriginal_Index, Exif_Photo_ExposureTime, Exif_Photo_ExposureTime_Index, Exif_Photo_SubSecTimeOriginal, Exif_Photo_SubSecTimeOriginal_Index, fd_exif, read, saferead255, SEEK_END, and SEEK_SET.

PHP_FUNCTION ( elphel_get_interframe_meta   ) 

Definition at line 1313 of file elphel_php.c.

References interframe_params_t::byrshift, ccam_dma_buf, ccam_dma_buf_len, CCAM_MMAP_META, CCAM_MMAP_META_SEC, interframe_params_t::color, ELPHEL_G, interframe_params_t::frame_length, interframe_params_t::hash32_b, interframe_params_t::hash32_g, interframe_params_t::hash32_gb, interframe_params_t::hash32_r, interframe_params_t::height, memcpy(), interframe_params_t::meta_index, interframe_params_t::quality2, interframe_params_t::signffff, interframe_params_t::timestamp_sec, interframe_params_t::timestamp_usec, and interframe_params_t::width.

PHP_FUNCTION ( elphel_set_exif_field   ) 

Definition at line 1600 of file elphel_php.c.

References ELPHEL_G, fd_exifdir, fd_exifmeta, exif_dir_table_t::ltag, read, SEEK_SET, value, and write.

PHP_FUNCTION ( elphel_get_exif_field   ) 

Definition at line 1567 of file elphel_php.c.

References ELPHEL_G, fd_exif, fd_exifdir, read, SEEK_CUR, SEEK_END, and SEEK_SET.

PHP_FUNCTION ( elphel_reverse_histogram   ) 

Get percentile (reverse cumulative histogram) - level (as a fraction 0..1.0) so that specified fraction of all pixels are below it.

Parameters:
color - needed color (0..3)
fraction - fraction (0.0 <=fraction<1.0) of all pixels to have value under the output (-1 will return -1, error)
frame (optional) absolute frame number for which histogram is needed. NOTE: If specified in the future - will wait if frame is not specified - will use latest histogram (previous to current frame)
Returns:
-1 if too late (or other errors), otherwise a level (in the 0.0<1.0 range) so that a specified fraction of all pixels are below it

256 of cumulated histogram values (in pixels)

256 of rounded percentiles (1 byte) - used as a starting point for linear interpolation

wrong color number

interpolate

if input level was ==-1 - error, don't try

floor()

seems hist_percentile[perc] rounds up, not down

adjust down (is that needed at all?)

adjust up (is that needed at all?)

Definition at line 1851 of file elphel_php.c.

References color, histogram_stuct_t::cumul_hist, ELPHEL_G, ELPHEL_GLOBALPARS, frame, G_THIS_FRAME, get_histogram_index(), hist_index, histogram_cache, and histogram_stuct_t::percentile.

PHP_FUNCTION ( elphel_histogram   ) 

Get cumulative histogram (fraction of all pixels below specified level).

Parameters:
color - needed color (0..3)
level - level (0.0 <=level<1.0) to compare pixel values to (-1 will return -1, error)
frame (optional) absolute frame number for which histogram is needed. NOTE: If specified in the future - will wait if frame is not specified - will use lates histogram (previous to current frame)
Returns:
-1 if too late (or other errors), otherwise a fraction of pixels (0..1.0) that are below the specified level

256 of cumulated histogram values (in pixels)

wrong color number

if input level was ==-1 - error, don't try

interpolate

Definition at line 1813 of file elphel_php.c.

References color, histogram_stuct_t::cumul_hist, ELPHEL_G, ELPHEL_GLOBALPARS, frame, G_THIS_FRAME, get_histogram_index(), hist, hist_index, and histogram_cache.

PHP_FUNCTION ( elphel_reverse_gamma   ) 

Use current (for the specified frame) gamma table to back-translate gamma converter output data (fraction <1.0) into the input (sensor) data.

Parameters:
color - needed color (0..3)
gammaLevel - level (0.0 <=level<1.0) proportional to the senosor output, normalized to 0.0..1.0 scale
frame (optional) absolute frame number for which gamma table is needed. NOTE: Will not wait if it is in the future - just return -1 if frame is not specified - will use the previous to current frame - same as the one for which histogram is availble (or will be very soon)
Returns:
-1 if too late (or other errors), otherwise a fraction of the full output level (0.0..1.0)

combined black, gamma, scale

wrong color number

now request gamma table for that hash32, including reverse

gamma table may be lost in cache - need reload/recalculation through elphel_gamma_add()

[257] "Gamma" table, 16-bit for both non-scaled prototypes

and scaled, 0..0xffff range (hardware will use less)

[256] reverse table to speed-up reversing (still need

interpolation).Index - most significant 8 bits, data - largest direct

8 MSBs used as index

seems gamma_reverse[] rounds up, not down

adjust down (is that needed at all?)

adjust up (is that needed at all?)

limit just in case?

Definition at line 1708 of file elphel_php.c.

References color, gamma_stuct_t::direct, ELPHEL_G, ELPHEL_GLOBALPARS, fd_gamma_cache, frame, G_THIS_FRAME, gamma_cache, gamma_direct, gamma_index, GAMMA_MODE_NEED_REVERSE, gamma_reverse, get_imageParamsThat(), gamma_stuct_t::hash32, P_GTAB_R, gamma_stuct_t::reverse, SEEK_CUR, and write.

PHP_FUNCTION ( elphel_gamma   ) 

Use current (for the specified frame) gamma table to convert input data (fraction <1.0) into output value (used by histograms).

Parameters:
color - needed color (0..3)
sensorLevel - level (0.0 <=level<1.0) proportional to the senosor output, normalized to 0.0..1.0 scale
frame (optional) absolute frame number for which gamma table is needed. NOTE: Will not wait if it is in the future - just return -1 if frame is not specified - will use the previous to current frame - same as the one for which histogram is availble (or will be very soon)
Returns:
-1 if too late (or other errors), otherwise a fraction of the full output level (0.0..1.0)

combined black, gamma, scale

wrong color number

now request gamma table for that hash32, including reverse

GAMMA_MODE_NEED_REVERSE;

gamma table may be lost in cache - need reload/recalculation through elphel_gamma_add()

[257] "Gamma" table, 16-bit for both non-scaled prototypes

and scaled, 0..0xffff range (hardware will use less)

Definition at line 1648 of file elphel_php.c.

References color, gamma_stuct_t::direct, ELPHEL_G, ELPHEL_GLOBALPARS, fd_gamma_cache, frame, G_THIS_FRAME, gamma_cache, gamma_direct, gamma_index, get_imageParamsThat(), P_GTAB_R, SEEK_CUR, and write.

PHP_FUNCTION ( elphel_fpga_write   ) 

Definition at line 1918 of file elphel_php.c.

References data, fd, return, SEEK_SET, and write.

PHP_FUNCTION ( elphel_fpga_read   ) 

wait for compressed frame in a circular frame buffer - will wait forever if comressor is off

32-bit registers, not bytes

Definition at line 1897 of file elphel_php.c.

References data, fd, read, return, and SEEK_SET.

PHP_FUNCTION ( elphel_wait_frame   ) 

wait for the next frame to be compressed (and related parameters updated

Definition at line 1632 of file elphel_php.c.

References ELPHEL_G, fd_circ, LSEEK_CIRC_TOWP, LSEEK_CIRC_WAIT, and SEEK_END.

PHP_FUNCTION ( elphel_get_fpga_time   ) 

Get current FPGA time as (double) seconds.

Definition at line 1967 of file elphel_php.c.

References ELPHEL_G, ELPHEL_GLOBALPARS, fd_fparmsall, G_MICROSECONDS, G_SECONDS, LSEEK_GET_FPGA_TIME, and SEEK_END.

PHP_FUNCTION ( elphel_set_fpga_time   ) 

set FPGA clock. Input parameter - (double) seconds (i.e. from 01/01/1970) This clock is used to timestamp each image returns same time rounded to microseconds (as written to FPGA)

Definition at line 1944 of file elphel_php.c.

References ELPHEL_G, fd_fparmsall, FRAMEPARS_SETFPGATIME, FRAMEPARS_SETFRAME, G_MICROSECONDS, G_SECONDS, and write.

PHP_FUNCTION ( elphel_reset_sensor   ) 

reset sensor, and re-initialize it

reset all framepars and globalPars

Definition at line 710 of file elphel_php.c.

References ELPHEL_G, elphel_set_P_value_common(), fd_fparmsall, LSEEK_FRAMEPARS_INIT, P_SENSOR, and SEEK_END.

PHP_FUNCTION ( elphel_compressor_frame   ) 

Acquire one frame to the buffer.

Definition at line 696 of file elphel_php.c.

References COMPRESSOR_RUN_SINGLE, elphel_set_P_value_common(), flags, frame, FRAMEPAIR_JUST_THIS, and P_COMPRESSOR_RUN.

PHP_FUNCTION ( elphel_compressor_stop   ) 

Stop FPGA compressor.

Definition at line 681 of file elphel_php.c.

References COMPRESSOR_RUN_STOP, elphel_set_P_value_common(), flags, frame, FRAMEPAIR_FORCE_NEWPROC, and P_COMPRESSOR_RUN.

PHP_FUNCTION ( elphel_compressor_run   ) 

these elphel_compressor_*() functions are for compatibility. Reset will now just stop, not actually reset

Definition at line 665 of file elphel_php.c.

References COMPRESSOR_RUN_CONT, elphel_set_P_value_common(), flags, frame, FRAMEPAIR_FORCE_NEWPROC, and P_COMPRESSOR_RUN.

PHP_FUNCTION ( elphel_compressor_reset   ) 

compatibility with old code

Definition at line 650 of file elphel_php.c.

References COMPRESSOR_RUN_STOP, elphel_set_P_value_common(), flags, frame, FRAMEPAIR_FORCE_NEWPROC, and P_COMPRESSOR_RUN.

PHP_FUNCTION ( elphel_get_state   ) 

NOTE: Just for compatibility with older code Get sensor state, usually 7- sensor is running, compressor is stopped, 8 - compressor is runing program sesnor/compressor according to the parameters specified. Argument==0 - restart the sensor, 1 - do it "on the fly"

Definition at line 443 of file elphel_php.c.

References COMPRESSOR_RUN_CONT, COMPRESSOR_RUN_SINGLE, ELPHEL_G, ELPHEL_GLOBALPARS, framePars, G_THIS_FRAME, P_COMPRESSOR_RUN, P_SENSOR_RUN, framepars_t::pars, PARS_FRAMES_MASK, and SENSOR_RUN_CONT.

PHP_FUNCTION ( elphel_histogram_get   ) 

return histograms for selected frame (absolute frame number) as a plain integer array some derivative histograms may be calculated if they do not exist yet (raw FPGA data should be read from IRQ/tasklet - no attemt to re-read FPGA here)

Parameters:
frame - absolute frame number
needed - bitmask specifying what tables to include in the output array, each group is in the order r(0),g(1),gb(2),b(3)
  • bits 0..3 - raw histograms from the FPGA (only if they are already in the cache)
  • bits 4..7 - cumulative histograms (sum of raw ones) - normally called from applications
  • bits 8..11 - calculate percentiles (reverse cumulative histograms) - normally called from applications
Returns:
NULL - error, otherwise a string with (struct histogram_stuct_t)

wait for all histograms, not just Y (G1)

mask out needed raw (fpga) bits

request histograms for frame=frame, wait until available if needed

use gamma_cache_index to retrieve table from cache

verify that histogram is still valid

verify that selected tables are valid

TODO: make array with subarrays for each individual table/color?

will return array 'return_value'

Definition at line 1153 of file elphel_php.c.

References ELPHEL_G, fd_histogram_cache, frame, histogram_cache, HISTOGRAM_CACHE_NUMBER, LSEEK_HIST_NEEDED, LSEEK_HIST_WAIT_C, memcpy(), SEEK_END, and SEEK_SET.

PHP_FUNCTION ( elphel_histogram_get_raw   ) 

return selected (by integer index) cached histogram structure (struct histogram_stuct_t) as a binary string

Parameters:
index - histogram cache index (or frame number, 3 lsb will be used)
Returns:
NULL - error, otherwise a string with (struct histogram_stuct_t)

wait for all histograms, not just Y (G1)

mask out needed raw (fpga) bits

request histograms for frame=frame, wait until available if needed

use gamma_cache_index to retrieve table from cache

Definition at line 1106 of file elphel_php.c.

References ELPHEL_G, fd_fparmsall, fd_histogram_cache, frame, histogram_cache, HISTOGRAM_CACHE_NUMBER, LSEEK_HIST_NEEDED, LSEEK_HIST_WAIT_C, memcpy(), SEEK_CUR, SEEK_END, and SEEK_SET.

PHP_FUNCTION ( elphel_gamma_get_raw   ) 

return selected (by integer index) cached gamma structure (struct gamma_stuct_t) as a binary string

Parameters:
index - gamma cache index
Returns:
NULL - error, otherwise a string with (struct gamma_stuct_t)

use gamma_cache_index to retrieve table from cache

just debug

Definition at line 1071 of file elphel_php.c.

References ELPHEL_G, gamma_cache, GAMMA_CACHE_NUMBER, and memcpy().

PHP_FUNCTION ( elphel_gamma_get_index   ) 

Find loaded gamma table, optionally scale it and provide cache index (0 - not in cache).

Parameters:
hash16 - unique ID (unsigned short ) of the table provided whan it was created. for regular gamma tables it is ((gamma *100) & 0xff) | (((black * 256) 0xff) << 8)
scale - optional scale will be applied to the gamma table. If provided scale is integer, it should be the same format as P_GTAB_* lower word - unsigned short, where GAMMA_SCLALE_1 (0x400) is 1.0, if it is floating point or integer 1 - it is "true" scale
Returns:
<0 - error, 0 - not in cache, >0 - cache index

look for a table in cache

0..0xffff

i/o error/ table does not exist - "silent" error?

Definition at line 1023 of file elphel_php.c.

References ELPHEL_G, fd_gamma_cache, GAMMA_SCLALE_1, SEEK_CUR, and write.

PHP_FUNCTION ( elphel_gamma_get   ) 

Read loaded gamma table, optionally scale it and provide "raw" (integer) array.

Parameters:
hash16 - unique ID (unsigned short ) of the table provided whan it was created. for regular gamma tables it is ((gamma *100) & 0xff) | (((black * 256) 0xff) << 8)
scale - optional scale will be applied to the gamma table. If provided scale is integer, it should be the same format as P_GTAB_* lower word - unsigned short, where GAMMA_SCLALE_1 (0x400) is 1.0, if it is floating point or integer 1 - it is "true" scale
raw - 0: return array of floating point numbers, in the range 0..1.0, !=0 - array of unsigned short numbers
Returns:
if OK - array of 257 numbers floating 0..1.0 or intefer 0..0xffff, negative integer - error

look for a table in cache

0..0xffff

i/o error/ table does not exist - "silent" error?

requested table does not exist in the cache - "silent" error?

use gamma_cache_index to retrieve table from cache

requested table was overwritten - "silent" error?

convert gtable to PHP array

will return array 'return_value'

Definition at line 955 of file elphel_php.c.

References ELPHEL_G, fd_gamma_cache, gamma_cache, GAMMA_SCLALE_1, LSEEK_GAMMA_ISCURRENT, memcpy(), raw, SEEK_CUR, SEEK_END, and write.

PHP_FUNCTION ( elphel_gamma_add_custom   ) 

Load custom gamma table, tag it with hash16 (unsigned short). Using lower byte of hash16 larger than 0x64 (100) or high byte of 0xff will prevent hash16 used by gamma/blacklevel pairs.

Parameters:
hash16 - hash 16 that will be used to identify the table when setting parameters
zarray - array of 257 elements indexed as 0..256, in the range of 0.. 1.0 to be used for a table
Returns:
-1.. -998 - errno when writing to driver -998 - wrong arguments -999 - array length is not 257 -1000..-1256 - missing element 0..256 -2000..-2256 - non-numeric element 0..256 >=0 - hash16

1.0

now iterate through indexed array

Definition at line 889 of file elphel_php.c.

References d, data, ELPHEL_G, fd_gamma_cache, GAMMA_SCLALE_1, and write.

PHP_FUNCTION ( elphel_gamma_add   ) 

Calculate new gamma table (specified by gamma value and black level) and put it into gamma cache Gamma cache will be used to program gamma tables to FPGA, calculate derivative tables Gamma tables should be loaded before used (gamma/black level/scale) specified as frame parameters gamma - floating point, <=1.0, will be rounded to 0.01. Larger gammas are reseved for custom tables black - floating point, <=1.0 or integer>1 (1..255) - level to subtract from sensor value.

Returns:
hash16 - ((gamma *100) & 0xff) | (((black * 256) 0xff) << 8)

don't use 255 - reserve it for custom tables

1.0

Definition at line 844 of file elphel_php.c.

References ELPHEL_G, fd_gamma_cache, gamma, gamma_calc(), GAMMA_SCLALE_1, and write.

PHP_FUNCTION ( elphel_set_P_arr   ) 

This function reads associative array and writes values to the camera registers, using "ELPHEL_* constants" to determine register address from the provided key in each key/value pair All non-numerical values are ignored Returns number of values written UPDATE:retuns frame number to which parameters were written

will accept flags both shifted and not shifted

allocate array to be written (8 bytes per value + 8)

emalloc failed

found the constant as is

Try to remove number from the end

FRAMEPAIR_MASK_BYTES to prevent bit-field modifier addition to constants that already have them

is it a global parameter?

free resources used for constant value

these globals can be written just through mmap

Fits in the range of the global parameters

Full 32-bit writes - use mmap

only some bitfield is modified - use (slower) write to have it atomic, no need to do bit field combining here

actually written to driver

RETURN_LONG(num_mmap_written+num_written);

Definition at line 721 of file elphel_php.c.

References data, ELPHEL_G, ELPHEL_GLOBALPARS, fd_fparmsall, flags, frame, FRAME_DEAFAULT_AHEAD, FRAMEPAIR_MASK_BYTES, FRAMEPAR_GLOBALS, FRAMEPARS_SETFRAME, G_THIS_FRAME, init_sens(), P_MAX_GPAR, splitConstantName(), and write.

PHP_FUNCTION ( elphel_get_P_arr   ) 

This function reads associative array and uses the keys as a template for the result array. If mey is one of the defined P_VALUE names (same as global constant but w/o "ELPHEL_" prefix) then the result array will have element with the same key and the value equal to the value of the camera parameter TODO:Make it per frame (absolute), combine with past frames frame absent - "current frame" frame ==0 - frame zero (static?)

number to add to the ELPHEL_* constant value

first see if this frame is either in the future, past or is frame zero (parameters that are not related to frames)

frame number not provided - use latest

try future first

too early for the frame number specified

not available - only global parameters could be retrieved

Maybe it is in the past frames (only subset of parameters preserved)

Too late, probably - all the records are gone by now

should be there, but in the past

found the constant as is

Try to remove number from the end

FRAMEPAIR_MASK_BYTES to prevent bit-field modifier addition to constants that already have them

is it a global parameter?

is it in the future/latest?

is it saved in past parameters?

Definition at line 496 of file elphel_php.c.

References data, ELPHEL_G, ELPHEL_GLOBALPARS, frame, FRAMEPAIR_FRAME_FIELD, FRAMEPAIR_MASK_BYTES, FRAMEPAR_GLOBALS, framePars, future, G_THIS_FRAME, P_FRAME, P_MAX_GPAR, framepars_t::pars, PARS_FRAMES_MASK, PARS_SAVE_FROM, framepars_past_t::past_pars, pastPars, PASTPARS_SAVE_ENTRIES_MASK, and splitConstantName().

PHP_FUNCTION ( elphel_set_P_value   ) 

Set acquisition/compression parameters. addr may include flags - addr|=(flags>>16) UPDATE: return frame number to which parameters was set

Definition at line 634 of file elphel_php.c.

References data, elphel_set_P_value_common(), flags, and frame.

PHP_FUNCTION ( elphel_get_P_value   ) 

Read value from the sensor/compressor parameters ("read" parameters, verified by the driver), see asm/elphel/c313a.h TODO: Make it read pastPars also?

remove any possible flags

is it a global parameter?

these globals can be written just through mmap

processing dynamic frame parameters

read current (most recent) frame - different from _set_

try framePars

This is what we are looking for

too early for the frame number specified

too late for framePars - let's try pastPars

This is what we are looking for

too late, probably

Definition at line 384 of file elphel_php.c.

References ELPHEL_G, ELPHEL_GLOBALPARS, frame, FRAMEPAIR_FRAME_FIELD, FRAMEPAIR_MASK_BYTES, FRAMEPAR_GLOBALS, framePars, G_THIS_FRAME, P_FRAME, P_MAX_GPAR, framepars_t::pars, PARS_FRAMES_MASK, PARS_SAVE_FROM, framepars_past_t::past_pars, pastPars, and PASTPARS_SAVE_ENTRIES_MASK.

PHP_FUNCTION ( elphel_is_frame_par   ) 

Strips integer constant of optional modifiers and finds if it is a valid frame parameter number.

Parameters:
full parameter address
Returns:
true if this address is a valid address of a frame parameter

remove any possible flags

Definition at line 371 of file elphel_php.c.

PHP_FUNCTION ( elphel_is_global_par   ) 

Strips integer constant of optional modifiers and finds if it is a valid global parameter number.

Parameters:
full parameter address
Returns:
true if this address is a valid address of a global parameter

remove any possible flags

Definition at line 355 of file elphel_php.c.

References FRAMEPAR_GLOBALS, and P_MAX_GPAR.

PHP_FUNCTION ( elphel_parse_P_name   ) 

Parse P_* /G_* parameter name with modifiers.

Parameters:
name - constant name (w/o leading "ELPHEL_")
Returns:
full address/number or NULL if it does not exist

found the constant as is

FRAMEPAIR_MASK_BYTES to prevent bit-field modifier addition to constants that already have them

Definition at line 322 of file elphel_php.c.

References FRAMEPAIR_MASK_BYTES, name, and splitConstantName().

PHP_FUNCTION ( elphel_framepars_get_raw   ) 

wait for absolute frame number (includes those that are not compressed)

Parameters:
index - frame index (0..7). -1 - return func2call page instead, -2 - globalPars
Returns:
NULL - error, otherwise a string with (struct framepars_t)

use gamma_cache_index to retrieve table from cache

Definition at line 461 of file elphel_php.c.

References ELPHEL_G, framePars, funcs2call, globalPars, memcpy(), and PARS_FRAMES_MASK.

PHP_FUNCTION ( elphel_wait_frame_abs   ) 

skip some frames (includes those that are not compressed) - will work even if no frames are compressed

Out of limit for skip frames

Definition at line 307 of file elphel_php.c.

References ELPHEL_G, fd_fparmsall, LSEEK_FRAME_WAIT_ABS, and SEEK_END.

PHP_FUNCTION ( elphel_skip_frames   ) 

current absolute frame number (includes those that are not compressed)

Out of limit for skip frames

Definition at line 296 of file elphel_php.c.

References ELPHEL_G, fd_fparmsall, LSEEK_FRAME_WAIT_ABS, SEEK_CUR, and SEEK_END.

PHP_FUNCTION ( elphel_get_frame   ) 

Get current frame number.

Definition at line 291 of file elphel_php.c.

References ELPHEL_GLOBALPARS, and G_THIS_FRAME.

PHP_MINFO_FUNCTION ( elphel   ) 

Definition at line 2141 of file elphel_php.c.

References PHP_ELPHEL_VERSION.

PHP_MINIT_FUNCTION ( elphel   ) 

use gcc -save-temps to debug those macros for constants

here initialize "ELPHEL_*" constants

Definition at line 2085 of file elphel_php.c.

References DEFINE_CONST_NAMES, DEFINE_LSEEK_NAMES, DEFINE_ONCHANGE_NAMES, DEFINE_P_NAMES, name, php_elphel_init_globals(), and value.

PHP_MSHUTDOWN_FUNCTION ( elphel   ) 

Definition at line 2128 of file elphel_php.c.

References ELPHEL_G, fd_circ, fd_exif, fd_exifdir, fd_exifmeta, fd_fparmsall, fd_gamma_cache, and fd_histogram_cache.

PHP_RINIT_FUNCTION ( elphel   ) 

Definition at line 2078 of file elphel_php.c.

int splitConstantName ( char *  name  ) 

See if the name ands with number, truncate name to remove number and return number value.

Parameters:
name constant name, possibly ending with a number (decimal) if constant includes "__" (double "_") and has 4 decimals after __WWBB, those decimals are treated as bit field specs (WW 1..31 - width, BB - 0..31 - start bit ), i.e. "__0816" is the 3-rd byte of 4 in the 32-bit parameter These bit-filed modifiers are stored in bits 16..20 (bit) and 21..25 (width) of parameter address (number)
Returns:
number value (to be added to the constant value) or -1 if name does not end with a number

terminate name with ''

Definition at line 262 of file elphel_php.c.

References d, and FRAMEPAIR_FRAME_BITS.

Referenced by PHP_FUNCTION().


Variable Documentation

unsigned long* ccam_dma_buf

Definition at line 25 of file elphel_php.h.

unsigned long ccam_dma_buf_len

Definition at line 26 of file elphel_php.h.

Referenced by PHP_FUNCTION().

zend_module_entry elphel_module_entry

Definition at line 223 of file elphel_php.c.

struct exif_dir_table_t exif_dir[ExifKmlNumber]

Definition at line 20 of file elphel_php.h.

Referenced by createExifDirectory(), PHP_FUNCTION(), and printExifXML().

int exif_size

Definition at line 19 of file elphel_php.h.

Referenced by createExifDirectory().

int fd_circ

(circbuf.c) access to /dev/circbuf (mmap, lseek)

Definition at line 24 of file elphel_php.h.

Referenced by listener_loop(), PHP_FUNCTION(), and PHP_MSHUTDOWN_FUNCTION().

int fd_exif

Definition at line 16 of file elphel_php.h.

Referenced by main(), PHP_FUNCTION(), PHP_MSHUTDOWN_FUNCTION(), and sendImage().

int fd_exifdir

Definition at line 17 of file elphel_php.h.

Referenced by createExifDirectory(), PHP_FUNCTION(), PHP_MSHUTDOWN_FUNCTION(), and printExifXML().

int fd_exifmeta

Definition at line 18 of file elphel_php.h.

Referenced by PHP_FUNCTION(), and PHP_MSHUTDOWN_FUNCTION().

int fd_fparmsall

Global variables.

*************************************************************************** ! FILE NAME : globalsinit.c ! DESCRIPTION: Opens files, mmap-s data structures, initializes variables ! For the autoexposure daemon ! Copyright (C) 2008 Elphel, Inc. ! -----------------------------------------------------------------------------** ! This program is free software: you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation, either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. ! -----------------------------------------------------------------------------** ! !

Log
globalsinit.c,v
! Revision 1.1.1.1 2008/11/27 20:04:01 elphel ! ! ! Revision 1.2 2008/11/18 19:30:16 elphel ! Added initialization of the "next" frame - otherwise it wait _very_ long if the camera frame number is reset ! ! Revision 1.1 2008/11/15 23:08:24 elphel ! 8.0.alpha17 - split autoexposure source file ! !

Definition at line 31 of file elphel_php.h.

int fd_gamma_cache

(gamma_tables.c) access to gammas

Definition at line 42 of file elphel_php.h.

int fd_histogram_cache

array of gamma structures

Definition at line 47 of file elphel_php.h.

struct framepars_t* framePars

Definition at line 33 of file elphel_php.h.

struct framepars_all_t* frameParsAll

Definition at line 32 of file elphel_php.h.

unsigned long* funcs2call

Definition at line 35 of file elphel_php.h.

Referenced by init_framepars_ptr(), initFramePars(), PHP_FUNCTION(), setFramePar(), setFramePars(), and setFrameParsAtomic().

struct gamma_stuct_t* gamma_cache

gamma cache is needed to re-linearize the data

array of histograms

Definition at line 43 of file elphel_php.h.

unsigned long* globalPars

each parameter has a 32-bit mask of what pgm_function to call - other fields not used

Definition at line 36 of file elphel_php.h.

struct histogram_stuct_t* histogram_cache

Definition at line 48 of file elphel_php.h.

struct framepars_past_t* pastPars

Definition at line 34 of file elphel_php.h.


Generated on Fri Nov 28 00:07:08 2008 for elphel by  doxygen 1.5.1