@@ -32,12 +32,12 @@ struct esp_lcd_dpi_panel_t {
3232 esp_lcd_panel_t base ; // Base class of generic lcd panel
3333 esp_lcd_dsi_bus_handle_t bus ; // DSI bus handle
3434 uint8_t virtual_channel ; // Virtual channel ID, index from 0
35- uint8_t cur_fb_index ; // Current frame buffer index
36- uint8_t num_fbs ; // Number of frame buffers
35+ uint8_t cur_fb_index ; // Current frame buffer index
36+ uint8_t num_fbs ; // Number of frame buffers
3737 uint8_t * fbs [DPI_PANEL_MAX_FB_NUM ]; // Frame buffers
3838 uint32_t h_pixels ; // Horizontal pixels
3939 uint32_t v_pixels ; // Vertical pixels
40- size_t frame_buffer_size ; // Frame buffer size
40+ size_t fb_size ; // Frame buffer size, in bytes
4141 size_t bits_per_pixel ; // Bits per pixel
4242 lcd_color_rgb_pixel_format_t pixel_format ; // RGB Pixel format
4343 dw_gdma_channel_handle_t dma_chan ; // DMA channel
@@ -126,7 +126,7 @@ static esp_err_t dpi_panel_create_dma_link(esp_lcd_dpi_panel_t *dpi_panel)
126126
127127 // create DMA link lists
128128 dw_gdma_link_list_config_t link_list_config = {
129- .num_items = DPI_PANEL_LLI_PER_FRAME ,
129+ .num_items = DPI_PANEL_MIN_DMA_NODES_PER_LINK ,
130130 .link_type = DW_GDMA_LINKED_LIST_TYPE_SINGLY ,
131131 };
132132 for (int i = 0 ; i < dpi_panel -> num_fbs ; i ++ ) {
@@ -191,21 +191,21 @@ esp_err_t esp_lcd_new_panel_dpi(esp_lcd_dsi_bus_handle_t bus, const esp_lcd_dpi_
191191 uint32_t cache_line_size = cache_hal_get_cache_line_size (CACHE_LL_LEVEL_EXT_MEM , CACHE_TYPE_DATA );
192192 // DMA doesn't have requirement on the buffer alignment, but the cache does
193193 uint32_t alignment = cache_line_size ;
194- size_t frame_buffer_size = panel_config -> video_timing .h_size * panel_config -> video_timing .v_size * bits_per_pixel / 8 ;
194+ size_t fb_size = panel_config -> video_timing .h_size * panel_config -> video_timing .v_size * bits_per_pixel / 8 ;
195195 uint8_t * frame_buffer = NULL ;
196196 for (int i = 0 ; i < num_fbs ; i ++ ) {
197- frame_buffer = heap_caps_aligned_calloc (alignment , 1 , frame_buffer_size , MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT );
197+ frame_buffer = heap_caps_aligned_calloc (alignment , 1 , fb_size , MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT );
198198 ESP_GOTO_ON_FALSE (frame_buffer , ESP_ERR_NO_MEM , err , TAG , "no memory for frame buffer" );
199199 dpi_panel -> fbs [i ] = frame_buffer ;
200200 ESP_LOGD (TAG , "fb[%d] @%p" , i , frame_buffer );
201201 // preset the frame buffer with black color
202202 // the frame buffer address alignment is ensured by `heap_caps_aligned_calloc`
203- // while the value of the frame_buffer_size may not be aligned to the cache line size
203+ // while the value of the fb_size may not be aligned to the cache line size
204204 // but that's not a problem because the `heap_caps_aligned_calloc` internally allocated a buffer whose size is aligned up to the cache line size
205- ESP_GOTO_ON_ERROR (esp_cache_msync (frame_buffer , frame_buffer_size , ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED ),
205+ ESP_GOTO_ON_ERROR (esp_cache_msync (frame_buffer , fb_size , ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED ),
206206 err , TAG , "cache write back failed" );
207207 }
208- dpi_panel -> frame_buffer_size = frame_buffer_size ;
208+ dpi_panel -> fb_size = fb_size ;
209209 dpi_panel -> bits_per_pixel = bits_per_pixel ;
210210 dpi_panel -> h_pixels = panel_config -> video_timing .h_size ;
211211 dpi_panel -> v_pixels = panel_config -> video_timing .v_size ;
@@ -282,6 +282,7 @@ esp_err_t esp_lcd_new_panel_dpi(esp_lcd_dsi_bus_handle_t bus, const esp_lcd_dpi_
282282 mipi_dsi_brg_ll_set_underrun_discard_count (hal -> bridge , panel_config -> video_timing .h_size );
283283 // use the DW_GDMA as the flow controller
284284 mipi_dsi_brg_ll_set_flow_controller (hal -> bridge , MIPI_DSI_LL_FLOW_CONTROLLER_DMA );
285+ mipi_dsi_brg_ll_set_multi_block_number (hal -> bridge , DPI_PANEL_MIN_DMA_NODES_PER_LINK );
285286 mipi_dsi_brg_ll_set_burst_len (hal -> bridge , 256 );
286287 mipi_dsi_brg_ll_set_empty_threshold (hal -> bridge , 1024 - 256 );
287288 // enable DSI bridge
@@ -381,7 +382,7 @@ static esp_err_t dpi_panel_init(esp_lcd_panel_t *panel)
381382 .burst_len = 16 ,
382383 .width = DW_GDMA_TRANS_WIDTH_64 ,
383384 },
384- .size = dpi_panel -> frame_buffer_size * 8 / 64 ,
385+ .size = dpi_panel -> fb_size * 8 / 64 ,
385386 };
386387 for (int i = 0 ; i < dpi_panel -> num_fbs ; i ++ ) {
387388 link_list = dpi_panel -> link_lists [i ];
@@ -419,7 +420,7 @@ static esp_err_t dpi_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
419420 uint8_t cur_fb_index = dpi_panel -> cur_fb_index ;
420421 uint8_t * frame_buffer = dpi_panel -> fbs [cur_fb_index ];
421422 uint8_t * draw_buffer = (uint8_t * )color_data ;
422- size_t frame_buffer_size = dpi_panel -> frame_buffer_size ;
423+ size_t fb_size = dpi_panel -> fb_size ;
423424 size_t bits_per_pixel = dpi_panel -> bits_per_pixel ;
424425
425426 // clip to boundaries
@@ -434,11 +435,11 @@ static esp_err_t dpi_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
434435 uint8_t draw_buf_fb_index = 0 ;
435436 // check if the user draw buffer resides in any frame buffer's memory range
436437 // if so, we don't need to copy the data, just do cache write back
437- if (draw_buffer >= dpi_panel -> fbs [0 ] && draw_buffer < dpi_panel -> fbs [0 ] + frame_buffer_size ) {
438+ if (draw_buffer >= dpi_panel -> fbs [0 ] && draw_buffer < dpi_panel -> fbs [0 ] + fb_size ) {
438439 draw_buf_fb_index = 0 ;
439- } else if (draw_buffer >= dpi_panel -> fbs [1 ] && draw_buffer < dpi_panel -> fbs [1 ] + frame_buffer_size ) {
440+ } else if (draw_buffer >= dpi_panel -> fbs [1 ] && draw_buffer < dpi_panel -> fbs [1 ] + fb_size ) {
440441 draw_buf_fb_index = 1 ;
441- } else if (draw_buffer >= dpi_panel -> fbs [2 ] && draw_buffer < dpi_panel -> fbs [2 ] + frame_buffer_size ) {
442+ } else if (draw_buffer >= dpi_panel -> fbs [2 ] && draw_buffer < dpi_panel -> fbs [2 ] + fb_size ) {
442443 draw_buf_fb_index = 2 ;
443444 } else {
444445 do_copy = true;
0 commit comments