/* 393: sFrameParsAll is an array of 4per-port structures */
/* 393: sFrameParsAll is an array of 4per-port structures */
staticstructframepars_all_tsFrameParsAll[SENSOR_PORTS]__attribute__((aligned(PAGE_SIZE)));///< Sensor Parameters, currently 16 pages all and 2048 pages some, static struct
staticstructframepars_all_tsFrameParsAll[SENSOR_PORTS]__attribute__((aligned(PAGE_SIZE)));///< Sensor Parameters, currently 16 pages all and 2048 pages some, static struct
unsignedlongframeParsInitialized;/// set to 0 at startup, 1 after initialization that is triggered by setParsAtomic()
unsignedlongframeParsInitialized;// set to 0 at startup, 1 after initialization that is triggered by setParsAtomic()
#define thisFrameNumber(p) GLOBALPARS(p,G_THIS_FRAME) // Current frame number (may lag from the hardware)
#define thisFrameNumber(p) GLOBALPARS(p,G_THIS_FRAME) // Current frame number (may lag from the hardware)
#ifdef NC353
#ifdef NC353
structframepars_all_t*frameparsall=NULL;/// - will be mmap-ed
structframepars_all_t*frameparsall=NULL;// - will be mmap-ed
structframepars_t*framepars=NULL;///< getting rid of static to be able to use extern
structframepars_t*framepars=NULL;///< getting rid of static to be able to use extern
structframepars_past_t*pastpars=NULL;///< getting rid of static to be able to use extern
structframepars_past_t*pastpars=NULL;///< getting rid of static to be able to use extern
unsignedlong*funcs2call=NULL;/// sFrameParsAll.func2call.pars; - each parameter has a 32-bit mask of what pgm_function to call - other fields not used
unsignedlong*funcs2call=NULL;// sFrameParsAll.func2call.pars; - each parameter has a 32-bit mask of what pgm_function to call - other fields not used
unsignedlong*globalPars=NULL;/// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
unsignedlong*globalPars=NULL;// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
unsignedlong*multiSensIndex=NULL;/// index for per-sensor alternatives
unsignedlong*multiSensIndex=NULL;// index for per-sensor alternatives
unsignedlong*multiSensRvrsIndex=NULL;/// reverse index (to parent) for the multiSensIndex
unsignedlong*multiSensRvrsIndex=NULL;// reverse index (to parent) for the multiSensIndex
wait_queue_head_tframepars_wait_queue;/// used to wait for the frame to be acquired
wait_queue_head_tframepars_wait_queue;// used to wait for the frame to be acquired
#endif
#endif
/* 393 : Changing to per-port */
/* 393 : Changing to per-port */
structframepars_all_t*aframeparsall=NULL;/// - will be mmap-ed, in 393 points to an array of structures
structframepars_all_t*aframeparsall=NULL;// - will be mmap-ed, in 393 points to an array of structures
structframepars_t*aframepars[SENSOR_PORTS];///< getting rid of static to be able to use extern
structframepars_t*aframepars[SENSOR_PORTS];///< getting rid of static to be able to use extern
structframepars_past_t*apastpars[SENSOR_PORTS];///< getting rid of static to be able to use extern
structframepars_past_t*apastpars[SENSOR_PORTS];///< getting rid of static to be able to use extern
unsignedlong*afuncs2call[SENSOR_PORTS];/// sFrameParsAll.func2call.pars; - each parameter has a 32-bit mask of what pgm_function to call - other fields not used
unsignedlong*afuncs2call[SENSOR_PORTS];// sFrameParsAll.func2call.pars; - each parameter has a 32-bit mask of what pgm_function to call - other fields not used
unsignedlong*aglobalPars[SENSOR_PORTS];/// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
unsignedlong*aglobalPars[SENSOR_PORTS];// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
unsignedlong*amultiSensIndex[SENSOR_PORTS];/// index for per-sensor alternatives
unsignedlong*amultiSensIndex[SENSOR_PORTS];// index for per-sensor alternatives
unsignedlong*amultiSensRvrsIndex[SENSOR_PORTS];/// reverse index (to parent) for the multiSensIndex
unsignedlong*amultiSensRvrsIndex[SENSOR_PORTS];// reverse index (to parent) for the multiSensIndex
wait_queue_head_taframepars_wait_queue[SENSOR_PORTS];/// used to wait for the frame to be acquired
wait_queue_head_taframepars_wait_queue[SENSOR_PORTS];// used to wait for the frame to be acquired
afuncs2call[sensor_port]=sFrameParsAll[sensor_port].func2call.pars;/// each parameter has a 32-bit mask of what pgm_function to call - other fields not used
afuncs2call[sensor_port]=sFrameParsAll[sensor_port].func2call.pars;// each parameter has a 32-bit mask of what pgm_function to call - other fields not used
aglobalPars[sensor_port]=sFrameParsAll[sensor_port].globalPars;/// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
aglobalPars[sensor_port]=sFrameParsAll[sensor_port].globalPars;// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
amultiSensIndex[sensor_port]=sFrameParsAll[sensor_port].multiSensIndex;/// indexes of individual sensor register shadows (first of 3) - now for all parameters, not just sensor ones
amultiSensIndex[sensor_port]=sFrameParsAll[sensor_port].multiSensIndex;// indexes of individual sensor register shadows (first of 3) - now for all parameters, not just sensor ones
amultiSensRvrsIndex[sensor_port]=sFrameParsAll[sensor_port].multiSensRvrsIndex;/// reverse index (to parent) for the multiSensIndex
amultiSensRvrsIndex[sensor_port]=sFrameParsAll[sensor_port].multiSensRvrsIndex;// reverse index (to parent) for the multiSensIndex
for(i=0;i<P_SENSOR_NUMREGS;i++)afuncs2call[sensor_port][P_SENSOR_REGS+i]=ONCHANGE_SENSORREGS;/// by default each "manual" write to any of 256 registers will trigger pgm_sensorreg function
for(i=0;i<P_SENSOR_NUMREGS;i++)afuncs2call[sensor_port][P_SENSOR_REGS+i]=ONCHANGE_SENSORREGS;// by default each "manual" write to any of 256 registers will trigger pgm_sensorreg function
/// Same for 10359 registers - will not change anything if there is no 10359 - these registers will not be changed, and if will be it wil cause no action
// Same for 10359 registers - will not change anything if there is no 10359 - these registers will not be changed, and if will be it wil cause no action
for(i=0;i<P_M10359_NUMREGS;i++)afuncs2call[sensor_port][P_M10359_REGS+i]=ONCHANGE_SENSORREGS;/// by default each "manual" write to any of 256 registers will trigger pgm_sensorreg function
for(i=0;i<P_M10359_NUMREGS;i++)afuncs2call[sensor_port][P_M10359_REGS+i]=ONCHANGE_SENSORREGS;// by default each "manual" write to any of 256 registers will trigger pgm_sensorreg function
initMultiPars(sensor_port);/// initialize structures for individual per-sensor parameters. Now only works for sensor registers using G_MULTI_REGSM. Should be called after/during sensor detection
initMultiPars(sensor_port);// initialize structures for individual per-sensor parameters. Now only works for sensor registers using G_MULTI_REGSM. Should be called after/during sensor detection
@@ -328,7 +326,7 @@ int initMultiPars(int sensor_port)
...
@@ -328,7 +326,7 @@ int initMultiPars(int sensor_port)
}
}
}
}
// remark: the line below is called from initFramePars, consider removing it
// remark: the line below is called from initFramePars, consider removing it
for(i=0;i<P_SENSOR_NUMREGS;i++)afuncs2call[sensor_port][P_SENSOR_REGS+i]=ONCHANGE_SENSORREGS;/// by default each "manual" write to any of 256 registers will trigger pgm_sensorreg function
for(i=0;i<P_SENSOR_NUMREGS;i++)afuncs2call[sensor_port][P_SENSOR_REGS+i]=ONCHANGE_SENSORREGS;// by default each "manual" write to any of 256 registers will trigger pgm_sensorreg function
/// Now update interframe_pars (interframe area) used to create JPEG headers. Interframe area survives exactly as long as the frames themselves (not like pastpars)
// Now update interframe_pars (interframe area) used to create JPEG headers. Interframe area survives exactly as long as the frames themselves (not like pastpars)
if(interframe_pars){/// frame was compressed, not just vsync
if(interframe_pars){// frame was compressed, not just vsync
///TODO: get rid of *_prev, use it for the future.
//TODO: get rid of *_prev, use it for the future.
memcpy(interframe_pars,&framepars[findex_this].pars[P_GTAB_R],24);/// will leave some gaps, but copy [P_ACTUAL_WIDTH]
memcpy(interframe_pars,&framepars[findex_this].pars[P_GTAB_R],24);// will leave some gaps, but copy [P_ACTUAL_WIDTH]
interframe_pars->height=framepars[findex_this].pars[P_ACTUAL_HEIGHT];/// NOTE: P_ACTUAL_WIDTH,P_QUALITY copied with memcpy
interframe_pars->height=framepars[findex_this].pars[P_ACTUAL_HEIGHT];// NOTE: P_ACTUAL_WIDTH,P_QUALITY copied with memcpy
@@ -794,9 +792,9 @@ int setFrameParsAtomic(int sensor_port, unsigned long frameno, int maxLatency, i
...
@@ -794,9 +792,9 @@ int setFrameParsAtomic(int sensor_port, unsigned long frameno, int maxLatency, i
}elseif(pars[npar].num&FRAMEPAIR_FRAME_FUNC){
}elseif(pars[npar].num&FRAMEPAIR_FRAME_FUNC){
funcs2call[index]=val;
funcs2call[index]=val;
D5(printk(" set funcs2call[0x%x]=0x%lx\n",index,val));
D5(printk(" set funcs2call[0x%x]=0x%lx\n",index,val));
// } else if ((frameno !=findex_prev) && (frameno != findex_future)) { /// do not write parameters in the future otherwise
// } else if ((frameno !=findex_prev) && (frameno != findex_future)) { // do not write parameters in the future otherwise
}elseif((frame8!=findex_future)||((pars[npar].num&FRAMEPAIR_JUST_THIS)==0)){/// do not write "JUST_THIS" parameters in the future otherwise they'll stick
}elseif((frame8!=findex_future)||((pars[npar].num&FRAMEPAIR_JUST_THIS)==0)){// do not write "JUST_THIS" parameters in the future otherwise they'll stick
if(pars[npar].num&FRAMEPAIR_MASK_BYTES){/// combine new value with the old one
if(pars[npar].num&FRAMEPAIR_MASK_BYTES){// combine new value with the old one
// processParsSeq (sensorproc, thisFrameNumber & PARS_FRAMES_MASK, 0); ///maxahead=0, the rest will be processed after frame sync, from the tasklet
// processParsSeq (sensorproc, thisFrameNumber & PARS_FRAMES_MASK, 0); //maxahead=0, the rest will be processed after frame sync, from the tasklet
MDF5(printk("\n"));
MDF5(printk("\n"));
processPars(sensor_port,sensorproc,thisFrameNumber(sensor_port)&PARS_FRAMES_MASK,0);///maxahead=0, the rest will be processed after frame sync, from the tasklet
processPars(sensor_port,sensorproc,thisFrameNumber(sensor_port)&PARS_FRAMES_MASK,0);//maxahead=0, the rest will be processed after frame sync, from the tasklet
}
}
PROFILE_NOW(7);
PROFILE_NOW(7);
D1I(local_irq_restore(flags));
D1I(local_irq_restore(flags));
...
@@ -878,32 +876,32 @@ int setFramePar(int sensor_port, struct framepars_t * this_framepars, unsigned l
...
@@ -878,32 +876,32 @@ int setFramePar(int sensor_port, struct framepars_t * this_framepars, unsigned l
return-ERR_FRAMEPARS_BADINDEX;
return-ERR_FRAMEPARS_BADINDEX;
}
}
//TODO: optimize to use mask several parameters together
//TODO: optimize to use mask several parameters together
if(index>=FRAMEPAR_GLOBALS){/// ignore frame logic, set "static" parameters to frame 0
if(index>=FRAMEPAR_GLOBALS){// ignore frame logic, set "static" parameters to frame 0
if(mindex&FRAMEPAIR_MASK_BYTES){/// combine new value with the old one
if(mindex&FRAMEPAIR_MASK_BYTES){// combine new value with the old one
}elseif((frame8!=findex_future)||((pars[npar].num&FRAMEPAIR_JUST_THIS)==0)){/// do not write "JUST_THIS" parameters in the future otherwise they'll stick
}elseif((frame8!=findex_future)||((pars[npar].num&FRAMEPAIR_JUST_THIS)==0)){// do not write "JUST_THIS" parameters in the future otherwise they'll stick
if(pars[npar].num&FRAMEPAIR_MASK_BYTES){/// combine new value with the old one
if(pars[npar].num&FRAMEPAIR_MASK_BYTES){// combine new value with the old one
for(nframe=frame8;nframe!=findex_future;nframe=(nframe-1)&PARS_FRAMES_MASK){///NOTE: frame8 is modified here
for(nframe=frame8;nframe!=findex_future;nframe=(nframe-1)&PARS_FRAMES_MASK){//NOTE: frame8 is modified here
framepars[nframe].modsince[bindex]|=bmask;
framepars[nframe].modsince[bindex]|=bmask;
framepars[nframe].modsince32|=bmask32;
framepars[nframe].modsince32|=bmask32;
}
}
}
}
}else{/// error - trying to write "just this" to the "future" - that would stick if allowed
}else{// error - trying to write "just this" to the "future" - that would stick if allowed
D1I(local_irq_restore(flags));
D1I(local_irq_restore(flags));
ELP_KERR(printk("Tried to write JUST_THIS parameter (0x%lx) too far in the future",pars[npar].num));
ELP_KERR(printk("Tried to write JUST_THIS parameter (0x%lx) too far in the future",pars[npar].num));
return-ERR_FRAMEPARS_TOOEARLY;
return-ERR_FRAMEPARS_TOOEARLY;
...
@@ -1020,19 +1018,19 @@ int setFramePars(int sensor_port, struct framepars_t * this_framepars, int numPa
...
@@ -1020,19 +1018,19 @@ int setFramePars(int sensor_port, struct framepars_t * this_framepars, int numPa
return0;
return0;
}
}
///TODO: make some parameters readonly (prohibited from modification from the userland)
//TODO: make some parameters readonly (prohibited from modification from the userland)
/// File operations:
// File operations:
/// open, release - nop
// open, release - nop
/// read - none
// read - none
/// write -> setFrameParsAtomic (first 4 bytes - absolute frame number, next 4 bytes - latency, then each 8 bytes - index/value)
// 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
// 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
// file pointer - absolute frame number
/// lseek (SEEK_SET, value) - set 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, 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_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) - 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)
// lseek (SEEK_END, value > 0) - execute commands, do not modify file pointer (and actually use it - frame number the command applies to)