intinitSequencers(intsensor_port);///Move to sensorcommon? currently it is used through frameparsall file (lseek)
voidinitGlobalPars(intsensor_port);/// resets all global parameters but debug mask (if ELPHEL_DEBUG)
intinitMultiPars(intsensor_port);/// initialize structures for individual per-sensor parameters. Now only works for sensor registers using G_MULTI_REGSM. Should be called aftre/during sensor detection
voidinitFramePars(intsensor_port);///initialize all parameters, set thisFrameNumber to frame8 (read from hardware, usually 0 after resetting i2c and cmd_seq)
voidinitFramePars(intsensor_port);///initialize all parameters, set thisFrameNumber to frame16 (read from hardware, usually 0 after resetting i2c and cmd_seq)
voidresetFrameNumber(intsensor_port,u32aframe,inthreset);/// reset this frame number (called from initFramePars(), also can be used to avoid frame number integer overflow)
@@ -486,7 +488,7 @@ int multisensor_pgm_window_common (int sensor_port, ///< sensor p
dev_dbg(g_dev_ptr,"frame16=%d\n",frame16);
if(composite&&(!async)){
printk("*** ERROR (Should be disabled in multisensor_pgm_multisens() ) CANNOT USE COMPOSITE MODE WITH FREE RUNNING SENSOR ***\n");
dev_err(g_dev_ptr,"*** ERROR (Should be disabled in multisensor_pgm_multisens() ) CANNOT USE COMPOSITE MODE WITH FREE RUNNING SENSOR ***\n");
composite=0;
SETFRAMEPARS_SET(P_MULTI_MODE,0);// Do we need to force anything here? If it was async->free transition? Or just TRIG mode should have all the dependencies of P_MULTI_MODE
}
...
...
@@ -502,13 +504,17 @@ int multisensor_pgm_window_common (int sensor_port, ///< sensor p
sFlipY[i]=flipY^(composite?((thispars->pars[P_MULTI_FLIPV]&(1<<i))?1:0):0);// in single (non -composite) mode use just flipY
}elseif((wt+wh-height1-vblank2)<(height2+vblank3+(sensor->minHeight*dv))){// Only first 2 sensors are needed - reduce second frame (10359, not the sensor)
height2=wh+wt-height1-vblank2;// only 10359, not the sensor
}else{// all 3 sensors needed, adjust height3 to make sure 10359 sends out exactly wh/dv lines (vblank* could be adjusted to compensate for Bayer when flipping)
X3X3_I2C_RCV2(sensor_port,I2C359_SLAVEADDR,I2C359_VERSION,&bitstream_version);// just 2 bytes, not 4
dev_dbg(g_dev_ptr,"Exceeded number of unbalanced writes on port %d: (%d > %d), reading i2c, got 0x%lx\n",sensor_port,get_unbalanced_writes(sensor_port),i2c_get_max_unbalanced_writes(),bitstream_version);
}
// wait for the write buffer to have some room
if(!x393_xi2c_ready_wr(sensor_port)){
dev_dbg(g_dev_ptr,"Had to wait for the i2c sequencer while multisensor_write_i2c(%d, %s, 0x%x, 0x%x, 0x%x)\n",
// Try to read chip version from each of the 3 possible sensors
printk("removing MRST from the sensor\n");
dev_info(g_dev_ptr,"removing MRST from the sensor\n");
//
sensio_ctl.d32=0;
sensio_ctl.mrst=1;
...
...
@@ -1036,9 +1098,10 @@ int multisensor_pgm_detectsensor (int sensor_port, ///< sensor p
udelay(100);
GLOBALPARS(sensor_port,G_SENS_AVAIL)|=1<<(GLOBALPARS(sensor_port,G_SENS_AVAIL));// temporary to indicate sensor detection functions that they need to initialize multisensor registers
for(i=0;i<MAX_SENSORS;i++){
// for (i=0;i<MAX_SENSORS;i++) {
for(i=0;i<3;i++){// 10359 only supports 3 sesnors, not 4
#ifdef NC353
dev_dbg(g_dev_ptr,"%s Probing sensor port %d, i2c bitdelays=0x%08x\n",__func__,i,i2c_delays(0));
dev_dbg(g_dev_ptr,"Probing sensor port %d, i2c bitdelays=0x%08x\n",i,i2c_delays(0));
rslt=multisensor_read_i2c(sensor_port,
MT9P001_I2C_ADDR+((i+1)*I2C359_INC),
P_MT9X001_CHIPVER,
...
...
@@ -1050,35 +1113,37 @@ int multisensor_pgm_detectsensor (int sensor_port, ///< sensor p
P_MT9X001_CHIPVER,
&sensor_id[i]);
#endif
// dev_dbg(g_dev_ptr,"%s Probing sensor port %d, i2c bitdelays=0x%08x, rslt=0x%x\n",__func__,i,i2c_delays(0),rslt);
// dev_dbg(g_dev_ptr,"Probing sensor port %d, i2c bitdelays=0x%08x, rslt=0x%x\n",i,i2c_delays(0),rslt);
printk("Found MT9P001 2592x1944 sensor on 10359A port %d, chip ID=%lx\n",(i+1),sensor_id[i]);
dev_info(g_dev_ptr,"Found MT9P001 2592x1944 sensor on 10359A port %d, chip ID=%lx\n",(i+1),sensor_id[i]);
GLOBALPARS(sensor_port,G_SENS_AVAIL)|=1<<i;
}elseif(sensor_id[i]==0xffff){
sensor_id[i]=0;
}else{
printk("Found UNSUPPORTED sensor on port %d, chip ID=0x%lx\n",(i+1),sensor_id[i]);
dev_warn(g_dev_ptr,"Found UNSUPPORTED sensor on port %d, chip ID=0x%lx\n",(i+1),sensor_id[i]);
}
}elsesensor_id[i]=0;
}
GLOBALPARS(sensor_port,G_SENS_AVAIL)&=(1<<(GLOBALPARS(sensor_port,G_SENS_AVAIL)))-1;// remove flag used to indicate sensor detection functions that they need to initialize multisesnor registers
if(GLOBALPARS(sensor_port,G_SENS_AVAIL)==0){
printk("No supported sensors connected to 10359A board\n");
dev_warn(g_dev_ptr,"No supported sensors connected to 10359A board\n");
Now overwrite sensor functions with it's own (originals (physical sensor ones) are already copied to the local structure
...
...
@@ -1171,6 +1236,7 @@ Now overwrite sensor functions with it's own (originals (physical sensor ones) a
CCAM_ENDFRAMES_EN;// Enable ending frame being compressed if no more data will be available (frame ended before specified number of blocks compressed)
#endif
if(nupdate)setFramePars(sensor_port,thispars,nupdate,pars_to_update);// save changes to sensor register shadows
dev_dbg(g_dev_ptr,"Done with multisensor_pgm_detectsensor thisFframe= 0x%lx hard frame = 0x%x\n",getThisFrameNumber(sensor_port),getHardFrameNumber(sensor_port,0));
returnthis_sensor_type;
}
...
...
@@ -1218,20 +1284,20 @@ int multisensor_pgm_multisens (int sensor_port, ///< sensor port n
if(!sensor_mask)sensor_mask=GLOBALPARS(sensor_port,G_SENS_AVAIL);// if none sensors were enabled - enable all what is available (same as with WOI size)
if(composite&&(!async)){
printk("*** CANNOT USE COMPOSITE MODE WITH FREE RUNNING SENSOR ***\n");
dev_err(g_dev_ptr,"*** CANNOT USE COMPOSITE MODE WITH FREE RUNNING SENSOR ***\n");
composite=0;
SETFRAMEPARS_SET(P_MULTI_MODE,0);// Do we need to force anything here? If it was async->free transition? Or just TRIG mode should have all the dependencies of P_MULTI_MODE
}
// TODO: recalculate sequence when MULTISENS_EN is chnaged (tried 5 - did not modify sequence, showed first frame only)
// Here - only recalculate SENSOR_HEIGHT, skipping disabled sensors. in multisensor_pgm_window() will need to skip disabled also
// No above is not really needed, sequence+enable can be handled by application software
if(multi_unitialized&&(!composite)&&(prev_composite||((new_sensor>=0)&&(old_sensor!=new_sensor)))){// now single-sensor mode, set P_WOI* from saved parameters
printk("%s:%d:%s ",__FILE__,__LINE__,__FUNCTION__);printk("WARNING: ((thispars->pars[P_CLK_SENSOR] == prevpars->pars[P_CLK_SENSOR])) but multi_phases_initialized is not yet set (re-init?)\n");
dev_warn(g_dev_ptr,"WARNING: ((thispars->pars[P_CLK_SENSOR] == prevpars->pars[P_CLK_SENSOR])) but multi_phases_initialized is not yet set (re-init?)\n");
}
multisensor_set_freq(sensor_port,0,thispars);// not the first time. Assuming no clock chip if clock4 is not set
reset=1;
// TODO: put here calculation of the sensor phases in 10359 from bitstream data and clock rate
// clk_period= 1000000000000.0f/thispars->pars[P_CLK_SENSOR]; // period in ps
if(!thispars->pars[P_CLK_SENSOR]){
dev_warn(g_dev_ptr,"Sensor clock is not set, using default 0x%lx\n",sensor_clk);