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

#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <asm/byteorder.h>
#include <errno.h>
#include "php.h"
#include "php_ini.h"
#include "elphel_php.h"

Include dependency graph for elphel_php.c:

Go to the source code of this file.

Defines

#define saferead255(f, d, l)   read(f,d,((l)<256)?(l):255)

Functions

static void init_sens ()
 call before any access to sensor parameters/functions
int splitConstantName (char *name)
 See if the name ands with number, truncate name to remove number and return number value.
 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_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_get_state)
 PHP_FUNCTION (elphel_framepars_get_raw)
 wait for absolute frame number (includes those that are not compressed)
 PHP_FUNCTION (elphel_get_P_arr)
long elphel_set_P_value_common (long addr, long data, long frame, long flags)
 common part of elphel_set_P_value() and elphel_compressor_*()
 PHP_FUNCTION (elphel_set_P_value)
 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_P_arr)
int gamma_calc (double gamma, double black, unsigned short *gtable)
 Calculate gamma table (as array of 257 unsigned short values).
 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)
long createExifDirectory (int rebuild)
 =================================
 PHP_FUNCTION (elphel_get_circbuf_pointers)
 TODO: make reverse order, specify how many frames wanted. So first will be most reliable.
 PHP_FUNCTION (elphel_get_interframe_meta)
 PHP_FUNCTION (elphel_get_exif_elphel)
 PHP_FUNCTION (elphel_update_exif)
 PHP_FUNCTION (elphel_get_exif_field)
 PHP_FUNCTION (elphel_set_exif_field)
 PHP_FUNCTION (elphel_wait_frame)
 wait for the next frame to be compressed (and related parameters updated
 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.
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
 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_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_set_fpga_time)
 PHP_FUNCTION (elphel_get_fpga_time)
 Get current FPGA time as (double) seconds.
static void php_elphel_init_globals (zend_elphel_globals *elphel_globals)
 PHP_RINIT_FUNCTION (elphel)
 PHP_MINIT_FUNCTION (elphel)
 use gcc -save-temps to debug those macros for constants
 PHP_MSHUTDOWN_FUNCTION (elphel)
 PHP_MINFO_FUNCTION (elphel)

Variables

static function_entry elphel_functions []
zend_module_entry elphel_module_entry


Define Documentation

#define saferead255 ( f,
d,
 )     read(f,d,((l)<256)?(l):255)

Definition at line 1356 of file elphel_php.c.

Referenced by PHP_FUNCTION().


Function Documentation

long createExifDirectory ( int  rebuild  ) 

=================================

build directory of pointers in the Exif data for some of the (variable) fields used in the Elphel cameras

Read the size of the Exif data

Definition at line 1222 of file elphel_php.c.

References ELPHEL_G, exif_dir, Exif_GPSInfo_CompassDirection, Exif_GPSInfo_CompassDirection_Index, Exif_GPSInfo_CompassDirectionRef, Exif_GPSInfo_CompassDirectionRef_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, exif_size, ExifKmlNumber, fd_exifdir, exif_dir_table_t::ltag, memcpy(), read, and SEEK_END.

Referenced by PHP_FUNCTION().

long elphel_set_P_value_common ( long  addr,
long  data,
long  frame,
long  flags 
)

common part of elphel_set_P_value() and elphel_compressor_*()

Parameters:
addr register address (with possible flags)
data data to write
frame frame to write (<0) - use current + FRAME_DEAFAULT_AHEAD
flags additional flags (0) - none
Returns:
<0 - -errno ( error), otherwise frame used

shortcut for global parameters - directly mmaped

these globals can be written just through mmap

will accept flags both shifted and not shifted

Definition at line 598 of file elphel_php.c.

References ELPHEL_G, ELPHEL_GLOBALPARS, fd_fparmsall, FRAME_DEAFAULT_AHEAD, FRAMEPAR_GLOBALS, FRAMEPARS_SETFRAME, G_THIS_FRAME, P_MAX_GPAR, and write.

Referenced by PHP_FUNCTION().

int gamma_calc ( double  gamma,
double  black,
unsigned short *  gtable 
)

Calculate gamma table (as array of 257 unsigned short values).

Parameters:
gamma - gamma value (1.0 - linear)
black - black level, 1.0 corresponds to 256 for 8bit values
gtable - gamma array reference (allocated by the caller)
Returns:
0 - OK, <0 - error

just in case k is provided as a fraction of 256, not 1.0

Same 0.13 <= gamma <= 10.0 limits for gamma as used earlier

Definition at line 814 of file elphel_php.c.

References x.

Referenced by PHP_FUNCTION().

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 1787 of file elphel_php.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.

static void init_sens (  )  [static]

call before any access to sensor parameters/functions

Definition at line 251 of file elphel_php.c.

Referenced by PHP_FUNCTION().

static void php_elphel_init_globals ( zend_elphel_globals *  elphel_globals  )  [static]

Definition at line 1977 of file elphel_php.c.

References EXIF_DEV_NAME, EXIFDIR_DEV_NAME, EXIFMETA_DEV_NAME, GAMMA_CACHE_NUMBER, HISTOGRAM_CACHE_NUMBER, return, and SEEK_END.

Referenced by PHP_MINIT_FUNCTION().

PHP_FUNCTION ( elphel_get_fpga_time   ) 

Get current FPGA time as (double) seconds.

Definition at line 1967 of file elphel_php.c.

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.

PHP_FUNCTION ( elphel_fpga_write   ) 

Definition at line 1918 of file elphel_php.c.

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.

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.

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.

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.

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.

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.

PHP_FUNCTION ( elphel_set_exif_field   ) 

Definition at line 1600 of file elphel_php.c.

PHP_FUNCTION ( elphel_get_exif_field   ) 

Definition at line 1567 of file elphel_php.c.

PHP_FUNCTION ( elphel_update_exif   ) 

Definition at line 1562 of file elphel_php.c.

PHP_FUNCTION ( elphel_get_exif_elphel   ) 

Definition at line 1357 of file elphel_php.c.

PHP_FUNCTION ( elphel_get_interframe_meta   ) 

Definition at line 1313 of file elphel_php.c.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

PHP_FUNCTION ( elphel_compressor_frame   ) 

Acquire one frame to the buffer.

Definition at line 696 of file elphel_php.c.

PHP_FUNCTION ( elphel_compressor_stop   ) 

Stop FPGA compressor.

Definition at line 681 of file elphel_php.c.

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.

PHP_FUNCTION ( elphel_compressor_reset   ) 

compatibility with old code

Definition at line 650 of file elphel_php.c.

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.

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.

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.

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.

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.

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.

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.

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.

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.

PHP_FUNCTION ( elphel_get_frame   ) 

Get current frame number.

Definition at line 291 of file elphel_php.c.

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

function_entry elphel_functions[] [static]

*************************************************************************** ! FILE NAME : elphel_php.c ! DESCRIPTION: Implementation of elphel extension module for PHP ! Copyright (C) 2002-2007 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
elphel_php.c,v
! Revision 1.1.1.1 2008/11/27 20:04:02 elphel ! ! ! Revision 1.28 2008/11/22 05:56:40 elphel ! elphel_set_P_arr(), elphel_set_P_value() now return frame number parameters were written to ! ! Revision 1.27 2008/11/20 07:06:04 elphel ! just touched to overcome dependency (or lack of its support) to make it notice updated c313a.h ! ! Revision 1.26 2008/11/15 07:04:27 elphel ! new parameters to modify analog gains while white balancing ! ! Revision 1.25 2008/11/13 05:40:45 elphel ! 8.0.alpha16 - modified histogram storage, profiling ! ! Revision 1.24 2008/11/05 02:01:25 elphel ! Added bit field manipulation in parameters ! ! Revision 1.23 2008/11/04 17:41:43 elphel ! added elphel_gamma(), elphel_reverse_gamma(), elphel_histogram(), elphel_reverse_histogram() functions ! ! Revision 1.22 2008/11/02 07:24:20 elphel ! added support for some legacy functions ! ! Revision 1.21 2008/11/02 00:33:02 elphel ! Added TODO ! ! Revision 1.20 2008/11/01 06:25:46 elphel ! elphel_get_circbuf_pointers() now returns framenumber too ! ! Revision 1.19 2008/10/31 18:26:32 elphel ! Adding support for constants like SENSOR_REGS32 (defined constant plus 32 to simplify referencing sensor registers from PHP ! ! Revision 1.18 2008/10/29 04:18:28 elphel ! v.8.0.alpha10 made a separate structure for global parameters (not related to particular frames in a frame queue) ! ! Revision 1.17 2008/10/28 07:05:49 elphel ! touched ! ! Revision 1.16 2008/10/25 19:51:06 elphel ! Changed word order in writes to gamma tables driver ! ! Revision 1.15 2008/10/23 18:26:14 elphel ! Fixed percentile calculations in histograms ! ! Revision 1.14 2008/10/23 08:11:38 elphel ! updated for histograms wait queues ! ! Revision 1.13 2008/10/19 06:56:05 elphel ! elphel_wait_frame() now works only for compressed frames, new elphel_skip_frames() and elphel_wait_frame_abs() wait sequencer frames (all sensor frames, even those that are not compressed) ! ! Revision 1.12 2008/10/15 22:28:56 elphel ! snapshot 8.0.alpha2 ! ! Revision 1.11 2008/10/13 16:56:20 elphel ! just touched to force recompile ! ! Revision 1.10 2008/10/12 06:13:10 elphel ! snapshot ! ! Revision 1.9 2008/10/08 21:26:25 elphel ! snapsot 7.2.0.pre4 - first images (actually - second) ! ! Revision 1.8 2008/10/05 05:13:33 elphel ! snapshot003 ! ! Revision 1.7 2008/10/04 16:10:12 elphel ! snapshot ! ! Revision 1.6 2008/09/25 00:58:11 elphel ! snapshot ! ! Revision 1.5 2008/09/19 18:06:38 elphel ! snapshot ! ! Revision 1.4 2008/09/19 04:37:24 elphel ! snapshot ! ! Revision 1.3 2008/09/07 19:48:08 elphel ! snapshot ! ! Revision 1.2 2008/06/04 20:07:08 elphel ! adding support for multiple frames ! ! Revision 1.21 2008/05/02 15:12:09 elphel ! minor comment edit ! ! Revision 1.20 2008/05/01 01:32:04 elphel ! support for the frame number - combining hardware frame counter used by i2c (3-bit) and software one ! ! Revision 1.19 2008/04/25 21:31:35 elphel ! Added Exif_Photo_ExposureTime to be returned by elphel_get_exif_elphel() ! ! Revision 1.18 2008/04/24 18:16:40 elphel ! New function to retrieve circbuf structure (frame pointers and Exif pointers) ! ! Revision 1.17 2008/04/22 22:14:08 elphel ! Added functions related to Exif data ! ! Revision 1.16 2008/04/20 06:49:04 elphel ! Added histogram related functions ! ! Revision 1.15 2008/04/17 22:36:07 elphel ! Bug fix, new function added - elphel_is_compressor_idle() ! ! Revision 1.14 2008/03/20 22:25:09 elphel ! elphel_trigger - programming synchronization parameters ! ! Revision 1.13 2008/03/15 23:04:21 elphel ! added FPGA registers R/W ! ! Revision 1.12 2008/01/27 06:23:17 elphel ! New function - elphel_wait_frame (wait fro the next frame to be compressed) ! ! Revision 1.11 2008/01/12 06:53:23 elphel ! 7.1.7.2 - added elphel_autoexposure_get() function to elphel php extension ! ! Revision 1.10 2008/01/11 07:47:44 elphel ! added elphel_autoexposure_set() function ! ! Revision 1.9 2008/01/10 02:43:37 elphel ! Added balance of 2 greens in Bayer mosaic ! ! Revision 1.8 2008/01/09 10:22:02 elphel ! Implemented elphel_white_balance() function ! ! Revision 1.7 2007/12/14 22:38:53 elphel ! cleaned up after fixing cache bug ! ! Revision 1.6 2007/12/06 19:05:33 elphel ! 2 new functions - arbitrary compressor command (elphel_compressor_cmd) and elphel_compressor_reset ! ! Revision 1.5 2007/12/05 23:41:04 elphel ! Fixing minor in bugs in the sensor reset code ! ! Revision 1.4 2007/12/05 22:01:19 elphel ! added handling etrax fs mmap cach problem when communicating between PHP extension and the driver ! ! Revision 1.3 2007/12/04 06:41:11 elphel ! Implementation of 2 additional functions: elphel_get_P_arr, elphel_set_P_arr !

Definition at line 179 of file elphel_php.c.

zend_module_entry elphel_module_entry

Initial value:

 {



    PHP_ELPHEL_EXTNAME,
    elphel_functions,
    PHP_MINIT(elphel),
    PHP_MSHUTDOWN(elphel),
    PHP_RINIT(elphel),
    NULL,
    PHP_MINFO(elphel),



    STANDARD_MODULE_PROPERTIES
}

Definition at line 223 of file elphel_php.c.


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