lib: fix idle line bug

After the recent change pipelining over three DMA transfers,
we obviously need two different idle line buffers, otherwise
the the metadata in the idle line currently in flight will
be overwritten in case we have two idle lines in a row.
When utilizing the full data rate, this cannot be observed,
as there won't be two idle lines in a row.
This commit is contained in:
Steve Markgraf 2024-12-27 22:18:44 +01:00
parent bae93b3a87
commit 07d3f58650

View file

@ -68,7 +68,8 @@
#define HSTX_CMD_NOP (0xfu << 12)
uint16_t *ring_buf = NULL;
uint16_t idle_line_buf[MODE_H_ACTIVE_PIXELS];
uint16_t idle_line_buf1[MODE_H_ACTIVE_PIXELS];
uint16_t idle_line_buf2[MODE_H_ACTIVE_PIXELS];
uint32_t info_p[64];
uint32_t info_len;
@ -232,10 +233,11 @@ void __scratch_x("") hstx_dma_irq_handler()
/* Output of actual data in active video lines */
uint16_t *next_line;
int next_tail = (fifo_tail + 1) % RBUF_SLICES;
uint16_t cur_active_line = v_scanline - (MODE_V_TOTAL_LINES - MODE_V_ACTIVE_LINES);
if (fifo_head == next_tail) {
/* No data to send, use idle line */
next_line = idle_line_buf;
next_line = (cur_active_line % 2) ? idle_line_buf1 : idle_line_buf2;
next_line[RBUF_SLICE_LEN - 1] = 0;
} else {
next_line = &ring_buf[fifo_tail * RBUF_SLICE_LEN];
@ -243,8 +245,6 @@ void __scratch_x("") hstx_dma_irq_handler()
next_line[RBUF_SLICE_LEN - 1] = RBUF_DATA_LEN;
}
uint16_t cur_active_line = v_scanline - (MODE_V_TOTAL_LINES - MODE_V_ACTIVE_LINES);
/* fill in metadata word (last word of line) */
if (cur_active_line < (sizeof(metadata_t) * 2)) {
uint8_t *met_p = (uint8_t *)&metadata;