Commit b049b19c authored by Andrey Filippov's avatar Andrey Filippov

added header file with debug macros

parent 515823ea
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/ *******************************************************************************/
/****************** INCLUDE FILES SECTION ***********************************/ /****************** INCLUDE FILES SECTION ***********************************/
#define DEBUG /* should be before linux/module.h - enables dev_dbg at boot in this file */ //#define DEBUG /* should be before linux/module.h - enables dev_dbg at boot in this file */
#include <linux/module.h> #include <linux/module.h>
#include <linux/sched.h> #include <linux/sched.h>
......
/***************************************************************************//**
* @file debug393.h
* @brief Macros for low-overhad logging messages to a large memory buffer
* using klogger_393
* @copyright Copyright 2016 (C) Elphel, Inc.
* @par <b>License</b>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
// Used debug bits:
// framepars.c
// 0
#define DBGB_FSFA 1 ///< setFrameParsAtomic (kthread)
#define DBGB_FASAP 2 ///< _processParsASAP (kthread, tasklet) (first N only)
#define DBGB_FSEQ 3 ///< _processParsSeq (kthread, tasklet) (first N only)
#define DBGB_FPPI 4 ///< _processPars (kthread, tasklet) (first N only)
#define DBGB_FPPT 5 ///< processPars (from tasklets) (first N only)
#define DBGB_FSFP 6 ///< setFramePar(), setFramePars() (tasklet)
#define DBGB_FSFV 7 ///< setFramePar(), setFramePars() - adiitional(verbose) (tasklet)
#define DBGB_FSCF 8 ///< schedule_pgm_func,schedule_this_pgm_func
#define DBGB_FFOP 9 ///< file operations
// pgm_functions.c
#define DBGB_PSFN 10 ///< start of each function
#define DBGB_PADD 11 ///< additional details
// x393_vidoemem.c
#define DBGB_VM 12 ///< vidoemem all debug
// 13
// 14
// 15
// 16
// 17
// 18
// 19
// 20
// 21
// 22
// 23
// 24
// 25
// 26
// 27
// 28
// 29
// 30
// 31
#define DBGB_SFA 1 ///< setFrameParsAtomic (kthread)
#include "klogger_393.h"
#include "framepars.h" // for aglobals
#ifndef ELPHEL_DEBUG393
#define ELPHEL_DEBUG393 1
#if ELPHEL_DEBUG393
static int klog_mode = 0xff; ///< bits specify attributes to log
/// log unconditionally, for any channel
#define MDG(...) print_klog393(klog_mode, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__);
/// log only if specified bit in G_DEBUG global parameter for the specified sensor port is set
#define MDP(bit,port,fmt,...) { if (GLOBALPARS(port,G_DEBUG) & (1 << bit)) print_klog393(klog_mode, __FILE__, __FUNCTION__, __LINE__,"%d: "fmt,port,__VA_ARGS__); }
#else
#define MDF(x)
#define MDP(bit,port,fmt,...)
#endif
#endif
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
//copied from cxi2c.c - TODO:remove unneeded //copied from cxi2c.c - TODO:remove unneeded
#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg) //#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg)
#include <linux/types.h> // div for 64 #include <linux/types.h> // div for 64
#include <asm/div64.h> // div for 64 #include <asm/div64.h> // div for 64
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
//#undef LOCK_BH_FRAMEPARS //#undef LOCK_BH_FRAMEPARS
#define LOCK_BH_FRAMEPARS #define LOCK_BH_FRAMEPARS
#define USE_KLOG393 //#define USE_KLOG393
...@@ -92,10 +92,17 @@ ...@@ -92,10 +92,17 @@
#endif #endif
#include "debug393.h"
#define ELPHEL_DEBUG 0
// Below are old NC353 debug macros, remove them
#if ELPHEL_DEBUG #if ELPHEL_DEBUG
/* 393: program G_DEBUG through sensor port 0 */ // #define MDF2(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 2)) { printk("%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__); x; } }
#define MDF(x) { printk("%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__); x; }
#define MDF2(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 2)) { printk("%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__); x; } }
// setFrameParsAtomic // setFrameParsAtomic
#define MDF5(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 5)) { printk("%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__); x; } } #define MDF5(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 5)) { printk("%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__); x; } }
#define D5(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 5)) { x; } } #define D5(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 5)) { x; } }
...@@ -108,10 +115,14 @@ ...@@ -108,10 +115,14 @@
// setFramePar[s] // setFramePar[s]
#define MDF8(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 8)) { printk("%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__); x; } } #define MDF8(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 8)) { printk("%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__); x; } }
#define D8(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 8)) { x; } } #define D8(x) { if (GLOBALPARS(0,G_DEBUG) & (1 << 8)) { x; } }
#define D5(chn,...)
#define D6(chn,...)
#define D7(chn,...)
#define D8(chn,...)
#define ELPHEL_DEBUG_THIS 0 #define ELPHEL_DEBUG_THIS 0
// #define ELPHEL_DEBUG_THIS 1 // #define ELPHEL_DEBUG_THIS 1
#else #else
#define MDF(x)
#define MDF2(x) #define MDF2(x)
#define MDF5(x) #define MDF5(x)
#define D5(x) #define D5(x)
...@@ -177,8 +188,6 @@ static DEFINE_SPINLOCK(framepars_lock_3); ///< ...@@ -177,8 +188,6 @@ static DEFINE_SPINLOCK(framepars_lock_3); ///<
spinlock_t * framepars_locks[4] = {&framepars_lock_0, &framepars_lock_1, &framepars_lock_2, &framepars_lock_3}; spinlock_t * framepars_locks[4] = {&framepars_lock_0, &framepars_lock_1, &framepars_lock_2, &framepars_lock_3};
/* Remove after compilation OK */ /* Remove after compilation OK */
//struct sensorproc_t * sensorproc = NULL; //struct sensorproc_t * sensorproc = NULL;
//void compressor_interrupts (int on) {} //void compressor_interrupts (int on) {}
...@@ -620,7 +629,8 @@ inline void _processParsASAP(int sensor_port, ///< sensor port ...@@ -620,7 +629,8 @@ inline void _processParsASAP(int sensor_port, ///< sensor port
unsigned long * p_nasap = &GLOBALPARS(sensor_port, G_CALLNASAP); unsigned long * p_nasap = &GLOBALPARS(sensor_port, G_CALLNASAP);
int i; int i;
int rslt; int rslt;
#if ELPHEL_DEBUG
#if ELPHEL_DEBUG_0
unsigned long allfunctions = framepars[0].functions | framepars[1].functions | framepars[2].functions | framepars[3].functions | 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; 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, if (allfunctions) MDF6(printk("frame16=%d, functions: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", frame16, framepars[0].functions,
...@@ -652,13 +662,16 @@ inline void _processParsASAP(int sensor_port, ///< sensor port ...@@ -652,13 +662,16 @@ inline void _processParsASAP(int sensor_port, ///< sensor port
(p_nasap[pars_ahead] & (procpars->functions) & remain) : (p_nasap[pars_ahead] & (procpars->functions) & remain) :
(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%08x procpars->functions=0x%08lx\n",
sensor_port, frame16, todo, pars_ahead, procpars->functions); 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",
frame16, todo, pars_ahead, p_nasap[pars_ahead], procpars->functions)
} else { } else {
todo = (pars_ahead) ? todo = (pars_ahead) ?
(p_nasap[pars_ahead] & (procpars->functions) & remain) : (p_nasap[pars_ahead] & (procpars->functions) & remain) :
(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%08x procpars->functions=0x%08lx\n",
sensor_port, frame16, todo, pars_ahead, procpars->functions); sensor_port, frame16, todo, pars_ahead, p_nasap[pars_ahead], procpars->functions);
} }
while ((todo = (pars_ahead) ? while ((todo = (pars_ahead) ?
(p_nasap[pars_ahead] & (procpars->functions) & remain) : (p_nasap[pars_ahead] & (procpars->functions) & remain) :
...@@ -673,11 +686,18 @@ inline void _processParsASAP(int sensor_port, ///< sensor port ...@@ -673,11 +686,18 @@ inline void _processParsASAP(int sensor_port, ///< sensor port
if (debug_flags) { if (debug_flags) {
dev_dbg(g_devfp_ptr,"port= %d, todo=0x%08lx (curr=0x%08lx) frame16=%d, pars_ahead=%d, frame_proc=%d i=%d, mask=0x%08lx func=0x%08x\n", dev_dbg(g_devfp_ptr,"port= %d, todo=0x%08lx (curr=0x%08lx) frame16=%d, pars_ahead=%d, frame_proc=%d i=%d, mask=0x%08lx func=0x%08x\n",
sensor_port, todo, procpars->functions, frame16, pars_ahead, frame_proc, i, mask, (int)sensorproc->pgm_func[i]); sensor_port, todo, procpars->functions, frame16, pars_ahead, frame_proc, i, mask, (int)sensorproc->pgm_func[i]);
MDP(DBGB_FASAP,sensor_port,"todo=0x%08lx (curr=0x%08lx) frame16=%d, pars_ahead=%d, frame_proc=%d i=%d, mask=0x%08lx func=0x%08x\n",
todo, procpars->functions, frame16, pars_ahead, frame_proc, i, mask, (int)sensorproc->pgm_func[i])
dev_dbg(g_devfp_ptr,"port= %d, %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", dev_dbg(g_devfp_ptr,"port= %d, %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
sensor_port, sensor_port,
framepars[0].functions, framepars[1].functions, framepars[2].functions, framepars[3].functions, framepars[0].functions, framepars[1].functions, framepars[2].functions, framepars[3].functions,
framepars[4].functions, framepars[5].functions, framepars[6].functions, framepars[7].functions); framepars[4].functions, framepars[5].functions, framepars[6].functions, framepars[7].functions);
MDP(DBGB_FASAP,sensor_port,"%08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
framepars[ 0].functions, framepars[ 1].functions, framepars[ 2].functions, framepars[ 3].functions,
framepars[ 4].functions, framepars[ 5].functions, framepars[ 6].functions, framepars[ 7].functions,
framepars[ 8].functions, framepars[ 9].functions, framepars[10].functions, framepars[11].functions,
framepars[12].functions, framepars[13].functions, framepars[14].functions, framepars[15].functions)
} else { } else {
dev_dbg(g_devfp_ptr,"port= %d, todo=0x%08lx (curr=0x%08lx) frame16=%d, pars_ahead=%d, frame_proc=%d i=%d, mask=0x%08lx func=0x%08x\n", dev_dbg(g_devfp_ptr,"port= %d, todo=0x%08lx (curr=0x%08lx) frame16=%d, pars_ahead=%d, frame_proc=%d i=%d, mask=0x%08lx func=0x%08x\n",
sensor_port, todo, procpars->functions, frame16, pars_ahead, frame_proc, i, mask, (int)sensorproc->pgm_func[i]); sensor_port, todo, procpars->functions, frame16, pars_ahead, frame_proc, i, mask, (int)sensorproc->pgm_func[i]);
...@@ -689,10 +709,12 @@ inline void _processParsASAP(int sensor_port, ///< sensor port ...@@ -689,10 +709,12 @@ inline void _processParsASAP(int sensor_port, ///< sensor port
} }
if (sensorproc->pgm_func[i]) { if (sensorproc->pgm_func[i]) {
dev_dbg(g_devfp_ptr,"port= %d, Calling GENERIC pgm_func[%d] ASAP\n",sensor_port,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)
rslt = sensorproc->pgm_func[i] (sensor_port, &(sensorproc->sensor), procpars, prevpars, -1); 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 } 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 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); 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)
rslt = sensorproc->pgm_func[i + 32] (sensor_port, &(sensorproc->sensor), procpars, prevpars, -1); 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? 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?
...@@ -778,10 +800,12 @@ inline void _processParsSeq(int sensor_port, ///< sensor port ...@@ -778,10 +800,12 @@ inline void _processParsSeq(int sensor_port, ///< sensor port
if (sensorproc->pgm_func[i]) { if (sensorproc->pgm_func[i]) {
// NOTE: Was (frame16+job_ahead +1) & PARS_FRAMES_MASK // 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); 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)
rslt = sensorproc->pgm_func[i] (sensor_port, &(sensorproc->sensor), procpars, prevpars, seq_frame); 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 } 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 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); 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)
rslt = sensorproc->pgm_func[i + 32] (sensor_port, &(sensorproc->sensor), procpars, prevpars, seq_frame); rslt = sensorproc->pgm_func[i + 32] (sensor_port, &(sensorproc->sensor), procpars, prevpars, seq_frame);
} }
if (rslt >= 0) { if (rslt >= 0) {
...@@ -811,20 +835,11 @@ inline void _processParsSeq(int sensor_port, ///< sensor port ...@@ -811,20 +835,11 @@ inline void _processParsSeq(int sensor_port, ///< sensor port
//#define P_CALLASAP 107 // bitmask - what functions work only in the current frame (ASAP) mode //#define P_CALLASAP 107 // bitmask - what functions work only in the current frame (ASAP) mode
void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, int maxahead) void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, int maxahead)
{ {
#ifdef USE_KLOG393
char klog393_str [256];
#endif
frame16 &= PARS_FRAMES_MASK; frame16 &= PARS_FRAMES_MASK;
if (debug_flags) { if (debug_flags) {
dev_dbg(g_devfp_ptr,"port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
#ifdef USE_KLOG393 MDP(DBGB_FPPI,sensor_port,"frame16=%d, maxahead=%d\n",
sprintf(klog393_str, frame16, maxahead)
"%s:%d:%s: "
"port= %d, frame16=%d, maxahead=%d\n",
__FILE__, __LINE__, __FUNCTION__,
sensor_port, frame16, maxahead);
klog393_ts(klog393_str);
#endif
} }
dev_dbg(g_devfp_ptr,"port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
if (!sensorproc){ if (!sensorproc){
...@@ -836,14 +851,8 @@ void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16 ...@@ -836,14 +851,8 @@ void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16
// dev_dbg(g_devfp_ptr,"%s before first _processParsASAP\n",__func__); // dev_dbg(g_devfp_ptr,"%s before first _processParsASAP\n",__func__);
_processParsASAP(sensor_port, sensorproc, frame16); // NC393: never gets here ? Only after _processParsSeq? _processParsASAP(sensor_port, sensorproc, frame16); // NC393: never gets here ? Only after _processParsSeq?
if (debug_flags) { if (debug_flags) {
#ifdef USE_KLOG393 MDP(DBGB_FPPI,sensor_port,"(after first _processParsASAP), frame16=%d, maxahead=%d\n",
sprintf(klog393_str, frame16, maxahead)
"%s:%d:%s: "
"port= %d (after first _processParsASAP), frame16=%d, maxahead=%d\n",
__FILE__, __LINE__, __FUNCTION__,
sensor_port, frame16, maxahead);
klog393_ts(klog393_str);
#endif
dev_dbg(g_devfp_ptr,"port= %d (after first _processParsASAP), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"port= %d (after first _processParsASAP), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
} }
dev_dbg(g_devfp_ptr,"port= %d (after first _processParsASAP), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"port= %d (after first _processParsASAP), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
...@@ -853,14 +862,8 @@ void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16 ...@@ -853,14 +862,8 @@ void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16
// dev_dbg(g_devfp_ptr,"%s before _processParsSeq\n",__func__); // dev_dbg(g_devfp_ptr,"%s before _processParsSeq\n",__func__);
_processParsSeq(sensor_port, sensorproc, frame16, maxahead); _processParsSeq(sensor_port, sensorproc, frame16, maxahead);
if (debug_flags) { if (debug_flags) {
#ifdef USE_KLOG393 MDP(DBGB_FPPI,sensor_port,"(after _processParsSeq), frame16=%d, maxahead=%d\n",
sprintf(klog393_str, frame16, maxahead)
"%s:%d:%s: "
"port= %d (after _processParsSeq), frame16=%d, maxahead=%d\n",
__FILE__, __LINE__, __FUNCTION__,
sensor_port, frame16, maxahead);
klog393_ts(klog393_str);
#endif
dev_dbg(g_devfp_ptr,"port= %d (after _processParsSeq), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"port= %d (after _processParsSeq), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
} }
dev_dbg(g_devfp_ptr,"port= %d (after _processParsSeq), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"port= %d (after _processParsSeq), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
...@@ -869,15 +872,8 @@ void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16 ...@@ -869,15 +872,8 @@ void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16
// dev_dbg(g_devfp_ptr,"%s before second _processParsASAP\n",__func__); // dev_dbg(g_devfp_ptr,"%s before second _processParsASAP\n",__func__);
_processParsASAP(sensor_port, sensorproc, frame16); _processParsASAP(sensor_port, sensorproc, frame16);
if (debug_flags) { if (debug_flags) {
#ifdef USE_KLOG393 MDP(DBGB_FPPI,sensor_port,"(after second _processParsASAP), frame16=%d, maxahead=%d\n",
sprintf(klog393_str, frame16, maxahead)
"%s:%d:%s: "
"port= %d (after second _processParsASAP), frame16=%d, maxahead=%d\n",
__FILE__, __LINE__, __FUNCTION__,
sensor_port, frame16, maxahead);
klog393_ts(klog393_str);
#endif
dev_dbg(g_devfp_ptr,"port= %d (after second _processParsASAP), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"port= %d (after second _processParsASAP), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
} }
dev_dbg(g_devfp_ptr,"port= %d (after second _processParsASAP), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"port= %d (after second _processParsASAP), frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
...@@ -915,20 +911,11 @@ void processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, ...@@ -915,20 +911,11 @@ void processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16,
#else #else
void processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, int maxahead) void processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, int maxahead)
{ {
#ifdef USE_KLOG393
char klog393_str [256];
#endif
FLAGS_IBH FLAGS_IBH
frame16 &= PARS_FRAMES_MASK; frame16 &= PARS_FRAMES_MASK;
if (debug_flags) { if (debug_flags) {
#ifdef USE_KLOG393 MDP(DBGB_FPPT,sensor_port,"==from tasklet: frame16=%d, maxahead=%d\n",
sprintf(klog393_str, frame16, maxahead)
"%s:%d:%s: "
"==from tasklet: port= %d, frame16=%d, maxahead=%d\n",
__FILE__, __LINE__, __FUNCTION__,
sensor_port, frame16, maxahead);
klog393_ts(klog393_str);
#endif
dev_dbg(g_devfp_ptr,"==from tasklet: port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"==from tasklet: port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
} }
...@@ -941,14 +928,8 @@ void processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, ...@@ -941,14 +928,8 @@ void processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16,
_processPars(sensor_port, sensorproc, frame16, maxahead); _processPars(sensor_port, sensorproc, frame16, maxahead);
UNLOCK_IBH(framepars_locks[sensor_port]); UNLOCK_IBH(framepars_locks[sensor_port]);
if (debug_flags) { if (debug_flags) {
#ifdef USE_KLOG393 MDP(DBGB_FPPT,sensor_port,"==Done from tasklet: frame16=%d, maxahead=%d\n",
sprintf(klog393_str, frame16, maxahead)
"%s:%d:%s: "
"==Done from tasklet: port= %d, frame16=%d, maxahead=%d\n",
__FILE__, __LINE__, __FUNCTION__,
sensor_port, frame16, maxahead);
klog393_ts(klog393_str);
#endif
dev_dbg(g_devfp_ptr,"== Done from tasklet: port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead); dev_dbg(g_devfp_ptr,"== Done from tasklet: port= %d, frame16=%d, maxahead=%d\n", sensor_port, frame16, maxahead);
} }
} }
...@@ -958,13 +939,17 @@ void processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, ...@@ -958,13 +939,17 @@ void processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16,
/** /**
* @brief schedule pgm_func to be executed for selected frame (frame16) * @brief schedule pgm_func to be executed for selected frame (frame16)
* @param sensor_port sensor port number (0..3) * @param sensor_port sensor port number (0..3)
* @param frame16 frame number (3-bit) to schedule a function for * @param frame16 frame number (4-bit) to schedule a function for
* @param func_num function number to schedule * @param func_num function number to schedule
*/ */
void schedule_pgm_func(int sensor_port, int frame16, int func_num) void schedule_pgm_func(int sensor_port, int frame16, int func_num)
{ {
dev_dbg(g_devfp_ptr,"%s port= %d, frame16=%d, func_num=%d\n",__func__, sensor_port, frame16, func_num);
aframepars[sensor_port][frame16 & PARS_FRAMES_MASK].functions |= 1 << 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",
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",
func_num, sensor_port, frame16,aframepars[sensor_port][frame16 & PARS_FRAMES_MASK].functions)
} }
/** /**
...@@ -976,9 +961,11 @@ void schedule_pgm_func(int sensor_port, int frame16, int func_num) ...@@ -976,9 +961,11 @@ void schedule_pgm_func(int sensor_port, int frame16, int func_num)
void schedule_this_pgm_func(int sensor_port, struct framepars_t * this_framepars, int func_num) void schedule_this_pgm_func(int sensor_port, struct framepars_t * this_framepars, int func_num)
{ {
int frame16 = this_framepars->pars[P_FRAME] & PARS_FRAMES_MASK; int frame16 = this_framepars->pars[P_FRAME] & PARS_FRAMES_MASK;
dev_dbg(g_devfp_ptr,"%s port= %d, frame16=%d, func_num=%d\n",__func__, sensor_port, frame16, func_num);
aframepars[sensor_port][frame16].functions |= 1 << func_num; aframepars[sensor_port][frame16].functions |= 1 << func_num;
dev_dbg(g_devfp_ptr,"func_num=%d, aframepars[%d][%d].functions=0x08lx\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",
func_num, sensor_port, frame16,aframepars[sensor_port][frame16 & PARS_FRAMES_MASK].functions)
} }
...@@ -1032,15 +1019,8 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0 ...@@ -1032,15 +1019,8 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0
struct framepars_t *framepars = aframepars[sensor_port]; struct framepars_t *framepars = aframepars[sensor_port];
unsigned long *funcs2call =afuncs2call[sensor_port]; unsigned long *funcs2call =afuncs2call[sensor_port];
int findex_this, findex_prev, findex_future, frame16; int findex_this, findex_prev, findex_future, frame16;
#ifdef USE_KLOG393 MDP(DBGB_FSFA,sensor_port,"frameno=0x%lx, findex_this=%ld (0x%lx) maxLatency=%d, numPars=%d, frameParsInitialized[%d]=%d\n",
char klog393_str [256]; frameno, findex_this, thisFrameNumber(sensor_port), maxLatency, numPars, sensor_port, frameParsInitialized[sensor_port])
sprintf(klog393_str,
"%s:%d:%s: "
"frameno=0x%lx, findex_this=%ld (0x%lx) maxLatency=%d, numPars=%d, frameParsInitialized[%d]=%d\n",
__FILE__, __LINE__, __FUNCTION__,
sensor_port, frameno, findex_this, thisFrameNumber(sensor_port), maxLatency, numPars, sensor_port, frameParsInitialized[sensor_port]);
klog393_ts(klog393_str);
#endif
dev_dbg(g_devfp_ptr,"port= %d, frameno=0x%lx, findex_this=%d (0x%lx) maxLatency=%d, numPars=%d, frameParsInitialized[%d]=%d\n", dev_dbg(g_devfp_ptr,"port= %d, frameno=0x%lx, findex_this=%d (0x%lx) maxLatency=%d, numPars=%d, frameParsInitialized[%d]=%d\n",
sensor_port, frameno, findex_this, thisFrameNumber(sensor_port), maxLatency, numPars, sensor_port, frameParsInitialized[sensor_port]); sensor_port, frameno, findex_this, thisFrameNumber(sensor_port), maxLatency, numPars, sensor_port, frameParsInitialized[sensor_port]);
//int klog393_ts(const char * str); //int klog393_ts(const char * str);
...@@ -1084,7 +1064,7 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0 ...@@ -1084,7 +1064,7 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0
dev_dbg(g_devfp_ptr,"port=%d, ERR_FRAMEPARS_BADINDEX, frameno = 0x%x\n",sensor_port, (int)frameno); dev_dbg(g_devfp_ptr,"port=%d, ERR_FRAMEPARS_BADINDEX, frameno = 0x%x\n",sensor_port, (int)frameno);
return -ERR_FRAMEPARS_BADINDEX; return -ERR_FRAMEPARS_BADINDEX;
} }
dev_dbg(g_devfp_ptr,"port= %d, ndex=0x%x, val=0x%lx", index, val, sensor_port); dev_dbg(g_devfp_ptr,"port= %d, index=0x%x, val=0x%lx", sensor_port, index, val);
if (index >= FRAMEPAR_GLOBALS) { // ignore frame logic, set "static" parameters to frame 0 if (index >= FRAMEPAR_GLOBALS) { // ignore frame logic, set "static" parameters to frame 0
if (pars[npar].num & FRAMEPAIR_MASK_BYTES) { // combine new value with the old one if (pars[npar].num & FRAMEPAIR_MASK_BYTES) { // combine new value with the old one
val = FRAMEPAIR_FRAME_MASK_NEW(pars[npar].num, GLOBALPARS(sensor_port,index), val); val = FRAMEPAIR_FRAME_MASK_NEW(pars[npar].num, GLOBALPARS(sensor_port,index), val);
...@@ -1093,14 +1073,14 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0 ...@@ -1093,14 +1073,14 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0
D5(printk(" set GLOBALPARS(0x%x)=0x%lx\n", index, val)); D5(printk(" set GLOBALPARS(0x%x)=0x%lx\n", index, val));
} else if (pars[npar].num & FRAMEPAIR_FRAME_FUNC) { } else if (pars[npar].num & FRAMEPAIR_FRAME_FUNC) {
funcs2call[index] = val; funcs2call[index] = val;
dev_dbg(g_devfp_ptr,"port= %d, set funcs2call[0x%x]=0x%lx\n", index, val, sensor_port); dev_dbg(g_devfp_ptr,"port= %d, set funcs2call[0x%x]=0x%lx\n", sensor_port, index, val);
// } else if ((frameno !=findex_prev) && (frameno != findex_future)) { // do not write parameters in the future otherwise // } else if ((frameno !=findex_prev) && (frameno != findex_future)) { // do not write parameters in the future otherwise
} else if ((frame16 != findex_future) || ((pars[npar].num & FRAMEPAIR_JUST_THIS) == 0)) { // do not write "JUST_THIS" parameters in the future otherwise they'll stick } else if ((frame16 != findex_future) || ((pars[npar].num & FRAMEPAIR_JUST_THIS) == 0)) { // do not write "JUST_THIS" parameters in the future otherwise they'll stick
if (pars[npar].num & FRAMEPAIR_MASK_BYTES) { // combine new value with the old one if (pars[npar].num & FRAMEPAIR_MASK_BYTES) { // combine new value with the old one
val = FRAMEPAIR_FRAME_MASK_NEW(pars[npar].num, framepars[frame16].pars[index], val); val = FRAMEPAIR_FRAME_MASK_NEW(pars[npar].num, framepars[frame16].pars[index], val);
} }
//TODO: optimize to use mask several parameters together //TODO: optimize to use mask several parameters together
dev_dbg(g_devfp_ptr,"port= %d, frame16=0x%x\n", frame16, sensor_port); dev_dbg(g_devfp_ptr,"port= %d, frame16=0x%x\n", sensor_port, frame16);
if ((framepars[frame16].pars[index] != val) || (pars[npar].num & FRAMEPAIR_FORCE_NEW)) { if ((framepars[frame16].pars[index] != val) || (pars[npar].num & FRAMEPAIR_FORCE_NEW)) {
bmask = 1 << (index & 31); bmask = 1 << (index & 31);
bindex = index >> 5; bindex = index >> 5;
...@@ -1144,25 +1124,12 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0 ...@@ -1144,25 +1124,12 @@ int setFrameParsAtomic(int sensor_port, ///< sensor port number (0
dev_dbg(g_devfp_ptr,"G_TASKLET_CTL -> 0x%x (port = %d )\n", (int) get_globalParam(sensor_port, G_TASKLET_CTL),sensor_port); dev_dbg(g_devfp_ptr,"G_TASKLET_CTL -> 0x%x (port = %d )\n", (int) get_globalParam(sensor_port, G_TASKLET_CTL),sensor_port);
// processPars(sensor_port, &asensorproc[sensor_port], thisFrameNumber(sensor_port) & PARS_FRAMES_MASK, 0); //maxahead=0, the rest will be processed after frame sync, from the tasklet // processPars(sensor_port, &asensorproc[sensor_port], thisFrameNumber(sensor_port) & PARS_FRAMES_MASK, 0); //maxahead=0, the rest will be processed after frame sync, from the tasklet
// Already having lock, call inner function. When called from tasklet, it will have to acquire lock // Already having lock, call inner function. When called from tasklet, it will have to acquire lock
#ifdef USE_KLOG393 MDP(DBGB_FSFA,sensor_port,"G_TASKLET_CTL -> 0x%x\n",
sprintf(klog393_str, (int) get_globalParam(sensor_port, G_TASKLET_CTL))
"%s:%d:%s: "
"G_TASKLET_CTL -> 0x%x (port = %d )\n",
__FILE__, __LINE__, __FUNCTION__,
(int) get_globalParam(sensor_port, G_TASKLET_CTL),sensor_port);
klog393_ts(klog393_str);
#endif
_processPars(sensor_port, &asensorproc[sensor_port], thisFrameNumber(sensor_port) & PARS_FRAMES_MASK, 0); //maxahead=0, the rest will be processed after frame sync, from the tasklet _processPars(sensor_port, &asensorproc[sensor_port], thisFrameNumber(sensor_port) & PARS_FRAMES_MASK, 0); //maxahead=0, the rest will be processed after frame sync, from the tasklet
#ifdef USE_KLOG393 MDP(DBGB_FSFA,sensor_port,"kthread _processPars( .., 0x%x) DONE\n",
sprintf(klog393_str, thisFrameNumber(sensor_port))
"%s:%d:%s: " dev_dbg(g_devfp_ptr,"kthread _processPars(%d, .., 0x%lx) DONE\n",sensor_port, thisFrameNumber(sensor_port));
"kthread _processPars(%d, .., 0x%x) DONE\n",
__FILE__, __LINE__, __FUNCTION__,
sensor_port, thisFrameNumber(sensor_port));
klog393_ts(klog393_str);
#endif
dev_dbg(g_devfp_ptr,"kthread _processPars(%d, .., 0x%x) DONE\n",sensor_port, thisFrameNumber(sensor_port));
} else { } else {
dev_dbg(g_devfp_ptr,"kthread: NOT calling _processPars(%d, .., 0x%lx) DONE\n",sensor_port, thisFrameNumber(sensor_port)); dev_dbg(g_devfp_ptr,"kthread: NOT calling _processPars(%d, .., 0x%lx) DONE\n",sensor_port, thisFrameNumber(sensor_port));
} }
...@@ -1193,7 +1160,11 @@ int setFramePar(int sensor_port, ///< sensor port number (0. ...@@ -1193,7 +1160,11 @@ int setFramePar(int sensor_port, ///< sensor port number (0.
struct framepars_t *framepars = aframepars[sensor_port]; struct framepars_t *framepars = aframepars[sensor_port];
unsigned long *funcs2call =afuncs2call[sensor_port]; unsigned long *funcs2call =afuncs2call[sensor_port];
dev_dbg(g_devfp_ptr, "%s: port=%d, thisFrameNumber=0x%lx frame16=%d index= %d (0x%lx), val=0x%lx\n",__func__, sensor_port, thisFrameNumber(sensor_port), frame16, index, mindex, val); dev_dbg(g_devfp_ptr, "port=%d, thisFrameNumber=0x%lx frame16=%d index= %d (0x%lx), val=0x%lx\n",
sensor_port, thisFrameNumber(sensor_port), frame16, index, mindex, val);
MDP(DBGB_FSFP,sensor_port,"thisFrameNumber=0x%lx frame16=%d index= %d (0x%lx), val=0x%lx\n",
thisFrameNumber(sensor_port), frame16, index, mindex, val)
// if (index > P_MAX_PAR) { // if (index > P_MAX_PAR) {
if (index > ((index >= FRAMEPAR_GLOBALS) ? (P_MAX_GPAR + FRAMEPAR_GLOBALS) : P_MAX_PAR)) { if (index > ((index >= FRAMEPAR_GLOBALS) ? (P_MAX_GPAR + FRAMEPAR_GLOBALS) : P_MAX_PAR)) {
...@@ -1210,6 +1181,9 @@ int setFramePar(int sensor_port, ///< sensor port number (0. ...@@ -1210,6 +1181,9 @@ int setFramePar(int sensor_port, ///< sensor port number (0.
} else if ((frame16 != findex_future) || ((mindex & FRAMEPAIR_JUST_THIS) == 0)) { // do not write "JUST_THIS" parameters in the future otherwise they'll stick } else if ((frame16 != findex_future) || ((mindex & FRAMEPAIR_JUST_THIS) == 0)) { // do not write "JUST_THIS" parameters in the future otherwise they'll stick
if (mindex & FRAMEPAIR_MASK_BYTES) { // combine new value with the old one if (mindex & FRAMEPAIR_MASK_BYTES) { // combine new value with the old one
val = FRAMEPAIR_FRAME_MASK_NEW(mindex, framepars[frame16].pars[index], val); val = FRAMEPAIR_FRAME_MASK_NEW(mindex, framepars[frame16].pars[index], val);
dev_dbg(g_devfp_ptr, "val updated to 0x%lx\n", val);
MDP(DBGB_FSFP,sensor_port,"val updated to 0x%lx\n", val)
} }
if ((framepars[frame16].pars[index] != val) || (mindex & (FRAMEPAIR_FORCE_NEW | FRAMEPAIR_FORCE_PROC))) { if ((framepars[frame16].pars[index] != val) || (mindex & (FRAMEPAIR_FORCE_NEW | FRAMEPAIR_FORCE_PROC))) {
bmask = 1 << (index & 31); bmask = 1 << (index & 31);
...@@ -1222,32 +1196,41 @@ int setFramePar(int sensor_port, ///< sensor port number (0. ...@@ -1222,32 +1196,41 @@ int setFramePar(int sensor_port, ///< sensor port number (0.
if (mindex & FRAMEPAIR_FORCE_PROC) { if (mindex & FRAMEPAIR_FORCE_PROC) {
framepars[frame16].functions |= funcs2call[index]; //Mark which functions will be needed to process the parameters framepars[frame16].functions |= funcs2call[index]; //Mark which functions will be needed to process the parameters
} }
dev_dbg(g_devfp_ptr, " bindex=0x%lx, bmask=0x%08lx, bmask32=0x%08lx, functions=0x%08lx\n", bindex, bmask, bmask32, framepars[frame16].functions); dev_dbg(g_devfp_ptr, " bindex=0x%lx, bmask=0x%08lx, bmask32=0x%08lx, functions=0x%08lx\n",
bindex, bmask, bmask32, framepars[frame16].functions);
MDP(DBGB_FSFP,sensor_port," bindex=0x%lx, bmask=0x%08lx, bmask32=0x%08lx, functions=0x%08lx\n",
bindex, bmask, bmask32, framepars[frame16].functions)
// Write parameter to the next frames up to the one that have the same parameter already modified // Write parameter to the next frames up to the one that have the same parameter already modified
if ((mindex & FRAMEPAIR_JUST_THIS) == 0) { if ((mindex & FRAMEPAIR_JUST_THIS) == 0) {
MDF8(printk(": --- setting next frames")); // MDF8(printk(": --- setting next frames"));
// for (nframe=(frame16+1) & PARS_FRAMES_MASK; (nframe != findex_prev) && (!(framepars[frame16].mod[bindex] & bmask)); nframe=(nframe+1) & PARS_FRAMES_MASK) { // for (nframe=(frame16+1) & PARS_FRAMES_MASK; (nframe != findex_prev) && (!(framepars[frame16].mod[bindex] & bmask)); nframe=(nframe+1) & PARS_FRAMES_MASK) {
for (nframe = (frame16 + 1) & PARS_FRAMES_MASK; (nframe != findex_prev) && (!(framepars[nframe].mod[bindex] & bmask)); nframe = (nframe + 1) & PARS_FRAMES_MASK) { 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; framepars[nframe].pars[index] = val;
D8(printk(" %d", nframe)); // D8(printk(" %d", nframe));
MDP(DBGB_FSFV,sensor_port,"framepars[%d].pars[%d] <- 0x%08x ", 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 frame16 = (frame16 - 1) & PARS_FRAMES_MASK; // for " regular parameters "modified since" do not include the target frame itself, for "JUST_THIS" - does
MDP(DBGB_FSFV,sensor_port,"%s\n","")
} }
// dev_dbg(g_devfp_ptr,"%s \n",__func__); // dev_dbg(g_devfp_ptr,"%s \n",__func__);
// Mark this parameter in all previous frames as "modified since" // Mark this parameter in all previous frames as "modified since"
// TODO: consider alternative way - first iterate through all parameters, build masks, then apply them // TODO: consider alternative way - first iterate through all parameters, build masks, then apply them
MDF8(printk(": >>> setting modsince")); // MDF8(printk(": >>> setting modsince"));
// for (nframe=(frame16-1) & PARS_FRAMES_MASK; nframe != findex_future; nframe=(nframe-1) & PARS_FRAMES_MASK) { // for (nframe=(frame16-1) & PARS_FRAMES_MASK; nframe != findex_future; nframe=(nframe-1) & PARS_FRAMES_MASK) {
for (nframe = frame16; nframe != findex_future; nframe = (nframe - 1) & PARS_FRAMES_MASK) { //NOTE: frame16 is modified here for (nframe = frame16; nframe != findex_future; nframe = (nframe - 1) & PARS_FRAMES_MASK) { //NOTE: frame16 is modified here
framepars[nframe].modsince[bindex] |= bmask; framepars[nframe].modsince[bindex] |= bmask;
framepars[nframe].modsince32 |= bmask32; framepars[nframe].modsince32 |= bmask32;
D8(printk(" %d", nframe)); MDP(DBGB_FSFV,sensor_port,"framepars[%d].modsince[%d] |= 0x%08x, framepars[%d].modsince32 |= 0x%08x ",
nframe, bindex, bmask, nframe, bmask32)
// D8(printk(" %d", nframe));
} }
D8(printk("\n")); MDP(DBGB_FSFV,sensor_port,"%s\n", "")
// D8(printk("\n"));
} }
} else { // error - trying to write "just this" to the "future" - that would stick if allowed } else { // error - trying to write "just this" to the "future" - that would stick if allowed
dev_dbg(g_devfp_ptr, "Tried to write JUST_THIS parameter (0x%lx) too far in the future", mindex); dev_dbg(g_devfp_ptr, "Tried to write JUST_THIS parameter (0x%lx) too far in the future", mindex);
dev_err(g_devfp_ptr, "Tried to write JUST_THIS parameter (0x%lx) too far in the future", mindex); dev_err(g_devfp_ptr, "Tried to write JUST_THIS parameter (0x%lx) too far in the future", mindex);
MDP(DBGB_FSFP,sensor_port,"Tried to write JUST_THIS parameter (0x%lx) too far in the future", mindex)
return -ERR_FRAMEPARS_TOOEARLY; return -ERR_FRAMEPARS_TOOEARLY;
} }
return 0; return 0;
...@@ -1266,12 +1249,14 @@ int setFrameParLocked(int sensor_port, ///< sensor port numb ...@@ -1266,12 +1249,14 @@ int setFrameParLocked(int sensor_port, ///< sensor port numb
FLAGS_IBH FLAGS_IBH
int rslt; int rslt;
LOCK_IBH(framepars_locks[sensor_port]); LOCK_IBH(framepars_locks[sensor_port]);
MDP(DBGB_FSFP,sensor_port,"mindex=0x%08lx, val=0x%08lx", mindex,val)
rslt = setFramePar(sensor_port, // sensor port number (0..3) rslt = setFramePar(sensor_port, // sensor port number (0..3)
this_framepars, // pointer to the current parameters structure this_framepars, // pointer to the current parameters structure
mindex, // parameter number (with optional modifiers in high bits) mindex, // parameter number (with optional modifiers in high bits)
val); // parameter value to set val); // parameter value to set
// @return 0 - OK, -ERR_FRAMEPARS_BADINDEX // @return 0 - OK, -ERR_FRAMEPARS_BADINDEX
UNLOCK_IBH(framepars_locks[sensor_port]); UNLOCK_IBH(framepars_locks[sensor_port]);
MDP(DBGB_FSFP,sensor_port,"DONE: mindex=0x%08lx, val=0x%08lx", mindex,val)
return rslt; return rslt;
} }
...@@ -1297,12 +1282,15 @@ int setFramePars(int sensor_port, ///< sensor port number (0 ...@@ -1297,12 +1282,15 @@ int setFramePars(int sensor_port, ///< sensor port number (0
struct framepars_t *framepars = aframepars[sensor_port]; struct framepars_t *framepars = aframepars[sensor_port];
unsigned long *funcs2call =afuncs2call[sensor_port]; unsigned long *funcs2call =afuncs2call[sensor_port];
dev_dbg(g_devfp_ptr, "%s : port= %d, this_framepars=0x%x numPars=%d\n",__func__, sensor_port, (int)this_framepars, numPars); dev_dbg(g_devfp_ptr, "port= %d, this_framepars=0x%x numPars=%d\n", sensor_port, (int)this_framepars, numPars);
MDP(DBGB_FSFP,sensor_port,"this_framepars=0x%x numPars=%d\n", (int)this_framepars, numPars)
for (npar = 0; npar < numPars; npar++) { for (npar = 0; npar < numPars; npar++) {
frame16 = (this_framepars->pars[P_FRAME]) & PARS_FRAMES_MASK; frame16 = (this_framepars->pars[P_FRAME]) & PARS_FRAMES_MASK;
val = pars[npar].val; val = pars[npar].val;
index = pars[npar].num & 0xffff; index = pars[npar].num & 0xffff;
dev_dbg(g_devfp_ptr, ": --- frame16=%d index=%d (0x%x) val=0x%x\n", frame16, index, (int)pars[npar].num, (int)val); dev_dbg(g_devfp_ptr, ": --- frame16=%d index=%d (0x%x) val=0x%x\n", frame16, index, (int)pars[npar].num, (int)val);
MDP(DBGB_FSFV,sensor_port," --- frame16=%d index=%d (0x%x) val=0x%x\n", frame16, index, (int)pars[npar].num, (int)val)
// remark: code below looks similar to setFramePar function, call it instead // remark: code below looks similar to setFramePar function, call it instead
if (index > ((index >= FRAMEPAR_GLOBALS) ? (P_MAX_GPAR + FRAMEPAR_GLOBALS) : P_MAX_PAR)) { if (index > ((index >= FRAMEPAR_GLOBALS) ? (P_MAX_GPAR + FRAMEPAR_GLOBALS) : P_MAX_PAR)) {
dev_err(g_devfp_ptr, " bad index=%d > %d\n", index, P_MAX_PAR); dev_err(g_devfp_ptr, " bad index=%d > %d\n", index, P_MAX_PAR);
...@@ -1333,13 +1321,16 @@ int setFramePars(int sensor_port, ///< sensor port number (0 ...@@ -1333,13 +1321,16 @@ int setFramePars(int sensor_port, ///< sensor port number (0
} }
// Write parameter to the next frames up to the one that have the same parameter already modified (only if not FRAMEPAIR_JUST_THIS) // Write parameter to the next frames up to the one that have the same parameter already modified (only if not FRAMEPAIR_JUST_THIS)
if ((pars[npar].num & FRAMEPAIR_JUST_THIS) == 0) { if ((pars[npar].num & FRAMEPAIR_JUST_THIS) == 0) {
MDF8(printk(": --- setting next frames")); // MDF8(printk(": --- setting next frames"));
for (nframe = (frame16 + 1) & PARS_FRAMES_MASK; (nframe != findex_prev) && (!(framepars[nframe].mod[bindex] & bmask)); nframe = (nframe + 1) & PARS_FRAMES_MASK) { for (nframe = (frame16 + 1) & PARS_FRAMES_MASK; (nframe != findex_prev) && (!(framepars[nframe].mod[bindex] & bmask)); nframe = (nframe + 1) & PARS_FRAMES_MASK) {
D8(printk(" %d", nframe));
framepars[nframe].pars[index] = val; framepars[nframe].pars[index] = val;
// D8(printk(" %d", nframe));
MDP(DBGB_FSFV,sensor_port,"framepars[%d].pars[%d] <- 0x%08x ", 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 frame16 = (frame16 - 1) & PARS_FRAMES_MASK; // for " regular parameters "modified since" do not include the target frame itself, for "JUST_THIS" - does
D8(printk("\n")); MDP(DBGB_FSFV,sensor_port,"%s\n", "")
// D8(printk("\n"));
} }
// Mark this parameter in all previous frames as "modified since" // Mark this parameter in all previous frames as "modified since"
// TODO: consider alternative way - first iterate through all parameters, build masks, then apply them // TODO: consider alternative way - first iterate through all parameters, build masks, then apply them
...@@ -1347,7 +1338,10 @@ int setFramePars(int sensor_port, ///< sensor port number (0 ...@@ -1347,7 +1338,10 @@ int setFramePars(int sensor_port, ///< sensor port number (0
for (nframe = frame16; nframe != findex_future; nframe = (nframe - 1) & PARS_FRAMES_MASK) { //NOTE: frame16 is modified here for (nframe = frame16; nframe != findex_future; nframe = (nframe - 1) & PARS_FRAMES_MASK) { //NOTE: frame16 is modified here
framepars[nframe].modsince[bindex] |= bmask; framepars[nframe].modsince[bindex] |= bmask;
framepars[nframe].modsince32 |= bmask32; framepars[nframe].modsince32 |= bmask32;
MDP(DBGB_FSFV,sensor_port,"framepars[%d].modsince[%d] |= 0x%08x, framepars[%d].modsince32 |= 0x%08x ",
nframe, bindex, bmask, nframe, bmask32)
} }
MDP(DBGB_FSFV,sensor_port,"%s\n", "")
} }
} else { // error - trying to write "just this" to the "future" - that would stick if allowed } else { // error - trying to write "just this" to the "future" - that would stick if allowed
dev_err(g_devfp_ptr, "Tried to write JUST_THIS parameter (0x%lx) too far in the future", pars[npar].num); dev_err(g_devfp_ptr, "Tried to write JUST_THIS parameter (0x%lx) too far in the future", pars[npar].num);
...@@ -1394,12 +1388,13 @@ int framepars_open(struct inode *inode, struct file *filp) ...@@ -1394,12 +1388,13 @@ int framepars_open(struct inode *inode, struct file *filp)
if (!privData) return -ENOMEM; if (!privData) return -ENOMEM;
filp->private_data = privData; filp->private_data = privData;
privData->minor = MINOR(inode->i_rdev); privData->minor = MINOR(inode->i_rdev);
dev_dbg(g_devfp_ptr,"%s : minor=0x%x\n",__func__, privData->minor); dev_dbg(g_devfp_ptr,"minor=0x%x\n",__func__, privData->minor);
switch (privData->minor) { switch (privData->minor) {
case DEV393_MINOR(DEV393_FRAMEPARS0): case DEV393_MINOR(DEV393_FRAMEPARS0):
case DEV393_MINOR(DEV393_FRAMEPARS1): case DEV393_MINOR(DEV393_FRAMEPARS1):
case DEV393_MINOR(DEV393_FRAMEPARS2): case DEV393_MINOR(DEV393_FRAMEPARS2):
case DEV393_MINOR(DEV393_FRAMEPARS3): case DEV393_MINOR(DEV393_FRAMEPARS3):
MDP(DBGB_FFOP,privData->minor-DEV393_MINOR(DEV393_FRAMEPARS0),"minor=0x%x\n",privData->minor)
inode->i_size = 0; //or return 8 - number of frame pages? inode->i_size = 0; //or return 8 - number of frame pages?
return 0; return 0;
default: default:
...@@ -1426,6 +1421,7 @@ int framepars_release(struct inode *inode, struct file *filp) ...@@ -1426,6 +1421,7 @@ int framepars_release(struct inode *inode, struct file *filp)
case DEV393_MINOR(DEV393_FRAMEPARS1): case DEV393_MINOR(DEV393_FRAMEPARS1):
case DEV393_MINOR(DEV393_FRAMEPARS2): case DEV393_MINOR(DEV393_FRAMEPARS2):
case DEV393_MINOR(DEV393_FRAMEPARS3): case DEV393_MINOR(DEV393_FRAMEPARS3):
MDP(DBGB_FFOP,p-DEV393_MINOR(DEV393_FRAMEPARS0),"minor=0x%x\n",p)
break; break;
default: default:
return -EINVAL; //! do not need to free anything - "wrong number" return -EINVAL; //! do not need to free anything - "wrong number"
...@@ -1455,6 +1451,7 @@ loff_t framepars_lseek(struct file * file, loff_t offset, int orig) ...@@ -1455,6 +1451,7 @@ loff_t framepars_lseek(struct file * file, loff_t offset, int orig)
sec_usec_t sec_usec; sec_usec_t sec_usec;
// struct framepars_t *framepars = aframepars[sensor_port]; // struct framepars_t *framepars = aframepars[sensor_port];
dev_dbg(g_devfp_ptr, "(framepars_lseek) offset=0x%x, orig=0x%x, sensor_port = %d\n", (int)offset, (int)orig, sensor_port); dev_dbg(g_devfp_ptr, "(framepars_lseek) offset=0x%x, orig=0x%x, sensor_port = %d\n", (int)offset, (int)orig, sensor_port);
MDP(DBGB_FFOP, sensor_port, "(framepars_lseek) offset=0x%x, orig=0x%x\n", (int)offset, (int)orig)
switch (orig) { switch (orig) {
case SEEK_SET: case SEEK_SET:
...@@ -1570,8 +1567,12 @@ ssize_t framepars_write(struct file * file, const char * buf, size_t count, loff ...@@ -1570,8 +1567,12 @@ ssize_t framepars_write(struct file * file, const char * buf, size_t count, loff
int result; int result;
sec_usec_t sec_usec; sec_usec_t sec_usec;
// dev_dbg(g_devfp_ptr,"%s : file->f_pos=0x%x, *off=0x%x, count=0x%x\n",__func__, (int)file->f_pos, (int)*off, (int)count); // dev_dbg(g_devfp_ptr,"%s : file->f_pos=0x%x, *off=0x%x, count=0x%x\n",__func__, (int)file->f_pos, (int)*off, (int)count);
dev_dbg(g_devfp_ptr, "%s: file->f_pos=0x%x, *off=0x%x, count=0x%x, minor=0x%x\n", dev_dbg(g_devfp_ptr, "file->f_pos=0x%x, *off=0x%x, count=0x%x, minor=0x%x\n",
__func__, (int)file->f_pos, (int)*off, (int)count, (int) privData->minor); (int)file->f_pos, (int)*off, (int)count, (int) privData->minor);
MDP(DBGB_FFOP, sensor_port, "file->f_pos=0x%x, *off=0x%x, count=0x%x, minor=0x%x\n",
(int)file->f_pos, (int)*off, (int)count, (int) privData->minor)
count &= ~7; // sizeof (struct frameparspair_t)==8 count &= ~7; // sizeof (struct frameparspair_t)==8
switch (privData->minor) { switch (privData->minor) {
case DEV393_MINOR(DEV393_FRAMEPARS0): case DEV393_MINOR(DEV393_FRAMEPARS0):
...@@ -1619,8 +1620,10 @@ ssize_t framepars_write(struct file * file, const char * buf, size_t count, loff ...@@ -1619,8 +1620,10 @@ ssize_t framepars_write(struct file * file, const char * buf, size_t count, loff
} }
last = first + 1; last = first + 1;
while ((last < count) && ((pars[last].num & 0xff00) != 0xff00)) last++; // skip to the end or next special instructions while ((last < count) && ((pars[last].num & 0xff00) != 0xff00)) last++; // skip to the end or next special instructions
dev_dbg(g_devfp_ptr, "%s 0x%x: setFrameParsAtomic(%ld, %d, %d)\n", dev_dbg(g_devfp_ptr, "0x%x: setFrameParsAtomic(%ld, %d, %d)\n",
__func__, (int) privData->minor, frame, latency, last - first); (int) privData->minor, frame, latency, last - first);
MDP(DBGB_FFOP, sensor_port, "0x%x: setFrameParsAtomic(%ld, %d, %d)\n",
(int) privData->minor, frame, latency, last - first)
result = setFrameParsAtomic(sensor_port,frame, latency, last - first, &pars[first]); result = setFrameParsAtomic(sensor_port,frame, latency, last - first, &pars[first]);
if (result < 0) { if (result < 0) {
if (count > sizeof(pars_static)) kfree(pars); if (count > sizeof(pars_static)) kfree(pars);
...@@ -1661,6 +1664,8 @@ int framepars_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1661,6 +1664,8 @@ int framepars_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_end - vma->vm_start, vma->vm_end - vma->vm_start,
vma->vm_page_prot); vma->vm_page_prot);
dev_dbg(g_devfp_ptr, "remap_pfn_range returned=%x\n", result); dev_dbg(g_devfp_ptr, "remap_pfn_range returned=%x\n", result);
MDP(DBGB_FFOP, sensor_port, "remap_pfn_range returned=%x\n", result)
if (result) return -EAGAIN; if (result) return -EAGAIN;
return 0; return 0;
default: return -EINVAL; default: return -EINVAL;
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
*/ */
//copied from cxi2c.c - TODO:remove unneeded //copied from cxi2c.c - TODO:remove unneeded
#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg) //#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg)
#include <linux/module.h> #include <linux/module.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/sched.h> #include <linux/sched.h>
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
*/ */
//copied from cxi2c.c - TODO:remove unneeded //copied from cxi2c.c - TODO:remove unneeded
#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg) //#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg)
#include <linux/module.h> #include <linux/module.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/sched.h> #include <linux/sched.h>
......
...@@ -18,9 +18,12 @@ ...@@ -18,9 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/platform_device.h> // For sysfs #include <linux/platform_device.h> // For sysfs
#include <linux/slab.h> //kzalloc
#include <linux/fs.h> #include <linux/fs.h>
#include <asm/uaccess.h> // copy_*_user #include <asm/uaccess.h> // copy_*_user
#include <linux/of.h> // Device Tree #include <linux/of.h> // Device Tree
...@@ -39,6 +42,7 @@ ...@@ -39,6 +42,7 @@
//#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)
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
static u32 buffer_size = 0; static u32 buffer_size = 0;
...@@ -46,22 +50,81 @@ static u32 buffer_size = 0; ...@@ -46,22 +50,81 @@ static u32 buffer_size = 0;
static u32 buffer_size_order = 0; static u32 buffer_size_order = 0;
#endif #endif
static u32 klog_mode=0xff;
static u32 buffer_wp = 0; static u32 buffer_wp = 0;
static u32 num_writes = 0;
static loff_t file_size = 0; // write pointer, 64 bits static loff_t file_size = 0; // write pointer, 64 bits
static char * klog393_buf = NULL; static char * klog393_buf = NULL;
const char klogger393_of_prop_name[] = "klogger-393,buffer_size"; const char klogger393_of_prop_bufsize_name[] = "klogger-393,buffer_size";
const static u32 max_string_len = PAGE_SIZE; ///< maximal string length const static u32 max_string_len = PAGE_SIZE; ///< maximal string length
int klogger393_open(struct inode *inode, struct file *filp); int klogger393_open(struct inode *inode, struct file *filp);
int klogger393_release(struct inode *inode, struct file *filp); int klogger393_release(struct inode *inode, struct file *filp);
loff_t klogger393_llseek(struct file * file, loff_t offset, int orig); loff_t klogger393_llseek(struct file * file, loff_t offset, int orig);
ssize_t klogger393_read (struct file * file, char * buf, size_t count, loff_t *off); ssize_t klogger393_read (struct file * file, char * buf, size_t count, loff_t *off);
// printk();
int print_klog393(const int mode, ///< bits 0: timestamp, 1 - file, 2 - function, 3 - line number, 4 - lock, irq & disable. all 0 - disabled
const char *file, /// file path to show
const char *function, /// function name to show
const int line, // line number to show
const char *fmt, ...) ///< Format and argumants as in printf
{
char buf[1024];
const char * cp;
sec_usec_t ts;
va_list args;
int mmode= mode & klog_mode;
if (!mmode){
return 0;
}
if (mmode & 16){
spin_lock_bh(&klogger_lock);
}
if (mmode & 1) {
get_fpga_rtc(&ts);
snprintf(buf,sizeof(buf),"%ld.%06ld:",ts.sec,ts.usec);
klog393_puts(buf);
}
if ((mmode & 2) && file) {
cp = strrchr(file,'/');
cp = cp? (cp+1):file;
snprintf(buf,sizeof(buf),"%s:",cp);
klog393_puts(buf);
}
if ((mmode & 4) && function) {
snprintf(buf,sizeof(buf),"%s:",function);
klog393_puts(buf);
}
if ((mmode & 8) && line) {
snprintf(buf,sizeof(buf),"%d:",line);
klog393_puts(buf);
}
va_start(args, fmt);
vsnprintf(buf,sizeof(buf),fmt,args);
va_end(args);
klog393_puts(buf);
if (mmode & 16){
spin_unlock_bh(&klogger_lock);
}
return 0;
}
/** Put string into the logger buffer*/ /** Put string into the logger buffer*/
int klog393_puts(const char * str) ///< String to log, limited by max_string_len (currently 4096 bytes) int klog393_puts(const char * str) ///< String to log, limited by max_string_len (currently 4096 bytes)
///< @return 0 - OK, -EMSGSIZE - string too long ///< @return 0 - OK, -EMSGSIZE - string too long
{ {
int sl = strlen(str); int sl = strlen(str);
u32 new_wp= buffer_wp+sl; u32 new_wp= buffer_wp+sl;
if (!(klog_mode & 0x80)){
return 0; // DEBUGGING: Do nothing if bit 7 == 0
}
// u32 pl; // u32 pl;
if (sl > max_string_len){ if (sl > max_string_len){
dev_err(g_dev_ptr,"%s: String too long (%d >%d)\n", dev_err(g_dev_ptr,"%s: String too long (%d >%d)\n",
...@@ -78,6 +141,7 @@ int klog393_puts(const char * str) ///< String to log, limited by max_string_len ...@@ -78,6 +141,7 @@ int klog393_puts(const char * str) ///< String to log, limited by max_string_len
buffer_wp = new_wp - buffer_size; buffer_wp = new_wp - buffer_size;
} }
file_size += sl; file_size += sl;
num_writes++;
return 0; return 0;
} }
/** Put string into the logger buffer, preceded by a timestamp "<sec>.<usec>: "*/ /** Put string into the logger buffer, preceded by a timestamp "<sec>.<usec>: "*/
...@@ -236,6 +300,54 @@ ssize_t klogger393_read (struct file * file, ///< file structure pointer ...@@ -236,6 +300,54 @@ ssize_t klogger393_read (struct file * file, ///< file structure pointer
} }
} }
// SysFS interface to read/modify video memory map
#define SYSFS_PERMISSIONS 0644 /* default permissions for sysfs files */
#define SYSFS_READONLY 0444
#define SYSFS_WRITEONLY 0222
static ssize_t show_mode(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf,"0x%x\n", klog_mode);
}
static ssize_t store_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
sscanf(buf, "%i", &klog_mode);
return count;
}
static ssize_t show_stats(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf,"Number of writes: 0x%x\n"
"Buffer size: 0x%x (%d)\n"
"Buffer write pointer: 0x%x (%d)\n"
"File size: 0x%llx (%lld)\n"
"Mode: 0x%x\n",
num_writes, buffer_size, buffer_size, buffer_wp, buffer_wp, file_size, file_size, klog_mode);
}
static DEVICE_ATTR(klogger_mode, SYSFS_PERMISSIONS, show_mode, store_mode);
static DEVICE_ATTR(klogger_stats, SYSFS_READONLY, show_stats, NULL);
static struct attribute *root_dev_attrs[] = {
&dev_attr_klogger_mode.attr,
&dev_attr_klogger_stats.attr,
NULL
};
static const struct attribute_group dev_attr_root_group = {
.attrs = root_dev_attrs,
.name = NULL,
};
static int klogger_393_sysfs_register(struct platform_device *pdev)
{
int retval=0;
struct device *dev = &pdev->dev;
if (&dev->kobj) {
if (((retval = sysfs_create_group(&dev->kobj, &dev_attr_root_group)))<0) return retval;
}
return retval;
}
int klogger_393_probe(struct platform_device *pdev) int klogger_393_probe(struct platform_device *pdev)
{ {
...@@ -243,19 +355,34 @@ int klogger_393_probe(struct platform_device *pdev) ...@@ -243,19 +355,34 @@ int klogger_393_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
const char * config_string; const char * config_string;
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
const __be32 *bufsize_be;
g_dev_ptr = dev; g_dev_ptr = dev;
buffer_wp = 0; buffer_wp = 0;
if (node) { if (node) {
if (of_property_read_string(node, klogger393_of_prop_name, &config_string)) { #if 0
if (of_property_read_string(node, klogger393_of_prop_bufsize_name, &config_string)) {
dev_err(dev,"%s: Device tree has entry for "DEV393_NAME(DEV393_KLOGGER)", but no '%s' property is provided\n", dev_err(dev,"%s: Device tree has entry for "DEV393_NAME(DEV393_KLOGGER)", but no '%s' property is provided\n",
__func__,klogger393_of_prop_name); __func__,klogger393_of_prop_bufsize_name);
return -EINVAL; return -EINVAL;
} }
if (!sscanf(config_string,"%i", &buffer_size)){ if (!sscanf(config_string,"%i", &buffer_size)){
dev_err(dev,"%s: Invalid buffer size for "DEV393_NAME(DEV393_KLOGGER)".%s - %s\n", dev_err(dev,"%s: Invalid buffer size for "DEV393_NAME(DEV393_KLOGGER)".%s - %s\n",
__func__,klogger393_of_prop_name,config_string); __func__,klogger393_of_prop_bufsize_name,config_string);
return -EINVAL; return -EINVAL;
} }
#endif
bufsize_be = (__be32 *)of_get_property(node, klogger393_of_prop_bufsize_name, NULL);
if (!bufsize_be) {
dev_err(dev,"%s: Device tree has entry for "DEV393_NAME(DEV393_KLOGGER)", but no '%s' property is provided\n",
__func__,klogger393_of_prop_bufsize_name);
return -EINVAL;
}
buffer_size = be32_to_cpup(bufsize_be);
//__builtin_clz //__builtin_clz
#ifndef KLOGGER_BUFFER_ANY_SIZE #ifndef KLOGGER_BUFFER_ANY_SIZE
buffer_size_order = 31 - __builtin_clz(buffer_size); buffer_size_order = 31 - __builtin_clz(buffer_size);
...@@ -266,17 +393,23 @@ int klogger_393_probe(struct platform_device *pdev) ...@@ -266,17 +393,23 @@ int klogger_393_probe(struct platform_device *pdev)
__func__,buffer_size,buffer_size); __func__,buffer_size,buffer_size);
} }
#endif #endif
klog393_buf = devm_kzalloc(dev, buffer_size, GFP_KERNEL); dev_info(dev,"%s: Setting up buffer for logging "DEV393_NAME(DEV393_KLOGGER)" of %d(0x%x) bytes\n",
__func__,buffer_size,buffer_size);
// klog393_buf = devm_kzalloc(dev, buffer_size, GFP_KERNEL);
klog393_buf = kzalloc(buffer_size, GFP_KERNEL);
if (!klog393_buf){ if (!klog393_buf){
buffer_size = 0; buffer_size = 0;
dev_err(dev,"%s: Failed to create buffer for "DEV393_NAME(DEV393_KLOGGER)" of %d(0x%x) bytes\n", dev_err(dev,"%s: Failed to create buffer for "DEV393_NAME(DEV393_KLOGGER)" of %d(0x%x) bytes\n",
__func__,buffer_size,buffer_size); __func__,buffer_size,buffer_size);
return -ENOMEM; return -ENOMEM;
} }
res = register_chrdev(DEV393_MAJOR(DEV393_FRAMEPARS0), DEV393_NAME(DEV393_FRAMEPARS0), &framepars_fops); dev_info(dev,"%s: Set up buffer for logging "DEV393_NAME(DEV393_KLOGGER)" of %d(0x%x) bytes @0x%08x\n",
__func__,buffer_size,buffer_size, (int) klog393_buf);
res = register_chrdev(DEV393_MAJOR(DEV393_KLOGGER), DEV393_NAME(DEV393_KLOGGER), &framepars_fops);
if (res < 0) { if (res < 0) {
dev_err(dev, "framepars_init: couldn't get a major number %d (DEV393_MAJOR(DEV393_FRAMEPARS0)).\n", dev_err(dev, "framepars_init: couldn't get a major number %d (DEV393_MAJOR(DEV393_KLOGGER)).\n",
DEV393_MAJOR(DEV393_FRAMEPARS0)); DEV393_MAJOR(DEV393_KLOGGER));
return res; return res;
} }
...@@ -288,15 +421,16 @@ int klogger_393_probe(struct platform_device *pdev) ...@@ -288,15 +421,16 @@ int klogger_393_probe(struct platform_device *pdev)
// klogger_393_sysfs_register(pdev); res = klogger_393_sysfs_register(pdev);
// dev_info(dev, DEV393_NAME(DEV393_KLOGGER)": registered sysfs\n"); dev_info(dev, DEV393_NAME(DEV393_KLOGGER)": registered sysfs, result = %d\n", res);
return 0; return 0;
} }
int klogger_393_remove(struct platform_device *pdev) int klogger_393_remove(struct platform_device *pdev)
{ {
if (klog393_buf) if (klog393_buf) {
devm_kfree(&pdev->dev, klog393_buf); // devm_kfree(&pdev->dev, klog393_buf); // actually not needed
}
unregister_chrdev(DEV393_MAJOR(DEV393_KLOGGER), DEV393_NAME(DEV393_KLOGGER)); unregister_chrdev(DEV393_MAJOR(DEV393_KLOGGER), DEV393_NAME(DEV393_KLOGGER));
return 0; return 0;
......
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
*/ */
#ifndef KLOGGER_393_H #ifndef KLOGGER_393_H
#define KLOGGER_393_H #define KLOGGER_393_H
//int print_klog393(const int mode, const char *fmt, ...);
int print_klog393(const int mode, const char *file, const char *function, const int line, const char *fmt, ...);
int klog393_puts(const char * str); int klog393_puts(const char * str);
int klog393_ts(const char * str); int klog393_ts(const char * str);
......
...@@ -323,7 +323,7 @@ ...@@ -323,7 +323,7 @@
// //
*/ */
#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg) //#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg)
/****************** INCLUDE FILES SECTION ***********************************/ /****************** INCLUDE FILES SECTION ***********************************/
#include <linux/types.h> // for div 64 #include <linux/types.h> // for div 64
#include <asm/div64.h> // for div 64 #include <asm/div64.h> // for div 64
......
...@@ -180,7 +180,7 @@ ...@@ -180,7 +180,7 @@
*/ */
// TODO:remove unneeded // TODO:remove unneeded
#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg) //#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg)
#include <linux/types.h> // for div 64 #include <linux/types.h> // for div 64
#include <asm/div64.h> // for div 64 #include <asm/div64.h> // for div 64
...@@ -217,8 +217,13 @@ ...@@ -217,8 +217,13 @@
#include "x393_videomem.h" #include "x393_videomem.h"
#include "detect_sensors.h" #include "detect_sensors.h"
// NC393 debug macros
#include "debug393.h"
/** /**
* @brief optional debug output macros * @brief optional debug output macros (obsolete)
*/ */
#if ELPHEL_DEBUG #if ELPHEL_DEBUG
// #define MDF2(x) { if (GLOBALPARS(G_DEBUG) & (1 <<2)) {printk("%s:%d:%s ",__FILE__,__LINE__,__FUNCTION__ );x ;} } // #define MDF2(x) { if (GLOBALPARS(G_DEBUG) & (1 <<2)) {printk("%s:%d:%s ",__FILE__,__LINE__,__FUNCTION__ );x ;} }
...@@ -295,6 +300,8 @@ int init_pgm_proc(int sensor_port) ...@@ -295,6 +300,8 @@ int init_pgm_proc(int sensor_port)
int i; int i;
struct sensorproc_t * sensorproc = &asensorproc[sensor_port]; struct sensorproc_t * sensorproc = &asensorproc[sensor_port];
dev_dbg(g_dev_ptr,"Initializing generic parameter-triggered function, port=%d\n",sensor_port); // OK NULL device here (not yet set) dev_dbg(g_dev_ptr,"Initializing generic parameter-triggered function, port=%d\n",sensor_port); // OK NULL device here (not yet set)
MDP(DBGB_PSFN,sensor_port,"Initializing generic parameter-triggered function, %s\n","") // OK NULL device here (not yet set)
for (i=0;i<64;i++) sensorproc->pgm_func[i]=NULL; for (i=0;i<64;i++) sensorproc->pgm_func[i]=NULL;
sensorproc->pgm_func[onchange_recalcseq]= &pgm_recalcseq; // recalculate sequences/latencies, according to P_SKIP, P_TRIG sensorproc->pgm_func[onchange_recalcseq]= &pgm_recalcseq; // recalculate sequences/latencies, according to P_SKIP, P_TRIG
sensorproc->pgm_func[onchange_detectsensor]= &pgm_detectsensor; // detect sensor type, sets sensor structure (capabilities), function pointers sensorproc->pgm_func[onchange_detectsensor]= &pgm_detectsensor; // detect sensor type, sets sensor structure (capabilities), function pointers
...@@ -339,6 +346,7 @@ int add_sensor_proc(int port, ///< sensor port ...@@ -339,6 +346,7 @@ int add_sensor_proc(int port, ///< sensor port
///< @return always 0 ///< @return always 0
{ {
dev_dbg(g_dev_ptr,"add_sensor_proc(%d, 0x%x,...)\n", port, index); dev_dbg(g_dev_ptr,"add_sensor_proc(%d, 0x%x,...)\n", port, index);
MDP(DBGB_PSFN, port,"add_sensor_proc(%d, 0x%x,...)\n", port, index)
asensorproc[port].pgm_func[32+(index & 0x1f)]= sens_func; asensorproc[port].pgm_func[32+(index & 0x1f)]= sens_func;
return 0; return 0;
} }
...@@ -356,12 +364,14 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number ( ...@@ -356,12 +364,14 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number (
///< @return OK - 0, <0 - error ///< @return OK - 0, <0 - error
{ {
x393_camsync_mode_t camsync_mode = {.d32=0}; x393_camsync_mode_t camsync_mode = {.d32=0};
int was_sensor_freq; int was_sensor_freq = 0; // 90000000; // getClockFreq(1);
int qperiod; int qperiod;
int i2cbytes; int i2cbytes;
int phase; int phase;
int mux,sens; int mux,sens;
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
if (frame16 >= 0) return -1; // can only work in ASAP mode if (frame16 >= 0) return -1; // can only work in ASAP mode
if (thispars->pars[P_SENSOR]) { if (thispars->pars[P_SENSOR]) {
dev_dbg(g_dev_ptr,"{%d} frame16=%d, SENSOR ALREADY DETECTED = %d\n",sensor_port,frame16, (int) thispars->pars[P_SENSOR]); dev_dbg(g_dev_ptr,"{%d} frame16=%d, SENSOR ALREADY DETECTED = %d\n",sensor_port,frame16, (int) thispars->pars[P_SENSOR]);
...@@ -403,10 +413,13 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number ( ...@@ -403,10 +413,13 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number (
if (mux != SENSOR_NONE) { if (mux != SENSOR_NONE) {
dev_dbg(g_dev_ptr,"Mux mode for port %d is %d, tryng 10359\n",sensor_port, mux); dev_dbg(g_dev_ptr,"Mux mode for port %d is %d, tryng 10359\n",sensor_port, mux);
MDP(DBGB_PADD, sensor_port,"Mux mode for port %d is %d, tryng 10359\n",sensor_port, mux)
// try multisensor here (before removing MRST) // try multisensor here (before removing MRST)
multisensor_pgm_detectsensor (sensor_port, sensor, thispars, prevpars, frame16); // multisensor multisensor_pgm_detectsensor (sensor_port, sensor, thispars, prevpars, frame16); // multisensor
} else { } else {
dev_dbg(g_dev_ptr,"Mux mode for port %d SENSOR_NONE, skipping 10359 detection\n",sensor_port); dev_dbg(g_dev_ptr,"Mux mode for port %d SENSOR_NONE, skipping 10359 detection\n",sensor_port);
MDP(DBGB_PADD, sensor_port,"Mux mode for port %d SENSOR_NONE, skipping 10359 detection\n",sensor_port)
} }
// if ((thispars->pars[P_SENSOR]==0) || // multisensor not detected // if ((thispars->pars[P_SENSOR]==0) || // multisensor not detected
// ((thispars->pars[P_SENSOR] & SENSOR_MASK) == SENSOR_MT9X001)) { // or is (from DT) SENSOR_MT9X001 // ((thispars->pars[P_SENSOR] & SENSOR_MASK) == SENSOR_MT9X001)) { // or is (from DT) SENSOR_MT9X001
...@@ -416,6 +429,7 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number ( ...@@ -416,6 +429,7 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number (
// dev_dbg(g_dev_ptr,"removing MRST from the sensor\n"); // dev_dbg(g_dev_ptr,"removing MRST from the sensor\n");
// dev_info(g_dev_ptr,"pgm_detectsensor(%d): TRYING MT9P001\n",sensor_port); // dev_info(g_dev_ptr,"pgm_detectsensor(%d): TRYING MT9P001\n",sensor_port);
dev_dbg(g_dev_ptr,"trying MT9P001, port=%d\n",sensor_port); dev_dbg(g_dev_ptr,"trying MT9P001, port=%d\n",sensor_port);
MDP(DBGB_PADD, sensor_port,"trying MT9P001, port=%d\n",sensor_port)
mt9x001_pgm_detectsensor(sensor_port, sensor, thispars, prevpars, frame16); // try Micron 5.0 Mpixel - should return sensor type mt9x001_pgm_detectsensor(sensor_port, sensor, thispars, prevpars, frame16); // try Micron 5.0 Mpixel - should return sensor type
} }
setFramePar(sensor_port, thispars, P_CLK_FPGA, 200000000); // FIXME: NC393 setFramePar(sensor_port, thispars, P_CLK_FPGA, 200000000); // FIXME: NC393
...@@ -423,6 +437,7 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number ( ...@@ -423,6 +437,7 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number (
if (thispars->pars[P_SENSOR] == SENSOR_DETECT) { if (thispars->pars[P_SENSOR] == SENSOR_DETECT) {
sensor->sensorType=SENSOR_NONE; // to prevent from initializing again sensor->sensorType=SENSOR_NONE; // to prevent from initializing again
dev_dbg(g_dev_ptr,"No image sensor found\n"); dev_dbg(g_dev_ptr,"No image sensor found\n");
MDP(DBGB_PADD, sensor_port,"No image sensor found%s\n","")
} }
setFramePar(sensor_port, thispars, P_SENSOR_WIDTH, sensor->imageWidth); // Maybe get rid of duplicates? setFramePar(sensor_port, thispars, P_SENSOR_WIDTH, sensor->imageWidth); // Maybe get rid of duplicates?
setFramePar(sensor_port, thispars, P_SENSOR_HEIGHT, sensor->imageHeight); // Maybe get rid of duplicates? setFramePar(sensor_port, thispars, P_SENSOR_HEIGHT, sensor->imageHeight); // Maybe get rid of duplicates?
...@@ -602,6 +617,7 @@ int pgm_initsensor (int sensor_port, ///< sensor port number ( ...@@ -602,6 +617,7 @@ int pgm_initsensor (int sensor_port, ///< sensor port number (
///< @return always 0 ///< @return always 0
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
if (frame16 >= 0) return -1; // should be ASAP if (frame16 >= 0) return -1; // should be ASAP
//TODO: seems nothing to do here - all in the sensor-specific function: //TODO: seems nothing to do here - all in the sensor-specific function:
return 0; return 0;
...@@ -621,13 +637,16 @@ int pgm_afterinit (int sensor_port, ///< sensor port number ( ...@@ -621,13 +637,16 @@ int pgm_afterinit (int sensor_port, ///< sensor port number (
{ {
struct frameparspair_t pars_to_update[24]; // 20 needed, increase if more entries will be added struct frameparspair_t pars_to_update[24]; // 20 needed, increase if more entries will be added
int nupdate=0; int nupdate=0;
int woi_width, woi_height;
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
// If this is a multisensor camera, update composite sensor dimensions (will trigger other related changes) // If this is a multisensor camera, update composite sensor dimensions (will trigger other related changes)
// For single sensors sensor size is updated only after initialization, with composite it needs to be updated after vertical gap or number of active sesnors is changed // For single sensors sensor size is updated only after initialization, with composite it needs to be updated after vertical gap or number of active sesnors is changed
// if (GLOBALPARS(G_SENS_AVAIL) ) multisensor_pgm_afterinit0 (sensor, thispars, prevpars,frame16); // if (GLOBALPARS(G_SENS_AVAIL) ) multisensor_pgm_afterinit0 (sensor, thispars, prevpars,frame16);
// Setup WOI. If size is zero - use maximal that sensor can, in non-zero - just refresh so appropriate actions will be scheduled on chnange // Setup WOI. If size is zero - use maximal that sensor can, in non-zero - just refresh so appropriate actions will be scheduled on chnange
int woi_width=thispars->pars[P_WOI_WIDTH]; woi_width=thispars->pars[P_WOI_WIDTH];
int woi_height=thispars->pars[P_WOI_HEIGHT]; woi_height=thispars->pars[P_WOI_HEIGHT];
if ((woi_width == 0) || (woi_height == 0)) { ///were zeroes if ((woi_width == 0) || (woi_height == 0)) { ///were zeroes
woi_width= thispars->pars[P_SENSOR_WIDTH]; woi_width= thispars->pars[P_SENSOR_WIDTH];
woi_height=thispars->pars[P_SENSOR_HEIGHT]; woi_height=thispars->pars[P_SENSOR_HEIGHT];
...@@ -693,13 +712,14 @@ int pgm_sensorphase (int sensor_port, ///< sensor port number ( ...@@ -693,13 +712,14 @@ int pgm_sensorphase (int sensor_port, ///< sensor port number (
x393_sensio_tim3_t sensio_tim3 = {.d32=0}; x393_sensio_tim3_t sensio_tim3 = {.d32=0};
// TODO: Temporary for NC393 - just applying SENSOR_IFACE_TIM0 - SENSOR_IFACE_TIM3 to FPGA, no calculations // TODO: Temporary for NC393 - just applying SENSOR_IFACE_TIM0 - SENSOR_IFACE_TIM3 to FPGA, no calculations
// Actual functionality should be moved to separate modules as they are different for parallel and hispi (may be more in the future) // Actual functionality should be moved to separate modules as they are different for parallel and hispi (may be more in the future)
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
if (FRAMEPAR_MODIFIED(P_SENSOR_IFACE_TIM0)) { if (FRAMEPAR_MODIFIED(P_SENSOR_IFACE_TIM0)) {
sensio_tim0.d32 = thispars->pars[P_SENSOR_IFACE_TIM0]; sensio_tim0.d32 = thispars->pars[P_SENSOR_IFACE_TIM0];
// X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_tim0, sensio_tim0); // X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_tim0, sensio_tim0);
set_x393_sensio_tim0 (sensio_tim0, sensor_port); // write directly, sequencer may be not operational set_x393_sensio_tim0 (sensio_tim0, sensor_port); // write directly, sequencer may be not operational
sensio_ctl.set_dly = 1; sensio_ctl.set_dly = 1;
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim0, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_tim0.d32); dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim0, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_tim0.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim0, 0x%x)\n", sensor_port, frame16, sensio_tim0.d32)
} }
if (FRAMEPAR_MODIFIED(P_SENSOR_IFACE_TIM1)) { if (FRAMEPAR_MODIFIED(P_SENSOR_IFACE_TIM1)) {
sensio_tim1.d32 = thispars->pars[P_SENSOR_IFACE_TIM1]; sensio_tim1.d32 = thispars->pars[P_SENSOR_IFACE_TIM1];
...@@ -707,6 +727,7 @@ int pgm_sensorphase (int sensor_port, ///< sensor port number ( ...@@ -707,6 +727,7 @@ int pgm_sensorphase (int sensor_port, ///< sensor port number (
set_x393_sensio_tim1 (sensio_tim1, sensor_port); // write directly, sequencer may be not operational set_x393_sensio_tim1 (sensio_tim1, sensor_port); // write directly, sequencer may be not operational
sensio_ctl.set_dly = 1; sensio_ctl.set_dly = 1;
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim1, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_tim1 .d32); dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim1, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_tim1 .d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim1, 0x%x)\n", sensor_port, frame16, sensio_tim1 .d32)
} }
if (FRAMEPAR_MODIFIED(P_SENSOR_IFACE_TIM2)) { if (FRAMEPAR_MODIFIED(P_SENSOR_IFACE_TIM2)) {
sensio_tim2.d32 = thispars->pars[P_SENSOR_IFACE_TIM2]; sensio_tim2.d32 = thispars->pars[P_SENSOR_IFACE_TIM2];
...@@ -714,6 +735,7 @@ int pgm_sensorphase (int sensor_port, ///< sensor port number ( ...@@ -714,6 +735,7 @@ int pgm_sensorphase (int sensor_port, ///< sensor port number (
set_x393_sensio_tim2 (sensio_tim2, sensor_port); // write directly, sequencer may be not operational set_x393_sensio_tim2 (sensio_tim2, sensor_port); // write directly, sequencer may be not operational
sensio_ctl.set_dly = 1; sensio_ctl.set_dly = 1;
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim2, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_tim2.d32); dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim2, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_tim2.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim2, 0x%x)\n",sensor_port, frame16, sensio_tim2.d32)
} }
if (FRAMEPAR_MODIFIED(P_SENSOR_IFACE_TIM3)) { if (FRAMEPAR_MODIFIED(P_SENSOR_IFACE_TIM3)) {
sensio_tim3.d32 = thispars->pars[P_SENSOR_IFACE_TIM3]; sensio_tim3.d32 = thispars->pars[P_SENSOR_IFACE_TIM3];
...@@ -721,15 +743,19 @@ int pgm_sensorphase (int sensor_port, ///< sensor port number ( ...@@ -721,15 +743,19 @@ int pgm_sensorphase (int sensor_port, ///< sensor port number (
set_x393_sensio_tim3 (sensio_tim3, sensor_port); // write directly, sequencer may be not operational set_x393_sensio_tim3 (sensio_tim3, sensor_port); // write directly, sequencer may be not operational
sensio_ctl.set_dly = 1; sensio_ctl.set_dly = 1;
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim3, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_tim3.d32); dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim3, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_tim3.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_tim3, 0x%x)\n", sensor_port, frame16, sensio_tim3.d32)
} }
if (get_port_interface == PARALLEL12){ if (get_port_interface(sensor_port) == PARALLEL12){
if (FRAMEPAR_MODIFIED(P_SENSOR_PHASE)) { // for parallel sensor it means quadrants: 90-degree shifts for data [1:0], hact [3:2] and vact [5:4] if (FRAMEPAR_MODIFIED(P_SENSOR_PHASE)) { // for parallel sensor it means quadrants: 90-degree shifts for data [1:0], hact [3:2] and vact [5:4]
sensio_ctl.quadrants = thispars->pars[P_SENSOR_PHASE] & 0x3f; sensio_ctl.quadrants = thispars->pars[P_SENSOR_PHASE] & 0x3f;
sensio_ctl.quadrants_set = 1; sensio_ctl.quadrants_set = 1;
} }
if (sensio_ctl.d32) if (sensio_ctl.d32) {
x393_sensio_ctrl(sensio_ctl, sensor_port); x393_sensio_ctrl(sensio_ctl, sensor_port);
dev_dbg(g_dev_ptr,"{%d} x393_sensio_ctrl(0x%08x, %d))\n",sensor_port, sensio_ctl.d32, sensor_port);
MDP(DBGB_PADD, sensor_port,"x393_sensio_ctrl(0x%08x, %d))\n", sensio_ctl.d32, sensor_port)
}
} else { } else {
/* TODO 393: Add HISPI code */ /* TODO 393: Add HISPI code */
...@@ -848,6 +874,7 @@ int pgm_exposure (int sensor_port, ///< sensor port number (0..3 ...@@ -848,6 +874,7 @@ int pgm_exposure (int sensor_port, ///< sensor port number (0..3
///< @return always 0 ///< @return always 0
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
return 0; return 0;
} }
...@@ -861,6 +888,7 @@ int pgm_i2c (int sensor_port, ///< sensor port number (0..3 ...@@ -861,6 +888,7 @@ int pgm_i2c (int sensor_port, ///< sensor port number (0..3
///< @return always 0 ///< @return always 0
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d (do nothing here?)\n",frame16)
if (frame16 >= PARS_FRAMES) return -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
#ifdef NC353 #ifdef NC353
int fpga_addr = frame16; int fpga_addr = frame16;
...@@ -885,6 +913,7 @@ int pgm_window (int sensor_port, ///< sensor port number (0..3 ...@@ -885,6 +913,7 @@ int pgm_window (int sensor_port, ///< sensor port number (0..3
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
return pgm_window_common (sensor_port, sensor, thispars, prevpars, frame16); return pgm_window_common (sensor_port, sensor, thispars, prevpars, frame16);
} }
...@@ -899,6 +928,7 @@ int pgm_window_safe (int sensor_port, ///< sensor port number (0.. ...@@ -899,6 +928,7 @@ int pgm_window_safe (int sensor_port, ///< sensor port number (0..
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
return pgm_window_common (sensor_port, sensor, thispars, prevpars, frame16); return pgm_window_common (sensor_port, sensor, thispars, prevpars, frame16);
} }
...@@ -1002,8 +1032,9 @@ int pgm_window_common (int sensor_port, ///< sensor port number ( ...@@ -1002,8 +1032,9 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
pf_stripes = height / (pfh * dv); pf_stripes = height / (pfh * dv);
if(pf_stripes < 1) pf_stripes = 1; if(pf_stripes < 1) pf_stripes = 1;
if (unlikely(thispars->pars[P_SENSOR_PIXV] != pfh)) { if (unlikely(thispars->pars[P_SENSOR_PIXV] != pfh)) {
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_SENSOR_PIXV, 0x%x)\n",sensor_port,pfh);
SETFRAMEPARS_SET(P_SENSOR_PIXV, pfh); SETFRAMEPARS_SET(P_SENSOR_PIXV, pfh);
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_SENSOR_PIXV, 0x%x)\n", sensor_port, pfh);
MDP(DBGB_PADD, sensor_port,"SETFRAMEPARS_SET(P_SENSOR_PIXV, 0x%x)\n", pfh)
} }
} else { } else {
if ((!oversize ) && (height > sensor_height)) height=sensor_height; if ((!oversize ) && (height > sensor_height)) height=sensor_height;
...@@ -1018,19 +1049,22 @@ int pgm_window_common (int sensor_port, ///< sensor port number ( ...@@ -1018,19 +1049,22 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
} }
// update photofinish height P_PF_HEIGHT // update photofinish height P_PF_HEIGHT
if (unlikely((thispars->pars[P_PF_HEIGHT] & 0xffff) != pfh)) { if (unlikely((thispars->pars[P_PF_HEIGHT] & 0xffff) != pfh)) {
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_PF_HEIGHT, 0x%x)\n", sensor_port,(int) ((thispars->pars[P_PF_HEIGHT] & 0xffff0000 ) | pfh));
SETFRAMEPARS_SET(P_PF_HEIGHT, (thispars->pars[P_PF_HEIGHT] & 0xffff0000 ) | pfh ); SETFRAMEPARS_SET(P_PF_HEIGHT, (thispars->pars[P_PF_HEIGHT] & 0xffff0000 ) | pfh );
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_PF_HEIGHT, 0x%x)\n", sensor_port,(int) ((thispars->pars[P_PF_HEIGHT] & 0xffff0000 ) | pfh));
MDP(DBGB_PADD, sensor_port,"SETFRAMEPARS_SET(P_PF_HEIGHT, 0x%x)\n", (int) ((thispars->pars[P_PF_HEIGHT] & 0xffff0000 ) | pfh))
} }
// update WOI height [P_WOI_HEIGHT // update WOI height [P_WOI_HEIGHT
if (unlikely(thispars->pars[P_WOI_HEIGHT] != height)) { if (unlikely(thispars->pars[P_WOI_HEIGHT] != height)) {
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_WOI_HEIGHT, 0x%x)\n",sensor_port,height);
SETFRAMEPARS_SET(P_WOI_HEIGHT, height); ///full height for the compressor (excluding margins) SETFRAMEPARS_SET(P_WOI_HEIGHT, height); ///full height for the compressor (excluding margins)
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_WOI_HEIGHT, 0x%x)\n", sensor_port, height);
MDP(DBGB_PADD, sensor_port,"SETFRAMEPARS_SET(P_WOI_HEIGHT, 0x%x)\n", height)
} }
// update P_ACTUAL_HEIGHT // update P_ACTUAL_HEIGHT
ah=height/dv; ah=height/dv;
if (unlikely(thispars->pars[P_ACTUAL_HEIGHT] != ah)) { if (unlikely(thispars->pars[P_ACTUAL_HEIGHT] != ah)) {
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_ACTUAL_HEIGHT, 0x%x)\n",sensor_port,ah);
SETFRAMEPARS_SET(P_ACTUAL_HEIGHT, ah); ///full height for the compressor (excluding margins) SETFRAMEPARS_SET(P_ACTUAL_HEIGHT, ah); ///full height for the compressor (excluding margins)
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_ACTUAL_HEIGHT, 0x%x)\n", sensor_port, ah);
MDP(DBGB_PADD, sensor_port,"SETFRAMEPARS_SET(P_ACTUAL_HEIGHT, 0x%x)\n", ah)
} }
// left margin // left margin
left = thispars->pars[P_WOI_LEFT]; left = thispars->pars[P_WOI_LEFT];
...@@ -1044,8 +1078,9 @@ int pgm_window_common (int sensor_port, ///< sensor port number ( ...@@ -1044,8 +1078,9 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
} }
// update P_WOI_LEFT // update P_WOI_LEFT
if (unlikely(thispars->pars[P_WOI_LEFT] != left)) { if (unlikely(thispars->pars[P_WOI_LEFT] != left)) {
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_WOI_LEFT, 0x%x)\n",sensor_port,left);
SETFRAMEPARS_SET(P_WOI_LEFT, left); SETFRAMEPARS_SET(P_WOI_LEFT, left);
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_WOI_LEFT, 0x%x)\n", sensor_port, left);
MDP(DBGB_PADD, sensor_port,"SETFRAMEPARS_SET(P_WOI_LEFT, 0x%x)\n", left)
} }
// top margin // top margin
...@@ -1061,8 +1096,9 @@ int pgm_window_common (int sensor_port, ///< sensor port number ( ...@@ -1061,8 +1096,9 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
} }
// update P_WOI_TOP // update P_WOI_TOP
if (unlikely(thispars->pars[P_WOI_TOP] != top)) { if (unlikely(thispars->pars[P_WOI_TOP] != top)) {
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_WOI_TOP, 0x%x)\n",sensor_port,top);
SETFRAMEPARS_SET(P_WOI_TOP, top); SETFRAMEPARS_SET(P_WOI_TOP, top);
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_WOI_TOP, 0x%x)\n", sensor_port, top);
MDP(DBGB_PADD, sensor_port,"SETFRAMEPARS_SET(P_WOI_TOP, 0x%x)\n", top)
} }
if (nupdate) setFramePars(sensor_port, thispars, nupdate, pars_to_update); // save changes, schedule functions if (nupdate) setFramePars(sensor_port, thispars, nupdate, pars_to_update); // save changes, schedule functions
return 0; return 0;
...@@ -1085,8 +1121,6 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3 ...@@ -1085,8 +1121,6 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3
{ {
// Calculate minimal frame period compressor can handle, apply requested fps, limit/program the sequencer // Calculate minimal frame period compressor can handle, apply requested fps, limit/program the sequencer
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame
struct frameparspair_t pars_to_update[8]; // 4 needed, increase if more entries will be added struct frameparspair_t pars_to_update[8]; // 4 needed, increase if more entries will be added
int nupdate=0; int nupdate=0;
int async=(thispars->pars[P_TRIG] & 4)?1:0; int async=(thispars->pars[P_TRIG] & 4)?1:0;
...@@ -1100,6 +1134,9 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3 ...@@ -1100,6 +1134,9 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3
uint64_t ull_min_period; uint64_t ull_min_period;
uint64_t ull_period; uint64_t ull_period;
#endif #endif
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 -1; // wrong frame
cycles=thispars->pars[P_TILES]; // number of tiles cycles=thispars->pars[P_TILES]; // number of tiles
// dev_dbg(g_dev_ptr,"{%d} tiles=%d(0x%x)\n",sensor_port,cycles,cycles); // dev_dbg(g_dev_ptr,"{%d} tiles=%d(0x%x)\n",sensor_port,cycles,cycles);
switch (thispars->pars[P_COLOR] & 0x0f){ switch (thispars->pars[P_COLOR] & 0x0f){
...@@ -1115,10 +1152,16 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3 ...@@ -1115,10 +1152,16 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3
} }
cycles *=64 *2; //cycles per frame (64 pixels/block, 2 clock cycles/pixel) cycles *=64 *2; //cycles per frame (64 pixels/block, 2 clock cycles/pixel)
dev_dbg(g_dev_ptr,"{%d} cycles=%d(0x%x)\n",sensor_port,cycles,cycles); dev_dbg(g_dev_ptr,"{%d} cycles=%d(0x%x)\n",sensor_port,cycles,cycles);
MDP(DBGB_PADD, sensor_port,"cycles=%d(0x%x)\n",cycles,cycles)
cycles += thispars->pars[P_FPGA_XTRA]; // extra cycles needed for the compressor to start/finish the frame; cycles += thispars->pars[P_FPGA_XTRA]; // extra cycles needed for the compressor to start/finish the frame;
dev_dbg(g_dev_ptr,"{%d} cycles with P_FPGA_XTRA =%d(0x%x)\n",sensor_port,cycles,cycles); dev_dbg(g_dev_ptr,"{%d} cycles with P_FPGA_XTRA =%d(0x%x)\n",sensor_port,cycles,cycles);
MDP(DBGB_PADD, sensor_port,"cycles with P_FPGA_XTRA =%d(0x%x)\n",cycles,cycles)
// #define P_CLK_FPGA, #define P_CLK_SENSOR 27-28 bits, cycles - 24-25 bits // #define P_CLK_FPGA, #define P_CLK_SENSOR 27-28 bits, cycles - 24-25 bits
if (!clk_sensor) {clk_sensor=90000000; dev_dbg(g_dev_ptr,"{%d} clk_sensor is 0, setting to %d\n",sensor_port,(int)clk_sensor);} if (!clk_sensor) {
clk_sensor=90000000;
dev_dbg(g_dev_ptr,"{%d} clk_sensor is 0, setting to %d\n",sensor_port,(int)clk_sensor);
MDP(DBGB_PADD, sensor_port,"clk_sensor is 0, setting to %d\n",(int)clk_sensor)
}
#if USELONGLONG #if USELONGLONG
ull_min_period=(((long long) cycles) * ((long long) clk_sensor)); ull_min_period=(((long long) cycles) * ((long long) clk_sensor));
...@@ -1129,7 +1172,8 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3 ...@@ -1129,7 +1172,8 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3
// ull_min_period/=thispars->pars[P_CLK_FPGA]; // ull_min_period/=thispars->pars[P_CLK_FPGA];
#endif #endif
min_period= ull_min_period; min_period= ull_min_period;
dev_dbg(g_dev_ptr,"{%d} min_period =%d(0x%x)\n",sensor_port,min_period,min_period); dev_dbg(g_dev_ptr,"{%d} min_period =%d(0x%x)\n", sensor_port, min_period, min_period);
MDP(DBGB_PADD, sensor_port,"min_period =%d(0x%x)\n", min_period, min_period)
// min_period = (((long long) cycles) * ((long long) thispars->pars[P_CLK_SENSOR])) / ((long long) thispars->pars[P_CLK_FPGA]); // min_period = (((long long) cycles) * ((long long) thispars->pars[P_CLK_SENSOR])) / ((long long) thispars->pars[P_CLK_FPGA]);
#else #else
if (cycles < (1<<16) ) { if (cycles < (1<<16) ) {
...@@ -1159,7 +1203,8 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3 ...@@ -1159,7 +1203,8 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3
// ull_period /= thispars->pars[P_FP1000SLIM]; // ull_period /= thispars->pars[P_FP1000SLIM];
#endif #endif
period= ull_period; period= ull_period;
dev_dbg(g_dev_ptr,"{%d} period =%d(0x%x)\n",sensor_port,period,period); dev_dbg(g_dev_ptr,"{%d} period =%d(0x%x)\n", sensor_port, period, period);
MDP(DBGB_PADD, sensor_port,"period =%d(0x%x)\n", period, period)
// period=(((long long) clk_sensor) * (long long) 1000)/((long long) thispars->pars[P_FP1000SLIM]); // period=(((long long) clk_sensor) * (long long) 1000)/((long long) thispars->pars[P_FP1000SLIM]);
#else #else
period=125*(( thispars->pars[P_CLK_SENSOR] << 3) / thispars->pars[P_FP1000SLIM]); // 125 <<3 = 1000 period=125*(( thispars->pars[P_CLK_SENSOR] << 3) / thispars->pars[P_FP1000SLIM]); // 125 <<3 = 1000
...@@ -1167,6 +1212,7 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3 ...@@ -1167,6 +1212,7 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3
#endif #endif
} }
dev_dbg(g_dev_ptr,"{%d} period=%d\n",sensor_port,period); dev_dbg(g_dev_ptr,"{%d} period=%d\n",sensor_port,period);
MDP(DBGB_PADD, sensor_port,"period =%d(0x%x)\n", period, period)
if ((thispars->pars[P_FPSFLAGS] & 1) && (period>min_period)) min_period=period; if ((thispars->pars[P_FPSFLAGS] & 1) && (period>min_period)) min_period=period;
// *********************************************************** P_PF_HEIGHT // *********************************************************** P_PF_HEIGHT
pfh=thispars->pars[P_PF_HEIGHT] &0xffff ; pfh=thispars->pars[P_PF_HEIGHT] &0xffff ;
...@@ -1177,7 +1223,8 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3 ...@@ -1177,7 +1223,8 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3
if (min_period != thispars->pars[P_PERIOD_MIN]) { if (min_period != thispars->pars[P_PERIOD_MIN]) {
SETFRAMEPARS_SET(P_PERIOD_MIN, min_period); // set it (and propagate to the later frames) SETFRAMEPARS_SET(P_PERIOD_MIN, min_period); // set it (and propagate to the later frames)
dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_PERIOD_MIN, 0x%x)\n",sensor_port,min_period); dev_dbg(g_dev_ptr,"{%d} SETFRAMEPARS_SET(P_PERIOD_MIN, 0x%x)\n", sensor_port, min_period);
MDP(DBGB_PADD, sensor_port,"SETFRAMEPARS_SET(P_PERIOD_MIN, 0x%x)\n", min_period)
} }
if (((thispars->pars[P_FPSFLAGS] & 2)==0) || (period < min_period)) period=0x7fffffff; // no upper limit if (((thispars->pars[P_FPSFLAGS] & 2)==0) || (period < min_period)) period=0x7fffffff; // no upper limit
if (period != thispars->pars[P_PERIOD_MAX]) SETFRAMEPARS_SET(P_PERIOD_MAX, period); // set it (and propagate to the later frames) if (period != thispars->pars[P_PERIOD_MAX]) SETFRAMEPARS_SET(P_PERIOD_MAX, period); // set it (and propagate to the later frames)
...@@ -1189,6 +1236,7 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3 ...@@ -1189,6 +1236,7 @@ int pgm_limitfps (int sensor_port, ///< sensor port number (0..3
if (thispars->pars[P_TRIG_PERIOD] < min_period) SETFRAMEPARS_SET(P_TRIG_PERIOD, min_period); // set it (and propagate to the later frames) if (thispars->pars[P_TRIG_PERIOD] < min_period) SETFRAMEPARS_SET(P_TRIG_PERIOD, min_period); // set it (and propagate to the later frames)
if (async && (thispars->pars[P_FPSFLAGS] & 2) && (thispars->pars[P_TRIG_PERIOD] > period)) { if (async && (thispars->pars[P_FPSFLAGS] & 2) && (thispars->pars[P_TRIG_PERIOD] > period)) {
SETFRAMEPARS_SET(P_TRIG_PERIOD, period); // set it (and propagate to the later frames) SETFRAMEPARS_SET(P_TRIG_PERIOD, period); // set it (and propagate to the later frames)
MDP(DBGB_PADD, sensor_port,"SETFRAMEPARS_SET(P_TRIG_PERIOD, 0x%x)\n", period)
} }
} }
if (nupdate) setFramePars(sensor_port, thispars, nupdate, pars_to_update); // save changes, schedule functions if (nupdate) setFramePars(sensor_port, thispars, nupdate, pars_to_update); // save changes, schedule functions
...@@ -1207,6 +1255,7 @@ int pgm_gains (int sensor_port, ///< sensor port number ( ...@@ -1207,6 +1255,7 @@ int pgm_gains (int sensor_port, ///< sensor port number (
///< @return always 0 ///< @return always 0
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
return 0; return 0;
} }
...@@ -1222,6 +1271,7 @@ int pgm_triggermode(int sensor_port, ///< sensor port number (0..3 ...@@ -1222,6 +1271,7 @@ int pgm_triggermode(int sensor_port, ///< sensor port number (0..3
{ {
x393_camsync_mode_t camsync_mode = {.d32=0}; x393_camsync_mode_t camsync_mode = {.d32=0};
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
#ifndef NC353 #ifndef NC353
camsync_mode.trig = (thispars->pars[P_TRIG] & 4)?1:0; camsync_mode.trig = (thispars->pars[P_TRIG] & 4)?1:0;
...@@ -1232,6 +1282,7 @@ int pgm_triggermode(int sensor_port, ///< sensor port number (0..3 ...@@ -1232,6 +1282,7 @@ int pgm_triggermode(int sensor_port, ///< sensor port number (0..3
camsync_mode.trig_set = 1; camsync_mode.trig_set = 1;
// set directly, bypassing sequencer as it may fail with wrong trigger // set directly, bypassing sequencer as it may fail with wrong trigger
x393_camsync_mode (camsync_mode); x393_camsync_mode (camsync_mode);
MDP(DBGB_PADD, sensor_port,"x393_camsync_mode(0x%x)\n",camsync_mode.d32)
return 0; return 0;
#else #else
// int fpga_addr= frame16; // int fpga_addr= frame16;
...@@ -1264,12 +1315,17 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3 ...@@ -1264,12 +1315,17 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
int bayer_modified; int bayer_modified;
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
if (FRAMEPAR_MODIFIED(P_BITS)){ if (FRAMEPAR_MODIFIED(P_BITS)){
sens_mode.bit16 = thispars->pars[P_BITS]; sens_mode.bit16 = thispars->pars[P_BITS];
sens_mode.bit16_set = 1; sens_mode.bit16_set = 1;
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_mode, sens_mode); X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_mode, sens_mode);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_mode, 0x%x)\n",sensor_port, sensor_port, frame16, sens_mode.d32); dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_mode, 0x%x)\n",
sensor_port, sensor_port, frame16, sens_mode.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_mode, 0x%x)\n",
sensor_port, frame16, sens_mode.d32)
#if 0 //TODO: not (yet) implemented #if 0 //TODO: not (yet) implemented
(thispars->pars[P_FPGATEST]), \ (thispars->pars[P_FPGATEST]), \
(thispars->pars[P_FPNS]), \ (thispars->pars[P_FPNS]), \
...@@ -1282,7 +1338,10 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3 ...@@ -1282,7 +1338,10 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
sensio_width.sensor_width = thispars->pars[P_ACTUAL_WIDTH]+(2 * COLOR_MARGINS); sensio_width.sensor_width = thispars->pars[P_ACTUAL_WIDTH]+(2 * COLOR_MARGINS);
} }
X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_width, sensio_width); X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_width, sensio_width);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_width, 0x%x)\n",sensor_port, sensor_port, frame16, sensio_width.d32); dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_width, 0x%x)\n",
sensor_port, sensor_port, frame16, sensio_width.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_width, 0x%x)\n",
sensor_port, frame16, sensio_width.d32)
// Program number of scan lines to acquire // Program number of scan lines to acquire
// Is PhotoFinish mode enabled? // **************** TODO: use ACTUAL_HEIGHT (and update it) not WOI_HEIGHT // Is PhotoFinish mode enabled? // **************** TODO: use ACTUAL_HEIGHT (and update it) not WOI_HEIGHT
...@@ -1294,7 +1353,11 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3 ...@@ -1294,7 +1353,11 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
n_scan_lines= thispars->pars[P_ACTUAL_HEIGHT]+(2 * COLOR_MARGINS)+thispars->pars[P_OVERLAP]; n_scan_lines= thispars->pars[P_ACTUAL_HEIGHT]+(2 * COLOR_MARGINS)+thispars->pars[P_OVERLAP];
} }
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_sync_mult, sync_mult); X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_sync_mult, sync_mult);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_sync_mult, 0x%x)\n",sensor_port, sensor_port, frame16, sync_mult.d32); dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_sync_mult, 0x%x)\n",
sensor_port, sensor_port, frame16, sync_mult.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_sync_mult, 0x%x)\n",
sensor_port, frame16, sync_mult.d32)
// See if NC393 has n_scan_lines - no // See if NC393 has n_scan_lines - no
/* /*
n_scan_lines&=0xffff; // was 0x3fff in NC353 code n_scan_lines&=0xffff; // was 0x3fff in NC353 code
...@@ -1307,12 +1370,13 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3 ...@@ -1307,12 +1370,13 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
flips=(thispars->pars[P_FLIPH] & 1) | ((thispars->pars[P_FLIPV] & 1)<<1); flips=(thispars->pars[P_FLIPH] & 1) | ((thispars->pars[P_FLIPV] & 1)<<1);
bayer_modified=FRAMEPAR_MODIFIED(P_BAYER) || FRAMEPAR_MODIFIED(P_FLIPH) || FRAMEPAR_MODIFIED(P_FLIPV) || FRAMEPAR_MODIFIED(P_MULTI_MODE); bayer_modified=FRAMEPAR_MODIFIED(P_BAYER) || FRAMEPAR_MODIFIED(P_FLIPH) || FRAMEPAR_MODIFIED(P_FLIPV) || FRAMEPAR_MODIFIED(P_MULTI_MODE);
dev_dbg(g_dev_ptr,"{%d} flips=%x\n",sensor_port, flips); dev_dbg(g_dev_ptr,"{%d} flips=%x\n",sensor_port, flips);
MDP(DBGB_PADD, sensor_port,"flips=%x\n",flips)
if (thispars->pars[P_MULTI_MODE]) { // Modify flips in composite mode - should match flips of the top (direct) channel if (thispars->pars[P_MULTI_MODE]) { // Modify flips in composite mode - should match flips of the top (direct) channel
int this_bit=(1<<thispars->pars[P_MULTI_TOPSENSOR]); int this_bit=(1<<thispars->pars[P_MULTI_TOPSENSOR]);
if (thispars->pars[P_MULTI_FLIPH] & this_bit) flips^=1; if (thispars->pars[P_MULTI_FLIPH] & this_bit) flips^=1;
if (thispars->pars[P_MULTI_FLIPV] & this_bit) flips^=2; if (thispars->pars[P_MULTI_FLIPV] & this_bit) flips^=2;
dev_dbg(g_dev_ptr,"{%d} composite mode - adjusted flips=%x\n",sensor_port, flips); dev_dbg(g_dev_ptr,"{%d} composite mode - adjusted flips=%x\n",sensor_port, flips);
MDP(DBGB_PADD, sensor_port,"composite mode - adjusted flips=%x\n",flips)
bayer_modified= bayer_modified || FRAMEPAR_MODIFIED(P_MULTI_FLIPH) || FRAMEPAR_MODIFIED(P_MULTI_FLIPV) || FRAMEPAR_MODIFIED(P_MULTI_TOPSENSOR); bayer_modified= bayer_modified || FRAMEPAR_MODIFIED(P_MULTI_FLIPH) || FRAMEPAR_MODIFIED(P_MULTI_FLIPV) || FRAMEPAR_MODIFIED(P_MULTI_TOPSENSOR);
} }
...@@ -1322,6 +1386,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3 ...@@ -1322,6 +1386,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
gamma_ctl.bayer_set = 1; gamma_ctl.bayer_set = 1;
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_gamma_ctrl, gamma_ctl); 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); 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)
} }
return 0; return 0;
#else #else
...@@ -1406,6 +1471,7 @@ int pgm_sensorrun (int sensor_port, ///< sensor port number (0..3 ...@@ -1406,6 +1471,7 @@ int pgm_sensorrun (int sensor_port, ///< sensor port number (0..3
{ {
#ifndef NC353 #ifndef NC353
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 if (frame16 >= PARS_FRAMES) return -EINVAL; // wrong frame
control_sensor_memory (sensor_port, control_sensor_memory (sensor_port,
thispars->pars[P_SENSOR_RUN] & 3, thispars->pars[P_SENSOR_RUN] & 3,
...@@ -1453,6 +1519,7 @@ int pgm_sensorstop (int sensor_port, ///< sensor port number (0..3 ...@@ -1453,6 +1519,7 @@ int pgm_sensorstop (int sensor_port, ///< sensor port number (0..3
{ {
#ifndef NC353 #ifndef NC353
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 if (frame16 >= PARS_FRAMES) return -EINVAL; // wrong frame
// Do we need to filter for stop only ( if ((thispars->pars[P_SENSOR_RUN] & 3)==0){... ) ? // Do we need to filter for stop only ( if ((thispars->pars[P_SENSOR_RUN] & 3)==0){... ) ?
control_sensor_memory (sensor_port, control_sensor_memory (sensor_port,
...@@ -1510,19 +1577,22 @@ int pgm_gamma (int sensor_port, ///< sensor port number (0..3 ...@@ -1510,19 +1577,22 @@ int pgm_gamma (int sensor_port, ///< sensor port number (0..3
// TODO: Add for multi-subchannel, for now using 0 // TODO: Add for multi-subchannel, for now using 0
dev_dbg(g_dev_ptr,"{%d} frame16=%d, (getThisFrameNumber() & PARS_FRAMES_MASK)= %ld\n",sensor_port,frame16, getThisFrameNumber(sensor_port) & PARS_FRAMES_MASK); dev_dbg(g_dev_ptr,"{%d} frame16=%d, (getThisFrameNumber() & PARS_FRAMES_MASK)= %ld\n",sensor_port,frame16, getThisFrameNumber(sensor_port) & PARS_FRAMES_MASK);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
/*
MDF3(dev_dbg(g_dev_ptr," frame16=%d, thispars->pars[P_GTAB_*]=0x%lx 0x%lx 0x%lx 0x%lx, thispars->pars[P_FRAME]=0x%lx" MDF3(dev_dbg(g_dev_ptr," frame16=%d, thispars->pars[P_GTAB_*]=0x%lx 0x%lx 0x%lx 0x%lx, thispars->pars[P_FRAME]=0x%lx"
" get_locked_hash32(*)=0x%lx 0x%lx 0x%lx 0x%lx\n", " get_locked_hash32(*)=0x%lx 0x%lx 0x%lx 0x%lx\n",
frame16, thispars->pars[P_GTAB_R],thispars->pars[P_GTAB_R+1],thispars->pars[P_GTAB_R+2],thispars->pars[P_GTAB_R+3],thispars->pars[P_FRAME], frame16, thispars->pars[P_GTAB_R],thispars->pars[P_GTAB_R+1],thispars->pars[P_GTAB_R+2],thispars->pars[P_GTAB_R+3],thispars->pars[P_FRAME],
get_locked_hash32(0),get_locked_hash32(1),get_locked_hash32(2),get_locked_hash32(3))); get_locked_hash32(0),get_locked_hash32(1),get_locked_hash32(2),get_locked_hash32(3)));
*/
dev_dbg(g_dev_ptr,"{%d} frame16=%d, thispars->pars[P_GTAB_*]=0x%lx 0x%lx 0x%lx 0x%lx, thispars->pars[P_FRAME]=0x%lx\n",
dev_dbg(g_dev_ptr,"{%d} frame16=%d, thispars->pars[P_GTAB_*]=0x%lx 0x%lx 0x%lx 0x%lx, thispars->pars[P_FRAME]=0x%lx\n",sensor_port,frame16, thispars->pars[P_GTAB_R],thispars->pars[P_GTAB_R+1],thispars->pars[P_GTAB_R+2],thispars->pars[P_GTAB_R+3],thispars->pars[P_FRAME]); sensor_port,frame16, thispars->pars[P_GTAB_R],thispars->pars[P_GTAB_R+1],thispars->pars[P_GTAB_R+2],
thispars->pars[P_GTAB_R+3],thispars->pars[P_FRAME]);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
// Not needed - now it can be done in advance (just prepare cache). Later it will be done again and actually programmed (1 frame ahead of time) // Not needed - now it can be done in advance (just prepare cache). Later it will be done again and actually programmed (1 frame ahead of time)
// return if too early // return if too early
// TODO: still calculate FPGA table , but not load it if too early? // TODO: still calculate FPGA table , but not load it if too early?
for (color=0; color<4; color++) { for (color=0; color<4; color++) {
if (get_locked_hash32(color,sensor_port,0)!=thispars->pars[P_GTAB_R+color]) { // modified for this color if (get_locked_hash32(color,sensor_port,0)!=thispars->pars[P_GTAB_R+color]) { // modified for this color
*pgamma32=thispars->pars[P_GTAB_R+color]; *pgamma32=thispars->pars[P_GTAB_R+color];
rslt=set_gamma_table (gamma32.hash16, rslt=set_gamma_table (gamma32.hash16,
...@@ -1537,6 +1607,7 @@ int pgm_gamma (int sensor_port, ///< sensor port number (0..3 ...@@ -1537,6 +1607,7 @@ int pgm_gamma (int sensor_port, ///< sensor port number (0..3
if (nupdate) { if (nupdate) {
setFramePars(sensor_port, thispars, nupdate, pars_to_update); // restore failed components setFramePars(sensor_port, thispars, nupdate, pars_to_update); // restore failed components
dev_dbg(g_dev_ptr,"{%d} had to restore back %d gamma tables (color components) \n",sensor_port,nupdate); dev_dbg(g_dev_ptr,"{%d} had to restore back %d gamma tables (color components) \n",sensor_port,nupdate);
MDP(DBGB_PSFN, sensor_port,"had to restore back %d gamma tables (color components) \n",nupdate)
return -1; return -1;
} }
return 0; return 0;
...@@ -1575,6 +1646,7 @@ int pgm_hist (int sensor_port, ///< sensor port number (0..3 ...@@ -1575,6 +1646,7 @@ int pgm_hist (int sensor_port, ///< sensor port number (0..3
}; };
*/ */
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
for (sub_chn =0; sub_chn < MAX_SENSORS; sub_chn++) if (GLOBALPARS(sensor_port, G_SUBCHANNELS) & (1 << sub_chn)){ for (sub_chn =0; sub_chn < MAX_SENSORS; sub_chn++) if (GLOBALPARS(sensor_port, G_SUBCHANNELS) & (1 << sub_chn)){
poffs = HIST_SUBCHN_OFFSET * sub_chn; poffs = HIST_SUBCHN_OFFSET * sub_chn;
...@@ -1603,8 +1675,15 @@ int pgm_hist (int sensor_port, ///< sensor port number (0..3 ...@@ -1603,8 +1675,15 @@ int pgm_hist (int sensor_port, ///< sensor port number (0..3
width_height.height_m1 = hist_setup_data.height-2; width_height.height_m1 = hist_setup_data.height-2;
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",sensor_port, sensor_port, frame16, left_top.d32, 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_wh, 0x%x, %d)\n",sensor_port, sensor_port, frame16, width_height.d32, sub_chn); sensor_port, sensor_port, frame16, left_top.d32, sub_chn);
MDP(DBGB_PADD, sensor_port," X393_SEQ_SEND1S(0x%x, 0x%x, x393_histogram_lt, 0x%x, %d)\n",
sensor_port, frame16, left_top.d32, sub_chn)
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1S(0x%x, 0x%x, x393_histogram_wh, 0x%x, %d)\n",
sensor_port, sensor_port, frame16, width_height.d32, sub_chn);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1S(0x%x, 0x%x, x393_histogram_wh, 0x%x, %d)\n",
sensor_port, frame16, width_height.d32, sub_chn)
if ((nupdate == 0) || (HIST_SUBCHN_OFFSET > 0)) { // Update only once until there are per-subchannle parameters if ((nupdate == 0) || (HIST_SUBCHN_OFFSET > 0)) { // Update only once until there are per-subchannle parameters
SETFRAMEPARS_SET(P_HISTWND_LEFT + poffs,hist_setup_data.left); SETFRAMEPARS_SET(P_HISTWND_LEFT + poffs,hist_setup_data.left);
SETFRAMEPARS_SET(P_HISTWND_WIDTH + poffs,hist_setup_data.width); SETFRAMEPARS_SET(P_HISTWND_WIDTH + poffs,hist_setup_data.width);
...@@ -1646,6 +1725,7 @@ int pgm_aexp (int sensor_port, ///< sensor port number (0..3 ...@@ -1646,6 +1725,7 @@ int pgm_aexp (int sensor_port, ///< sensor port number (0..3
{ {
//TODO: //TODO:
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
return 0; return 0;
} }
...@@ -1664,6 +1744,8 @@ int pgm_quality (int sensor_port, ///< sensor port number (0..3 ...@@ -1664,6 +1744,8 @@ int pgm_quality (int sensor_port, ///< sensor port number (0..3
int c_coring_index; int c_coring_index;
int composite_quality=(thispars->pars[P_QUALITY] & 0xff7f) | ((thispars->pars[P_PORTRAIT] & 1)<<7); int composite_quality=(thispars->pars[P_QUALITY] & 0xff7f) | ((thispars->pars[P_PORTRAIT] & 1)<<7);
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
// int fpga_addr=(frame16 <0) ? X313_SEQ_ASAP : (X313_SEQ_FRAME0+frame16); // int fpga_addr=(frame16 <0) ? X313_SEQ_ASAP : (X313_SEQ_FRAME0+frame16);
if (thispars->pars[P_CORING_INDEX]!= prevpars->pars[P_CORING_INDEX]) { if (thispars->pars[P_CORING_INDEX]!= prevpars->pars[P_CORING_INDEX]) {
...@@ -1671,7 +1753,10 @@ int pgm_quality (int sensor_port, ///< sensor port number (0..3 ...@@ -1671,7 +1753,10 @@ int pgm_quality (int sensor_port, ///< sensor port number (0..3
c_coring_index=(thispars->pars[ P_CORING_INDEX]>>16) & 0xffff; c_coring_index=(thispars->pars[ P_CORING_INDEX]>>16) & 0xffff;
if (c_coring_index==0) c_coring_index=y_coring_index; if (c_coring_index==0) c_coring_index=y_coring_index;
set_coring_fpga(y_coring_index, 0, sensor_port); set_coring_fpga(y_coring_index, 0, sensor_port);
MDP(DBGB_PADD, sensor_port,"set_coring_fpga(%d, %d, %d)\n", y_coring_index, 0, sensor_port)
set_coring_fpga(c_coring_index, 1, sensor_port); set_coring_fpga(c_coring_index, 1, sensor_port);
MDP(DBGB_PADD, sensor_port,"set_coring_fpga(%d, %d, %d)\n", c_coring_index, 1, sensor_port)
//TODO: Set coring index (it seems to be a pair? void set_x393_cmprs_coring_mode (x393_cmprs_coring_mode_t d, int cmprs_chn); // Select coring mode //TODO: Set coring index (it seems to be a pair? void set_x393_cmprs_coring_mode (x393_cmprs_coring_mode_t d, int cmprs_chn); // Select coring mode
// Not needed, it is always downloaded to pair 0 // Not needed, it is always downloaded to pair 0
...@@ -1684,7 +1769,11 @@ int pgm_quality (int sensor_port, ///< sensor port number (0..3 ...@@ -1684,7 +1769,11 @@ int pgm_quality (int sensor_port, ///< sensor port number (0..3
cmprs_mode.qbank = thispars->pars[P_COMPMOD_QTAB]; cmprs_mode.qbank = thispars->pars[P_COMPMOD_QTAB];
cmprs_mode.qbank_set = 1; cmprs_mode.qbank_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);
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); 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)
return 0; return 0;
} else return -EFAULT; } else return -EFAULT;
} }
...@@ -1702,6 +1791,7 @@ int pgm_memsensor (int sensor_port, ///< sensor port number ( ...@@ -1702,6 +1791,7 @@ int pgm_memsensor (int sensor_port, ///< sensor port number (
#ifndef NC353 #ifndef NC353
int width_marg, height_marg, width_bursts; int width_marg, height_marg, width_bursts;
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
width_marg = thispars->pars[P_ACTUAL_WIDTH]; width_marg = thispars->pars[P_ACTUAL_WIDTH];
height_marg = thispars->pars[P_ACTUAL_WIDTH]; height_marg = thispars->pars[P_ACTUAL_WIDTH];
...@@ -1809,12 +1899,13 @@ int pgm_memcompressor (int sensor_port, ///< sensor port number ( ...@@ -1809,12 +1899,13 @@ int pgm_memcompressor (int sensor_port, ///< sensor port number (
//TODO: redo for nc393 //TODO: redo for nc393
#ifndef NC353 #ifndef NC353
int width_marg, height_marg; int width_marg, height_marg;
int overlap; // tile overlap (total - 2 for JPEG18, 4 - for JPEG20, 0 otherwise int overlap = 0; // tile overlap (total - 2 for JPEG18, 4 - for JPEG20, 0 otherwise
int width_bursts; int width_bursts;
int cmprs_top = 0; // 1 for JPEG18 only, 0 for others int cmprs_top = 0; // 1 for JPEG18 only, 0 for others
int tile_width; // in bursts, 2 for those with overlap (height>16), 4 with heigh==16 int tile_width; // in bursts, 2 for those with overlap (height>16), 4 with heigh==16
int tile_height; // 16/18 (20 not yet implemented) int tile_height; // 16/18 (20 not yet implemented)
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
width_marg = thispars->pars[P_ACTUAL_WIDTH]; width_marg = thispars->pars[P_ACTUAL_WIDTH];
height_marg = thispars->pars[P_ACTUAL_WIDTH]; height_marg = thispars->pars[P_ACTUAL_WIDTH];
...@@ -1905,12 +1996,12 @@ int pgm_compmode (int sensor_port, ///< sensor port number (0..3 ...@@ -1905,12 +1996,12 @@ int pgm_compmode (int sensor_port, ///< sensor port number (0..3
int csb; int csb;
int csr; int csr;
#ifndef NC353 #ifndef NC353
int comp_cmd=0;
// x393cmd_t x393cmd; // x393cmd_t x393cmd;
x393_cmprs_mode_t cmprs_mode = {.d32=0}; x393_cmprs_mode_t cmprs_mode = {.d32=0};
x393_cmprs_colorsat_t cmprs_colorsat = {.d32=0}; x393_cmprs_colorsat_t cmprs_colorsat = {.d32=0};
x393_cmprs_coring_mode_t cmprs_coring_mode = {.d32=0}; x393_cmprs_coring_mode_t cmprs_coring_mode = {.d32=0};
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
if (!jpeg_htable_is_programmed(sensor_port)) jpeg_htable_fpga_pgm (sensor_port); if (!jpeg_htable_is_programmed(sensor_port)) jpeg_htable_fpga_pgm (sensor_port);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
// x393cmd = (frame16<0)? ASAP: ABSOLUTE; // x393cmd = (frame16<0)? ASAP: ABSOLUTE;
...@@ -1962,9 +2053,14 @@ int pgm_compmode (int sensor_port, ///< sensor port number (0..3 ...@@ -1962,9 +2053,14 @@ int pgm_compmode (int sensor_port, ///< sensor port number (0..3
cmprs_mode.multiframe = (frames_in_buffer_minus_one(sensor_port)>0)? 1:0; cmprs_mode.multiframe = (frames_in_buffer_minus_one(sensor_port)>0)? 1:0;
cmprs_mode.multiframe_set = 1; cmprs_mode.multiframe_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);
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); 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)
} else { } else {
dev_dbg(g_dev_ptr,"{%d} comp_cmd.d32==0, does not need to be sent\n",sensor_port); dev_dbg(g_dev_ptr,"{%d} cmprs_mode.d32==0, does not need to be sent\n",sensor_port);
MDP(DBGB_PADD, sensor_port,"cmprs_mode.d32=0x%x, does not need to be sent\n",cmprs_mode.d32)
} }
// color saturation changed? // color saturation changed?
if (FRAMEPAR_MODIFIED(P_COLOR_SATURATION_BLUE) || FRAMEPAR_MODIFIED(P_COLOR_SATURATION_RED)) { if (FRAMEPAR_MODIFIED(P_COLOR_SATURATION_BLUE) || FRAMEPAR_MODIFIED(P_COLOR_SATURATION_RED)) {
...@@ -1981,20 +2077,27 @@ int pgm_compmode (int sensor_port, ///< sensor port number (0..3 ...@@ -1981,20 +2077,27 @@ int pgm_compmode (int sensor_port, ///< sensor port number (0..3
cmprs_colorsat.colorsat_blue = csb; cmprs_colorsat.colorsat_blue = csb;
cmprs_colorsat.colorsat_red = csr; cmprs_colorsat.colorsat_red = csr;
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_color_saturation, cmprs_colorsat); X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_color_saturation, cmprs_colorsat);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_color_saturation, 0x%x)\n",sensor_port,sensor_port, frame16, cmprs_colorsat.d32); dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_color_saturation, 0x%x)\n",
sensor_port, sensor_port, frame16, cmprs_colorsat.d32);
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_color_saturation, 0x%x)\n",
sensor_port, frame16, cmprs_colorsat.d32)
} }
// compressor quantizer zero bin mode changed? // compressor quantizer zero bin mode changed?
// Quantizer tuning - bits 0..7 - zero bin, 15:8 - quantizer bias // Quantizer tuning - bits 0..7 - zero bin, 15:8 - quantizer bias
if (FRAMEPAR_MODIFIED(P_CORING_PAGE)) { if (FRAMEPAR_MODIFIED(P_CORING_PAGE)) {
cmprs_coring_mode.coring_table = thispars->pars[P_CORING_PAGE]; cmprs_coring_mode.coring_table = thispars->pars[P_CORING_PAGE];
X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_coring_mode, cmprs_coring_mode); X393_SEQ_SEND1 (sensor_port, frame16, x393_cmprs_coring_mode, cmprs_coring_mode);
dev_dbg(g_dev_ptr,"{%d} X3X3_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_coring_mode, 0x%x)\n",sensor_port, sensor_port, frame16, cmprs_coring_mode.d32); dev_dbg(g_dev_ptr,"{%d} X3X3_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_coring_mode, 0x%x)\n",
sensor_port, sensor_port, frame16, cmprs_coring_mode.d32);
MDP(DBGB_PADD, sensor_port,"X3X3_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_coring_mode, 0x%x)\n",
sensor_port, frame16, cmprs_coring_mode.d32)
} }
if (nupdate) setFramePars(sensor_port, thispars, nupdate, pars_to_update); // save changes, schedule functions if (nupdate) setFramePars(sensor_port, thispars, nupdate, pars_to_update); // save changes, schedule functions
#else #else
int comp_cmd=0;
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
if (!jpeg_htable_is_programmed(sensor_port)) jpeg_htable_fpga_pgm (sensor_port); if (!jpeg_htable_is_programmed(sensor_port)) jpeg_htable_fpga_pgm (sensor_port);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
...@@ -2109,6 +2212,7 @@ int pgm_focusmode (int sensor_port, ///< sensor port number (0..3 ...@@ -2109,6 +2212,7 @@ int pgm_focusmode (int sensor_port, ///< sensor port number (0..3
{P_FOCUS_HEIGHT, 0} {P_FOCUS_HEIGHT, 0}
}; };
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
if (frame16 >= 0) return -1; // now can only programm in immediate mode by writing the table if (frame16 >= 0) return -1; // now can only programm in immediate mode by writing the table
focus_setup_data.totalwidth=(thispars->pars[P_ACTUAL_WIDTH]& 0xfff0) -0x10; // anyway should be 16x focus_setup_data.totalwidth=(thispars->pars[P_ACTUAL_WIDTH]& 0xfff0) -0x10; // anyway should be 16x
focus_setup_data.show1= thispars->pars[P_FOCUS_SHOW1]; focus_setup_data.show1= thispars->pars[P_FOCUS_SHOW1];
...@@ -2153,8 +2257,10 @@ int pgm_focusmode (int sensor_port, ///< sensor port number (0..3 ...@@ -2153,8 +2257,10 @@ int pgm_focusmode (int sensor_port, ///< sensor port number (0..3
x393_cmprs_tables_data(focus_setup_data32[i], sensor_port); x393_cmprs_tables_data(focus_setup_data32[i], sensor_port);
} }
local_irq_restore(flags); local_irq_restore(flags);
print_hex_dump_bytes("", DUMP_PREFIX_NONE, &focus_setup_data32[0], sizeof (focus_setup_data)); // print_hex_dump_bytes("", DUMP_PREFIX_NONE, &focus_setup_data32[0], sizeof (focus_setup_data));
MDP(DBGB_PADD, sensor_port,"focus_setup_data left=%d, right=%d, top=%d, bottom=%d, total width=%d, filter_no=%d, show1=%d\n",
focus_setup_data.left,focus_setup_data.right,focus_setup_data.top,focus_setup_data.bottom,
focus_setup_data.totalwidth,focus_setup_data.filter_no,focus_setup_data.show1 )
#else #else
fpga_table_write_nice (CX313_FPGA_TABLES_FOCUSPARS, sizeof(focus_setup_data)/sizeof(focus_setup_data.left), (unsigned long *) &focus_setup_data); fpga_table_write_nice (CX313_FPGA_TABLES_FOCUSPARS, sizeof(focus_setup_data)/sizeof(focus_setup_data.left), (unsigned long *) &focus_setup_data);
#endif #endif
...@@ -2190,6 +2296,9 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3 ...@@ -2190,6 +2296,9 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3
x393_camsync_mode_t camsync_mode = {.d32=0}; x393_camsync_mode_t camsync_mode = {.d32=0};
int update_master_channel = 0; // set if any of the common (not channel-specific) parameters is modified int update_master_channel = 0; // set if any of the common (not channel-specific) parameters is modified
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
// 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);
if (frame16 >= PARS_FRAMES) return -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
if (frame16 >= 0) return -1; // ASAP only mode if (frame16 >= 0) return -1; // ASAP only mode
// Trigger condition changed? (0 - internal sequencer) // Trigger condition changed? (0 - internal sequencer)
...@@ -2198,11 +2307,13 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3 ...@@ -2198,11 +2307,13 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3
x393_camsync_trig_src(camsync_src); x393_camsync_trig_src(camsync_src);
update_master_channel=1; update_master_channel=1;
dev_dbg(g_dev_ptr,"{%d} x393_camsync_trig_src(0x%x)\n",sensor_port, camsync_src.d32); dev_dbg(g_dev_ptr,"{%d} x393_camsync_trig_src(0x%x)\n",sensor_port, camsync_src.d32);
MDP(DBGB_PADD, sensor_port,"x393_camsync_trig_src(0x%x)\n", camsync_src.d32)
} }
// Trigger delay changed? // Trigger delay changed?
if (FRAMEPAR_MODIFIED(P_TRIG_DELAY)) { // individual per-channel parameters if (FRAMEPAR_MODIFIED(P_TRIG_DELAY)) { // individual per-channel parameters
set_x393_camsync_trig_delay (thispars->pars[P_TRIG_DELAY], sensor_port); // CAMSYNC trigger delay set_x393_camsync_trig_delay (thispars->pars[P_TRIG_DELAY], sensor_port); // CAMSYNC trigger delay
dev_dbg(g_dev_ptr,"{%d} set_x393_camsync_trig_delay(0x%x, %d)\n",sensor_port, camsync_src.d32, sensor_port); dev_dbg(g_dev_ptr,"{%d} set_x393_camsync_trig_delay(0x%x, %d)\n",sensor_port, camsync_src.d32, sensor_port);
MDP(DBGB_PADD, sensor_port,"set_x393_camsync_trig_delay(0x%x, %d)\n", camsync_src.d32, sensor_port)
} }
// Sequencer output word changed? (to which outputs it is sent and what polarity) // Sequencer output word changed? (to which outputs it is sent and what polarity)
if (FRAMEPAR_MODIFIED(P_TRIG_OUT)) { if (FRAMEPAR_MODIFIED(P_TRIG_OUT)) {
...@@ -2210,6 +2321,8 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3 ...@@ -2210,6 +2321,8 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3
x393_camsync_trig_dst(camsync_dst); x393_camsync_trig_dst(camsync_dst);
update_master_channel=1; update_master_channel=1;
dev_dbg(g_dev_ptr,"{%d} x393_camsync_trig_dst(0x%x)\n",sensor_port, camsync_dst.d32); dev_dbg(g_dev_ptr,"{%d} x393_camsync_trig_dst(0x%x)\n",sensor_port, camsync_dst.d32);
MDP(DBGB_PADD, sensor_port,"x393_camsync_trig_dst(0x%x)\n", camsync_dst.d32)
// dev_dbg(g_dev_ptr,"{%d} port_csp0_addr[0x%x]=0x%x\n",sensor_port, (int) X313_WA_CAMSYNCOUT, (int) thispars->pars[P_TRIG_OUT]); // dev_dbg(g_dev_ptr,"{%d} port_csp0_addr[0x%x]=0x%x\n",sensor_port, (int) X313_WA_CAMSYNCOUT, (int) thispars->pars[P_TRIG_OUT]);
// Enable connection from the trigger module to the FPGA GPIO pins // Enable connection from the trigger module to the FPGA GPIO pins
...@@ -2217,6 +2330,7 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3 ...@@ -2217,6 +2330,7 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3
gpio_set_pins.chn_a = 3; // Set dibit enable gpio_set_pins.chn_a = 3; // Set dibit enable
x393_gpio_set_pins(gpio_set_pins); x393_gpio_set_pins(gpio_set_pins);
dev_dbg(g_dev_ptr,"{%d} x393_gpio_set_pins(0x%x)\n",sensor_port, gpio_set_pins.d32); dev_dbg(g_dev_ptr,"{%d} x393_gpio_set_pins(0x%x)\n",sensor_port, gpio_set_pins.d32);
MDP(DBGB_PADD, sensor_port,"x393_gpio_set_pins(0x%x)\n",gpio_set_pins.d32)
} else { } else {
// Not needed, I think // Not needed, I think
// port_csp0_addr[X313_WA_IOPINS] = X313_WA_IOPINS_DIS_TRIG_OUT; // port_csp0_addr[X313_WA_IOPINS] = X313_WA_IOPINS_DIS_TRIG_OUT;
...@@ -2231,6 +2345,7 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3 ...@@ -2231,6 +2345,7 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3
set_x393_camsync_trig_period(thispars->pars[P_TRIG_PERIOD]); set_x393_camsync_trig_period(thispars->pars[P_TRIG_PERIOD]);
update_master_channel=1; update_master_channel=1;
dev_dbg(g_dev_ptr,"{%d} set_x393_camsync_trig_period(0x%lx)\n",sensor_port, thispars->pars[P_TRIG_PERIOD]); dev_dbg(g_dev_ptr,"{%d} set_x393_camsync_trig_period(0x%lx)\n",sensor_port, thispars->pars[P_TRIG_PERIOD]);
MDP(DBGB_PADD, sensor_port,"set_x393_camsync_trig_period(0x%lx)\n", thispars->pars[P_TRIG_PERIOD])
} }
} }
// Bit length changed or not yet initialized? // Bit length changed or not yet initialized?
...@@ -2243,6 +2358,7 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3 ...@@ -2243,6 +2358,7 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3
set_x393_camsync_trig_period(d); set_x393_camsync_trig_period(d);
update_master_channel=1; update_master_channel=1;
dev_dbg(g_dev_ptr,"{%d} set_x393_camsync_trig_period(0x%x) (bit length)\n",sensor_port, d); dev_dbg(g_dev_ptr,"{%d} set_x393_camsync_trig_period(0x%x) (bit length)\n",sensor_port, d);
MDP(DBGB_PADD, sensor_port,"set_x393_camsync_trig_period(0x%x) (bit length)\n",d)
} }
// P_EXTERN_TIMESTAMP changed? (0 - internal sequencer) // P_EXTERN_TIMESTAMP changed? (0 - internal sequencer)
if (FRAMEPAR_MODIFIED(P_EXTERN_TIMESTAMP)) { if (FRAMEPAR_MODIFIED(P_EXTERN_TIMESTAMP)) {
...@@ -2262,6 +2378,7 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3 ...@@ -2262,6 +2378,7 @@ int pgm_trigseq (int sensor_port, ///< sensor port number (0..3
if (camsync_mode.d32){ // anything set? if (camsync_mode.d32){ // anything set?
x393_camsync_mode (camsync_mode); x393_camsync_mode (camsync_mode);
dev_dbg(g_dev_ptr,"{%d} x393_camsync_mode(0x%x)\n",sensor_port, camsync_mode.d32); dev_dbg(g_dev_ptr,"{%d} x393_camsync_mode(0x%x)\n",sensor_port, camsync_mode.d32);
MDP(DBGB_PADD, sensor_port,"x393_camsync_mode(0x%x)\n", camsync_mode.d32)
} }
if (nupdate) setFramePars(sensor_port, thispars, nupdate, pars_to_update); // save changes, schedule functions if (nupdate) setFramePars(sensor_port, thispars, nupdate, pars_to_update); // save changes, schedule functions
return 0; return 0;
...@@ -2339,6 +2456,7 @@ int pgm_irq (int sensor_port, ///< sensor port number (0..3) ...@@ -2339,6 +2456,7 @@ int pgm_irq (int sensor_port, ///< sensor port number (0..3)
///< @return OK - 0, <0 - error ///< @return OK - 0, <0 - error
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d, does nothing\n",frame16)
if (frame16 >= PARS_FRAMES) return -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
#ifdef NC353 #ifdef NC353
int fpga_addr=(frame16 <0) ? X313_SEQ_ASAP : (X313_SEQ_FRAME0+frame16); int fpga_addr=(frame16 <0) ? X313_SEQ_ASAP : (X313_SEQ_FRAME0+frame16);
...@@ -2350,8 +2468,10 @@ int pgm_irq (int sensor_port, ///< sensor port number (0..3) ...@@ -2350,8 +2468,10 @@ int pgm_irq (int sensor_port, ///< sensor port number (0..3)
X3X3_SEQ_SEND1(fpga_addr, X313_WA_SMART_IRQ, (2 | ((thispars->pars[P_IRQ_SMART] & 1)?1:0)) | \ X3X3_SEQ_SEND1(fpga_addr, X313_WA_SMART_IRQ, (2 | ((thispars->pars[P_IRQ_SMART] & 1)?1:0)) | \
(8 | ((thispars->pars[P_IRQ_SMART] & 2)?4:0))); (8 | ((thispars->pars[P_IRQ_SMART] & 2)?4:0)));
#endif #endif
/*
MDF3(dev_dbg(g_dev_ptr," X3X3_SEQ_SEND1(0x%x,0x%x, 0x%x)\n", fpga_addr, (int) X313_WA_SMART_IRQ, (int) ( (2 | ((thispars->pars[P_IRQ_SMART] & 1)?1:0)) | \ MDF3(dev_dbg(g_dev_ptr," X3X3_SEQ_SEND1(0x%x,0x%x, 0x%x)\n", fpga_addr, (int) X313_WA_SMART_IRQ, (int) ( (2 | ((thispars->pars[P_IRQ_SMART] & 1)?1:0)) | \
(8 | ((thispars->pars[P_IRQ_SMART] & 2)?4:0))))); (8 | ((thispars->pars[P_IRQ_SMART] & 2)?4:0)))));
*/
return 0; return 0;
} }
...@@ -2375,6 +2495,7 @@ int pgm_recalcseq (int sensor_port, ///< sensor port number (0..3 ...@@ -2375,6 +2495,7 @@ int pgm_recalcseq (int sensor_port, ///< sensor port number (0..3
{G_CALLNEXT+4,0}, {G_CALLNEXT+4,0},
{G_CALLNASAP,0}}; {G_CALLNASAP,0}};
dev_dbg(g_dev_ptr,"{%d} frame16=%d, safe=%d, async=%d, nooverlap=%d\n",sensor_port,frame16, safe, async, nooverlap); dev_dbg(g_dev_ptr,"{%d} frame16=%d, safe=%d, async=%d, nooverlap=%d\n",sensor_port,frame16, safe, async, nooverlap);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
for (i=0; i < (sizeof(ahead_tab)/sizeof(ahead_tab[0])); i+=7) { for (i=0; i < (sizeof(ahead_tab)/sizeof(ahead_tab[0])); i+=7) {
b=ahead_tab[i]; b=ahead_tab[i];
d=ahead_tab[i+1+(nooverlap?5:(1+((async?2:0)+(safe?1:0))))]; ///continuous/safe - 1, continuous/no skip - 2, async/safe - 3, async/no skip - 4, nooverlap - 5 d=ahead_tab[i+1+(nooverlap?5:(1+((async?2:0)+(safe?1:0))))]; ///continuous/safe - 1, continuous/no skip - 2, async/safe - 3, async/no skip - 4, nooverlap - 5
...@@ -2417,6 +2538,7 @@ int pgm_comprestart(int sensor_port, ///< sensor port number (0..3 ...@@ -2417,6 +2538,7 @@ int pgm_comprestart(int sensor_port, ///< sensor port number (0..3
int disable_need = 1; // TODO: Use some G_* parameter int disable_need = 1; // TODO: Use some G_* parameter
x393_cmprs_mode_t cmprs_mode = {.d32=0}; x393_cmprs_mode_t cmprs_mode = {.d32=0};
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
// does it need to be be started (nothing do be done to stop) // does it need to be be started (nothing do be done to stop)
if (thispars->pars[P_COMPRESSOR_RUN]==0) return 0; // does not need compressor to be started if (thispars->pars[P_COMPRESSOR_RUN]==0) return 0; // does not need compressor to be started
...@@ -2448,6 +2570,8 @@ int pgm_comprestart(int sensor_port, ///< sensor port number (0..3 ...@@ -2448,6 +2570,8 @@ int pgm_comprestart(int sensor_port, ///< sensor port number (0..3
cmprs_mode.run_set = 1; 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);
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); 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)
return 0; return 0;
#else #else
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
...@@ -2492,6 +2616,7 @@ int pgm_compstop (int sensor_port, ///< sensor port number (0..3 ...@@ -2492,6 +2616,7 @@ int pgm_compstop (int sensor_port, ///< sensor port number (0..3
int disable_need = 1; // TODO: Use some G_* parameter int disable_need = 1; // TODO: Use some G_* parameter
x393_cmprs_mode_t cmprs_mode = {.d32=0}; x393_cmprs_mode_t cmprs_mode = {.d32=0};
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 if (frame16 >= PARS_FRAMES) return -EINVAL; // wrong frame
switch(thispars->pars[P_COLOR]){ switch(thispars->pars[P_COLOR]){
case COLORMODE_COLOR: case COLORMODE_COLOR:
...@@ -2513,6 +2638,7 @@ int pgm_compstop (int sensor_port, ///< sensor port number (0..3 ...@@ -2513,6 +2638,7 @@ int pgm_compstop (int sensor_port, ///< sensor port number (0..3
cmprs_mode.run_set = 1; 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);
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); 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)
return 0; return 0;
#else #else
...@@ -2539,7 +2665,11 @@ int pgm_compctl (int sensor_port, ///< sensor port number (0..3 ...@@ -2539,7 +2665,11 @@ int pgm_compctl (int sensor_port, ///< sensor port number (0..3
int extra_pages; int extra_pages;
int disable_need = 1; // TODO: Use some G_* parameter int disable_need = 1; // TODO: Use some G_* parameter
x393_cmprs_mode_t cmprs_mode = {.d32=0}; x393_cmprs_mode_t cmprs_mode = {.d32=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]); 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 (frame16 >= PARS_FRAMES) return -1; // wrong frame
if ((prevpars->pars[P_COMPRESSOR_RUN]==0) && (thispars->pars[P_COMPRESSOR_RUN]!=0)) { // just started if ((prevpars->pars[P_COMPRESSOR_RUN]==0) && (thispars->pars[P_COMPRESSOR_RUN]!=0)) { // just started
// Was for NC353 // Was for NC353
...@@ -2650,6 +2780,8 @@ int pgm_gammaload (int sensor_port, ///< sensor port number (0..3 ...@@ -2650,6 +2780,8 @@ int pgm_gammaload (int sensor_port, ///< sensor port number (0..3
dev_dbg(g_dev_ptr,"{%d} frame16=%d, (getThisFrameNumber() & PARS_FRAMES_MASK)= %ld, thispars->pars[P_GTAB_R]=0x%lx, thispars->pars[P_FRAME]=0x%lx\n", dev_dbg(g_dev_ptr,"{%d} frame16=%d, (getThisFrameNumber() & PARS_FRAMES_MASK)= %ld, thispars->pars[P_GTAB_R]=0x%lx, thispars->pars[P_FRAME]=0x%lx\n",
sensor_port, frame16, getThisFrameNumber(sensor_port) & PARS_FRAMES_MASK, thispars->pars[P_GTAB_R], thispars->pars[P_FRAME]); sensor_port, frame16, getThisFrameNumber(sensor_port) & PARS_FRAMES_MASK, thispars->pars[P_GTAB_R], thispars->pars[P_FRAME]);
MDP(DBGB_PSFN, sensor_port,"frame16=%d, (getThisFrameNumber() & PARS_FRAMES_MASK)= %ld, thispars->pars[P_GTAB_R]=0x%lx, thispars->pars[P_FRAME]=0x%lx\n",
frame16, getThisFrameNumber(sensor_port) & PARS_FRAMES_MASK, thispars->pars[P_GTAB_R], thispars->pars[P_FRAME])
///NOTE: Yes, ASAP, but - 1 frame ahead ///NOTE: Yes, ASAP, but - 1 frame ahead
if (frame16 >= 0) return -1; // only can work in ASAP mode if (frame16 >= 0) return -1; // only can work in ASAP mode
...@@ -2715,6 +2847,7 @@ int pgm_sensorregs (int sensor_port, ///< sensor port number (0..3 ...@@ -2715,6 +2847,7 @@ int pgm_sensorregs (int sensor_port, ///< sensor port number (0..3
///< @return OK - 0, <0 - error ///< @return OK - 0, <0 - error
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
return 0; return 0;
} }
...@@ -2729,6 +2862,7 @@ int pgm_sensorregs (int sensor_port, ///< sensor port number (0..3 ...@@ -2729,6 +2862,7 @@ int pgm_sensorregs (int sensor_port, ///< sensor port number (0..3
///< @return OK - 0, <0 - error ///< @return OK - 0, <0 - error
{ {
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); // nothing here, all in multisensor.c dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); // nothing here, all in multisensor.c
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
return 0; return 0;
} }
...@@ -2756,6 +2890,7 @@ int pgm_prescal (int sensor_port, ///< sensor port number ( ...@@ -2756,6 +2890,7 @@ int pgm_prescal (int sensor_port, ///< sensor port number (
// be applied to all active subchannels. // be applied to all active subchannels.
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16); 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 -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
for (sub_chn = 0; sub_chn < MAX_SENSORS; sub_chn++) if (GLOBALPARS(sensor_port, G_SUBCHANNELS) & (1 << sub_chn)){ for (sub_chn = 0; sub_chn < MAX_SENSORS; sub_chn++) if (GLOBALPARS(sensor_port, G_SUBCHANNELS) & (1 << sub_chn)){
poffs = VIGNET_SUBCHN_OFFSET * sub_chn; poffs = VIGNET_SUBCHN_OFFSET * sub_chn;
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#define VIDEOMEM_MODULE_DESCRIPTION "Video buffer driver" #define VIDEOMEM_MODULE_DESCRIPTION "Video buffer driver"
//#define VIDEOMEM_DRIVER_NAME "video_mem" //#define VIDEOMEM_DRIVER_NAME "video_mem"
// NC393 debug macros
#include "debug393.h"
static const struct of_device_id elphel393_videomem_of_match[]; static const struct of_device_id elphel393_videomem_of_match[];
static struct device *g_dev_ptr; ///< Global pointer to basic device structure. This pointer is used in debugfs output functions static struct device *g_dev_ptr; ///< Global pointer to basic device structure. This pointer is used in debugfs output functions
...@@ -82,6 +84,10 @@ int setup_sensor_memory (int num_sensor, ///< sensor port number (0..3) ...@@ -82,6 +84,10 @@ int setup_sensor_memory (int num_sensor, ///< sensor port number (0..3)
dev_dbg(g_dev_ptr,"{%d} frame16=%d, command=%d\n",num_sensor,frame16, (int) x393cmd); dev_dbg(g_dev_ptr,"{%d} frame16=%d, command=%d\n",num_sensor,frame16, (int) x393cmd);
dev_dbg(g_dev_ptr,"sa=0x%08x sa_inc=0x%08x lfn=0x%08x fw=0x%08x wh=0x%08x lt=0x%08x\n", dev_dbg(g_dev_ptr,"sa=0x%08x sa_inc=0x%08x lfn=0x%08x fw=0x%08x wh=0x%08x lt=0x%08x\n",
window_frame_sa.d32,window_frame_sa_inc.d32, window_last_frame_num, window_full_width.d32,window_width_height.d32,window_left_top.d32); window_frame_sa.d32,window_frame_sa_inc.d32, window_last_frame_num, window_full_width.d32,window_width_height.d32,window_left_top.d32);
MDP(DBGB_VM,num_sensor,"frame16=%d, command=%d\n", frame16, (int) x393cmd)
MDP(DBGB_VM,num_sensor,"sa=0x%08x sa_inc=0x%08x lfn=0x%08x fw=0x%08x wh=0x%08x lt=0x%08x\n",
window_frame_sa.d32,window_frame_sa_inc.d32, window_last_frame_num, window_full_width.d32,window_width_height.d32,window_left_top.d32)
switch (x393cmd){ switch (x393cmd){
case ASAP: case ASAP:
...@@ -153,6 +159,18 @@ int control_sensor_memory (int num_sensor, ///< sensor port number (0..3) ...@@ -153,6 +159,18 @@ int control_sensor_memory (int num_sensor, ///< sensor port number (0..3)
return -EINVAL; return -EINVAL;
} }
dev_dbg(g_dev_ptr,"{%d} frame16=%d, cmd=%d, x393cms=%d\n",num_sensor,frame16, cmd, (int) x393cmd);
dev_dbg(g_dev_ptr,"mode=0x%x (enable=%d, chn_nreset=%d, write_mem=%d, extra_pages=%d, keep_open=%d, byte32=%d, reset_frame=%d, single=%d,repetitive=%d, disable_need=%d,skip_too_late=%d )\n",
mcntrl_mode.d32, mcntrl_mode.enable, mcntrl_mode.chn_nreset, mcntrl_mode.write_mem, mcntrl_mode.extra_pages,
mcntrl_mode.keep_open, mcntrl_mode.byte32, mcntrl_mode.reset_frame, mcntrl_mode.single, mcntrl_mode.repetitive,
mcntrl_mode.disable_need, mcntrl_mode.skip_too_late);
MDP(DBGB_VM,num_sensor,"frame16=%d, cmd=%d, x393cms=%d\n",frame16, cmd, (int) x393cmd)
MDP(DBGB_VM,num_sensor,"mode=0x%x (enable=%d, chn_nreset=%d, write_mem=%d, extra_pages=%d, keep_open=%d, byte32=%d, reset_frame=%d, single=%d,repetitive=%d, disable_need=%d,skip_too_late=%d )\n",
mcntrl_mode.d32, mcntrl_mode.enable, mcntrl_mode.chn_nreset, mcntrl_mode.write_mem, mcntrl_mode.extra_pages,
mcntrl_mode.keep_open, mcntrl_mode.byte32, mcntrl_mode.reset_frame, mcntrl_mode.single, mcntrl_mode.repetitive,
mcntrl_mode.disable_need, mcntrl_mode.skip_too_late)
switch (x393cmd){ switch (x393cmd){
case ASAP: case ASAP:
frame16 = 0; frame16 = 0;
...@@ -215,7 +233,16 @@ int setup_compressor_memory (int num_sensor, ///< sensor port number (0..3 ...@@ -215,7 +233,16 @@ int setup_compressor_memory (int num_sensor, ///< sensor port number (0..3
dev_dbg(g_dev_ptr,"{%d} frame16=%d, command=%d\n",num_sensor,frame16, (int) x393cmd); dev_dbg(g_dev_ptr,"{%d} frame16=%d, command=%d\n",num_sensor,frame16, (int) x393cmd);
dev_dbg(g_dev_ptr,"sa=0x%08x sa_inc=0x%08x lfn=0x%08x fw=0x%08x wh=0x%08x lt=0x%08x whs=0x%08x\n", dev_dbg(g_dev_ptr,"sa=0x%08x sa_inc=0x%08x lfn=0x%08x fw=0x%08x wh=0x%08x lt=0x%08x whs=0x%08x\n",
window_frame_sa.d32,window_frame_sa_inc.d32, window_last_frame_num.d32, window_full_width.d32,window_width_height.d32,window_left_top.d32, window_tile_whs.d32); window_frame_sa.d32,window_frame_sa_inc.d32, window_last_frame_num.d32, window_full_width.d32,
window_width_height.d32,window_left_top.d32, window_tile_whs.d32);
MDP(DBGB_VM,num_sensor,"frame16=%d, command=%d\n", frame16, (int) x393cmd)
MDP(DBGB_VM,num_sensor,"sa=0x%08x sa_inc=0x%08x lfn=0x%08x fw=0x%08x wh=0x%08x lt=0x%08x whs=0x%08x\n",
window_frame_sa.d32,window_frame_sa_inc.d32, window_last_frame_num, window_full_width.d32,
window_width_height.d32,window_left_top.d32, window_tile_whs.d32)
switch (x393cmd){ switch (x393cmd){
case ASAP: case ASAP:
...@@ -294,6 +321,16 @@ int control_compressor_memory (int num_sensor, ///< sensor port number (0. ...@@ -294,6 +321,16 @@ int control_compressor_memory (int num_sensor, ///< sensor port number (0.
default: default:
return -EINVAL; return -EINVAL;
} }
dev_dbg(g_dev_ptr,"{%d} frame16=%d, cmd=%d, x393cms=%d\n",num_sensor,frame16, cmd, (int) x393cmd);
dev_dbg(g_dev_ptr,"mode=0x%x (enable=%d, chn_nreset=%d, write_mem=%d, extra_pages=%d, keep_open=%d, byte32=%d, reset_frame=%d, single=%d,repetitive=%d, disable_need=%d,skip_too_late=%d )\n",
mcntrl_mode.d32, mcntrl_mode.enable, mcntrl_mode.chn_nreset, mcntrl_mode.write_mem, mcntrl_mode.extra_pages,
mcntrl_mode.keep_open, mcntrl_mode.byte32, mcntrl_mode.reset_frame, mcntrl_mode.single, mcntrl_mode.repetitive,
mcntrl_mode.disable_need, mcntrl_mode.skip_too_late);
MDP(DBGB_VM,num_sensor,"frame16=%d, cmd=%d, x393cms=%d\n",frame16, cmd, (int) x393cmd)
MDP(DBGB_VM,num_sensor,"mode=0x%x (enable=%d, chn_nreset=%d, write_mem=%d, extra_pages=%d, keep_open=%d, byte32=%d, reset_frame=%d, single=%d,repetitive=%d, disable_need=%d,skip_too_late=%d )\n",
mcntrl_mode.d32, mcntrl_mode.enable, mcntrl_mode.chn_nreset, mcntrl_mode.write_mem, mcntrl_mode.extra_pages,
mcntrl_mode.keep_open, mcntrl_mode.byte32, mcntrl_mode.reset_frame, mcntrl_mode.single, mcntrl_mode.repetitive,
mcntrl_mode.disable_need, mcntrl_mode.skip_too_late)
switch (x393cmd){ switch (x393cmd){
case ASAP: case ASAP:
......
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