Commit 8b4b7b64 authored by Andrey Filippov's avatar Andrey Filippov

debugging with 10359 multiplexer (Eyesis mode)

parent 11d96e51
......@@ -262,11 +262,14 @@
elphel393_sensor_i2c: elphel393-sensor-i2c@0 {
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) */
elphel393-sensor-i2c,i2c_devices = "mt9f002 0x10 2 2 500",
"mt9p006 0x48 1 2 500",
"el10359 0x08 1 2 500",
elphel393-sensor-i2c,i2c_devices = "mt9f002 0x10 2 2 500",
"mt9p006 0x48 1 2 500",
"el10359 0x08 1 2 500",
"el10359_32 0x08 1 4 500",
"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 {
......@@ -285,6 +288,10 @@
compatible = "elphel,elphel393-mt9x001-1.00";
};
elphel393_clock10359:elphel393-clock10359@0{
compatible = "elphel,elphel393_clock10359-1.00";
};
klogger_393: klogger-393@0 {
compatible = "elphel,klogger-393-1.00";
klogger-393,buffer_size = <1048576>;
......
......@@ -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);
int divmn, divmx, err1,err, div,q,qmn,qmx,qmx1,fdv,p, e,fdvq;
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
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) {
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;
}
if (f <=0 ) {
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;
}
divmx=CY22393_PLLMAX/f; if (divmx > 127) divmx=127; // could not be <1
divmn=CY22393_PLLMIN/f; if (divmn < 1) divmn=1;
if (divmn >127) {
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;
}
err1=f;
......@@ -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;
qmx=fpmx/fdv-2; if (qmx >255) qmx=255;
// 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;
else if ((qmn*div) < qmx1) qmn=qmx1/div;
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
pars->dv=div;
err1=e/q/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) {
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,
pars->dv,
(pars->p+6),
......@@ -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,
pars->dv,
(pars->p+6),
......@@ -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 error;
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
sensor_port, // sensor port number
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) {
sensor_port, reg_addr, mask, value);
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;
if ((error = x393_xi2c_write_reg(CLOCK_NAME, // device class name
sensor_port, // sensor port number
......@@ -179,24 +181,45 @@ int setCYField (int sensor_port, int reg_addr, int mask, int value) {
}
int x393_getClockFreq(int sensor_port, int nclock) {
if ((sensor_port < 0) || (sensor_port > 3) || (nclock < 0) || (nclock > 3))return -EINVAL; // bad clock number
else {
return clock_frequency[(sensor_port << 2) || nclock];
}
if ((sensor_port < 0) || (sensor_port > 3) || (nclock < 0) || (nclock > 3))return -EINVAL; // bad clock number
else {
dev_dbg(sdev, "clock_frequency[%d]\n",(sensor_port << 2) + nclock);
return clock_frequency[(sensor_port << 2) + nclock];
}
}
EXPORT_SYMBOL_GPL(x393_getClockFreq);
int x393_setClockFreq(int sensor_port, int nclock, int freq)
{ // freq now in Hz
int err=0;
int i,bp,bq,bdiv,pllc,fact;
t_pll_params pll_params;
sensor_port &= 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
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 ( (i=calc_pll_params (freq, &pll_params)) !=0) {
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)
break;
case 3:
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;
} else {
// 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)
return err;
}
clock_frequency[(sensor_port << 2) + nclock] = fact;
dev_dbg(sdev, "clock_frequency[%d]\n",(sensor_port << 2) + nclock);
return fact;
}
EXPORT_SYMBOL_GPL(x393_setClockFreq);
......@@ -400,7 +424,7 @@ static void elphel393_clock10359_init_of(struct platform_device *pdev)
static int elphel393_clock10359_probe(struct platform_device *pdev)
{
sdev =&pdev->dev;
dev_dbg(&pdev->dev,"Probing elphel_clock10359\n");
dev_info(&pdev->dev,"Probing elphel_clock10359\n");
elphel393_clock10359_sysfs_register(pdev);
dev_dbg(&pdev->dev,"elphel393_clock10359_sysfs_register() done\n");
......
......@@ -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)
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 binning_cost = 0;
int width,i;
......
This diff is collapsed.
......@@ -51,7 +51,7 @@
//#define I2C359_I2CMUX 0x07
// #define I2C359_I2CMUX_2MEM 0x1
// #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_LOCAL 0x01 ///< clock source: local (clock generator on the 10359 board
#define I2C359_MODE 0x09 ///< register address: mode register
......
......@@ -1096,6 +1096,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
}
// dh (decimation changed)?
dh = thispars->pars[P_DCM_HOR];
dh = dh?dh:1;
if (FRAMEPAR_MODIFIED(P_DCM_HOR)) {
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)
......@@ -1103,6 +1104,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
}
// dv (decimation changed)?
dv = thispars->pars[P_DCM_VERT];
dv = dv?dv:1;
if (FRAMEPAR_MODIFIED(P_DCM_VERT)) {
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)
......@@ -1110,6 +1112,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
}
// bh (binning changed)?
bh = thispars->pars[P_BIN_HOR];
dv = dv?dv:1;
if (FRAMEPAR_MODIFIED(P_BIN_HOR)) {
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)
......@@ -1117,6 +1120,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
}
// bv (binning changed)?
bv = thispars->pars[P_BIN_VERT];
bv = bv?bv:1;
if (FRAMEPAR_MODIFIED(P_BIN_VERT)) {
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)
......
......@@ -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)) {
i2c_page_alloc_init(sensor_port); // reset all pages allocation
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);
for (subchn = 0; subchn <4; subchn++){ // subchn == 0 - broadcast
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);
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
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);
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);
dev_sensor.data_bytes=4; // for reading 10359 in 32-bit mode
set_xi2c_rdc(&dev_sensor, sensor_port, LEGACY_READ_PAGE4);
......
This diff is collapsed.
......@@ -42,7 +42,7 @@ int read_xi2c_frame (int chn);
int i2c_page_alloc (int chn);
int i2c_page_register(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_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);
......@@ -60,5 +60,13 @@ int read_xi2c_fifo (int chn);
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_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 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
......@@ -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_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 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_inc_t window_frame_sa_inc = {.d32=0};
......@@ -554,7 +554,7 @@ static int videomem_probe(struct platform_device *pdev)
int res;
struct device *dev = &pdev->dev;
const struct of_device_id *match;
const __be32 *bufsize_be;
// const __be32 *bufsize_be;
struct device_node *node;
elphel393_videomem_sysfs_register(pdev);
......
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