Commit a93c7321 authored by Andrey Filippov's avatar Andrey Filippov

fixing circbuf pointers

parent bb96d648
...@@ -658,7 +658,7 @@ loff_t circbuf_lseek(struct file * file, loff_t offset, int orig) { ...@@ -658,7 +658,7 @@ loff_t circbuf_lseek(struct file * file, loff_t offset, int orig) {
case LSEEK_CIRC_FIRST: case LSEEK_CIRC_FIRST:
case LSEEK_CIRC_SCND: case LSEEK_CIRC_SCND:
//! Starting from the write pointer do be able to count all the frames in the buffer //! Starting from the write pointer do be able to count all the frames in the buffer
rp=camSeqGetJPEG_wp(chn); rp=camSeqGetJPEG_wp(chn); // 32-bit words, not byte address
prev_p=rp; prev_p=rp;
preprev_p=prev_p; // for second preprev_p=prev_p; // for second
nf=0; nf=0;
......
...@@ -191,12 +191,12 @@ int camseq_get_jpeg_rp(unsigned int chn) ...@@ -191,12 +191,12 @@ int camseq_get_jpeg_rp(unsigned int chn)
return (chn < SENSOR_PORTS) ? image_acq_priv.jpeg_ptr[chn].jpeg_rp : 0; return (chn < SENSOR_PORTS) ? image_acq_priv.jpeg_ptr[chn].jpeg_rp : 0;
} }
void camseq_set_jpeg_rp(unsigned int chn, int ptr) void camseq_set_jpeg_rp(unsigned int chn, int ptr) // ptr in bytes
{ {
if (chn < SENSOR_PORTS) { if (chn < SENSOR_PORTS) {
image_acq_priv.jpeg_ptr[chn].jpeg_rp = ptr; image_acq_priv.jpeg_ptr[chn].jpeg_rp = ptr >> 2;
set_globalParam(chn, G_CIRCBUFRP, ptr); set_globalParam(chn, G_CIRCBUFRP, ptr); // in bytes (same as in 353)
set_globalParam(chn, G_FREECIRCBUF, set_globalParam(chn, G_FREECIRCBUF,
(((get_globalParam(chn, G_CIRCBUFRP) <= get_globalParam(chn, G_CIRCBUFWP))? (((get_globalParam(chn, G_CIRCBUFRP) <= get_globalParam(chn, G_CIRCBUFWP))?
get_globalParam(chn, G_CIRCBUFSIZE):0)+ get_globalParam(chn, G_CIRCBUFRP)) get_globalParam(chn, G_CIRCBUFSIZE):0)+ get_globalParam(chn, G_CIRCBUFRP))
...@@ -215,7 +215,7 @@ int camSeqGetJPEG_wp(unsigned int chn) ...@@ -215,7 +215,7 @@ int camSeqGetJPEG_wp(unsigned int chn)
return (chn < SENSOR_PORTS) ? image_acq_priv.jpeg_ptr[chn].jpeg_wp : 0; return (chn < SENSOR_PORTS) ? image_acq_priv.jpeg_ptr[chn].jpeg_wp : 0;
} }
int camSeqGetJPEG_rp(unsigned int chn) int camSeqGetJPEG_rp(unsigned int chn) // return in DWORDs, not in bytes
{ {
return (chn < SENSOR_PORTS) ? image_acq_priv.jpeg_ptr[chn].jpeg_rp : 0; return (chn < SENSOR_PORTS) ? image_acq_priv.jpeg_ptr[chn].jpeg_rp : 0;
} }
...@@ -225,9 +225,11 @@ void camSeqSetJPEG_rp(unsigned int chn, ///< channel (0..3) ...@@ -225,9 +225,11 @@ void camSeqSetJPEG_rp(unsigned int chn, ///< channel (0..3)
{ {
if (chn < SENSOR_PORTS) { if (chn < SENSOR_PORTS) {
image_acq_priv.jpeg_ptr[chn].jpeg_rp = ptr << 2; // image_acq_priv.jpeg_ptr[chn].jpeg_rp = ptr << 2;
image_acq_priv.jpeg_ptr[chn].jpeg_rp = ptr ;
set_globalParam(chn, G_CIRCBUFRP, ptr); // set_globalParam(chn, G_CIRCBUFRP, ptr); // wrong! should be in bytes
set_globalParam(chn, G_CIRCBUFRP, ptr << 2); // this is as in nc353
set_globalParam(chn, G_FREECIRCBUF, set_globalParam(chn, G_FREECIRCBUF,
(((get_globalParam(chn, G_CIRCBUFRP) <= get_globalParam(chn, G_CIRCBUFWP))? (((get_globalParam(chn, G_CIRCBUFRP) <= get_globalParam(chn, G_CIRCBUFWP))?
get_globalParam(chn, G_CIRCBUFSIZE):0)+ get_globalParam(chn, G_CIRCBUFRP)) get_globalParam(chn, G_CIRCBUFSIZE):0)+ get_globalParam(chn, G_CIRCBUFRP))
...@@ -392,7 +394,9 @@ inline void update_irq_circbuf(struct jpeg_ptr_t *jptr) { ...@@ -392,7 +394,9 @@ inline void update_irq_circbuf(struct jpeg_ptr_t *jptr) {
/*set_globalParam (G_CIRCBUFWP, JPEG_wp<<2);set_globalParam (G_FREECIRCBUF, (((get_globalParam (G_CIRCBUFRP) <= get_globalParam (G_CIRCBUFWP))? get_globalParam (G_CIRCBUFSIZE):0)+ /*set_globalParam (G_CIRCBUFWP, JPEG_wp<<2);set_globalParam (G_FREECIRCBUF, (((get_globalParam (G_CIRCBUFRP) <= get_globalParam (G_CIRCBUFWP))? get_globalParam (G_CIRCBUFSIZE):0)+
get_globalParam (G_CIRCBUFRP)) - get_globalParam (G_CIRCBUFWP));*/ get_globalParam (G_CIRCBUFRP)) - get_globalParam (G_CIRCBUFWP));*/
/* the concept of global parameters will be changed, use one channel only for testing */ /* the concept of global parameters will be changed, use one channel only for testing */
set_globalParam(jptr->chn_num, G_CIRCBUFWP, jptr->jpeg_wp); // set_globalParam(jptr->chn_num, G_CIRCBUFWP, jptr->jpeg_wp);
set_globalParam(jptr->chn_num, G_CIRCBUFWP, jptr->jpeg_wp << 2); // jptr->jpeg_wp in 32-bit words, G_CIRCBUFWP - in bytes
set_globalParam (jptr->chn_num, G_FREECIRCBUF, set_globalParam (jptr->chn_num, G_FREECIRCBUF,
(((get_globalParam (jptr->chn_num, G_CIRCBUFRP) <= get_globalParam (jptr->chn_num, G_CIRCBUFWP))?get_globalParam (jptr->chn_num, G_CIRCBUFSIZE):0)+ (((get_globalParam (jptr->chn_num, G_CIRCBUFRP) <= get_globalParam (jptr->chn_num, G_CIRCBUFWP))?get_globalParam (jptr->chn_num, G_CIRCBUFSIZE):0)+
get_globalParam (jptr->chn_num, G_CIRCBUFRP)) - get_globalParam (jptr->chn_num, G_CIRCBUFWP)); get_globalParam (jptr->chn_num, G_CIRCBUFRP)) - get_globalParam (jptr->chn_num, G_CIRCBUFWP));
...@@ -1002,6 +1006,8 @@ void trigger_restart(void) ...@@ -1002,6 +1006,8 @@ void trigger_restart(void)
{ {
u32 period = get_x393_camsync_trig_period(); u32 period = get_x393_camsync_trig_period();
if (!(period & ~31)) period = 1; // if 0 or bit length setup if (!(period & ~31)) period = 1; // if 0 or bit length setup
period = 1; // make it always single/not changing any P_*
set_x393_camsync_trig_period(period); set_x393_camsync_trig_period(period);
dev_dbg(g_dev_ptr, "Reset trigger period in immediate mode = %d (0x%x)\n", (int) period, (int) period); dev_dbg(g_dev_ptr, "Reset trigger period in immediate mode = %d (0x%x)\n", (int) period, (int) period);
} }
......
...@@ -36,7 +36,7 @@ void camseq_set_jpeg_rp(unsigned int chn, int ptr); ...@@ -36,7 +36,7 @@ void camseq_set_jpeg_rp(unsigned int chn, int ptr);
int camSeqGetJPEG_frame(unsigned int chn); int camSeqGetJPEG_frame(unsigned int chn);
// DWORD I/O, same as in NC353 // DWORD I/O, same as in NC353, but was an error later
int camSeqGetJPEG_wp (unsigned int chn); int camSeqGetJPEG_wp (unsigned int chn);
int camSeqGetJPEG_rp (unsigned int chn); int camSeqGetJPEG_rp (unsigned int chn);
void camSeqSetJPEG_rp(unsigned int chn, int ptr); void camSeqSetJPEG_rp(unsigned int chn, int ptr);
......
...@@ -687,7 +687,9 @@ ...@@ -687,7 +687,9 @@
#define FRAMEPAR_GLOBALS 0x01000 ///< start of global (not frame-related) parameters #define FRAMEPAR_GLOBALS 0x01000 ///< start of global (not frame-related) parameters
#define GLOBALS_PRESERVE 0x20 /// number of parameters that are not erased during initGlobalPars //#define GLOBALS_PRESERVE 0x20 /// number of parameters that are not erased during initGlobalPars
#define GLOBALS_PRESERVE 0x26 /// number of parameters that are not erased during initGlobalPars - include G_CIRCBUFSIZE ==+37 (or move it)
//G_CIRCBUFSIZE
#define GLOBALPARS(p, x) (aglobalPars[p][(x)-FRAMEPAR_GLOBALS]) ///< should work in drivers and applications, First 32 parameter values are not erased with initGlobalPars #define GLOBALPARS(p, x) (aglobalPars[p][(x)-FRAMEPAR_GLOBALS]) ///< should work in drivers and applications, First 32 parameter values are not erased with initGlobalPars
#define GLOBALPARS_SNGL(x) (globalPars[(x)-FRAMEPAR_GLOBALS]) ///< for applications that use just one port #define GLOBALPARS_SNGL(x) (globalPars[(x)-FRAMEPAR_GLOBALS]) ///< for applications that use just one port
......
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