mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-27 11:57:48 +08:00
fix(freertos): do not reinitalize mutex condition
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
From c5bd602452a72e031cc91050e2dc7a04e8d6bc49 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Nicu=C8=99or=20C=C3=AE=C8=9Bu?= <nicusor.citu@nxp.com>
|
||||||
|
Date: Mon, 30 Oct 2023 15:07:38 +0200
|
||||||
|
Subject: [PATCH 1/2] fix(freertos) Do not reinitialize the mutex/conditional
|
||||||
|
if already done.
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
In some cases, the mutex_lock() gets called before its creation so it will perform the init first.
|
||||||
|
Next, if mutex_init() gets eventually called, do not reinit the mutex.
|
||||||
|
|
||||||
|
Signed-off-by: Nicușor Cîțu <nicusor.citu@nxp.com>
|
||||||
|
---
|
||||||
|
src/osal/lv_freertos.c | 6 ++++--
|
||||||
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/osal/lv_freertos.c b/src/osal/lv_freertos.c
|
||||||
|
index 49192402d..bc3f7d9d8 100644
|
||||||
|
--- a/src/osal/lv_freertos.c
|
||||||
|
+++ b/src/osal/lv_freertos.c
|
||||||
|
@@ -96,7 +96,8 @@ lv_result_t lv_thread_delete(lv_thread_t * pxThread)
|
||||||
|
|
||||||
|
lv_result_t lv_mutex_init(lv_mutex_t * pxMutex)
|
||||||
|
{
|
||||||
|
- prvMutexInit(pxMutex);
|
||||||
|
+ /* If mutex in uninitialized, perform initialization. */
|
||||||
|
+ prvCheckMutexInit(pxMutex);
|
||||||
|
|
||||||
|
return LV_RESULT_OK;
|
||||||
|
}
|
||||||
|
@@ -165,7 +166,8 @@ lv_result_t lv_thread_sync_init(lv_thread_sync_t * pxCond)
|
||||||
|
/* Store the handle of the calling task. */
|
||||||
|
pxCond->xTaskToNotify = xTaskGetCurrentTaskHandle();
|
||||||
|
#else
|
||||||
|
- prvCondInit(pxCond);
|
||||||
|
+ /* If the cond is uninitialized, perform initialization. */
|
||||||
|
+ prvCheckCondInit(pxCond);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return LV_RESULT_OK;
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
From d4c7c547c1c3ea36c08a5decf6b9d68ce4739044 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Nicu=C8=99or=20C=C3=AE=C8=9Bu?= <nicusor.citu@nxp.com>
|
||||||
|
Date: Wed, 1 Nov 2023 10:57:34 +0200
|
||||||
|
Subject: [PATCH 2/2] feat(draw_unit) Add unit_count to figure out if other
|
||||||
|
units are available.
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Signed-off-by: Nicușor Cîțu <nicusor.citu@nxp.com>
|
||||||
|
---
|
||||||
|
src/draw/lv_draw.c | 1 +
|
||||||
|
src/draw/lv_draw.h | 1 +
|
||||||
|
src/draw/nxp/vglite/lv_draw_vglite.c | 10 ++++++++--
|
||||||
|
3 files changed, 10 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/draw/lv_draw.c b/src/draw/lv_draw.c
|
||||||
|
index c84816c91..0f6f85bbf 100644
|
||||||
|
--- a/src/draw/lv_draw.c
|
||||||
|
+++ b/src/draw/lv_draw.c
|
||||||
|
@@ -57,6 +57,7 @@ void * lv_draw_create_unit(size_t size)
|
||||||
|
|
||||||
|
new_unit->next = _draw_info.unit_head;
|
||||||
|
_draw_info.unit_head = new_unit;
|
||||||
|
+ _draw_info.unit_count++;
|
||||||
|
|
||||||
|
return new_unit;
|
||||||
|
}
|
||||||
|
diff --git a/src/draw/lv_draw.h b/src/draw/lv_draw.h
|
||||||
|
index 6eb99e71a..497a444be 100644
|
||||||
|
--- a/src/draw/lv_draw.h
|
||||||
|
+++ b/src/draw/lv_draw.h
|
||||||
|
@@ -174,6 +174,7 @@ typedef struct {
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
lv_draw_unit_t * unit_head;
|
||||||
|
+ uint32_t unit_count;
|
||||||
|
uint32_t used_memory_for_layers_kb;
|
||||||
|
#if LV_USE_OS
|
||||||
|
lv_thread_sync_t sync;
|
||||||
|
diff --git a/src/draw/nxp/vglite/lv_draw_vglite.c b/src/draw/nxp/vglite/lv_draw_vglite.c
|
||||||
|
index 3278bb548..fe2fd8179 100644
|
||||||
|
--- a/src/draw/nxp/vglite/lv_draw_vglite.c
|
||||||
|
+++ b/src/draw/nxp/vglite/lv_draw_vglite.c
|
||||||
|
@@ -20,12 +20,15 @@
|
||||||
|
#include "lv_vglite_buf.h"
|
||||||
|
#include "lv_vglite_utils.h"
|
||||||
|
|
||||||
|
+#include "../../../core/lv_global.h"
|
||||||
|
#include "../../../display/lv_display_private.h"
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* DEFINES
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
+#define _draw_info LV_GLOBAL_DEFAULT()->draw_info
|
||||||
|
+
|
||||||
|
#define DRAW_UNIT_ID_VGLITE 2
|
||||||
|
|
||||||
|
#if LV_USE_OS
|
||||||
|
@@ -237,9 +240,12 @@ static int32_t _vglite_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer)
|
||||||
|
/* Try to get an ready to draw. */
|
||||||
|
lv_draw_task_t * t = lv_draw_get_next_available_task(layer, NULL, DRAW_UNIT_ID_VGLITE);
|
||||||
|
|
||||||
|
- /* Return 0 is no selection, some tasks can be supported by other units. */
|
||||||
|
+ /* If no selection:
|
||||||
|
+ * return 0 if any other unit is available and might support the task
|
||||||
|
+ * return -1 if no more units
|
||||||
|
+ */
|
||||||
|
if(t == NULL || t->preferred_draw_unit_id != DRAW_UNIT_ID_VGLITE)
|
||||||
|
- return 0;
|
||||||
|
+ return (_draw_info.unit_count > 1 ? 0 : -1);
|
||||||
|
|
||||||
|
void * buf = lv_draw_layer_alloc_buf(layer);
|
||||||
|
if(buf == NULL)
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
@@ -96,7 +96,8 @@ lv_result_t lv_thread_delete(lv_thread_t * pxThread)
|
|||||||
|
|
||||||
lv_result_t lv_mutex_init(lv_mutex_t * pxMutex)
|
lv_result_t lv_mutex_init(lv_mutex_t * pxMutex)
|
||||||
{
|
{
|
||||||
prvMutexInit(pxMutex);
|
/* If mutex in uninitialized, perform initialization. */
|
||||||
|
prvCheckMutexInit(pxMutex);
|
||||||
|
|
||||||
return LV_RESULT_OK;
|
return LV_RESULT_OK;
|
||||||
}
|
}
|
||||||
@@ -165,7 +166,8 @@ lv_result_t lv_thread_sync_init(lv_thread_sync_t * pxCond)
|
|||||||
/* Store the handle of the calling task. */
|
/* Store the handle of the calling task. */
|
||||||
pxCond->xTaskToNotify = xTaskGetCurrentTaskHandle();
|
pxCond->xTaskToNotify = xTaskGetCurrentTaskHandle();
|
||||||
#else
|
#else
|
||||||
prvCondInit(pxCond);
|
/* If the cond is uninitialized, perform initialization. */
|
||||||
|
prvCheckCondInit(pxCond);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return LV_RESULT_OK;
|
return LV_RESULT_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user