feat(nuttx): refactor Nuttx porting layer (#4634)
Signed-off-by: YanXiaowei <yanxiaowei@xiaomi.com> Co-authored-by: YanXiaowei <yanxiaowei@xiaomi.com>
This commit is contained in:
19
Kconfig
19
Kconfig
@@ -1236,12 +1236,18 @@ menu "LVGL configuration"
|
|||||||
depends on LV_USE_LINUX_FBDEV && LV_LINUX_FBDEV_CUSTOM_BUFFER
|
depends on LV_USE_LINUX_FBDEV && LV_LINUX_FBDEV_CUSTOM_BUFFER
|
||||||
default 60
|
default 60
|
||||||
|
|
||||||
config LV_USE_NUTTX_FBDEV
|
config LV_USE_NUTTX
|
||||||
bool "Use Nuttx framebuffer device"
|
bool "Use Nuttx to open window and handle touchscreen"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config LV_USE_NUTTX_CUSTOM_INIT
|
||||||
|
bool "Use Custom Nuttx init API to open window and handle touchscreen"
|
||||||
|
depends on LV_USE_NUTTX
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config LV_USE_NUTTX_LCD
|
config LV_USE_NUTTX_LCD
|
||||||
bool "Use NuttX LCD device"
|
bool "Use NuttX LCD device"
|
||||||
|
depends on LV_USE_NUTTX
|
||||||
default n
|
default n
|
||||||
|
|
||||||
choice
|
choice
|
||||||
@@ -1272,6 +1278,11 @@ menu "LVGL configuration"
|
|||||||
depends on LV_USE_NUTTX_LCD && LV_NUTTX_LCD_CUSTOM_BUFFER
|
depends on LV_USE_NUTTX_LCD && LV_NUTTX_LCD_CUSTOM_BUFFER
|
||||||
default 60
|
default 60
|
||||||
|
|
||||||
|
config LV_USE_NUTTX_TOUCHSCREEN
|
||||||
|
bool "Use NuttX touchscreen driver"
|
||||||
|
depends on LV_USE_NUTTX
|
||||||
|
default n
|
||||||
|
|
||||||
config LV_USE_LINUX_DRM
|
config LV_USE_LINUX_DRM
|
||||||
bool "Use Linux DRM device"
|
bool "Use Linux DRM device"
|
||||||
default n
|
default n
|
||||||
@@ -1279,10 +1290,6 @@ menu "LVGL configuration"
|
|||||||
config LV_USE_TFT_ESPI
|
config LV_USE_TFT_ESPI
|
||||||
bool "Use TFT_eSPI driver"
|
bool "Use TFT_eSPI driver"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config LV_USE_NUTTX_TOUCHSCREEN
|
|
||||||
bool "Use NuttX touchscreen driver"
|
|
||||||
default n
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Examples"
|
menu "Examples"
|
||||||
|
|||||||
@@ -754,7 +754,11 @@
|
|||||||
#define LV_LINUX_FBDEV_BUFFER_SIZE 60
|
#define LV_LINUX_FBDEV_BUFFER_SIZE 60
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LV_USE_NUTTX_FBDEV 0
|
/*Use Nuttx to open window and handle touchscreen*/
|
||||||
|
#define LV_USE_NUTTX 0
|
||||||
|
|
||||||
|
/*Use Nuttx custom init API to open window and handle touchscreen*/
|
||||||
|
#define LV_USE_NUTTX_CUSTOM_INIT 0
|
||||||
|
|
||||||
/*Driver for /dev/lcd*/
|
/*Driver for /dev/lcd*/
|
||||||
#define LV_USE_NUTTX_LCD 0
|
#define LV_USE_NUTTX_LCD 0
|
||||||
@@ -763,15 +767,15 @@
|
|||||||
#define LV_NUTTX_LCD_BUFFER_SIZE 60
|
#define LV_NUTTX_LCD_BUFFER_SIZE 60
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*Driver for /dev/input*/
|
||||||
|
#define LV_USE_NUTTX_TOUCHSCREEN 0
|
||||||
|
|
||||||
/*Driver for /dev/dri/card*/
|
/*Driver for /dev/dri/card*/
|
||||||
#define LV_USE_LINUX_DRM 0
|
#define LV_USE_LINUX_DRM 0
|
||||||
|
|
||||||
/*Interface for TFT_eSPI*/
|
/*Interface for TFT_eSPI*/
|
||||||
#define LV_USE_TFT_ESPI 0
|
#define LV_USE_TFT_ESPI 0
|
||||||
|
|
||||||
/*Driver for /dev/input*/
|
|
||||||
#define LV_USE_NUTTX_TOUCHSCREEN 0
|
|
||||||
|
|
||||||
/*==================
|
/*==================
|
||||||
* EXAMPLES
|
* EXAMPLES
|
||||||
*==================*/
|
*==================*/
|
||||||
|
|||||||
7
lvgl.h
7
lvgl.h
@@ -118,10 +118,11 @@ extern "C" {
|
|||||||
|
|
||||||
#include "src/dev/display/drm/lv_linux_drm.h"
|
#include "src/dev/display/drm/lv_linux_drm.h"
|
||||||
#include "src/dev/display/fb/lv_linux_fbdev.h"
|
#include "src/dev/display/fb/lv_linux_fbdev.h"
|
||||||
#include "src/dev/display/fb/lv_nuttx_fbdev.h"
|
|
||||||
#include "src/dev/display/lcd/lv_nuttx_lcd.h"
|
|
||||||
|
|
||||||
#include "src/dev/input/touchscreen/lv_nuttx_touchscreen.h"
|
#include "src/dev/nuttx/lv_nuttx_entry.h"
|
||||||
|
#include "src/dev/nuttx/lv_nuttx_fbdev.h"
|
||||||
|
#include "src/dev/nuttx/lv_nuttx_touchscreen.h"
|
||||||
|
#include "src/dev/nuttx/lv_nuttx_lcd.h"
|
||||||
|
|
||||||
#include "src/core/lv_global.h"
|
#include "src/core/lv_global.h"
|
||||||
/*********************
|
/*********************
|
||||||
|
|||||||
129
src/dev/nuttx/lv_nuttx_entry.c
Normal file
129
src/dev/nuttx/lv_nuttx_entry.c
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/**
|
||||||
|
* @file lv_nuttx_entry.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* INCLUDES
|
||||||
|
*********************/
|
||||||
|
#include "lv_nuttx_entry.h"
|
||||||
|
|
||||||
|
#if LV_USE_NUTTX
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* DEFINES
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* TYPEDEFS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC PROTOTYPES
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
static uint32_t millis(void);
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC VARIABLES
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* MACROS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* GLOBAL FUNCTIONS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
#if LV_ENABLE_GLOBAL_CUSTOM
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lv_global_free
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void lv_global_free(void * data)
|
||||||
|
{
|
||||||
|
if(data) {
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lv_global_default
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
lv_global_t * lv_global_default(void)
|
||||||
|
{
|
||||||
|
static int index = -1;
|
||||||
|
lv_global_t * data;
|
||||||
|
|
||||||
|
if(index < 0) {
|
||||||
|
index = task_tls_alloc(lv_global_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(index >= 0) {
|
||||||
|
data = (lv_global_t *)task_tls_get_value(index);
|
||||||
|
if(data == NULL) {
|
||||||
|
data = (lv_global_t *)calloc(1, sizeof(lv_global_t));
|
||||||
|
task_tls_set_value(index, (uintptr_t)data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lv_display_t * lv_nuttx_init(lv_nuttx_t * info)
|
||||||
|
{
|
||||||
|
lv_display_t * disp = NULL;
|
||||||
|
|
||||||
|
#if !LV_USE_NUTTX_CUSTOM_INIT
|
||||||
|
|
||||||
|
if(info && info->fb_path) {
|
||||||
|
#if LV_USE_NUTTX_LCD
|
||||||
|
disp = lv_nuttx_lcd_create(info->fb_path);
|
||||||
|
#else
|
||||||
|
disp = lv_nuttx_fbdev_create();
|
||||||
|
if(lv_nuttx_fbdev_set_file(disp, info->fb_path) != 0) {
|
||||||
|
lv_display_remove(disp);
|
||||||
|
disp = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info && info->input_path) {
|
||||||
|
#if LV_USE_NUTTX_TOUCHSCREEN
|
||||||
|
lv_nuttx_touchscreen_create(info->input_path);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
disp = lv_nuttx_init_custom(info);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lv_tick_set_cb(millis);
|
||||||
|
|
||||||
|
return disp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC FUNCTIONS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
static uint32_t millis(void)
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
uint32_t tick = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||||
|
|
||||||
|
return tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*LV_USE_NUTTX*/
|
||||||
59
src/dev/nuttx/lv_nuttx_entry.h
Normal file
59
src/dev/nuttx/lv_nuttx_entry.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* @file lv_nuttx_entry.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* INCLUDES
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
#ifndef LV_NUTTX_ENTRY_H
|
||||||
|
#define LV_NUTTX_ENTRY_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* INCLUDES
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
#include "../../display/lv_display.h"
|
||||||
|
#include "../../indev/lv_indev.h"
|
||||||
|
|
||||||
|
#if LV_USE_NUTTX
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* DEFINES
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* TYPEDEFS
|
||||||
|
**********************/
|
||||||
|
typedef struct {
|
||||||
|
const char * fb_path;
|
||||||
|
const char * input_path;
|
||||||
|
bool need_wait_vsync;
|
||||||
|
} lv_nuttx_t;
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* GLOBAL PROTOTYPES
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
lv_display_t * lv_nuttx_init(lv_nuttx_t * info);
|
||||||
|
|
||||||
|
#if LV_USE_NUTTX_CUSTOM_INIT
|
||||||
|
lv_display_t * lv_nuttx_init_custom(lv_nuttx_t * info);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* MACROS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
#endif /* LV_USE_NUTTX*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LV_NUTTX_ENTRY_H */
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
#include "lv_nuttx_fbdev.h"
|
#include "lv_nuttx_fbdev.h"
|
||||||
#if LV_USE_NUTTX_FBDEV
|
#if LV_USE_NUTTX
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -18,8 +18,9 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <nuttx/video/fb.h>
|
#include <nuttx/video/fb.h>
|
||||||
|
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
#include "../../../lvgl_private.h"
|
#include "../../lvgl_private.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@@ -286,4 +287,4 @@ static int fbdev_init_mem2(lv_nuttx_fb_t * dsc)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /*LV_USE_NUTTX_FBDEV*/
|
#endif /*LV_USE_NUTTX*/
|
||||||
@@ -14,9 +14,9 @@ extern "C" {
|
|||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#include "../../../display/lv_display.h"
|
#include "lv_nuttx_entry.h"
|
||||||
|
|
||||||
#if LV_USE_NUTTX_FBDEV
|
#if LV_USE_NUTTX
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@@ -37,7 +37,7 @@ int lv_nuttx_fbdev_set_file(lv_display_t * disp, const char * file);
|
|||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
#endif /* LV_USE_NUTTX_FBDEV */
|
#endif /* LV_USE_NUTTX */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#include "lv_nuttx_lcd.h"
|
#include "lv_nuttx_lcd.h"
|
||||||
|
|
||||||
#if LV_USE_NUTTX_LCD
|
#if LV_USE_NUTTX_LCD
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
#include <nuttx/lcd/lcd_dev.h>
|
#include <nuttx/lcd/lcd_dev.h>
|
||||||
|
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
#include "../../../lvgl_private.h"
|
#include "../../lvgl_private.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@@ -14,7 +14,7 @@ extern "C" {
|
|||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#include "../../../display/lv_display.h"
|
#include "lv_nuttx_entry.h"
|
||||||
|
|
||||||
#if LV_USE_NUTTX_LCD
|
#if LV_USE_NUTTX_LCD
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <nuttx/input/touchscreen.h>
|
#include <nuttx/input/touchscreen.h>
|
||||||
#include "../../../lvgl_private.h"
|
#include "../../lvgl_private.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@@ -137,4 +137,4 @@ static lv_indev_t * touchscreen_init(int fd)
|
|||||||
return touchscreen->indev_drv;
|
return touchscreen->indev_drv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /*LV_USE_NUTTX_SCREEN*/
|
#endif /*LV_USE_NUTTX_TOUCHSCREEN*/
|
||||||
@@ -18,7 +18,7 @@ extern "C" {
|
|||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#include "../../../indev/lv_indev.h"
|
#include "lv_nuttx_entry.h"
|
||||||
|
|
||||||
#if LV_USE_NUTTX_TOUCHSCREEN
|
#if LV_USE_NUTTX_TOUCHSCREEN
|
||||||
|
|
||||||
@@ -2478,11 +2478,21 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LV_USE_NUTTX_FBDEV
|
/*Use Nuttx to open window and handle touchscreen*/
|
||||||
#ifdef CONFIG_LV_USE_NUTTX_FBDEV
|
#ifndef LV_USE_NUTTX
|
||||||
#define LV_USE_NUTTX_FBDEV CONFIG_LV_USE_NUTTX_FBDEV
|
#ifdef CONFIG_LV_USE_NUTTX
|
||||||
|
#define LV_USE_NUTTX CONFIG_LV_USE_NUTTX
|
||||||
#else
|
#else
|
||||||
#define LV_USE_NUTTX_FBDEV 0
|
#define LV_USE_NUTTX 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*Use Nuttx custom init API to open window and handle touchscreen*/
|
||||||
|
#ifndef LV_USE_NUTTX_CUSTOM_INIT
|
||||||
|
#ifdef CONFIG_LV_USE_NUTTX_CUSTOM_INIT
|
||||||
|
#define LV_USE_NUTTX_CUSTOM_INIT CONFIG_LV_USE_NUTTX_CUSTOM_INIT
|
||||||
|
#else
|
||||||
|
#define LV_USE_NUTTX_CUSTOM_INIT 0
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2511,6 +2521,15 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*Driver for /dev/input*/
|
||||||
|
#ifndef LV_USE_NUTTX_TOUCHSCREEN
|
||||||
|
#ifdef CONFIG_LV_USE_NUTTX_TOUCHSCREEN
|
||||||
|
#define LV_USE_NUTTX_TOUCHSCREEN CONFIG_LV_USE_NUTTX_TOUCHSCREEN
|
||||||
|
#else
|
||||||
|
#define LV_USE_NUTTX_TOUCHSCREEN 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*Driver for /dev/dri/card*/
|
/*Driver for /dev/dri/card*/
|
||||||
#ifndef LV_USE_LINUX_DRM
|
#ifndef LV_USE_LINUX_DRM
|
||||||
#ifdef CONFIG_LV_USE_LINUX_DRM
|
#ifdef CONFIG_LV_USE_LINUX_DRM
|
||||||
@@ -2529,15 +2548,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*Driver for /dev/input*/
|
|
||||||
#ifndef LV_USE_NUTTX_TOUCHSCREEN
|
|
||||||
#ifdef CONFIG_LV_USE_NUTTX_TOUCHSCREEN
|
|
||||||
#define LV_USE_NUTTX_TOUCHSCREEN CONFIG_LV_USE_NUTTX_TOUCHSCREEN
|
|
||||||
#else
|
|
||||||
#define LV_USE_NUTTX_TOUCHSCREEN 0
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*==================
|
/*==================
|
||||||
* EXAMPLES
|
* EXAMPLES
|
||||||
*==================*/
|
*==================*/
|
||||||
|
|||||||
Reference in New Issue
Block a user