staticstructframepars_all_tsFrameParsAll__attribute__((aligned(PAGE_SIZE)));///< Sensor Parameters, currently 8 pages all and 2048 pages some, static struct
staticstructframepars_all_tsFrameParsAll__attribute__((aligned(PAGE_SIZE)));///< Sensor Parameters, currently 8 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 GLOBALPARS(G_THIS_FRAME) // Current frame number (may lag from the hardware)
#define thisFrameNumber GLOBALPARS(G_THIS_FRAME) // Current frame number (may lag from the hardware)
//#define THISFRAMENUMBER GLOBALPARS(G_THIS_FRAME) // Current frame number (may lag from the hardware)
//#define THISFRAMENUMBER GLOBALPARS(G_THIS_FRAME) // Current frame number (may lag from the hardware)
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
/**
/**
...
@@ -320,30 +320,33 @@ struct framepars_pd {
...
@@ -320,30 +320,33 @@ struct framepars_pd {
/**
/**
* @brief assign non-static pointers to static data to be used as extern
* @brief assign non-static pointers to static data to be used as extern
*/
*/
voidinit_framepars_ptr(void){
voidinit_framepars_ptr(void)
frameparsall=&sFrameParsAll;/// - will be mmap-ed
{
frameparsall=&sFrameParsAll;/// - will be mmap-ed
framepars=sFrameParsAll.framePars;
framepars=sFrameParsAll.framePars;
pastpars=sFrameParsAll.pastPars;
pastpars=sFrameParsAll.pastPars;
funcs2call=sFrameParsAll.func2call.pars;/// each parameter has a 32-bit mask of what pgm_function to call - other fields not used
funcs2call=sFrameParsAll.func2call.pars;/// each parameter has a 32-bit mask of what pgm_function to call - other fields not used
globalPars=sFrameParsAll.globalPars;/// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
globalPars=sFrameParsAll.globalPars;/// parameters that are not frame-related, their changes do not initiate any actions so they can be mmaped for both
multiSensIndex=sFrameParsAll.multiSensIndex;/// indexes of individual sensor register shadows (first of 3) - now for all parameters, not just sensor ones
multiSensIndex=sFrameParsAll.multiSensIndex;/// indexes of individual sensor register shadows (first of 3) - now for all parameters, not just sensor ones
multiSensRvrsIndex=sFrameParsAll.multiSensRvrsIndex;/// reverse index (to parent) for the multiSensIndex
multiSensRvrsIndex=sFrameParsAll.multiSensRvrsIndex;/// reverse index (to parent) for the multiSensIndex
for(i=0;i<P_SENSOR_NUMREGS;i++)funcs2call[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++)funcs2call[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 chnaged, 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 chnaged, and if will be it wil cause no action
for(i=0;i<P_M10359_NUMREGS;i++)funcs2call[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++)funcs2call[P_M10359_REGS+i]=ONCHANGE_SENSORREGS;/// by default each "manual" write to any of 256 registers will trigger pgm_sensorreg function
initMultiPars();/// 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();/// initialize structures for individual per-sensor parameters. Now only works for sensor registers using G_MULTI_REGSM. Should be called after/during sensor detection
frameParsInitialized=1;
frameParsInitialized=1;
}
}
/**
/**
* @brief reset all global parameters, set default for debug mask (if ELPHEL_DEBUG)
* @brief reset all global parameters, set default for debug mask (if ELPHEL_DEBUG)
* @brief initialize structures for individual per-sensor parameters. Now only works for sensor registers using G_MULTI_REGSM. Should be called after/during sensor detection
* @brief initialize structures for individual per-sensor parameters. Now only works for sensor registers using G_MULTI_REGSM. Should be called after/during sensor detection
* @return number of multi-regs
* @return number of multi-regs
*/
*/
intinitMultiPars(void){
intinitMultiPars(void)
inti,j,n;
{
intireg=P_MULTI_REGS;/// multi-reg shadows start index
inti,j,n;
intireg=P_MULTI_REGS;/// multi-reg shadows start index
funcs2call[ireg]=ONCHANGE_SENSORREGS;/// by default each "manual" write to any of these registers will trigger pgm_sensorreg function
funcs2call[ireg]=ONCHANGE_SENSORREGS;/// by default each "manual" write to any of these registers will trigger pgm_sensorreg function
multiSensRvrsIndex[ireg++]=j|((n+1)<<16);
multiSensRvrsIndex[ireg++]=j|((n+1)<<16);
}
}
GLOBALPARS(G_MULTI_NUM)++;
GLOBALPARS(G_MULTI_NUM)++;
}
}
}
}
}
}
for(i=0;i<P_SENSOR_NUMREGS;i++)funcs2call[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++)funcs2call[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
D5(printk(" set GLOBALPARS(0x%x)=0x%lx\n",index,val));
D5(printk(" set GLOBALPARS(0x%x)=0x%lx\n",index,val));
}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
}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