mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
refactor(gdma): increase performance and optimize api
This commit is contained in:
committed by
Chen Ji Chang
parent
305d434bda
commit
bd2d64bffb
@@ -33,7 +33,6 @@ static inline void rmt_rx_mount_dma_buffer(rmt_rx_channel_t *rx_chan, const void
|
||||
.buffer_alignment = mem_alignment,
|
||||
.flags = {
|
||||
.mark_final = GDMA_FINAL_LINK_TO_DEFAULT,
|
||||
.check_size_align = gdma_is_size_alignment_required(rx_chan->base.dma_chan),
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -63,9 +62,9 @@ static esp_err_t rmt_rx_init_dma_link(rmt_rx_channel_t *rx_channel, const rmt_rx
|
||||
ESP_RETURN_ON_ERROR(gdma_register_rx_event_callbacks(rx_channel->base.dma_chan, &cbs, rx_channel), TAG, "register DMA callbacks failed");
|
||||
|
||||
// get the alignment requirement from DMA
|
||||
size_t dma_int_mem_alignment = 0, dma_ext_mem_alignment = 0;
|
||||
gdma_get_channel_alignment_constraints(rx_channel->base.dma_chan, &dma_int_mem_alignment, &dma_ext_mem_alignment, NULL);
|
||||
size_t buffer_alignment = MAX(dma_int_mem_alignment, dma_ext_mem_alignment);
|
||||
gdma_channel_alignment_info_t align_info;
|
||||
gdma_get_channel_alignment_constraints(rx_channel->base.dma_chan, &align_info);
|
||||
size_t buffer_alignment = MAX(align_info.int_mem_alignment, align_info.ext_enc_mem_alignment);
|
||||
rx_channel->num_dma_nodes = esp_dma_calculate_node_count(config->mem_block_symbols * sizeof(rmt_symbol_word_t),
|
||||
buffer_alignment, DMA_DESCRIPTOR_BUFFER_MAX_SIZE);
|
||||
rx_channel->num_dma_nodes = MAX(2, rx_channel->num_dma_nodes); // at least 2 DMA nodes for ping-pong
|
||||
|
||||
@@ -53,9 +53,10 @@ static esp_err_t rmt_tx_init_dma_link(rmt_tx_channel_t *tx_channel, const rmt_tx
|
||||
// register the DMA callbacks may fail if the interrupt service can not be installed successfully
|
||||
ESP_RETURN_ON_ERROR(gdma_register_tx_event_callbacks(tx_channel->base.dma_chan, &cbs, tx_channel), TAG, "register DMA callbacks failed");
|
||||
|
||||
size_t int_alignment = 0;
|
||||
gdma_channel_alignment_info_t align_info;
|
||||
// get the alignment requirement from DMA
|
||||
gdma_get_channel_alignment_constraints(tx_channel->base.dma_chan, &int_alignment, NULL, NULL);
|
||||
gdma_get_channel_alignment_constraints(tx_channel->base.dma_chan, &align_info);
|
||||
size_t int_alignment = align_info.int_mem_alignment;
|
||||
// apply RMT hardware alignment requirement
|
||||
int_alignment = MAX(int_alignment, sizeof(rmt_symbol_word_t));
|
||||
// the memory returned by `heap_caps_aligned_calloc` also meets the cache alignment requirement (both address and size)
|
||||
|
||||
Reference in New Issue
Block a user