Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
linux-elphel
Commits
35f01d22
Commit
35f01d22
authored
Jul 25, 2016
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating multi10359, documenting
parent
a9dd5e60
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
2303 additions
and
14 deletions
+2303
-14
clock10359.c
src/drivers/elphel/clock10359.c
+1
-1
framepars.c
src/drivers/elphel/framepars.c
+1
-1
multi10359.c
src/drivers/elphel/multi10359.c
+2035
-1
multi10359.h
src/drivers/elphel/multi10359.h
+139
-1
sensor_i2c.c
src/drivers/elphel/sensor_i2c.c
+67
-0
sensor_i2c.h
src/drivers/elphel/sensor_i2c.h
+41
-1
c313a.h
src/include/elphel/c313a.h
+19
-9
No files found.
src/drivers/elphel/clock10359.c
View file @
35f01d22
...
@@ -75,7 +75,6 @@ typedef struct {
...
@@ -75,7 +75,6 @@ typedef struct {
int
calc_pll_params
(
unsigned
int
f
,
t_pll_params
*
pars
);
// f -in Hz
int
calc_pll_params
(
unsigned
int
f
,
t_pll_params
*
pars
);
// f -in Hz
int
setCYField
(
int
sensor_port
,
int
addr
,
int
mask
,
int
value
);
/// bus==1 - FPGA (sensor bus through 10359), 0 - CPU bus
int
setCYField
(
int
sensor_port
,
int
addr
,
int
mask
,
int
value
);
/// bus==1 - FPGA (sensor bus through 10359), 0 - CPU bus
int
setClockFreq
(
int
nclock
,
int
freq
);
// freq now in Hz
int
calc_pll_params
(
unsigned
int
f
,
t_pll_params
*
pars
)
{
// f -in Hz
int
calc_pll_params
(
unsigned
int
f
,
t_pll_params
*
pars
)
{
// f -in Hz
// t_pll_params pars;
// t_pll_params pars;
...
@@ -176,6 +175,7 @@ int setCYField (int sensor_port, int reg_addr, int mask, int value) {
...
@@ -176,6 +175,7 @@ int setCYField (int sensor_port, int reg_addr, int mask, int value) {
sensor_port
,
reg_addr
,
mask
,
value
,
reg_data
);
sensor_port
,
reg_addr
,
mask
,
value
,
reg_data
);
return
error
;
return
error
;
}
}
return
0
;
}
}
int
x393_getClockFreq
(
int
sensor_port
,
int
nclock
)
{
int
x393_getClockFreq
(
int
sensor_port
,
int
nclock
)
{
...
...
src/drivers/elphel/framepars.c
View file @
35f01d22
...
@@ -115,7 +115,7 @@
...
@@ -115,7 +115,7 @@
#endif
#endif
/**
/**
*
\def FRAMEPARS_DRIVER_NAME
driver name to display
* driver name to display
*/
*/
#define FRAMEPARS_DRIVER_NAME "Elphel (R) Model 393 Frame Parameters device driver"
#define FRAMEPARS_DRIVER_NAME "Elphel (R) Model 393 Frame Parameters device driver"
...
...
src/drivers/elphel/multi10359.c
View file @
35f01d22
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/drivers/elphel/multi10359.h
View file @
35f01d22
This diff is collapsed.
Click to expand it.
src/drivers/elphel/sensor_i2c.c
View file @
35f01d22
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include "x393.h"
#include "x393.h"
#include "sensor_i2c.h"
#include "sensor_i2c.h"
#include <elphel/c313a.h> // PARS_FRAMES_MASK
//------------------
//------------------
...
@@ -85,8 +86,10 @@ void i2c_page_alloc_init(void)
...
@@ -85,8 +86,10 @@ void i2c_page_alloc_init(void)
for
(
i
=
0
;
i
<
sizeof
(
sysfs_page
)
/
sizeof
(
sysfs_page
[
0
]);
i
++
)
sysfs_page
[
i
]
=
-
1
;
for
(
i
=
0
;
i
<
sizeof
(
sysfs_page
)
/
sizeof
(
sysfs_page
[
0
]);
i
++
)
sysfs_page
[
i
]
=
-
1
;
}
}
/** Reserve i2c page (1 of 256) for a sensor port
/** Reserve i2c page (1 of 256) for a sensor port
* @param chn sensor port number (0..3)
* @param chn sensor port number (0..3)
* @return allocated page number or -ENOMEM if all pages are already used
*/
*/
int
i2c_page_alloc
(
int
chn
)
int
i2c_page_alloc
(
int
chn
)
{
{
...
@@ -109,6 +112,31 @@ int i2c_page_alloc(int chn)
...
@@ -109,6 +112,31 @@ int i2c_page_alloc(int chn)
}
}
EXPORT_SYMBOL_GPL
(
i2c_page_alloc
);
EXPORT_SYMBOL_GPL
(
i2c_page_alloc
);
/** Register specific page, can be used with legacy software to register page equal to slave address,
* and use 0xff for reading. Works with 1byhte addresses and 16-bit data */
int
i2c_page_register
(
int
chn
,
///< Sensor port
int
page
)
///< page to register (for legacy software, use 7-bit slave address
///< @return 0 on success, -ENOMEM if page is already registered
{
int
g
=
page
>>
5
;
int
b
=
page
&
0x1f
;
u32
*
fb
=
free_i2c_pages
+
((
chn
<<
3
)
+
g
);
spin_lock
(
&
lock
);
if
(
unlikely
(
!
(
*
fb
&
(
1
<<
(
31
-
b
)))))
{
spin_unlock
(
&
lock
);
return
-
ENOMEM
;
// page is already registered
}
*
fb
&=
(
1
<<
(
31
-
b
));
if
(
unlikely
(
*
fb
==
0
)){
free_i2c_groups
[
chn
]
&=
~
(
1
<<
(
31
-
g
));
}
spin_unlock
(
&
lock
);
return
0
;
}
EXPORT_SYMBOL_GPL
(
i2c_page_register
);
/** Free i2c page
/** Free i2c page
* @param chn sensor port number (0..3)
* @param chn sensor port number (0..3)
* @param page i2c configuration page to release
* @param page i2c configuration page to release
...
@@ -355,6 +383,45 @@ void write_xi2c_reg16 (int chn, ///< sensor port
...
@@ -355,6 +383,45 @@ void write_xi2c_reg16 (int chn, ///< sensor port
}
}
EXPORT_SYMBOL_GPL
(
write_xi2c_reg16
);
EXPORT_SYMBOL_GPL
(
write_xi2c_reg16
);
/** Write sensor 16 bit (or 8 bit as programmed in the table) data in immediate mode */
void
write_xi2c_reg16_rel
(
int
chn
,
///< sensor port
int
page
,
///< index in the table (8 bits)
int
frame
,
///< relative frame number modulo PARS_FRAMES
int
addr
,
///< low byte of the register address (high is in the table), 8 bits
u32
data
)
///< 16 or 8-bit data (LSB aligned)
{
u32
dw
=
((
page
&
0xff
)
<<
24
)
|
((
addr
&
0xff
)
<<
16
)
|
(
data
&
0xffff
);
x393_sensi2c_rel
(
dw
,
chn
,
frame
&
PARS_FRAMES_MASK
);
}
EXPORT_SYMBOL_GPL
(
write_xi2c_reg16_rel
);
/** Write sensor 16 bit (or 8 bit as programmed in the table) data in immediate mode */
void
write_xi2c_reg16_abs
(
int
chn
,
///< sensor port
int
page
,
///< index in the table (8 bits)
int
frame
,
///< absolute frame number modulo PARS_FRAMES
int
addr
,
///< low byte of the register address (high is in the table), 8 bits
u32
data
)
///< 16 or 8-bit data (LSB aligned)
{
u32
dw
=
((
page
&
0xff
)
<<
24
)
|
((
addr
&
0xff
)
<<
16
)
|
(
data
&
0xffff
);
x393_sensi2c_abs
(
dw
,
chn
,
frame
&
PARS_FRAMES_MASK
);
}
EXPORT_SYMBOL_GPL
(
write_xi2c_reg16_abs
);
/** Compatibility with the legacy code: frame <0 - ASAP, >=0 - absolute
* Write sensor 16 bit (or 8 bit as programmed in the table) data in immediate mode */
void
write_xi2c_reg16_abs_asap
(
int
chn
,
///< sensor port
int
page
,
///< index in the table (8 bits)
int
frame
,
///< absolute frame number modulo PARS_FRAMES
int
addr
,
///< low byte of the register address (high is in the table), 8 bits
u32
data
)
///< 16 or 8-bit data (LSB aligned)
{
u32
dw
=
((
page
&
0xff
)
<<
24
)
|
((
addr
&
0xff
)
<<
16
)
|
(
data
&
0xffff
);
if
(
frame
<
0
)
x393_sensi2c_abs
(
dw
,
chn
,
0
);
else
x393_sensi2c_abs
(
dw
,
chn
,
frame
&
PARS_FRAMES_MASK
);
}
EXPORT_SYMBOL_GPL
(
write_xi2c_reg16_abs
);
/** Initiate sensor i2c read in immediate mode (data itself has to be read from FIFO with read_xi2c_fifo)
/** Initiate sensor i2c read in immediate mode (data itself has to be read from FIFO with read_xi2c_fifo)
* Use slave address from provided class structure.
* Use slave address from provided class structure.
*/
*/
...
...
src/drivers/elphel/sensor_i2c.h
View file @
35f01d22
...
@@ -14,7 +14,8 @@
...
@@ -14,7 +14,8 @@
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
*******************************************************************************/
#ifndef SENSOR_I2C.H
#define SENSOR_I2C.H
/** I2C device description to be used with i2c sequencer*/
/** I2C device description to be used with i2c sequencer*/
typedef
struct
{
typedef
struct
{
char
name
[
32
];
///< Device class name (up to 31 characters)
char
name
[
32
];
///< Device class name (up to 31 characters)
...
@@ -29,14 +30,30 @@ typedef struct{
...
@@ -29,14 +30,30 @@ typedef struct{
* @param chn sensor port number (0..3) */
* @param chn sensor port number (0..3) */
int
i2c_page_alloc
(
int
chn
);
int
i2c_page_alloc
(
int
chn
);
/* Register specific page, can be used with legacy software to register page equal to slave address,
* and use 0xff for reading. Works with 1byhte addresses and 16-bit data */
int
i2c_page_register
(
int
chn
,
// Sensor port
int
page
);
// page to register (for legacy software, use 7-bit slave address
// @return 0 on success, -ENOMEM if page is already registered
/* Free i2c page */
/* Free i2c page */
void
i2c_page_free
(
int
chn
,
int
page
);
void
i2c_page_free
(
int
chn
,
int
page
);
/* Find device list entry by device class name */
x393_i2c_device_t
*
xi2c_dev_get
(
const
char
*
name
);
// Device class name as string
/* Set i2c table entry to raw data (will just overwrite tbl_mode = 2)*/
/* Set i2c table entry to raw data (will just overwrite tbl_mode = 2)*/
void
set_xi2c_raw
(
int
chn
,
void
set_xi2c_raw
(
int
chn
,
int
page
,
// index in lookup table
int
page
,
// index in lookup table
u32
data
);
// Bit delay - number of mclk periods in 1/4 of the SCL period
u32
data
);
// Bit delay - number of mclk periods in 1/4 of the SCL period
/* Set i2c table entry for write operation */
void
set_xi2c_wr
(
int
chn
,
// sensor port
int
page
,
// index in lookup table
int
sa7
,
// slave address (7 bit)
int
rah
,
// High byte of the i2c register address
int
num_bytes
,
// Number of bytes to write (1..10)
int
bit_delay
);
// Bit delay - number of mclk periods in 1/4 of the SCL period
/*
/*
* Set i2c table entry for write operation using known devices
* Set i2c table entry for write operation using known devices
* Get device with xi2c_dev_get(), copy and modify, if needed to
* Get device with xi2c_dev_get(), copy and modify, if needed to
...
@@ -78,6 +95,28 @@ void write_xi2c_reg16 (int chn,
...
@@ -78,6 +95,28 @@ void write_xi2c_reg16 (int chn,
int
addr
,
// low 8 bits
int
addr
,
// low 8 bits
u32
data
);
// 16 or 8-bit data (LSB aligned)
u32
data
);
// 16 or 8-bit data (LSB aligned)
/* Write sensor 16 bit (or 8 bit as programmed in the table) data in immediate mode */
void
write_xi2c_reg16_rel
(
int
chn
,
// sensor port
int
page
,
// index in the table (8 bits)
int
frame
,
// relative frame number modulo PARS_FRAMES
int
addr
,
// low byte of the register address (high is in the table), 8 bits
u32
data
);
///< 16 or 8-bit data (LSB aligned)
/* Write sensor 16 bit (or 8 bit as programmed in the table) data in immediate mode */
void
write_xi2c_reg16_abs
(
int
chn
,
// sensor port
int
page
,
// index in the table (8 bits)
int
frame
,
// absolute frame number modulo PARS_FRAMES
int
addr
,
// low byte of the register address (high is in the table), 8 bits
u32
data
);
//16 or 8-bit data (LSB aligned)
/* Compatibility with the legacy code: frame <0 - ASAP, >=0 - absolute
* Write sensor 16 bit (or 8 bit as programmed in the table) data in immediate mode */
void
write_xi2c_reg16_abs_asap
(
int
chn
,
// sensor port
int
page
,
// index in the table (8 bits)
int
frame
,
// absolute frame number modulo PARS_FRAMES
int
addr
,
// low byte of the register address (high is in the table), 8 bits
u32
data
);
// 16 or 8-bit data (LSB aligned)
/* Initiate sensor i2c read in immediate mode (data itself has to be read from FIFO with read_xi2c_fifo)
/* Initiate sensor i2c read in immediate mode (data itself has to be read from FIFO with read_xi2c_fifo)
* Use slave address from provided class structure. */
* Use slave address from provided class structure. */
void
read_xi2c
(
x393_i2c_device_t
*
dc
,
// device class
void
read_xi2c
(
x393_i2c_device_t
*
dc
,
// device class
...
@@ -110,3 +149,4 @@ int x393_xi2c_read_reg( const char * cname, // device class name
...
@@ -110,3 +149,4 @@ int x393_xi2c_read_reg( const char * cname, // device class name
int
sa7_offs
,
// slave address (7-bit) offset from the class defined slave address
int
sa7_offs
,
// slave address (7-bit) offset from the class defined slave address
int
reg_addr
,
// register address (width is defined by class)
int
reg_addr
,
// register address (width is defined by class)
int
*
datap
);
// pointer to a data receiver (read data width is defined by class)
int
*
datap
);
// pointer to a data receiver (read data width is defined by class)
#endif
src/include/elphel/c313a.h
View file @
35f01d22
...
@@ -71,8 +71,6 @@
...
@@ -71,8 +71,6 @@
//xi2craw_aux c 134 6
//xi2craw_aux c 134 6
//xi2cenable c 134 7
//xi2cenable c 134 7
#define FPGA_DCM_STEP 22 // ps/step
#define FPGA_DCM_RANGE 250 // maximal phase correction (+/-) ?
/* camera sequencer states */
/* camera sequencer states */
//Obsolete
//Obsolete
#define CAMSEQ_OFF 0 // off, not programmed (Video mode off on Zoran sensors)
#define CAMSEQ_OFF 0 // off, not programmed (Video mode off on Zoran sensors)
...
@@ -123,6 +121,10 @@
...
@@ -123,6 +121,10 @@
#endif
#endif
#define FPGA_DCM_STEP 22 // ps/step
#define FPGA_DCM_RANGE 250 // maximal phase correction (+/-) ?
/* supported ioctl _IOC_NR's */
/* supported ioctl _IOC_NR's */
#ifndef I2C_WRITEARG
#ifndef I2C_WRITEARG
#define I2C_WRITEARG(bus, slave, reg, value) (((bus) << 24) | ((slave) << 16) | ((reg) << 8) | (value))
#define I2C_WRITEARG(bus, slave, reg, value) (((bus) << 24) | ((slave) << 16) | ((reg) << 8) | (value))
...
@@ -593,15 +595,22 @@
...
@@ -593,15 +595,22 @@
#endif
#endif
#define P_MAX_PAR_ROUNDUP ROUND_UP (P_MAX_PAR , (PAGE_SIZE/8)) ///< half page in DWORDs
#define P_MAX_PAR_ROUNDUP ROUND_UP (P_MAX_PAR , (PAGE_SIZE/8)) ///< half page in DWORDs
#ifdef NC353 // to hide old code
#ifdef SAFE_CHECK
#ifdef SAFE_CHECK
#define MULTIREG(x,n) ((((n)>=0) && ((n)<MAX_SENSORS) && ((x) >0) && ((x) < P_MAX_PAR) && (multiSensIndex[x] > 0))? (multiSensIndex[x]+(n)) : 0)
#define MULTIREG(x,n) ((((n)>=0) && ((n)<MAX_SENSORS) && ((x) >0) && ((x) < P_MAX_PAR) && (multiSensIndex[x] > 0))? (multiSensIndex[x]+(n)) : 0)
#else
#else
#define MULTIREG(x,n) ((multiSensIndex[x] > 0)? (multiSensIndex[x]+(n)) : 0) // unsafe
#define MULTIREG(x,n) ((multiSensIndex[x] > 0)? (multiSensIndex[x]+(n)) : 0) // unsafe
#endif
#endif
#define MULTIRVRSREG(x) (multiSensRvrsIndex[x])
#define MULTIRVRSREG(x) (multiSensRvrsIndex[x])
#else
#ifdef SAFE_CHECK
#define MULTIREG(p,x,n) ((((n)>=0) && ((n)<MAX_SENSORS) && ((x) >0) && ((x) < P_MAX_PAR) && (amultiSensIndex[p][x] > 0))? (amultiSensIndex[p][x]+(n)) : 0)
#else
#define MULTIREG(p,x,n) ((amultiSensIndex[p][x] > 0)? (amultiSensIndex[p][x]+(n)) : 0) // unsafe
#endif
#define MULTIRVRSREG(p,x) (amultiSensRvrsIndex[p][x])
#endif
///amultiSensRvrsIndex
//#define P_MAX_PAR 511 /// maximal # of used parameter
//#define P_MAX_PAR 511 /// maximal # of used parameter
//#define P_MAX_GPAR 1023 // maximal # of global parameter
//#define P_MAX_GPAR 1023 // maximal # of global parameter
//#define P_MAX_GPAR 2047 /// maximal # of global parameter - TODO: change name to NUM_GPAR and make it 2048
//#define P_MAX_GPAR 2047 /// maximal # of global parameter - TODO: change name to NUM_GPAR and make it 2048
...
@@ -1603,10 +1612,11 @@ struct sensorproc_t {
...
@@ -1603,10 +1612,11 @@ struct sensorproc_t {
/// functions return <0 on error (and do nothing)
/// functions return <0 on error (and do nothing)
/// first 32 functions are called directly when appropriate bit is set, next 32 - sensor specific that are called
/// first 32 functions are called directly when appropriate bit is set, next 32 - sensor specific that are called
/// by corresponding one with (number-32) if not NULL. Sensor initilaization should set up those functions
/// by corresponding one with (number-32) if not NULL. Sensor initilaization should set up those functions
int
(
*
pgm_func
[
64
])
(
struct
sensor_t
*
sensor
,
/// pointer to sensor parameters
int
(
*
pgm_func
[
64
])
(
int
sensor_port
,
///< sensor port number (0..3)
struct
framepars_t
*
framepars
,
/// pointer to structure with array of current frame parameters
struct
sensor_t
*
sensor
,
///< pointer to sensor parameters
struct
framepars_t
*
prevpars
,
/// pointer to structure with array of previous frame parameters
struct
framepars_t
*
framepars
,
///< pointer to structure with array of current frame parameters
int
frame8
);
/// frame to program (latency applied), -1 - ASAP
struct
framepars_t
*
prevpars
,
///< pointer to structure with array of previous frame parameters
int
frame16
);
///< frame to program (latency applied), -1 - ASAP
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment