Commit e2386cf2 authored by Andrey Filippov's avatar Andrey Filippov

debugging histograms, testing with ported camvc

parent 385eb407
......@@ -99,7 +99,7 @@ int init_ccam_dma_buf_ptr(struct platform_device *pdev)
circbuf_priv[i].phys_addr = dma_handle + CIRCBUF_START_OFFSET + i * CCAM_DMA_SIZE;
circbuf_priv[i].buf_size = CCAM_DMA_SIZE;
circbuf_priv[i].buf_size32 = circbuf_priv[i].buf_size; // used in many places
circbuf_priv[i].buf_size32 = circbuf_priv[i].buf_size>>2; // used in many places
ccam_dma_buf_ptr[i] = circbuf_priv[i].buf_ptr;
// set circular buffer size in bytes
set_globalParam(i, G_CIRCBUFSIZE, circbuf_priv[i].buf_size);
......@@ -318,7 +318,7 @@ int circbuf_open(struct inode *inode, struct file *filp)
{
unsigned int minor = MINOR(inode->i_rdev);
inode->i_size = circbuf_priv[minor_to_chn(minor, NULL)].buf_size; // CCAM__DMA_SIZE;
dev_dbg(g_dev_ptr, "inode->i_size = 0x%lx\n", inode->i_size);
dev_dbg(g_dev_ptr, "inode->i_size = 0x%llx\n", inode->i_size);
return 0;
}
......@@ -391,10 +391,10 @@ int circbuf_valid_ptr(loff_t *rp_offset, struct interframe_params_t **fpp, unsig
{
int rp = *rp_offset;
int last_image_chunk;
unsigned int sec;
unsigned int usec;
// unsigned int sec;
// unsigned int usec;
int wp = camseq_get_jpeg_wp(chn);
unsigned int len32 = get_image_length(DW2BYTE(wp), chn, &last_image_chunk);
// unsigned int len32 = get_image_length(DW2BYTE(wp), chn, &last_image_chunk);
struct interframe_params_t *fp, *fp_off;
if (rp & 0x1f) {
......@@ -445,13 +445,14 @@ int circbufValidPointer(int rp,
struct interframe_params_t ** fpp,
unsigned int chn)
{
struct interframe_params_t * fp;
int wp, p;
if (rp & 0x1f) { //!rp is not 32-bytes aligned
dev_dbg(g_dev_ptr, "circbufValidPointer: misaligned pointer\n");
return -2;
}
int wp=camSeqGetJPEG_wp(chn);
int p= rp >> 2; // index in ccam_dma_buf
struct interframe_params_t * fp;
wp=camSeqGetJPEG_wp(chn);
p= rp >> 2; // index in ccam_dma_buf
fp = (struct interframe_params_t *) &circbuf_priv[chn].buf_ptr[X393_BUFFSUB32(p, 8, chn)]; // 32 bytes before the frame pointer, may roll-over to the end of ccam_dma_buf
dev_dbg(g_dev_ptr, "rp=0x%x (0x%x), offset=0x%x\n",
......@@ -461,10 +462,27 @@ int circbufValidPointer(int rp,
*fpp=fp;
dev_dbg(g_dev_ptr, "p=0x%x , wp==0x%x\n",p,wp);
if (p == wp) {
dev_dbg(g_dev_ptr, "circbufValidPointer: frame not yet acquired, fp - not valid\n");
return 0; // frame not yet acquired, fp - not valid
}
if (fp->signffff != 0xffff) { //! signature is overwritten
dev_dbg(g_dev_ptr, "circbufValidPointer: signanure overwritten\n");
int i;
dev_dbg(g_dev_ptr, "circbufValidPointer: signature overwritten\n");
dev_dbg(g_dev_ptr, "wp = 0x%x, p=0x%x\n",wp,p);
for (i=p-16; i<p+8; i+=8){
dev_dbg(g_dev_ptr, "%06x: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
i, circbuf_priv[chn].buf_ptr[i+0], circbuf_priv[chn].buf_ptr[i+1], circbuf_priv[chn].buf_ptr[i+2], circbuf_priv[chn].buf_ptr[i+3],
circbuf_priv[chn].buf_ptr[i+4], circbuf_priv[chn].buf_ptr[i+5], circbuf_priv[chn].buf_ptr[i+6], circbuf_priv[chn].buf_ptr[i+7]);
}
for (i=wp-16; i<wp+8; i+=8){
dev_dbg(g_dev_ptr, "%06x: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
i, circbuf_priv[chn].buf_ptr[i+0], circbuf_priv[chn].buf_ptr[i+1], circbuf_priv[chn].buf_ptr[i+2], circbuf_priv[chn].buf_ptr[i+3],
circbuf_priv[chn].buf_ptr[i+4], circbuf_priv[chn].buf_ptr[i+5], circbuf_priv[chn].buf_ptr[i+6], circbuf_priv[chn].buf_ptr[i+7]);
}
dev_dbg(g_dev_ptr, "circbuf_priv_ptr[%d].buf_size=0x%lx, circbuf_priv_ptr[%d].buf_size32=0x%lx\n",
chn,circbuf_priv_ptr[chn].buf_size, chn,circbuf_priv_ptr[chn].buf_size32);
return -1;
}
if ((fp->timestamp_sec) & X313_LENGTH_MASK) {
......@@ -875,6 +893,11 @@ loff_t circbuf_lseek(struct file * file, loff_t offset, int orig) {
case LSEEK_CIRC_LAST:
file->f_pos=camSeqGetJPEG_wp(chn)<<2;
fvld=circbufValidPointer(file->f_pos, &fp, chn); //!set fp
if (fvld <0 ){
dev_dbg(g_dev_ptr, "*** LSEEK_CIRC_LAST: invalid pointer rp=0x%x, fvld=%d, fl=0x%x\n",
(int) (file->f_pos >> 2), (int)fvld,(int)circbuf_priv[chn].buf_ptr[X393_BUFFSUB32(rp, 9, chn)] ^ X313_LENGTH_MASK);
}
case LSEEK_CIRC_PREV:
rp= file->f_pos >> 2;
fl=circbuf_priv[chn].buf_ptr[X393_BUFFSUB32(rp, 9, chn)] ^ X313_LENGTH_MASK;
......
......@@ -110,11 +110,12 @@ static struct exif_datetime_t {
static int exif_open (struct inode *inode, struct file *filp);
static int exif_release(struct inode *inode, struct file *filp);
static loff_t exif_lseek (struct file * file, loff_t offset, int orig);
static ssize_t exif_write (struct file * file, const char * buf, size_t count, loff_t *off);
static ssize_t exif_read (struct file * file, char * buf, size_t count, loff_t *off);
int exif_open (struct inode *inode, struct file *filp);
int exif_release(struct inode *inode, struct file *filp);
loff_t exif_lseek (struct file * file, loff_t offset, int orig);
ssize_t exif_write (struct file * file, const char * buf, size_t count, loff_t *off);
ssize_t exif_read (struct file * file, char * buf, size_t count, loff_t *off);
static int __init exif_init(void);
static struct file_operations exif_fops = {
......@@ -357,7 +358,9 @@ int putlong_meta(int sensor_port, unsigned long data, int * indx, unsigned long
*/
char * encode_time(char buf[27], unsigned long sec, unsigned long usec) {
unsigned long s,d,m,y,y4,lp,h;
spin_lock_bh(&lock);
unsigned long flags;
spin_lock_irqsave(&lock,flags);
if (((sec-exif_time.today_sec)>86400) || (sec < exif_time.today_sec)) {// today's time is not valid, try tomorrow:
memcpy(&exif_time.today_date[0],&exif_time.tomorrow_date[0],sizeof(exif_time.today_date)+sizeof(exif_time.today_sec));
if (((sec-exif_time.today_sec)>86400) || (sec < exif_time.today_sec)) {// today's time is _still_ not valid, has to do it itself :-(
......@@ -416,13 +419,14 @@ char * encode_time(char buf[27], unsigned long sec, unsigned long usec) {
sprintf(&now_datetime.subsec[0],"%06ld",usec);
memcpy(buf,&now_datetime.datetime[0],sizeof(now_datetime));
// return &now_datetime.datetime[0];
spin_unlock_bh(&lock);
spin_unlock_irqrestore(&lock,flags);
return buf;
}
int store_meta(int sensor_port) { //called from IRQ service - put current metadata to meta_buffer, return page index
int meta_index;
if (!aexif_enabled[sensor_port]) return 0;
int meta_index=aexif_wp[sensor_port];
meta_index=aexif_wp[sensor_port];
memcpy(&ameta_buffer[sensor_port][meta_index * aexif_meta_size[sensor_port]], ameta_buffer[sensor_port], aexif_meta_size[sensor_port]);
aexif_wp[sensor_port]++;
if (aexif_wp[sensor_port] > MAX_EXIF_FRAMES) aexif_wp[sensor_port] = 1;
......@@ -431,7 +435,8 @@ int store_meta(int sensor_port) { //called from IRQ service - put current metada
//!++++++++++++++++++++++++++++++++++++ open() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
static int exif_open(struct inode *inode, struct file *filp) {
//static
int exif_open(struct inode *inode, struct file *filp) {
int p = MINOR(inode->i_rdev);
int * pd= (int *) &(filp->private_data);
switch (p) {
......@@ -458,7 +463,8 @@ static int exif_open(struct inode *inode, struct file *filp) {
//!++++++++++++++++++++++++++++++++++++ release() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
static int exif_release(struct inode *inode, struct file *filp){
//static
int exif_release(struct inode *inode, struct file *filp){
int p = MINOR(inode->i_rdev);
int * pd= (int *) &(filp->private_data);
switch (p) {
......@@ -489,13 +495,14 @@ static int exif_release(struct inode *inode, struct file *filp){
//!++++++++++++++++++++++++++++++++++++ lseek() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
static loff_t exif_lseek (struct file * file, loff_t offset, int orig) {
//static
loff_t exif_lseek (struct file * file, loff_t offset, int orig) {
int p=(int)file->private_data;
int thissize=minor_file_size(p);
int maxsize=minor_max_size(p);
// int fp;
dev_dbg(g_devfp_ptr,"exif_lseek, minor=%d, offset = 0x%llx, orig=%d\n",p,offset,orig);
// int sensor_port;
int fp;
switch (orig) {
case SEEK_SET:
file->f_pos = offset;
......@@ -584,7 +591,8 @@ static loff_t exif_lseek (struct file * file, loff_t offset, int orig) {
//!++++++++++++++++++++++++++++++++++++ write() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
static ssize_t exif_write (struct file * file, const char * buf, size_t count, loff_t *off) {
//static
ssize_t exif_write (struct file * file, const char * buf, size_t count, loff_t *off) {
int p=(int)file->private_data;
int sensor_port;
// int thissize=minor_file_size(p);
......@@ -644,7 +652,8 @@ static ssize_t exif_write (struct file * file, const char * buf, size_t coun
//!++++++++++++++++++++++++++++++++++++ read() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
static ssize_t exif_read (struct file * file, char * buf, size_t count, loff_t *off) {
//static
ssize_t exif_read (struct file * file, char * buf, size_t count, loff_t *off) {
int p=(int)file->private_data;
int thissize=minor_file_size(p);
char * cp, * metap;
......
......@@ -230,7 +230,7 @@ loff_t histograms_lseek (struct file * file, loff_t offset, int orig);
int histograms_mmap (struct file *file, struct vm_area_struct *vma);
inline void histogram_calc_cumul ( unsigned long * hist, unsigned long * cumul_hist );
inline unsigned long histogram_calc_cumul ( unsigned long * hist, unsigned long * cumul_hist );
inline void histogram_calc_percentiles ( unsigned long * cumul_hist, unsigned char * percentile);
/** Initialize FPGA DMA engine for histograms. Obviously requires bitstream to be loaded.
......@@ -393,7 +393,8 @@ int set_histograms (int sensor_port, ///< sensor port number (0..3)
return 0;
// Copying received data to histograms structure, maybe later we can skip that step and use data in place
// hist_frame=(frame-1) & PARS_FRAMES_MASK; // TODO: Verify
hist_frame=frame & PARS_FRAMES_MASK; // TODO: Verify
// hist_frame=frame & PARS_FRAMES_MASK; // TODO: Verify
hist_frame=(frame + (GLOBALPARS(sensor_port, G_HIST_SHIFT))) & PARS_FRAMES_MASK; // TODO: Verify
for (i=0; i<4; i++) if (needed & ( 1 << i )) {
u32 phys_addr= fpga_hist_phys + PAGE_SIZE*(hist_frame + PARS_FRAMES * (sensor_chn + MAX_SENSORS *sensor_port)) + i*256*sizeof(u32); // start of selected color
u32 * dma_data = &fpga_hist_data[sensor_port][sensor_chn][hist_frame][i][0];
......@@ -446,6 +447,7 @@ int get_histograms(int sensor_port, ///< sensor port number (0..3)
unsigned long thisFrameNumber=getThisFrameNumber(sensor_port);
unsigned long * gammaHash;
unsigned long * framep;
unsigned long dbg_sum;
if (hist_indx <0 ) return -EINVAL;
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",
......@@ -487,7 +489,8 @@ int get_histograms(int sensor_port, ///< sensor port number (0..3)
if (needed & 0xf0) { // Calculating cumulative histograms
for (i=0; i<4; i++) if (needed & ( 0x10 << i )) {
color_start= i<<8 ;
histogram_calc_cumul ( (unsigned long *) &histograms[hist_indx][index].hist[color_start], (unsigned long *) &histograms[hist_indx][index].cumul_hist[color_start] );
dbg_sum = histogram_calc_cumul ( (unsigned long *) &histograms[hist_indx][index].hist[color_start], (unsigned long *) &histograms[hist_indx][index].cumul_hist[color_start] );
dev_dbg(g_dev_ptr, "frame: 0x%lx (now 0x%lx) color:%d, pixel sum=0x%08lx\n",frame, thisFrameNumber, i, dbg_sum);
histograms[hist_indx][index].valid |= 0x10 << i;
}
dev_dbg(g_dev_ptr, "needed=0x%x, valid=0x%lx\n",needed,histograms[hist_indx][index].valid);
......@@ -504,12 +507,14 @@ int get_histograms(int sensor_port, ///< sensor port number (0..3)
}
/** Calculate cumulative histogram (one color component) from the corresponding raw histogram */
inline void histogram_calc_cumul ( unsigned long * hist, ///< input raw histogram array of unsigned long, single color (256)
unsigned long * cumul_hist) ///< output cumulative histogram array of unsigned long, single color (256)
inline unsigned long histogram_calc_cumul ( unsigned long * hist, ///< input raw histogram array of unsigned long, single color (256)
unsigned long * cumul_hist) ///< output cumulative histogram array of unsigned long, single color (256)
///< @return sum of all pixels (last value)
{
int i;
cumul_hist[0]=hist[0];
for (i=1; i<256;i++) cumul_hist[i]=cumul_hist[i-1]+hist[i];
return cumul_hist[255];
}
/**
......@@ -663,17 +668,19 @@ loff_t histograms_lseek (struct file * file,
case DEV393_MINOR(DEV393_HISTOGRAM) :
switch(orig) {
case SEEK_CUR: // ignore offset - in NC353 it was get latest?
offset = -1; // for now - just make "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
offset+=getThisFrameNumber(privData->port); // get relative to current frame (-1 - latest)
//no break (CDT understands this)
case SEEK_SET: // negative - make latest?
case SEEK_SET: // negative - make relative to current (-1 - latest, -2 - before latest - up to 15 before)
if (offset <0){
dev_dbg(g_dev_ptr, "offset= %lld (0x%llx) changing to previous frame \n",offset,offset);
offset = getThisFrameNumber(privData->port) -1;
offset += getThisFrameNumber(privData->port);
}
privData->frame=offset;
// Try to make some precautions to avoid waiting forever - if the past frame is requested - request histogram for the current frame,
......
......@@ -42,6 +42,17 @@
//#define DEV393_KLOGGER ("klogger_393", "klogger_393", 144, 1, "0666", "c") ///< kernel event logger to memory (no i/o)
#ifdef LOCK_BH_KLOGGER
#define FLAGS_KLOGGER_BH
#define LOCK_KLOGGER_BH(x) spin_lock_bh(x)
#define UNLOCK_KLOGGER_BH(x) spin_unlock_bh(x)
#else
#define FLAGS_KLOGGER_BH unsigned long flags;
#define LOCK_KLOGGER_BH(x) spin_lock_irqsave(x,flags)
#define UNLOCK_KLOGGER_BH(x) spin_unlock_irqrestore(x,flags)
#endif
static DEFINE_SPINLOCK(klogger_lock);
static struct device *g_dev_ptr=NULL; ///< Global pointer to basic device structure. This pointer is used in debugfs output functions
......@@ -72,6 +83,7 @@ int print_klog393(const int mode, ///< bits 0: timestamp, 1 - file, 2 - fu
const char *fmt, ...) ///< Format and argumants as in printf
{
FLAGS_KLOGGER_BH
char buf[1024];
const char * cp;
sec_usec_t ts;
......@@ -81,7 +93,8 @@ int print_klog393(const int mode, ///< bits 0: timestamp, 1 - file, 2 - fu
return 0;
}
if (mmode & 16){
spin_lock_bh(&klogger_lock);
// spin_lock_bh(&klogger_lock);
LOCK_KLOGGER_BH(&klogger_lock);
}
if (mmode & 1) {
get_fpga_rtc(&ts);
......@@ -107,7 +120,8 @@ int print_klog393(const int mode, ///< bits 0: timestamp, 1 - file, 2 - fu
va_end(args);
klog393_puts(buf);
if (mmode & 16){
spin_unlock_bh(&klogger_lock);
// spin_unlock_bh(&klogger_lock);
UNLOCK_KLOGGER_BH(&klogger_lock);
}
return 0;
......
......@@ -1867,8 +1867,8 @@ int pgm_hist (int sensor_port, ///< sensor port number (0..3
// set these values to FPGA
left_top.left = hist_setup_data.left;
left_top.top = hist_setup_data.top;
width_height.width_m1 = hist_setup_data.width-2;
width_height.height_m1 = hist_setup_data.height-2;
width_height.width_m1 = hist_setup_data.width-1;
width_height.height_m1 = hist_setup_data.height-1;
X393_SEQ_SEND1S (sensor_port, frame16, x393_histogram_lt, left_top, sub_chn);
X393_SEQ_SEND1S (sensor_port, frame16, x393_histogram_wh, width_height,sub_chn);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1S(0x%x, 0x%x, x393_histogram_lt, 0x%x, %d)\n",
......
......@@ -34,6 +34,9 @@
#include <asm/outercache.h>
#include <asm/cacheflush.h>
#include <linux/spinlock.h>
#include <uapi/elphel/c313a.h>
#include <uapi/elphel/exifa.h>
//#include <uapi/elphel/x393_devices.h>
......@@ -56,6 +59,23 @@
// NC393 debug macros
#include "debug393.h"
static DEFINE_SPINLOCK(framepars_irq_0); ///<
static DEFINE_SPINLOCK(framepars_irq_1); ///<
static DEFINE_SPINLOCK(framepars_irq_2); ///<
static DEFINE_SPINLOCK(framepars_irq_3); ///<
/** Define array of pointers to locks - hardware allows concurrent writes to different ports tables */
spinlock_t * frame_irq_locks[4] = {&framepars_irq_0, &framepars_irq_1, &framepars_irq_2, &framepars_irq_3};
static DEFINE_SPINLOCK(compressor_irq_0); ///<
static DEFINE_SPINLOCK(compressor_irq_1); ///<
static DEFINE_SPINLOCK(compressor_irq_2); ///<
static DEFINE_SPINLOCK(compressor_irq_3); ///<
/** Define array of pointers to locks - hardware allows concurrent writes to different ports tables */
spinlock_t * compressor_locks[4] = {&compressor_irq_0, &compressor_irq_1, &compressor_irq_2, &compressor_irq_3};
/* Driver name to display in log messages.*/
//#define IMAGEACQ_DRIVER_DESCRIPTION "Elphel (R) Model 393 Image Acquisition device driver"
......@@ -342,14 +362,7 @@ static inline int updateIRQJPEG_wp(struct jpeg_ptr_t *jptr)
// Find absolute frame number just compressed WRONG, should use comressor frame number
// cmdseqmux_status = x393_cmdseqmux_status(); // CMDSEQMUX status data (frame numbers and interrupts
frame16 = getHardFrameNumber(jptr->chn_num, 1); // Use compressor
#if 0
switch (jptr->chn_num){
case 0: frame16 =cmdseqmux_status.frame_num0; break;
case 1: frame16 =cmdseqmux_status.frame_num1; break;
case 2: frame16 =cmdseqmux_status.frame_num2; break;
default: frame16 =cmdseqmux_status.frame_num3;
}
#endif
if (frame16 > (aframe & PARS_FRAMES_MASK))
aframe -= 16;
jptr->frame = (aframe & ~PARS_FRAMES_MASK) | frame16; // This is absolute compressed frame number, may lag behind current one
......@@ -361,58 +374,6 @@ static inline int updateIRQJPEG_wp(struct jpeg_ptr_t *jptr)
if (zero_counter[jptr->chn_num] < 1000)
frame_pos[jptr->chn_num][zero_counter[jptr->chn_num] - 1] = frame_counter[jptr->chn_num];
}
/* end of debug code */
/* Correct frame length and re-adjust interframe params.
* This operations was scheduled on previous interrupt.
*/
// if (jptr->flags & SENS_FLAG_HW_OFF) {
// int len32;
// int len32_ptr = jptr->jpeg_wp - INTERFRAME_PARAMS_SZ - 1;
// phys_addr = circbuf_priv_ptr[jptr->chn_num].phys_addr + DW2BYTE(jptr->jpeg_wp) - CHUNK_SIZE;
// virt_addr = circbuf_priv_ptr[jptr->chn_num].buf_ptr + jptr->jpeg_wp - INTERFRAME_PARAMS_SZ;
// outer_inv_range(phys_addr, phys_addr + (CHUNK_SIZE - 1));
// __cpuc_flush_dcache_area(virt_addr, CHUNK_SIZE);
// len32 = circbuf_priv_ptr[jptr->chn_num].buf_ptr[len32_ptr];
// len32 -= INTERFRAME_PARAMS_SZ;
// circbuf_priv_ptr[jptr->chn_num].buf_ptr[len32_ptr] = len32;
// __cpuc_flush_dcache_area(virt_addr, CHUNK_SIZE);
// outer_inv_range(phys_addr, phys_addr + (CHUNK_SIZE - 1));
// jptr->flags &= ~SENS_FLAG_HW_OFF;
// }
/* Looks like compressor is not writing 32 zero bytes when last frame ends precisely at the
* end of buffer. Try to detect this situation and set a flag so that we can overwrite first
* 32 bytes of the buffer on next interrupt. These bytes will be used as interframe parameters and current frame length
* will be decreased by these 32 bytes. Such a measure will corrupt the frame but preserve the structure.
*/
// if (jptr->jpeg_wp == 0) {
// // we need to invalidate two cache lines in order to
// // estimate the situation correctly: one line after the pointer, which should be the line of
// // 32 bytes of newly compressed frame(or zero bytes?), and one line before the pointer, which should be the last line of the frame. If this is not done
// // then the data read from memory can be incorrect and error detection will give false result. Barrier is set to
// // prevent compiler from reordering operations.
// phys_addr = circbuf_priv_ptr[jptr->chn_num].phys_addr;
// virt_addr = circbuf_priv_ptr[jptr->chn_num].buf_ptr;
// dev_dbg(g_dev_ptr, "from updateIRQJPEG_wp: phys_addr = 0x%x, virt_addr = 0x%p\n", phys_addr, virt_addr);
// outer_inv_range(phys_addr, phys_addr + (CHUNK_SIZE - 1));
// __cpuc_flush_dcache_area(virt_addr, CHUNK_SIZE);
// phys_addr = circbuf_priv_ptr[jptr->chn_num].phys_addr + CCAM__DMA_SIZE - CHUNK_SIZE;
// virt_addr = circbuf_priv_ptr[jptr->chn_num].buf_ptr + BYTE2DW(CCAM__DMA_SIZE - CHUNK_SIZE);
// outer_inv_range(phys_addr, phys_addr + (CHUNK_SIZE - 1));
// __cpuc_flush_dcache_area(virt_addr, CHUNK_SIZE);
// dev_dbg(g_dev_ptr, "from updateIRQJPEG_wp: phys_addr = 0x%x, virt_addr = 0x%p\n", phys_addr, virt_addr);
// barrier();
// prev_dword = X393__BUFFSUB(DW2BYTE(jptr->jpeg_wp), 4);
// dev_dbg(g_dev_ptr, "circbuf_priv_ptr[jptr->chn_num].buf_ptr[jptr->jpeg_wp] = 0x%x\n", circbuf_priv_ptr[jptr->chn_num].buf_ptr[jptr->jpeg_wp]);
// dev_dbg(g_dev_ptr, "circbuf_priv_ptr[jptr->chn_num].buf_ptr[BYTE2DW(prev_dword)] = 0x%x\n", circbuf_priv_ptr[jptr->chn_num].buf_ptr[BYTE2DW(prev_dword)]);
//// if (circbuf_priv_ptr[jptr->chn_num].buf_ptr[jptr->jpeg_wp] == 0x00 &&
// if ((circbuf_priv_ptr[jptr->chn_num].buf_ptr[BYTE2DW(prev_dword)] & MARKER_FF) == MARKER_FF) {
//// jptr->jpeg_wp += INTERFRAME_PARAMS_SZ;
// jptr->flags |= SENS_FLAG_HW_OFF;
// corrected_offset[jptr->chn_num] += 1;
// }
// }
// invalidate CPU L1 and L2 caches
// the code below was used to find cache coherence issues
......@@ -659,7 +620,8 @@ static irqreturn_t frame_sync_irq_handler(int irq, void *dev_id)
int frame16;
u32 aframe;
cmdframeseq_mode.interrupt_cmd = IRQ_CLEAR;
local_irq_save(flags);
// local_irq_save(flags);
spin_lock_irqsave(frame_irq_locks[jptr->chn_num],flags);
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,
......@@ -668,7 +630,8 @@ static irqreturn_t frame_sync_irq_handler(int irq, void *dev_id)
// tasklet_schedule(&tasklet_cmdseq);
tasklet_schedule(tasklet_cmdseq[jptr->chn_num]);
x393_cmdframeseq_ctrl(cmdframeseq_mode, jptr->chn_num);
local_irq_restore(flags);
// local_irq_restore(flags);
spin_unlock_irqrestore(frame_irq_locks[jptr->chn_num],flags);
return IRQ_HANDLED;
}
......@@ -688,7 +651,10 @@ static irqreturn_t compressor_irq_handler(int irq, void *dev_id)
// int frame16;
unsigned long flags;
local_irq_save(flags);
// local_irq_save(flags);
spin_lock_irqsave(compressor_locks[jptr->chn_num],flags);
if (updateIRQJPEG_wp(jptr)) { // Updates write pointer, invalidates cache, calculates absolute frame number (compressed)
update_irq_circbuf(jptr); // Update global parameters (accessible over mmap): G_CIRCBUFWP, G_FREECIRCBUF (depends on user-set G_CIRCBUFRP)
updateIRQFocus(jptr); // Reads FPGA and updates both G_GFOCUS_VALUE and P_FOCUS_VALUE
......@@ -714,7 +680,9 @@ static irqreturn_t compressor_irq_handler(int irq, void *dev_id)
// tasklet_schedule(tasklets_compressor[jptr->chn_num]);
irq_ctrl.interrupt_cmd = IRQ_CLEAR;
x393_cmprs_interrupts(irq_ctrl, jptr->chn_num);
local_irq_restore(flags);
// local_irq_restore(flags);
spin_unlock_irqrestore(compressor_locks[jptr->chn_num],flags);
return IRQ_HANDLED;
}
......@@ -952,7 +920,8 @@ void reset_compressor(unsigned int chn)
{
unsigned long flags;
local_irq_save(flags);
// local_irq_save(flags);
spin_lock_irqsave(frame_irq_locks[chn],flags);
#ifdef TEST_DISABLE_CODE
port_csp0_addr[X313_WA_COMP_CMD]= COMPCMD_RESET; // bypasses command sequencer
if (framepars) set_imageParamsR_all( P_COMPRESSOR_RUN, COMPRESSOR_RUN_STOP );
......@@ -964,7 +933,9 @@ void reset_compressor(unsigned int chn)
image_acq_priv.jpeg_ptr[chn].fpga_cntr_prev = 0;
image_acq_priv.jpeg_ptr[chn].flags = 0;
//update_irq_circbuf(jptr);
local_irq_restore(flags);
// local_irq_restore(flags);
spin_unlock_irqrestore(frame_irq_locks[chn],flags);
}
/** Camera compressor interrupts on/off */
......
......@@ -784,6 +784,7 @@
#define G_HIST_Y_FRAME (FRAMEPAR_GLOBALS + 102) ///< last frame for which Y histogram was calculated (uses 4 locations)
#define G_HIST_C_FRAME (FRAMEPAR_GLOBALS + 106) ///< last frame for which C histograms were calculated (uses 4 locations)
#define G_HIST_SHIFT (FRAMEPAR_GLOBALS + 107) ///< debug feature - add 0..15 to the histogram frame to read DMA memory
#define G_SENSOR_CALIB (FRAMEPAR_GLOBALS + 1024) ///< 1024 Array of sensor calibration data, sensor dependent.For Micron it is 256*4 actual gains in 8.16 format
///< Only first 96 for each color are used
......@@ -1347,6 +1348,7 @@ struct p_names_t {
G_NAME_ENTRY(TEMPERATURE01), \
G_NAME_ENTRY(TEMPERATURE23), \
G_NAME_ENTRY(SENSOR_CALIB) \
G_NAME_ENTRY(G_HIST_SHIFT) \
};
#define ONCHANGE_NAME_ENTRY(y) { onchange_##y, #y }
......
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