Commit e2386cf2 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

debugging histograms, testing with ported camvc

parent 385eb407
Loading
Loading
Loading
Loading
+32 −9
Original line number Original line Diff line number Diff line
@@ -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].phys_addr = dma_handle + CIRCBUF_START_OFFSET + i * CCAM_DMA_SIZE;
		circbuf_priv[i].buf_size = 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;
		ccam_dma_buf_ptr[i] = circbuf_priv[i].buf_ptr;
		// set circular buffer size in bytes
		// set circular buffer size in bytes
		set_globalParam(i, G_CIRCBUFSIZE, circbuf_priv[i].buf_size);
		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);
    unsigned int minor = MINOR(inode->i_rdev);
	inode->i_size = circbuf_priv[minor_to_chn(minor, NULL)].buf_size; // CCAM__DMA_SIZE;
	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;
	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 rp = *rp_offset;
	int last_image_chunk;
	int last_image_chunk;
	unsigned int sec;
//	unsigned int sec;
	unsigned int usec;
//	unsigned int usec;
	int wp = camseq_get_jpeg_wp(chn);
	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;
	struct interframe_params_t *fp, *fp_off;


	if (rp & 0x1f) {
	if (rp & 0x1f) {
@@ -445,13 +445,14 @@ int circbufValidPointer(int rp,
        struct interframe_params_t ** fpp,
        struct interframe_params_t ** fpp,
        unsigned int chn)
        unsigned int chn)
{
{
    struct interframe_params_t * fp;
    int wp, p;
    if (rp & 0x1f) {  //!rp is not 32-bytes aligned
    if (rp & 0x1f) {  //!rp is not 32-bytes aligned
        dev_dbg(g_dev_ptr, "circbufValidPointer: misaligned pointer\n");
        dev_dbg(g_dev_ptr, "circbufValidPointer: misaligned pointer\n");
        return -2;
        return -2;
    }
    }
    int wp=camSeqGetJPEG_wp(chn);
    wp=camSeqGetJPEG_wp(chn);
    int p= rp >> 2; // index in ccam_dma_buf
    p= rp >> 2; // index in ccam_dma_buf
    struct interframe_params_t * fp;
    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
    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",
    dev_dbg(g_dev_ptr, "rp=0x%x (0x%x), offset=0x%x\n",
@@ -461,10 +462,27 @@ int circbufValidPointer(int rp,
    *fpp=fp;
    *fpp=fp;
    dev_dbg(g_dev_ptr, "p=0x%x , wp==0x%x\n",p,wp);
    dev_dbg(g_dev_ptr, "p=0x%x , wp==0x%x\n",p,wp);
    if (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
        return 0; // frame not yet acquired, fp - not valid
    }
    }
    if (fp->signffff != 0xffff) { //! signature is overwritten
    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;
        return -1;
    }
    }
    if ((fp->timestamp_sec) & X313_LENGTH_MASK) {
    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:
          case LSEEK_CIRC_LAST:
             file->f_pos=camSeqGetJPEG_wp(chn)<<2;
             file->f_pos=camSeqGetJPEG_wp(chn)<<2;
             fvld=circbufValidPointer(file->f_pos, &fp, chn); //!set fp
             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:
          case LSEEK_CIRC_PREV:
             rp= file->f_pos >> 2;
             rp= file->f_pos >> 2;
             fl=circbuf_priv[chn].buf_ptr[X393_BUFFSUB32(rp, 9, chn)] ^ X313_LENGTH_MASK;
             fl=circbuf_priv[chn].buf_ptr[X393_BUFFSUB32(rp, 9, chn)] ^ X313_LENGTH_MASK;
+23 −14
Original line number Original line Diff line number Diff line
@@ -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);
int        exif_open   (struct inode *inode, struct file *filp);
static loff_t     exif_lseek  (struct file * file, loff_t offset, int orig);
int        exif_release(struct inode *inode, struct file *filp);
static ssize_t    exif_write  (struct file * file, const char * buf, size_t count, loff_t *off);
loff_t     exif_lseek  (struct file * file, loff_t offset, int orig);
static ssize_t    exif_read   (struct file * file, char * buf, size_t count, loff_t *off);
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 int __init exif_init(void);


static struct file_operations exif_fops = {
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) {
char * encode_time(char buf[27], unsigned long sec, unsigned long usec) {
	unsigned long s,d,m,y,y4,lp,h;
	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:
	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));
		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 :-(
		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);
	sprintf(&now_datetime.subsec[0],"%06ld",usec);
	memcpy(buf,&now_datetime.datetime[0],sizeof(now_datetime));
	memcpy(buf,&now_datetime.datetime[0],sizeof(now_datetime));
	//  return &now_datetime.datetime[0];
	//  return &now_datetime.datetime[0];
	spin_unlock_bh(&lock);
    spin_unlock_irqrestore(&lock,flags);
	return buf;
	return buf;
}
}


int store_meta(int sensor_port) { //called from IRQ service - put current metadata to meta_buffer, return page index
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;
	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]);
	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]++;
	aexif_wp[sensor_port]++;
	if (aexif_wp[sensor_port] > MAX_EXIF_FRAMES) aexif_wp[sensor_port] = 1;
	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() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
//!++++++++++++++++++++++++++++++++++++ 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 p = MINOR(inode->i_rdev);
	int * pd= (int *) &(filp->private_data);
	int * pd= (int *) &(filp->private_data);
	switch (p) {
	switch (p) {
@@ -458,7 +463,8 @@ static int exif_open(struct inode *inode, struct file *filp) {


//!++++++++++++++++++++++++++++++++++++ release() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
//!++++++++++++++++++++++++++++++++++++ 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 p = MINOR(inode->i_rdev);
	int * pd= (int *) &(filp->private_data);
	int * pd= (int *) &(filp->private_data);
	switch (p) {
	switch (p) {
@@ -489,13 +495,14 @@ static int exif_release(struct inode *inode, struct file *filp){


//!++++++++++++++++++++++++++++++++++++ lseek() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
//!++++++++++++++++++++++++++++++++++++ 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 p=(int)file->private_data;
	int thissize=minor_file_size(p);
	int thissize=minor_file_size(p);
	int maxsize=minor_max_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);
    dev_dbg(g_devfp_ptr,"exif_lseek, minor=%d, offset = 0x%llx, orig=%d\n",p,offset,orig);
	//   int sensor_port;
	//   int sensor_port;
	int fp;
	switch (orig) {
	switch (orig) {
	case SEEK_SET:
	case SEEK_SET:
		file->f_pos = offset;
		file->f_pos = offset;
@@ -584,7 +591,8 @@ static loff_t exif_lseek (struct file * file, loff_t offset, int orig) {


//!++++++++++++++++++++++++++++++++++++ write() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
//!++++++++++++++++++++++++++++++++++++ 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 p=(int)file->private_data;
	int sensor_port;
	int sensor_port;
	//  int thissize=minor_file_size(p);
	//  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() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
//!++++++++++++++++++++++++++++++++++++ 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 p=(int)file->private_data;
	int thissize=minor_file_size(p);
	int thissize=minor_file_size(p);
	char * cp, * metap;
	char * cp, * metap;
+15 −8
Original line number Original line Diff line number Diff line
@@ -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);
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);
inline void  histogram_calc_percentiles ( unsigned long * cumul_hist,  unsigned char * percentile);


/** Initialize FPGA DMA engine for histograms. Obviously requires bitstream to be loaded.
/** 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;
        return 0;
    // Copying received data to histograms structure, maybe later we can skip that step and use data in place
    // 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-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 )) {
    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 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];
        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 thisFrameNumber=getThisFrameNumber(sensor_port);
    unsigned long * gammaHash;
    unsigned long * gammaHash;
    unsigned long * framep;
    unsigned long * framep;
    unsigned long dbg_sum;
    if (hist_indx <0 ) return -EINVAL;
    if (hist_indx <0 ) return -EINVAL;
    raw_needed=(needed | (needed>>4) | needed>>8) & 0xf;
    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",
    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
    if (needed & 0xf0) { // Calculating cumulative histograms
        for (i=0; i<4; i++) if (needed & ( 0x10 << i )) {
        for (i=0; i<4; i++) if (needed & ( 0x10 << i )) {
            color_start= i<<8 ;
            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;
            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);
        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 */
/** 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)
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)
                                              unsigned long * cumul_hist) ///< output cumulative histogram array of unsigned long, single color (256)
                                               ///< @return sum of all pixels (last value)
{
{
    int i;
    int i;
    cumul_hist[0]=hist[0];
    cumul_hist[0]=hist[0];
    for (i=1; i<256;i++) cumul_hist[i]=cumul_hist[i-1]+hist[i];
    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) :
    case DEV393_MINOR(DEV393_HISTOGRAM) :
        switch(orig) {
        switch(orig) {
        case SEEK_CUR: // ignore offset - in NC353 it was get latest?
        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
#if 0
            offset+=(privData-> wait_mode)?
            offset+=(privData-> wait_mode)?
                    GLOBALPARS(privData->port,G_HIST_C_FRAME+privData->subchannel):
                    GLOBALPARS(privData->port,G_HIST_C_FRAME+privData->subchannel):
                    GLOBALPARS(privData->port,G_HIST_Y_FRAME+privData->subchannel);
                    GLOBALPARS(privData->port,G_HIST_Y_FRAME+privData->subchannel);
#endif
#endif

            offset+=getThisFrameNumber(privData->port); // get relative to current frame (-1 - latest)
            //no break (CDT understands this)
            //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){
            if (offset <0){
                dev_dbg(g_dev_ptr, "offset= %lld (0x%llx) changing to previous frame \n",offset,offset);
                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;
            privData->frame=offset;
            // Try to make some precautions to avoid waiting forever - if the past frame is requested - request histogram for the current frame,
            // Try to make some precautions to avoid waiting forever - if the past frame is requested - request histogram for the current frame,
+16 −2
Original line number Original line Diff line number Diff line
@@ -42,6 +42,17 @@


//#define DEV393_KLOGGER        ("klogger_393",      "klogger_393",    144,  1, "0666", "c")  ///< kernel event logger to memory (no i/o)
//#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 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
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
                  const char *fmt, ...) ///< Format and argumants as in printf


{
{
    FLAGS_KLOGGER_BH
    char buf[1024];
    char buf[1024];
    const char * cp;
    const char * cp;
    sec_usec_t ts;
    sec_usec_t ts;
@@ -81,7 +93,8 @@ int print_klog393(const int mode, ///< bits 0: timestamp, 1 - file, 2 - fu
        return 0;
        return 0;
    }
    }
    if (mmode & 16){
    if (mmode & 16){
        spin_lock_bh(&klogger_lock);
//        spin_lock_bh(&klogger_lock);
        LOCK_KLOGGER_BH(&klogger_lock);
    }
    }
    if (mmode & 1) {
    if (mmode & 1) {
        get_fpga_rtc(&ts);
        get_fpga_rtc(&ts);
@@ -107,7 +120,8 @@ int print_klog393(const int mode, ///< bits 0: timestamp, 1 - file, 2 - fu
    va_end(args);
    va_end(args);
    klog393_puts(buf);
    klog393_puts(buf);
    if (mmode & 16){
    if (mmode & 16){
        spin_unlock_bh(&klogger_lock);
//        spin_unlock_bh(&klogger_lock);
        UNLOCK_KLOGGER_BH(&klogger_lock);
    }
    }


    return 0;
    return 0;
+2 −2
Original line number Original line Diff line number Diff line
@@ -1867,8 +1867,8 @@ int pgm_hist (int sensor_port, ///< sensor port number (0..3
            // set these values to FPGA
            // set these values to FPGA
            left_top.left =          hist_setup_data.left;
            left_top.left =          hist_setup_data.left;
            left_top.top =           hist_setup_data.top;
            left_top.top =           hist_setup_data.top;
            width_height.width_m1 =  hist_setup_data.width-2;
            width_height.width_m1 =  hist_setup_data.width-1;
            width_height.height_m1 = hist_setup_data.height-2;
            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_lt, left_top, sub_chn);
            X393_SEQ_SEND1S (sensor_port, frame16, x393_histogram_wh, width_height,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",
            dev_dbg(g_dev_ptr,"{%d}   X393_SEQ_SEND1S(0x%x, 0x%x, x393_histogram_lt, 0x%x, %d)\n",
Loading