Commit 66ec8f57 authored by Andrey Filippov's avatar Andrey Filippov

merged with framepars

parents 2677b54a cf73e112
...@@ -262,11 +262,14 @@ ...@@ -262,11 +262,14 @@
elphel393_sensor_i2c: elphel393-sensor-i2c@0 { elphel393_sensor_i2c: elphel393-sensor-i2c@0 {
compatible = "elphel,elphel393-sensor-i2c-1.00"; compatible = "elphel,elphel393-sensor-i2c-1.00";
/* Add known devices: name, slave address (7-bit), number of address bytes, number of data bytes, SCL frequency (kHz) */ /* Add known devices: name, slave address (7-bit), number of address bytes, number of data bytes, SCL frequency (kHz) */
elphel393-sensor-i2c,i2c_devices = "mt9f002 0x10 2 2 500", elphel393-sensor-i2c,i2c_devices = "mt9f002 0x10 2 2 500",
"mt9p006 0x48 1 2 500", "mt9p006 0x48 1 2 500",
"el10359 0x08 1 2 500", "el10359 0x08 1 2 500",
"el10359_32 0x08 1 4 500",
"pca9500_eeprom 0x50 1 1 100", "pca9500_eeprom 0x50 1 1 100",
"cy22393 0x69 1 1 100"; "sensor_eeprom 0x50 1 1 100",
"sensor_temp 0x18 1 2 100",
"cy22393 0x69 1 1 100";
} ; } ;
framepars_operations: elphel393-framepars@0 { framepars_operations: elphel393-framepars@0 {
...@@ -285,6 +288,10 @@ ...@@ -285,6 +288,10 @@
compatible = "elphel,elphel393-mt9x001-1.00"; compatible = "elphel,elphel393-mt9x001-1.00";
}; };
elphel393_clock10359:elphel393-clock10359@0{
compatible = "elphel,elphel393_clock10359-1.00";
};
klogger_393: klogger-393@0 { klogger_393: klogger-393@0 {
compatible = "elphel,klogger-393-1.00"; compatible = "elphel,klogger-393-1.00";
klogger-393,buffer_size = <1048576>; klogger-393,buffer_size = <1048576>;
......
...@@ -84,25 +84,25 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz ...@@ -84,25 +84,25 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz
unsigned int fpmx= CY22393_XTAL * (CY22393_PMAX + 6); unsigned int fpmx= CY22393_XTAL * (CY22393_PMAX + 6);
int divmn, divmx, err1,err, div,q,qmn,qmx,qmx1,fdv,p, e,fdvq; int divmn, divmx, err1,err, div,q,qmn,qmx,qmx1,fdv,p, e,fdvq;
pars->rslt=3; // other error pars->rslt=3; // other error
dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d\r\n",f0,f,CY22393_OUTMAX); dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d\n",f0,f,CY22393_OUTMAX);
f/=CY22393_SCALE; // to fit into 32-bit calculations f/=CY22393_SCALE; // to fit into 32-bit calculations
dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d\r\n",f0,f,CY22393_OUTMAX); dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d\n",f0,f,CY22393_OUTMAX);
if (f>CY22393_OUTMAX) { if (f>CY22393_OUTMAX) {
pars->rslt=2; pars->rslt=2;
dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d\r\n",f0,f,CY22393_OUTMAX); dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d\n",f0,f,CY22393_OUTMAX);
return pars->rslt; return pars->rslt;
} }
if (f <=0 ) { if (f <=0 ) {
pars->rslt=1; pars->rslt=1;
dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d\r\n",f0,f,CY22393_OUTMAX); dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d\n",f0,f,CY22393_OUTMAX);
return pars->rslt; return pars->rslt;
} }
divmx=CY22393_PLLMAX/f; if (divmx > 127) divmx=127; // could not be <1 divmx=CY22393_PLLMAX/f; if (divmx > 127) divmx=127; // could not be <1
divmn=CY22393_PLLMIN/f; if (divmn < 1) divmn=1; divmn=CY22393_PLLMIN/f; if (divmn < 1) divmn=1;
if (divmn >127) { if (divmn >127) {
pars->rslt=1; pars->rslt=1;
dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d, divmn=%d\r\n",f0,f,CY22393_OUTMAX,divmn); dev_dbg(sdev, "f0=%d,f=%d, CY22393_OUTMAX=%d, divmn=%d\n",f0,f,CY22393_OUTMAX,divmn);
return pars->rslt; return pars->rslt;
} }
err1=f; err1=f;
...@@ -113,7 +113,7 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz ...@@ -113,7 +113,7 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz
qmn=fpmn/fdv-2; if (qmn < 0) qmn=0; qmn=fpmn/fdv-2; if (qmn < 0) qmn=0;
qmx=fpmx/fdv-2; if (qmx >255) qmx=255; qmx=fpmx/fdv-2; if (qmx >255) qmx=255;
// recalculate qmn to avoid same div*qmn as already tried with lover div // recalculate qmn to avoid same div*qmn as already tried with lover div
dev_dbg(sdev, "div=%d,qmn=%d, qmx=%d\r\n",div,qmn,qmx); dev_dbg(sdev, "div=%d,qmn=%d, qmx=%d\n",div,qmn,qmx);
if (div==1) qmx1=qmx; if (div==1) qmx1=qmx;
else if ((qmn*div) < qmx1) qmn=qmx1/div; else if ((qmn*div) < qmx1) qmn=qmx1/div;
for (q=qmn+2;q<=qmx+2; q++) { for (q=qmn+2;q<=qmx+2; q++) {
...@@ -127,10 +127,10 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz ...@@ -127,10 +127,10 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz
pars->dv=div; pars->dv=div;
err1=e/q/div; err1=e/q/div;
err=err1*div; err=err1*div;
dev_dbg(sdev, "f=%d, div=%d, p=%d,q=%d, err1=%d\r\n", (f0*p)/q/div, div,p, q, err1); dev_dbg(sdev, "f=%d, div=%d, p=%d,q=%d, err1=%d\n", (f0*p)/q/div, div,p, q, err1);
if (err1==0) { if (err1==0) {
pars->corr=(pars->p<226)?0:((pars->p<621)?1:((pars->p<829)?2:((pars->p<1038)?3:4))); pars->corr=(pars->p<226)?0:((pars->p<621)?1:((pars->p<829)?2:((pars->p<1038)?3:4)));
dev_dbg(sdev, "f=%d, div=%d, p=%d,q=%d, err1=%d, rslt=%d\r\n", dev_dbg(sdev, "f=%d, div=%d, p=%d,q=%d, err1=%d, rslt=%d\n",
(f0*(pars->p+6))/(pars->q+2)/pars->dv, (f0*(pars->p+6))/(pars->q+2)/pars->dv,
pars->dv, pars->dv,
(pars->p+6), (pars->p+6),
...@@ -142,7 +142,7 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz ...@@ -142,7 +142,7 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz
} }
} }
} }
dev_dbg(sdev, "f=%d, div=%d, p=%d,q=%d, err1=%d, rslt=%d\r\n", dev_dbg(sdev, "f=%d, div=%d, p=%d,q=%d, err1=%d, rslt=%d\n",
(f0*(pars->p+6))/(pars->q+2)/pars->dv, (f0*(pars->p+6))/(pars->q+2)/pars->dv,
pars->dv, pars->dv,
(pars->p+6), (pars->p+6),
...@@ -156,6 +156,7 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz ...@@ -156,6 +156,7 @@ int calc_pll_params (unsigned int f, t_pll_params * pars) { // f -in Hz
int setCYField (int sensor_port, int reg_addr, int mask, int value) { int setCYField (int sensor_port, int reg_addr, int mask, int value) {
int error; int error;
int reg_data; int reg_data;
dev_dbg(sdev,"setCYField(%d, 0x%x, 0x%x,0x%x)\n",sensor_port, reg_addr, mask, value);
if ((error = x393_xi2c_read_reg(CLOCK_NAME, // device class name if ((error = x393_xi2c_read_reg(CLOCK_NAME, // device class name
sensor_port, // sensor port number sensor_port, // sensor port number
0, // slave address (7-bit) offset from the class defined slave address 0, // slave address (7-bit) offset from the class defined slave address
...@@ -165,6 +166,7 @@ int setCYField (int sensor_port, int reg_addr, int mask, int value) { ...@@ -165,6 +166,7 @@ int setCYField (int sensor_port, int reg_addr, int mask, int value) {
sensor_port, reg_addr, mask, value); sensor_port, reg_addr, mask, value);
return error; return error;
} }
dev_dbg(sdev,"setCYField(%d, 0x%x, 0x%x,0x%x)=>0x%x\n",sensor_port, reg_addr, mask, value,reg_data);
reg_data ^= (reg_data ^ value) & mask; reg_data ^= (reg_data ^ value) & mask;
if ((error = x393_xi2c_write_reg(CLOCK_NAME, // device class name if ((error = x393_xi2c_write_reg(CLOCK_NAME, // device class name
sensor_port, // sensor port number sensor_port, // sensor port number
...@@ -179,24 +181,45 @@ int setCYField (int sensor_port, int reg_addr, int mask, int value) { ...@@ -179,24 +181,45 @@ int setCYField (int sensor_port, int reg_addr, int mask, int value) {
} }
int x393_getClockFreq(int sensor_port, int nclock) { int x393_getClockFreq(int sensor_port, int nclock) {
if ((sensor_port < 0) || (sensor_port > 3) || (nclock < 0) || (nclock > 3))return -EINVAL; // bad clock number if ((sensor_port < 0) || (sensor_port > 3) || (nclock < 0) || (nclock > 3))return -EINVAL; // bad clock number
else { else {
return clock_frequency[(sensor_port << 2) || nclock]; dev_dbg(sdev, "clock_frequency[%d]\n",(sensor_port << 2) + nclock);
} return clock_frequency[(sensor_port << 2) + nclock];
}
} }
EXPORT_SYMBOL_GPL(x393_getClockFreq); EXPORT_SYMBOL_GPL(x393_getClockFreq);
int x393_setClockFreq(int sensor_port, int nclock, int freq) int x393_setClockFreq(int sensor_port, int nclock, int freq)
{ // freq now in Hz { // freq now in Hz
int err=0; int err=0;
int i,bp,bq,bdiv,pllc,fact;
t_pll_params pll_params;
sensor_port &= 3; sensor_port &= 3;
nclock &= 3; nclock &= 3;
t_pll_params pll_params;
int i,bp,bq,bdiv,pllc,fact;
bp=0; bq=0; bdiv=0; pllc= 0; // just to make gcc happy bp=0; bq=0; bdiv=0; pllc= 0; // just to make gcc happy
fact=0; fact=0;
dev_dbg(sdev, "setClockFreq(%d,%d,%d)\r\n",sensor_port,nclock,freq); dev_dbg(sdev, "setClockFreq(%d,%d,%d)\n",sensor_port,nclock,freq);
// Just temporary debug:
#if 1
for (i = 0; i< 24; i++) {
int reg_data;
// dev_dbg(sdev,"setCYField(%d, 0x%x, 0x%x,0x%x)\n",sensor_port, reg_addr, mask, value);
if ((err = x393_xi2c_read_reg(CLOCK_NAME, // device class name
sensor_port, // sensor port number
0, // slave address (7-bit) offset from the class defined slave address
i, // register address (width is defined by class)
&reg_data)) <0) { // pointer to a data receiver (read data width is defined by class)
dev_err(sdev,"x393_xi2c_read_reg(%d, 0, 0x%x, 0x%x) failed reading i2c register\n", sensor_port, i, reg_data);
break;
}
dev_err(sdev,"CY22393 port %d: [0x%x] => 0x%x\n", sensor_port, i, reg_data);
}
#endif
if ((freq!=0) && (nclock!=3) ){ if ((freq!=0) && (nclock!=3) ){
if ( (i=calc_pll_params (freq, &pll_params)) !=0) { if ( (i=calc_pll_params (freq, &pll_params)) !=0) {
dev_err(sdev, "bad frequency for clock %d - %d Hz, err=%d\n",nclock,freq,i); dev_err(sdev, "bad frequency for clock %d - %d Hz, err=%d\n",nclock,freq,i);
...@@ -255,7 +278,7 @@ int x393_setClockFreq(int sensor_port, int nclock, int freq) ...@@ -255,7 +278,7 @@ int x393_setClockFreq(int sensor_port, int nclock, int freq)
break; break;
case 3: case 3:
if ((freq!=0) && (freq!=CY22393_SCALE*CY22393_XTAL)) { if ((freq!=0) && (freq!=CY22393_SCALE*CY22393_XTAL)) {
dev_err(sdev, "Only frequency 0 (off) and %d Hz (xtal) are allowed for channel 3\r\n",CY22393_SCALE*CY22393_XTAL); dev_err(sdev, "Only frequency 0 (off) and %d Hz (xtal) are allowed for channel 3\n",CY22393_SCALE*CY22393_XTAL);
return -EINVAL; return -EINVAL;
} else { } else {
// int setCYField (sensor_port,int devfd, int addr, int mask, int value) O_RDWR // int setCYField (sensor_port,int devfd, int addr, int mask, int value) O_RDWR
...@@ -275,6 +298,7 @@ int x393_setClockFreq(int sensor_port, int nclock, int freq) ...@@ -275,6 +298,7 @@ int x393_setClockFreq(int sensor_port, int nclock, int freq)
return err; return err;
} }
clock_frequency[(sensor_port << 2) + nclock] = fact; clock_frequency[(sensor_port << 2) + nclock] = fact;
dev_dbg(sdev, "clock_frequency[%d]\n",(sensor_port << 2) + nclock);
return fact; return fact;
} }
EXPORT_SYMBOL_GPL(x393_setClockFreq); EXPORT_SYMBOL_GPL(x393_setClockFreq);
...@@ -400,7 +424,7 @@ static void elphel393_clock10359_init_of(struct platform_device *pdev) ...@@ -400,7 +424,7 @@ static void elphel393_clock10359_init_of(struct platform_device *pdev)
static int elphel393_clock10359_probe(struct platform_device *pdev) static int elphel393_clock10359_probe(struct platform_device *pdev)
{ {
sdev =&pdev->dev; sdev =&pdev->dev;
dev_dbg(&pdev->dev,"Probing elphel_clock10359\n"); dev_info(&pdev->dev,"Probing elphel_clock10359\n");
elphel393_clock10359_sysfs_register(pdev); elphel393_clock10359_sysfs_register(pdev);
dev_dbg(&pdev->dev,"elphel393_clock10359_sysfs_register() done\n"); dev_dbg(&pdev->dev,"elphel393_clock10359_sysfs_register() done\n");
......
...@@ -837,7 +837,7 @@ inline void _processParsSeq(int sensor_port, ///< sensor port ...@@ -837,7 +837,7 @@ inline void _processParsSeq(int sensor_port, ///< sensor port
{ {
unsigned long todo, mask, remain; unsigned long todo, mask, remain;
int job_ahead; // doing job "job_ahead" ahead of needed int job_ahead; // doing job "job_ahead" ahead of needed
int pars_ahead; // considering parameter "pars_ahead" of the (frame16+job_ahead) mod 8 int pars_ahead; // considering parameter "pars_ahead" of the (frame16+job_ahead) mod 16
int frame_proc; // current frame for which parameters are considered int frame_proc; // current frame for which parameters are considered
struct framepars_t * procpars; struct framepars_t * procpars;
struct framepars_t * prevpars; // maybe - drop calculation for each function, move it to pgm_* where needed? struct framepars_t * prevpars; // maybe - drop calculation for each function, move it to pgm_* where needed?
...@@ -968,7 +968,10 @@ void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16 ...@@ -968,7 +968,10 @@ void _processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16
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);
if (debug_flags) debug_flags--; if (debug_flags) {
dev_dbg(g_devfp_ptr,"debug_flags= %d \n", debug_flags);
debug_flags--;
}
} }
...@@ -1007,7 +1010,7 @@ int processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, ...@@ -1007,7 +1010,7 @@ int processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16,
if (debug_flags) { if (debug_flags) {
MDP(DBGB_FPPT,sensor_port,"==from tasklet: frame16=%d, maxahead=%d\n", MDP(DBGB_FPPT,sensor_port,"==from tasklet: frame16=%d, maxahead=%d\n",
frame16, maxahead) frame16, maxahead)
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 now=0x%lx\n", sensor_port, frame16, maxahead, getThisFrameNumber(sensor_port));
} }
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);
...@@ -1021,13 +1024,12 @@ int processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16, ...@@ -1021,13 +1024,12 @@ int processPars(int sensor_port, struct sensorproc_t * sensorproc, int frame16,
if (debug_flags) { if (debug_flags) {
MDP(DBGB_FPPT,sensor_port,"==Done from tasklet: frame16=%d, maxahead=%d\n", MDP(DBGB_FPPT,sensor_port,"==Done from tasklet: frame16=%d, maxahead=%d\n",
frame16, maxahead) frame16, maxahead)
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 now=0x%lx\n", sensor_port, frame16, maxahead, getThisFrameNumber(sensor_port));
} }
return 0; return 0;
} }
#endif #endif
/** /**
* @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)
......
...@@ -16,7 +16,7 @@ void init_framepars_ptr(int sensor_port); ...@@ -16,7 +16,7 @@ void init_framepars_ptr(int sensor_port);
int initSequencers (int sensor_port); ///Move to sensorcommon? currently it is used through frameparsall file (lseek) int initSequencers (int sensor_port); ///Move to sensorcommon? currently it is used through frameparsall file (lseek)
void initGlobalPars (int sensor_port); /// resets all global parameters but debug mask (if ELPHEL_DEBUG) void initGlobalPars (int sensor_port); /// resets all global parameters but debug mask (if ELPHEL_DEBUG)
int initMultiPars (int sensor_port); /// initialize structures for individual per-sensor parameters. Now only works for sensor registers using G_MULTI_REGSM. Should be called aftre/during sensor detection int initMultiPars (int sensor_port); /// initialize structures for individual per-sensor parameters. Now only works for sensor registers using G_MULTI_REGSM. Should be called aftre/during sensor detection
void initFramePars (int sensor_port); ///initialize all parameters, set thisFrameNumber to frame8 (read from hardware, usually 0 after resetting i2c and cmd_seq) void initFramePars (int sensor_port); ///initialize all parameters, set thisFrameNumber to frame16 (read from hardware, usually 0 after resetting i2c and cmd_seq)
void resetFrameNumber (int sensor_port, u32 aframe, int hreset); /// reset this frame number (called from initFramePars(), also can be used to avoid frame number integer overflow) void resetFrameNumber (int sensor_port, u32 aframe, int hreset); /// reset this frame number (called from initFramePars(), also can be used to avoid frame number integer overflow)
unsigned long get_imageParamsFrame(int sensor_port, int n, int frame); unsigned long get_imageParamsFrame(int sensor_port, int n, int frame);
......
...@@ -1219,7 +1219,7 @@ int mt9x001_pgm_limitfps (int sensor_port, ///< sensor port numb ...@@ -1219,7 +1219,7 @@ int mt9x001_pgm_limitfps (int sensor_port, ///< sensor port numb
{ {
struct frameparspair_t pars_to_update[16]; // maximum 7 registers updated (need to recount) struct frameparspair_t pars_to_update[16]; // maximum 7 registers updated (need to recount)
int nupdate=0; int nupdate=0;
int dh= thispars->pars[P_DCM_HOR]; int dh= thispars->pars[P_DCM_HOR]?thispars->pars[P_DCM_HOR]:1;
int ww= thispars->pars[P_SENSOR_PIXH] * dh; int ww= thispars->pars[P_SENSOR_PIXH] * dh;
int binning_cost = 0; int binning_cost = 0;
int width,i; int width,i;
...@@ -1989,8 +1989,8 @@ int mt9x001_pgm_triggermode (int sensor_port, ///< sensor p ...@@ -1989,8 +1989,8 @@ int mt9x001_pgm_triggermode (int sensor_port, ///< sensor p
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 (frame16 >= PARS_FRAMES) return -1; // wrong frame if (frame16 >= PARS_FRAMES) return -1; // wrong frame
newreg= (thispars->pars[P_SENSOR_REGS+P_MT9X001_RMODE1] & 0xfe7f) | // old value without snamshot and GRR bits newreg= (thispars->pars[P_SENSOR_REGS+P_MT9X001_RMODE1] & 0xfe7f) | // old value without snamshot and GRR bits
((thispars->pars[P_TRIG] & 4)?0x100:0) | // snapshot mode for P_TRIG==4 or 5 ((thispars->pars[P_TRIG] & 4)?0x100:0) | // snapshot mode for P_TRIG==4 or 20
((thispars->pars[P_TRIG] & 1)?0x80:0); // GRR mode for P_TRIG==5 (no effect for 1 ((thispars->pars[P_TRIG] & 0x10)?0x80:0); // GRR mode for P_TRIG==20
if (newreg != thispars->pars[P_SENSOR_REGS+P_MT9X001_RMODE1]) { if (newreg != thispars->pars[P_SENSOR_REGS+P_MT9X001_RMODE1]) {
// turn off triggered mode immediately, turn on later (or should made at least before changing camsync parameters) // turn off triggered mode immediately, turn on later (or should made at least before changing camsync parameters)
if (!(thispars->pars[P_TRIG] & 4)){ if (!(thispars->pars[P_TRIG] & 4)){
......
This diff is collapsed.
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
//#define I2C359_I2CMUX 0x07 //#define I2C359_I2CMUX 0x07
// #define I2C359_I2CMUX_2MEM 0x1 // #define I2C359_I2CMUX_2MEM 0x1
// #define I2C359_I2CMUX_2SENSORS 0x0 // #define I2C359_I2CMUX_2SENSORS 0x0
#define I2C359_CLKSRC 0x08 ///< register address: clock source #define I2C359_CLKSRC 0x08 ///< register address: clock source // does not read back
#define I2C359_CLKSRC_SYSTEM 0x00 ///< clock source: system (from the system board over) #define I2C359_CLKSRC_SYSTEM 0x00 ///< clock source: system (from the system board over)
#define I2C359_CLKSRC_LOCAL 0x01 ///< clock source: local (clock generator on the 10359 board #define I2C359_CLKSRC_LOCAL 0x01 ///< clock source: local (clock generator on the 10359 board
#define I2C359_MODE 0x09 ///< register address: mode register #define I2C359_MODE 0x09 ///< register address: mode register
......
...@@ -1096,6 +1096,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number ( ...@@ -1096,6 +1096,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
} }
// dh (decimation changed)? // dh (decimation changed)?
dh = thispars->pars[P_DCM_HOR]; dh = thispars->pars[P_DCM_HOR];
dh = dh?dh:1;
if (FRAMEPAR_MODIFIED(P_DCM_HOR)) { if (FRAMEPAR_MODIFIED(P_DCM_HOR)) {
if (dh<1) dh=1; else if (dh>32) dh=32; if (dh<1) dh=1; else if (dh>32) dh=32;
while ((dh>1) && !(sensor->dcmHor & (1 << (dh-1)))) dh--; // adjust decimation to maximal supported (if requested is not supported) while ((dh>1) && !(sensor->dcmHor & (1 << (dh-1)))) dh--; // adjust decimation to maximal supported (if requested is not supported)
...@@ -1103,6 +1104,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number ( ...@@ -1103,6 +1104,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
} }
// dv (decimation changed)? // dv (decimation changed)?
dv = thispars->pars[P_DCM_VERT]; dv = thispars->pars[P_DCM_VERT];
dv = dv?dv:1;
if (FRAMEPAR_MODIFIED(P_DCM_VERT)) { if (FRAMEPAR_MODIFIED(P_DCM_VERT)) {
if (dv<1) dv=1; else if (dv>32) dv=32; if (dv<1) dv=1; else if (dv>32) dv=32;
while ((dv>1) && !(sensor->dcmVert & (1 << (dv-1)))) dv--; // adjust decimation to maximal supported (if requested is not supported) while ((dv>1) && !(sensor->dcmVert & (1 << (dv-1)))) dv--; // adjust decimation to maximal supported (if requested is not supported)
...@@ -1110,6 +1112,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number ( ...@@ -1110,6 +1112,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
} }
// bh (binning changed)? // bh (binning changed)?
bh = thispars->pars[P_BIN_HOR]; bh = thispars->pars[P_BIN_HOR];
dv = dv?dv:1;
if (FRAMEPAR_MODIFIED(P_BIN_HOR)) { if (FRAMEPAR_MODIFIED(P_BIN_HOR)) {
if (bh<1) bh=1; else if (bh>dh) bh=dh; if (bh<1) bh=1; else if (bh>dh) bh=dh;
while ((bh>1) && !(sensor->binHor & (1 << (bh-1)))) bh--; // adjust binning to maximal supported (if requested is not supported) while ((bh>1) && !(sensor->binHor & (1 << (bh-1)))) bh--; // adjust binning to maximal supported (if requested is not supported)
...@@ -1117,6 +1120,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number ( ...@@ -1117,6 +1120,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
} }
// bv (binning changed)? // bv (binning changed)?
bv = thispars->pars[P_BIN_VERT]; bv = thispars->pars[P_BIN_VERT];
bv = bv?bv:1;
if (FRAMEPAR_MODIFIED(P_BIN_VERT)) { if (FRAMEPAR_MODIFIED(P_BIN_VERT)) {
if (bv<1) bv=1; else if (bv>dv) bv=dv; if (bv<1) bv=1; else if (bv>dv) bv=dv;
while ((bv>1) && !(sensor->binVert & (1 << (bv-1)))) bv--; // adjust binning to maximal supported (if requested is not supported) while ((bv>1) && !(sensor->binVert & (1 << (bv-1)))) bv--; // adjust binning to maximal supported (if requested is not supported)
...@@ -1437,7 +1441,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3 ...@@ -1437,7 +1441,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
x393_gamma_ctl_t gamma_ctl = {.d32=0}; x393_gamma_ctl_t gamma_ctl = {.d32=0};
int bayer; int bayer;
int n_scan_lines, n_ph_lines; int n_scan_lines; //, n_ph_lines;
int flips; int flips;
int bayer_modified; int bayer_modified;
x393_mcntrl_frame_start_dly_t start_dly ={.d32=0}; x393_mcntrl_frame_start_dly_t start_dly ={.d32=0};
...@@ -1525,8 +1529,8 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3 ...@@ -1525,8 +1529,8 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
if (FRAMEPAR_MODIFIED(P_MEMSENSOR_DLY) && ((start_dly.start_dly = thispars->pars[P_MEMSENSOR_DLY]))){ if (FRAMEPAR_MODIFIED(P_MEMSENSOR_DLY) && ((start_dly.start_dly = thispars->pars[P_MEMSENSOR_DLY]))){
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_mcntrl_scanline_start_delay, start_dly); X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_mcntrl_scanline_start_delay, start_dly);
dev_dbg(g_dev_ptr,"{%d} Setting sensor-to-memory frame sync delay to %ld (0x%lx)\n",sensor_port, start_dly.start_dly,start_dly.start_dly); dev_dbg(g_dev_ptr,"{%d} Setting sensor-to-memory frame sync delay to %d (0x%x)\n",sensor_port, start_dly.start_dly,start_dly.start_dly);
MDP(DBGB_PADD, sensor_port,"Setting sensor-to-memory frame sync delay to %ld (0x%lx)\n", start_dly.start_dly,start_dly.start_dly) MDP(DBGB_PADD, sensor_port,"Setting sensor-to-memory frame sync delay to %d (0x%x)\n", start_dly.start_dly,start_dly.start_dly)
} }
...@@ -2400,8 +2404,8 @@ int pgm_focusmode (int sensor_port, ///< sensor port number (0..3 ...@@ -2400,8 +2404,8 @@ int pgm_focusmode (int sensor_port, ///< sensor port number (0..3
///< be applied to, negative - ASAP ///< be applied to, negative - ASAP
///< @return OK - 0, <0 - error ///< @return OK - 0, <0 - error
{ {
unsigned long flags; // unsigned long flags;
int i; // int i;
// x393_cmprs_table_addr_t table_addr; // x393_cmprs_table_addr_t table_addr;
struct { struct {
short left; short left;
...@@ -2884,7 +2888,7 @@ int pgm_compstop (int sensor_port, ///< sensor port number (0..3 ...@@ -2884,7 +2888,7 @@ int pgm_compstop (int sensor_port, ///< sensor port number (0..3
disable_need, disable_need,
(frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer (frame16<0)? ASAP: ABSOLUTE, // how to apply commands - directly or through channel sequencer
frame16); frame16);
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}@0x%lx: X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_control_reg, 0x%x)\n",sensor_port, getThisFrameNumber(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) 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;
...@@ -2913,7 +2917,7 @@ int pgm_compctl (int sensor_port, ///< sensor port number (0..3 ...@@ -2913,7 +2917,7 @@ int pgm_compctl (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};
int reset_frame = 0; int reset_frame = 0;
int just_started = 0; // int just_started = 0;
dev_dbg(g_dev_ptr,"{%d} frame16=%d, prevpars->pars[P_COMPRESSOR_RUN]=%d, thispars->pars[P_COMPRESSOR_RUN]=%d \n", 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]); 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", MDP(DBGB_PSFN, sensor_port,"frame16=%d, prevpars->pars[P_COMPRESSOR_RUN]=%d, thispars->pars[P_COMPRESSOR_RUN]=%d \n",
...@@ -2958,7 +2962,8 @@ int pgm_compctl (int sensor_port, ///< sensor port number (0..3 ...@@ -2958,7 +2962,8 @@ int pgm_compctl (int sensor_port, ///< sensor port number (0..3
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}@0x%lx: X393_SEQ_SEND1(0x%x, 0x%x, x393_cmprs_control_reg, 0x%x)\n",sensor_port, getThisFrameNumber(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) 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;
......
...@@ -1141,16 +1141,21 @@ int legacy_i2c(int ports) ///< bitmask of the sensor ports to use ...@@ -1141,16 +1141,21 @@ int legacy_i2c(int ports) ///< bitmask of the sensor ports to use
for (sensor_port=0; sensor_port< SENSOR_PORTS; sensor_port++) if (ports & (1 << sensor_port)) { for (sensor_port=0; sensor_port< SENSOR_PORTS; sensor_port++) if (ports & (1 << sensor_port)) {
i2c_page_alloc_init(sensor_port); // reset all pages allocation i2c_page_alloc_init(sensor_port); // reset all pages allocation
i2c_page_register(sensor_port, class_10359->slave7); i2c_page_register(sensor_port, class_10359->slave7);
dev_dbg(g_dev_ptr, "Reset previously allocated pages for port= %d\n",sensor_port);
dev_dbg(g_dev_ptr, "Setting 10359 page for port %d, slave= 0x%x\n",sensor_port,class_10359->slave7);
set_xi2c_wrc(class_10359, sensor_port, class_10359->slave7, 0); set_xi2c_wrc(class_10359, sensor_port, class_10359->slave7, 0);
for (subchn = 0; subchn <4; subchn++){ // subchn == 0 - broadcast for (subchn = 0; subchn <4; subchn++){ // subchn == 0 - broadcast
dev_sensor.slave7 = class_sensor->slave7 + I2C359_INC * subchn; dev_sensor.slave7 = class_sensor->slave7 + I2C359_INC * subchn;
dev_dbg(g_dev_ptr, "Setting sensor page for port %d, slave= 0x%x\n",sensor_port,dev_sensor.slave7);
i2c_page_register(sensor_port, dev_sensor.slave7); i2c_page_register(sensor_port, dev_sensor.slave7);
set_xi2c_wrc(&dev_sensor, sensor_port, dev_sensor.slave7, 0); set_xi2c_wrc(&dev_sensor, sensor_port, dev_sensor.slave7, 0);
} }
// Now register one page for reading 10359 and the sensor using sensor speed data // Now register one page for reading 10359 and the sensor using sensor speed data
memcpy(&dev_sensor, class_sensor, sizeof(x393_i2c_device_t)); // dev_sensor)); memcpy(&dev_sensor, class_sensor, sizeof(x393_i2c_device_t)); // dev_sensor));
dev_dbg(g_dev_ptr, "Registering page to read senors 16-bit on port %d, page= 0x%x\n",sensor_port,LEGACY_READ_PAGE2);
i2c_page_register(sensor_port, LEGACY_READ_PAGE2); i2c_page_register(sensor_port, LEGACY_READ_PAGE2);
set_xi2c_rdc(&dev_sensor, sensor_port, LEGACY_READ_PAGE2); set_xi2c_rdc(&dev_sensor, sensor_port, LEGACY_READ_PAGE2);
dev_dbg(g_dev_ptr, "Registering page to read 32-bit data for 10359 on port %d, page= 0x%x\n",sensor_port,LEGACY_READ_PAGE4);
i2c_page_register(sensor_port, LEGACY_READ_PAGE4); i2c_page_register(sensor_port, LEGACY_READ_PAGE4);
dev_sensor.data_bytes=4; // for reading 10359 in 32-bit mode dev_sensor.data_bytes=4; // for reading 10359 in 32-bit mode
set_xi2c_rdc(&dev_sensor, sensor_port, LEGACY_READ_PAGE4); set_xi2c_rdc(&dev_sensor, sensor_port, LEGACY_READ_PAGE4);
......
This diff is collapsed.
...@@ -42,7 +42,7 @@ int read_xi2c_frame (int chn); ...@@ -42,7 +42,7 @@ int read_xi2c_frame (int chn);
int i2c_page_alloc (int chn); int i2c_page_alloc (int chn);
int i2c_page_register(int chn, int page); int i2c_page_register(int chn, int page);
void i2c_page_free (int chn, int page); void i2c_page_free (int chn, int page);
x393_i2c_device_t * xi2c_dev_get(const char * name); //x393_i2c_device_t * xi2c_dev_get(const char * name);
void set_xi2c_raw (int chn, int page, u32 data); void set_xi2c_raw (int chn, int page, u32 data);
void set_xi2c_wr (int chn,int page, int sa7, int rah, int num_bytes, int bit_delay); void set_xi2c_wr (int chn,int page, int sa7, int rah, int num_bytes, int bit_delay);
void set_xi2c_wrc (x393_i2c_device_t * dc, int chn, int page, int rah); void set_xi2c_wrc (x393_i2c_device_t * dc, int chn, int page, int rah);
...@@ -60,5 +60,13 @@ int read_xi2c_fifo (int chn); ...@@ -60,5 +60,13 @@ int read_xi2c_fifo (int chn);
x393_i2c_device_t * xi2c_dev_get(const char * name); x393_i2c_device_t * xi2c_dev_get(const char * name);
int x393_xi2c_write_reg(const char * cname, int chn, int sa7_offs, int reg_addr, int data); int x393_xi2c_write_reg(const char * cname, int chn, int sa7_offs, int reg_addr, int data);
int x393_xi2c_read_reg (const char * cname, int chn, int sa7_offs, int reg_addr, int * datap); int x393_xi2c_read_reg (const char * cname, int chn, int sa7_offs, int reg_addr, int * datap);
int x393_xi2c_ready_wr(int chn);
int x393_xi2c_wait_wr(int chn);
int legacy_read_i2c_reg(int chn, int page, int sa7, int reg_addr, int len, int * datap); int legacy_read_i2c_reg(int chn, int page, int sa7, int reg_addr, int len, int * datap);
int i2c_get_max_unbalanced_writes(void);
void reset_unbalanced_writes(int chn);
void inc_unbalanced_writes(int chn);
int check_unbalanced_writes(int chn);
int get_unbalanced_writes(int chn);
#endif #endif
...@@ -213,7 +213,7 @@ int setup_compressor_memory (int num_sensor, ///< sensor port number (0..3 ...@@ -213,7 +213,7 @@ int setup_compressor_memory (int num_sensor, ///< sensor port number (0..3
int frame_full_width = buffer_settings.frame_full_width[num_sensor] >> 4; int frame_full_width = buffer_settings.frame_full_width[num_sensor] >> 4;
int frame_sa_inc = frame_full_width * (buffer_settings.frame_height[num_sensor] >>3); int frame_sa_inc = frame_full_width * (buffer_settings.frame_height[num_sensor] >>3);
int last_frame_num = buffer_settings.frames_in_buffer[num_sensor] - 1; int last_frame_num = buffer_settings.frames_in_buffer[num_sensor] - 1;
int byte32 = 1; ///< 1 - 32-byte columns (currently used), 0 - 16 byte columns // int byte32 = 1; ///< 1 - 32-byte columns (currently used), 0 - 16 byte columns
x393_mcntrl_window_frame_sa_t window_frame_sa = {.d32=0}; x393_mcntrl_window_frame_sa_t window_frame_sa = {.d32=0};
x393_mcntrl_window_frame_sa_inc_t window_frame_sa_inc = {.d32=0}; x393_mcntrl_window_frame_sa_inc_t window_frame_sa_inc = {.d32=0};
...@@ -554,7 +554,7 @@ static int videomem_probe(struct platform_device *pdev) ...@@ -554,7 +554,7 @@ static int videomem_probe(struct platform_device *pdev)
int res; int res;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
const struct of_device_id *match; const struct of_device_id *match;
const __be32 *bufsize_be; // const __be32 *bufsize_be;
struct device_node *node; struct device_node *node;
elphel393_videomem_sysfs_register(pdev); elphel393_videomem_sysfs_register(pdev);
......
...@@ -303,7 +303,9 @@ ...@@ -303,7 +303,9 @@
<li> bit 0 - "old" external mode (0 - internal, 1 - external ) <li> bit 0 - "old" external mode (0 - internal, 1 - external )
<li> bit 1 - enable(1) or disable(0) external trigger to stop clip <li> bit 1 - enable(1) or disable(0) external trigger to stop clip
<li> bit 2 - async (snapshot, ext trigger) mode, 0 - continuous NOTE: Only this bit is used now <li> bit 2 - async (snapshot, ext trigger) mode, 0 - continuous NOTE: Only this bit is used now
<li> bit 3 - no overlap, single frames: program - acquire/compress same frame</ul>*/ <li> bit 3 - no overlap, single frames: program - acquire/compress same frame
<li> bit 4 - global reset release (GRR) mode - (only when combined with bit 2)
</ul>*/
#define P_BGFRAME 16 ///< Background measurement mode - will use 16-bit mode and no FPN correction #define P_BGFRAME 16 ///< Background measurement mode - will use 16-bit mode and no FPN correction
//#define P_IMGSZMEM 17 ///< image size in video memory (calculated when channel 0 is programmed) NC393: Not used ??? //#define P_IMGSZMEM 17 ///< image size in video memory (calculated when channel 0 is programmed) NC393: Not used ???
//#define P_COMP_BAYER 17 ///< -> 119 derivative, readonly - calculated from P_BAYER and COMPMOD_BYRSH to separate sensor and compressor channels //#define P_COMP_BAYER 17 ///< -> 119 derivative, readonly - calculated from P_BAYER and COMPMOD_BYRSH to separate sensor and compressor channels
......
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