Commit cdd973c0 authored by Andrey Filippov's avatar Andrey Filippov

fixing handling MULTI_FLIP* and SENSOR_PHASE

parent 6ea28cb0
...@@ -632,27 +632,6 @@ void updateFramePars(int sensor_port, ///< sensor port number (0..3) ...@@ -632,27 +632,6 @@ void updateFramePars(int sensor_port, ///< sensor port number (0..3)
int comp_frame16 = getHardFrameNumber(sensor_port, 1); // Use compressor frame number int comp_frame16 = getHardFrameNumber(sensor_port, 1); // Use compressor frame number
u32 comp_aframe = thisCompressorFrameNumber(sensor_port); u32 comp_aframe = thisCompressorFrameNumber(sensor_port);
x393_cmprs_mode_t cmprs_mode = get_x393_cmprs_control_reg(sensor_port); x393_cmprs_mode_t cmprs_mode = get_x393_cmprs_control_reg(sensor_port);
#if 0
// Add to x393.h
x393_cmprs_mode_t get_x393_cmprs_control_reg (int cmprs_chn);
// Add to x393.c
x393_cmprs_mode_t get_x393_cmprs_control_reg (int cmprs_chn)
{ x393_cmprs_mode_t d; d.d32 = readl(mmio_ptr + (0x1800 + 0x40 * cmprs_chn)); return d; }
#endif
#endif
#ifdef NC353
// Old comments from NC353
// If interrupt was from compression done (circbuf advanced, interframe_pars!=null), the frame16 (hardware) maybe not yet advanced
// We can fix it here, but it will not work if some frames were not processed in time
if ((interframe_pars != NULL) && (((frame16 ^ thisFrameNumber(sensor_port)) & PARS_FRAMES_MASK) == 0)) {
findex_this = frame16 & PARS_FRAMES_MASK;
/* 393 TODO: Check what to do with P_IRQ_SMART */
if (framepars[findex_this].pars[P_IRQ_SMART] & 4) frame16 = (frame16 + 1) & PARS_FRAMES_MASK; // verify that this mode is enabled (together with bit0)
}
#endif #endif
dev_dbg(g_devfp_ptr,"%s : port= %d, frame16=%d\n",__func__, sensor_port, frame16); dev_dbg(g_devfp_ptr,"%s : port= %d, frame16=%d\n",__func__, sensor_port, frame16);
while ((frame16 ^ thisFrameNumber(sensor_port)) & PARS_FRAMES_MASK) { // While hardware pointer is still ahead of the software maintained one while ((frame16 ^ thisFrameNumber(sensor_port)) & PARS_FRAMES_MASK) { // While hardware pointer is still ahead of the software maintained one
...@@ -685,26 +664,6 @@ x393_cmprs_mode_t get_x393_cmprs_control_reg (int cmprs_chn) ...@@ -685,26 +664,6 @@ x393_cmprs_mode_t get_x393_cmprs_control_reg (int cmprs_chn)
// 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)
// debug code - save compressor states in the past parameters // debug code - save compressor states in the past parameters
#if 0
struct framepars_past_t {
unsigned long past_pars[PARS_SAVE_NUM]; ///< Array of frame parameters preserved for the future
};
#endif
#ifdef NC353
if (interframe_pars) { // frame was compressed, not just vsync
//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]
interframe_pars->height = framepars[findex_this].pars[P_ACTUAL_HEIGHT]; // NOTE: P_ACTUAL_WIDTH,P_QUALITY copied with memcpy
interframe_pars->color = framepars[findex_this].pars[P_COLOR];
interframe_pars->byrshift = framepars[findex_this].pars[P_COMPMOD_BYRSH];
interframe_pars->quality2 |= (framepars[findex_this].pars[P_PORTRAIT] & 1) << 7;
}
#endif
// copy parameters from findex_future (old "farthest in the future") to findex_prev (new "fartherst in the future") if it was changed since // copy parameters from findex_future (old "farthest in the future") to findex_prev (new "fartherst in the future") if it was changed since
if ((bmask32 = framepars[findex_prev].modsince32)) { if ((bmask32 = framepars[findex_prev].modsince32)) {
dev_dbg(g_devfp_ptr,"%s framepars[%d].modsince32=0x%lx\n",__func__, findex_prev, bmask32); dev_dbg(g_devfp_ptr,"%s framepars[%d].modsince32=0x%lx\n",__func__, findex_prev, bmask32);
...@@ -745,6 +704,10 @@ x393_cmprs_mode_t get_x393_cmprs_control_reg (int cmprs_chn) ...@@ -745,6 +704,10 @@ x393_cmprs_mode_t get_x393_cmprs_control_reg (int cmprs_chn)
} }
} }
thisFrameNumber(sensor_port)++; thisFrameNumber(sensor_port)++;
// if (thisFrameNumber(sensor_port)<20) {
// dev_dbg(g_devfp_ptr,"thisFrameNumber(%d)=0x%x\n",sensor_port, (int) thisFrameNumber(sensor_port));
// }
} }
} }
......
...@@ -779,7 +779,7 @@ loff_t histograms_lseek (struct file * file, ...@@ -779,7 +779,7 @@ loff_t histograms_lseek (struct file * file,
dev_dbg(g_dev_ptr, "wait_event_interruptible (ahist_y_wait_queue[%d],0x%x & 0x%x)\n",privData->port, (int) get_imageParamsThis(privData->port, P_DAEMON_EN), (int) (1<<(offset & 0x1f))); dev_dbg(g_dev_ptr, "wait_event_interruptible (ahist_y_wait_queue[%d],0x%x & 0x%x)\n",privData->port, (int) get_imageParamsThis(privData->port, P_DAEMON_EN), (int) (1<<(offset & 0x1f)));
wait_event_interruptible (ahist_y_wait_queue[privData->port], get_imageParamsThis(privData->port, P_DAEMON_EN) & (1<<(offset & 0x1f))); wait_event_interruptible (ahist_y_wait_queue[privData->port], get_imageParamsThis(privData->port, P_DAEMON_EN) & (1<<(offset & 0x1f)));
break; break;
case LSEEK_DAEMON_HIST_C: // wait for daemon enabled and histograms Y ready case LSEEK_DAEMON_HIST_C: // wait for daemon enabled and histograms C ready
dev_dbg(g_dev_ptr, "wait_event_interruptible (ahist_c_wait_queue[%d],0x%x & 0x%x)\n",privData->port, (int) get_imageParamsThis(privData->port, P_DAEMON_EN), (int) (1<<(offset & 0x1f))); dev_dbg(g_dev_ptr, "wait_event_interruptible (ahist_c_wait_queue[%d],0x%x & 0x%x)\n",privData->port, (int) get_imageParamsThis(privData->port, P_DAEMON_EN), (int) (1<<(offset & 0x1f)));
wait_event_interruptible (ahist_c_wait_queue[privData->port], get_imageParamsThis(privData->port, P_DAEMON_EN) & (1<<(offset & 0x1f))); wait_event_interruptible (ahist_c_wait_queue[privData->port], get_imageParamsThis(privData->port, P_DAEMON_EN) & (1<<(offset & 0x1f)));
break; break;
......
...@@ -967,7 +967,7 @@ int multisensor_write_i2c(int sensor_port,///< sensor port number ...@@ -967,7 +967,7 @@ int multisensor_write_i2c(int sensor_port,///< sensor port number
*/ */
static int multi_unitialized=0; ///< temporary hack to resolve race between individual and multi_ flips at startup static int multi_unitialized[]={0,0,0,0}; ///< temporary hack to resolve race between individual and multi_ flips at startup
/** /**
* @brief detect and initialize sensor and related data structures * @brief detect and initialize sensor and related data structures
...@@ -1010,7 +1010,7 @@ int multisensor_pgm_detectsensor (int sensor_port, ///< sensor p ...@@ -1010,7 +1010,7 @@ int multisensor_pgm_detectsensor (int sensor_port, ///< sensor p
sensor_port, getThisFrameNumber(sensor_port), sensor_port, frame16, sens_mode.d32, getHardFrameNumber(sensor_port,0)); sensor_port, getThisFrameNumber(sensor_port), sensor_port, frame16, sens_mode.d32, getHardFrameNumber(sensor_port,0));
// .hact_delay = -2500, // -2.5ns delay in ps // .hact_delay = -2500, // -2.5ns delay in ps
// .sensorDelay = 2460, // Delay from sensor clock at FPGA output to pixel data transition (FPGA input), short cable (ps) // .sensorDelay = 2460, // Delay from sensor clock at FPGA output to pixel data transition (FPGA input), short cable (ps)
multi_unitialized=0; // reset this static variable - it will prevent copying individual flips to multiple until composite mode is used multi_unitialized[sensor_port]=0; // reset this static variable - it will prevent copying individual flips to multiple until composite mode is used
dev_dbg(g_dev_ptr,"frame16=%d\n",frame16); dev_dbg(g_dev_ptr,"frame16=%d\n",frame16);
GLOBALPARS(sensor_port,G_SENS_AVAIL)=0; // no 10359A board present GLOBALPARS(sensor_port,G_SENS_AVAIL)=0; // no 10359A board present
if (frame16 >= 0) return -1; // can only work in ASAP mode if (frame16 >= 0) return -1; // can only work in ASAP mode
...@@ -1352,7 +1352,7 @@ int multisensor_pgm_multisens (int sensor_port, ///< sensor port n ...@@ -1352,7 +1352,7 @@ int multisensor_pgm_multisens (int sensor_port, ///< sensor port n
// int multi_flipv=thispars->pars[P_MULTI_FLIPV]; // int multi_flipv=thispars->pars[P_MULTI_FLIPV];
// int old_sensor=prev_selected-1; // may be <0 // int old_sensor=prev_selected-1; // may be <0
// int new_sensor=selected-1; // >=0 // int new_sensor=selected-1; // >=0
if (multi_unitialized && (!prev_composite) && (old_sensor>=0)) { // was single-sensor mode, copy P_WOI_* to individual sensor WOI and FLIPS if (multi_unitialized[sensor_port] && (!prev_composite) && (old_sensor>=0)) { // was single-sensor mode, copy P_WOI_* to individual sensor WOI and FLIPS
dev_dbg(g_dev_ptr,"multi_unitialized=%d old_sensor=%x, multi_fliph=%x multi_flipv=%x\n", multi_unitialized, old_sensor, multi_fliph,multi_flipv); dev_dbg(g_dev_ptr,"multi_unitialized=%d old_sensor=%x, multi_fliph=%x multi_flipv=%x\n", multi_unitialized, old_sensor, multi_fliph,multi_flipv);
wois[(P_MULTI_WIDTH1- P_MULTI_WOI)+old_sensor]= prevpars->pars[P_WOI_WIDTH]; wois[(P_MULTI_WIDTH1- P_MULTI_WOI)+old_sensor]= prevpars->pars[P_WOI_WIDTH];
wois[(P_MULTI_HEIGHT1-P_MULTI_WOI)+old_sensor]= prevpars->pars[P_WOI_HEIGHT]; wois[(P_MULTI_HEIGHT1-P_MULTI_WOI)+old_sensor]= prevpars->pars[P_WOI_HEIGHT];
...@@ -1362,7 +1362,7 @@ int multisensor_pgm_multisens (int sensor_port, ///< sensor port n ...@@ -1362,7 +1362,7 @@ int multisensor_pgm_multisens (int sensor_port, ///< sensor port n
multi_flipv= (multi_flipv & (~(1<<old_sensor))) | ((prevpars->pars[P_FLIPV] & 1) << old_sensor); multi_flipv= (multi_flipv & (~(1<<old_sensor))) | ((prevpars->pars[P_FLIPV] & 1) << old_sensor);
dev_dbg(g_dev_ptr,"multi_unitialized=%d old_sensor=%x, multi_fliph=%x multi_flipv=%x\n", multi_unitialized, old_sensor, multi_fliph,multi_flipv); dev_dbg(g_dev_ptr,"multi_unitialized=%d old_sensor=%x, multi_fliph=%x multi_flipv=%x\n", multi_unitialized, old_sensor, multi_fliph,multi_flipv);
} }
if (multi_unitialized && (!composite) && (prev_composite || ((new_sensor>=0) && (old_sensor!=new_sensor)))) { // now single-sensor mode, set P_WOI* from saved parameters if (multi_unitialized[sensor_port] && (!composite) && (prev_composite || ((new_sensor>=0) && (old_sensor!=new_sensor)))) { // now single-sensor mode, set P_WOI* from saved parameters
if ((wois[(P_MULTI_WIDTH1- P_MULTI_WOI)+new_sensor]==0) || (wois[(P_MULTI_HEIGHT1- P_MULTI_WOI)+new_sensor]==0)) { if ((wois[(P_MULTI_WIDTH1- P_MULTI_WOI)+new_sensor]==0) || (wois[(P_MULTI_HEIGHT1- P_MULTI_WOI)+new_sensor]==0)) {
// This particular sensor was never initialized // This particular sensor was never initialized
if (prev_composite || // should never get here - if that was composite mode before, P_MULTI_* should be already set. Using sensor defaults if (prev_composite || // should never get here - if that was composite mode before, P_MULTI_* should be already set. Using sensor defaults
...@@ -1476,7 +1476,7 @@ int multisensor_pgm_multisens (int sensor_port, ///< sensor port n ...@@ -1476,7 +1476,7 @@ int multisensor_pgm_multisens (int sensor_port, ///< sensor port n
SETFRAMEPARS_COND(P_SENSOR_HEIGHT, total_height); SETFRAMEPARS_COND(P_SENSOR_HEIGHT, total_height);
if (nupdate) setFramePars(sensor_port,thispars, nupdate, pars_to_update); // save changes, schedule functions if (nupdate) setFramePars(sensor_port,thispars, nupdate, pars_to_update); // save changes, schedule functions
if ( composite) multi_unitialized=1; // now mark as used - will enable copying from individual to composite flips if ( composite) multi_unitialized[sensor_port]=1; // now mark as used - will enable copying from individual to composite flips
return 0; return 0;
} }
......
...@@ -466,12 +466,14 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number ( ...@@ -466,12 +466,14 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number (
// restore/set sensor clock // restore/set sensor clock
if ((was_sensor_freq < sensor->minClockFreq) || (was_sensor_freq > sensor->maxClockFreq)) was_sensor_freq=sensor->nomClockFreq; if ((was_sensor_freq < sensor->minClockFreq) || (was_sensor_freq > sensor->maxClockFreq)) was_sensor_freq=sensor->nomClockFreq;
setFramePar(sensor_port, thispars, P_CLK_SENSOR | FRAMEPAIR_FORCE_NEWPROC, was_sensor_freq); // will schedule clock/phase adjustment setFramePar(sensor_port, thispars, P_CLK_SENSOR | FRAMEPAIR_FORCE_NEWPROC, was_sensor_freq); // will schedule clock/phase adjustment
/*
phase=thispars->pars[P_SENSOR_PHASE]; phase=thispars->pars[P_SENSOR_PHASE];
// TODO: remove phase adjustment from here // TODO: remove phase adjustment from here
if (phase==0) { if (phase==0) {
phase= 0x40000; phase= 0x40000;
setFramePar(sensor_port, thispars, P_SENSOR_PHASE | FRAMEPAIR_FORCE_NEWPROC, phase); // will schedule clock/phase adjustment setFramePar(sensor_port, thispars, P_SENSOR_PHASE | FRAMEPAIR_FORCE_NEWPROC, phase); // will schedule clock/phase adjustment
} }
*/
setFramePar(sensor_port, thispars, P_I2C_EOF | FRAMEPAIR_FORCE_NEWPROC, 0); // increment i2c at SOF - change to EOF? setFramePar(sensor_port, thispars, P_I2C_EOF | FRAMEPAIR_FORCE_NEWPROC, 0); // increment i2c at SOF - change to EOF?
// NOTE: sensor detected - enabling camera interrupts here (actual interrupts will start later) // NOTE: sensor detected - enabling camera interrupts here (actual interrupts will start later)
......
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