From 892d97ccc107045fef25389bf0660cbed7f2ebe7 Mon Sep 17 00:00:00 2001 From: Cosmin-Daniel Radu Date: Thu, 12 Sep 2024 11:43:30 +0300 Subject: [PATCH] feat(pxp) Add option to use PXP only for rotation without creating PXP draw unit. Signed-off-by: Cosmin-Daniel Radu --- Kconfig | 12 +++++++++- lv_conf_template.h | 12 +++++++--- src/draw/nxp/pxp/lv_draw_buf_pxp.c | 2 ++ src/draw/nxp/pxp/lv_draw_pxp.c | 14 ++++++++---- src/draw/nxp/pxp/lv_draw_pxp.h | 10 +++++--- src/draw/nxp/pxp/lv_draw_pxp_fill.c | 2 ++ src/draw/nxp/pxp/lv_draw_pxp_img.c | 2 ++ src/draw/nxp/pxp/lv_draw_pxp_layer.c | 2 ++ src/draw/nxp/pxp/lv_pxp_cfg.c | 6 +++-- src/draw/nxp/pxp/lv_pxp_cfg.h | 6 +++-- src/draw/nxp/pxp/lv_pxp_osa.c | 6 +++-- src/draw/nxp/pxp/lv_pxp_osa.h | 6 +++-- src/draw/nxp/pxp/lv_pxp_utils.c | 6 ++++- src/draw/nxp/pxp/lv_pxp_utils.h | 6 ++++- src/lv_conf_internal.h | 34 +++++++++++++++++++++++----- src/lv_init.c | 14 ++++++++---- 16 files changed, 108 insertions(+), 32 deletions(-) diff --git a/Kconfig b/Kconfig index 04f6094ae..60b2c3679 100644 --- a/Kconfig +++ b/Kconfig @@ -372,8 +372,18 @@ menu "LVGL configuration" depends on LV_USE_DRAW_VGLITE default n + config LV_USE_PXP + bool "Use NXP's PXP on iMX RTxxx platforms" + default n + config LV_USE_DRAW_PXP - bool "Use NXP's PXP on iMX RTxxx platforms" + bool "Use PXP for drawing" + depends on LV_USE_PXP + default y + + config LV_USE_ROTATE_PXP + bool "Use PXP to rotate display" + depends on LV_USE_PXP default n config LV_USE_PXP_DRAW_THREAD diff --git a/lv_conf_template.h b/lv_conf_template.h index 5902e166c..11987d0b9 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -214,10 +214,16 @@ #endif /* Use NXP's PXP on iMX RTxxx platforms. */ -#define LV_USE_DRAW_PXP 0 +#define LV_USE_PXP 0 -#if LV_USE_DRAW_PXP - #if LV_USE_OS +#if LV_USE_PXP + /* Use PXP for drawing.*/ + #define LV_USE_DRAW_PXP 1 + + /* Use PXP to rotate display.*/ + #define LV_USE_ROTATE_PXP 0 + + #if LV_USE_DRAW_PXP && LV_USE_OS /* Use additional draw thread for PXP processing.*/ #define LV_USE_PXP_DRAW_THREAD 1 #endif diff --git a/src/draw/nxp/pxp/lv_draw_buf_pxp.c b/src/draw/nxp/pxp/lv_draw_buf_pxp.c index e83da1ca3..95dfc347c 100644 --- a/src/draw/nxp/pxp/lv_draw_buf_pxp.c +++ b/src/draw/nxp/pxp/lv_draw_buf_pxp.c @@ -15,6 +15,7 @@ #include "lv_draw_pxp.h" +#if LV_USE_PXP #if LV_USE_DRAW_PXP #include "../../lv_draw_buf_private.h" #include "lv_pxp_cfg.h" @@ -109,3 +110,4 @@ static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * } #endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_PXP*/ diff --git a/src/draw/nxp/pxp/lv_draw_pxp.c b/src/draw/nxp/pxp/lv_draw_pxp.c index e606e6798..6c5aeb4f3 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp.c +++ b/src/draw/nxp/pxp/lv_draw_pxp.c @@ -15,7 +15,8 @@ #include "lv_draw_pxp.h" -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP #include "lv_pxp_cfg.h" #include "lv_pxp_utils.h" @@ -82,6 +83,9 @@ static void _pxp_execute_drawing(lv_draw_pxp_unit_t * u); void lv_draw_pxp_init(void) { + lv_pxp_init(); + +#if LV_USE_DRAW_PXP lv_draw_buf_pxp_init_handlers(); lv_draw_pxp_unit_t * draw_pxp_unit = lv_draw_create_unit(sizeof(lv_draw_pxp_unit_t)); @@ -89,11 +93,10 @@ void lv_draw_pxp_init(void) draw_pxp_unit->base_unit.dispatch_cb = _pxp_dispatch; draw_pxp_unit->base_unit.delete_cb = _pxp_delete; - lv_pxp_init(); - #if LV_USE_PXP_DRAW_THREAD lv_thread_init(&draw_pxp_unit->thread, LV_THREAD_PRIO_HIGH, _pxp_render_thread_cb, 2 * 1024, draw_pxp_unit); #endif +#endif /*LV_USE_DRAW_PXP*/ } void lv_draw_pxp_deinit(void) @@ -159,7 +162,7 @@ void lv_draw_pxp_rotate(const void * src_buf, void * dest_buf, int32_t src_width /********************** * STATIC FUNCTIONS **********************/ - +#if LV_USE_DRAW_PXP static inline bool _pxp_src_cf_supported(lv_color_format_t cf) { bool is_cf_supported = false; @@ -484,5 +487,6 @@ static void _pxp_render_thread_cb(void * ptr) LV_LOG_INFO("Exit PXP draw thread."); } #endif - #endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/ +#endif /*LV_USE_PXP*/ diff --git a/src/draw/nxp/pxp/lv_draw_pxp.h b/src/draw/nxp/pxp/lv_draw_pxp.h index e048813e5..d34ad3f84 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp.h +++ b/src/draw/nxp/pxp/lv_draw_pxp.h @@ -22,7 +22,8 @@ extern "C" { #include "../../../lv_conf_internal.h" -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP #include "../../sw/lv_draw_sw_private.h" #include "../../../misc/lv_area_private.h" @@ -40,8 +41,6 @@ typedef lv_draw_sw_unit_t lv_draw_pxp_unit_t; * GLOBAL PROTOTYPES **********************/ -void lv_draw_buf_pxp_init_handlers(void); - void lv_draw_pxp_init(void); void lv_draw_pxp_deinit(void); @@ -50,6 +49,9 @@ void lv_draw_pxp_rotate(const void * src_buf, void * dest_buf, int32_t src_width int32_t src_stride, int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t cf); +#if LV_USE_DRAW_PXP +void lv_draw_buf_pxp_init_handlers(void); + void lv_draw_pxp_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc, const lv_area_t * coords); @@ -63,6 +65,8 @@ void lv_draw_pxp_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * d * MACROS **********************/ #endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/ +#endif /*LV_USE_PXP*/ #ifdef __cplusplus } /*extern "C"*/ diff --git a/src/draw/nxp/pxp/lv_draw_pxp_fill.c b/src/draw/nxp/pxp/lv_draw_pxp_fill.c index c75de3480..33b80473c 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp_fill.c +++ b/src/draw/nxp/pxp/lv_draw_pxp_fill.c @@ -15,6 +15,7 @@ #include "lv_draw_pxp.h" +#if LV_USE_PXP #if LV_USE_DRAW_PXP #include "lv_pxp_cfg.h" #include "lv_pxp_utils.h" @@ -145,3 +146,4 @@ static void _pxp_fill(uint8_t * dest_buf, const lv_area_t * dest_area, int32_t d } #endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_PXP*/ diff --git a/src/draw/nxp/pxp/lv_draw_pxp_img.c b/src/draw/nxp/pxp/lv_draw_pxp_img.c index 08c0a8ad6..79f3790e9 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp_img.c +++ b/src/draw/nxp/pxp/lv_draw_pxp_img.c @@ -15,6 +15,7 @@ #include "lv_draw_pxp.h" +#if LV_USE_PXP #if LV_USE_DRAW_PXP #include "lv_pxp_cfg.h" #include "lv_pxp_utils.h" @@ -363,3 +364,4 @@ static void _pxp_blit(uint8_t * dest_buf, const lv_area_t * dest_area, int32_t d } #endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_PXP*/ diff --git a/src/draw/nxp/pxp/lv_draw_pxp_layer.c b/src/draw/nxp/pxp/lv_draw_pxp_layer.c index 4ee33010d..34cb285b7 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp_layer.c +++ b/src/draw/nxp/pxp/lv_draw_pxp_layer.c @@ -15,6 +15,7 @@ #include "lv_draw_pxp.h" +#if LV_USE_PXP #if LV_USE_DRAW_PXP #include "../../../stdlib/lv_string.h" @@ -154,3 +155,4 @@ void lv_draw_pxp_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * d } #endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_PXP*/ diff --git a/src/draw/nxp/pxp/lv_pxp_cfg.c b/src/draw/nxp/pxp/lv_pxp_cfg.c index f1d796293..675c1d030 100644 --- a/src/draw/nxp/pxp/lv_pxp_cfg.c +++ b/src/draw/nxp/pxp/lv_pxp_cfg.c @@ -15,7 +15,8 @@ #include "lv_pxp_cfg.h" -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP #include "lv_pxp_osa.h" /********************* @@ -88,4 +89,5 @@ void lv_pxp_wait(void) * STATIC FUNCTIONS **********************/ -#endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/ +#endif /*LV_USE_PXP*/ diff --git a/src/draw/nxp/pxp/lv_pxp_cfg.h b/src/draw/nxp/pxp/lv_pxp_cfg.h index b487e7ff9..67d135857 100644 --- a/src/draw/nxp/pxp/lv_pxp_cfg.h +++ b/src/draw/nxp/pxp/lv_pxp_cfg.h @@ -22,7 +22,8 @@ extern "C" { #include "../../../lv_conf_internal.h" -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP #include "fsl_cache.h" #include "fsl_pxp.h" @@ -93,7 +94,8 @@ void lv_pxp_wait(void); * MACROS **********************/ -#endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/ +#endif /*LV_USE_PXP*/ #ifdef __cplusplus } /*extern "C"*/ diff --git a/src/draw/nxp/pxp/lv_pxp_osa.c b/src/draw/nxp/pxp/lv_pxp_osa.c index b573b212b..43dd8155b 100644 --- a/src/draw/nxp/pxp/lv_pxp_osa.c +++ b/src/draw/nxp/pxp/lv_pxp_osa.c @@ -15,7 +15,8 @@ #include "lv_pxp_osa.h" -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP #include "lv_pxp_utils.h" #include "../../../misc/lv_log.h" #include "../../../osal/lv_os.h" @@ -183,4 +184,5 @@ static void _pxp_wait(void) #endif } -#endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/ +#endif /*LV_USE_PXP*/ diff --git a/src/draw/nxp/pxp/lv_pxp_osa.h b/src/draw/nxp/pxp/lv_pxp_osa.h index 371429049..5e3d6669d 100644 --- a/src/draw/nxp/pxp/lv_pxp_osa.h +++ b/src/draw/nxp/pxp/lv_pxp_osa.h @@ -22,7 +22,8 @@ extern "C" { #include "../../../lv_conf_internal.h" -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP #include "lv_pxp_cfg.h" /********************* @@ -51,7 +52,8 @@ pxp_cfg_t * pxp_get_default_cfg(void); * MACROS **********************/ -#endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/ +#endif /*LV_USE_PXP*/ #ifdef __cplusplus } /*extern "C"*/ diff --git a/src/draw/nxp/pxp/lv_pxp_utils.c b/src/draw/nxp/pxp/lv_pxp_utils.c index 3940a68b5..26acf6ca9 100644 --- a/src/draw/nxp/pxp/lv_pxp_utils.c +++ b/src/draw/nxp/pxp/lv_pxp_utils.c @@ -15,7 +15,8 @@ #include "lv_pxp_utils.h" -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP /********************* * DEFINES @@ -89,6 +90,7 @@ pxp_as_pixel_format_t pxp_get_as_px_format(lv_color_format_t cf) return as_px_format; } +#if LV_USE_DRAW_PXP pxp_ps_pixel_format_t pxp_get_ps_px_format(lv_color_format_t cf) { pxp_ps_pixel_format_t ps_px_format = kPXP_PsPixelFormatRGB565; @@ -143,3 +145,5 @@ bool pxp_buf_aligned(const void * buf, uint32_t stride) **********************/ #endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/ +#endif /*LV_USE_PXP*/ diff --git a/src/draw/nxp/pxp/lv_pxp_utils.h b/src/draw/nxp/pxp/lv_pxp_utils.h index a1f0a16c4..c9ba7bafd 100644 --- a/src/draw/nxp/pxp/lv_pxp_utils.h +++ b/src/draw/nxp/pxp/lv_pxp_utils.h @@ -21,7 +21,8 @@ extern "C" { *********************/ #include "../../../lv_conf_internal.h" -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP #include "fsl_pxp.h" #include "../../../misc/lv_color.h" @@ -59,6 +60,7 @@ pxp_output_pixel_format_t pxp_get_out_px_format(lv_color_format_t cf); pxp_as_pixel_format_t pxp_get_as_px_format(lv_color_format_t cf); +#if LV_USE_DRAW_PXP pxp_ps_pixel_format_t pxp_get_ps_px_format(lv_color_format_t cf); bool pxp_buf_aligned(const void * buf, uint32_t stride); @@ -72,6 +74,8 @@ bool pxp_buf_aligned(const void * buf, uint32_t stride); **********************/ #endif /*LV_USE_DRAW_PXP*/ +#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/ +#endif /*LV_USE_PXP*/ #ifdef __cplusplus } /*extern "C"*/ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 979875350..640b62a98 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -629,16 +629,38 @@ #endif /* Use NXP's PXP on iMX RTxxx platforms. */ -#ifndef LV_USE_DRAW_PXP - #ifdef CONFIG_LV_USE_DRAW_PXP - #define LV_USE_DRAW_PXP CONFIG_LV_USE_DRAW_PXP +#ifndef LV_USE_PXP + #ifdef CONFIG_LV_USE_PXP + #define LV_USE_PXP CONFIG_LV_USE_PXP #else - #define LV_USE_DRAW_PXP 0 + #define LV_USE_PXP 0 #endif #endif -#if LV_USE_DRAW_PXP - #if LV_USE_OS +#if LV_USE_PXP + /* Use PXP for drawing.*/ + #ifndef LV_USE_DRAW_PXP + #ifdef LV_KCONFIG_PRESENT + #ifdef CONFIG_LV_USE_DRAW_PXP + #define LV_USE_DRAW_PXP CONFIG_LV_USE_DRAW_PXP + #else + #define LV_USE_DRAW_PXP 0 + #endif + #else + #define LV_USE_DRAW_PXP 1 + #endif + #endif + + /* Use PXP to rotate display.*/ + #ifndef LV_USE_ROTATE_PXP + #ifdef CONFIG_LV_USE_ROTATE_PXP + #define LV_USE_ROTATE_PXP CONFIG_LV_USE_ROTATE_PXP + #else + #define LV_USE_ROTATE_PXP 0 + #endif + #endif + + #if LV_USE_DRAW_PXP && LV_USE_OS /* Use additional draw thread for PXP processing.*/ #ifndef LV_USE_PXP_DRAW_THREAD #ifdef LV_KCONFIG_PRESENT diff --git a/src/lv_init.c b/src/lv_init.c index 26897a7bc..a019d6e57 100644 --- a/src/lv_init.c +++ b/src/lv_init.c @@ -43,8 +43,10 @@ #if LV_USE_DRAW_VGLITE #include "draw/nxp/vglite/lv_draw_vglite.h" #endif -#if LV_USE_DRAW_PXP - #include "draw/nxp/pxp/lv_draw_pxp.h" +#if LV_USE_PXP + #if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP + #include "draw/nxp/pxp/lv_draw_pxp.h" + #endif #endif #if LV_USE_DRAW_DAVE2D #include "draw/renesas/dave2d/lv_draw_dave2d.h" @@ -198,9 +200,11 @@ void lv_init(void) lv_draw_vglite_init(); #endif -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP lv_draw_pxp_init(); #endif +#endif #if LV_USE_DRAW_DAVE2D lv_draw_dave2d_init(); @@ -385,9 +389,11 @@ void lv_deinit(void) lv_obj_style_deinit(); -#if LV_USE_DRAW_PXP +#if LV_USE_PXP +#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP lv_draw_pxp_deinit(); #endif +#endif #if LV_USE_DRAW_VGLITE lv_draw_vglite_deinit();