From b8b581a83d48b243dee806f9f2e2d1d49f3c3e51 Mon Sep 17 00:00:00 2001 From: Cosmin-Daniel Radu Date: Tue, 8 Oct 2024 17:30:36 +0300 Subject: [PATCH] feat(nxp): Release/nxp patches for LVGL master (#6978) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicușor Cîțu Signed-off-by: Cristian Stoica Signed-off-by: Cosmin-Daniel Radu Co-authored-by: Nicușor Cîțu Co-authored-by: Cristian Stoica --- Kconfig | 12 ++++++- docs/integration/chip/nxp.rst | 14 ++++---- lv_conf_template.h | 13 ++++--- src/display/lv_display.c | 25 +++++++++++++ src/display/lv_display.h | 15 ++++++++ src/draw/lv_draw_buf.c | 10 ++++++ src/draw/lv_draw_buf.h | 3 ++ src/draw/nxp/pxp/lv_draw_buf_pxp.c | 8 ++++- src/draw/nxp/pxp/lv_draw_pxp.c | 17 +++++---- src/draw/nxp/pxp/lv_draw_pxp.h | 13 ++++--- 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/draw/nxp/vglite/lv_draw_buf_vglite.c | 22 +++++++++++- src/draw/nxp/vglite/lv_draw_vglite.c | 17 ++++----- src/draw/nxp/vglite/lv_draw_vglite_triangle.c | 4 +-- src/lv_conf_internal.h | 35 +++++++++++++++---- src/lv_init.c | 14 +++++--- 24 files changed, 207 insertions(+), 57 deletions(-) diff --git a/Kconfig b/Kconfig index 1fd917da5..7d5715c2c 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/docs/integration/chip/nxp.rst b/docs/integration/chip/nxp.rst index 17f432260..60dc5bde5 100644 --- a/docs/integration/chip/nxp.rst +++ b/docs/integration/chip/nxp.rst @@ -36,7 +36,9 @@ PXP accelerator Basic configuration: ^^^^^^^^^^^^^^^^^^^^ -- Select NXP PXP engine in "lv_conf.h": Set :c:macro:`LV_USE_DRAW_PXP` to `1`. +- Select NXP PXP engine in "lv_conf.h": Set :c:macro:`LV_USE_PXP` to `1`. +- In order to use PXP as a draw unit, select in "lv_conf.h": Set :c:macro:`LV_USE_DRAW_PXP` to `1`. +- In order to use PXP to rotate the screen, select in "lv_conf.h": Set :c:macro:`LV_USE_ROTATE_PXP` to `1`. - Enable PXP asserts in "lv_conf.h": Set :c:macro: `LV_USE_PXP_ASSERT` to `1`. There are few PXP assertions that can stop the program execution in case the c:macro:`LV_ASSERT_HANDLER` is set to `while(1);` (Halt by default). Else, @@ -48,16 +50,16 @@ Basic initialization: ^^^^^^^^^^^^^^^^^^^^^ PXP draw initialization is done automatically in :cpp:func:`lv_init()` once the -PXP is enabled, no user code is required: +PXP is enabled as a draw unit or to rotate the screen, no user code is required: .. code-block:: c - #if LV_USE_DRAW_PXP - lv_draw_pxp_init(); - #endif + #if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP + lv_draw_pxp_init(); + #endif During PXP initialization, a new draw unit `lv_draw_pxp_unit_t` will be created -with the additional callbacks: +with the additional callbacks, if :c:macro:`LV_USE_DRAW_PXP` is set to `1`: .. code-block:: c diff --git a/lv_conf_template.h b/lv_conf_template.h index 8dc118203..05ec3e832 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -115,7 +115,6 @@ /* * Unblocking an RTOS task with a direct notification is 45% faster and uses less RAM * than unblocking a task using an intermediary object such as a binary semaphore. - * * RTOS task notifications can only be used when there is only one task that can be the recipient of the event. */ #define LV_USE_FREERTOS_TASK_NOTIFY 1 @@ -229,10 +228,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/display/lv_display.c b/src/display/lv_display.c index 247fa163e..dfa0b415a 100644 --- a/src/display/lv_display.c +++ b/src/display/lv_display.c @@ -451,6 +451,31 @@ void lv_display_set_buffers(lv_display_t * disp, void * buf1, void * buf2, uint3 lv_display_set_render_mode(disp, render_mode); } +void lv_display_set_buffers_with_stride(lv_display_t * disp, void * buf1, void * buf2, uint32_t buf_size, + uint32_t stride, lv_display_render_mode_t render_mode) +{ + LV_ASSERT_MSG(buf1 != NULL, "Null buffer"); + lv_color_format_t cf = lv_display_get_color_format(disp); + uint32_t w = lv_display_get_horizontal_resolution(disp); + uint32_t h = lv_display_get_vertical_resolution(disp); + LV_ASSERT_MSG(w != 0 && h != 0, "display resolution is 0"); + + if(render_mode == LV_DISPLAY_RENDER_MODE_PARTIAL) { + /* for partial mode, we calculate the height based on the buf_size and stride */ + h = buf_size / stride; + LV_ASSERT_MSG(h != 0, "the buffer is too small"); + } + else { + LV_ASSERT_FORMAT_MSG(stride * h <= buf_size, "%s mode requires screen sized buffer(s)", + render_mode == LV_DISPLAY_RENDER_MODE_FULL ? "FULL" : "DIRECT"); + } + + lv_draw_buf_init(&disp->_static_buf1, w, h, cf, stride, buf1, buf_size); + lv_draw_buf_init(&disp->_static_buf2, w, h, cf, stride, buf2, buf_size); + lv_display_set_draw_buffers(disp, &disp->_static_buf1, buf2 ? &disp->_static_buf2 : NULL); + lv_display_set_render_mode(disp, render_mode); +} + void lv_display_set_render_mode(lv_display_t * disp, lv_display_render_mode_t render_mode) { if(disp == NULL) disp = lv_display_get_default(); diff --git a/src/display/lv_display.h b/src/display/lv_display.h index 9d4fc060c..2887ab691 100644 --- a/src/display/lv_display.h +++ b/src/display/lv_display.h @@ -239,6 +239,21 @@ int32_t lv_display_get_dpi(const lv_display_t * disp); void lv_display_set_buffers(lv_display_t * disp, void * buf1, void * buf2, uint32_t buf_size, lv_display_render_mode_t render_mode); +/** + * Set the frame buffers for a display, similarly to `lv_display_set_buffers`, but allow + * for a custom stride as required by a display controller. + * This allows the frame buffers to have a stride alignment different from the rest of + * the buffers` + * @param disp pointer to a display + * @param buf1 first buffer + * @param buf2 second buffer (can be `NULL`) + * @param buf_size buffer size in byte + * @param stride buffer stride in bytes + * @param render_mode LV_DISPLAY_RENDER_MODE_PARTIAL/DIRECT/FULL + */ +void lv_display_set_buffers_with_stride(lv_display_t * disp, void * buf1, void * buf2, uint32_t buf_size, + uint32_t stride, lv_display_render_mode_t render_mode); + /** * Set the buffers for a display, accept a draw buffer pointer. * Normally use `lv_display_set_buffers` is enough for most cases. diff --git a/src/draw/lv_draw_buf.c b/src/draw/lv_draw_buf.c index 06e67ed25..a6dc29bb1 100644 --- a/src/draw/lv_draw_buf.c +++ b/src/draw/lv_draw_buf.c @@ -83,6 +83,16 @@ lv_draw_buf_handlers_t * lv_draw_buf_get_handlers(void) return &default_handlers; } +lv_draw_buf_handlers_t * lv_draw_buf_get_font_handlers(void) +{ + return &font_draw_buf_handlers; +} + +lv_draw_buf_handlers_t * lv_draw_buf_get_image_handlers(void) +{ + return &image_cache_draw_buf_handlers; +} + uint32_t lv_draw_buf_width_to_stride(uint32_t w, lv_color_format_t color_format) { return lv_draw_buf_width_to_stride_ex(&default_handlers, w, color_format); diff --git a/src/draw/lv_draw_buf.h b/src/draw/lv_draw_buf.h index d1809dfb7..0a6086968 100644 --- a/src/draw/lv_draw_buf.h +++ b/src/draw/lv_draw_buf.h @@ -129,6 +129,9 @@ void lv_draw_buf_handlers_init(lv_draw_buf_handlers_t * handlers, * @return pointer to the struct of handlers */ lv_draw_buf_handlers_t * lv_draw_buf_get_handlers(void); +lv_draw_buf_handlers_t * lv_draw_buf_get_font_handlers(void); +lv_draw_buf_handlers_t * lv_draw_buf_get_image_handlers(void); + /** * Align the address of a buffer. The buffer needs to be large enough for the real data after alignment diff --git a/src/draw/nxp/pxp/lv_draw_buf_pxp.c b/src/draw/nxp/pxp/lv_draw_buf_pxp.c index e83da1ca3..9819cfc64 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" @@ -51,8 +52,12 @@ static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * void lv_draw_buf_pxp_init_handlers(void) { lv_draw_buf_handlers_t * handlers = lv_draw_buf_get_handlers(); + lv_draw_buf_handlers_t * font_handlers = lv_draw_buf_get_font_handlers(); + lv_draw_buf_handlers_t * image_handlers = lv_draw_buf_get_image_handlers(); handlers->invalidate_cache_cb = _invalidate_cache; + font_handlers->invalidate_cache_cb = _invalidate_cache; + image_handlers->invalidate_cache_cb = _invalidate_cache; } /********************** @@ -66,7 +71,7 @@ static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * lv_color_format_t cf = header->cf; if(area->y1 == 0) { - uint16_t size = stride * lv_area_get_height(area); + uint32_t size = stride * lv_area_get_height(area); /* Invalidate full buffer. */ DEMO_CleanInvalidateCacheByAddr((void *)draw_buf->data, size); @@ -109,3 +114,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..b86e30f42 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; @@ -321,8 +324,7 @@ static int32_t _pxp_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer) if(t == NULL || t->preferred_draw_unit_id != DRAW_UNIT_ID_PXP) return LV_DRAW_UNIT_IDLE; - void * buf = lv_draw_layer_alloc_buf(layer); - if(buf == NULL) + if(lv_draw_layer_alloc_buf(layer) == NULL) return LV_DRAW_UNIT_IDLE; t->state = LV_DRAW_TASK_STATE_IN_PROGRESS; @@ -484,5 +486,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 d5e98d791..d34ad3f84 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp.h +++ b/src/draw/nxp/pxp/lv_draw_pxp.h @@ -22,8 +22,10 @@ extern "C" { #include "../../../lv_conf_internal.h" -#if LV_USE_DRAW_PXP -#include "../../sw/lv_draw_sw.h" +#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" /********************* * DEFINES @@ -39,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); @@ -49,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); @@ -62,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/draw/nxp/vglite/lv_draw_buf_vglite.c b/src/draw/nxp/vglite/lv_draw_buf_vglite.c index ae9b59a5e..85403956f 100644 --- a/src/draw/nxp/vglite/lv_draw_buf_vglite.c +++ b/src/draw/nxp/vglite/lv_draw_buf_vglite.c @@ -35,6 +35,7 @@ **********************/ static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area); +static uint32_t _width_to_stride(uint32_t w, lv_color_format_t cf); /********************** * STATIC VARIABLES @@ -51,8 +52,17 @@ static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * void lv_draw_buf_vglite_init_handlers(void) { lv_draw_buf_handlers_t * handlers = lv_draw_buf_get_handlers(); + lv_draw_buf_handlers_t * font_handlers = lv_draw_buf_get_font_handlers(); + lv_draw_buf_handlers_t * image_handlers = lv_draw_buf_get_image_handlers(); handlers->invalidate_cache_cb = _invalidate_cache; + font_handlers->invalidate_cache_cb = _invalidate_cache; + image_handlers->invalidate_cache_cb = _invalidate_cache; + + handlers->width_to_stride_cb = _width_to_stride; + font_handlers->width_to_stride_cb = _width_to_stride; + image_handlers->width_to_stride_cb = _width_to_stride; + } /********************** @@ -66,7 +76,7 @@ static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * lv_color_format_t cf = header->cf; if(area->y1 == 0) { - uint16_t size = stride * lv_area_get_height(area); + uint32_t size = stride * lv_area_get_height(area); /* Invalidate full buffer. */ DEMO_CleanInvalidateCacheByAddr((void *)draw_buf->data, size); @@ -108,4 +118,14 @@ static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * } } +static uint32_t _width_to_stride(uint32_t w, lv_color_format_t cf) +{ + uint8_t bits_per_pixel = lv_color_format_get_bpp(cf); + uint32_t width_bits = (w * bits_per_pixel + 7) & ~7; + uint32_t width_bytes = width_bits / 8; + uint8_t align_bytes = vglite_get_stride_alignment(cf); + + return (width_bytes + align_bytes - 1) & ~(align_bytes - 1); +} + #endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite.c b/src/draw/nxp/vglite/lv_draw_vglite.c index abb52c0da..c6fc016f4 100644 --- a/src/draw/nxp/vglite/lv_draw_vglite.c +++ b/src/draw/nxp/vglite/lv_draw_vglite.c @@ -291,16 +291,14 @@ static int32_t _vglite_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer) if(t == NULL) return LV_DRAW_UNIT_IDLE; - if(lv_draw_get_unit_count() > 1) { - /* Let the SW unit to draw this task. */ - if(t->preferred_draw_unit_id != DRAW_UNIT_ID_VGLITE) + if(t->preferred_draw_unit_id != DRAW_UNIT_ID_VGLITE) { + /* Let the preferred known unit to draw this task. */ + if(t->preferred_draw_unit_id != LV_DRAW_UNIT_NONE) { return LV_DRAW_UNIT_IDLE; - } - else { - /* Fake unsupported tasks as ready. */ - if(t->preferred_draw_unit_id != DRAW_UNIT_ID_VGLITE) { + } + else { + /* Fake unsupported tasks as ready. */ t->state = LV_DRAW_TASK_STATE_READY; - /* Request a new dispatching as it can get a new task. */ lv_draw_dispatch_request(); @@ -308,8 +306,7 @@ static int32_t _vglite_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer) } } - void * buf = lv_draw_layer_alloc_buf(layer); - if(buf == NULL) + if(lv_draw_layer_alloc_buf(layer) == NULL) return LV_DRAW_UNIT_IDLE; t->state = LV_DRAW_TASK_STATE_IN_PROGRESS; diff --git a/src/draw/nxp/vglite/lv_draw_vglite_triangle.c b/src/draw/nxp/vglite/lv_draw_vglite_triangle.c index 4f72f3aff..8556fdf2a 100644 --- a/src/draw/nxp/vglite/lv_draw_vglite_triangle.c +++ b/src/draw/nxp/vglite/lv_draw_vglite_triangle.c @@ -97,8 +97,8 @@ static void _vglite_draw_triangle(const lv_area_t * coords, const lv_area_t * cl tri_area.x2 = (int32_t)LV_MAX3(dsc->p[0].x, dsc->p[1].x, dsc->p[2].x); tri_area.y2 = (int32_t)LV_MAX3(dsc->p[0].y, dsc->p[1].y, dsc->p[2].y); - uint32_t width = tri_area.x2 - tri_area.x1; - uint32_t height = tri_area.y2 - tri_area.y1; + uint32_t width = lv_area_get_width(&tri_area); + uint32_t height = lv_area_get_height(&tri_area); /* Init path */ int32_t triangle_path[] = { /*VG line path*/ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index e0aefaee7..9bb336ed1 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -286,7 +286,6 @@ /* * Unblocking an RTOS task with a direct notification is 45% faster and uses less RAM * than unblocking a task using an intermediary object such as a binary semaphore. - * * RTOS task notifications can only be used when there is only one task that can be the recipient of the event. */ #ifndef LV_USE_FREERTOS_TASK_NOTIFY @@ -644,16 +643,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 b7eff16ea..15aa8fd2e 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" @@ -201,9 +203,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(); @@ -392,9 +396,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();