1 /**
2  * @file lv_gpu_stm32_dma2d.h
3  *
4  */
5 
6 #ifndef LV_GPU_STM32_DMA2D_H
7 #define LV_GPU_STM32_DMA2D_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include "../../misc/lv_color.h"
14 #include "../../hal/lv_hal_disp.h"
15 #include "../sw/lv_draw_sw.h"
16 
17 #if LV_USE_GPU_STM32_DMA2D
18 
19 /*********************
20  *      INCLUDES
21  *********************/
22 #include LV_GPU_DMA2D_CMSIS_INCLUDE
23 
24 /*********************
25  *      DEFINES
26  *********************/
27 #if defined(LV_STM32_DMA2D_TEST)
28 // removes "static" modifier for some internal methods in order to test them
29 #define LV_STM32_DMA2D_STATIC
30 #else
31 #define LV_STM32_DMA2D_STATIC static
32 #endif
33 
34 /**********************
35  *      TYPEDEFS
36  **********************/
37 enum dma2d_color_format {
38     ARGB8888 = 0x0,
39     RGB888 = 0x01,
40     RGB565 = 0x02,
41     ARGB1555 = 0x03,
42     ARGB4444 = 0x04,
43     A8 = 0x09,
44     UNSUPPORTED = 0xff,
45 };
46 typedef enum dma2d_color_format dma2d_color_format_t;
47 typedef lv_draw_sw_ctx_t lv_draw_stm32_dma2d_ctx_t;
48 struct _lv_disp_drv_t;
49 
50 /**********************
51  * GLOBAL PROTOTYPES
52  **********************/
53 void lv_draw_stm32_dma2d_init(void);
54 void lv_draw_stm32_dma2d_ctx_init(struct _lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx);
55 void lv_draw_stm32_dma2d_ctx_deinit(struct _lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx);
56 static void lv_draw_stm32_dma2d_blend(lv_draw_ctx_t * draw_ctx, const lv_draw_sw_blend_dsc_t * dsc);
57 static void lv_draw_stm32_dma2d_buffer_copy(lv_draw_ctx_t * draw_ctx,
58                                             void * dest_buf, lv_coord_t dest_stride, const lv_area_t * dest_area,
59                                             void * src_buf, lv_coord_t src_stride, const lv_area_t * src_area);
60 static lv_res_t lv_draw_stm32_dma2d_img(lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * img_dsc,
61                                         const lv_area_t * src_area, const void * src);
62 static void lv_gpu_stm32_dma2d_wait_cb(lv_draw_ctx_t * draw_ctx);
63 static void lv_draw_stm32_dma2d_img_decoded(lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * img_dsc,
64                                             const lv_area_t * coords, const uint8_t * src_buf, lv_img_cf_t color_format);
65 static dma2d_color_format_t lv_color_format_to_dma2d_color_format(lv_img_cf_t color_format);
66 static lv_point_t lv_area_get_offset(const lv_area_t * area1, const lv_area_t * area2);
67 
68 /**********************
69  *  STATIC PROTOTYPES
70  **********************/
71 LV_STM32_DMA2D_STATIC void _lv_draw_stm32_dma2d_blend_fill(const lv_color_t * dst_buf, lv_coord_t dst_stride,
72                                                            const lv_area_t * draw_area, lv_color_t color, lv_opa_t opa);
73 LV_STM32_DMA2D_STATIC void _lv_draw_stm32_dma2d_blend_map(const lv_color_t * dest_buf, lv_coord_t dest_stride,
74                                                           const lv_area_t * draw_area, const void * src_buf, lv_coord_t src_stride, const lv_point_t * src_offset, lv_opa_t opa,
75                                                           dma2d_color_format_t src_color_format, bool ignore_src_alpha);
76 LV_STM32_DMA2D_STATIC void _lv_draw_stm32_dma2d_blend_paint(const lv_color_t * dst_buf, lv_coord_t dst_stride,
77                                                             const lv_area_t * draw_area, const lv_opa_t * mask_buf, lv_coord_t mask_stride, const lv_point_t * mask_offset,
78                                                             lv_color_t color, lv_opa_t opa);
79 LV_STM32_DMA2D_STATIC void _lv_draw_stm32_dma2d_copy_buffer(const lv_color_t * dest_buf, lv_coord_t dest_stride,
80                                                             const lv_area_t * draw_area, const lv_color_t * src_buf, lv_coord_t src_stride, const lv_point_t * src_offset);
81 LV_STM32_DMA2D_STATIC void _lv_gpu_stm32_dma2d_await_dma_transfer_finish(lv_disp_drv_t * disp_drv);
82 LV_STM32_DMA2D_STATIC void _lv_gpu_stm32_dma2d_start_dma_transfer(void);
83 LV_STM32_DMA2D_STATIC void _lv_gpu_stm32_dma2d_invalidate_cache(uint32_t address, lv_coord_t offset,
84                                                                 lv_coord_t width, lv_coord_t height, uint8_t pixel_size);
85 LV_STM32_DMA2D_STATIC void _lv_gpu_stm32_dma2d_clean_cache(uint32_t address, lv_coord_t offset, lv_coord_t width,
86                                                            lv_coord_t height, uint8_t pixel_size);
87 LV_STM32_DMA2D_STATIC bool _lv_gpu_stm32_dwt_init(void);
88 LV_STM32_DMA2D_STATIC void _lv_gpu_stm32_dwt_reset(void);
89 LV_STM32_DMA2D_STATIC uint32_t _lv_gpu_stm32_dwt_get_us(void);
90 
91 /**********************
92  *      MACROS
93  **********************/
94 
95 #endif  /*LV_USE_GPU_STM32_DMA2D*/
96 
97 #ifdef __cplusplus
98 } /*extern "C"*/
99 #endif
100 
101 #endif /*LV_GPU_STM32_DMA2D_H*/
102