voidgamma_encode_fpga(unsignedshort*gamma_in,unsignedlong*gamma_out);///Hardware-dependent encoding of the FPGA "gamma" table. Converts unsigned short array of 257 16-bit values (only 10 msb-s are used) to 256 unsigned long words to be written to FPGA
voidgamma_encode_fpga(unsignedshort*gamma_in,unsignedlong*gamma_out);///Hardware-dependent encoding of the FPGA "gamma" table. Converts unsigned short array of 257 16-bit values (only 10 msb-s are used) to 256 unsigned long words to be written to FPGA
// #define GAMMA_MODE_HARDWARE 4 // the table is needed to program FPGA: fpga-encoded table will be calculated (if not yet), node will be locked for specified
// #define GAMMA_MODE_HARDWARE 4 // the table is needed to program FPGA: fpga-encoded table will be calculated (if not yet), node will be locked for specified
/// first three letters - sentence to log (letters after "$GP"). next "n"/"b" (up to 24 total) - "n" number (will be encoded 4 digits/byte, follwed by "0xF"
/// "b" - byte - all but last will have MSB 0 (& 0x7f), the last one - with MSB set (| 0x80). If there are no characters in the field 0xff will be output
//printk("imu opened in R/W mode, (numBytesWritten=0x%x, numBytesRead=0x%x\n", numBytesWritten, numBytesRead);
}else{// read mode, use file pointer as read pointer, start from the latest data
filp->f_pos=numBytesWritten;// there is still a chance to lseek to an earlier position - reopening at the position of the total number of bytes written to the buffer
//printk("imu opened in RDONLY mode, (numBytesWritten=0x%x, numBytesRead=0x%x\n", numBytesWritten, numBytesRead);
}
}
break;
}
default:return-EINVAL;
}
// minors[p]=p;
// filp->private_data = &minors[p];
filp->private_data=(int*)p;// store just minor there
printk(KERN_NOTICE"Closing IMU device, numBytesWritten=0x%llx, numBytesRead=0x%llx (only global pointer, does not include files opened in read mode)\n",numBytesWritten,numBytesRead);
// if(d[2] == 0x01) - MT9T001 chip rev 01 - color gains had a bug
// if(d[2] == 0x01) - MT9T001 chip rev 01 - color gains had a bug
...
@@ -785,7 +785,7 @@ int mt9x001_pgm_detectsensor (int sensor_port, ///< sensor port
...
@@ -785,7 +785,7 @@ int mt9x001_pgm_detectsensor (int sensor_port, ///< sensor port
add_sensor_proc(onchange_triggermode,&mt9x001_pgm_triggermode);// program sensor trigger mode
add_sensor_proc(onchange_triggermode,&mt9x001_pgm_triggermode);// program sensor trigger mode
add_sensor_proc(onchange_sensorregs,&mt9x001_pgm_sensorregs);// write sensor registers (only changed from outside the driver as they may have different latencies)?
add_sensor_proc(onchange_sensorregs,&mt9x001_pgm_sensorregs);// write sensor registers (only changed from outside the driver as they may have different latencies)?
if(nupdate)setFramePars(sensor_port,thispars,nupdate,pars_to_update);// save changes to sensor register shadows
if(nupdate)setFramePars(sensor_port,thispars,nupdate,pars_to_update);// save changes to sensor register shadows
return-1;
return-1;
}
}
#endif
rslt=multisensor_set_freq(1,thispars);// first time (1)
rslt=multisensor_set_freq(sensor_port,1,thispars);// first time (1)
if(rslt>0)printk("10359A sensor clock set to %d\n",rslt);
if(rslt>0)printk("10359A sensor clock set to %d\n",rslt);
elseif(rslt==0)printk("10359A sensors are using 10353 system clock, as set in configuration\n");
elseif(rslt==0)printk("10359A sensors are using 10353 system clock, as set in configuration\n");
elseprintk("10359 sensor clock failure, will use system clock from 10353 board\n");
elseprintk("10359 sensor clock failure, will use system clock from 10353 board\n");
...
@@ -1031,21 +1039,21 @@ int multisensor_pgm_detectsensor (int sensor_port, ///< sensor p
...
@@ -1031,21 +1039,21 @@ int multisensor_pgm_detectsensor (int sensor_port, ///< sensor p
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
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){
if(GLOBALPARS(sensor_port,G_SENS_AVAIL)==0){
printk("No supported sensors connected to 10359A board\n");
printk("No supported sensors connected to 10359A board\n");
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");
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");
}
}
multisensor_set_freq(0,thispars);// not the first time. Assuming no clock chip if clock4 is not set
multisensor_set_freq(sensor_port,0,thispars);// not the first time. Assuming no clock chip if clock4 is not set
reset=1;
reset=1;
// TODO: put here calculation of the sensor phases in 10359 from bitstream data and clock rate
// TODO: put here calculation of the sensor phases in 10359 from bitstream data and clock rate
clk_period=1000000000000.0/thispars->pars[P_CLK_SENSOR];// period in ps
// clk_period= 1000000000000.0f/thispars->pars[P_CLK_SENSOR]; // period in ps
/** Initialize array of functions that program different acquisition parameters (some are sensor dependent)
/** Initialize array of functions that program different acquisition parameters (some are sensor dependent)
* @return always 0 */
* @return always 0 */
intinit_pgm_proc(void){
intinit_pgm_proc(void)
{
inti;
inti;
MDF1(printk("\n"));
MDF1(printk("\n"));
for(i=0;i<64;i++)sensorproc->pgm_func[i]=NULL;
for(i=0;i<64;i++)sensorproc->pgm_func[i]=NULL;
...
@@ -325,7 +328,7 @@ int init_pgm_proc(void) {
...
@@ -325,7 +328,7 @@ int init_pgm_proc(void) {
sensorproc->pgm_func[onchange_sensorregs]=&pgm_sensorregs;// write sensor registers (only changed from outside the driver as they may have different latencies)?
sensorproc->pgm_func[onchange_sensorregs]=&pgm_sensorregs;// write sensor registers (only changed from outside the driver as they may have different latencies)?
sensorproc->pgm_func[onchange_prescal]=&pgm_prescal;// change scales for per-color digital gains, apply vignetting correction
sensorproc->pgm_func[onchange_prescal]=&pgm_prescal;// change scales for per-color digital gains, apply vignetting correction
return0;
return0;
}
}
/**
/**
...
@@ -333,10 +336,11 @@ return 0;
...
@@ -333,10 +336,11 @@ return 0;
* @param index function index (internally 32 is added to distinguish from the common (not sensor-specific) functions
* @param index function index (internally 32 is added to distinguish from the common (not sensor-specific) functions
* @param sens_func pointer to a sensor-specific function
* @param sens_func pointer to a sensor-specific function
// NOTE: sensor detected - enabling camera interrupts here (actual interrupts will start later)
// NOTE: sensor detected - enabling camera interrupts here (actual interrupts will start later)
// Here interrupts are disabled - with camera_interrupts (0) earlier in this function)
// Here interrupts are disabled - with camera_interrupts (0) earlier in this function)
...
@@ -541,10 +552,10 @@ int pgm_afterinit (int sensor_port, ///< sensor port number (
...
@@ -541,10 +552,10 @@ int pgm_afterinit (int sensor_port, ///< sensor port number (
structframeparspair_tpars_to_update[24];// 20 needed, increase if more entries will be added
structframeparspair_tpars_to_update[24];// 20 needed, increase if more entries will be added
intnupdate=0;
intnupdate=0;
MDF3(printk(" frame16=%d\n",frame16));
MDF3(printk(" frame16=%d\n",frame16));
// If this is a multisensor camera, update composite sensor dimensions (will trigger other related changes)
// If this is a multisensor camera, update composite sensor dimensions (will trigger other related changes)
// For single sensors sensor size is updated only after initialization, with composite it needs to be updated after vertical gap or number of active sesnors is changed
// For single sensors sensor size is updated only after initialization, with composite it needs to be updated after vertical gap or number of active sesnors is changed
// if (GLOBALPARS(G_SENS_AVAIL) ) multisensor_pgm_afterinit0 (sensor, thispars, prevpars,frame16);
// if (GLOBALPARS(G_SENS_AVAIL) ) multisensor_pgm_afterinit0 (sensor, thispars, prevpars,frame16);
// Setup WOI. If size is zero - use maximal that sensor can, in non-zero - just refresh so appropriate actions will be scheduled on chnange
// Setup WOI. If size is zero - use maximal that sensor can, in non-zero - just refresh so appropriate actions will be scheduled on chnange
// goodEOL=0; // last 8/16 blocks of pixels in each scanline are bad (only 2 are actually written)
// goodEOL=0; // last 8/16 blocks of pixels in each scanline are bad (only 2 are actually written)
// if 8-bit mode we'll need to update ntilex. fpga tries to write 2 bytes more (but not crossing the page boundaries
// if 8-bit mode we'll need to update ntilex. fpga tries to write 2 bytes more (but not crossing the page boundaries
// GoodEOL - if image width is multiple of 512 pixels 1 extra block (16 pixels) needs to be written to memory (and padlen will be more by 512 bytes (256 words)
// GoodEOL - if image width is multiple of 512 pixels 1 extra block (16 pixels) needs to be written to memory (and padlen will be more by 512 bytes (256 words)
// due to FPGA controller implementation (it writes extra 4 pixels for the margins, but not when it crosses 512 byte boundary)
// due to FPGA controller implementation (it writes extra 4 pixels for the margins, but not when it crosses 512 byte boundary)
// When reading 20x20 macroblocks to the compressor, such exception is not needed, it crosses page boundaries when needed
// When reading 20x20 macroblocks to the compressor, such exception is not needed, it crosses page boundaries when needed
if((thispars->pars[P_BITS]==8)&&(!thispars->pars[P_BGFRAME])){// in 16-bit mode ntilex will stay the same
if((thispars->pars[P_BITS]==8)&&(!thispars->pars[P_BGFRAME])){// in 16-bit mode ntilex will stay the same
// if (imageParamsR[P_OVERLAP]>=(imageParamsR[P_ACTUAL_HEIGHT]+2)) imageParamsR[P_OVERLAP]=imageParamsR[P_ACTUAL_HEIGHT]+1; rotten code, left as a comment
// if (imageParamsR[P_OVERLAP]>=(imageParamsR[P_ACTUAL_HEIGHT]+2)) imageParamsR[P_OVERLAP]=imageParamsR[P_ACTUAL_HEIGHT]+1; rotten code, left as a comment
if(thispars->pars[P_OVERLAP]>0)ntiley=(ntiley<<1);// ntiley will be twice bigger for synch. mode)
if(thispars->pars[P_OVERLAP]>0)ntiley=(ntiley<<1);// ntiley will be twice bigger for synch. mode)
padlen=((ntilex+31)>>5)<<8;
padlen=((ntilex+31)>>5)<<8;
//TODO:fix it to be able to use two (or larger) frame buffer
//TODO:fix it to be able to use two (or larger) frame buffer