os/linux-2.6-tag--devboard-R2_10-4/arch/cris/arch-v32/drivers/elphel/framepars.c File Reference

#include <linux/types.h>
#include <asm/div64.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/autoconf.h>
#include <linux/vmalloc.h>
#include <asm/system.h>
#include <asm/byteorder.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/delay.h>
#include <asm/uaccess.h>
#include <asm/elphel/driver_numbers.h>
#include <asm/elphel/c313a.h>
#include <asm/elphel/exifa.h>
#include "fpgactrl.h"
#include "x3x3.h"
#include "sensor_common.h"
#include "framepars.h"
#include "param_depend.h"
#include "cxdma.h"

Include dependency graph for framepars.c:

Go to the source code of this file.

Data Structures

struct  framepars_pd
 used to wait for the frame to be acquired file private data More...

Defines

#define MDF(x)
#define MDF2(x)
#define MDF5(x)
#define D5(x)
#define MDF6(x)
#define D6(x)
#define MDF7(x)
#define D7(x)
#define ELPHEL_DEBUG_THIS   0
#define MDD1(x)
#define MDF1(x)
#define D1(x)
#define D1I(x)   x
#define X3X3_FRAMEPARS_DRIVER_NAME   "Elphel (R) Model 353 Frame Parameters device driver"
#define thisFrameNumber   GLOBALPARS(G_THIS_FRAME)
 set to 0 at startup, 1 after initialization that is triggered by setParsAtomic()
#define THISFRAMENUMBER   GLOBALPARS(G_THIS_FRAME)

Functions

static struct framepars_all_t
sFrameParsAll 
__attribute__ ((aligned(PAGE_SIZE)))
 Sensor Parameters, currently 8 pages all and 2048 pages some, static struct.
void init_framepars_ptr (void)
 TODO: init framepars (zero parameters) before initscripts (not when detecting the sensors) - then initscript will be able to overwrite some.
int framepars_open (struct inode *inode, struct file *filp)
 Driver OPEN method.
int framepars_release (struct inode *inode, struct file *filp)
 Driver RELEASE method.
loff_t framepars_lseek (struct file *file, loff_t offset, int orig)
 Driver LSEEK method (and execute commands)
  • lseek (SEEK_SET, value) - set absolute frame number
  • lseek (SEEK_CUR, value) - set frame number relative to the current frame number (thisFrameNumber),
  • lseek (SEEK_CUR, 0) - (used by ftell()) DOES NOT modify file pointer, returns thisFrameNumber,
  • lseek (SEEK_END, value <= 0) - do nothing?, do not modify file pointer
  • lseek (SEEK_END, value > 0) - execute commands, do not modify file pointer (and actually use it - frame number the command applies to)
  • no commands yet.

ssize_t framepars_write (struct file *file, const char *buf, size_t count, loff_t *off)
 Driver WRITE method writes all at once, no provisions to continue in the next call.
int framepars_mmap (struct file *file, struct vm_area_struct *vma)
 Driver MMAP method (should be used read only) provides access to both 8-frame parameters (including future ones), frame - 0 - some static ones too and much longer retained pastparameters - subset of all parameters.
static int __init framepars_init (void)
 framepars driver init
void initSequencers (void)
 Reset hardware sequencers (i2c, command) and initialize framepars structure.
void resetFrameNumber (void)
 initialize all parameters, set thisFrameNumber to frame8 (read from hardware, usually 0 after resetting i2c and cmd_seq)
void initFramePars (void)
 resets all global parameters but debug mask (if ELPHEL_DEBUG)
void initGlobalPars (void)
 Move to sensorcommon? currently it is used through frameparsall file (lseek).
unsigned long get_imageParamsThis (int n)
 reset this frame number (called from initFramePars(), also can be used to avoid frame number integer overflow)
unsigned long get_imageParamsPrev (int n)
 reads parameters from the previous frame (matching hardware index) - used to determine if historam was needed
void set_imageParamsThis (int n, unsigned long d)
 writes read-only parameter to the current frame (does not propagate to next frames as setFramePar() does) In most cases you really need to use setFramePar() instead;
unsigned long get_globalParam (int n)
 reads global (not related to particular frames) parameters
void set_globalParam (int n, unsigned long d)
 sets global (not related to particular frames) parameters
void set_imageParamsR_all (int n, unsigned long d)
 set same parameters in all frames currently used only in compressor reset
void updateFramePars (int frame8, struct interframe_params_t *interframe_pars)
 ++++++++++++++++++++++++++++++++++++++++++ called from ISR - advance thisFrameNumber to match hardware frame8, copy parameters as needed. before: (thisFrameNumber mod8 pointed to current (for the software) parameters frame (now behind by at least 1, maybe 2) (thisFrameNumber-1) mod 8 - oldest with parameters preserved, also containes histograms results (+image timestamp, size?) subset of that frame data is copied to pastpars (thisFrameNumber-2) mod 8 - farthest in the future frame after: thisFrameNumber matches hardware pointer
void processParsASAP (struct sensorproc_t *sensorproc, int frame8)
 process parameters that are overdue or due in ASAP mode (not through the sequencer) Called twice from processPars - at the beginning and at the end to finish off any derivatives (needed?)
void processParsSeq (struct sensorproc_t *sensorproc, int frame8, int maxahead)
 Next 5 should go in that sequence.
void processPars (struct sensorproc_t *sensorproc, int frame8, int maxahead)
 Program image acquisition, according to the parameters changed Called from ISR?
void schedule_pgm_func (int frame8, int func_num)
 schedule pgm_func to be executed for selected frame
void schedule_this_pgm_func (struct framepars_t *this_framepars, int func_num)
 schedule pgm_func to be executed for the current frame
unsigned long getThisFrameNumber (void)
 just return current thisFrameNumber
int setFrameParsStatic (int numPars, struct frameparspair_t *pars)
 Set parameters that will never change (usually after sensor discovery).
int setFrameParsAtomic (unsigned long frameno, int maxLatency, int numPars, struct frameparspair_t *pars)
 TODO: Make (an "unlimited") future commands que based on lists and a tree frame index.
int setFramePar (struct framepars_t *this_framepars, unsigned long mindex, unsigned long val)
 set output/calculated parameter and propogate changes - will not trigger any actions
int setFramePars (struct framepars_t *this_framepars, int numPars, struct frameparspair_t *pars)
 same for several pars at once
 module_init (framepars_init)
 MODULE_LICENSE ("GPLv3.0")
 MODULE_AUTHOR ("Andrey Filippov <andrey@elphel.com>.")
 MODULE_DESCRIPTION (X3X3_FRAMEPARS_DRIVER_NAME)

Variables

unsigned long frameParsInitialized
framepars_all_tframeparsall = NULL
framepars_tframepars = NULL
 
  • will be mmap-ed getting rid of static to be able to use extern

framepars_past_tpastpars = NULL
 getting rid of static to be able to use extern
unsigned long * funcs2call = NULL
unsigned long * globalPars = NULL
 each parameter has a 32-bit mask of what pgm_function to call - other fields not used
wait_queue_head_t framepars_wait_queue
 parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
static struct file_operations framepars_fops


Define Documentation

#define D1 ( x   ) 

Definition at line 237 of file framepars.c.

#define D1I ( x   )     x

Definition at line 238 of file framepars.c.

#define D5 ( x   ) 

Definition at line 219 of file framepars.c.

#define D6 ( x   ) 

Definition at line 221 of file framepars.c.

#define D7 ( x   ) 

Definition at line 223 of file framepars.c.

#define ELPHEL_DEBUG_THIS   0

Definition at line 224 of file framepars.c.

#define MDD1 ( x   ) 

Definition at line 235 of file framepars.c.

#define MDF ( x   ) 

Definition at line 216 of file framepars.c.

#define MDF1 ( x   ) 

Definition at line 236 of file framepars.c.

#define MDF2 ( x   ) 

Definition at line 217 of file framepars.c.

#define MDF5 ( x   ) 

Definition at line 218 of file framepars.c.

#define MDF6 ( x   ) 

Definition at line 220 of file framepars.c.

#define MDF7 ( x   ) 

Definition at line 222 of file framepars.c.

#define THISFRAMENUMBER   GLOBALPARS(G_THIS_FRAME)

Definition at line 251 of file framepars.c.

#define thisFrameNumber   GLOBALPARS(G_THIS_FRAME)

set to 0 at startup, 1 after initialization that is triggered by setParsAtomic()

Definition at line 250 of file framepars.c.

Referenced by get_imageParamsPrev(), get_imageParamsThis(), getThisFrameNumber(), resetFrameNumber(), set_imageParamsThis(), setFramePar(), setFramePars(), setFrameParsAtomic(), tasklet_fpga_function(), and updateFramePars().

#define X3X3_FRAMEPARS_DRIVER_NAME   "Elphel (R) Model 353 Frame Parameters device driver"

Definition at line 246 of file framepars.c.

Referenced by framepars_init().


Function Documentation

static struct framepars_all_t sFrameParsAll __attribute__ ( (aligned(PAGE_SIZE))   )  [static]

Sensor Parameters, currently 8 pages all and 2048 pages some, static struct.

static int __init framepars_init ( void   )  [static]

framepars driver init

Returns:
0

sets default debug if enabled

Definition at line 1233 of file framepars.c.

References framepars_fops, FRAMEPARS_MAJOR, framepars_wait_queue, frameParsInitialized, init_framepars_ptr(), init_waitqueue_head, initGlobalPars(), KERN_ERR, printk, and X3X3_FRAMEPARS_DRIVER_NAME.

loff_t framepars_lseek ( struct file *  file,
loff_t  offset,
int  orig 
)

Driver LSEEK method (and execute commands)

Parameters:
file 
offset 
orig SEEK_SET, SEEK_CUR or SEEK_SET END
Returns:
file position (absolute frame number)

do not modify frame number

modifies frame number, but it is better to use absolute SEEK SET

Wait for absolute frame number

Skip 0..255 frames

Does not modify current frame pointer? lseek (,0,SEEK_CUR) anyway returns getThisFrameNumber()

Other lseek commands

wait the daemon enabled and a new frame interrupt (sensor frame sync)

better to use write, not lseek to set FPGA time

reset hardware sequencers, init framepars structure

reset all global parameters but G_DEBUG - it is set to default level if ELPHEL_DEBUG is defined true

reset absoulte frame number to avoid integer frame number overflow

process modified parameters in frame 0 (to start sensor detection)

frame0, all 8 frames (maxAhead==8)

initialize ETRAX DMA (normally done in sensor_common.c at driver init

stop DMA

start DMA

reset compressor and buffer pointers

disable camera interrupts

enable camera interrupts

Definition at line 1049 of file framepars.c.

References camera_interrupts(), framepars, framepars_wait_queue, G_MICROSECONDS, G_SECONDS, get_imageParamsThis, getThisFrameNumber(), GLOBALPARS, initGlobalPars(), initSequencers(), LSEEK_COMPRESSOR_RESET, LSEEK_DAEMON_FRAME, LSEEK_DMA_INIT, LSEEK_DMA_START, LSEEK_DMA_STOP, LSEEK_FRAME_RESET, LSEEK_FRAME_WAIT_ABS, LSEEK_FRAME_WAIT_REL, LSEEK_FRAMEPARS_INIT, LSEEK_GET_FPGA_TIME, LSEEK_INTERRUPT_OFF, LSEEK_INTERRUPT_ON, LSEEK_SENSORPROC, LSEEK_SET_FPGA_TIME, MDF1, MDF2, P_DAEMON_EN, printk, processPars(), reset_compressor(), resetFrameNumber(), SEEK_CUR, SEEK_END, SEEK_SET, sensorproc, x313_dma_init(), x313_dma_start(), x313_dma_stop(), X313_GET_FPGA_TIME, and X313_SET_FPGA_TIME.

int framepars_mmap ( struct file *  file,
struct vm_area_struct *  vma 
)

Driver MMAP method (should be used read only) provides access to both 8-frame parameters (including future ones), frame - 0 - some static ones too and much longer retained pastparameters - subset of all parameters.

Parameters:
file 
vma 
Returns:
OK - 0, negative - errors

Definition at line 1211 of file framepars.c.

References CMOSCAM_MINOR_FRAMEPARS, frameparsall, MDF1, framepars_pd::minor, and printk.

int framepars_open ( struct inode *  inode,
struct file *  filp 
)

Driver OPEN method.

Parameters:
inode inode
filp file pointer
Returns:
OK - 0, -EINVAL for wrong minor

Definition at line 997 of file framepars.c.

References CMOSCAM_MINOR_FRAMEPARS, GFP_KERNEL, kfree, kmalloc, MDF1, framepars_pd::minor, and printk.

int framepars_release ( struct inode *  inode,
struct file *  filp 
)

Driver RELEASE method.

Parameters:
inode inode
filp file pointer
Returns:
OK - 0, -EINVAL for wrong minor

do not need to free anything - "wrong number"

Definition at line 1022 of file framepars.c.

References CMOSCAM_MINOR_FRAMEPARS, kfree, MDF1, and printk.

ssize_t framepars_write ( struct file *  file,
const char *  buf,
size_t  count,
loff_t *  off 
)

Driver WRITE method writes all at once, no provisions to continue in the next call.

Parameters:
file 
buf 
count 
off 
Returns:
OK - number of bytes written, negative - errors

will be sufficient for most calls

************* NOTE: Never use file->f_pos in write() and read() !!!

sizeof (struct frameparspair_t)==8

only allocate if static is not enough

divide by sizeof(struct frameparspair_t); // 8

ignore value (should be already set in G_SECONDS, G_MICROSECONDS frame0)

ignore value, set frame 0 G_SECONDS, G_MICROSECONDS to FPGA registers

*sizeof(struct frameparspair_t);

Definition at line 1141 of file framepars.c.

References CMOSCAM_MINOR_FRAMEPARS, frame, FRAMEPARS_GETFPGATIME, FRAMEPARS_SETFPGATIME, FRAMEPARS_SETFRAME, FRAMEPARS_SETFRAMEREL, FRAMEPARS_SETLATENCY, G_MICROSECONDS, G_SECONDS, getThisFrameNumber(), GFP_KERNEL, GLOBALPARS, kfree, kmalloc, latency, MDF1, framepars_pd::minor, num, printk, setFrameParsAtomic(), frameparspair_t::val, X313_GET_FPGA_TIME, and X313_SET_FPGA_TIME.

unsigned long get_globalParam ( int  n  )  [inline]

reads global (not related to particular frames) parameters

Parameters:
n number of a parameter to read (numbers start from FRAMEPAR_GLOBALS)
Returns:
parameter value (unsigned long)

Definition at line 370 of file framepars.c.

References GLOBALPARS.

Referenced by camSeqSetJPEG_rp(), setFrameParsAtomic(), tasklet_fpga_function(), updateFramePars(), updateIRQ_Exif(), updateIRQ_interframe(), updateIRQCircbuf(), and updateIRQJPEG_wp().

unsigned long get_imageParamsPrev ( int  n  )  [inline]

reads parameters from the previous frame (matching hardware index) - used to determine if historam was needed

Parameters:
n number of a parameter to read
Returns:
parameter value (unsigned long)

Definition at line 350 of file framepars.c.

References framepars, PARS_FRAMES_MASK, and thisFrameNumber.

Referenced by tasklet_fpga_function().

unsigned long get_imageParamsThis ( int  n  )  [inline]

reset this frame number (called from initFramePars(), also can be used to avoid frame number integer overflow)

Parameters:
n number of a parameter to read
Returns:
parameter value (unsigned long)

Definition at line 341 of file framepars.c.

References framepars, framepars_t::pars, PARS_FRAMES_MASK, and thisFrameNumber.

unsigned long getThisFrameNumber ( void   ) 

just return current thisFrameNumber

Returns:
current value of thisFrameNumber

Definition at line 672 of file framepars.c.

References thisFrameNumber.

Referenced by framepars_lseek(), framepars_write(), histograms_lseek(), pgm_gamma(), pgm_gammaload(), stream__ioctl(), stream__release(), and tasklet_fpga_function().

void init_framepars_ptr ( void   ) 

TODO: init framepars (zero parameters) before initscripts (not when detecting the sensors) - then initscript will be able to overwrite some.

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

parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both

Definition at line 276 of file framepars.c.

References framepars, framepars_all_t::framePars, frameparsall, framepars_all_t::func2call, funcs2call, globalPars, framepars_all_t::globalPars, framepars_t::pars, pastpars, and framepars_all_t::pastPars.

Referenced by framepars_init().

void initFramePars ( void   ) 

resets all global parameters but debug mask (if ELPHEL_DEBUG)

initialize frameParsDeps.pars masks:

by default each "manual" write to any of 256 registers will trigger pgm_sensorreg function

Definition at line 317 of file framepars.c.

References framepars, frameParsInitialized, funcs2call, memset(), ONCHANGE_SENSORREGS, P_SENSOR_NUMREGS, P_SENSOR_REGS, param_depend_tab, and resetFrameNumber().

Referenced by initSequencers().

void initGlobalPars ( void   ) 

Move to sensorcommon? currently it is used through frameparsall file (lseek).

Definition at line 330 of file framepars.c.

References ELPHEL_DEBUG_STARTUP, G_DEBUG, globalPars, GLOBALPARS, MDF, memset(), and printk.

Referenced by framepars_init(), and framepars_lseek().

void initSequencers ( void   ) 

Reset hardware sequencers (i2c, command) and initialize framepars structure.

Definition at line 294 of file framepars.c.

References initFramePars(), MDF2, printk, X3X3_I2C_RESET_WAIT, and X3X3_SEQ_RESET.

Referenced by framepars_lseek(), and setFrameParsAtomic().

MODULE_AUTHOR ( "Andrey Filippov <andrey@elphel.com>."   ) 

MODULE_DESCRIPTION ( X3X3_FRAMEPARS_DRIVER_NAME   ) 

module_init ( framepars_init   ) 

MODULE_LICENSE ( "GPLv3.0"   ) 

void processPars ( struct sensorproc_t sensorproc,
int  frame8,
int  maxahead 
)

Program image acquisition, according to the parameters changed Called from ISR?

Parameters:
sensorproc pointer to sensor static parameters and functions
frame8 current hardware frame number
maxahead maximal number of frames to program ahead of the current (make it P_* parameter ?)
Returns:
always 0 ?

first - do all ASAP tasks (they should not be done ahead of the corresponding interrupt!)

now - the rest commands that use FPGA queues for the i2c/sequencer commands, executed at frame syncs for jobahead =0 it is still possible to have some functions in ASAP mode with non-zero latency

re-test ASAP tasks - they might appear as a result of other commands executed

Definition at line 632 of file framepars.c.

References PARS_FRAMES_MASK, processParsASAP(), processParsSeq(), and sensorproc.

Referenced by framepars_lseek(), and setFrameParsAtomic().

void processParsASAP ( struct sensorproc_t sensorproc,
int  frame8 
) [inline]

process parameters that are overdue or due in ASAP mode (not through the sequencer) Called twice from processPars - at the beginning and at the end to finish off any derivatives (needed?)

Parameters:
sensorproc 
frame8 

considering parameter "pars_ahead" of the (frame8+job_ahead) mod 8

current frame for which parameters are considered

maybe - drop calculation for each function, move it to pgm_* where needed?

do all ASAP tasks (they should not be done ahead of the corresponding interrupt!) Now try overdue functions with latencies >=1 and try them in ASAP mode

none, *1, *2,*3,*4

skip zeros - todo will stay current (.functions will not change

now (todo & mask) !=0

only sensor-specific function, nothing to do common to all sensors

sensor - specific functions, called after the main ones

Nothing to do with errors here - just report?

Definition at line 489 of file framepars.c.

References framepars, framepars_t::functions, G_CALLNASAP, GLOBALPARS, mask, MDF6, PARS_FRAMES_MASK, sensorproc_t::pgm_func, printk, sensorproc_t::sensor, and sensorproc.

Referenced by processPars().

void processParsSeq ( struct sensorproc_t sensorproc,
int  frame8,
int  maxahead 
) [inline]

Next 5 should go in that sequence.

doing job "job_ahead" ahead of needed

considering parameter "pars_ahead" of the (frame8+job_ahead) mod 8

current frame for which parameters are considered

maybe - drop calculation fpr each function, move it to pgm_* where needed?

sequencer frame for which pgm_* function should schedule data

use 5 if maxahead >5

commands that use FPGA queues for the i2c/sequencer commands, executed at frame syncs Modifying - as soon as found the frame to process with non-zero masked .functions - process all functions for that frame with appropriate sequencer frame. For now - scan p_nasap[i] to find latency - improve that later

Check if at least one function is needed for frame_proc

all, *1, *2,*3,*4 - for all will have G_CALLNASAP twice

p_nasap[pars_ahead] & ///all, *1, *2,*3,*4 - for all will have G_CALLNASAP twice

eliminate ASAP-only function

skip zeros - todo will stay current (.functions will not change)

now (todo & mask) !=0 find the right latency

this_ahead==1..5

NOTE: Was (frame8+job_ahead +1) & PARS_FRAMES_MASK

only sensor-specific function, nothing to do common to all sensors

sensor - specific functions, called after the main ones

mark it done

Definition at line 551 of file framepars.c.

References framepars, framepars_t::functions, G_CALLNASAP, GLOBALPARS, mask, MDF6, min, PARS_FRAMES, PARS_FRAMES_MASK, sensorproc_t::pgm_func, printk, sensorproc_t::sensor, and sensorproc.

Referenced by processPars().

void resetFrameNumber ( void   ) 

initialize all parameters, set thisFrameNumber to frame8 (read from hardware, usually 0 after resetting i2c and cmd_seq)

initialize frameParsDeps.pars masks:

Definition at line 305 of file framepars.c.

References framepars, MDF2, P_FRAME, PARS_FRAMES, PARS_FRAMES_MASK, printk, thisFrameNumber, and X3X3_I2C_FRAME.

Referenced by framepars_lseek(), and initFramePars().

void schedule_pgm_func ( int  frame8,
int  func_num 
)

schedule pgm_func to be executed for selected frame

Parameters:
frame8 frame number (3-bit) to schedule a function for
func_num function number to schedule

Definition at line 651 of file framepars.c.

References framepars, framepars_t::functions, MDF1, PARS_FRAMES_MASK, and printk.

void schedule_this_pgm_func ( struct framepars_t this_framepars,
int  func_num 
)

schedule pgm_func to be executed for the current frame

Parameters:
this_framepars pointer to frame parameters structure
func_num number of function to schedule

Definition at line 661 of file framepars.c.

References framepars, framepars_t::functions, MDF1, P_FRAME, framepars_t::pars, PARS_FRAMES_MASK, and printk.

Referenced by pgm_sensorphase().

void set_globalParam ( int  n,
unsigned long  d 
) [inline]

sets global (not related to particular frames) parameters

Parameters:
n number of a parameter to set (numbers start from FRAMEPAR_GLOBALS)
d data to write to the selected parameter

Definition at line 379 of file framepars.c.

References GLOBALPARS.

Referenced by camSeqSetJPEG_rp(), updateIRQ_interframe(), updateIRQCircbuf(), updateIRQFocus(), updateIRQJPEG_wp(), and x313_setDMABuffer().

void set_imageParamsR_all ( int  n,
unsigned long  d 
) [inline]

set same parameters in all frames currently used only in compressor reset

Parameters:
n number of a parameter to set
d data to write to the selected parameter

Definition at line 389 of file framepars.c.

References framepars, and PARS_FRAMES.

Referenced by reset_compressor().

void set_imageParamsThis ( int  n,
unsigned long  d 
) [inline]

writes read-only parameter to the current frame (does not propagate to next frames as setFramePar() does) In most cases you really need to use setFramePar() instead;

Parameters:
n number of a parameter to set
d data to write to the selected parameter

Definition at line 361 of file framepars.c.

References framepars, framepars_t::pars, PARS_FRAMES_MASK, and thisFrameNumber.

Referenced by updateIRQFocus().

int setFramePar ( struct framepars_t this_framepars,
unsigned long  mindex,
unsigned long  val 
)

set output/calculated parameter and propogate changes - will not trigger any actions

Parameters:
this_framepars pointer to the current parameters structure
mindex parameter number (with optional modifiers in high bits)
val parameter value to set
Returns:
0 - OK, -ERR_FRAMEPARS_BADINDEX

ignore frame logic, set "static" parameters to frame 0

combine new value with the old one

write to func_proc[] instead

do not write "JUST_THIS" parameters in the future otherwise they'll stick

combine new value with the old one

Set this parameter for specified frame, (for now - unconditionally mark as modified, even if the value is the same as it was - CHANGED!

Mark which functions will be needed to process the parameters

Write parameter to the next frames up to the one that have the same parameter already modified

for " regular parameters "modified since" do not include the target frame itself, for "JUST_THIS" - does

Mark this parameter in all previous frames as "modified since" TODO: consider alternative way - first iterate through all parameters, build masks, then apply them

NOTE: frame8 is modified here

error - trying to write "just this" to the "future" - that would stick if allowed

Definition at line 814 of file framepars.c.

References D1I, ELP_KERR, ERR_FRAMEPARS_BADINDEX, ERR_FRAMEPARS_TOOEARLY, flags, FRAMEPAIR_FORCE_NEW, FRAMEPAIR_FORCE_PROC, FRAMEPAIR_FRAME_FUNC, FRAMEPAIR_FRAME_MASK_NEW, FRAMEPAIR_JUST_THIS, FRAMEPAIR_MASK_BYTES, FRAMEPAR_GLOBALS, framepars, funcs2call, framepars_t::functions, GLOBALPARS, local_irq_restore, local_irq_save, framepars_t::mod, framepars_t::mod32, framepars_t::modsince, framepars_t::modsince32, P_FRAME, P_MAX_GPAR, P_MAX_PAR, framepars_t::pars, PARS_FRAMES_MASK, printk, and thisFrameNumber.

Referenced by histograms_lseek(), mt9x001_pgm_detectsensor(), mt9x001_pgm_triggermode(), pgm_detectsensor(), pgm_memsensor(), stream__ioctl(), and stream__release().

int setFramePars ( struct framepars_t this_framepars,
int  numPars,
struct frameparspair_t pars 
)

same for several pars at once

Parameters:
this_framepars pointer to the current parameters structure
numPars number of parameters to set
pars array of parameters (number/value pairs). Parameter numbers accept modifiers
Returns:
0 - OK, -ERR_FRAMEPARS_BADINDEX

ignore frame logic, set "static" parameters to frame 0

combine new value with the old one

do not write "JUST_THIS" parameters in the future otherwise they'll stick

combine new value with the old one

Set this parameter for specified frame, (for now - unconditionally mark as modified, even if the value is the same as it was - CHANGED!

Mark which functions will be needed to process the parameters

Write parameter to the next frames up to the one that have the same parameter already modified (only if not FRAMEPAIR_JUST_THIS)

for " regular parameters "modified since" do not include the target frame itself, for "JUST_THIS" - does

Mark this parameter in all previous frames as "modified since" TODO: consider alternative way - first iterate through all parameters, build masks, then apply them

NOTE: frame8 is modified here

error - trying to write "just this" to the "future" - that would stick if allowed

Definition at line 895 of file framepars.c.

References D1I, ELP_KERR, ERR_FRAMEPARS_BADINDEX, ERR_FRAMEPARS_TOOEARLY, flags, FRAMEPAIR_FORCE_NEW, FRAMEPAIR_FORCE_PROC, FRAMEPAIR_FRAME_FUNC, FRAMEPAIR_FRAME_MASK_NEW, FRAMEPAIR_JUST_THIS, FRAMEPAIR_MASK_BYTES, FRAMEPAR_GLOBALS, framepars, funcs2call, framepars_t::functions, GLOBALPARS, local_irq_restore, local_irq_save, framepars_t::mod, framepars_t::mod32, framepars_t::modsince, framepars_t::modsince32, num, P_FRAME, P_MAX_GPAR, P_MAX_PAR, framepars_t::pars, PARS_FRAMES_MASK, printk, and thisFrameNumber.

Referenced by mt9x001_pgm_gains(), mt9x001_pgm_initsensor(), mt9x001_pgm_limitfps(), mt9x001_pgm_window_common(), pgm_afterinit(), pgm_compmode(), pgm_focusmode(), pgm_gammaload(), pgm_hist(), pgm_memcompressor(), pgm_sensorphase(), and pgm_window_common().

int setFrameParsAtomic ( unsigned long  frameno,
int  maxLatency,
int  numPars,
struct frameparspair_t pars 
)

TODO: Make (an "unlimited") future commands que based on lists and a tree frame index.

Parameters:
frameno absolute (full) frame number parameters should be applied to
maxLatency maximal command latency (parameters should be set not less than maxLatency ahead of the current frame) maxLatency < 0 - don't check latency (i.e.only commands that are not releted to particular frames)
numPars number of parameters to set (0 is OK to just test if it is too early/too late)
pars array of parameters (number/value pairs). FRAMEPAIR_FORCE_NEW modifier to parameter number
Returns:
0 - OK, -ERR_FRAMEPARS_TOOEARLY, -ERR_FRAMEPARS_TOOLATE

Will call initFramePars(); and initialize functions

actually - fartherst in the future??

not too late, not too early, go ahead

ignore frame logic, set "static" parameters to frame 0

combine new value with the old one

do not write "JUST_THIS" parameters in the future otherwise they'll stick

combine new value with the old one

Set this parameter for specified frame

Mark which functions will be needed to process the parameters

Write parameter to the next frames up to the one that have the same parameter already modified (only if not FRAMEPAIR_JUST_THIS)

for " regular parameters "modified since" do not include the target frame itself, for "JUST_THIS" - does

Mark this parameter in all previous frames as "modified since" TODO: consider alternative way - first iterate through all parameters, build masks, then apply them

NOTE: frame8 is modified here

error - trying to write "just this" to the "future" - that would stick if allowed

Try to process parameters immediately after written. If 0, only non-ASAP will be processed to prevent effects of uncertainty of when was it called relative to frame sync Changed to all (don't care about uncertainty - they will trigger only if it is too late or during sensor detection/initialization)

maxahead=0, the rest will be processed after frame sync, from the tasklet

Definition at line 705 of file framepars.c.

References D1I, D5, ELP_KERR, ERR_FRAMEPARS_BADINDEX, ERR_FRAMEPARS_TOOEARLY, ERR_FRAMEPARS_TOOLATE, flags, FRAMEPAIR_FORCE_NEW, FRAMEPAIR_FRAME_FUNC, FRAMEPAIR_FRAME_MASK_NEW, FRAMEPAIR_JUST_THIS, FRAMEPAIR_MASK_BYTES, FRAMEPAR_GLOBALS, framepars, frameParsInitialized, funcs2call, framepars_t::functions, G_TASKLET_CTL, get_globalParam(), GLOBALPARS, initSequencers(), local_irq_restore, local_irq_save, MDF2, MDF5, framepars_t::mod, framepars_t::mod32, framepars_t::modsince, framepars_t::modsince32, num, P_MAX_GPAR, P_MAX_PAR, framepars_t::pars, PARS_FRAMES, PARS_FRAMES_MASK, printk, processPars(), PROFILE_NOW, sensorproc, TASKLET_CTL_NOSAME, and thisFrameNumber.

Referenced by framepars_write().

int setFrameParsStatic ( int  numPars,
struct frameparspair_t pars 
)

Set parameters that will never change (usually after sensor discovery).

Parameters:
numPars number of parameters to set
pars array of parameters (number/value pairs)
Returns:
always 0

Definition at line 683 of file framepars.c.

References ERR_FRAMEPARS_BADINDEX, framepars, num, P_MAX_PAR, framepars_t::pars, and PARS_FRAMES.

void updateFramePars ( int  frame8,
struct interframe_params_t interframe_pars 
)

++++++++++++++++++++++++++++++++++++++++++ called from ISR - advance thisFrameNumber to match hardware frame8, copy parameters as needed. before: (thisFrameNumber mod8 pointed to current (for the software) parameters frame (now behind by at least 1, maybe 2) (thisFrameNumber-1) mod 8 - oldest with parameters preserved, also containes histograms results (+image timestamp, size?) subset of that frame data is copied to pastpars (thisFrameNumber-2) mod 8 - farthest in the future frame after: thisFrameNumber matches hardware pointer

Parameters:
interframe_pars pointer to structure (between frames in the frame buffer) to save a pointer to past parameters pass NULL if compressor was off (or no time to copy?)

before update: framepars[findex_prev] holds previous frame data (oldest availble) framepars[findex_future] holds fartherst in the future one after update: framepars[findex_prev] holds fartherst in the future one ("this" will become "prev")

copy subset of the parameters to the long buffer of past parameters. TODO: fill Exif also here? TODO:DONE: Change - make pastpars be save for all frames, not just compressed ones With PASTPARS_SAVE_ENTRIES being multiple of PARS_FRAMES - make it possible to calculate past_index from thisFrameNumber

copying from what was past frame that might include histogram data

Now update interframe_pars (interframe area) used to create JPEG headers. Interframe area survives exactly as long as the frames themselves (not like pastpars)

frame was compressed, not just vsync

TODO: get rid of *_prev, use it for the future.

will leave some gaps, but copy [P_ACTUAL_WIDTH]

NOTE: P_ACTUAL_WIDTH,P_QUALITY copied with memcpy

copy parameters from findex_future (old "fartherst in the future") to findex_prev (new "fartherst in the future") if it was changed since

mark as not "modified since" (yet)

mark as not "modified since" super index

clear "modified" and flags on the brand new future frame

.mod[0]-.mod[30], .mod32

No functions yet needed on the brand new frame

that will be the full frame number

NOTE: Handle past due - copy functions, and mod if functions were non-zero

Some functions were not yet processed (past due)

Definition at line 405 of file framepars.c.

References framepars, framepars_t::functions, G_TASKLET_CTL, get_globalParam(), MDF, MDF7, memcpy(), memset(), framepars_t::mod32, framepars_t::modsince, framepars_t::modsince32, P_ACTUAL_HEIGHT, P_COLOR, P_COMPMOD_BYRSH, P_FRAME, P_GTAB_R, framepars_t::pars, PARS_FRAMES_MASK, PARS_SAVE_COPY, PARS_SAVE_FROM, pastpars, PASTPARS_SAVE_ENTRIES_MASK, printk, TASKLET_CTL_IGNPAST, and thisFrameNumber.

Referenced by elphel_FPGA_interrupt().


Variable Documentation

struct framepars_t* framepars = NULL

Definition at line 254 of file framepars.c.

Referenced by framepars_lseek(), get_imageParamsPrev(), get_imageParamsThis(), histograms_lseek(), init_framepars_ptr(), initFramePars(), pgm_gammaload(), processParsASAP(), processParsSeq(), reset_compressor(), resetFrameNumber(), schedule_pgm_func(), schedule_this_pgm_func(), set_imageParamsR_all(), set_imageParamsThis(), setFramePar(), setFramePars(), setFrameParsAtomic(), setFrameParsStatic(), stream__ioctl(), stream__release(), tasklet_fpga_function(), and updateFramePars().

struct file_operations framepars_fops [static]

Initial value:

TODO: make some parameters readonly (prohibited from modification from the userland) File operations: open, release - nop read - none write -> setFrameParsAtomic (first 4 bytes - absolute frame number, next 4 bytes - latency, then each 8 bytes - index/value) can use current file pointer or special indexes (0x****ff01 - set frame number, 0x****ff02 - set latency) that should come before actual parameters file pointer - absolute frame number lseek (SEEK_SET, value) - set absolute frame number lseek (SEEK_CUR, value) - set frame number relative to the current frame number (thisFrameNumber), lseek (SEEK_CUR, 0) - (used by ftell()) also modifies file pointer - set it to thisFrameNumber, lseek (SEEK_END, value <= 0) - do nothing?, do not modify file pointer lseek (SEEK_END, value > 0) - execute commands, do not modify file pointer (and actually use it - frame number the command applies to) mmap (should be used read only)

Definition at line 982 of file framepars.c.

Referenced by framepars_init().

wait_queue_head_t framepars_wait_queue

parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both

Definition at line 259 of file framepars.c.

Referenced by elphel_FPGA_interrupt(), framepars_init(), and framepars_lseek().

struct framepars_all_t* frameparsall = NULL

Definition at line 253 of file framepars.c.

Referenced by framepars_mmap(), and init_framepars_ptr().

unsigned long frameParsInitialized

Definition at line 249 of file framepars.c.

Referenced by framepars_init(), initFramePars(), and setFrameParsAtomic().

unsigned long* funcs2call = NULL

Definition at line 256 of file framepars.c.

unsigned long* globalPars = NULL

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

Definition at line 257 of file framepars.c.

struct framepars_past_t* pastpars = NULL

getting rid of static to be able to use extern

Definition at line 255 of file framepars.c.

Referenced by createDefaultConfig(), init_framepars_ptr(), and updateFramePars().


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