#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) |
#define | HIST_LEN 256 * 4 * 4 |
#define | GAMMA_LEN 256 * 4 * 2 |
Functions | |
static void | init_sens () |
call before any access to sensor parameters/functions | |
PHP_FUNCTION (elphel_flush_cache) | |
long | createExifDirectory (int rebuild) |
PHP_FUNCTION (elphel_get_circbuf_pointers) | |
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 (elph_hello) | |
this function below is just for experiments | |
PHP_FUNCTION (elphel_wait_frame) | |
wait for the next frame to be compressed (and related parameters updated | |
PHP_FUNCTION (elphel_autoexposure_set) | |
Set autoexposure parameters according to the ones written. | |
PHP_FUNCTION (elphel_autoexposure_get) | |
copy window and exposure parameters to autoexp_state | |
PHP_FUNCTION (elphel_get_histogram) | |
PHP_FUNCTION (elphel_get_gamma) | |
PHP_FUNCTION (elphel_gamma) | |
PHP_FUNCTION (elphel_histogram) | |
int | calcWhiteBalance (int thrsh, int min_pixels, double diffGains[3], long use_green2) |
PHP_FUNCTION (elphel_white_balance) | |
PHP_FUNCTION (elphel_get_P_arr) | |
PHP_FUNCTION (elphel_get_P_warr) | |
Same as above, but reads _written_ parameters, not the output ones. | |
PHP_FUNCTION (elphel_set_P_arr) | |
PHP_FUNCTION (elphel_fpga_read) | |
Low-level, direct FPGA read/write. | |
PHP_FUNCTION (elphel_fpga_write) | |
PHP_FUNCTION (elphel_get_P_value) | |
PHP_FUNCTION (elphel_set_P_value) | |
Set acquisition/compression parameters. Second half (>=1024) maps to the read parameters (see above). | |
PHP_FUNCTION (elphel_get_state) | |
Get sensor state, usually 7- sensor is running, compressor is stopped, 8 - compressor is runing. | |
PHP_FUNCTION (elphel_program_sensor) | |
program sesnor/compressor according to the parameters specified. Argument==0 - restart the sensor, 1 - do it "on the fly" | |
PHP_FUNCTION (elphel_compressor_cmd) | |
Send arbitrary command to the FPGA compressor. | |
PHP_FUNCTION (elphel_compressor_reset) | |
Reset FPGA compressor (reinitialize, may need to issue twice in a row). | |
PHP_FUNCTION (elphel_compressor_run) | |
Start FPGA compressor. | |
PHP_FUNCTION (elphel_compressor_stop) | |
Stop FPGA comressor (need to wait when it is stopped). | |
PHP_FUNCTION (elphel_compressor_frame) | |
Acquire one frame to the buffer. | |
PHP_FUNCTION (elphel_is_compressor_idle) | |
return 1 if compressor is actually stopped | |
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_trigger) | |
Program trigger parameters, start/restart trigger. | |
static void | php_elphel_init_globals (zend_elphel_globals *elphel_globals) |
PHP_RINIT_FUNCTION (elphel) | |
PHP_MINIT_FUNCTION (elphel) | |
PHP_MSHUTDOWN_FUNCTION (elphel) | |
PHP_MINFO_FUNCTION (elphel) | |
Variables | |
static function_entry | elphel_functions [] |
include <asm/elphel/c313a.h> - is now in the elphel_php.h | |
zend_module_entry | elphel_module_entry |
#define GAMMA_LEN 256 * 4 * 2 |
Definition at line 561 of file elphel_php.c.
#define HIST_LEN 256 * 4 * 4 |
Definition at line 560 of file elphel_php.c.
#define saferead255 | ( | f, | |||
d, | |||||
l | ) | read(f,d,((l)<256)?(l):255) |
*********************************** WHITE BALANCE ****************************************** This function can be used for white balance. It will find percentiles ("cent" means 0x100 here) for 4 colors (both greens separate) so that the highest value of 4 will be equal to thrsh (should be less than 255). after compensation for non-linear "gamma" (for the values close to 255 it can be linearly approximated) these values can be used to directly adjust color balance - just reverse proportionally to the ratio of this result. returns 0 - OK, <0 error
copying arrays, so they will be "frozen", not updated with the new frames
continue by lowering threshold to match the minimal number of pixels
continue down, lowering thrsh until min_pixels is met.
could not satisfy min_pixels - wrong min_pixels?
continue down, looking when other colors will get the same number of pixels (smax), then linear interpolate fractions.
problem with the histogram
unapply gamma (histogram is calculated _after_ "gamma" but we need the _before_ gamma values here
OK
use_green2 | third parameter Green1/Green (index2/index1) |
Definition at line 653 of file elphel_php.c.
References ELPHEL_G, GAMMA_LEN, hist_gamma_mmap, HIST_LEN, and memcpy().
long createExifDirectory | ( | int | rebuild | ) |
Definition at line 172 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(), and read.
Referenced by PHP_FUNCTION().
static void init_sens | ( | ) | [static] |
call before any access to sensor parameters/functions
Definition at line 162 of file elphel_php.c.
References ELPHEL_G, fd_sens, imageParamsR, LSEEK_INIT_SENSOR, and P_SENSOR.
Referenced by PHP_FUNCTION().
static void php_elphel_init_globals | ( | zend_elphel_globals * | elphel_globals | ) | [static] |
Definition at line 1119 of file elphel_php.c.
References AUTOEXP_DEV_NAME, EXIF_DEV_NAME, EXIFDIR_DEV_NAME, EXIFMETA_DEV_NAME, P_NUMBER, return, and TABLES_LEN.
Referenced by PHP_MINIT_FUNCTION().
PHP_FUNCTION | ( | elphel_trigger | ) |
PHP_FUNCTION | ( | elphel_get_fpga_time | ) |
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 1085 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_reset_sensor | ) |
reset sensor, and re-initialize it
reset circbuf and DMA
reset senosr
re-initialize sensor
Definition at line 1075 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_is_compressor_idle | ) |
PHP_FUNCTION | ( | elphel_compressor_frame | ) |
PHP_FUNCTION | ( | elphel_compressor_stop | ) |
Stop FPGA comressor (need to wait when it is stopped).
Definition at line 1053 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_compressor_run | ) |
PHP_FUNCTION | ( | elphel_compressor_reset | ) |
Reset FPGA compressor (reinitialize, may need to issue twice in a row).
Definition at line 1038 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_compressor_cmd | ) |
PHP_FUNCTION | ( | elphel_program_sensor | ) |
program sesnor/compressor according to the parameters specified. Argument==0 - restart the sensor, 1 - do it "on the fly"
Definition at line 1014 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_get_state | ) |
Get sensor state, usually 7- sensor is running, compressor is stopped, 8 - compressor is runing.
Definition at line 1008 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_set_P_value | ) |
Set acquisition/compression parameters. Second half (>=1024) maps to the read parameters (see above).
Definition at line 989 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 Second half (>=1024) maps to write parameters (to be used by the camera driver)
Definition at line 975 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_fpga_write | ) |
Definition at line 950 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_fpga_read | ) |
Low-level, direct FPGA read/write.
32-bit registers, not bytes
Definition at line 929 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
Definition at line 891 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_get_P_warr | ) |
Same as above, but reads _written_ parameters, not the output ones.
Definition at line 857 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
Definition at line 828 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_white_balance | ) |
elphel_white_balance ([double thrsh [, double minfrac [, double rscale [,double bscale]]]]); needs program non_stop to apply calculated results returns 0 if OK, else - negative (error number)
R/G, B/G. G1/G
threshold (0..255) for the "brightest color"
minimal number of pixels above threshold for the brightest color (threshold will be lowered to satisfy min_pixels)
error, negative
apply color correction (if any) to the result
program the calculated values make sure that with small steps the integer values are changed by at least 1
Definition at line 769 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_histogram | ) |
Definition at line 617 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_gamma | ) |
*********************************** GAMMA ****************************************** Uses gamma table selected by first parameter (0 - R, 1 - G, 2 - GB, 3 - B) and the fraction (0..1.0) to find (and interpolate) the output value
wrong channel
copying array, so they will be "frozen", not updated with the new frames here - no need to copy...
Definition at line 596 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_get_gamma | ) |
Definition at line 578 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_get_histogram | ) |
Definition at line 566 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_autoexposure_get | ) |
PHP_FUNCTION | ( | elphel_autoexposure_set | ) |
Set autoexposure parameters according to the ones written.
Definition at line 546 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 538 of file elphel_php.c.
PHP_FUNCTION | ( | elph_hello | ) |
this function below is just for experiments
this below works
Definition at line 525 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_set_exif_field | ) |
Definition at line 493 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_get_exif_field | ) |
Definition at line 460 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_update_exif | ) |
Definition at line 455 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_get_exif_elphel | ) |
Definition at line 249 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_get_circbuf_pointers | ) |
Definition at line 219 of file elphel_php.c.
PHP_FUNCTION | ( | elphel_flush_cache | ) |
Definition at line 166 of file elphel_php.c.
PHP_MINFO_FUNCTION | ( | elphel | ) |
PHP_MINIT_FUNCTION | ( | elphel | ) |
Definition at line 1205 of file elphel_php.c.
References DEFINE_P_NAMES, and php_elphel_init_globals().
PHP_MSHUTDOWN_FUNCTION | ( | elphel | ) |
Definition at line 1222 of file elphel_php.c.
References ccam_dma_buf, ELPHEL_G, fd_autoexp, fd_circ, fd_exif, fd_exifdir, fd_exifmeta, fd_sens, hist_gamma_mmap, and imageParamsR.
PHP_RINIT_FUNCTION | ( | elphel | ) |
Definition at line 1198 of file elphel_php.c.
function_entry elphel_functions[] [static] |
include <asm/elphel/c313a.h> - is now in the elphel_php.h
*************************************************************************** ! 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/>. ! -----------------------------------------------------------------------------** !
Definition at line 96 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 134 of file elphel_php.c.