octoi: Fix frame_rifo_depth() function
We use the 'correct' math in frame_rifo_depth now so the count is accurate down to zero. We need to fixup the logic that drags the 'write pointer' (last_in_fn) along when reading from an empty FIFO. We also need proper init (which was missing alltogether beforehand). Change-Id: I088f181e74358eb2c96a7aab7a7c875b9276d980 Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
parent
ce817ca149
commit
d413cbcb4b
|
@ -97,6 +97,7 @@ void frame_rifo_init(struct frame_rifo *rifo)
|
|||
memset(rifo->buf, 0xff, sizeof(rifo->buf));
|
||||
rifo->next_out = rifo->buf;
|
||||
rifo->next_out_fn = 0;
|
||||
rifo->last_in_fn = -1;
|
||||
memset(rifo->bitvec, 0, sizeof(rifo->bitvec));
|
||||
}
|
||||
|
||||
|
@ -151,10 +152,11 @@ int frame_rifo_out(struct frame_rifo *rifo, uint8_t *out)
|
|||
if (rifo->next_out >= RIFO_BUF_END(rifo))
|
||||
rifo->next_out -= sizeof(rifo->buf);
|
||||
|
||||
/* if we're empty we 'drag' last_in along to avoid overflows */
|
||||
if (frame_rifo_depth(rifo) == 0)
|
||||
rifo->last_in_fn += 1;
|
||||
|
||||
rifo->next_out_fn += 1;
|
||||
/* make sure that frame_rifo_depth() doing last_in - next_out won't overflow */
|
||||
if (rifo->next_out_fn == rifo->last_in_fn + 1)
|
||||
rifo->last_in_fn = rifo->next_out_fn;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ static inline bool frame_rifo_fn_in_range(const struct frame_rifo *ff, uint32_t
|
|||
/* current depth of RIFO */
|
||||
static inline unsigned int frame_rifo_depth(struct frame_rifo *rifo)
|
||||
{
|
||||
return rifo->last_in_fn - rifo->next_out_fn;
|
||||
return rifo->last_in_fn - rifo->next_out_fn + 1;
|
||||
}
|
||||
|
||||
void frame_rifo_init(struct frame_rifo *rifo);
|
||||
|
|
Loading…
Reference in New Issue