diff --git a/scripts/prerequisites-apt.txt b/scripts/prerequisites-apt.txt index 75ad7298d0..7c76b794b5 100644 --- a/scripts/prerequisites-apt.txt +++ b/scripts/prerequisites-apt.txt @@ -38,3 +38,5 @@ libavformat-dev:i386 libavcodec-dev:i386 libswscale-dev:i386 libavutil-dev:i386 +libuv1-dev +libuv1-dev:i386 diff --git a/src/drivers/nuttx/lv_nuttx_cache.c b/src/drivers/nuttx/lv_nuttx_cache.c index ec1833c1a9..9acd1b269e 100644 --- a/src/drivers/nuttx/lv_nuttx_cache.c +++ b/src/drivers/nuttx/lv_nuttx_cache.c @@ -14,7 +14,12 @@ #include "../../draw/lv_draw_buf_private.h" #include "../../core/lv_global.h" -#include + +#ifdef __NuttX__ + #include +#else + #include "mock/nuttx_cache.h" +#endif /********************* * DEFINES diff --git a/src/drivers/nuttx/lv_nuttx_entry.c b/src/drivers/nuttx/lv_nuttx_entry.c index 47c3b18ae2..f4949caec3 100644 --- a/src/drivers/nuttx/lv_nuttx_entry.c +++ b/src/drivers/nuttx/lv_nuttx_entry.c @@ -11,18 +11,27 @@ #if LV_USE_NUTTX #include -#include -#include #include #include +#include #include "lv_nuttx_cache.h" #include "lv_nuttx_image_cache.h" #include "../../core/lv_global.h" #include "lv_nuttx_profiler.h" #include "lv_nuttx_mouse.h" - #include "../../../lvgl.h" +#if LV_USE_NUTTX_LIBUV + #include +#endif + +#ifdef __NuttX__ + #include + #include +#else + #include "mock/nuttx_clock.h" +#endif + /********************* * DEFINES *********************/ @@ -49,7 +58,7 @@ static uint32_t millis(void); #endif static void check_stack_size(void); -#ifdef CONFIG_LV_USE_NUTTX_LIBUV +#if LV_USE_NUTTX_LIBUV static void lv_nuttx_uv_loop(lv_nuttx_result_t * result); #endif @@ -198,9 +207,10 @@ void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result) void lv_nuttx_run(lv_nuttx_result_t * result) { -#ifdef CONFIG_LV_USE_NUTTX_LIBUV - lv_nuttx_uv_loop(&ui_loop, result); +#if LV_USE_NUTTX_LIBUV + lv_nuttx_uv_loop(result); #else + LV_UNUSED(result); while(1) { uint32_t idle; idle = lv_timer_handler(); @@ -294,7 +304,7 @@ static void syslog_print(lv_log_level_t level, const char * buf) } #endif -#ifdef CONFIG_LV_USE_NUTTX_LIBUV +#if LV_USE_NUTTX_LIBUV static void lv_nuttx_uv_loop(lv_nuttx_result_t * result) { uv_loop_t loop; @@ -312,7 +322,7 @@ static void lv_nuttx_uv_loop(lv_nuttx_result_t * result) #endif data = lv_nuttx_uv_init(&uv_info); - uv_run(loop, UV_RUN_DEFAULT); + uv_run(&loop, UV_RUN_DEFAULT); lv_nuttx_uv_deinit(&data); } #endif diff --git a/src/drivers/nuttx/lv_nuttx_fbdev.c b/src/drivers/nuttx/lv_nuttx_fbdev.c index 1057c3bee2..4849c52094 100644 --- a/src/drivers/nuttx/lv_nuttx_fbdev.c +++ b/src/drivers/nuttx/lv_nuttx_fbdev.c @@ -18,7 +18,12 @@ #include #include #include -#include + +#ifdef __NuttX__ + #include +#else + #include "mock/nuttx_video_fb.h" +#endif #include "../../../lvgl.h" #include "../../lvgl_private.h" @@ -334,7 +339,7 @@ static lv_color_format_t fb_fmt_to_color_format(int fmt) return LV_COLOR_FORMAT_UNKNOWN; } -static int fbdev_get_pinfo(int fd, FAR struct fb_planeinfo_s * pinfo) +static int fbdev_get_pinfo(int fd, struct fb_planeinfo_s * pinfo) { if(ioctl(fd, FBIOGET_PLANEINFO, (unsigned long)((uintptr_t)pinfo)) < 0) { LV_LOG_ERROR("ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d", errno); @@ -443,7 +448,7 @@ static int fbdev_init_mem3(lv_nuttx_fb_t * dsc) * It needs to be divisible by pinfo.stride */ - buf_offset = pinfo.fbmem - dsc->mem; + buf_offset = (uintptr_t)pinfo.fbmem - (uintptr_t)dsc->mem; if((buf_offset % dsc->pinfo.stride) != 0) { LV_LOG_WARN("It is detected that buf_offset(%" PRIuPTR ") " @@ -456,7 +461,7 @@ static int fbdev_init_mem3(lv_nuttx_fb_t * dsc) if(buf_offset == 0) { dsc->mem3_yoffset = dsc->vinfo.yres * 2; - dsc->mem3 = pinfo.fbmem + dsc->mem3_yoffset * pinfo.stride; + dsc->mem3 = (uint8_t *)pinfo.fbmem + dsc->mem3_yoffset * pinfo.stride; LV_LOG_USER("Use consecutive mem3 = %p, yoffset = %" LV_PRIu32, dsc->mem3, dsc->mem3_yoffset); } diff --git a/src/drivers/nuttx/lv_nuttx_image_cache.c b/src/drivers/nuttx/lv_nuttx_image_cache.c index 8171f78f3b..1426d9b6a6 100644 --- a/src/drivers/nuttx/lv_nuttx_image_cache.c +++ b/src/drivers/nuttx/lv_nuttx_image_cache.c @@ -14,7 +14,13 @@ #if LV_USE_NUTTX #include "../../draw/lv_draw_buf_private.h" -#include +#include + +#ifdef __NuttX__ + #include +#else + #include "mock/nuttx_mm.h" +#endif /********************* * DEFINES @@ -157,7 +163,7 @@ static bool defer_init(void) ctx->heap_size = info.arena; LV_LOG_USER("heap info:"); - LV_LOG_USER(" heap: %p", ctx->heap); + LV_LOG_USER(" heap: %p", (void *)ctx->heap); LV_LOG_USER(" mem: %p", ctx->mem); LV_LOG_USER(" mem_size: %" LV_PRIu32, ctx->mem_size); LV_LOG_USER(" arena: %d", info.arena); diff --git a/src/drivers/nuttx/lv_nuttx_lcd.c b/src/drivers/nuttx/lv_nuttx_lcd.c index 43385b0510..3b0fd121f3 100644 --- a/src/drivers/nuttx/lv_nuttx_lcd.c +++ b/src/drivers/nuttx/lv_nuttx_lcd.c @@ -17,14 +17,19 @@ #include #include #include -#include #include #include -#include #include "../../../lvgl.h" #include "../../lvgl_private.h" +#ifdef __NuttX__ + #include + #include +#else + #include "mock/nuttx_lcd_dev.h" +#endif + /********************* * DEFINES *********************/ diff --git a/src/drivers/nuttx/lv_nuttx_mouse.c b/src/drivers/nuttx/lv_nuttx_mouse.c index 211669408c..c1516a4d8b 100644 --- a/src/drivers/nuttx/lv_nuttx_mouse.c +++ b/src/drivers/nuttx/lv_nuttx_mouse.c @@ -17,12 +17,18 @@ #include #include #include -#include #include #include -#include +#include #include "../../lvgl_private.h" +#ifdef __NuttX__ + #include + #include +#else + #include "mock/nuttx_input_mouse.h" +#endif + /********************* * DEFINES *********************/ diff --git a/src/drivers/nuttx/lv_nuttx_profiler.c b/src/drivers/nuttx/lv_nuttx_profiler.c index 6825b23035..016de78f51 100644 --- a/src/drivers/nuttx/lv_nuttx_profiler.c +++ b/src/drivers/nuttx/lv_nuttx_profiler.c @@ -13,10 +13,20 @@ #include "../../misc/lv_profiler_builtin_private.h" #include "../../misc/lv_log.h" +#include "../../core/lv_global.h" #include "../../stdlib/lv_sprintf.h" -#include +#include "../../stdlib/lv_string.h" +#include "lv_nuttx_entry.h" #include #include +#include +#include + +#ifdef __NuttX__ + #include +#else + #include "mock/nuttx_arch.h" +#endif /********************* * DEFINES @@ -126,7 +136,7 @@ static void flush_cb(const char * buf) { #if LV_USE_NUTTX_TRACE_FILE if(trace_fd >= 0) { - write(trace_fd, buf, strlen(buf)); + write(trace_fd, buf, lv_strlen(buf)); return; } #endif diff --git a/src/drivers/nuttx/lv_nuttx_touchscreen.c b/src/drivers/nuttx/lv_nuttx_touchscreen.c index b34e71021d..210e87aace 100644 --- a/src/drivers/nuttx/lv_nuttx_touchscreen.c +++ b/src/drivers/nuttx/lv_nuttx_touchscreen.c @@ -17,12 +17,17 @@ #include #include #include -#include #include #include -#include #include "../../lvgl_private.h" +#ifdef __NuttX__ + #include + #include +#else + #include "mock/nuttx_input_touchscreen.h" +#endif + /********************* * DEFINES *********************/ diff --git a/src/drivers/nuttx/mock/nuttx_arch.h b/src/drivers/nuttx/mock/nuttx_arch.h new file mode 100644 index 0000000000..bf8d5e9452 --- /dev/null +++ b/src/drivers/nuttx/mock/nuttx_arch.h @@ -0,0 +1,49 @@ +/** + * @file nuttx_arch.h + * + */ + +#ifndef NUTTX_ARCH_H +#define NUTTX_ARCH_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +static inline unsigned long up_perf_getfreq(void) +{ + return 1000000; /*1 MHz for mock*/ +} + +static inline uint32_t up_perf_gettime(void) +{ + return 0; +} + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*NUTTX_ARCH_H*/ diff --git a/src/drivers/nuttx/mock/nuttx_cache.h b/src/drivers/nuttx/mock/nuttx_cache.h new file mode 100644 index 0000000000..1ecaa9b4cf --- /dev/null +++ b/src/drivers/nuttx/mock/nuttx_cache.h @@ -0,0 +1,51 @@ +/** + * @file nuttx_cache.h + * + */ + +#ifndef NUTTX_CACHE_H +#define NUTTX_CACHE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include + +/********************* + * DEFINES + *********************/ + +/********************* + * TYPEDEFS + *********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +static inline void up_invalidate_dcache(uintptr_t start, uintptr_t end) +{ + (void)start; + (void)end; +} + +static inline void up_flush_dcache(uintptr_t start, uintptr_t end) +{ + (void)start; + (void)end; +} + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*NUTTX_CACHE_H*/ diff --git a/src/drivers/nuttx/mock/nuttx_clock.h b/src/drivers/nuttx/mock/nuttx_clock.h new file mode 100644 index 0000000000..d2486c9985 --- /dev/null +++ b/src/drivers/nuttx/mock/nuttx_clock.h @@ -0,0 +1,55 @@ +/** + * @file nuttx_clock.h + * + */ + +#ifndef NUTTX_CLOCK_H +#define NUTTX_CLOCK_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include + +/********************* + * DEFINES + *********************/ + +#define CONFIG_SCHED_CPULOAD 1 + +#define pthread_get_stacksize_np(tid) 0 + +/********************** + * TYPEDEFS + **********************/ + +struct cpuload_s { + volatile uint32_t total; /* Total number of clock ticks */ + volatile uint32_t active; /* Number of ticks while this thread was active */ +}; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +static inline int clock_cpuload(int pid, struct cpuload_s * cpuload) +{ + (void)pid; + (void)cpuload; + return -1; +} + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*NUTTX_CLOCK_H*/ diff --git a/src/drivers/nuttx/mock/nuttx_input_mouse.h b/src/drivers/nuttx/mock/nuttx_input_mouse.h new file mode 100644 index 0000000000..f9cee77db2 --- /dev/null +++ b/src/drivers/nuttx/mock/nuttx_input_mouse.h @@ -0,0 +1,55 @@ +/** + * @file nuttx_input_mouse.h + * + */ + +#ifndef NUTTX_INPUT_MOUSE_H +#define NUTTX_INPUT_MOUSE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include + +/********************* + * DEFINES + *********************/ + +/* These definitions provide the meaning of all of the bits that may be + * reported in the struct mouse_report_s buttons. + */ + +#define MOUSE_BUTTON_1 (1 << 0) /* True: Left mouse button pressed */ +#define MOUSE_BUTTON_2 (1 << 1) /* True: Right mouse button pressed */ +#define MOUSE_BUTTON_3 (1 << 2) /* True: Middle mouse button pressed */ + +/********************** + * TYPEDEFS + **********************/ + +struct mouse_report_s { + uint8_t buttons; /* See MOUSE_* definitions above */ + uint8_t dummy; /* Padded with 1 byte here */ + int16_t x; /* X coordinate of the mouse position */ + int16_t y; /* Y coordinate of the mouse position */ + int16_t wheel; /* Mouse wheel position */ +}; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*NUTTX_INPUT_MOUSE_H*/ diff --git a/src/drivers/nuttx/mock/nuttx_input_touchscreen.h b/src/drivers/nuttx/mock/nuttx_input_touchscreen.h new file mode 100644 index 0000000000..2d1858f51e --- /dev/null +++ b/src/drivers/nuttx/mock/nuttx_input_touchscreen.h @@ -0,0 +1,125 @@ +/** + * @file nuttx_input_touchscreen.h + * + */ + +#ifndef NUTTX_INPUT_TOUCHSCREEN_H +#define NUTTX_INPUT_TOUCHSCREEN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include + +/********************* + * DEFINES + *********************/ + +#define _TSIOC(x) (x) + +/* Common TSC IOCTL commands */ + +#define TSIOC_SETXRCAL _TSIOC(0x0001) /* arg: Pointer to + * int Xplate R calibration value + */ +#define TSIOC_GETXRCAL _TSIOC(0x0002) /* arg: Pointer to + * int Xplate R calibration value + */ +#define TSIOC_SETFREQUENCY _TSIOC(0x0003) /* arg: Pointer to + * uint32_t frequency value + */ +#define TSIOC_GETFREQUENCY _TSIOC(0x0004) /* arg: Pointer to + * uint32_t frequency value + */ +#define TSIOC_GETFWVERSION _TSIOC(0x0005) /* arg: Pointer to + * uint32_t firmware version + * value + * */ +#define TSIOC_ENABLEGESTURE _TSIOC(0x0006) /* arg: Pointer to + * int for enable gesture feature + */ +#define TSIOC_DOACALIB _TSIOC(0x0007) /* arg: none. + * Initiate TS auto calibration + */ +#define TSIOC_CALDATA _TSIOC(0x0008) /* arg: Pointer to + * struct g_tscaldata_s + */ +#define TSIOC_USESCALED _TSIOC(0x0009) /* arg: bool, yes/no */ +#define TSIOC_GETOFFSETX _TSIOC(0x000a) /* arg: Pointer to + * int X offset value + */ +#define TSIOC_GETOFFSETY _TSIOC(0x000b) /* arg: Pointer to + * int Y offset value + */ +#define TSIOC_GETTHRESHX _TSIOC(0x000c) /* arg: Pointer to + * int X threshold value + */ +#define TSIOC_GETTHRESHY _TSIOC(0x000d) /* arg: Pointer to + * int Y threshold value + */ + +#define TSIOC_GRAB _TSIOC(0x000e) /* arg: Pointer to + * int for enable grab + */ + +#define TSIOC_GETMAXPOINTS _TSIOC(0x000f) /* arg: Pointer to + * uint8_t max touch point + */ +#define TSIOC_GETRESOLUTION _TSIOC(0x0010) /* arg: Pointer to + * struct touch_resolution_s + */ + +/* These definitions provide the meaning of all of the bits that may be + * reported in the struct touch_point_s flags. + */ + +#define TOUCH_DOWN (1 << 0) /* A new touch contact is established */ +#define TOUCH_MOVE (1 << 1) /* Movement occurred with previously reported contact */ +#define TOUCH_UP (1 << 2) /* The touch contact was lost */ +#define TOUCH_ID_VALID (1 << 3) /* Touch ID is certain */ +#define TOUCH_POS_VALID (1 << 4) /* Hardware provided a valid X/Y position */ +#define TOUCH_PRESSURE_VALID (1 << 5) /* Hardware provided a valid pressure */ +#define TOUCH_SIZE_VALID (1 << 6) /* Hardware provided a valid H/W contact size */ +#define TOUCH_GESTURE_VALID (1 << 7) /* Hardware provided a valid gesture */ + +/********************** + * TYPEDEFS + **********************/ + +struct touch_point_s { + uint8_t id; /* Unique identifies contact; Same in all reports for the contact */ + uint8_t flags; /* See TOUCH_* definitions above */ + int16_t x; /* X coordinate of the touch point (uncalibrated) */ + int16_t y; /* Y coordinate of the touch point (uncalibrated) */ + int16_t h; /* Height of touch point (uncalibrated) */ + int16_t w; /* Width of touch point (uncalibrated) */ + uint16_t gesture; /* Gesture of touchscreen contact */ + uint16_t pressure; /* Touch pressure */ + uint16_t dummy; /* Padded with 2 bytes here */ + uint64_t timestamp; /* Touch event time stamp, in microseconds */ +}; + +struct touch_sample_s { + int32_t npoints; /* The number of touch points in point[] */ + int32_t dummy; /* Padded with 4 bytes here */ + struct touch_point_s point[1]; /* Actual dimension is npoints */ +}; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*NUTTX_INPUT_TOUCHSCREEN_H*/ diff --git a/src/drivers/nuttx/mock/nuttx_lcd_dev.h b/src/drivers/nuttx/mock/nuttx_lcd_dev.h new file mode 100644 index 0000000000..38fb7a5fda --- /dev/null +++ b/src/drivers/nuttx/mock/nuttx_lcd_dev.h @@ -0,0 +1,104 @@ +/** + * @file nuttx_lcd_dev.h + * + */ + +#ifndef NUTTX_LCD_DEV_H +#define NUTTX_LCD_DEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include "nuttx_video_fb.h" + +/********************* + * DEFINES + *********************/ + +#define _LCDIOC(x) (x) + +#define LCDDEVIO_PUTRUN _LCDIOC(0) /* Arg: const struct lcddev_run_s* */ +#define LCDDEVIO_PUTAREA _LCDIOC(1) /* Arg: const struct lcddev_area_s* */ +#define LCDDEVIO_GETRUN _LCDIOC(2) /* Arg: struct lcddev_run_s* */ +#define LCDDEVIO_GETAREA _LCDIOC(3) /* Arg: struct lcddev_area_s* */ +#define LCDDEVIO_GETPOWER _LCDIOC(4) /* Arg: int* */ +#define LCDDEVIO_SETPOWER _LCDIOC(5) /* Arg: int */ +#define LCDDEVIO_GETCONTRAST _LCDIOC(6) /* Arg: int* */ +#define LCDDEVIO_SETCONTRAST _LCDIOC(7) /* Arg: unsigned int */ +#define LCDDEVIO_GETPLANEINFO _LCDIOC(8) /* Arg: struct lcd_planeinfo_s* */ +#define LCDDEVIO_GETVIDEOINFO _LCDIOC(9) /* Arg: struct fb_videoinfo_s* */ +#define LCDDEVIO_SETPLANENO _LCDIOC(10) /* Arg: int */ + +#define LCDDEVIO_GETAREAALIGN _LCDIOC(17) /* Arg: struct lcddev_area_align_s* */ + +/********************** + * TYPEDEFS + **********************/ + +struct lcddev_area_s { + fb_coord_t row_start, row_end; + fb_coord_t col_start, col_end; + fb_coord_t stride; /* row stride in bytes */ + uint8_t * data; +}; + +/* Some special LCD drivers require input data to be aligned. + * Such as starting row and column, width, height, data address, etc. + */ + +struct lcddev_area_align_s { + uint16_t row_start_align; /* Start row index alignment */ + uint16_t height_align; /* Height alignment */ + uint16_t col_start_align; /* Start column index alignment */ + uint16_t width_align; /* Width alignment */ + uint16_t buf_align; /* Buffer addr alignment */ +}; + +/* This structure describes one color plane. Some YUV formats may support + * up to 4 planes (although they probably wouldn't be used on LCD hardware). + * The framebuffer driver provides the video memory address in its + * corresponding fb_planeinfo_s structure. The LCD driver, instead, provides + * methods to transfer data to/from the LCD color plane. + */ + +struct lcd_planeinfo_s { + /* This is working memory allocated by the LCD driver for each LCD device + * and for each color plane. This memory will hold one raster line of + * data. The size of the allocated run buffer must therefore be at least + * (bpp * xres / 8). Actual alignment of the buffer must conform to the + * bitwidth of the underlying pixel type. + * + * If there are multiple planes, they may share the same working buffer + * because different planes will not be operate on concurrently. However, + * if there are multiple LCD devices, they must each have unique run + * buffers. + */ + + uint8_t * buffer; + + /* This is the number of bits in one pixel. This may be one of {1, 2, 4, + * 8, 16, 24, or 32} unless support for one or more of those resolutions + * has been disabled. + */ + + uint8_t bpp; +}; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*NUTTX_LCD_DEV_H*/ diff --git a/src/drivers/nuttx/mock/nuttx_mm.h b/src/drivers/nuttx/mock/nuttx_mm.h new file mode 100644 index 0000000000..0d43513a2b --- /dev/null +++ b/src/drivers/nuttx/mock/nuttx_mm.h @@ -0,0 +1,142 @@ +/** + * @file nuttx_mm.h + * + */ + +#ifndef NUTTX_MM_H +#define NUTTX_MM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include +#include + +/********************* + * DEFINES + *********************/ + +/* Special PID to query the info about alloc, free and mempool */ + +#define PID_MM_ORPHAN (-6) +#define PID_MM_BIGGEST (-5) +#define PID_MM_FREE (-4) +#define PID_MM_ALLOC (-3) +#define PID_MM_LEAK (-2) +#define PID_MM_MEMPOOL (-1) + +#ifndef ULONG_MAX +#define ULONG_MAX 4294967295UL +#endif + +#define CONFIG_MM_BACKTRACE 1 + +/********************** + * TYPEDEFS + **********************/ + +struct mm_heap_s { + /* This is the size of the heap provided to mm */ + + size_t mm_heapsize; + + /* This is the heap maximum used memory size */ + + size_t mm_maxused; + + /* This is the current used size of the heap */ + + size_t mm_curused; + + /* Kasan is disable or enable for this heap */ + + bool mm_nokasan; +}; + +struct malltask { + /* Negative pid means differently. See include/malloc.h */ + + int pid; /* Process id */ + unsigned long seqmin; /* The minimum sequence */ + unsigned long seqmax; /* The maximum sequence */ +}; + +#define mm_memdump_s malltask + +struct mallinfo { + int arena; /* non-mmapped space allocated from system */ + int ordblks; /* number of free chunks */ + int smblks; /* number of fastbin blocks */ + int hblks; /* number of mmapped regions */ + int hblkhd; /* space in mmapped regions */ + int usmblks; /* always 0, preserved for backwards compatibility */ + int fsmblks; /* space available in freed fastbin blocks */ + int uordblks; /* total allocated space */ + int fordblks; /* total free space */ + int keepcost; /* top-most, releasable (via malloc_trim) space */ + int aordblks; /* This is the number of allocated (in use) chunks for task */ + int mxordblk; /* size of the largest free chunk */ +}; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +static inline struct mm_heap_s * mm_initialize(const char * name, void * mem, size_t size) +{ + (void)name; + (void)mem; + (void)size; + return NULL; +} + +static inline void mm_uninitialize(struct mm_heap_s * heap) +{ + (void)heap; +} + +static inline void * mm_malloc(struct mm_heap_s * heap, size_t size) +{ + (void)heap; + (void)size; + return NULL; +} + +static inline void mm_free(struct mm_heap_s * heap, void * ptr) +{ + (void)heap; + (void)ptr; +} + +static inline void mm_memdump(struct mm_heap_s * heap, const struct mm_memdump_s * dump) +{ + (void)heap; + (void)dump; +} + +static inline struct mallinfo mm_mallinfo(struct mm_heap_s * heap) +{ + (void)heap; + struct mallinfo info = {0}; + return info; +} + +static inline int gettid(void) +{ + return -1; +} + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*NUTTX_MM_H*/ diff --git a/src/drivers/nuttx/mock/nuttx_video_fb.h b/src/drivers/nuttx/mock/nuttx_video_fb.h new file mode 100644 index 0000000000..13179911cf --- /dev/null +++ b/src/drivers/nuttx/mock/nuttx_video_fb.h @@ -0,0 +1,343 @@ +/** + * @file nuttx_video_fb.h + * + */ + +#ifndef LV_NUTTX_VIDEO_FB_H +#define LV_NUTTX_VIDEO_FB_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include +#include + +/********************* + * DEFINES + *********************/ + +#define _FBIOC(x) (x) + +/* Color format definitions. This pretty much defines the color pixel + * processing organization of the video controller. + */ + +/* Monochrome Formats *******************************************************/ + +#define FB_FMT_Y1 0 /* BPP=1, monochrome */ +#define FB_FMT_Y2 1 /* BPP=2, 2-bit uncompressed greyscale */ +#define FB_FMT_Y4 2 /* BPP=4, 4-bit uncompressed greyscale */ +#define FB_FMT_Y8 3 /* BPP=8, 8-bit uncompressed greyscale */ +#define FB_FMT_Y16 4 /* BPP=16, 16-bit uncompressed greyscale */ +#define FB_FMT_GREY FB_FMT_Y8 /* BPP=8 */ +#define FB_FMT_Y800 FB_FMT_Y8 /* BPP=8 */ + +#define FB_ISMONO(f) (((f) >= FB_FMT_Y1) && (f) <= FB_FMT_Y16) + +/* RGB video formats ********************************************************/ + +/* Standard RGB */ + +#define FB_FMT_RGB4 5 /* BPP=4 */ +#define FB_FMT_RGB8 6 /* BPP=8 RGB palette index */ +#define FB_FMT_RGB8_222 7 /* BPP=8 R=2, G=2, B=2 */ +#define FB_FMT_RGB8_332 8 /* BPP=8 R=3, G=3, B=2 */ +#define FB_FMT_RGB12_444 9 /* BPP=12 R=4, G=4, B=4 */ +#define FB_FMT_RGB16_555 10 /* BPP=16 R=5, G=5, B=5 (1 unused bit) */ +#define FB_FMT_RGB16_565 11 /* BPP=16 R=5, G=6, B=5 */ +#define FB_FMT_RGB24 12 /* BPP=24 */ +#define FB_FMT_RGB32 13 /* BPP=32 */ + +/* Run length encoded RGB */ + +#define FB_FMT_RGBRLE4 14 /* BPP=4 */ +#define FB_FMT_RGBRLE8 15 /* BPP=8 */ + +/* Raw RGB */ + +#define FB_FMT_RGBRAW 16 /* BPP=? */ + +/* Raw RGB with arbitrary sample packing within a pixel. Packing and + * precision of R, G and B components is determined by bit masks for each. + */ + +#define FB_FMT_RGBBTFLD16 17 /* BPP=16 */ +#define FB_FMT_RGBBTFLD24 18 /* BPP=24 */ +#define FB_FMT_RGBBTFLD32 19 /* BPP=32 */ +#define FB_FMT_RGBA16 20 /* BPP=16 Raw RGB with alpha */ +#define FB_FMT_RGBA32 21 /* BPP=32 Raw RGB with alpha */ + +/* Raw RGB with a transparency field. Layout is as for standard RGB at 16 and + * 32 bits per pixel but the msb in each pixel indicates whether the pixel is + * transparent or not. + */ + +#define FB_FMT_RGBT16 22 /* BPP=16 */ +#define FB_FMT_RGBT32 23 /* BPP=32 */ + +#define FB_ISRGB(f) (((f) >= FB_FMT_RGB4) && (f) <= FB_FMT_RGBT32) + +/* Packed YUV Formats *******************************************************/ + +#define FB_FMT_AYUV 24 /* BPP=32 Combined YUV and alpha */ +#define FB_FMT_CLJR 25 /* BPP=8 4 pixels packed into a uint32_t. + * YUV 4:1:1 with l< 8 bits + * per YUV sample */ +#define FB_FMT_CYUV 26 /* BPP=16 UYVY except that height is + * reversed */ +#define FB_FMT_IRAW 27 /* BPP=? Intel uncompressed YUV */ +#define FB_FMT_IUYV 28 /* BPP=16 Interlaced UYVY (line order + * 0,2,4,.., 1,3,5...) */ +#define FB_FMT_IY41 29 /* BPP=12 Interlaced Y41P (line order + * 0,2,4,.., 1,3,5...) */ +#define FB_FMT_IYU2 30 /* BPP=24 */ +#define FB_FMT_HDYC 31 /* BPP=16 UYVY except uses the BT709 + * color space */ +#define FB_FMT_UYVP 32 /* BPP=24? YCbCr 4:2:2, 10-bits per + * component in U0Y0V0Y1 order */ +#define FB_FMT_UYVY 33 /* BPP=16 YUV 4:2:2 */ +#define FB_FMT_UYNV FB_FMT_UYVY /* BPP=16 */ +#define FB_FMT_Y422 FB_FMT_UYVY /* BPP=16 */ +#define FB_FMT_V210 34 /* BPP=32 10-bit 4:2:2 YCrCb */ +#define FB_FMT_V422 35 /* BPP=16 Upside down version of UYVY */ +#define FB_FMT_V655 36 /* BPP=16? 16-bit YUV 4:2:2 */ +#define FB_FMT_VYUY 37 /* BPP=? ATI Packed YUV Data */ +#define FB_FMT_YUYV 38 /* BPP=16 YUV 4:2:2 */ +#define FB_FMT_YUY2 FB_FMT_YUYV /* BPP=16 YUV 4:2:2 */ +#define FB_FMT_YUNV FB_FMT_YUYV /* BPP=16 YUV 4:2:2 */ +#define FB_FMT_YVYU 39 /* BPP=16 YUV 4:2:2 */ +#define FB_FMT_Y41P 40 /* BPP=12 YUV 4:1:1 */ +#define FB_FMT_Y411 41 /* BPP=12 YUV 4:1:1 */ +#define FB_FMT_Y211 42 /* BPP=8 */ +#define FB_FMT_Y41T 43 /* BPP=12 Y41P LSB for transparency */ +#define FB_FMT_Y42T 44 /* BPP=16 UYVY LSB for transparency */ +#define FB_FMT_YUVP 45 /* BPP=24? YCbCr 4:2:2 Y0U0Y1V0 order */ + +#define FB_ISYUVPACKED(f) (((f) >= FB_FMT_AYUV) && (f) <= FB_FMT_YUVP) + +/* Packed Planar YUV Formats ************************************************/ + +#define FB_FMT_YVU9 46 /* BPP=9 8-bit Y followed by 8-bit + * 4x4 VU */ +#define FB_FMT_YUV9 47 /* BPP=9? */ +#define FB_FMT_IF09 48 /* BPP=9.5 YVU9 + 4x4 plane of delta + * relative to tframe. */ +#define FB_FMT_YV16 49 /* BPP=16 8-bit Y followed by 8-bit + * 2x1 VU */ +#define FB_FMT_YV12 50 /* BPP=12 8-bit Y followed by 8-bit + * 2x2 VU */ +#define FB_FMT_I420 51 /* BPP=12 8-bit Y followed by 8-bit + * 2x2 UV */ +#define FB_FMT_IYUV FB_FMT_I420 /* BPP=12 */ +#define FB_FMT_NV12 52 /* BPP=12 8-bit Y followed by an + * interleaved 2x2 UV */ +#define FB_FMT_NV21 53 /* BPP=12 NV12 with UV reversed */ +#define FB_FMT_IMC1 54 /* BPP=12 YV12 except UV planes same + * stride as Y */ +#define FB_FMT_IMC2 55 /* BPP=12 IMC1 except UV lines + * interleaved at half stride + * boundaries */ +#define FB_FMT_IMC3 56 /* BPP=12 As IMC1 except that UV + * swapped */ +#define FB_FMT_IMC4 57 /* BPP=12 As IMC2 except that UV + * swapped */ +#define FB_FMT_CLPL 58 /* BPP=12 YV12 but including a level + * of indirection. */ +#define FB_FMT_Y41B 59 /* BPP=12? 4:1:1 planar. */ +#define FB_FMT_Y42B 60 /* BPP=16? YUV 4:2:2 planar. */ +#define FB_FMT_CXY1 61 /* BPP=12 */ +#define FB_FMT_CXY2 62 /* BPP=16 */ + +#define FB_ISYUVPLANAR(f) (((f) >= FB_FMT_YVU9) && (f) <= FB_FMT_CXY2) +#define FB_ISYUV(f) (FB_ISYUVPACKED(f) || FB_ISYUVPLANAR(f)) + +/* Hardware cursor control **************************************************/ + +#ifdef CONFIG_FB_HWCURSOR +# define FB_CUR_ENABLE 0x01 /* Enable the cursor */ +# define FB_CUR_SETIMAGE 0x02 /* Set the cursor image */ +# define FB_CUR_SETPOSITION 0x04 /* Set the position of the cursor */ +# define FB_CUR_SETSIZE 0x08 /* Set the size of the cursor */ +# define FB_CUR_XOR 0x10 /* Use XOR vs COPY ROP on image */ +#endif + +/* Hardware overlay acceleration ********************************************/ + +#define FB_NO_OVERLAY -1 + +#ifdef CONFIG_FB_OVERLAY +# define FB_ACCL_TRANSP 0x01 /* Hardware tranparency support */ +# define FB_ACCL_CHROMA 0x02 /* Hardware chromakey support */ +# define FB_ACCL_COLOR 0x04 /* Hardware color support */ +# define FB_ACCL_AREA 0x08 /* Hardware support area selection */ + +#ifdef CONFIG_FB_OVERLAY_BLIT +# define FB_ACCL_BLIT 0x10 /* Hardware blit support */ +# define FB_ACCL_BLEND 0x20 /* Hardware blend support */ +#endif + +/* Overlay transparency mode ************************************************/ + +# define FB_CONST_ALPHA 0x00 /* Transparency by alpha value */ +# define FB_PIXEL_ALPHA 0x01 /* Transparency by pixel alpha value */ + +#endif /* CONFIG_FB_OVERLAY */ + +/* FB character driver IOCTL commands ***************************************/ + +/* ioctls */ + +#define FBIOGET_VIDEOINFO _FBIOC(0x0001) /* Get color plane info */ +/* Argument: writable struct + * fb_videoinfo_s */ +#define FBIOGET_PLANEINFO _FBIOC(0x0002) /* Get video plane info */ +/* Argument: writable struct + * fb_planeinfo_s */ + +#ifdef CONFIG_FB_CMAP +# define FBIOGET_CMAP _FBIOC(0x0003) /* Get RGB color mapping */ +/* Argument: writable struct + * fb_cmap_s */ +# define FBIOPUT_CMAP _FBIOC(0x0004) /* Put RGB color mapping */ +/* Argument: read-only struct + * fb_cmap_s */ +#endif + +#ifdef CONFIG_FB_HWCURSOR +# define FBIOGET_CURSOR _FBIOC(0x0005) /* Get cursor attributes */ +/* Argument: writable struct + * fb_cursorattrib_s */ +# define FBIOPUT_CURSOR _FBIOC(0x0006) /* Set cursor attributes */ +/* Argument: read-only struct + * fb_setcursor_s */ +#endif + +#ifdef CONFIG_FB_UPDATE +# define FBIO_UPDATE _FBIOC(0x0007) /* Update a rectangular region in + * the framebuffer + * Argument: read-only struct + * fb_area_s */ +#endif + +#ifdef CONFIG_FB_SYNC +# define FBIO_WAITFORVSYNC _FBIOC(0x0008) /* Wait for vertical sync */ +#endif + +#ifdef CONFIG_FB_OVERLAY +# define FBIOGET_OVERLAYINFO _FBIOC(0x0009) /* Get video overlay info */ +/* Argument: writable struct + * fb_overlayinfo_s */ +# define FBIO_SELECT_OVERLAY _FBIOC(0x000a) /* Select overlay */ +/* Argument: read-only + * unsigned long */ +# define FBIOSET_TRANSP _FBIOC(0x000b) /* Set opacity or transparency + * Argument: read-only struct + * fb_overlayinfo_s */ +# define FBIOSET_CHROMAKEY _FBIOC(0x000c) /* Set chroma key + * Argument: read-only struct + * fb_overlayinfo_s */ +# define FBIOSET_COLOR _FBIOC(0x000d) /* Set color + * Argument: read-only struct + * fb_overlayinfo_s */ +# define FBIOSET_BLANK _FBIOC(0x000e) /* Blank or unblank + * Argument: read-only struct + * fb_overlayinfo_s */ +# define FBIOSET_AREA _FBIOC(0x000f) /* Set active overlay area + * Argument: read-only struct + * fb_overlayinfo_s */ +# define FBIOSET_DESTAREA _FBIOC(0x0010) /* Set destination area on + * primary FB. + * Argument: read-only struct + * fb_overlayinfo_s */ + +#ifdef CONFIG_FB_OVERLAY_BLIT +# define FBIOSET_BLIT _FBIOC(0x0011) /* Blit area between overlays + * Argument: read-only struct + * fb_overlayblit_s */ +# define FBIOSET_BLEND _FBIOC(0x0012) /* Blend area between overlays + * Argument: read-only struct + * fb_overlayblend_s */ +#endif + +#define FBIOPAN_OVERLAY _FBIOC(0x0013) /* Pan display for overlay + * Argument: read-only struct + * fb_overlayinfo_s */ + +#endif /* CONFIG_FB_OVERLAY */ + +/* Specific Controls ********************************************************/ + +#define FBIOSET_POWER _FBIOC(0x0014) /* Set panel power + * Argument: int */ +#define FBIOGET_POWER _FBIOC(0x0015) /* Get panel current power + * Argument: int* */ +#define FBIOSET_FRAMERATE _FBIOC(0x0016) /* Set frame rate + * Argument: int */ +#define FBIOGET_FRAMERATE _FBIOC(0x0017) /* Get frame rate + * Argument: int* */ + +#define FBIOPAN_DISPLAY _FBIOC(0x0018) /* Pan display + * Argument: read-only struct + * fb_planeinfo_s* */ + +#define FBIOPAN_CLEAR _FBIOC(0x0019) /* Pan clear */ +/* Argument: read-only + * unsigned long */ + +#define FBIOSET_VSYNCOFFSET _FBIOC(0x001a) /* Set VSync offset in usec + * Argument: int */ + +/* Linux Support ************************************************************/ + +#define FBIOGET_VSCREENINFO _FBIOC(0x001b) /* Get video variable info */ +/* Argument: writable struct + * fb_var_screeninfo */ +#define FBIOGET_FSCREENINFO _FBIOC(0x001c) /* Get video fix info */ +/* Argument: writable struct + * fb_fix_screeninfo */ + +/********************** + * TYPEDEFS + **********************/ + +typedef uint16_t fb_coord_t; + +struct fb_videoinfo_s { + uint8_t fmt; /* see FB_FMT_* */ + fb_coord_t xres; /* Horizontal resolution in pixel columns */ + fb_coord_t yres; /* Vertical resolution in pixel rows */ + uint8_t nplanes; /* Number of color planes supported */ + uint8_t noverlays; /* Number of overlays supported */ + uint8_t moduleinfo[128]; /* Module information filled by vendor */ +}; + +struct fb_planeinfo_s { + void * fbmem; /* Start of frame buffer memory */ + size_t fblen; /* Length of frame buffer memory in bytes */ + fb_coord_t stride; /* Length of a line in bytes */ + uint8_t display; /* Display number */ + uint8_t bpp; /* Bits per pixel */ + uint32_t xres_virtual; /* Virtual Horizontal resolution in pixel columns */ + uint32_t yres_virtual; /* Virtual Vertical resolution in pixel rows */ + uint32_t xoffset; /* Offset from virtual to visible resolution */ + uint32_t yoffset; /* Offset from virtual to visible resolution */ +}; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_NUTTX_VIDEO_FB_H*/ diff --git a/tests/src/lv_test_conf.h b/tests/src/lv_test_conf.h index 61de02b244..2b776ebbf5 100644 --- a/tests/src/lv_test_conf.h +++ b/tests/src/lv_test_conf.h @@ -86,6 +86,7 @@ typedef void * lv_user_data_t; #define LV_DPI_DEF 160 #define LV_USE_DRAW_SDL 1 #define LV_USE_SDL 1 +#define LV_USE_NUTTX 1 #include "lv_test_conf_full.h" #elif LV_TEST_OPTION == 4 #define LV_COLOR_DEPTH 24 diff --git a/tests/src/lv_test_conf_full.h b/tests/src/lv_test_conf_full.h index 1f38331828..accf94d7ed 100644 --- a/tests/src/lv_test_conf_full.h +++ b/tests/src/lv_test_conf_full.h @@ -148,6 +148,29 @@ #define LV_USE_LINUX_FBDEV 1 #endif +#ifndef LV_USE_NUTTX + #define LV_USE_NUTTX 0 +#endif +#if defined(_WIN32) && LV_USE_NUTTX + #undef LV_USE_NUTTX /* Disable NuttX build on Windows */ + #define LV_USE_NUTTX 0 +#endif +#if LV_USE_NUTTX + #define LV_USE_NUTTX_INDEPENDENT_IMAGE_HEAP 1 + #define LV_NUTTX_DEFAULT_DRAW_BUF_USE_INDEPENDENT_IMAGE_HEAP 1 + #define LV_USE_NUTTX_LIBUV 1 + #define LV_USE_NUTTX_CUSTOM_INIT 0 + #define LV_USE_NUTTX_LCD 1 + #define LV_NUTTX_LCD_BUFFER_COUNT 2 + #define LV_NUTTX_LCD_BUFFER_SIZE 60 + #define LV_USE_NUTTX_TOUCHSCREEN 1 + #define LV_NUTTX_TOUCHSCREEN_CURSOR_SIZE 20 + #define LV_USE_NUTTX_MOUSE 1 + #define LV_USE_NUTTX_MOUSE_MOVE_STEP 1 + #define LV_USE_NUTTX_TRACE_FILE 1 + #define LV_NUTTX_TRACE_FILE_PATH "/data/lvgl-trace.log" +#endif + #ifndef LV_USE_WAYLAND #define LV_USE_WAYLAND 1 #endif