1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

lv_disp: add clean_dcache_cb callback

This commit is contained in:
Themba Dube 2020-08-21 09:52:13 -04:00
parent 001fabbb18
commit 24c2921c21
4 changed files with 29 additions and 14 deletions

View File

@ -352,6 +352,21 @@ void lv_disp_trig_activity(lv_disp_t * disp)
disp->last_activity_time = lv_tick_get(); disp->last_activity_time = lv_tick_get();
} }
/**
* Invalidate any CPU cache that is related to the display.
* @param disp pointer to an display (NULL to use the default display)
*/
void lv_disp_invalidate_cache(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("lv_disp_invalidate_cache: no display registered");
return;
}
if(disp->driver.clean_dcache_cb)
disp->driver.clean_dcache_cb(&disp->driver);
}
/** /**
* Get a pointer to the screen refresher task to * Get a pointer to the screen refresher task to

View File

@ -133,6 +133,12 @@ uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp);
*/ */
void lv_disp_trig_activity(lv_disp_t * disp); void lv_disp_trig_activity(lv_disp_t * disp);
/**
* Invalidate any CPU cache that is related to the display.
* @param disp pointer to an display (NULL to use the default display)
*/
void lv_disp_invalidate_cache(lv_disp_t * disp);
/** /**
* Get a pointer to the screen refresher task to * Get a pointer to the screen refresher task to
* modify its parameters with `lv_task_...` functions. * modify its parameters with `lv_task_...` functions.

View File

@ -7,6 +7,7 @@
* INCLUDES * INCLUDES
*********************/ *********************/
#include "lv_gpu_stm32_dma2d.h" #include "lv_gpu_stm32_dma2d.h"
#include "../lv_core/lv_disp.h"
#include "../lv_core/lv_refr.h" #include "../lv_core/lv_refr.h"
#if LV_USE_GPU_STM32_DMA2D #if LV_USE_GPU_STM32_DMA2D
@ -41,7 +42,6 @@
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void invalidate_cache(void);
static void dma2d_wait(void); static void dma2d_wait(void);
/********************** /**********************
@ -82,7 +82,7 @@ void lv_gpu_stm32_dma2d_init(void)
*/ */
void lv_gpu_stm32_dma2d_fill(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, lv_coord_t fill_w, lv_coord_t fill_h) void lv_gpu_stm32_dma2d_fill(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, lv_coord_t fill_w, lv_coord_t fill_h)
{ {
invalidate_cache(); lv_disp_invalidate_cache(NULL);
DMA2D->CR = 0x30000; DMA2D->CR = 0x30000;
DMA2D->OMAR = (uint32_t)buf; DMA2D->OMAR = (uint32_t)buf;
@ -112,7 +112,7 @@ void lv_gpu_stm32_dma2d_fill_mask(lv_color_t * buf, lv_coord_t buf_w, lv_color_t
lv_opa_t opa, lv_coord_t fill_w, lv_coord_t fill_h) lv_opa_t opa, lv_coord_t fill_w, lv_coord_t fill_h)
{ {
#if 0 #if 0
invalidate_cache(); lv_disp_invalidate_cache(NULL);
/* Configure the DMA2D Mode, Color Mode and line output offset */ /* Configure the DMA2D Mode, Color Mode and line output offset */
hdma2d.Init.Mode = DMA2D_M2M_BLEND; hdma2d.Init.Mode = DMA2D_M2M_BLEND;
@ -156,7 +156,7 @@ void lv_gpu_stm32_dma2d_fill_mask(lv_color_t * buf, lv_coord_t buf_w, lv_color_t
void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_coord_t map_w, void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_coord_t map_w,
lv_coord_t copy_w, lv_coord_t copy_h) lv_coord_t copy_w, lv_coord_t copy_h)
{ {
invalidate_cache(); lv_disp_invalidate_cache(NULL);
DMA2D->CR = 0; DMA2D->CR = 0;
/* copy output colour mode, this register controls both input and output colour format */ /* copy output colour mode, this register controls both input and output colour format */
@ -186,7 +186,7 @@ void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_
void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_opa_t opa, void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_opa_t opa,
lv_coord_t map_w, lv_coord_t copy_w, lv_coord_t copy_h) lv_coord_t map_w, lv_coord_t copy_w, lv_coord_t copy_h)
{ {
invalidate_cache(); lv_disp_invalidate_cache(NULL);
DMA2D->CR = 0x20000; DMA2D->CR = 0x20000;
DMA2D->BGPFCCR = LV_DMA2D_COLOR_FORMAT; DMA2D->BGPFCCR = LV_DMA2D_COLOR_FORMAT;
@ -214,15 +214,6 @@ void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
static void invalidate_cache(void)
{
#if __DCACHE_PRESENT
if(SCB->CCR & (uint32_t)SCB_CCR_DC_Msk) {
SCB_CleanInvalidateDCache();
}
#endif
}
static void dma2d_wait(void) static void dma2d_wait(void)
{ {
lv_disp_t * disp = _lv_refr_get_disp_refreshing(); lv_disp_t * disp = _lv_refr_get_disp_refreshing();

View File

@ -111,6 +111,9 @@ typedef struct _disp_drv_t {
* User can execute very simple tasks here or yield the task */ * User can execute very simple tasks here or yield the task */
void (*wait_cb)(struct _disp_drv_t * disp_drv); void (*wait_cb)(struct _disp_drv_t * disp_drv);
/** OPTIONAL: Called when lvgl needs any CPU cache that affects rendering to be cleaned */
void (*clean_dcache_cb)(struct _disp_drv_t * disp_drv);
#if LV_USE_GPU #if LV_USE_GPU
/** OPTIONAL: Blend two memories using opacity (GPU only)*/ /** OPTIONAL: Blend two memories using opacity (GPU only)*/
void (*gpu_blend_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, void (*gpu_blend_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length,