Commit 406266d1 authored by Andrey Filippov's avatar Andrey Filippov

just debugging

parent 9f42f3da
......@@ -706,7 +706,18 @@ loff_t circbuf_lseek(struct file *file, loff_t offset, int orig)
case LSEEK_CIRC_UTIME:
return get_rtc_usec();
break;
default:
// New in NC393 - separate comressor interrupts
case LSEEK_INTERRUPT_OFF: // disable camera interrupts
dev_dbg(g_dev_ptr, "LSEEK_INTERRUPT_OFF\n");
compressor_interrupts(0,chn);
break;
case LSEEK_INTERRUPT_ON: // enable camera interrupts
dev_dbg(g_dev_ptr, "LSEEK_INTERRUPT_ON\n");
compressor_interrupts(1,chn);
break;
default: // offset >=32
if ((offset & ~0x1f)==LSEEK_DAEMON_CIRCBUF) {
wait_event_interruptible(circbuf_wait_queue, get_imageParamsThis(chn, P_DAEMON_EN) & (1<<(offset & 0x1f)));
}
......
......@@ -153,7 +153,7 @@ int get_detected_sensor_code(int port, ///< Sensor port number (0..3)
return SENSOR_NONE;
}
/** Gert configured sensorport subchannels */
/** Get configured sensor port subchannels */
int get_subchannels(int port) ///< Sensor port
///< @return bitmask of available channels
{
......
This diff is collapsed.
......@@ -17,7 +17,7 @@ void initSequencers (int sensor_port); ///Move to sensorcommon? currently it
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
void initFramePars (int sensor_port); ///initialize all parameters, set thisFrameNumber to frame8 (read from hardware, usually 0 after resetting i2c and cmd_seq)
void resetFrameNumber (int sensor_port); /// 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_imageParamsThis (int sensor_port, int n);
unsigned long get_imageParamsPrev (int sensor_port, int n);
......@@ -29,9 +29,9 @@ unsigned long get_globalParam (int sensor_port, int n);
void set_globalParam (int sensor_port, int n, unsigned long d);
void set_imageParamsR_all(int sensor_port, int n, unsigned long d);
void updateFramePars (int sensor_port, int frame8, struct interframe_params_t * frame_pars); /// called from ISR - advance thisFrameNumber to match hardware frame8, copy parameters as needed.
/// frame8 usually is just next after thisFrameNumber
/// frame_pars - pointer to structure (between frames in the frame buffer) to save a pointer to past parameters
//Next 2 called from ISR
void updateInterFrame(int sensor_port, int frame16, struct interframe_params_t * interframe_pars);
void updateFramePars (int sensor_port, int frame16);
int setFrameParsStatic (int sensor_port, int numPars, struct frameparspair_t * pars);
unsigned long getThisFrameNumber (int sensor_port); /// just return current thisFrameNumber
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ int unlock_gamma_node (int color, int sensor_port, int sensor_subchn); /// NOTE:
/// return a pointer to the gamma table (single color) encoded in FPGA format (NULL if there is to table ready)
///
unsigned long * get_gamma_fpga(int color, int sensor_port, int sensor_subchn);
void fpga_gamma_write_nice (int color, int sensor_port, int sensor_subchn, u32 * gamma);
int fpga_gamma_write_nice (int color, int sensor_port, int sensor_subchn, unsigned long * gamma);
int gamma_new_node(void);
......
This diff is collapsed.
......@@ -20,13 +20,11 @@
extern wait_queue_head_t hist_y_wait_queue; /// wait queue for the G1 histogram (used as Y)
extern wait_queue_head_t hist_c_wait_queue; /// wait queue for all the other (R,G2,B) histograms (color)
void init_histograms(int chn_mask);
int get_hist_index (int sensor_port, int sensor_chn);
// void init_histograms(int chn_mask);
int histograms_check_init(void);
int get_hist_index (int sensor_port, int sensor_chn); //no hardware involved
int set_histograms (int sensor_port, int sensor_chn, unsigned long frame, int needed, unsigned long * gammaHash, unsigned long * framep);
int get_histograms (int sensor_port, int sensor_chn, unsigned long frame, int needed);
int histograms_init_hardware(void);
//int histograms_init_hardware(void);
void histograms_dma_ctrl(int mode); // 0 - reset, 1 - disable, 2 - enable
This diff is collapsed.
......@@ -194,6 +194,7 @@ int mt9x001_pgm_detectsensor (int sensor_port, ///< sensor port
///< be applied to, negative - ASAP
///< @return 0 - OK, negative - error
;
void mt9x001_set_device(struct device *dev);
#if 0
int adjustBinning_mt9x001(void);
int program_woi_mt9x001(int nonstop);
......
This diff is collapsed.
......@@ -129,7 +129,7 @@ each dibit:
//#define I2C359_CLK_NUMBER 4 // system clock number for the 10359A on-board clock generator
void multi10359_set_device(struct device *dev);
int multisensor_pgm_detectsensor (int sensor_port, struct sensor_t * sensor, struct framepars_t * thispars, struct framepars_t * prevpars, int frame16);
//int legacy_i2c (int ports);
/*
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -25,8 +25,9 @@
#define X393_MAXHEIGHT 65536 // 16384 // multiple of 16 - unsafe - not enough room for black level subtraction
#define X393_MAXHEIGHT_SAFE 65536 // 4096 // multiple of 16 OK for black level subtraction TODO: disable black level if unsafe
int init_pgm_proc(void);
int add_sensor_proc(int index, int (*sens_func)(int sensor_port, struct sensor_t * , struct framepars_t * , struct framepars_t *, int ));
void pgm_functions_set_device(struct device *dev);
int init_pgm_proc(int sensor_port);
int add_sensor_proc(int port, int index, int (*sens_func)(int sensor_port, struct sensor_t * , struct framepars_t * , struct framepars_t *, int ));
/// Commands through sequencer: switch between ASAP (frame <0) and absolute
/// @param port - sensor port (0..3)
......
......@@ -180,7 +180,7 @@ int get_cache_index(unsigned int chn)
void reset_qtables(unsigned int chn)
{
int ind = get_cache_index(chn);
qtables_set[ind].qtable_fpga_initialized = 0;
qtables_set[ind].qtable_cache_initialized = 0;
qtables_set[ind].qtable_fpga_initialized = 0;
}
......
This diff is collapsed.
......@@ -6,7 +6,9 @@
#define _SENSOR_COMMON_H
//extern struct sensor_t sensor; // current sensor (will be copied to by sensor driver), made external for the cc353.c to read/write i2c
extern struct sensorproc_t * sensorproc;
extern struct sensorproc_t * asensorproc;
//extern struct sensorproc_t * sensorproc;
/// IRQ-safe "nice" FPGA table write and histogram read functions - they split the data in chunks of fixed size,
/// disable IRQ, transfer a chunk, then reenable interrupt before proceedg to the next chunk
#define FPGA_TABLE_CHUNK 64 // up to 64 words to send to the table/from histogram on a single IRQ-off transfer
......@@ -24,6 +26,8 @@ extern struct sensorproc_t * sensorproc;
//int camSeqGetJPEG_wp(void);
//int camSeqGetJPEG_rp(void);
//void camSeqSetJPEG_rp(int p);
u32 get_compressor_frame(unsigned int chn);
int getHardFrameNumber(int sensor_port, int use_compressor);
int camseq_get_jpeg_wp(unsigned int chn);
int camseq_get_jpeg_rp(unsigned int chn);
void camseq_set_jpeg_rp(unsigned int chn, int ptr);
......
This diff is collapsed.
......@@ -37,6 +37,7 @@ typedef struct{
int i2c_stop_run_reset(int chn, int cmd);
int i2c_drive_mode (int chn, int sda_drive_high, int sda_release);
int read_xi2c_frame (int chn);
int i2c_page_alloc (int chn);
int i2c_page_register(int chn, int page);
......
......@@ -17,6 +17,9 @@
#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/errno.h>
#include <uapi/elphel/c313a.h> // PARS_FRAMES_MASK
#include "x393.h"
......@@ -24,6 +27,7 @@
#define REPEAT_STATUS_READ 10 ///< Number of times status is re-read waiting for a new timestamp
static void __iomem* zynq_devcfg_ptr = NULL; // 0xF8007000..f8007fff /f800700c needed
static DEFINE_SPINLOCK(fpga_time_lock);
// Nothing to init? Started in pgm_detectsesnor through sensor_common:sequencer_stop_run_reset
......@@ -44,7 +48,7 @@ sec_usec_t * get_fpga_rtc(sec_usec_t * ts) ///< Pointer to a sec/usec structure
// x393_rtc_sec_t sec;
int i;
if (!ts) return NULL;
spin_lock(&fpga_time_lock);
spin_lock_bh(&fpga_time_lock);
stat = x393_rtc_status();
stat_ctrl.mode = 1;
stat_ctrl.seq_num = stat.seq_num + 1;
......@@ -57,7 +61,7 @@ sec_usec_t * get_fpga_rtc(sec_usec_t * ts) ///< Pointer to a sec/usec structure
break;
}
}
spin_unlock(&fpga_time_lock);
spin_unlock_bh(&fpga_time_lock);
return ts;
}
......@@ -68,8 +72,18 @@ void set_fpga_rtc (sec_usec_t ts) ///< timestamp providing seconds and microseco
x393_rtc_sec_t sec;
usec.usec = ts.usec;
sec.sec = ts.sec;
spin_lock(&fpga_time_lock);
spin_lock_bh(&fpga_time_lock);
set_x393_rtc_usec(usec);
set_x393_rtc_sec_set(sec); // And apply
spin_unlock(&fpga_time_lock);
spin_unlock_bh(&fpga_time_lock);
}
/** Check if bitstream is loaded */
int is_fpga_programmed(void) ///< @return 0 - bitstream is NOT loaded, 1 - bitsteam IS loaded, -ENOMEM - error in ioremap
{
if (!zynq_devcfg_ptr){
zynq_devcfg_ptr = ioremap(0xf8007000, 0x00010000);
if (!zynq_devcfg_ptr)
return -ENOMEM;
}
return (readl(zynq_devcfg_ptr + 0x000c) & 4)? 1: 0;
}
......@@ -19,4 +19,5 @@
//void fpga_table_write_nice (int addr, int len, unsigned long * data);
sec_usec_t * get_fpga_rtc(sec_usec_t * ts);
void set_fpga_rtc (sec_usec_t ts);
int is_fpga_programmed(void);
......@@ -423,26 +423,22 @@ static ssize_t show_frames_in_buffer(struct device *dev, struct device_attribute
}
static ssize_t store_frame_start(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
size_t len;
sscanf(buf, "%i", &buffer_settings.frame_start[get_channel_from_name(attr)], &len);
sscanf(buf, "%i", &buffer_settings.frame_start[get_channel_from_name(attr)]);
return count;
}
static ssize_t store_full_width(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
size_t len;
sscanf(buf, "%i", &buffer_settings.frame_full_width[get_channel_from_name(attr)], &len);
sscanf(buf, "%i", &buffer_settings.frame_full_width[get_channel_from_name(attr)]);
return count;
}
static ssize_t store_frame_height(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
size_t len;
sscanf(buf, "%i", &buffer_settings.frame_height[get_channel_from_name(attr)], &len);
sscanf(buf, "%i", &buffer_settings.frame_height[get_channel_from_name(attr)]);
return count;
}
static ssize_t store_frames_in_buffer(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
size_t len;
sscanf(buf, "%i", &buffer_settings.frames_in_buffer[get_channel_from_name(attr)], &len);
sscanf(buf, "%i", &buffer_settings.frames_in_buffer[get_channel_from_name(attr)]);
return count;
}
......
......@@ -509,11 +509,13 @@
#define P_EXPOS 141 ///< P_RW_EXPOS 1 exposure time - now in microseconds?
#define P_VEXPOS 142 ///< video exposure (if 0 - use P_RW_EXPOS in ms)
#define P_FOCUS_VALUE 143 ///< (readonly) - sum of all blocks focus values inside focus WOI
#define P_COMPMOD_BYRSH 144 ///< Bayer shift in compressor
#define P_PORTRAIT 145 ///< Quantization coefficients optimized for vertical scan lines
/// 143 - last to copy ============
// 145 (was 143 in NC353) - last to copy ============
#define P_COMPMOD_BYRSH 160 ///< Bayer shift in compressor
#define P_PORTRAIT 161 ///< Quantization coefficients optimized for vertical scan lines
//#define P_COMPMOD_BYRSH 160 ///< Bayer shift in compressor
//#define P_PORTRAIT 161 ///< Quantization coefficients optimized for vertical scan lines
//TODO: rearrange, combine with other AUTOEXP
......@@ -666,9 +668,9 @@
#define P_MAX_GPAR (NUM_GPAR - 1) ///< maximal # of global parameter - TODO: change name to NUM_GPAR and make it 2048
#define PARS_SAVE_FROM 128 ///< PARS_SAVE_NUM parameters starting from PARS_SAVE_FROM from "this" frame will be saved in circular buffer, PASTPARS_SAVE_ENTRIES entries
#define PARS_SAVE_COPY 16 ///< number of parameters copied from future (framepars) to the past (pastpars)
#define PARS_SAVE_COPY 18 ///< number of parameters copied from future (framepars) to the past (pastpars)
#define PARS_SAVE_NUM 32 ///< total size of previous parameter save page
#define PP_PROFILE_START 16 ///< index of the first profile timestamp in pastpars
#define PP_PROFILE_START PARS_SAVE_COPY ///< index of the first profile timestamp in pastpars
#define P_PROFILE (PARS_SAVE_FROM + PP_PROFILE_START) ///< index to access profiles as pastpars (i.e. from PHP ELPHEL_PROFILE1,PHP ELPHEL_PROFILE2)
#define FRAMEPAR_GLOBALS 0x01000 ///< start of global (not frame-related) parameters
......@@ -758,6 +760,10 @@
//#define G_HIST_Y_FRAME (FRAMEPAR_GLOBALS + 57) // /< last frame for which Y histogram was calculated
//#define G_HIST_C_FRAME (FRAMEPAR_GLOBALS + 58) // /< last frame for which C histograms were calculated
#define G_SUBCHANNELS (FRAMEPAR_GLOBALS + 56) ///< subchannels used on this sensor port (bitmask)
#define G_COMPRESSOR_FRAME (FRAMEPAR_GLOBALS + 57) ///< last compressed frame number
//Gap 2 DWORDS
#define G_SKIP_DIFF_FRAME (FRAMEPAR_GLOBALS + 59) ///< number of frames with different size to tolerate before producing POLLHUP in poll(circbuf)
#define G_FTP_NEXT_TIME (FRAMEPAR_GLOBALS + 60) ///< time of the next FTP upload (seconds from epoch)
......@@ -925,40 +931,40 @@ struct framepars_t {
* TODO: Try to make room for some new ones.
*/
enum onchange_functions_t {
onchange_recalcseq=0, ///< recalculate sequences/latencies, according to P_SKIP, P_TRIG
onchange_detectsensor, ///< detect sensor type, sets sensor structure (capabilities), function pointers
onchange_sensorphase, ///< program sensor clock/phase (needs to know maximal clock frequency)
onchange_i2c, ///< program i2c
onchange_sensorregs, ///< write sensor registers (only changed from outside the driver as they may have different latencies)?
onchange_initsensor, ///< resets sensor, reads sensor registers, schedules "secret" manufacturer's corrections to the registers (stops/re-enables hardware i2c)
onchange_afterinit, ///< restore image size, decimation,... after sensor reset or set them according to sensor capabilities if none were specified
onchange_multisens, ///< chnages related to multiplexed sensors
onchange_window, ///< program sensor WOI and mirroring (flipping)
onchange_window_safe, ///< program sensor WOI and mirroring (flipping) - lower latency, no bad frames
onchange_recalcseq=0, ///< 0 recalculate sequences/latencies, according to P_SKIP, P_TRIG
onchange_detectsensor, ///< 1 detect sensor type, sets sensor structure (capabilities), function pointers
onchange_sensorphase, ///< 2 program sensor clock/phase (needs to know maximal clock frequency)
onchange_i2c, ///< 3 program i2c
onchange_sensorregs, ///< 4 write sensor registers (only changed from outside the driver as they may have different latencies)?
onchange_initsensor, ///< 5 resets sensor, reads sensor registers, schedules "secret" manufacturer's corrections to the registers (stops/re-enables hardware i2c)
onchange_afterinit, ///< 6 restore image size, decimation,... after sensor reset or set them according to sensor capabilities if none were specified
onchange_multisens, ///< 7 chnages related to multiplexed sensors
onchange_window, ///< 8 program sensor WOI and mirroring (flipping)
onchange_window_safe, ///< 9 program sensor WOI and mirroring (flipping) - lower latency, no bad frames
// onchange_exposure, ///< program exposure
onchange_gains, ///< program analog gains
onchange_triggermode, ///< program sensor trigger mode
onchange_sensorin, ///< program sensor input in FPGA (Bayer, 8/16 bits, ??)
onchange_sensorstop, ///< Stop acquisition from the sensor to the FPGA (start has latency of 2)
onchange_sensorrun, ///< Start/single acquisition from the sensor to the FPGA (stop has latency of 1)
onchange_gamma, ///< program gamma table
onchange_hist, ///< program histogram window
onchange_aexp, ///< program autoexposure mode
onchange_quality, ///< program quantization table(s)
onchange_memsensor, ///< program memory channels 0 (sensor->memory) and 1 (memory->FPN)
onchange_memcompressor, ///< program memory channel 2 (memory->compressor)
onchange_limitfps, ///< check compressor will keep up, limit sensor FPS if needed
onchange_exposure, ///< program exposure - NOTE: was just after onchange_window
onchange_compmode, ///< program compressor modes (excluding start/stop/single)
onchange_focusmode, ///< program focus modes
onchange_trigseq, ///< program sequencer (int/ext)
onchange_irq, ///< program smart IRQ mode (needs to be on)
onchange_comprestart, ///< restart after changing geometry (recognizes ASAP and programs memory channel 2 then)
onchange_compstop, ///< stop compressor when changing geometry
onchange_compctl, ///< only start/stop/single (after explicitly changed, not when geometry was changed)
onchange_gammaload, ///< write gamma tables (should be prepared). Maybe - just last byte, to activate?
onchange_prescal ///< change scales for per-color digital gains, apply vignetting correction
onchange_gains, ///< 10 program analog gains
onchange_triggermode, ///< 11 program sensor trigger mode
onchange_sensorin, ///< 12 program sensor input in FPGA (Bayer, 8/16 bits, ??)
onchange_sensorstop, ///< 13 Stop acquisition from the sensor to the FPGA (start has latency of 2)
onchange_sensorrun, ///< 14 Start/single acquisition from the sensor to the FPGA (stop has latency of 1)
onchange_gamma, ///< 15 program gamma table
onchange_hist, ///< 16 program histogram window
onchange_aexp, ///< 17 program autoexposure mode
onchange_quality, ///< 18 program quantization table(s)
onchange_memsensor, ///< 19 program memory channels 0 (sensor->memory) and 1 (memory->FPN)
onchange_memcompressor, ///< 20 program memory channel 2 (memory->compressor)
onchange_limitfps, ///< 21 check compressor will keep up, limit sensor FPS if needed
onchange_exposure, ///< 22 program exposure - NOTE: was just after onchange_window
onchange_compmode, ///< 23 program compressor modes (excluding start/stop/single)
onchange_focusmode, ///< 24 program focus modes
onchange_trigseq, ///< 25 program sequencer (int/ext)
onchange_irq, ///< 26 program smart IRQ mode (needs to be on)
onchange_comprestart, ///< 27 restart after changing geometry (recognizes ASAP and programs memory channel 2 then)
onchange_compstop, ///< 28 stop compressor when changing geometry
onchange_compctl, ///< 29 only start/stop/single (after explicitly changed, not when geometry was changed)
onchange_gammaload, ///< 30 write gamma tables (should be prepared). Maybe - just last byte, to activate?
onchange_prescal ///< 31 change scales for per-color digital gains, apply vignetting correction
// onchange_sensorregs /// write sensor registers (only changed from outside the driver as they may have different latencies)?
// add others - none left, all 32 bits used
};
......@@ -1325,6 +1331,7 @@ struct p_names_t {
G_NAME_ENTRY(HIST_Y_FRAME), \
G_NAME_ENTRY(HIST_C_FRAME), \
G_NAME_ENTRY(SUBCHANNELS), \
G_NAME_ENTRY(COMPRESSOR_FRAME), \
G_NAME_ENTRY(SKIP_DIFF_FRAME), \
G_NAME_ENTRY(FTP_NEXT_TIME), \
G_NAME_ENTRY(DAEMON_ERR), \
......
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