Commit 0d5bd2de authored by Andrey Filippov's avatar Andrey Filippov

more debugging with updated fpga code

parent 1769750d
......@@ -353,7 +353,7 @@ int putlong_meta(int sensor_port, unsigned long data, int * indx, unsigned long
// Uses struct exif_time that should be updated from the user space (once a day),
// calculates date/time ignoring leap seconds if not updated in time
/*
* 393: Continue to use same static buffers for exif_time
* 393: Continue to use same static buffers for exif_time - common to all channels
*/
char * encode_time(char buf[27], unsigned long sec, unsigned long usec) {
unsigned long s,d,m,y,y4,lp,h;
......@@ -422,11 +422,11 @@ char * encode_time(char buf[27], unsigned long sec, unsigned long usec) {
int store_meta(int sensor_port) { //called from IRQ service - put current metadata to meta_buffer, return page index
if (!aexif_enabled[sensor_port]) return 0;
int retval=aexif_wp[sensor_port];
memcpy(&ameta_buffer[sensor_port][aexif_wp[sensor_port] * aexif_meta_size[sensor_port]], ameta_buffer[sensor_port],aexif_meta_size[sensor_port]);
int meta_index=aexif_wp[sensor_port];
memcpy(&ameta_buffer[sensor_port][meta_index * aexif_meta_size[sensor_port]], ameta_buffer[sensor_port], aexif_meta_size[sensor_port]);
aexif_wp[sensor_port]++;
if (aexif_wp[sensor_port] > MAX_EXIF_FRAMES) aexif_wp[sensor_port] = 1;
return retval;
return meta_index;
}
//!++++++++++++++++++++++++++++++++++++ open() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
......
......@@ -258,6 +258,8 @@ int framepars_mmap(struct file *file, struct vm_area_struct *vma);
*/
int initSequencers(int sensor_port)
{
// x393_rtc_sec_t rtc_sec = {.d32=0};
sec_usec_t sec_usec;
FLAGS_IBH
if (!is_fpga_programmed){
dev_err(g_devfp_ptr,"*** Attempted to access hardware without bitsteram ***\n");
......@@ -268,9 +270,12 @@ int initSequencers(int sensor_port)
dev_info(g_devfp_ptr,"Configuring compressor DMA channels\n");
init_compressor_dma(0xf, // all channels (TODO: NC393 - select channels in DT or use existing for sesnors?
0); // not to interfere with python setting the same
// 1); // reset all channels (do only once, resetting running DMA may confuse AXI)
// Start RTC by writing 0 to seconds if it was not already set, otherwise preserve current time
get_fpga_rtc(&sec_usec);
set_fpga_rtc( sec_usec);
// Start RTC by writing 0 to seconds
// set_x393_rtc_sec_set (rtc_sec); // started RTC, correct time may be set later or before
hardware_initialized = 1;
}
dev_dbg(g_devfp_ptr,"port= %d,initSequencers:resetting both sequencers (not really?)\n", sensor_port);
#ifdef TEST_DISABLE_CODE
......@@ -412,6 +417,14 @@ int initMultiPars(int sensor_port)
return GLOBALPARS(sensor_port, G_MULTI_NUM);
}
/** Reads parameters for the specified frame number, OK to use in compressor ISR using last compressed frame */
inline unsigned long get_imageParamsFrame(int sensor_port, ///< sensor port (0..3)
int n, ///< parameter index (should be 128..143)
int frame) ///< absolute frame number
{
return aframepars[sensor_port][frame & PARS_FRAMES_MASK].pars[n];
}
/**
* @brief reads parameters from the current frame (matching hardware index)
* @param sensor_port sensor port number (0..3)
......@@ -434,7 +447,7 @@ inline unsigned long get_imageParamsPrev(int sensor_port, int n)
return aframepars[sensor_port][(thisFrameNumber(sensor_port) - 1) & PARS_FRAMES_MASK].pars[n];
}
/** Reads past parameters (small subset of all) fro absolute frame number */
/** Reads past parameters (small subset of all) for absolute frame number */
inline unsigned long get_imageParamsPast(int sensor_port, ///< sensor port (0..3)
int n, ///< parameter index (should be 128..143)
int frame) ///< absolute frame number
......@@ -508,45 +521,54 @@ void updateInterFrame(int sensor_port, ///< Sensor port number (0..3)
// int index32;
// unsigned long bmask, bmask32;
int pastParsIndex;
// struct framepars_t *framepars = aframepars[sensor_port];
// u32 compressed_frame; ///< absolute number of compressed frame , matching frame16
// compressed_frame = (thisFrameNumber(sensor_port) & ~PARS_FRAMES_MASK) | (frame16 & PARS_FRAMES_MASK);
// if (compressed_frame > thisFrameNumber(sensor_port)) // compressor frame number can never be higher than sesnor one
// compressed_frame -= PARS_FRAMES;
int compressedIndex = compressed_frame & PARS_FRAMES_MASK; // last compressed frame mod 16
struct framepars_t *framepars = aframepars[sensor_port];
thisCompressorFrameNumber(sensor_port) = compressed_frame;
// pastParsIndex = (thisFrameNumber(sensor_port) - 1) & PASTPARS_SAVE_ENTRIES_MASK; // copying from what was past frame that might include histogram data
pastParsIndex = compressed_frame & PASTPARS_SAVE_ENTRIES_MASK; // copying from what was past frame that might include histogram data
// memcpy(interframe_pars, &framepars[findex_this].pars[P_GTAB_R], 24); // will leave some gaps, but copy [P_ACTUAL_WIDTH]
// After Frame sync interrupt processed, oldest valid will be is sensor frame number -2, compressor lag is 1 frame (0..2), so read not past-pars is OK
#ifdef USE_PASTPARS_IN_CMPRSIRQ
memcpy(interframe_pars, &apastpars[sensor_port][pastParsIndex].past_pars[P_GTAB_R-PARS_SAVE_FROM], 24); // will leave some gaps, but copy [P_ACTUAL_WIDTH]
interframe_pars->height = apastpars[sensor_port][pastParsIndex].past_pars[P_ACTUAL_HEIGHT-PARS_SAVE_FROM]; // NOTE: P_ACTUAL_WIDTH,P_QUALITY copied with memcpy
interframe_pars->color = apastpars[sensor_port][pastParsIndex].past_pars[P_COLOR-PARS_SAVE_FROM];
interframe_pars->byrshift = apastpars[sensor_port][pastParsIndex].past_pars[P_COMPMOD_BYRSH-PARS_SAVE_FROM];
interframe_pars->quality2 |= (apastpars[sensor_port][pastParsIndex].past_pars[P_PORTRAIT-PARS_SAVE_FROM] & 1) << 7;
#else
memcpy (interframe_pars, &framepars[compressedIndex].pars[P_GTAB_R], 24); /// will leave some gaps, but copy [P_ACTUAL_WIDTH]
interframe_pars->height= framepars[compressedIndex].pars[P_ACTUAL_HEIGHT]; /// NOTE: P_ACTUAL_WIDTH,P_QUALITY copied with memcpy
interframe_pars->color= framepars[compressedIndex].pars[P_COLOR];
interframe_pars->byrshift=framepars[compressedIndex].pars[P_COMPMOD_BYRSH];
interframe_pars->quality2 |= (framepars[compressedIndex].pars[P_PORTRAIT] & 1) << 7;
#endif
}
//++++++++++++++++++++++++++++++++++++++++++
/** Called from ISR (sensor frame interrupt)- advance thisFrameNumber to match hardware frame16, copy parameters as needed.
* before: (thisFrameNumber mod8 pointed to current (for the software) parameters frame (now behind by at least 1, maybe 2)
* (thisFrameNumber-1) mod 8 - oldest with parameters preserved, also containes histograms results (+image timestamp, size?)
* subset of that frame data is copied to pastpars
* (thisFrameNumber-2) mod 8 - farthest in the future frame
* before: (thisFrameNumber mod 16 pointed to current (for the software) parameters frame (now behind by at least 1, maybe 2)
* (thisFrameNumber-1) mod 16 - oldest with parameters preserved, also containes histograms results (+image timestamp, size?)
* subset of that frame data is copied to pastpars
* (thisFrameNumber-2) mod 16- farthest in the future frame
* after: thisFrameNumber matches hardware pointer
* @param sensor_port sensor port number (0..3)
* @param interframe_pars pointer to structure (between frames in the frame buffer) to save a pointer to past parameters
* pass NULL if compressor was off (or no time to copy?)
*/
//TODO: Remove interframe, handle it with compressor interrupts (above)
void updateFramePars(int sensor_port, int frame16)
/// Among other things copies subset of parameters to pastpars
void updateFramePars(int sensor_port, ///< sensor port number (0..3)
int frame16) ///< Sensor sequencer (hardware) frame number
{
int findex_this, findex_prev, findex_future, findex_next;
int index, index32;
unsigned long bmask, bmask32;
int pastParsIndex;
struct framepars_t *framepars = aframepars[sensor_port];
// If interrupt was from compression done (circbuf advanced, interframe_pars!=null), the frame16 (hardware) maybe not yet advanced
// We can fix it here, but it will not work if some frames were not processed in time
#ifdef NC353
// Old comments from NC353
// If interrupt was from compression done (circbuf advanced, interframe_pars!=null), the frame16 (hardware) maybe not yet advanced
// We can fix it here, but it will not work if some frames were not processed in time
if ((interframe_pars != NULL) && (((frame16 ^ thisFrameNumber(sensor_port)) & PARS_FRAMES_MASK) == 0)) {
findex_this = frame16 & PARS_FRAMES_MASK;
......@@ -556,25 +578,35 @@ void updateFramePars(int sensor_port, int frame16)
}
#endif
dev_dbg(g_devfp_ptr,"%s : port= %d, frame16=%d\n",__func__, sensor_port, frame16);
while ((frame16 ^ thisFrameNumber(sensor_port)) & PARS_FRAMES_MASK) {
while ((frame16 ^ thisFrameNumber(sensor_port)) & PARS_FRAMES_MASK) { // While hardware pointer is still ahead of the software maintained one
dev_dbg(g_devfp_ptr,"%s : port= %d, frame16=%d, thisFrameNumber(sensor_port)\n",__func__, sensor_port, frame16, (int)thisFrameNumber(sensor_port));
// before update:
// framepars[findex_prev] holds previous frame data (oldest availble)
// framepars[findex_prev] holds previous frame data (oldest availble - latest?)
// framepars[findex_future] holds farthest in the future one
// after update:
// framepars[findex_prev] holds farthest in the future one ("this" will become "prev")
findex_this = thisFrameNumber(sensor_port) & PARS_FRAMES_MASK;
findex_prev = (findex_this - 1) & PARS_FRAMES_MASK;
findex_future = (findex_this - 2) & PARS_FRAMES_MASK; // farthest in the future
findex_next = (findex_this + 1) & PARS_FRAMES_MASK;
findex_this = thisFrameNumber(sensor_port) & PARS_FRAMES_MASK; // Nothing is yet done for this frame (mod 16)
findex_prev = (findex_this - 1) & PARS_FRAMES_MASK; // Holds previous frame data (mod 16) (latest available)
findex_future = (findex_this - 2) & PARS_FRAMES_MASK; // farthest in the future (mod 16) (not to overwrite latest
findex_next = (findex_this + 1) & PARS_FRAMES_MASK; // Just next frame (mod 16) after the current
// copy subset of the parameters to the long buffer of past parameters. TODO: fill Exif also here?
// TODO:DONE: Change - make pastpars be save for all frames, not just compressed ones
// With PASTPARS_SAVE_ENTRIES being multiple of PARS_FRAMES - make it possible to calculate past_index from thisFrameNumber
// pastParsIndex= thisFrameNumber & PASTPARS_SAVE_ENTRIES_MASK;
pastParsIndex = (thisFrameNumber(sensor_port) - 1) & PASTPARS_SAVE_ENTRIES_MASK; // copying from what was past frame that might include histogram data
// memcpy (pastpars[pastParsIndex].past_pars, &framepars[findex_prev].pars[PARS_SAVE_FROM], sizeof(pastpars[0].past_pars));
memcpy(apastpars[sensor_port][pastParsIndex].past_pars, &framepars[findex_prev].pars[PARS_SAVE_FROM], PARS_SAVE_COPY * sizeof(int));
// Now update interframe_pars (interframe area) used to create JPEG headers. Interframe area survives exactly as long as the frames themselves (not like pastpars)
// memcpy(apastpars[sensor_port][pastParsIndex].past_pars, &framepars[findex_prev].pars[PARS_SAVE_FROM], PARS_SAVE_COPY * sizeof(int));
memcpy(apastpars[sensor_port][pastParsIndex].past_pars, &framepars[findex_prev].pars[PARS_SAVE_FROM], PARS_SAVE_COPY << 2);
// Now update interframe_pars (interframe area) used to create JPEG headers. Interframe area survives exactly as long as the frames themselves (not like pastpars)
#if 0
struct framepars_past_t {
unsigned long past_pars[PARS_SAVE_NUM]; ///< Array of frame parameters preserved for the future
};
#endif
#ifdef NC353
if (interframe_pars) { // frame was compressed, not just vsync
//TODO: get rid of *_prev, use it for the future.
......
......@@ -625,6 +625,7 @@ int pgm_initsensor (int sensor_port, ///< sensor port number (
x393_lens_height_m1_t vign_hight1 = {.d32=0};
x393_lens_height_m1_t vign_hight2 = {.d32=0};
x393_sens_mode_t sens_mode = {.d32=0};
x393_camsync_mode_t camsync_mode = {.d32=0};
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
......@@ -681,7 +682,61 @@ int pgm_initsensor (int sensor_port, ///< sensor port number (
MDP(DBGB_PADD, sensor_port,"X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_mode, 0x%x)\n",
sensor_port, frame16, sens_mode.d32)
/*
self.set_camsync_period (0) # reset circuitry
self.X393_gpio.set_gpio_ports (port_a = True)
self.set_camsync_mode (
en = True,
en_snd = True,
en_ts_external = external_timestamp,
triggered_mode = trigger_mode,
master_chn = 0,
chn_en = sensor_mask)
void x393_camsync_mode (x393_camsync_mode_t d); // CAMSYNC mode
// CAMSYNC mode
typedef union {
struct {
u32 en: 1; // [ 0] (1) Enable CAMSYNC module
u32 en_set: 1; // [ 1] (1) Set 'en' bit
u32 en_snd: 1; // [ 2] (1) Enable sending timestamps (valid with 'en_snd_set')
u32 en_snd_set: 1; // [ 3] (0) Set 'en_snd'
u32 ext: 1; // [ 4] (1) Use external (received) timestamps, if available. O - use local timestamps
u32 ext_set: 1; // [ 5] (0) Set 'ext'
u32 trig: 1; // [ 6] (1) Sensor triggered mode (0 - free running sensor)
u32 trig_set: 1; // [ 7] (0) Set 'trig'
u32 master_chn: 2; // [ 9: 8] (0) master sensor channel (zero delay in internal trigger mode, delay used for flash output)
u32 master_chn_set: 1; // [ 10] (0) Set 'master_chn'
u32 ts_chns: 4; // [14:11] (1) Channels to generate timestmp messages (bit mask)
u32 ts_chns_set: 4; // [18:15] (0) Sets for 'ts_chns' (each bit controls corresponding 'ts_chns' bit)
u32 :13;
};
struct {
u32 d32:32; // [31: 0] (0) cast to u32
};
} x393_camsync_mode_t;
self.set_camsync_mode (
en = True,
en_snd = True,
en_ts_external = False,
triggered_mode = False,
master_chn = 0,
chn_en = sensor_mask)
*/
camsync_mode.en = 1;
camsync_mode.en_set = 1;
camsync_mode.ext = 0;
camsync_mode.ext_set = 1;
camsync_mode.trig = 0;
camsync_mode.trig_set = 1;
x393_camsync_mode (camsync_mode); // immediate mode, bypass sequencer CAMSYNC mode
// (TODO NC393: Make it possible to synchronize writes (through sequencer)
set_x393_camsync_trig_period (0); // reset circuitry (immediate mode)
if (frame16 >= 0) return -1; // should be ASAP
//TODO: seems nothing to do here - all in the sensor-specific function:
//Adding setup compressor report status mode - maybe move elsethere? Needed for comprfessor frame reporting, has to be done just once
......@@ -1378,6 +1433,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
x393_sensio_width_t sensio_width = {.d32=0};
x393_sens_sync_mult_t sync_mult = {.d32=0};
x393_gamma_ctl_t gamma_ctl = {.d32=0};
int n_scan_lines, n_ph_lines;
int flips;
int bayer_modified;
......@@ -1450,7 +1506,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
// Change Bayer for gamma/histograms?
if (bayer_modified) {
gamma_ctl.bayer = thispars->pars[P_BAYER] ^ flips ^ sensor->bayer;
gamma_ctl.bayer = thispars->pars[P_BAYER] ^ flips ^ sensor->bayer ^ 3; // 3 added for NC393
gamma_ctl.bayer_set = 1;
}
//NC393: Other needed bits are set in pgm_initsensor (they must be set just once)
......@@ -1462,6 +1518,31 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
}
#if 0
typedef union {
struct {
u32 run: 2; // [ 1: 0] (0) Run mode
u32 run_set: 1; // [ 2] (0) Set 'run'
u32 qbank: 3; // [ 5: 3] (0) Quantization table bank
u32 qbank_set: 1; // [ 6] (0) Set 'qbank'
u32 dcsub: 1; // [ 7] (0) Subtract DC enable
u32 dcsub_set: 1; // [ 8] (0) Set 'qbank'
u32 cmode: 4; // [12: 9] (0) Color format
u32 cmode_set: 1; // [ 13] (0) Set 'cmode'
u32 multiframe: 1; // [ 14] (0) Multi/single frame mode
u32 multiframe_set: 1; // [ 15] (0) Set 'multiframe'
u32 : 2;
u32 bayer: 2; // [19:18] (0) Bayer shift
u32 bayer_set: 1; // [ 20] (0) Set 'bayer'
u32 focus: 2; // [22:21] (0) Focus mode
u32 focus_set: 1; // [ 23] (0) Set 'focus'
u32 : 8;
};
struct {
u32 d32:32; // [31: 0] (0) cast to u32
};
} x393_cmprs_mode_t;
// Control for the gamma-conversion module
typedef union {
......
......@@ -39,7 +39,6 @@ int add_sensor_proc(int port, int index, int (*sens_func)(int sensor_port, struc
#define X393_SEQ_SEND1S(port,frame,func,data,subchn) {if ((frame) < 0) seqr_##func (0, (data), (port), (subchn)); \
else seqa_##func ((frame), (data), (port), (subchn)); }
/** Tells if parameter is modifies
* @param x parameter index to test
* @return nonzero if modified */
......
......@@ -67,7 +67,7 @@ static struct device *g_dev_ptr;
/** @brief Contains read and write pointers along with IRQ number for a single channel*/
struct jpeg_ptr_t {
volatile u32 frame; ///< Absolute frame number
volatile u32 frame; ///< Absolute frame number (last compressed)
volatile int jpeg_wp; ///< JPEG write pointer in 32 bit words
volatile int jpeg_rp; ///< JPEG read pointer in 32 bit words
volatile int fpga_cntr_prev; ///< This field contains previous value of the FPGA transfer counter which is used to find out if it has changed. This pointer is in 32 bit words.
......@@ -136,8 +136,9 @@ u32 get_compressor_frame(unsigned int chn) ///< Sensor port number (0..3)
/** @brief Works like a cache to time save on looking for tags in the directory (forced to recalculate if does not match)
* will have offset of the Exif_Image_DateTime data in meta page (Exif_Photo_SubSecTime should go immediately after in meta page)
*/
static struct meta_offsets_t { // Never used even in NC353?
static struct meta_offsets_t { //
int Image_DateTime; ///< EXIF Date/Time offset
///< Has offset of the Exif_Image_DateTime data in meta page (Exif_Photo_SubSecTime should go immediately after in meta page)
int Photo_DateTimeOriginal; ///< EXIF Date/Time Original offset
int Photo_ExposureTime; ///< EXIF exposure offset
int Image_ImageNumber; ///< EXIF image number offset
......@@ -182,6 +183,11 @@ void camseq_set_jpeg_rp(unsigned int chn, int ptr)
- get_globalParam(chn, G_CIRCBUFWP));
}
}
/** Get latest compressed frame number */
int camSeqGetJPEG_frame(unsigned int chn)
{
return (chn < SENSOR_PORTS) ? image_acq_priv.jpeg_ptr[chn].frame : 0;
}
/** Write pointer in circbuf, in DWORDs */
int camSeqGetJPEG_wp(unsigned int chn)
......@@ -196,6 +202,7 @@ int camSeqGetJPEG_rp(unsigned int chn)
void camSeqSetJPEG_rp(unsigned int chn, ///< channel (0..3)
int ptr) /// DWORD index in the buffer
{
if (chn < SENSOR_PORTS) {
image_acq_priv.jpeg_ptr[chn].jpeg_rp = ptr << 2;
......@@ -344,7 +351,7 @@ static inline int updateIRQJPEG_wp(struct jpeg_ptr_t *jptr)
}
#endif
if (frame16 > (aframe & PARS_FRAMES_MASK))
aframe += 16;
aframe -= 16;
jptr->frame = (aframe & ~PARS_FRAMES_MASK) | frame16; // This is absolute compressed frame number, may lag behind current one
/* debug code follows */
......@@ -442,19 +449,6 @@ inline void updateIRQFocus(struct jpeg_ptr_t *jptr)
set_imageParamsThis (jptr->chn_num, P_FOCUS_VALUE, high_freq);
}
inline static void set_default_interframe(struct interframe_params_t *params)
{
// params->height = 1936;
// params->width = 2592;
params->height = circbuf_height;
params->width = circbuf_width;
// params->byrshift = 3;
params->byrshift = circbuf_byrshift;
params->color = 0;
params->quality2 = circbuf_quality;
//params->quality2 = 100;
}
/**
* @brief Locate area between frames in the circular buffer
* @return pointer to interframe parameters structure
......@@ -486,10 +480,6 @@ inline struct interframe_params_t* updateIRQ_interframe(struct jpeg_ptr_t *jptr)
interframe->frame_length = jpeg_len;
interframe->signffff = 0xffff;
/* debug code follows */
//set_default_interframe(interframe); // TODO: Production NC393: should be removed?
/* end of debug code */
set_globalParam(jptr->chn_num, G_FRAME_SIZE, jpeg_len);
// invalidate CPU L1 and L2 caches (in this order)
......@@ -546,30 +536,26 @@ inline void updateIRQ_Exif(struct jpeg_ptr_t *jptr, ///< pointer
int maker_offset;
u32 frame = jptr->frame;
int frame_index = frame & PASTPARS_SAVE_ENTRIES_MASK;
// [P_FRAME-PARS_SAVE_FROM
// Now find if parameters are still available or need pastpars (that may switch at any time or should we use pastpars already as they were copied
// at the start of the frame ?
//get_imageParamsThis
// NC393: current parameters are valid at compressor done interrupt (after frame sync interrupts latest valid is new frame number - 2
if (index_time<0) index_time+=get_globalParam (sensor_port, G_CIRCBUFSIZE)>>2;
// struct exif_datetime_t
// calculates datetime([20] and subsec[7], returns pointer to char[27]
exif_meta_time_string=encode_time(time_buff, ccam_dma_buf_ptr[sensor_port][index_time], ccam_dma_buf_ptr[sensor_port][index_time+1]);
// may be split in datetime/subsec - now it will not notice missing subseq field in template
// may be split in datetime/subsec - now it will not notice missing subsec field in template
write_meta_irq(sensor_port, exif_meta_time_string, &meta_offsets.Photo_DateTimeOriginal, Exif_Photo_DateTimeOriginal, 27);
write_meta_irq(sensor_port, exif_meta_time_string, &meta_offsets.Image_DateTime, Exif_Image_DateTime, 20); // may use 27 if room is provided
putlong_meta_irq(sensor_port, get_imageParamsPast(sensor_port, P_EXPOS, frame), &meta_offsets.Photo_ExposureTime, Exif_Photo_ExposureTime);
putlong_meta_irq(sensor_port, get_imageParamsFrame(sensor_port, P_EXPOS, frame), &meta_offsets.Photo_ExposureTime, Exif_Photo_ExposureTime);
putlong_meta_irq(sensor_port, frame, &meta_offsets.Image_ImageNumber, Exif_Image_ImageNumber);
//Exif_Photo_MakerNote
global_flips=(get_imageParamsPast(sensor_port, P_FLIPH, frame) & 1) | ((get_imageParamsPast(sensor_port, P_FLIPV, frame)<<1) & 2);
global_flips=(get_imageParamsFrame(sensor_port, P_FLIPH, frame) & 1) | ((get_imageParamsFrame(sensor_port, P_FLIPV, frame)<<1) & 2);
extra_flips=0;
if (get_imageParamsThis(sensor_port, P_MULTI_MODE)!=0) { // No past!
extra_flips=get_imageParamsThis(sensor_port, P_MULTI_MODE_FLIPS); // No past!
if (get_imageParamsFrame(sensor_port, P_MULTI_MODE,frame)!=0) {
extra_flips=get_imageParamsFrame(sensor_port, P_MULTI_MODE_FLIPS,frame);
global_flips=extra_flips & 3;
}
orientation_short[0]=0;
orientation_short[1]=0xf & orientations[(get_imageParamsThis(sensor_port, P_PORTRAIT)&3) | (global_flips<<2)]; // No past!
orientation_short[1]=0xf & orientations[(get_imageParamsFrame(sensor_port, P_PORTRAIT, frame)&3) | (global_flips<<2)];
write_meta_irq(sensor_port, orientation_short, &meta_offsets.Image_Orientation, Exif_Image_Orientation, 2);
// write sensor number
......@@ -579,33 +565,40 @@ inline void updateIRQ_Exif(struct jpeg_ptr_t *jptr, ///< pointer
write_meta_irq(sensor_port, short_buff, &meta_offsets.PageNumber, Exif_Image_PageNumber, 2);
//TODO - use memcpy
maker_offset=putlong_meta_irq(sensor_port, get_imageParamsPast(sensor_port, P_GAINR,frame), &meta_offsets.Photo_MakerNote, Exif_Photo_MakerNote);
maker_offset=putlong_meta_irq(sensor_port, get_imageParamsFrame(sensor_port, P_GAINR,frame), &meta_offsets.Photo_MakerNote, Exif_Photo_MakerNote);
if (maker_offset>0) {
putlong_meta_raw_irq(sensor_port, get_imageParamsPast(sensor_port, P_GAING,frame), maker_offset+4);
putlong_meta_raw_irq(sensor_port, get_imageParamsPast(sensor_port, P_GAINGB,frame), maker_offset+8);
putlong_meta_raw_irq(sensor_port, get_imageParamsPast(sensor_port, P_GAINB,frame), maker_offset+12);
putlong_meta_raw_irq(sensor_port, get_imageParamsPast(sensor_port, P_GTAB_R,frame), maker_offset+16);
putlong_meta_raw_irq(sensor_port, get_imageParamsPast(sensor_port, P_GTAB_G,frame), maker_offset+20);
putlong_meta_raw_irq(sensor_port, get_imageParamsPast(sensor_port, P_GTAB_GB,frame), maker_offset+24);
putlong_meta_raw_irq(sensor_port, get_imageParamsPast(sensor_port, P_GTAB_B,frame), maker_offset+28);
putlong_meta_raw_irq(sensor_port, get_imageParamsThis(sensor_port, P_WOI_LEFT) | (get_imageParamsThis(sensor_port, P_WOI_WIDTH)<<16), maker_offset+32); //No Past
putlong_meta_raw_irq(sensor_port, get_imageParamsThis(sensor_port, P_WOI_TOP) | (get_imageParamsThis(sensor_port, P_WOI_HEIGHT)<<16), maker_offset+36); //No Past
#if 0 // just debugging
putlong_meta_raw_irq(sensor_port, frame, maker_offset+ 4);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_EXPOS, frame), maker_offset+ 8);
putlong_meta_raw_irq(sensor_port, ccam_dma_buf_ptr[sensor_port][index_time], maker_offset+12);
putlong_meta_raw_irq(sensor_port, ccam_dma_buf_ptr[sensor_port][index_time+1], maker_offset+16);
#else
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_GAING,frame), maker_offset+4);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_GAINGB,frame), maker_offset+8);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_GAINB,frame), maker_offset+12);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_GTAB_R,frame), maker_offset+16);
#endif
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_GTAB_G,frame), maker_offset+20);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_GTAB_GB,frame), maker_offset+24);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_GTAB_B,frame), maker_offset+28);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_WOI_LEFT,frame) | (get_imageParamsFrame(sensor_port, P_WOI_WIDTH,frame)<<16), maker_offset+32); //No Past
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_WOI_TOP,frame) | (get_imageParamsFrame(sensor_port, P_WOI_HEIGHT,frame)<<16), maker_offset+36); //No Past
putlong_meta_raw_irq(sensor_port, global_flips |
((get_imageParamsThis(sensor_port, P_BAYER)<<2) & 0xc) | // No past!
((get_imageParamsPast(sensor_port, P_COLOR, frame)<<4) & 0xF0) |
((get_imageParamsThis(sensor_port, P_DCM_HOR)<<8) & 0xF00) | // No past!
((get_imageParamsThis(sensor_port, P_DCM_VERT)<<12) & 0xF000) | // No past!
((get_imageParamsThis(sensor_port, P_BIN_HOR)<<16) & 0xF0000) | // No past!
((get_imageParamsThis(sensor_port, P_BIN_VERT)<<20) & 0xF00000) | // No past!
((get_imageParamsFrame(sensor_port, P_BAYER, frame)<<2) & 0xc) |
((get_imageParamsFrame(sensor_port, P_COLOR, frame)<<4) & 0xF0) |
((get_imageParamsFrame(sensor_port, P_DCM_HOR, frame)<<8) & 0xF00) |
((get_imageParamsFrame(sensor_port, P_DCM_VERT, frame)<<12) & 0xF000) |
((get_imageParamsFrame(sensor_port, P_BIN_HOR, frame)<<16) & 0xF0000) |
((get_imageParamsFrame(sensor_port, P_BIN_VERT, frame)<<20) & 0xF00000) |
(extra_flips <<24) , maker_offset+40);
putlong_meta_raw_irq(sensor_port, get_imageParamsThis(sensor_port, P_MULTI_HEIGHT_BLANK1), maker_offset+44); // No past!
putlong_meta_raw_irq(sensor_port, get_imageParamsThis(sensor_port, P_MULTI_HEIGHT_BLANK2), maker_offset+48); // No past!
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_MULTI_HEIGHT_BLANK1,frame), maker_offset+44);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_MULTI_HEIGHT_BLANK2,frame), maker_offset+48);
// putlong_meta_raw_irq(0x1234567, maker_offset+52); // just testing
putlong_meta_raw_irq(sensor_port, get_imageParamsPast(sensor_port, P_QUALITY, frame) |
((get_imageParamsThis(sensor_port, P_PORTRAIT)&1)<<7) | // No past!
(get_imageParamsThis(sensor_port, P_CORING_INDEX)<<16), maker_offset+52); // No past!
putlong_meta_raw_irq(sensor_port, get_globalParam(sensor_port, G_TEMPERATURE01), maker_offset+56); // data should be provided by a running daemon // No past!
putlong_meta_raw_irq(sensor_port, get_globalParam(sensor_port, G_TEMPERATURE23), maker_offset+60); // No past!
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, P_QUALITY, frame) |
((get_imageParamsFrame(sensor_port, P_PORTRAIT, frame)&1)<<7) |
( get_imageParamsFrame(sensor_port, P_CORING_INDEX, frame)<<16), maker_offset+52);
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, G_TEMPERATURE01, frame), maker_offset+56); // data should be provided by a running daemon
putlong_meta_raw_irq(sensor_port, get_imageParamsFrame(sensor_port, G_TEMPERATURE23, frame), maker_offset+60);
//get_globalParam(G_TASKLET_CTL)
// left 1 long spare (+44)
}
......@@ -691,7 +684,7 @@ static irqreturn_t compressor_irq_handler(int irq, void *dev_id)
struct jpeg_ptr_t *jptr = dev_id;
struct interframe_params_t *interframe = NULL;
x393_cmprs_interrupts_t irq_ctrl;
int frame16;
// int frame16;
unsigned long flags;
local_irq_save(flags);
......@@ -703,13 +696,15 @@ static irqreturn_t compressor_irq_handler(int irq, void *dev_id)
// invalidates cache
updateIRQ_Exif(jptr, interframe); // Updates Exif data for compressed frame (separate ring buffer), extending interframe data
// interframe use: just adds meta_index
frame16 = getHardFrameNumber(jptr->chn_num, 1); // Use compressor frame number
// frame16 = getHardFrameNumber(jptr->chn_num, 1); // Use compressor frame number
// Updarte G_COMPRESSOR_FRAME (from jptr->frame, set other interframe data from past parameters (subset of all parameters preserved after the frame)
updateInterFrame(jptr->chn_num, // Sensor port number (0..3)
jptr->frame, // absolute compressed frame number, updated in updateIRQJPEG_wp
// interrupt should be processed after frame sync interrupt
interframe); // pointer to the area in circbuf to save parameters
// copies some data from old (but not pastpars) to interframe
tasklet_schedule(tasklets_compressor[jptr->chn_num]);
// wake_up_interruptible(&circbuf_wait_queue); // should be done in tasklet (after cache invalidation)
}
......
......@@ -305,7 +305,8 @@
<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>*/
#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 ///< derivative, readonly - calculated from P_BAYER and COMPMOD_BYRSH to separate sensor and compressor channels
// image page numbers depend on image size/pixel depth, so changing any of them will invalidate all pages
#define P_PAGE_ACQ 18 ///< Number of image page buffer to acquire to (0.1?) NC393: Not used ???
#define P_PAGE_READ 19 ///< Number of image page buffer to read from to (0.1?) NC393: Not used ???
......@@ -1073,7 +1074,7 @@ struct p_names_t {
P_NAME_ENTRY(TRIG), \
P_NAME_ENTRY(EXPOS), \
P_NAME_ENTRY(BGFRAME), \
P_NAME_ENTRY(IMGSZMEM), \
P_NAME_ENTRY(COMP_BAYER), \
P_NAME_ENTRY(PAGE_ACQ), \
P_NAME_ENTRY(PAGE_READ), \
P_NAME_ENTRY(OVERLAP), \
......
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