feat(drivers/st_ltdc): add rotation support to LTDC driver (#7254)

This commit is contained in:
Liam
2024-12-02 04:05:43 +01:00
committed by GitHub
parent 63ac1cec9b
commit a87a28bcd4
2 changed files with 48 additions and 23 deletions

View File

@@ -81,6 +81,20 @@ Providing a second partial buffer can improve CPU utilization and increase
performance compared to
a single buffer if :c:macro:`LV_ST_LTDC_USE_DMA2D_FLUSH` is enabled.
Display Rotation
****************
The driver supports display rotation with
:cpp:expr:`lv_display_set_rotation(disp, rotation)` where rotation is one of
:cpp:enumerator:`LV_DISP_ROTATION_90`, :cpp:enumerator:`LV_DISP_ROTATION_180`,
or :cpp:enumerator:`LV_DISP_ROTATION_270`. The rotation is initially
:cpp:enumerator:`LV_DISP_ROTATION_0`.
The rotation is done in software and only works if the display was
created using :cpp:func:`lv_st_ltdc_create_partial`.
:c:macro:`LV_ST_LTDC_USE_DMA2D_FLUSH` will be have no effect if rotation
is used.
DMA2D
*****

View File

@@ -12,6 +12,7 @@
#include "lv_st_ltdc.h"
#include "../../../display/lv_display_private.h"
#include "../../../draw/sw/lv_draw_sw.h"
#include "ltdc.h"
#if LV_ST_LTDC_USE_DMA2D_FLUSH
@@ -154,16 +155,20 @@ static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_m
LTDC_LayerCfgTypeDef * layer_cfg = &hltdc.LayerCfg[layer_idx];
lv_color_format_t cf = lv_display_get_color_format(disp);
int32_t disp_width = lv_display_get_horizontal_resolution(disp);
int32_t disp_width = disp->hor_res;
uint8_t * fb = (uint8_t *) layer_cfg->FBStartAdress;
uint32_t px_size = lv_color_format_get_size(cf);
uint32_t fb_stride = px_size * disp_width;
uint8_t * first_pixel = fb + fb_stride * area->y1 + px_size * area->x1;
lv_area_t rotated_area = *area;
lv_display_rotate_area(disp, &rotated_area);
uint8_t * first_pixel = fb + fb_stride * rotated_area.y1 + px_size * rotated_area.x1;
int32_t area_width = lv_area_get_width(area);
int32_t area_height = lv_area_get_height(area);
lv_display_rotation_t rotation = lv_display_get_rotation(disp);
if(rotation == LV_DISPLAY_ROTATION_0) {
#if LV_ST_LTDC_USE_DMA2D_FLUSH
uint32_t dma2d_input_cf = get_dma2d_input_cf_from_lv_cf(cf);
uint32_t dma2d_output_cf = get_dma2d_output_cf_from_layer_cf(layer_cfg->PixelFormat);
@@ -190,6 +195,12 @@ static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_m
g_data.disp_flushed_in_flush_cb[layer_idx] = true;
#endif
}
else {
uint32_t area_stride = px_size * area_width;
lv_draw_sw_rotate(px_map, first_pixel, area_width, area_height, area_stride, fb_stride, rotation, cf);
g_data.disp_flushed_in_flush_cb[layer_idx] = true;
}
}
}
static void flush_wait_cb(lv_display_t * disp)