Commit 0b49b265 authored by Mikhail Karpenko's avatar Mikhail Karpenko

WIP: update circbuf_lseek code

parent 69517989
This diff is collapsed.
......@@ -34,4 +34,12 @@ extern wait_queue_head_t circbuf_wait_queue;
extern unsigned long *ccam_dma_buf_ptr;
//unsigned long *circbuf_get_ccam_ptr(void);
// private data
struct circbuf_priv_t {
int minor;
unsigned long *buf_ptr;
dma_addr_t phys_addr;
};
extern struct circbuf_priv_t *circbuf_priv_ptr;
#endif /* _CIRCBUF_H */
......@@ -290,21 +290,31 @@ inline void updateIRQFocus(struct jpeg_ptr_t *jptr)
* @return pointer to interframe parameters structure
*/
inline struct interframe_params_t* updateIRQ_interframe(struct jpeg_ptr_t *jptr) {
int circbuf_size=get_globalParam (G_CIRCBUFSIZE)>>2;
int alen = JPEG_wp-9; if (alen<0) alen+=circbuf_size;
int jpeg_len=ccam_dma_buf_ptr[alen] & 0xffffff;
set_globalParam(G_FRAME_SIZE,jpeg_len);
int aframe_params=(alen & 0xfffffff8)-
(((jpeg_len + CCAM_MMAP_META + 3) & 0xffffffe0)>>2) /// multiple of 32-byte chunks to subtract
-8; /// size of the storage area to be filled before the frame
if(aframe_params < 0) aframe_params += circbuf_size;
struct interframe_params_t* interframe= (struct interframe_params_t*) &ccam_dma_buf_ptr[aframe_params];
/// should we use memcpy as before here?
interframe->frame_length=jpeg_len;
interframe->signffff=0xffff;
#if ELPHEL_DEBUG_THIS
set_globalParam (0x306,get_globalParam (0x306)+1);
#endif
// int circbuf_size=get_globalParam (G_CIRCBUFSIZE)>>2;
// int alen = JPEG_wp-9; if (alen<0) alen+=circbuf_size;
// int jpeg_len=ccam_dma_buf_ptr[alen] & 0xffffff;
// set_globalParam(G_FRAME_SIZE,jpeg_len);
// int aframe_params=(alen & 0xfffffff8)-
// (((jpeg_len + CCAM_MMAP_META + 3) & 0xffffffe0)>>2) /// multiple of 32-byte chunks to subtract
// -8; /// size of the storage area to be filled before the frame
// if(aframe_params < 0) aframe_params += circbuf_size;
// struct interframe_params_t* interframe= (struct interframe_params_t*) &ccam_dma_buf_ptr[aframe_params];
///// should we use memcpy as before here?
// interframe->frame_length=jpeg_len;
// interframe->signffff=0xffff;
//#if ELPHEL_DEBUG_THIS
// set_globalParam (0x306,get_globalParam (0x306)+1);
//#endif
struct interframe_params_t *interframe;
int circbuf_size = BYTE2DW(get_globalParam(G_CIRCBUFSIZE));
int len_offset = X313_BUFFSUB(jptr->jpeg_wp, 8);
int len32 = circbuf_priv_ptr[jptr->chn_num].buf_ptr[len_offset] & FRAME_LENGTH_MASK;
int frame_params_offset = X313_BUFFSUB(jptr->jpeg_wp, INTERFRAME_PARAMS_SZ);
interframe = (struct interframe_params_t *) &circbuf_priv_ptr[jptr->chn_num].buf_ptr[frame_params_offset];
interframe->frame_length = len32;
set_globalParam(G_FRAME_SIZE, len32);
return interframe;
}
......
......@@ -16,7 +16,9 @@
/** @brief The size of #interframe_params_t structure in double words */
#define INTERFRAME_PARAMS_SZ 8
#define MARKER_FF 0xff
#define MARKER_FF 0xff000000
#define FRAME_LENGTH_MASK 0xffffff
#define IRQ_NOP 0
#define IRQ_CLEAR 1
......
......@@ -1611,11 +1611,46 @@ struct sensorproc_t {
/// signffff
/// timestamp_sec (camogm only, exif is separate)
/// timestamp_usec (camogm only, exif is separate)
//struct interframe_params_t {
///// This data will survive as long as the frame itself in the circular buffer. Some other fields (like exposure) are stored in Exif
///// dont move - should partially match P_* area
// union{unsigned long hash32_r; struct{unsigned short scale_r; union {unsigned short hash16_r; struct{unsigned char gamma_r; unsigned char black_r; };};};}; ///00-03
// union{unsigned long hash32_g; struct{unsigned short scale_g; union {unsigned short hash16_g; struct{unsigned char gamma_g; unsigned char black_g; };};};}; ///04-07
// union{unsigned long hash32_gb;struct{unsigned short scale_gb;union {unsigned short hash16_gb;struct{unsigned char gamma_gb;unsigned char black_gb;};};};}; ///08-11
// union{unsigned long hash32_b; struct{unsigned short scale_b; union {unsigned short hash16_b; struct{unsigned char gamma_b; unsigned char black_b; };};};}; ///12-15
// unsigned short quality2; /// Quality is represented by 2-byte value. Each byte uses Y table if the value is Q<128,// 16-17
// /// and C table with (Q-128) if it is Q>=128.
// /// If the High byte is zero, it is treated as Q^0x80 (Q|=(Q^0x80)<<8) for compatibility
// /// with a standard single-byte Q value
///// updated in 8.0.8.37 - bit 7 in quality2 means "portrait mode"
// unsigned char color; /// color mode //18
// unsigned char byrshift; /// bayer shift in compressor //19
// unsigned short width; /// frame width, pixels 20-21 - NOTE: should be 20-21
// unsigned short height; /// frame height, pixels 22-23
//
///*24 *//// unsigned char bindec_hor; //! ((bh-1) << 4) | (dh-1) & 0xf (binning/decimation horizontal, 1..16 for each)
///*25 *//// unsigned char bindec_vert; //! ((bv-1) << 4) | (dv-1) & 0xf (binning/decimation vertical , 1..16 for each)
///*24-25*/ unsigned short meta_index; //! index of the linked meta page
//
///*26-27*/ unsigned short signffff; //! should be 0xffff - it will be a signature that JPEG data was not overwritten,
// //! JPEG bitstream can not have two 0xff after each other
// union {
///*28-31*/ unsigned long timestamp_sec ; //! number of seconds since 1970 till the start of the frame exposure
///*28-31*/ unsigned long frame_length ; //! JPEG frame length in circular buffer, bytes
// };
///*32-35*/ unsigned long timestamp_usec; //! number of microseconds to add
//};
/* Some fields were rearranged to make old code happy, this should to be fixed
* Last three double words contain time stamp and (length+0xff) marker in new camera
*/
struct interframe_params_t {
/// This data will survive as long as the frame itself in the circular buffer. Some other fields (like exposure) are stored in Exif
/// dont move - should partially match P_* area
union {
union{unsigned long hash32_r; struct{unsigned short scale_r; union {unsigned short hash16_r; struct{unsigned char gamma_r; unsigned char black_r; };};};}; ///00-03
union{unsigned long hash32_g; struct{unsigned short scale_g; union {unsigned short hash16_g; struct{unsigned char gamma_g; unsigned char black_g; };};};}; ///04-07
};
union{unsigned long hash32_gb;struct{unsigned short scale_gb;union {unsigned short hash16_gb;struct{unsigned char gamma_gb;unsigned char black_gb;};};};}; ///08-11
union{unsigned long hash32_b; struct{unsigned short scale_b; union {unsigned short hash16_b; struct{unsigned char gamma_b; unsigned char black_b; };};};}; ///12-15
unsigned short quality2; /// Quality is represented by 2-byte value. Each byte uses Y table if the value is Q<128,// 16-17
......@@ -1630,15 +1665,23 @@ struct interframe_params_t {
/*24 *//// unsigned char bindec_hor; //! ((bh-1) << 4) | (dh-1) & 0xf (binning/decimation horizontal, 1..16 for each)
/*25 *//// unsigned char bindec_vert; //! ((bv-1) << 4) | (dv-1) & 0xf (binning/decimation vertical , 1..16 for each)
/*24-25*/ unsigned short meta_index; //! index of the linked meta page
/*24-25*/ unsigned long meta_index; //! index of the linked meta page
/*26-27*/ unsigned short signffff; //! should be 0xffff - it will be a signature that JPEG data was not overwritten,
//! JPEG bitstream can not have two 0xff after each other
union {
union {
/*28-31*/ unsigned long timestamp_sec ; //! number of seconds since 1970 till the start of the frame exposure
/*28-31*/ unsigned long frame_length ; //! JPEG frame length in circular buffer, bytes
};
/*28-31*/ unsigned long frame_length; //! JPEG frame length in circular buffer, bytes
};
/*32-35*/ unsigned long timestamp_usec; //! number of microseconds to add
union {
unsigned long len32; //! should be 0xffxxyyzz - it will be a signature that JPEG data was not overwritten,
//! xxyyzz here is the length in 32 double words;
struct {
unsigned char pad0; // pad double word with 3 bytes and use only most significant byte as 0xff marker
unsigned char pad1;
unsigned char pad2;
unsigned char signffff;
};
};
};
struct i2c_timing_t {
......
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