Commit 385eb407 authored by Andrey Filippov's avatar Andrey Filippov

histograms debugging, project setup files updated

parent 4ddade87
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
......@@ -11,16 +11,6 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>clean,</triggers>
......
......@@ -495,7 +495,7 @@ inline int get_image_start_chn(int last_chunk_offset, unsigned int len32, int ch
return X393_BUFFSUB_CHN(last_chunk_offset + CHUNK_SIZE - INSERTED_BYTES(len32) - CCAM_MMAP_META, len32, chn);
}
#ifdef PRE_FRAMEPARS
/* debug code follows */
void stop_compressor(unsigned int chn)
{
......@@ -503,8 +503,9 @@ void stop_compressor(unsigned int chn)
mode.run = 1;
mode.run_set = 1;
x393_cmprs_control_reg(mode, chn);
set_x393_cmprs_control_reg(mode, chn);
}
#endif
void dump_state(unsigned int chn)
{
int img_start, last_image_chunk;
......
......@@ -261,7 +261,7 @@ int initSequencers(int sensor_port)
// x393_rtc_sec_t rtc_sec = {.d32=0};
sec_usec_t sec_usec;
FLAGS_IBH
if (!is_fpga_programmed){
if (!is_fpga_programmed()){
dev_err(g_devfp_ptr,"*** Attempted to access hardware without bitsteram ***\n");
return - ENODEV;
}
......@@ -425,6 +425,23 @@ inline unsigned long get_imageParamsFrame(int sensor_port, ///< sensor port (0..
return aframepars[sensor_port][frame & PARS_FRAMES_MASK].pars[n];
}
inline unsigned long * get_imageParamsFramePtr(int sensor_port, ///< sensor port (0..3)
int n, ///< parameter index (should be 128..143)
int frame) ///< absolute frame number
{
return &(aframepars[sensor_port][frame & PARS_FRAMES_MASK].pars[n]);
}
inline unsigned long * get_imageParamsPastPtr(int sensor_port, ///< sensor port (0..3)
int n, ///< parameter index (should be 128..143)
int frame) ///< absolute frame number
{
return &(apastpars[sensor_port][frame & PASTPARS_SAVE_ENTRIES_MASK].past_pars[n-PARS_SAVE_FROM]);
}
/**
* @brief reads parameters from the current frame (matching hardware index)
* @param sensor_port sensor port number (0..3)
......@@ -565,6 +582,21 @@ void updateFramePars(int sensor_port, ///< sensor port number (0..3)
unsigned long bmask, bmask32;
int pastParsIndex;
struct framepars_t *framepars = aframepars[sensor_port];
#define DEBUG_BYRSH
#ifdef DEBUG_BYRSH
int comp_frame16 = getHardFrameNumber(sensor_port, 1); // Use compressor frame number
u32 comp_aframe = thisCompressorFrameNumber(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
......@@ -579,7 +611,7 @@ void updateFramePars(int sensor_port, ///< sensor port number (0..3)
#endif
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
dev_dbg(g_devfp_ptr,"%s : port= %d, frame16=%d, thisFrameNumber(sensor_port)\n",__func__, sensor_port, frame16, (int)thisFrameNumber(sensor_port));
dev_dbg(g_devfp_ptr,"%s : port= %d, frame16=%d, thisFrameNumber(%d)=%d\n",__func__, sensor_port, frame16, sensor_port, (int)thisFrameNumber(sensor_port));
// before update:
// framepars[findex_prev] holds previous frame data (oldest availble - latest?)
// framepars[findex_future] holds farthest in the future one
......@@ -598,8 +630,19 @@ void updateFramePars(int sensor_port, ///< sensor port number (0..3)
// memcpy(apastpars[sensor_port][pastParsIndex].past_pars, &framepars[findex_prev].pars[PARS_SAVE_FROM], PARS_SAVE_COPY * sizeof(int));
memcpy(apastpars[sensor_port][pastParsIndex].past_pars, &framepars[findex_prev].pars[PARS_SAVE_FROM], PARS_SAVE_COPY << 2);
#ifdef DEBUG_BYRSH
apastpars[sensor_port][pastParsIndex].past_pars[PARS_SAVE_COPY + 0] = comp_frame16;
apastpars[sensor_port][pastParsIndex].past_pars[PARS_SAVE_COPY + 1] = comp_aframe;
apastpars[sensor_port][pastParsIndex].past_pars[PARS_SAVE_COPY + 2] = cmprs_mode.d32;
apastpars[sensor_port][pastParsIndex].past_pars[PARS_SAVE_COPY + 3] = pastParsIndex;
#endif
// 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
#if 0
struct framepars_past_t {
unsigned long past_pars[PARS_SAVE_NUM]; ///< Array of frame parameters preserved for the future
......@@ -677,7 +720,7 @@ inline void _processParsASAP(int sensor_port, ///< sensor port
int i;
int rslt;
#if ELPHEL_DEBUG_0
#ifdef ELPHEL_DEBUG_0
unsigned long allfunctions = framepars[0].functions | framepars[1].functions | framepars[2].functions | framepars[3].functions |
framepars[4].functions | framepars[5].functions | framepars[6].functions | framepars[7].functions;
if (allfunctions) MDF6(printk("frame16=%d, functions: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", frame16, framepars[0].functions,
......@@ -708,16 +751,16 @@ inline void _processParsASAP(int sensor_port, ///< sensor port
todo = (pars_ahead) ?
(p_nasap[pars_ahead] & (procpars->functions) & remain) :
(procpars->functions & remain);
dev_dbg(g_devfp_ptr,"port=%d frame16=%d todo=0x%08lx,p_nasap[%d]=0x%08x procpars->functions=0x%08lx\n",
dev_dbg(g_devfp_ptr,"port=%d frame16=%d todo=0x%08lx,p_nasap[%d]=0x%08lx procpars->functions=0x%08lx\n",
sensor_port, frame16, todo, pars_ahead, p_nasap[pars_ahead], procpars->functions);
MDP(DBGB_FASAP,sensor_port,"frame16=%d todo=0x%08lx,p_nasap[%d]=0x%08x procpars->functions=0x%08lx\n",
MDP(DBGB_FASAP,sensor_port,"frame16=%d todo=0x%08lx,p_nasap[%d]=0x%08lx procpars->functions=0x%08lx\n",
frame16, todo, pars_ahead, p_nasap[pars_ahead], procpars->functions)
} else {
todo = (pars_ahead) ?
(p_nasap[pars_ahead] & (procpars->functions) & remain) :
(procpars->functions & remain);
dev_dbg(g_devfp_ptr,"port=%d frame16=%d todo=0x%08lx,p_nasap[%d]=0x%08x procpars->functions=0x%08lx\n",
dev_dbg(g_devfp_ptr,"port=%d frame16=%d todo=0x%08lx,p_nasap[%d]=0x%08lx procpars->functions=0x%08lx\n",
sensor_port, frame16, todo, pars_ahead, p_nasap[pars_ahead], procpars->functions);
}
while ((todo = (pars_ahead) ?
......@@ -755,13 +798,13 @@ inline void _processParsASAP(int sensor_port, ///< sensor port
framepars[4].functions, framepars[5].functions, framepars[6].functions, framepars[7].functions);
}
if (sensorproc->pgm_func[i]) {
dev_dbg(g_devfp_ptr,"port= %d, Calling GENERIC pgm_func[%d] ASAP\n",sensor_port,i);
MDP(DBGB_FASAP,sensor_port,"Calling GENERIC pgm_func[%d] ASAP\n",i)
dev_dbg(g_devfp_ptr,"port= %d, Calling GENERIC pgm_func[%d] ASAP, now frame = 0x%lx\n",sensor_port,i,thisFrameNumber(sensor_port));
MDP(DBGB_FASAP,sensor_port,"Calling GENERIC pgm_func[%d] ASAP, now frame = 0x%x\n",i,thisFrameNumber(sensor_port))
rslt = sensorproc->pgm_func[i] (sensor_port, &(sensorproc->sensor), procpars, prevpars, -1);
} else rslt = 0; // only sensor-specific function, nothing to do common to all sensors
if ((rslt >= 0) && (sensorproc->pgm_func[i + 32])) { // sensor - specific functions, called after the main ones
dev_dbg(g_devfp_ptr,"port= %d, Calling SENSOR-SPECIFIC pgm_func[%d] ASAP\n",sensor_port,i);
MDP(DBGB_FASAP,sensor_port,"Calling SENSOR-SPECIFIC pgm_func[%d] ASAP\n",i)
dev_dbg(g_devfp_ptr,"port= %d, Calling SENSOR-SPECIFIC pgm_func[%d] ASAP, now frame = 0x%lx\n",sensor_port,i,thisFrameNumber(sensor_port));
MDP(DBGB_FASAP,sensor_port,"Calling SENSOR-SPECIFIC pgm_func[%d] ASAP, now frame = 0x%x\n",i,thisFrameNumber(sensor_port))
rslt = sensorproc->pgm_func[i + 32] (sensor_port, &(sensorproc->sensor), procpars, prevpars, -1);
}
if (rslt < 0) dev_warn(g_devfp_ptr,"%s:%d:%s - error=%d", __FILE__, __LINE__, __FUNCTION__, rslt);// Nothing to do with errors here - just report?
......@@ -775,6 +818,7 @@ inline void _processParsASAP(int sensor_port, ///< sensor port
dev_dbg(g_devfp_ptr,"%s port=%d DONE\n", __func__, sensor_port);
}
// Next 5 should go in that sequence
//#define G_CALLNASAP 119 // bitmask - what functions can be used not only in the current frame (ASAP) mode
//#define G_CALLNEXT1 120 // bitmask of actions to be one or more frames ahead of the programmed one (OR-ed with G_CALLNEXT2..G_CALLNEXT4)
......@@ -846,13 +890,13 @@ inline void _processParsSeq(int sensor_port, ///< sensor port
if (sensorproc->pgm_func[i]) {
// NOTE: Was (frame16+job_ahead +1) & PARS_FRAMES_MASK
dev_dbg(g_devfp_ptr,"port= %d, Calling GENERIC pgm_func[%d], seq_frame = %d\n",sensor_port,i,seq_frame);
MDP(DBGB_FSEQ,sensor_port,"Calling GENERIC pgm_func[%d], seq_frame = %d\n",i,seq_frame)
dev_dbg(g_devfp_ptr,"port= %d, Calling GENERIC pgm_func[%d], seq_frame = 0x%x, now frame = 0x%lx\n",sensor_port,i,seq_frame,thisFrameNumber(sensor_port));
MDP(DBGB_FSEQ,sensor_port,"Calling GENERIC pgm_func[%d], seq_frame = 0x%x, now frame = 0x%x\n",i,seq_frame,thisFrameNumber(sensor_port))
rslt = sensorproc->pgm_func[i] (sensor_port, &(sensorproc->sensor), procpars, prevpars, seq_frame);
} else rslt = 0; // only sensor-specific function, nothing to do common to all sensors
if ((rslt >= 0) && (sensorproc->pgm_func[i + 32])) { // sensor - specific functions, called after the main ones
dev_dbg(g_devfp_ptr,"port= %d, Calling SENSOR-SPECIFIC pgm_func[%d], seq_frame = %d\n",sensor_port,i,seq_frame);
MDP(DBGB_FSEQ,sensor_port,"Calling SENSOR-SPECIFIC pgm_func[%d], seq_frame = %d\n",i,seq_frame)
dev_dbg(g_devfp_ptr,"port= %d, Calling SENSOR-SPECIFIC pgm_func[%d], seq_frame = 0x%x, now frame = 0x%lx\n",sensor_port,i,seq_frame,thisFrameNumber(sensor_port));
MDP(DBGB_FSEQ,sensor_port,"Calling SENSOR-SPECIFIC pgm_func[%d], seq_frame = 0x%x, now frame = 0x%x\n",i,seq_frame,thisFrameNumber(sensor_port))
rslt = sensorproc->pgm_func[i + 32] (sensor_port, &(sensorproc->sensor), procpars, prevpars, seq_frame);
}
if (rslt >= 0) {
......@@ -979,6 +1023,7 @@ int processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16,
frame16, maxahead)
dev_dbg(g_devfp_ptr,"== Done from tasklet: port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
}
return 0;
}
#endif
......@@ -992,9 +1037,9 @@ int processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16,
void schedule_pgm_func(int sensor_port, int frame16, int func_num)
{
aframepars[sensor_port][frame16 & PARS_FRAMES_MASK].functions |= 1 << func_num;
dev_dbg(g_devfp_ptr,"func_num=%d, aframepars[%d][%d].functions=0x08lx\n",
dev_dbg(g_devfp_ptr,"func_num=%d, aframepars[%d][%d].functions=0x%08lx\n",
func_num, sensor_port, frame16, aframepars[sensor_port][frame16 & PARS_FRAMES_MASK].functions);
MDP(DBGB_FSCF,sensor_port,"func_num=%d, aframepars[%d][%d].functions=0x08lx\n",
MDP(DBGB_FSCF,sensor_port,"func_num=%d, aframepars[%d][%d].functions=0x%08lx\n",
func_num, sensor_port, frame16,aframepars[sensor_port][frame16 & PARS_FRAMES_MASK].functions)
}
......@@ -1009,9 +1054,9 @@ void schedule_this_pgm_func(int sensor_port, struct framepars_t * this_framepars
{
int frame16 = this_framepars->pars[P_FRAME] & PARS_FRAMES_MASK;
aframepars[sensor_port][frame16].functions |= 1 << func_num;
dev_dbg(g_devfp_ptr,"func_num=%d, aframepars[%d][%d].functions=0x08lx\n",
dev_dbg(g_devfp_ptr,"func_num=%d, aframepars[%d][%d].functions=0x08%lx\n",
func_num, sensor_port, frame16, aframepars[sensor_port][frame16 & PARS_FRAMES_MASK].functions);
MDP(DBGB_FSCF,sensor_port,"func_num=%d, aframepars[%d][%d].functions=0x08lx\n",
MDP(DBGB_FSCF,sensor_port,"func_num=%d, aframepars[%d][%d].functions=0x08%lx\n",
func_num, sensor_port, frame16,aframepars[sensor_port][frame16 & PARS_FRAMES_MASK].functions)
}
......@@ -1154,8 +1199,8 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0
for (nframe = (frame16 + 1) & PARS_FRAMES_MASK; (nframe != findex_prev) && (!(framepars[nframe].mod[bindex] & bmask)); nframe = (nframe + 1) & PARS_FRAMES_MASK) {
framepars[nframe].pars[index] = val;
dev_dbg(g_devfp_ptr,"framepars[%d].pars[%d] <- 0x%08x ", nframe, index, val);
MDP(DBGB_FSFA,sensor_port,"framepars[%d].pars[%d] <- 0x%08x ", nframe, index, val)
dev_dbg(g_devfp_ptr,"framepars[%d].pars[%d] <- 0x%08lx ", nframe, index, val);
MDP(DBGB_FSFA,sensor_port,"framepars[%d].pars[%d] <- 0x%08lx ", nframe, index, val)
}
frame16 = (frame16 - 1) & PARS_FRAMES_MASK; // for " regular parameters "modified since" do not include the target frame itself, for "JUST_THIS" - does
dev_dbg(g_devfp_ptr,"\n");
......@@ -1452,7 +1497,7 @@ int framepars_open(struct inode *inode, struct file *filp)
if (!privData) return -ENOMEM;
filp->private_data = privData;
privData->minor = MINOR(inode->i_rdev);
dev_dbg(g_devfp_ptr,"minor=0x%x\n",__func__, privData->minor);
dev_dbg(g_devfp_ptr,"minor=0x%x\n", privData->minor);
switch (privData->minor) {
case DEV393_MINOR(DEV393_FRAMEPARS0):
case DEV393_MINOR(DEV393_FRAMEPARS1):
......@@ -1789,7 +1834,7 @@ static ssize_t store_fpga_time(struct device *dev, struct device_attribute *attr
{
sec_usec_t sec_usec={.sec=0, .usec=0};
// avoiding floating point calcualtions in the kernel
char *cp = buf;
const char *cp = buf;
int i;
if (sscanf(buf, "%lu.%s", &sec_usec.sec, cp)>0){
sscanf(cp,"%lu",&sec_usec.usec);
......@@ -1842,7 +1887,6 @@ static ssize_t show_all_frames(struct device *dev, struct device_attribute *attr
return buf-buf0;
}
static DEVICE_ATTR(this_frame0, SYSFS_PERMISSIONS, show_this_frame, store_this_frame);
static DEVICE_ATTR(this_frame1, SYSFS_PERMISSIONS, show_this_frame, store_this_frame);
static DEVICE_ATTR(this_frame2, SYSFS_PERMISSIONS, show_this_frame, store_this_frame);
......@@ -1886,7 +1930,7 @@ int framepars_init(struct platform_device *pdev)
{
int res;
struct device *dev = &pdev->dev;
const struct of_device_id *match;
// const struct of_device_id *match;
int sensor_port;
for (sensor_port = 0; sensor_port < SENSOR_PORTS; sensor_port++) {
......
......@@ -24,6 +24,8 @@ unsigned long get_imageParamsThis (int sensor_port, int n);
unsigned long get_imageParamsPrev (int sensor_port, int n);
unsigned long get_imageParamsPast(int sensor_port, int n, int frame);
unsigned long * get_imageParamsFramePtr(int sensor_port, int n, int frame);
unsigned long * get_imageParamsPastPtr (int sensor_port, int n, int frame);
void set_imageParamsThis (int sensor_port, int n, unsigned long d);
unsigned long get_globalParam (int sensor_port, int n);
......@@ -69,9 +71,5 @@ void schedule_this_pgm_func (int sensor_port, struct framepars_t * this_fr
//inline void _processParsSeq (int sensor_port, struct sensorproc_t * sensorproc, int frame8, int maxahead);
int processPars (int sensor_port, struct sensorproc_t * sensorproc, int frame8, int maxahead);
///*** TODO: Add option (flag?) to write "single" (like single compress, single sensor) so it will not make all the next frames "single"
int framepars_init (struct platform_device *pdev);
int framepars_remove (struct platform_device *pdev);
// *** TODO: Add option (flag?) to write "single" (like single compress, single sensor) so it will not make all the next frames "single"
#endif
......@@ -135,8 +135,14 @@
#endif
//u32 (*fpga_hist_data)[SENSOR_PORTS][MAX_SENSORS][PARS_FRAMES][4][256]; ///< Array of histogram data, mapped to the memory wheer FPGA sends data
//u32 *fpga_hist_data[SENSOR_PORTS][MAX_SENSORS][PARS_FRAMES][4][256]; ///< Array of histogram data, mapped to the memory wheer FPGA sends data
u32 (*fpga_hist_data)[SENSOR_PORTS][MAX_SENSORS][PARS_FRAMES][4][256]; ///< Array of histogram data, mapped to the memory wheer FPGA sends data
//u32 *fpga_hist_data[SENSOR_PORTS][MAX_SENSORS][PARS_FRAMES][4][256]; ///< Array of histogram data, mapped to the memory where FPGA sends data
//u32 (*fpga_hist_data)[SENSOR_PORTS][MAX_SENSORS][PARS_FRAMES][4][256]; ///< Array of histogram data, mapped to the memory where FPGA sends data
//typedef u32 fpga_hist_t [SENSOR_PORTS][MAX_SENSORS][PARS_FRAMES][4][256];
//typedef u32 fpga_hist_t [][MAX_SENSORS][PARS_FRAMES][4][256];
typedef u32 (*fpga_hist_t)[MAX_SENSORS][PARS_FRAMES][4][256];
fpga_hist_t fpga_hist_data;
dma_addr_t fpga_hist_phys; // physical address of the start of the received histogram data
#define X3X3_HISTOGRAMS_DRIVER_DESCRIPTION "Elphel (R) Model 353 Histograms device driver"
......@@ -151,7 +157,7 @@ static int numHistChn = 0;
/** Variable-length array (length is the total number of active sensors <=16), each being the same as in 353:
* consisting of SENSOR_PORTS histogram_stuct_t structures */
struct histogram_stuct_t (*histograms)[HISTOGRAM_CACHE_NUMBER];
struct histogram_stuct_t (*histograms)[HISTOGRAM_CACHE_NUMBER] = NULL;
//struct histogram_stuct_t *histograms;
dma_addr_t histograms_phys; ///< likely not needed, saved during allocation
......@@ -231,14 +237,15 @@ inline void histogram_calc_percentiles ( unsigned long * cumul_hist, unsigned
* Histograms will be initialized for all possible ports/channels, only some will be enabled */
int histograms_init_hardware(void)
{
int port, chn;
x393_hist_saxi_addr_t saxi_addr;
// fpga_hist_data = (u32 [SENSOR_PORTS][MAX_SENSORS][PARS_FRAMES][4][256]) pElphel_buf->d2h_vaddr; // must be page-aligned!
fpga_hist_data = (u32 *) pElphel_buf->histograms_vaddr; // d2h_vaddr; // must be page-aligned!
int port, chn, hist_chn;
x393_hist_saxi_addr_t saxi_addr = {.d32=0};
// fpga_hist_data = (u32 *) pElphel_buf->histograms_vaddr; // d2h_vaddr; // must be page-aligned!
fpga_hist_data = (fpga_hist_t) pElphel_buf->histograms_vaddr; // d2h_vaddr; // must be page-aligned!
fpga_hist_phys = pElphel_buf->histograms_paddr; //d2h_paddr;
for (port=0; port<SENSOR_PORTS; port++) for (chn=0; chn < MAX_SENSORS; chn++) {
saxi_addr.page=(fpga_hist_phys >> PAGE_SHIFT)+ PARS_FRAMES * (chn + MAX_SENSORS *port);// table for 4 colors is exactly 1 page;
set_x393_hist_saxi_addr (saxi_addr, chn); // Histogram DMA addresses (in 4096 byte pages)
hist_chn = chn + MAX_SENSORS *port;
saxi_addr.page=(fpga_hist_phys >> PAGE_SHIFT)+ PARS_FRAMES * hist_chn;// table for 4 colors is exactly 1 page;
set_x393_hist_saxi_addr (saxi_addr, hist_chn); // Histogram DMA addresses (in 4096 byte pages)
}
// Hand all data to device
dma_sync_single_for_device(NULL, fpga_hist_phys, SENSOR_PORTS*MAX_SENSORS*PARS_FRAMES*4*256*4, DMA_FROM_DEVICE);
......@@ -300,7 +307,7 @@ void init_histograms(int chn_mask) ///< combined subchannels and ports Save mask
// dev_warn(g_dev_ptr, "dma_alloc_coherent(NULL, 0x%x, 0x%x,GFP_NOWAIT)",pages * PAGE_SIZE, (int) histograms_phys);
// histograms = dma_alloc_coherent(NULL,(pages * PAGE_SIZE),&histograms_phys,GFP_ATOMIC); // OK
dev_warn(g_dev_ptr, "dma_alloc_coherent should be done before (@probe), needed are 0x%x bytes)",pages * PAGE_SIZE);
dev_warn(g_dev_ptr, "dma_alloc_coherent should be done before (@probe), needed are 0x%lx bytes)",pages * PAGE_SIZE);
BUG_ON(!histograms);
histograms_p= (struct histogram_stuct_t *) histograms;
// MDF21(printk("\n"));
......@@ -329,7 +336,7 @@ int get_hist_index (int sensor_port, ///< sensor port number (0..3)
}
/**
* @brief Get histograms from the FPGA (called as tasklet?)
* @brief Get histograms from the FPGA (called as tasklet - not anymore?)
* TODO: should it be one frame behind current?
* each group of 4 bits cover 4 colors of the same type */
int set_histograms (int sensor_port, ///< sensor port number (0..3)
......@@ -346,18 +353,41 @@ int set_histograms (int sensor_port, ///< sensor port number (0..3)
unsigned long * framep) ///< array of 8 values to copy (frame, gains,expos,vexpos, focus), NULL OK
///< @return 0 OK, -EINVAL unused port/channel
{
int i, color_start, hist_indx, hist_frame;
hist_indx=get_hist_index(sensor_port,sensor_chn);
const int hist_frames_available = PARS_FRAMES - 3; // ?
int i, color_start, hist_indx, hist_frame, hist_frame_index;
unsigned long thisFrameNumber=getThisFrameNumber(sensor_port);
dev_dbg(g_dev_ptr, "Setting histograms for frame=%ld(0x%lx), thisFrameNumber=%ld (0x%lx), needed=0x%x\n",
frame,frame,thisFrameNumber,thisFrameNumber, needed);
hist_indx=get_hist_index(sensor_port,sensor_chn); // channel/subchannel combination, removed unused
if (hist_indx <0 ) return -EINVAL;
if (histograms[hist_indx][GLOBALPARS(sensor_port,G_HIST_LAST_INDEX+sensor_chn)].frame!=frame) {
GLOBALPARS(sensor_port, G_HIST_LAST_INDEX+sensor_chn)=(GLOBALPARS(sensor_port, G_HIST_LAST_INDEX+sensor_chn)+1) & (HISTOGRAM_CACHE_NUMBER-1);
histograms[hist_indx][GLOBALPARS(sensor_port, G_HIST_LAST_INDEX+sensor_chn)].valid=0; // overwrite all
histograms[hist_indx][GLOBALPARS(sensor_port, G_HIST_LAST_INDEX+sensor_chn)].frame=frame; // add to existent
if (framep) memcpy (&(histograms[hist_indx][GLOBALPARS(sensor_port,G_HIST_LAST_INDEX)].frame), framep, 32); // copy provided frame, gains,expos,vexpos, focus
if (gammaHash) memcpy (&(histograms[hist_indx][GLOBALPARS(sensor_port,G_HIST_LAST_INDEX)].gtab_r), gammaHash, 16); // copy provided 4 hash32 values
if (frame >= thisFrameNumber) {
dev_dbg(g_dev_ptr, "frame=%ld(0x%lx) >= thisFrameNumber=%ld (0x%lx) (not yet available)\n",frame,frame,thisFrameNumber,thisFrameNumber);
return -EINVAL; // not yet available
}
// verify frame still not overwritten
if (frame < (thisFrameNumber - hist_frames_available)) {
dev_dbg(g_dev_ptr, "frame=%ld(0x%lx) < thisFrameNumber=%ld (0x%lx) - %d (already gone)\n",frame,frame,thisFrameNumber,thisFrameNumber,hist_frames_available);
return -EINVAL; // not yet available
}
dev_dbg(g_dev_ptr, "Setting histograms for frame=%ld(0x%lx), thisFrameNumber=%ld (0x%lx), needed=0x%x, hist_indx=0x%x \n",
frame,frame,thisFrameNumber,thisFrameNumber, needed, hist_indx);
hist_frame_index = (int) GLOBALPARS(sensor_port,G_HIST_LAST_INDEX+sensor_chn);
dev_dbg(g_dev_ptr, "histograms[%d][%d].frame = 0x%lx\n",
hist_indx, hist_frame_index, histograms[hist_indx][hist_frame_index].frame);
if (histograms[hist_indx][hist_frame_index].frame!=frame) {
hist_frame_index = (hist_frame_index+1) & (HISTOGRAM_CACHE_NUMBER-1);
GLOBALPARS(sensor_port, G_HIST_LAST_INDEX+sensor_chn)=hist_frame_index;
histograms[hist_indx][hist_frame_index].valid=0; // overwrite all
histograms[hist_indx][hist_frame_index].frame=frame; // add to existent
if (framep) memcpy (&(histograms[hist_indx][hist_frame_index].frame), framep, 32); // copy provided frame, gains,expos,vexpos, focus
if (gammaHash) memcpy (&(histograms[hist_indx][hist_frame_index].gtab_r), gammaHash, 16); // copy provided 4 hash32 values
dev_dbg(g_dev_ptr, "histograms[%d][%d].frame = 0x%lx\n",
hist_indx, hist_frame_index, histograms[hist_indx][hist_frame_index].frame);
} else {
needed &= ~histograms[hist_indx][GLOBALPARS(sensor_port,G_HIST_LAST_INDEX)].valid; // remove those that are already available from the request
needed &= ~histograms[hist_indx][hist_frame_index].valid; // remove those that are already available from the request
}
dev_dbg(g_dev_ptr, "needed=0x%x\n", needed);
// TODO: handle valid and needed for multichannel?
if (!(needed & 0xf)) // nothing to do with FPGA
return 0;
......@@ -371,12 +401,22 @@ int set_histograms (int sensor_port, ///< sensor port number (0..3)
outer_inv_range(phys_addr, phys_addr + (256*sizeof(u32) - 1));
__cpuc_flush_dcache_area(dma_data, 256*sizeof(u32));
color_start= i<<8 ;
memcpy(&histograms[hist_indx][GLOBALPARS(sensor_port, G_HIST_LAST_INDEX+sensor_chn)],
memcpy(&histograms[hist_indx][hist_frame_index].hist[256*i],
dma_data, 256*sizeof(u32));
// old in 353: fpga_hist_read_nice (color_start, 256, (unsigned long *) &histograms[GLOBALPARS(G_HIST_LAST_INDEX)].hist[color_start]);
histograms[hist_indx][ GLOBALPARS(sensor_port,G_HIST_LAST_INDEX+sensor_chn)].valid |= 1 << i;
histograms[hist_indx][hist_frame_index].valid |= 1 << i;
dev_dbg(g_dev_ptr, "histograms[%d][%d].valid=0x%lx\n",
hist_indx, hist_frame_index,histograms[hist_indx][hist_frame_index].valid );
}
return 0;
/*
for (i=0; i<4; i++) if (needed & ( 1 << i )) {
color_start= i<<8 ;
fpga_hist_read_nice (color_start, 256, (unsigned long *) &histograms[GLOBALPARS(G_HIST_LAST_INDEX)].hist[color_start]);
histograms[GLOBALPARS(G_HIST_LAST_INDEX)].valid |= 1 << i;
}
*/
}
......@@ -403,9 +443,29 @@ int get_histograms(int sensor_port, ///< sensor port number (0..3)
int i, color_start, index;
int hist_indx=get_hist_index(sensor_port,sensor_chn);
int raw_needed;
unsigned long thisFrameNumber=getThisFrameNumber(sensor_port);
unsigned long * gammaHash;
unsigned long * framep;
if (hist_indx <0 ) return -EINVAL;
index=GLOBALPARS(sensor_port, G_HIST_LAST_INDEX+sensor_chn);
raw_needed=(needed | (needed>>4) | needed>>8) & 0xf;
dev_dbg(g_dev_ptr, "sensor_port=%d, sensor_chn=%d, frame = %ld (0x%lx), thisFrameNumber=%ld(0x%lx), needed = 0x%x, raw_needed=0x%x\n",
sensor_port, sensor_chn, frame, frame, thisFrameNumber, thisFrameNumber, needed, raw_needed);
if (raw_needed){
// get parameters - decide from current or mpastpars
if (frame == (thisFrameNumber-1)) { // use pars
gammaHash = get_imageParamsFramePtr(sensor_port, P_GTAB_R, frame);
framep = get_imageParamsFramePtr(sensor_port, P_FRAME, frame);
} else {
gammaHash = get_imageParamsPastPtr (sensor_port, P_GTAB_R, frame);
framep = get_imageParamsPastPtr (sensor_port, P_FRAME, frame);
}
if ((i= set_histograms (sensor_port, sensor_chn, frame, raw_needed, gammaHash, framep))){
dev_dbg(g_dev_ptr, "Failed to set up histograms for frame= %ld(0x%lx), thisFrameNumber=%ld(0x%lx), returned %d\n",
frame,frame, thisFrameNumber,thisFrameNumber,i);
return i;
}
}
index=GLOBALPARS(sensor_port, G_HIST_LAST_INDEX+sensor_chn); // set_histograms may increment G_HIST_LAST_INDEX+sensor_chn
for (i=0;i<HISTOGRAM_CACHE_NUMBER;i++) {
dev_dbg(g_dev_ptr, "index=%d, needed=0x%x\n",index,needed);
if ((histograms[hist_indx][index].frame <= frame) && ((histograms[hist_indx][index].valid & raw_needed)==raw_needed)) break;
......@@ -413,9 +473,13 @@ int get_histograms(int sensor_port, ///< sensor port number (0..3)
}
if (i>=HISTOGRAM_CACHE_NUMBER) {
dev_err(g_dev_ptr, "no histograms exist for requested colors (0x%x), requested 0x%x\n",raw_needed,needed);
// here we need to try to locate and copy raw histogram
return -EFAULT; // if Y - never calculated, if C - maybe all the cache is used by Y
}
needed &= ~0x0f; // mask out FPGA read requests -= they are not handled here anymore (use set_histograms())
/// needed &= ~0x0f; // mask out FPGA read requests -= they are not handled here anymore (use set_histograms())
dev_dbg(g_dev_ptr, "needed=0x%x\n",needed);
needed |= ((needed >>4) & 0xf0); // cumulative histograms are needed for percentile calculations
needed &= ~histograms[hist_indx][index].valid;
......@@ -590,20 +654,27 @@ loff_t histograms_lseek (struct file * file,
loff_t offset,
int orig)
{
int p,s;
int p,s,index;
struct histograms_pd * privData = (struct histograms_pd *) file->private_data;
unsigned long reqAddr,reqFrame;
dev_dbg(g_dev_ptr, "histograms_lseek: offset=0x%x, orig=0x%x\n",(int) offset, (int) orig);
dev_dbg(g_dev_ptr, "histograms_lseek: offset=%d(0x%x), orig=0x%x, getThisFrameNumber(%d)=0x%x\n", (int) offset, (int) offset, (int) orig, privData->port, (int)getThisFrameNumber(privData->port));
switch (privData->minor) {
case DEV393_MINOR(DEV393_HISTOGRAM) :
switch(orig) {
case SEEK_CUR: // ignore offset
case SEEK_CUR: // ignore offset - in NC353 it was get latest?
offset = -1; // for now - just make "latest"
#if 0
offset+=(privData-> wait_mode)?
GLOBALPARS(privData->port,G_HIST_C_FRAME+privData->subchannel):
GLOBALPARS(privData->port,G_HIST_Y_FRAME+privData->subchannel);
#endif
//no break (CDT understands this)
case SEEK_SET:
case SEEK_SET: // negative - make latest?
if (offset <0){
dev_dbg(g_dev_ptr, "offset= %lld (0x%llx) changing to previous frame \n",offset,offset);
offset = getThisFrameNumber(privData->port) -1;
}
privData->frame=offset;
// Try to make some precautions to avoid waiting forever - if the past frame is requested - request histogram for the current frame,
// if the "immediate" future (fits into the array of frames) one - request that frame's histogram
......@@ -613,34 +684,56 @@ loff_t histograms_lseek (struct file * file,
if (privData->request_en) {
reqAddr=(privData-> wait_mode)?P_HISTRQ_C:P_HISTRQ_Y;
reqFrame=getThisFrameNumber(privData->port);
dev_dbg(g_dev_ptr, "offset= %d (0x%x), reqFrame=%d (0x%x) \n",(int) offset,(int) offset,(int) reqFrame,(int) reqFrame);
if (offset > reqFrame) {
if (offset > (reqFrame+5)) reqFrame+=5; // What is this 5?
else reqFrame=offset;
dev_dbg(g_dev_ptr, "offset= %d (0x%x), modified reqFrame for future request =%d (0x%x) \n",(int) offset,(int) offset,(int) reqFrame,(int) reqFrame);
}
if (offset < reqFrame) { // just debugging
dev_dbg(g_dev_ptr, "offset < reqFrame, will run get_histograms (%d, %d, 0x%x, 0x%x) \n",
privData->port, privData->subchannel, (int) offset, (int) privData->needed);
}
if ((offset < reqFrame) && // if the requested frame is in the past - try to get it first before requesting a new
(((privData->frame_index = get_histograms (privData->port, privData->subchannel, offset, privData->needed))) >=0)) {
// file->f_pos=privData->frame_index;
if (((index = get_hist_index(privData->port, privData->subchannel))) <0)
return -ENODEV; // requested combination of port and subchannel does not exist
file->f_pos=privData->frame_index + HISTOGRAM_CACHE_NUMBER * get_hist_index(privData->port, privData->subchannel);
dev_dbg(g_dev_ptr, "Returning %d (0x%x)\n", (int) file->f_pos, (int) file->f_pos);
return file->f_pos;
}
// request histogram(s)
// setFramePar(&framepars[reqFrame & PARS_FRAMES_MASK], reqAddr, 1);
dev_dbg(g_dev_ptr, "setFrameParLocked(%d, &aframepars[%d][0x%x], 0x%lx, 1)\n",
privData->port, privData->port, (int) (reqFrame & PARS_FRAMES_MASK), reqAddr);
setFrameParLocked(privData->port, &aframepars[privData->port][reqFrame & PARS_FRAMES_MASK], reqAddr, 1);
// make sure (harmful) interrupt did not happen since getThisFrameNumber()
if (reqFrame < getThisFrameNumber(privData->port)) {
// setFramePar(&framepars[getThisFrameNumber() & PARS_FRAMES_MASK], reqAddr, 1);
dev_dbg(g_dev_ptr, "setFrameParLocked(%d, &aframepars[%d][0x%lx], 0x%lx, 1)\n",
privData->port, privData->port, getThisFrameNumber(privData->port) & PARS_FRAMES_MASK, reqAddr);
setFrameParLocked(privData->port, &aframepars[privData->port][getThisFrameNumber(privData->port) & PARS_FRAMES_MASK], reqAddr, 1);
}
} else { // debug
dev_dbg(g_dev_ptr, "privData->request_en=0\n");
}
#if 0
if (privData-> wait_mode) wait_event_interruptible (hist_c_wait_queue,GLOBALPARS(privData->port,G_HIST_C_FRAME + privData->subchannel)>=offset);
else wait_event_interruptible (hist_y_wait_queue,GLOBALPARS(privData->port,G_HIST_Y_FRAME + privData->subchannel)>=offset);
#endif
dev_dbg(g_dev_ptr, "Before waiting: frame = 0x%x, offset=0x%x privData-> wait_mode=%d\n",
(int) getThisFrameNumber(privData->port), (int) offset, privData-> wait_mode);
// neded next frame after requested (modify php too?)
if (privData-> wait_mode) wait_event_interruptible (hist_c_wait_queue,getThisFrameNumber(privData->port)>offset);
else wait_event_interruptible (hist_y_wait_queue,getThisFrameNumber(privData->port)>offset);
dev_dbg(g_dev_ptr, "After waiting: frame = 0x%x\n", (int) getThisFrameNumber(privData->port));
privData->frame_index = get_histograms (privData->port, privData->subchannel, offset, privData->needed);
if (privData->frame_index <0) {
return -EFAULT;
} else {
// file->f_pos=privData->frame_index;
file->f_pos=privData->frame_index + HISTOGRAM_CACHE_NUMBER * get_hist_index(privData->port, privData->subchannel);
dev_dbg(g_dev_ptr, "file->f_pos (full histogram number - cache and port/channel combined) = 0x%x\n", (int) file->f_pos);
return file->f_pos;
}
break; // just in case
......@@ -737,7 +830,7 @@ int histograms_init(struct platform_device *pdev) {
int res;
int sz, pages;
struct device *dev = &pdev->dev;
const struct of_device_id *match; // not yet used
// const struct of_device_id *match; // not yet used
// init_histograms(); // Not now??? Need to have list of channels
// Do it later, from the user space
res = register_chrdev(DEV393_MAJOR(DEV393_HISTOGRAM), DEV393_NAME(DEV393_HISTOGRAM), &histograms_fops);
......@@ -759,7 +852,7 @@ int histograms_init(struct platform_device *pdev) {
sz = SENSOR_PORTS * MAX_SENSORS * HISTOGRAM_CACHE_NUMBER * sizeof(struct histogram_stuct_t);
pages = ((sz -1 ) >> PAGE_SHIFT) + 1;
histograms = dma_alloc_coherent(NULL,(pages * PAGE_SIZE),&histograms_phys,GFP_KERNEL);
dev_info(dev, "dma_alloc_coherent(NULL, 0x%x, 0x%x,GFP_KERNEL)",pages * PAGE_SIZE, (int) histograms_phys);
dev_info(dev, "dma_alloc_coherent(NULL, 0x%lx, 0x%x,GFP_KERNEL)", pages * PAGE_SIZE, (int) histograms_phys);
g_dev_ptr = dev; // to use for debug print
return 0;
}
......
......@@ -14,6 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef HISTOGRAMS_H
#define HISTOGRAMS_H
#undef ISR_HISTOGRAMS // to histograms-related disable code in ISR - not needed in NC393
// These wait queues will be advanced each frame after the histogram data is transferred to the FPGA.
// It will happen even if the corresponding task is disabled, with the only exception:
// hist_c_wait_queue will not be awaken in the current frame if it is too late (frame counter incremented while serving tasklet)
......@@ -28,3 +32,4 @@ int get_histograms (int sensor_port, int sensor_chn, unsigned long frame, int ne
//int histograms_init_hardware(void);
void histograms_dma_ctrl(int mode); // 0 - reset, 1 - disable, 2 - enable
#endif
......@@ -690,7 +690,7 @@ static ssize_t imu_write(struct file * file, const char * buf, size_t count, lof
switch ((int) file->private_data) {
case DEV393_MINOR(DEV393_LOGGER) :
case DEV393_MINOR(DEV393_LOGGER_CTRL):
if (!file->f_mode & FMODE_WRITE) {
if (!(file->f_mode & FMODE_WRITE)) {
return -EINVAL; // readonly
}
if (p >= sizeof(wbuf)) return -EINVAL; // bigger than all
......
......@@ -408,7 +408,7 @@ int klogger_393_probe(struct platform_device *pdev)
__func__,buffer_size,buffer_size, (int) klog393_buf);
res = register_chrdev(DEV393_MAJOR(DEV393_KLOGGER), DEV393_NAME(DEV393_KLOGGER), &framepars_fops);
if (res < 0) {
dev_err(dev, "framepars_init: couldn't get a major number %d (DEV393_MAJOR(DEV393_KLOGGER)).\n",
dev_err(dev, "klogger_393_probe: couldn't get a major number %d (DEV393_MAJOR(DEV393_KLOGGER)).\n",
DEV393_MAJOR(DEV393_KLOGGER));
return res;
}
......
......@@ -159,7 +159,7 @@ const unsigned long param_depend_tab[]=
P_SENSOR, ONCHANGE_DETECTSENSOR | ONCHANGE_RECALCSEQ | ONCHANGE_INITSENSOR | ONCHANGE_AFTERINIT | ONCHANGE_MULTISENS | \
ONCHANGE_WINDOW | ONCHANGE_EXPOSURE | ONCHANGE_HIST | ONCHANGE_AEXP | ONCHANGE_FOCUSMODE | ONCHANGE_LIMITFPS | ONCHANGE_HIST | \
ONCHANGE_MEMSENSOR | ONCHANGE_MEMCOMPRESSOR | ONCHANGE_COMPMODE | ONCHANGE_COMPSTOP | ONCHANGE_COMPRESTART ,
P_BAYER , ONCHANGE_SENSORIN ,
P_BAYER , ONCHANGE_SENSORIN, // | ONCHANGE_COMPMODE , // ONCHANGE_COMPMODE added for NC393
P_CLK_FPGA, ONCHANGE_I2C | ONCHANGE_LIMITFPS | ONCHANGE_HIST | \
ONCHANGE_MEMSENSOR | ONCHANGE_MEMCOMPRESSOR | ONCHANGE_COMPMODE | ONCHANGE_COMPSTOP | ONCHANGE_COMPRESTART ,
/// not need ONCHANGE_INITSENSOR | ONCHANGE_AFTERINIT - they will be scheduled by pgm_sensorphase if needed for the sensor
......@@ -207,6 +207,8 @@ const unsigned long param_depend_tab[]=
P_FPNS, ONCHANGE_SENSORIN ,
P_FPNM, ONCHANGE_SENSORIN ,
P_VIRTTRIG, ONCHANGE_SENSORIN ,
P_COMP_BAYER, ONCHANGE_COMPMODE , // NC393 - derivative from P_BAYER, flips, ...
P_MEMSENSOR_DLY, ONCHANGE_SENSORIN ,
P_COMPMOD_BYRSH, ONCHANGE_COMPMODE,
P_COMPMOD_TILSH, ONCHANGE_COMPMODE,
P_COMPMOD_DCSUB, ONCHANGE_COMPMODE,
......
......@@ -641,16 +641,16 @@ int pgm_initsensor (int sensor_port, ///< sensor port number (
vign_hight1.height_m1 = 0;
vign_hight2.height_m1 = 0;
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_gamma_ctrl, gamma_ctl);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_gamma_ctrl, 0x%x)\n",sensor_port, sensor_port, frame16, gamma_ctl.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_gamma_ctrl, 0x%x)\n",sensor_port, frame16, gamma_ctl.d32)
// Enable gamma module to pass through
gamma_ctl.en = 1;
gamma_ctl.en_set = 1;
gamma_ctl.repet = 1;
gamma_ctl.repet_set = 1;
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_gamma_ctrl, gamma_ctl);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_gamma_ctrl, 0x%x)\n",sensor_port, sensor_port, frame16, gamma_ctl.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_gamma_ctrl, 0x%x)\n",sensor_port, frame16, gamma_ctl.d32)
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_gamma_height01m1, gamma_height01m1);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_gamma_height01m1, 0x%x)\n",sensor_port, sensor_port, frame16, gamma_height01m1.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_gamma_height01m1, 0x%x)\n",sensor_port, frame16, gamma_height01m1.d32)
......@@ -670,6 +670,7 @@ int pgm_initsensor (int sensor_port, ///< sensor port number (
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_lens_height2_m1, 0x%x)\n",sensor_port, sensor_port, frame16, vign_hight2.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_lens_height2_m1, 0x%x)\n",sensor_port, frame16, vign_hight2.d32)
// TODO NC393: Setup for all used sub-channels (or is it in multisensor?)
sens_mode.hist_en = 1; // just first subchannel
sens_mode.hist_nrst = 1; // just first subchannel
sens_mode.hist_set = 1;
......@@ -1433,10 +1434,12 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
x393_sensio_width_t sensio_width = {.d32=0};
x393_sens_sync_mult_t sync_mult = {.d32=0};
x393_gamma_ctl_t gamma_ctl = {.d32=0};
int bayer;
int n_scan_lines, n_ph_lines;
int flips;
int bayer_modified;
x393_mcntrl_frame_start_dly_t start_dly ={.d32=0};
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
......@@ -1506,7 +1509,9 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
// Change Bayer for gamma/histograms?
if (bayer_modified) {
gamma_ctl.bayer = thispars->pars[P_BAYER] ^ flips ^ sensor->bayer ^ 3; // 3 added for NC393
bayer = thispars->pars[P_BAYER] ^ flips ^ sensor->bayer ^ 3; // 3 added for NC393;
setFramePar(sensor_port, thispars, P_COMP_BAYER | FRAMEPAIR_FORCE_PROC, bayer);
gamma_ctl.bayer = bayer; // 3 added for NC393
gamma_ctl.bayer_set = 1;
}
//NC393: Other needed bits are set in pgm_initsensor (they must be set just once)
......@@ -1517,6 +1522,13 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_gamma_ctrl, 0x%x)\n",sensor_port, frame16, gamma_ctl.d32)
}
if (FRAMEPAR_MODIFIED(P_MEMSENSOR_DLY) && ((start_dly.start_dly = thispars->pars[P_MEMSENSOR_DLY]))){
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_mcntrl_scanline_start_delay, start_dly);
dev_dbg(g_dev_ptr,"{%d} Setting sensor-to-memory frame sync delay to %ld (0x%lx)\n",sensor_port, start_dly.start_dly,start_dly.start_dly);
MDP(DBGB_PADD, sensor_port,"Setting sensor-to-memory frame sync delay to %ld (0x%lx)\n", start_dly.start_dly,start_dly.start_dly)
}
#if 0
typedef union {
......@@ -1645,15 +1657,18 @@ int pgm_sensorrun (int sensor_port, ///< sensor port number (0..3
///< @return OK - 0, <0 - error
{
int reset_frame;
#ifndef NC353
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
if (frame16 >= PARS_FRAMES) return -EINVAL; // wrong frame
reset_frame = ((prevpars->pars[P_SENSOR_RUN]==0) && (thispars->pars[P_SENSOR_RUN]!=0))? 1:0;
if (thispars->pars[P_SENSOR_RUN] & 3) { // do nothing if stopped, set run/single accordingly
control_sensor_memory (sensor_port,
thispars->pars[P_SENSOR_RUN] & 3,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
thispars->pars[P_SENSOR_RUN] & 3,
reset_frame,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
}
// Is it OK to process stop here too?
return 0;
......@@ -1703,6 +1718,7 @@ int pgm_sensorstop (int sensor_port, ///< sensor port number (0..3
if ((thispars->pars[P_SENSOR_RUN] & 3)==0){ // do nothing if not stop
control_sensor_memory (sensor_port,
thispars->pars[P_SENSOR_RUN] & 3,
0,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
}
......@@ -2215,8 +2231,8 @@ int pgm_compmode (int sensor_port, ///< sensor port number (0..3
// TODO: Modify left margin by 1 for COLORMODE_COLOR !
}
// Bayer shift changed? (additional bayer shift, separate from the gamma-tables one)
if (FRAMEPAR_MODIFIED(P_COMPMOD_BYRSH)) {
cmprs_mode.bayer = thispars->pars[P_COMPMOD_BYRSH];
if (FRAMEPAR_MODIFIED(P_COMPMOD_BYRSH) || FRAMEPAR_MODIFIED(P_COMP_BAYER)) {
cmprs_mode.bayer = thispars->pars[P_COMPMOD_BYRSH] ^ thispars->pars[P_COMP_BAYER];
cmprs_mode.bayer_set = 1;
}
#if 0
......@@ -2727,6 +2743,7 @@ int pgm_comprestart(int sensor_port, ///< sensor port number (0..3
#ifndef NC353
int extra_pages;
int disable_need = 1; // TODO: Use some G_* parameter
int reset_frame;
x393_cmprs_mode_t cmprs_mode = {.d32=0};
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
......@@ -2737,6 +2754,7 @@ int pgm_comprestart(int sensor_port, ///< sensor port number (0..3
(int)thispars->pars[P_COMPRESSOR_RUN])
return 0; // does not need compressor to be started
}
reset_frame = ((prevpars->pars[P_COMPRESSOR_RUN]==0) && (thispars->pars[P_COMPRESSOR_RUN]!=0))? 1:0;
// NC393: memory controller already set by pgm_memcompressor, but we'll need to setup dependent/from memory here
switch(thispars->pars[P_COLOR]){
case COLORMODE_COLOR:
......@@ -2759,15 +2777,20 @@ int pgm_comprestart(int sensor_port, ///< sensor port number (0..3
break;
}
cmprs_mode.run_set = 1;
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode);
if (thispars->pars[P_COMPRESSOR_RUN] == COMPRESSOR_RUN_STOP) { // turn comressor off first
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode);
}
// enable memory after the compressor, same latency
control_compressor_memory (sensor_port,
thispars->pars[P_COMPRESSOR_RUN] & 3, // stop/single/run(/reset)
reset_frame,
extra_pages,
disable_need,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
if (thispars->pars[P_COMPRESSOR_RUN] != COMPRESSOR_RUN_STOP) { // turn comressor on after memory
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode);
}
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_control_reg, 0x%x)\n",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)
......@@ -2828,12 +2851,13 @@ int pgm_compstop (int sensor_port, ///< sensor port number (0..3
// Stop compressor (do not propagate frame sync late, finish current frame)
cmprs_mode.run = X393_CMPRS_CBIT_RUN_DISABLE;
cmprs_mode.run_set = 1;
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode);
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode); // compressor off
// Stop memory -> compressor. Will continue current frame until finished
//TODO NC393: Handle safe/unsafe reprogramming memory at frame syncs - compression can be finished later
control_compressor_memory (sensor_port,
control_compressor_memory (sensor_port, // compressor memory off
COMPRESSOR_RUN_STOP,
0, // reset_frame
extra_pages,
disable_need,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
......@@ -2866,22 +2890,15 @@ int pgm_compctl (int sensor_port, ///< sensor port number (0..3
int extra_pages;
int disable_need = 1; // TODO: Use some G_* parameter
x393_cmprs_mode_t cmprs_mode = {.d32=0};
int reset_frame = 0;
int just_started = 0;
dev_dbg(g_dev_ptr,"{%d} frame16=%d, prevpars->pars[P_COMPRESSOR_RUN]=%d, thispars->pars[P_COMPRESSOR_RUN]=%d \n",
sensor_port,frame16, (int) prevpars->pars[P_COMPRESSOR_RUN], (int) thispars->pars[P_COMPRESSOR_RUN]);
MDP(DBGB_PSFN, sensor_port,"frame16=%d, prevpars->pars[P_COMPRESSOR_RUN]=%d, thispars->pars[P_COMPRESSOR_RUN]=%d \n",
frame16, (int) prevpars->pars[P_COMPRESSOR_RUN], (int) thispars->pars[P_COMPRESSOR_RUN])
if (frame16 >= PARS_FRAMES) return -1; // wrong frame
if ((prevpars->pars[P_COMPRESSOR_RUN]==0) && (thispars->pars[P_COMPRESSOR_RUN]!=0)) { // just started
// Was for NC353
// reset memory controller for the channel2 to the start of the frame
// enable memory channel2 (NOTE: when is it disabled? does it need to be disabled?)
// set number of tiles to compressor
// NC393: memory controller already set by pgm_memcompressor, but we'll need to setup dependent/from memory here
//Seems nothing here?
// Or is there?
}
reset_frame = ((prevpars->pars[P_COMPRESSOR_RUN]==0) && (thispars->pars[P_COMPRESSOR_RUN]!=0))? 1:0;
switch(thispars->pars[P_COLOR]){
case COLORMODE_COLOR:
case COLORMODE_COLOR20:
......@@ -2904,16 +2921,20 @@ int pgm_compctl (int sensor_port, ///< sensor port number (0..3
break;
}
cmprs_mode.run_set = 1;
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode);
// enable memory after the compressor, same latency
if (thispars->pars[P_COMPRESSOR_RUN] == COMPRESSOR_RUN_STOP) { // turn comressor off first
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode);
}
// // enable memory after the compressor, same latency
control_compressor_memory (sensor_port,
thispars->pars[P_COMPRESSOR_RUN] & 3, // stop/single/run(/reset)
extra_pages,
disable_need,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
thispars->pars[P_COMPRESSOR_RUN] & 3, // stop/single/run(/reset)
reset_frame,
extra_pages,
disable_need,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16);
if (thispars->pars[P_COMPRESSOR_RUN] != COMPRESSOR_RUN_STOP) { // turn comressor on after memory
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_control_reg, cmprs_mode);
}
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_control_reg, 0x%x)\n",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)
......
......@@ -535,7 +535,7 @@ inline void updateIRQ_Exif(struct jpeg_ptr_t *jptr, ///< pointer
unsigned char orientation_short[2];
int maker_offset;
u32 frame = jptr->frame;
int frame_index = frame & PASTPARS_SAVE_ENTRIES_MASK;
// int frame_index = frame & PASTPARS_SAVE_ENTRIES_MASK;
// NC393: current parameters are valid at compressor done interrupt (after frame sync interrupts latest valid is new frame number - 2
if (index_time<0) index_time+=get_globalParam (sensor_port, G_CIRCBUFSIZE)>>2;
// struct exif_datetime_t
......@@ -655,11 +655,12 @@ static irqreturn_t frame_sync_irq_handler(int irq, void *dev_id)
{
struct jpeg_ptr_t *jptr = dev_id;
x393_cmdframeseq_mode_t cmdframeseq_mode = {.d32 = 0};
cmdframeseq_mode.interrupt_cmd = IRQ_CLEAR;
unsigned long flags;
int frame16;
u32 aframe;
cmdframeseq_mode.interrupt_cmd = IRQ_CLEAR;
local_irq_save(flags);
u32 aframe = GLOBALPARS(jptr->chn_num, G_THIS_FRAME); // thisFrameNumber(jptr->chn_num); // current absolute frame number
aframe = GLOBALPARS(jptr->chn_num, G_THIS_FRAME); // thisFrameNumber(jptr->chn_num); // current absolute frame number
frame16 = getHardFrameNumber(jptr->chn_num, 0); // Use sensor frame number
updateFramePars (jptr->chn_num,
frame16);
......@@ -728,7 +729,7 @@ void tasklet_compressor_function(unsigned long arg)
{
dma_addr_t phys_addr_start, phys_addr_end;
void *virt_addr_start;
int sensor_port = image_acq_priv.jpeg_ptr[arg].chn_num; // == arg & 3
// int sensor_port = image_acq_priv.jpeg_ptr[arg].chn_num; // == arg & 3
const struct jpeg_ptr_t *jptr = &image_acq_priv.jpeg_ptr[arg];
unsigned int sz;
u32 ccam_dma_size = circbuf_priv_ptr[jptr->chn_num].buf_size;
......@@ -760,10 +761,10 @@ implement 2 modes of controlling when to calculate histograms:
1 - add mask to 3 frame number LSB (i.e. - 0/10000000/10001000/10101010/11111111) - 3 contol bits - en/dis and mode
2 - requested in advance (i.e. by autoexposure when writing new exposure or white balance - when writing balance
mode 1 will provide easy way to display histograms (no need to repetively request them),
mode 1 will provide easy way to display histograms (no need to repeatedly request them),
mode 2 - useful for autoexposure
Modify waiting (LSEEK_*) for histogrames so they will only unfreeze if the histogram is available (skipping multiple frames))
Modify waiting (LSEEK_*) for histograms so they will only unfreeze if the histogram is available (skipping multiple frames))
For displaying histograms - try use latest available - not waiting fro a particular frame.
......@@ -774,19 +775,16 @@ For displaying histograms - try use latest available - not waiting fro a particu
//#define HISTOGRAMS_WAKEUP_ALWAYS 0
void tasklet_cmdseq_function(unsigned long arg)
{
// int is_compressor_irq = 1; // TODO: add interrupts from frame sync if compressor is off
int hist_en;
int sensor_port = image_acq_priv.jpeg_ptr[arg].chn_num; // == arg & 3
int tasklet_disable=get_globalParam(sensor_port, G_TASKLET_CTL);
unsigned long thisFrameNumber=getThisFrameNumber(sensor_port);
#ifdef ISR_HISTOGRAMS
unsigned long prevFrameNumber=thisFrameNumber-1;
unsigned long * hash32p=&(aframepars[sensor_port][(thisFrameNumber-1) & PARS_FRAMES_MASK].pars[P_GTAB_R]); // same gamma for all sub-channels
unsigned long * framep= &(aframepars[sensor_port][(thisFrameNumber-1) & PARS_FRAMES_MASK].pars[P_FRAME]);
// const struct jpeg_ptr_t *jptr = &image_acq_priv.jpeg_ptr[arg];
// dma_addr_t phys_addr_start, phys_addr_end;
// void *virt_addr_start;
// unsigned int sz;
int subchn,hist_indx;
#endif
// Time is out?
......@@ -817,8 +815,11 @@ void tasklet_cmdseq_function(unsigned long arg)
default: // calculate always (safer)
hist_en=1;
}
// Actually in NC393 nothing has to be done with histograms at interrupts - do all the processing when histograms are requested
//#ifdef TEST_DISABLE_CODE
if (hist_en) {
#ifdef ISR_HISTOGRAMS
histograms_check_init(); // check if histograms are initialized and initialize if not (structures and hardware)
// after updateFramePars gammaHash are from framepars[this-1]
for (subchn=0;subchn<MAX_SENSORS;subchn++) if (((hist_indx=get_hist_index(sensor_port,subchn)))>=0){
......@@ -842,12 +843,12 @@ void tasklet_cmdseq_function(unsigned long arg)
dev_dbg(g_dev_ptr, "%s : port= %d, === already next frame (1)\n", __func__, sensor_port);
return; // already next frame
}
#endif // ifdef ISR_HISTOGRAMS
#if HISTOGRAMS_WAKEUP_ALWAYS
}
wake_up_interruptible(&hist_y_wait_queue); // wait queue for the G1 histogram (used as Y)
#else
wake_up_interruptible(&hist_y_wait_queue); // wait queue for the G1 histogram (used as Y)
wake_up_interruptible(&hist_y_wait_queue); // wait queue for the G1 histogram (used as Y)
}
#endif
// Process parameters
......@@ -882,6 +883,7 @@ void tasklet_cmdseq_function(unsigned long arg)
hist_en=1;
}
if (hist_en) {
#ifdef ISR_HISTOGRAMS
histograms_check_init(); // check if histograms are initialized and initialize if not (structures and hardware)
// after updateFramePars gammaHash are from framepars[this-1]
// after updateFramePars gammaHash are from framepars[this-1]
......@@ -904,6 +906,7 @@ void tasklet_cmdseq_function(unsigned long arg)
dev_dbg(g_dev_ptr, "%s : port= %d, === already next frame (1)\n", __func__, sensor_port);
return; // already next frame
}
#endif // ifdef ISR_HISTOGRAMS
#if HISTOGRAMS_WAKEUP_ALWAYS
}
wake_up_interruptible(&hist_c_wait_queue); // wait queue for all the other (R,G2,B) histograms (color)
......@@ -1141,7 +1144,6 @@ int image_acq_init(struct platform_device *pdev)
dev_info(dev, "reset_qtables(0) (policy = COMMON_CACHE)\n");
set_cache_policy(COMMON_CACHE);
reset_qtables(0); // force initialization at next access (with COMMON_CACHE chyannel is ignored, with PER_CHN_CACHE - do for each chennel)
// framepars_init(pdev);
pgm_functions_set_device(dev);
g_dev_ptr = dev;
return 0;
......
......@@ -190,7 +190,7 @@ int is_fpga_programmed(void) ///< @return 0 - bitstream is NOT loaded, 1 - bitst
if (!zynq_devcfg_ptr){
zynq_devcfg_ptr = ioremap(0xf8007000, 0x00010000);
if (!zynq_devcfg_ptr)
return -ENOMEM;
return 0; // -ENOMEM;
}
return (readl(zynq_devcfg_ptr + 0x000c) & 4)? 1: 0;
}
......@@ -125,6 +125,8 @@ int setup_sensor_memory (int num_sensor, ///< sensor port number (0..3)
/** Control (stop/single/run/reset) memory controller for a sensor channel */
int control_sensor_memory (int num_sensor, ///< sensor port number (0..3)
int cmd, ///< command: 0 stop, 1 - single, 2 - repetitive, 3 - reset
int reset_frame, ///< reset addresses to the start of frame, reset buffer (1 of 4) pointer.
///< Should only be used if the channel controller was stopped before
x393cmd_t x393cmd, ///< how to apply commands - directly or through channel sequencer
int frame16) ///< Frame number the command should be applied to (if not immediate mode)
///< @return 0 -OK
......@@ -140,7 +142,9 @@ int control_sensor_memory (int num_sensor, ///< sensor port number (0..3)
.single = 0, // [ 9] (0) run single frame
.repetitive = 1, // [ 10] (1) run repetitive frames
.disable_need = 0, // [ 11] (0) disable 'need' generation, only 'want' (compressor channels)
.skip_too_late = 1}; // [ 12] (0) Skip over missed blocks to preserve frame structure (increment pointers)
.skip_too_late = 1, // [ 12] (0) Skip over missed blocks to preserve frame structure (increment pointers)
.abort_late = 1};// [ 14] (0) abort frame if not finished by the new frame sync (wait pending memory transfers)
mcntrl_mode.reset_frame = reset_frame;
switch (cmd){
case SENSOR_RUN_STOP:
mcntrl_mode.enable = 0;
......@@ -192,7 +196,6 @@ int control_sensor_memory (int num_sensor, ///< sensor port number (0..3)
return 0;
}
/** Setup memory controller for a compressor channel */
int setup_compressor_memory (int num_sensor, ///< sensor port number (0..3)
int window_width, ///< 13-bit - in 8*16=128 bit bursts
......@@ -285,26 +288,30 @@ int setup_compressor_memory (int num_sensor, ///< sensor port number (0..3
/** Control memory controller (stop/single/run/reset) for a compressor channel */
int control_compressor_memory (int num_sensor, ///< sensor port number (0..3)
int cmd, ///< command: 0 stop, 1 - single, 2 - repetitive, 3 - reset
int reset_frame, ///< reset addresses to the start of frame, reset buffer (1 of 4) pointer.
///< Should only be used if the channel controller was stopped before
int extra_pages, ///< extra pages needed (1) - number of previous pages to keep in a 4-page buffer
int disable_need, ///< disable "need" (yield to sensor channels - they can not wait)
x393cmd_t x393cmd, ///< how to apply commands - directly or through channel sequencer
int frame16) ///< Frame number the command should be applied to (if not immediate mode)
///< @return 0 - OK
{
x393_mcntrl_mode_scan_t mcntrl_mode = {.enable = 1, // [ 0] (1) enable requests from this channel ( 0 will let current to finish, but not raise want/need)
.chn_nreset = 1, // [ 1] (1) 0: immediately reset all the internal circuitry
x393_mcntrl_mode_scan_t mcntrl_mode = {.chn_nreset = 1, // [ 0] (1) 0: immediately reset all the internal circuitry
.enable = 1, // [ 1] (1) enable requests from this channel ( 0 will let current to finish, but not raise want/need)
.write_mem = 0, // [ 2] (0) 0 - read from memory, 1 - write to memory
.extra_pages = 1, // [ 4: 3] (0) 2-bit number of extra pages that need to stay (not to be overwritten) in the buffer
.keep_open = 0, // [ 5] (0) (NA in linescan) for 8 or less rows - do not close page between accesses (not used in scanline mode)
.byte32 = 1, // [ 6] (1) (NA in linescan) 32-byte columns (0 - 16-byte), not used in scanline mode
.reset_frame = 0, // [ 8] (0) reset frame number
.reset_frame = 1, // [ 8] (0) reset frame number
.single = 0, // [ 9] (0) run single frame
.repetitive = 1, // [ 10] (1) run repetitive frames
.disable_need = 1, // [ 11] (0) disable 'need' generation, only 'want' (compressor channels)
.skip_too_late = 1};// [ 12] (0) Skip over missed blocks to preserve frame structure (increment pointers)
mcntrl_mode.disable_need = disable_need; // non-constant parameter
mcntrl_mode.extra_pages = extra_pages; // non-constant parameter
.skip_too_late = 1, // [ 12] (0) Skip over missed blocks to preserve frame structure (increment pointers)
.copy_frame = 1, // [ 13] (0) Copy frame number from the master (sensor) channel. Combine with reset_frame to reset bjuffer
.abort_late = 1};// [ 14] (0) abort frame if not finished by the new frame sync (wait pending memory transfers)
mcntrl_mode.disable_need = disable_need;
mcntrl_mode.extra_pages = extra_pages;
mcntrl_mode.reset_frame = reset_frame;
switch (cmd){
case COMPRESSOR_RUN_STOP:
mcntrl_mode.enable = 0;
......
......@@ -25,14 +25,14 @@ struct elphel_video_buf_t
int frames_in_buffer[4]; ///< Number of frames in channel 0 buffer
};
int setup_sensor_memory (int num_sensor, int window_width, int window_height, int window_left,
int window_top, x393cmd_t x393cmd, int frame16);
int control_sensor_memory (int num_sensor, int cmd, x393cmd_t x393cmd, int frame16);
int setup_sensor_memory (int num_sensor, int window_width, int window_height, int window_left,
int window_top, x393cmd_t x393cmd, int frame16);
int control_sensor_memory (int num_sensor, int cmd, int reset_frame, x393cmd_t x393cmd, int frame16);
int setup_compressor_memory (int num_sensor, int window_width, int window_height, int window_left,
int window_top, int tile_width, int tile_height, int tile_vstep,
x393cmd_t x393cmd, int frame16);
int control_compressor_memory (int num_sensor, int cmd, int extra_pages, int disable_need, x393cmd_t x393cmd, int frame16);
int control_compressor_memory (int num_sensor, int cmd, int reset_frame, int extra_pages, int disable_need, x393cmd_t x393cmd, int frame16);
int frames_in_buffer_minus_one (int num_sensor);
void memchan_enable (int chn, int enable);
......
......@@ -306,7 +306,7 @@
<li> bit 3 - no overlap, single frames: program - acquire/compress same frame</ul>*/
#define P_BGFRAME 16 ///< Background measurement mode - will use 16-bit mode and no FPN correction
//#define P_IMGSZMEM 17 ///< image size in video memory (calculated when channel 0 is programmed) NC393: Not used ???
#define P_COMP_BAYER 17 ///< derivative, readonly - calculated from P_BAYER and COMPMOD_BYRSH to separate sensor and compressor channels
//#define P_COMP_BAYER 17 ///< -> 119 derivative, readonly - calculated from P_BAYER and COMPMOD_BYRSH to separate sensor and compressor channels
// image page numbers depend on image size/pixel depth, so changing any of them will invalidate all pages
#define P_PAGE_ACQ 18 ///< Number of image page buffer to acquire to (0.1?) NC393: Not used ???
#define P_PAGE_READ 19 ///< Number of image page buffer to read from to (0.1?) NC393: Not used ???
......@@ -458,6 +458,8 @@
#define P_RFOCUS_TOP 117 ///< relative (0x10000 - 1.0)focus WOI top margin, inclusive (3 LSB will be zeroed as it should be multiple of 8x8 block height)
#define P_RFOCUS_HEIGHT 118 ///< relative (0x10000 - 1.0)focus WOI height (3 LSB will be zeroed as it should be multiple of 8x8 block height)
#define P_COMP_BAYER 119 ///< compressor bayer (before applying P_COMPMOD_BYRSH)
#define P_MEMSENSOR_DLY 120 ///< sensor-to-memory channel frame sync delay in mclk cycles (5ns @200MHz)
// Obsolete in x393, may need something different
#ifdef NC353
#define P_SDRAM_CHN20 125 ///< data to be written to the SDRAM CH2 REG 0 (last moment) TODO: Obsolete in x393, may need something different
......@@ -501,7 +503,7 @@
// the following 8 values should go in the same sequence as fields in the histogram page
// 393: per sub-channel
//// Will need to have them per-subchannel (4x)
//Next 8 copied to histograms data
#define P_FRAME 136 ///< Frame number (reset with JPEG pointers) -(read only)
#define P_GAINR 137 ///< R channel gain 8.16 (0x10000 - 1.0). Combines both analog gain and digital scaling
#define P_GAING 138 ///< G channel gain ("red line")
......@@ -510,6 +512,7 @@
#define P_EXPOS 141 ///< P_RW_EXPOS 1 exposure time - now in microseconds?
#define P_VEXPOS 142 ///< video exposure (if 0 - use P_RW_EXPOS in ms)
#define P_FOCUS_VALUE 143 ///< (readonly) - sum of all blocks focus values inside focus WOI
#define P_COMPMOD_BYRSH 144 ///< Bayer shift in compressor
#define P_PORTRAIT 145 ///< Quantization coefficients optimized for vertical scan lines
......@@ -678,7 +681,8 @@
#define GLOBALS_PRESERVE 0x20 /// number of parameters that are not erased during initGlobalPars
#define GLOBALPARS(p, x) (aglobalPars[p][(x)-FRAMEPAR_GLOBALS]) ///< should work in drivers and applications, First 32 parameter values are not erased with initGlobalPars
#define GLOBALPARS(p, x) (aglobalPars[p][(x)-FRAMEPAR_GLOBALS]) ///< should work in drivers and applications, First 32 parameter values are not erased with initGlobalPars
#define GLOBALPARS_SNGL(x) (globalPars[(x)-FRAMEPAR_GLOBALS]) ///< for applications that use just one port
#define G_DEBUG (FRAMEPAR_GLOBALS + 2) ///< Each bit turns on/off some debug outputs
#define G_TEST_CTL_BITS (FRAMEPAR_GLOBALS + 3) ///< turn some features on/off in the drivers for debugging purposes
......@@ -879,7 +883,8 @@
/// if defined 1 - will wakeup each frame, regardless of the availability of the histograms
#define HISTOGRAMS_WAKEUP_ALWAYS 0
//#define HISTOGRAMS_WAKEUP_ALWAYS 0
#define HISTOGRAMS_WAKEUP_ALWAYS 1
/// Number of frames handled in the buffer (increased to 16 for NC393).
///
......@@ -1074,7 +1079,6 @@ struct p_names_t {
P_NAME_ENTRY(TRIG), \
P_NAME_ENTRY(EXPOS), \
P_NAME_ENTRY(BGFRAME), \
P_NAME_ENTRY(COMP_BAYER), \
P_NAME_ENTRY(PAGE_ACQ), \
P_NAME_ENTRY(PAGE_READ), \
P_NAME_ENTRY(OVERLAP), \
......@@ -1190,6 +1194,8 @@ struct p_names_t {
P_NAME_ENTRY(RFOCUS_WIDTH), \
P_NAME_ENTRY(RFOCUS_TOP), \
P_NAME_ENTRY(RFOCUS_HEIGHT), \
P_NAME_ENTRY(COMP_BAYER), \
P_NAME_ENTRY(MEMSENSOR_DLY), \
P_NAME_ENTRY(SENSOR_IFACE_TIM0), \
P_NAME_ENTRY(SENSOR_IFACE_TIM1), \
P_NAME_ENTRY(SENSOR_IFACE_TIM2), \
......
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