Commit 1cc7fb99 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

fixed bad frames for mt9f002 when changing window size

parent d30f6065
......@@ -140,7 +140,7 @@ const unsigned short mt9f002_ahead_tab[] =
onchange_initsensor, 1, 0, 0, 0, 0, 0, /// resets sensor, reads sensor registers, schedules "secret" manufacturer's corrections to the registers (stops/re-enables hardware i2c)
onchange_afterinit, 0, 0, 0, 0, 0, 0, /// restore image size, decimation,... after sensor reset or set them according to sensor capabilities if none were specified
onchange_multisens, 0, 2, 1, 1, 1, 0, /// chnages related to multiplexed sensors
onchange_window, 0, 2, 1, 1, 1, 0, /// program sensor WOI and mirroring (flipping) - NOTE: 1 bad frame to skip
onchange_window, 0, 2, 1, 2, 1, 0, /// program sensor WOI and mirroring (flipping) - NOTE: 1 bad frame to skip
onchange_window_safe, 0, 1, 1, 1, 1, 0, /// program sensor WOI and mirroring (flipping) - NOTE: no bad frames
onchange_exposure, 0, 2, 1, 2, 1, 0, /// program exposure
onchange_gains, 0, 1, 1, 1, 1, 0, /// program analog gains
......@@ -156,7 +156,7 @@ const unsigned short mt9f002_ahead_tab[] =
onchange_memcompressor, 0, 0, 0, 0, 0, 0, /// program memory channel 2 (memory->compressor) (delays programming until onchange_comprestart if needed)
/// For Micron sensors limitfps should have the same latency as changing window height, otherwise when WOI_HEIGHT 0x3c0->0x790 and next frame VBLANK 0x13e->0x284
/// sensor waits till the counter overflows (>10 seconds) without any frame sync pulses
onchange_limitfps, 0, 2, 1, 1, 1, 0, /// check compressor will keep up, limit sensor FPS if needed
onchange_limitfps, 0, 2, 1, 2, 1, 0, /// check compressor will keep up, limit sensor FPS if needed
onchange_compmode, 0, 0, 0, 0, 0, 0, /// program compressor modes
onchange_focusmode, 1, 0, 0, 0, 0, 0, /// program focus modes (through writing the tables, so no sequencer)
onchange_trigseq, 0, 2, 1, 1, 1, 0, /// NC393: OK to program through the sequencer (full 32 bits)
......@@ -732,9 +732,16 @@ int mt9f002_pgm_sensorin (int sensor_port, ///< sensor port number
{
x393_sensio_width_t sensio_width = {.d32=0};
int cframe16 = getThisFrameNumber(sensor_port);
dev_dbg(g_dev_ptr,"{%d} s_i cframe16=0x%08x frame16=%d\n",sensor_port,cframe16,frame16);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame
// this is a hack because there's no delay after SOF in HISPI proto
sensio_width.sensor_width = MT9F002_VACT_DELAY;
X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_width, sensio_width);
if (!(thispars->pars[P_FRAMESYNC_DLY] & 0x10000)){
sensio_width.sensor_width = MT9F002_VACT_DELAY;
X393_SEQ_SEND1(sensor_port, frame16, x393_sensio_width, sensio_width);
}
return 0;
}
......@@ -827,7 +834,7 @@ int mt9f002_pgm_window_common (int sensor_port, ///< sensor port
int dv,dh,bv,bh,ww,wh,wl,wt,flip,flipX,flipY,d, v;
int wws,wwe,whs,whe;
int compressor_margin; // 0 for JP4, 2 for JPEG
struct frameparspair_t pars_to_update[29];
struct frameparspair_t pars_to_update[12];
int nupdate=0;
int min_frame_blanking_lines = thispars->pars[P_SENSOR_REGS+P_MT9F002_MIN_FRAME_BLANKING_LINES];
......@@ -843,7 +850,9 @@ int mt9f002_pgm_window_common (int sensor_port, ///< sensor port
int whs_vact_delay = 0;
int whe_vact_delay = 0;
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
int cframe16 = getThisFrameNumber(sensor_port);
dev_dbg(g_dev_ptr,"{%d} w_c cframe=0x%08x frame16=%d\n",sensor_port,cframe16,frame16);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame
//pr_info("mt9f002_pgm_window_common: %d\n",thispars->pars[P_EXPOS]);
......@@ -1160,7 +1169,9 @@ int mt9f002_pgm_limitfps (int sensor_port, ///< sensor port numb
unsigned long trig_period;
dev_dbg(g_dev_ptr,"{%d} pgm_limit_fps frame16=%d\n",sensor_port,frame16);
int cframe16 = getThisFrameNumber(sensor_port);
dev_dbg(g_dev_ptr,"{%d} l_f cframe16=0x%08x frame16=%d\n",sensor_port,cframe16,frame16);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame
//pr_info("mt9f002_pgm_limitfps: %d\n",thispars->pars[P_EXPOS]);
......@@ -1409,7 +1420,9 @@ int mt9f002_pgm_exposure (int sensor_port, ///< sensor port number
int row_time_in_pixels=thispars->pars[P_VIRT_WIDTH];
int pix_period;
dev_dbg(g_dev_ptr,"{%d} pgm_exposure frame16=%d\n",sensor_port,frame16);
int cframe16 = getThisFrameNumber(sensor_port);
dev_dbg(g_dev_ptr,"{%d} exp cframe=0x%08x frame16=%d\n",sensor_port,cframe16,frame16);
// wrong frame
if (frame16 >= PARS_FRAMES) return -1;
......
......@@ -786,6 +786,7 @@ static unsigned short mt9p001_multiregs[]=
int mt9x001_pgm_detectsensor (int sensor_port, struct sensor_t * sensor, struct framepars_t * thispars, struct framepars_t * prevpars, int frame16);
int mt9x001_pgm_initsensor (int sensor_port, struct sensor_t * sensor, struct framepars_t * thispars, struct framepars_t * prevpars, int frame16);
int mt9x001_pgm_sensorin (int sensor_port, struct sensor_t * sensor, struct framepars_t * thispars, struct framepars_t * prevpars, int frame16);
int mt9x001_pgm_window (int sensor_port, struct sensor_t * sensor, struct framepars_t * thispars, struct framepars_t * prevpars, int frame16);
int mt9x001_pgm_window_safe (int sensor_port, struct sensor_t * sensor, struct framepars_t * thispars, struct framepars_t * prevpars, int frame16);
int mt9x001_pgm_window_common(int sensor_port, struct sensor_t * sensor, struct framepars_t * thispars, struct framepars_t * prevpars, int frame16);
......@@ -918,6 +919,7 @@ int mt9x001_pgm_detectsensor (int sensor_port, ///< sensor port
dev_dbg(g_dev_ptr,"{%d} copied %d bytes of sensor static parameters\n",sensor_port,sizeof(mt9p001));
add_sensor_proc(sensor_port,onchange_detectsensor,&mt9x001_pgm_detectsensor); // detect sensor type, sets sensor structure (capabilities), function pointers NOTE: will be called directly, not through pointers
add_sensor_proc(sensor_port,onchange_initsensor, &mt9x001_pgm_initsensor); // resets sensor, reads sensor registers, schedules "secret" manufacturer's corrections to the registers (stops/re-enables hardware i2c)
add_sensor_proc(sensor_port,onchange_sensorin, &mt9x001_pgm_sensorin); // see mt9f002
add_sensor_proc(sensor_port,onchange_exposure, &mt9x001_pgm_exposure); // program exposure
add_sensor_proc(sensor_port,onchange_window, &mt9x001_pgm_window); // program sensor WOI and mirroring (flipping)
add_sensor_proc(sensor_port,onchange_window_safe, &mt9x001_pgm_window_safe); // program sensor WOI and mirroring (flipping) - now - only flipping? with lower latency
......@@ -1096,6 +1098,33 @@ int mt9x001_pgm_initsensor (int sensor_port, ///< sensor port
return 0;
}
/**
* Program sensor input in FPGA (Bayer, 8/16 bits, FPN, test mode, number of lines).
*/
int mt9x001_pgm_sensorin (int sensor_port, ///< sensor port number (0..3)
struct sensor_t * sensor, ///< sensor static parameters (capabilities)
struct framepars_t * thispars, ///< sensor current parameters
struct framepars_t * prevpars, ///< sensor previous parameters (not used here)
int frame16) ///< 4-bit (hardware) frame number parameters should
///< be applied to, negative - ASAP
///< @return OK - 0, <0 - error
{
x393_sensio_width_t sensio_width = {.d32=0};
int cframe16 = getThisFrameNumber(sensor_port);
dev_dbg(g_dev_ptr,"{%d} s_i cframe16=0x%08x frame16=%d\n",sensor_port,cframe16,frame16);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame
// mt9f002 needed MT9F002_VACT_DELAY here, but mt9x001 needs 0 - has no real effect probably
if (!(thispars->pars[P_FRAMESYNC_DLY] & 0x10000)){
sensio_width.sensor_width = 0;
X393_SEQ_SEND1(sensor_port, frame16, x393_sensio_width, sensio_width);
}
return 0;
}
/** Program sensor WOI and mirroring
* Validating, changing related parameters/scheduling actions, scheduling i2c commands
......
......@@ -1503,6 +1503,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
// Writing WOI width for internally generated HACT
if (thispars->pars[P_FRAMESYNC_DLY] & 0x10000) { /// set enforced HACT length, if 0 - use HACT from sensor
sensio_width.sensor_width = thispars->pars[P_ACTUAL_WIDTH]+(2 * margins);
X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_width, sensio_width);
}
/*
......@@ -1512,8 +1513,6 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
}
*/
X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_width, sensio_width);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_width, 0x%x)\n",
sensor_port, sensor_port, frame16, sensio_width.d32);
......@@ -2919,6 +2918,15 @@ int pgm_comprestart(int sensor_port, ///< sensor port number (0..3
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
/*
// OLEG: temporary test to restart sensor
control_sensor_memory (sensor_port,
thispars->pars[P_SENSOR_RUN] & 3,
reset_frame,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
*/
// turn comressor on after memory
if (thispars->pars[P_COMPRESSOR_RUN] != COMPRESSOR_RUN_STOP) {
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode);
......@@ -2996,6 +3004,15 @@ int pgm_compstop (int sensor_port, ///< sensor port number (0..3
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
/*
// OLEG: temporary test to stop sensor
control_sensor_memory (sensor_port,
SENSOR_RUN_STOP,
0, // reset_frame
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
*/
dev_dbg(g_dev_ptr,"{%d}@0x%lx: X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_control_reg, 0x%x)\n",sensor_port, getThisFrameNumber(sensor_port), sensor_port, frame16, cmprs_mode.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_control_reg, 0x%x)\n", sensor_port, frame16, cmprs_mode.d32)
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment