Commit 81559b1f authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

changes for mux and mux broadcast address

parent e5bb1292
......@@ -45,10 +45,10 @@ struct sensor_port_config_t *pSensorPortConfig;
// removed static to export
static struct sensor_port_config_t sensorPortConfig[] = {
{.mux=SENSOR_NONE,.sensor={SENSOR_NONE,SENSOR_NONE,SENSOR_NONE,SENSOR_NONE}},
{.mux=SENSOR_NONE,.sensor={SENSOR_NONE,SENSOR_NONE,SENSOR_NONE,SENSOR_NONE}},
{.mux=SENSOR_NONE,.sensor={SENSOR_NONE,SENSOR_NONE,SENSOR_NONE,SENSOR_NONE}},
{.mux=SENSOR_NONE,.sensor={SENSOR_NONE,SENSOR_NONE,SENSOR_NONE,SENSOR_NONE}}
{.mux=SENSOR_NONE,.broadcast_addr=0,.sensor={SENSOR_NONE,SENSOR_NONE,SENSOR_NONE,SENSOR_NONE}},
{.mux=SENSOR_NONE,.broadcast_addr=0,.sensor={SENSOR_NONE,SENSOR_NONE,SENSOR_NONE,SENSOR_NONE}},
{.mux=SENSOR_NONE,.broadcast_addr=0,.sensor={SENSOR_NONE,SENSOR_NONE,SENSOR_NONE,SENSOR_NONE}},
{.mux=SENSOR_NONE,.broadcast_addr=0,.sensor={SENSOR_NONE,SENSOR_NONE,SENSOR_NONE,SENSOR_NONE}}
};
static const struct of_device_id elphel393_detect_sensors_of_match[];
......@@ -126,6 +126,11 @@ sens_iface_t get_iface_by_code(int code, ///< sensor code
return NONE;
}
/** Get sensor port multiplexer type */
int set_broadcast_address(int port,int value){
sensorPortConfig[port & 3].broadcast_addr = value;
return 0;
}
/** Get sensor port multiplexer type */
int get_detected_mux_code(int port) ///< Sensor port number (0..3)
......@@ -398,7 +403,7 @@ static int elphel393_detect_sensors_sysfs_register(struct platform_device *pdev)
* @param table - pointer to the global struct
* @return 0
*/
static int par2addr_fill(const unsigned short *par2addr, u16 *table){
static int par2addr_fill(const unsigned short *par2addr, u32 *table){
int i=0;
......@@ -407,7 +412,7 @@ static int par2addr_fill(const unsigned short *par2addr, u16 *table){
// reset
for(i=0;i<MAX_SENSOR_REGS;i++){
table[i] = 0;
table[i] = 0xffffffff;
}
i=0;
......
......@@ -25,11 +25,18 @@
#define MAX_SENSOR_REGS 256
#define MAX_FPGA_RECS 256
#define MUX_BROADCAST_INDEX 3
struct sensor_port_config_t {
u32 mux; ///< Sensor multiplexer, currently 0 (SENSOR_DETECT, SENSOR_MUX_10359 or SENSOR_NONE)
u32 broadcast_addr; ///< For MUX: broadcast address for connected sensors, for single sensor it's 0, for mux: 3
u32 sensor[MAX_SENSORS]; ///< Without mux only [0] is used, with 10359 - 0..2 are used (i2c addressing is shifted so 0 is broadcast)
u16 par2addr[MAX_SENSORS][MAX_SENSOR_REGS]; ///< Big LUT. SENSOR_REGSxxx par to sensor reg 'yyy' internal address: haddr+laddr for 16 bit
u8 haddr2rec[MAX_SENSORS][MAX_FPGA_RECS]; ///< Big LUT (but almost empty). Sensor's page address (haddr of reg addr) to fpga i2c record number (fpga line#)
//u16 par2addr[MAX_SENSORS][MAX_SENSOR_REGS]; ///< Big LUT. SENSOR_REGSxxx par to sensor reg 'yyy' internal address: haddr+laddr for 16 bit
// u32 for error handling
u32 par2addr[MAX_SENSORS][MAX_SENSOR_REGS]; ///< Big LUT. SENSOR_REGSxxx par to sensor reg 'yyy' internal address: haddr+laddr for 16 bit
//u8 haddr2rec[MAX_SENSORS][MAX_FPGA_RECS]; ///< Big LUT (but almost empty). Sensor's page address (haddr of reg addr) to fpga i2c record number (fpga line#)
// u32 is for error handling
u32 haddr2rec[MAX_SENSORS][MAX_FPGA_RECS]; ///< Big LUT (but almost empty). Sensor's page address (haddr of reg addr) to fpga i2c record number (fpga line#)
unsigned short *pages_ptr[MAX_SENSORS];
};
......@@ -42,6 +49,7 @@ const char * get_name_by_code(int code, int type);
sens_iface_t get_iface_by_code(int code, int type);
int get_detected_mux_code(int port);
int set_broadcast_address(int port,int value);
int get_detected_sensor_code(int port, int sub_chn);
int get_subchannels(int port);
int set_detected_mux_code(int port, int mux_type);
......
This diff is collapsed.
......@@ -14,10 +14,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef _MT9F002_H
#define _MT9F002_H
#define MT9F002_PARTID 0x2E01 ///< MT9F002 PartID register value
#define MT9F002_I2C_ADDR 0x10 ///< MT9P I2C slave address (7 bit)
#define MT9F002_RESET_REGISTER_VALUE 0x001c
// number of lines to sacrifice before generating Frame Valid
#define MT9F002_VACT_DELAY 2
/* ON Semi MT9F002 i2c register addresses */
......@@ -556,6 +561,13 @@
#define P_MT9F002_ANALOG_GAIN_CODE_BLUE 18
#define P_MT9F002_COARSE_INTEGRATION_TIME 19
#define P_MT9F002_Y_ADDR_START 20
#define P_MT9F002_Y_ADDR_END 21
#define P_MT9F002_X_ADDR_START 22
#define P_MT9F002_X_ADDR_END 23
#define P_MT9F002_READ_MODE 24
//#define P_REG(x) x
//#define P_MT9F002_MODEL_ID 4
......@@ -586,3 +598,5 @@ int mt9f002_pgm_detectsensor (int sensor_port, ///< sensor port
///< @return 0 - OK, negative - error
;
void mt9f002_set_device(struct device *dev);
#endif
......@@ -1044,7 +1044,7 @@ int mt9x001_pgm_initsensor (int sensor_port, ///< sensor port
/** Program sensor WOI and mirroring
* Validating, changing related parameters/scheduling actions, scheduling i2c commands
* As different sensors may produce "bad frames" for differnt WOI changes (i.e. MT9P001 seems to do fine with FLIP, but not WOI_WIDTH)
* As different sensors may produce "bad frames" for different WOI changes (i.e. MT9P001 seems to do fine with FLIP, but not WOI_WIDTH)
* pgm_window and pgm_window_safe will do the same - they will just be called with different latencies and with compressor stopped)*/
int mt9x001_pgm_window (int sensor_port, ///< sensor port number (0..3)
struct sensor_t * sensor, ///< sensor static parameters (capabilities)
......
......@@ -404,6 +404,9 @@ int pgm_detectsensor (int sensor_port, ///< sensor port number (
GLOBALPARS(sensor_port, G_SUBCHANNELS) = get_subchannels(sensor_port);
mux = get_detected_mux_code(sensor_port); // none/detect/10359
// set broadcast address here, default is 0 for no-mux, MUX_BROADCAST_INDEX is for mux
if (mux != SENSOR_NONE) set_broadcast_address(sensor_port,MUX_BROADCAST_INDEX);
dev_dbg(g_dev_ptr,"port = %d, mux = %d, sens= %d\n",sensor_port, mux, sens);
//if ((mux == SENSOR_NONE) && (thispars->pars[P_SENSOR] == SENSOR_NONE))
......@@ -744,7 +747,7 @@ int pgm_afterinit (int sensor_port, ///< sensor port number (
SETFRAMEPARS_UPDATE_SET(P_BIN_HOR | FRAMEPAIR_FORCE_NEW, 1);
SETFRAMEPARS_UPDATE_SET(P_BIN_VERT | FRAMEPAIR_FORCE_NEW, 1);
// Set analog gains to 1.0 if not set otherwise
// FIXME: Without those 3 lines it is not initialaized (or immediately reset) from the parameters in autocampars.xml. GAING=0x10000, all the rest - 0
// FIXME: Without those 3 lines it is not initialized (or immediately reset) from the parameters in autocampars.xml. GAING=0x10000, all the rest - 0
/*
if (!(GLOBALPARS(G_DEBUG) & (1 <<28))) { // debugging here ! ***********************************
SETFRAMEPARS_UPDATE_SET(P_GAINR | FRAMEPAIR_FORCE_NEW, 0x20000); ///gain ==1.0
......@@ -1043,12 +1046,12 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
}
// flips changed?
if (FRAMEPAR_MODIFIED(P_FLIPH)) {
if (unlikely((thispars->pars[P_FLIPH] & sensor->flips & 1)!=thispars->pars[P_FLIPH])) { // remove unsupoported flips
if (unlikely((thispars->pars[P_FLIPH] & sensor->flips & 1)!=thispars->pars[P_FLIPH])) { // remove unsupported flips
SETFRAMEPARS_SET(P_FLIPH, (thispars->pars[P_FLIPH] & sensor->flips & 1));
}
}
if (FRAMEPAR_MODIFIED(P_FLIPV)) {
if (unlikely((thispars->pars[P_FLIPV] & (sensor->flips>>1) & 1)!=thispars->pars[P_FLIPV])) { // remove unsupoported flips
if (unlikely((thispars->pars[P_FLIPV] & (sensor->flips>>1) & 1)!=thispars->pars[P_FLIPV])) { // remove unsupported flips
SETFRAMEPARS_SET(P_FLIPV, (thispars->pars[P_FLIPV] & (sensor->flips >> 1 ) & 1));
}
}
......@@ -1432,7 +1435,6 @@ int pgm_triggermode(int sensor_port, ///< sensor port number (0..3
/** Program sensor input in FPGA (Bayer, 8/16 bits, FPN, test mode, number of lines).
* TODO: implement for 393 (program_sensor())
*/
int pgm_sensorin (int sensor_port, ///< sensor port number (0..3)
struct sensor_t * sensor, ///< sensor static parameters (capabilities)
struct framepars_t * thispars, ///< sensor current parameters
......@@ -1490,10 +1492,12 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
sensio_width.sensor_width = thispars->pars[P_ACTUAL_WIDTH]+(2 * margins);
}
// fix for MT9F002
/*
// fix for MT9F002 (moved to the sensor driver)
if ((sens & SENSOR_MASK) == SENSOR_MT9F002){
sensio_width.sensor_width = 2;
sensio_width.sensor_width = MT9F002_VACT_DELAY;
}
*/
X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_width, sensio_width);
......
This diff is collapsed.
......@@ -1147,7 +1147,7 @@ int image_acq_stop(struct platform_device *pdev)
}
/**
* Register i2c pages equal to slave address
* Register i2c pages
* @param port
* @param sub_chn
* @param i2c_dev
......@@ -1161,13 +1161,14 @@ int fpga_register_i2c_pages(int port, int sub_chn, x393_i2c_device_t i2c_dev){
int haddr;
u16 *table = pSensorPortConfig[port].pages_ptr[sub_chn];
u8 *h2r = pSensorPortConfig[port].haddr2rec[sub_chn];
u32 *h2r = pSensorPortConfig[port].haddr2rec[sub_chn];
bool used_page[256];
bool used_haddr[256];
// init
for(i=0;i<256;i++){
used_page[i] = false;
used_haddr[i] = false;
h2r[i] = 0xffffffff;
}
// loop through pages table
......@@ -1183,8 +1184,8 @@ int fpga_register_i2c_pages(int port, int sub_chn, x393_i2c_device_t i2c_dev){
break;
}
if(!used_page[haddr]){
used_page[haddr] = true;
if(!used_haddr[haddr]){
used_haddr[haddr] = true;
line_num = i2c_page_alloc(port);
if (line_num<0){
......
......@@ -110,9 +110,26 @@ long long get_frame_pos(unsigned int chn, unsigned int pos);
* @param reg sensor register address (8-bit)
* @param data value to set (16 bits) */
#define X3X3_I2C_SEND2(port,frame,sa7,reg,data) {\
int _ADDR = pSensorPortConfig[(port)].par2addr[0][(reg)];\
int _PAGE = pSensorPortConfig[(port)].haddr2rec[0][(_ADDR>>8)&0xff];\
write_xi2c_reg16_abs_asap((port),_PAGE,(frame),_ADDR&0xff,(data));\
write_xi2c_reg16_abs_asap((port),(sa7),(frame),(reg),(data));\
}
/** Perform I2C write (8 bits address, 16 bits data in "legacy" mode,
* pages matching slave address should be registered.
*
* TODO: Add registering single sensors as in multi10359. Registering twice is OK.
* Slave address is now 7-bit,old was 8-bit, change (10359 already done)
* @param port - sensor port
* @param frame Frame number to apply, <0 - ASAP
* @param si - slave device index (for mux board)
* @param reg sensor register address (16-bit)
* @param data value to set (16 bits) */
//int _ADDR = pSensorPortConfig[(port)].par2addr[si][(reg)];
#define X3X3_I2C_SEND2_LUT(port,frame,si,reg,data) {\
int _PAGE = pSensorPortConfig[(port)].haddr2rec[(si)][((reg)>>8)&0xff];\
BUG_ON(!(_PAGE&0xffffff00));\
write_xi2c_reg16_abs_asap((port),_PAGE,(frame),(reg)&0xff,(data));\
}
/** Perform I2C write in immediate mode (8 bits address, 16 bits data in "legacy" mode,
......@@ -129,6 +146,22 @@ long long get_frame_pos(unsigned int chn, unsigned int pos);
write_xi2c_reg16((port),_PAGE,_ADDR&0xff,(data));\
}
/** Perform I2C write in immediate mode (8 bits address, 16 bits data in "legacy" mode,
* pages matching slave address should be registered.
*
* Slave address is now 7-bit,old was 8-bit, change (10359 already done)
* @param port - sensor port
* @param si - slave device index (for mux board)
* @param reg sensor register address (8-bit)
* @param data value to set (16 bits) */
#define X3X3_I2C_SEND2_LUT_ASAP(port,si,reg,data) {\
int _PAGE = pSensorPortConfig[(port)].haddr2rec[(si)][((reg)>>8)&0xff];\
BUG_ON(!(_PAGE&0xffffff00));\
write_xi2c_reg16((port),_PAGE,(reg)&0xff,(data));\
}
/** Perform I2C read (8 bits address, 16 bits data in "legacy" mode (sensors and 10359),
* page LEGACY_READ_PAGE2 (==0xff) should be registered - legacy_i2c.
*
......
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