From 5051829c50995b21841c294e5d9b393c64e72f6a Mon Sep 17 00:00:00 2001 From: Siyuan Miao Date: Sun, 22 Jun 2025 15:39:48 +0000 Subject: [PATCH] feat: update github actions --- .github/workflows/build.yml | 7 ++ internal/native/cgo/CMakeLists.txt | 6 +- internal/native/cgo/build.sh | 2 +- internal/native/cgo/ctrl.c | 9 +-- internal/native/cgo/ctrl.h | 3 + internal/native/cgo/log.h | 126 +++++++++++------------------ internal/native/cgo/lv_conf.h | 20 ++--- internal/native/cgo/video.c | 11 +-- 8 files changed, 81 insertions(+), 103 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c7cbb22..930fbdd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,13 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Set up Cmake cache + uses: buildjet/cache@v4 + with: + path: internal/native/cgo/build + key: jetkvm-cgo-${{ hashFiles('internal/native/cgo/**/*.c', 'internal/native/cgo/**/*.h', 'internal/native/cgo/**/*.patch', 'internal/native/cgo/**/*.txt', 'internal/native/cgo/**/*.sh', '!internal/native/cgo/build/**') }} + restore-keys: | + jetkvm-cgo-${{ hashFiles('internal/native/cgo/**/*.c', 'internal/native/cgo/**/*.h', 'internal/native/cgo/**/*.patch', 'internal/native/cgo/**/*.txt', 'internal/native/cgo/**/*.sh', '!internal/native/cgo/build/**') }} - name: Set up Node.js uses: actions/setup-node@v4 with: diff --git a/internal/native/cgo/CMakeLists.txt b/internal/native/cgo/CMakeLists.txt index f3ef65b..dcf0799 100644 --- a/internal/native/cgo/CMakeLists.txt +++ b/internal/native/cgo/CMakeLists.txt @@ -32,7 +32,10 @@ FetchContent_Declare( GIT_REPOSITORY https://github.com/lvgl/lvgl.git GIT_TAG v8.3.11 GIT_SHALLOW 1 - PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/lvgl-no-examples.patch + UPDATE_DISCONNECTED 1 + PATCH_COMMAND + git apply ${CMAKE_CURRENT_SOURCE_DIR}/lvgl-no-examples.patch + COMMAND rm -rf demos examples ) FetchContent_MakeAvailable(lvgl) @@ -41,6 +44,7 @@ FetchContent_Declare( lv_drivers GIT_REPOSITORY https://github.com/lvgl/lv_drivers.git GIT_TAG v8.3.0 + UPDATE_DISCONNECTED 1 ) FetchContent_MakeAvailable(lv_drivers) diff --git a/internal/native/cgo/build.sh b/internal/native/cgo/build.sh index c247477..5b71fb0 100755 --- a/internal/native/cgo/build.sh +++ b/internal/native/cgo/build.sh @@ -14,6 +14,6 @@ VERBOSE=1 cmake -B build \ -DCMAKE_CROSSCOMPILING=1 \ -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE \ -DSKIP_GLIBC_NAMES=ON \ - -DMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=Release cmake --build build \ No newline at end of file diff --git a/internal/native/cgo/ctrl.c b/internal/native/cgo/ctrl.c index 83e82cb..ef8bd6f 100644 --- a/internal/native/cgo/ctrl.c +++ b/internal/native/cgo/ctrl.c @@ -30,7 +30,7 @@ void jetkvm_set_video_handler(jetkvm_video_handler_t *handler) { video_handler = handler; } -void report_video_format(bool ready, const char *error, u_int16_t width, u_int16_t height, double frame_per_second) +void video_report_format(bool ready, const char *error, u_int16_t width, u_int16_t height, double frame_per_second) { state.ready = ready; state.error = error; @@ -42,7 +42,7 @@ void report_video_format(bool ready, const char *error, u_int16_t width, u_int16 } } -int socket_send_frame(const uint8_t *frame, ssize_t len) +int video_send_frame(const uint8_t *frame, ssize_t len) { if (video_handler != NULL) { (*video_handler)(frame, len); @@ -50,11 +50,6 @@ int socket_send_frame(const uint8_t *frame, ssize_t len) log_error("video handler is not set"); } return 0; - // if (video_client_fd <= 0) - // { - // return -1; - // } - // return send(video_client_fd, frame, len, 0); } /** diff --git a/internal/native/cgo/ctrl.h b/internal/native/cgo/ctrl.h index f3b74fc..80c8ab4 100644 --- a/internal/native/cgo/ctrl.h +++ b/internal/native/cgo/ctrl.h @@ -51,4 +51,7 @@ int jetkvm_video_set_edid(const char *edid_hex); char *jetkvm_video_get_edid_hex(); jetkvm_video_state_t *jetkvm_video_get_status(); +void video_report_format(bool ready, const char *error, u_int16_t width, u_int16_t height, double frame_per_second); +int video_send_frame(const uint8_t *frame, ssize_t len); + #endif //VIDEO_DAEMON_CTRL_H diff --git a/internal/native/cgo/log.h b/internal/native/cgo/log.h index 1b4a255..31b2ee7 100644 --- a/internal/native/cgo/log.h +++ b/internal/native/cgo/log.h @@ -16,44 +16,12 @@ void jetkvm_log(const char *message); /* Log to screen */ -#define emit_log(level, file, func, line, ...) do { \ - /* call the log handler */ \ - char msg_buffer[1024]; \ - sprintf(msg_buffer, __VA_ARGS__); \ - log_message(level, file, func, line, msg_buffer); \ +#define emit_log(level, file, func, line, ...) do { \ + /* call the log handler */ \ + char msg_buffer[1024]; \ + sprintf(msg_buffer, __VA_ARGS__); \ + log_message(level, file, func, line, msg_buffer); \ } while (0) - // /* display the level */ \ - // printf("%10s%s", level, " "); \ - // \ - // /* display the function doing the logging */ \ - // printf("%s%s", func, " " : ""); \ - // \ - // /* display the file and/or the line number */ \ - // printf( \ - // "%s%s%s%.d%s%s", \ - // DISPLAY_FUNC && (DISPLAY_FILE || DISPLAY_LINE) ? "(" : "", \ - // DISPLAY_FILE ? file : "", \ - // DISPLAY_FILE && DISPLAY_LINE ? ":" : "", \ - // DISPLAY_LINE ? line : 0, \ - // DISPLAY_FUNC && (DISPLAY_FILE || DISPLAY_LINE) ? ") " : "", \ - // !DISPLAY_FUNC && (DISPLAY_FILE || DISPLAY_LINE) ? " " : "" \ - // ); \ - // \ - // /* display message border */ \ - // printf("%s%s", DISPLAY_BORDER ? BORDER : "", DISPLAY_BORDER ? " " : ""); \ - // \ - // /* display the callee's message */ \ - // if (DISPLAY_MESSAGE) printf(__VA_ARGS__); \ - // \ - // /* add the message ending (usually '\n') */ \ - // printf("%s", DISPLAY_ENDING ? MSG_ENDING : ""); \ - // \ - // /* reset the colour */ \ - // printf("%s", DISPLAY_RESET ? RESET_COLOUR : ""); \ - // \ - // /* add a newline */ \ - // printf("\n"); \ - // fflush(stdout); \ /* Level enum */ #define LEVEL_PANIC 5 @@ -65,66 +33,66 @@ void jetkvm_log(const char *message); #define LEVEL_TRACE -1 /* TRACE LOG */ -#define log_trace(...) do { \ - if (LOG_LEVEL <= LEVEL_TRACE) { \ - emit_log( \ - LEVEL_TRACE, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ - ); \ - } \ +#define log_trace(...) do { \ + if (LOG_LEVEL <= LEVEL_TRACE) { \ + emit_log( \ + LEVEL_TRACE, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ + ); \ + } \ } while (0) /* DEBUG LOG */ -#define log_debug(...) do { \ - if (LOG_LEVEL <= LEVEL_DEBUG) { \ - emit_log( \ - LEVEL_DEBUG, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ - ); \ - } \ +#define log_debug(...) do { \ + if (LOG_LEVEL <= LEVEL_DEBUG) { \ + emit_log( \ + LEVEL_DEBUG, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ + ); \ + } \ } while (0) /* INFO LOG */ -#define log_info(...) do { \ - if (LOG_LEVEL <= LEVEL_INFO) { \ - emit_log( \ - LEVEL_INFO, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ - ); \ - } \ +#define log_info(...) do { \ + if (LOG_LEVEL <= LEVEL_INFO) { \ + emit_log( \ + LEVEL_INFO, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ + ); \ + } \ } while (0) /* NOTICE LOG */ -#define log_notice(...) do { \ - if (LOG_LEVEL <= LEVEL_NOTICE) { \ - emit_log( \ - LEVEL_NOTICE, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ - ); \ - } \ +#define log_notice(...) do { \ + if (LOG_LEVEL <= LEVEL_INFO) { \ + emit_log( \ + LEVEL_INFO, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ + ); \ + } \ } while (0) /* WARN LOG */ -#define log_warn(...) do { \ - if (LOG_LEVEL <= LEVEL_WARN) { \ - emit_log( \ - LEVEL_WARN, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ - ); \ - } \ +#define log_warn(...) do { \ + if (LOG_LEVEL <= LEVEL_WARN) { \ + emit_log( \ + LEVEL_WARN, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ + ); \ + } \ } while (0) /* ERROR LOG */ -#define log_error(...) do { \ - if (LOG_LEVEL <= LEVEL_ERROR) { \ - emit_log( \ - LEVEL_ERROR, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ - ); \ - } \ +#define log_error(...) do { \ + if (LOG_LEVEL <= LEVEL_ERROR) { \ + emit_log( \ + LEVEL_ERROR, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ + ); \ + } \ } while (0) /* PANIC LOG */ -#define log_panic(...) do { \ - if (LOG_LEVEL <= LEVEL_PANIC) { \ - emit_log( \ - LEVEL_PANIC, __FILENAME__, __func__, __LINE__, __VA_ARGS__\ - ); \ - } \ +#define log_panic(...) do { \ + if (LOG_LEVEL <= LEVEL_PANIC) { \ + emit_log( \ + LEVEL_PANIC, __FILENAME__, __func__, __LINE__, __VA_ARGS__ \ + ); \ + } \ } while (0) #endif //VIDEO_DAEMON_LOG_H diff --git a/internal/native/cgo/lv_conf.h b/internal/native/cgo/lv_conf.h index 043bb2f..1df5400 100644 --- a/internal/native/cgo/lv_conf.h +++ b/internal/native/cgo/lv_conf.h @@ -477,31 +477,31 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ # define LV_USE_CALENDAR_HEADER_DROPDOWN 1 #endif /*LV_USE_CALENDAR*/ -#define LV_USE_CHART 1 +#define LV_USE_CHART 0 -#define LV_USE_COLORWHEEL 1 +#define LV_USE_COLORWHEEL 0 #define LV_USE_IMGBTN 1 #define LV_USE_KEYBOARD 1 -#define LV_USE_LED 1 +#define LV_USE_LED 0 #define LV_USE_LIST 1 -#define LV_USE_METER 1 +#define LV_USE_METER 0 -#define LV_USE_MSGBOX 1 +#define LV_USE_MSGBOX 0 -#define LV_USE_SPINBOX 1 +#define LV_USE_SPINBOX 0 -#define LV_USE_SPINNER 1 +#define LV_USE_SPINNER 0 -#define LV_USE_TABVIEW 1 +#define LV_USE_TABVIEW 0 -#define LV_USE_TILEVIEW 1 +#define LV_USE_TILEVIEW 0 -#define LV_USE_WIN 1 +#define LV_USE_WIN 0 #define LV_USE_SPAN 1 #if LV_USE_SPAN diff --git a/internal/native/cgo/video.c b/internal/native/cgo/video.c index 4ab721c..d70bbd2 100644 --- a/internal/native/cgo/video.c +++ b/internal/native/cgo/video.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -276,7 +277,7 @@ static void *venc_read_stream(void *arg) // loopCount, stFrame.u32Seq, stFrame.pstPack->u32Len, // stFrame.pstPack->u64PTS, nowUs - stFrame.pstPack->u64PTS); pData = RK_MPI_MB_Handle2VirAddr(stFrame.pstPack->pMbBlk); - socket_send_frame(pData, (ssize_t)stFrame.pstPack->u32Len); + video_send_frame(pData, (ssize_t)stFrame.pstPack->u32Len); s32Ret = RK_MPI_VENC_ReleaseStream(VENC_CHANNEL, &stFrame); if (s32Ret != RK_SUCCESS) { @@ -645,19 +646,19 @@ void *run_detect_format(void *arg) { // No timings could be detected because no signal was found. log_info("HDMI status: no signal"); - report_video_format(false, "no_signal", 0, 0, 0); + video_report_format(false, "no_signal", 0, 0, 0); } else if (errno == ENOLCK) { // The signal was unstable and the hardware could not lock on to it. log_info("HDMI status: no lock"); - report_video_format(false, "no_lock", 0, 0, 0); + video_report_format(false, "no_lock", 0, 0, 0); } else if (errno == ERANGE) { // Timings were found, but they are out of range of the hardware capabilities. printf("HDMI status: out of range\n"); - report_video_format(false, "out_of_range", 0, 0, 0); + video_report_format(false, "out_of_range", 0, 0, 0); } else { @@ -679,7 +680,7 @@ void *run_detect_format(void *arg) detected_width = dv_timings.bt.width; detected_height = dv_timings.bt.height; detected_signal = true; - report_video_format(true, NULL, detected_width, detected_height, frames_per_second); + video_report_format(true, NULL, detected_width, detected_height, frames_per_second); if (streaming_flag == true) { log_info("restarting on going video streaming");