Enable double buffering

Doesn't work though with new refactored code on S3 device - do not use...
This commit is contained in:
mrfaptastic 2022-09-30 11:31:53 +01:00
parent 2db8f26659
commit 30f0014b0c
4 changed files with 66 additions and 11 deletions

View file

@ -98,6 +98,9 @@ bool MatrixPanel_I2S_DMA::allocateDMAmemory()
// malloc the DMA linked list descriptors that i2s_parallel will need // malloc the DMA linked list descriptors that i2s_parallel will need
desccount = numDMAdescriptorsPerRow * ROWS_PER_FRAME; desccount = numDMAdescriptorsPerRow * ROWS_PER_FRAME;
if (m_cfg.double_buff)
dma_bus.enable_double_dma_desc();
dma_bus.allocate_dma_desc_memory(desccount); dma_bus.allocate_dma_desc_memory(desccount);
/* /*

View file

@ -564,6 +564,9 @@ static void IRAM_ATTR irq_hndlr(void* arg) { // if we use I2S1 (default)
_dmadesc_a[_dmadesc_count-1].qe.stqe_next = &_dmadesc_a[0]; _dmadesc_a[_dmadesc_count-1].qe.stqe_next = &_dmadesc_a[0];
_dmadesc_b[_dmadesc_count-1].qe.stqe_next = &_dmadesc_a[0]; _dmadesc_b[_dmadesc_count-1].qe.stqe_next = &_dmadesc_a[0];
} }
_dmadesc_a_active ^= _dmadesc_a_active;
} // end flip } // end flip

View file

@ -269,7 +269,7 @@
void Bus_Parallel16::enable_double_dma_desc(void) void Bus_Parallel16::enable_double_dma_desc(void)
{ {
//_double_dma_buffer = true; _double_dma_buffer = true;
} }
// Need this to work for double buffers etc. // Need this to work for double buffers etc.
@ -288,8 +288,20 @@
return false; return false;
} }
if (_double_dma_buffer)
{
_dmadesc_b= (HUB75_DMA_DESCRIPTOR_T*)heap_caps_malloc(sizeof(HUB75_DMA_DESCRIPTOR_T) * len, MALLOC_CAP_DMA);
if (_dmadesc_b == nullptr)
{
ESP_LOGE(TAG, "ERROR: Couldn't malloc _dmadesc_b. Not enough memory.");
_double_dma_buffer = false;
}
}
_dmadesc_a_idx = 0; _dmadesc_a_idx = 0;
// _dmadesc_b_idx = 0; _dmadesc_b_idx = 0;
return true; return true;
@ -311,6 +323,29 @@
return; return;
} }
if (_double_dma_buffer == true && dmadesc_b == true)
{
_dmadesc_b[_dmadesc_b_idx].dw0.owner = DMA_DESCRIPTOR_BUFFER_OWNER_DMA;
_dmadesc_b[_dmadesc_b_idx].dw0.suc_eof = 0;
_dmadesc_b[_dmadesc_b_idx].dw0.size = _dmadesc_b[_dmadesc_b_idx].dw0.length = size; //sizeof(data);
_dmadesc_b[_dmadesc_b_idx].buffer = data; //data;
if (_dmadesc_b_idx == _dmadesc_count-1) {
_dmadesc_b[_dmadesc_b_idx].next = (dma_descriptor_t *) &_dmadesc_b[0];
}
else {
_dmadesc_b[_dmadesc_b_idx].next = (dma_descriptor_t *) &_dmadesc_b[_dmadesc_b_idx+1];
}
_dmadesc_b_idx++;
}
else
{
_dmadesc_a[_dmadesc_a_idx].dw0.owner = DMA_DESCRIPTOR_BUFFER_OWNER_DMA; _dmadesc_a[_dmadesc_a_idx].dw0.owner = DMA_DESCRIPTOR_BUFFER_OWNER_DMA;
_dmadesc_a[_dmadesc_a_idx].dw0.suc_eof = 0; _dmadesc_a[_dmadesc_a_idx].dw0.suc_eof = 0;
_dmadesc_a[_dmadesc_a_idx].dw0.size = _dmadesc_a[_dmadesc_a_idx].dw0.length = size; //sizeof(data); _dmadesc_a[_dmadesc_a_idx].dw0.size = _dmadesc_a[_dmadesc_a_idx].dw0.length = size; //sizeof(data);
@ -326,6 +361,8 @@
_dmadesc_a_idx++; _dmadesc_a_idx++;
}
} // end create_dma_desc_link } // end create_dma_desc_link
void Bus_Parallel16::dma_transfer_start() void Bus_Parallel16::dma_transfer_start()
@ -350,6 +387,22 @@
void Bus_Parallel16::flip_dma_output_buffer() void Bus_Parallel16::flip_dma_output_buffer()
{ {
if ( _double_dma_buffer == false) return;
if ( _dmadesc_a_active == true) // change across to everything 'b''
{
_dmadesc_a[_dmadesc_count-1].next = (dma_descriptor_t *) &_dmadesc_b[0];
_dmadesc_b[_dmadesc_count-1].next = (dma_descriptor_t *) &_dmadesc_b[0];
}
else
{
_dmadesc_a[_dmadesc_count-1].next = (dma_descriptor_t *) &_dmadesc_a[0];
_dmadesc_b[_dmadesc_count-1].next = (dma_descriptor_t *) &_dmadesc_a[0];
}
_dmadesc_a_active ^= _dmadesc_a_active;
} // end flip } // end flip

View file

@ -157,15 +157,11 @@
HUB75_DMA_DESCRIPTOR_T* _dmadesc_a = nullptr; HUB75_DMA_DESCRIPTOR_T* _dmadesc_a = nullptr;
// uint32_t _clock_reg_value; bool _double_dma_buffer = false;
// uint32_t _fast_wait = 0; bool _dmadesc_a_active = true;
uint32_t _dmadesc_b_idx = 0;
//bool _double_dma_buffer = false; HUB75_DMA_DESCRIPTOR_T* _dmadesc_b = nullptr;
//bool _dmadesc_a_active = true;
//uint32_t _dmadesc_b_idx = 0;
//HUB75_DMA_DESCRIPTOR_T* _dmadesc_b = nullptr;
esp_lcd_i80_bus_handle_t _i80_bus; esp_lcd_i80_bus_handle_t _i80_bus;