From 37ca5ef4ed9bc020107aae09ea0c48d909dbddcb Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Thu, 28 Mar 2024 04:12:10 +0000 Subject: [PATCH 1/2] remove RK3566 bsp SDL2 patches --- ...mplement-librga-framebuffer-rotation.patch | 248 ------------ .../patches/RK3566/0004-fix-touch-mouse.patch | 74 ---- ...ion-should-respect-panel-orientation.patch | 356 ------------------ .../0006-limit-rga-buffering-when-egl.patch | 59 --- 4 files changed, 737 deletions(-) delete mode 100644 packages/graphics/SDL2/patches/RK3566/0003-Implement-librga-framebuffer-rotation.patch delete mode 100644 packages/graphics/SDL2/patches/RK3566/0004-fix-touch-mouse.patch delete mode 100644 packages/graphics/SDL2/patches/RK3566/0005-KMSDRM-Rotation-should-respect-panel-orientation.patch delete mode 100644 packages/graphics/SDL2/patches/RK3566/0006-limit-rga-buffering-when-egl.patch diff --git a/packages/graphics/SDL2/patches/RK3566/0003-Implement-librga-framebuffer-rotation.patch b/packages/graphics/SDL2/patches/RK3566/0003-Implement-librga-framebuffer-rotation.patch deleted file mode 100644 index c39da6d5c..000000000 --- a/packages/graphics/SDL2/patches/RK3566/0003-Implement-librga-framebuffer-rotation.patch +++ /dev/null @@ -1,248 +0,0 @@ -From d60c64d4142a0a706632c50b79474ee51464f973 Mon Sep 17 00:00:00 2001 -From: Johnny on Flame -Date: Sun, 6 Aug 2023 20:57:02 +0000 -Subject: [PATCH 3/7] Implement librga framebuffer rotation. - ---- - CMakeLists.txt | 2 +- - Makefile.in | 2 +- - src/video/kmsdrm/SDL_kmsdrmsym.h | 2 +- - src/video/kmsdrm/SDL_kmsdrmvideo.c | 75 +++++++++++++++++++++++---- - src/video/kmsdrm/SDL_kmsdrmvideo.h | 8 +++ - 6 files changed, 102 insertions(+), 13 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index d6c82c819..374f24e85 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -663,7 +663,7 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC) - check_c_compiler_flag("" HAVE_NO_UNDEFINED) - set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) - if(HAVE_NO_UNDEFINED AND NOT (USE_CLANG AND WINDOWS)) -- list(APPEND EXTRA_LDFLAGS_BUILD "-Wl,--no-undefined") -+ list(APPEND EXTRA_LDFLAGS_BUILD "-Wl,--no-undefined -lrga") - endif() - endif() - -diff --git a/Makefile.in b/Makefile.in -index eb4c4bc1a..5cd04eeec 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -23,7 +23,7 @@ CXX = @CXX@ - INCLUDE = @INCLUDE@ - CFLAGS = @BUILD_CFLAGS@ - EXTRA_CFLAGS = @EXTRA_CFLAGS@ --LDFLAGS = @BUILD_LDFLAGS@ -+LDFLAGS = @BUILD_LDFLAGS@ -lrga - EXTRA_LDFLAGS = @EXTRA_LDFLAGS@ - LIBTOOL = @LIBTOOL@ - INSTALL = @INSTALL@ -diff --git a/src/video/kmsdrm/SDL_kmsdrmsym.h b/src/video/kmsdrm/SDL_kmsdrmsym.h -index 8b9e7b257..b33373805 100644 ---- a/src/video/kmsdrm/SDL_kmsdrmsym.h -+++ b/src/video/kmsdrm/SDL_kmsdrmsym.h -@@ -122,7 +122,7 @@ SDL_KMSDRM_SYM(struct gbm_surface *,gbm_surface_create,(struct gbm_device *gbm, - SDL_KMSDRM_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf)) - SDL_KMSDRM_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf)) - SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo)) -- -+SDL_KMSDRM_SYM(int,gbm_bo_get_fd,(struct gbm_bo *bo)) - - #undef SDL_KMSDRM_MODULE - #undef SDL_KMSDRM_SYM -diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c -index ebe15fe9c..c5340afa8 100644 ---- a/src/video/kmsdrm/SDL_kmsdrmvideo.c -+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c -@@ -44,6 +44,7 @@ - #include "SDL_kmsdrmopengles.h" - #include "SDL_kmsdrmmouse.h" - #include "SDL_kmsdrmdyn.h" -+#include - #include "SDL_kmsdrmvulkan.h" - #include - #include -@@ -51,6 +52,7 @@ - #include - #include - #include -+#include - - #ifdef __OpenBSD__ - static SDL_bool moderndri = SDL_FALSE; -@@ -68,6 +70,9 @@ static char kmsdrm_dri_cardpath[32]; - #define EGL_PLATFORM_GBM_MESA 0x31D7 - #endif - -+rga_info_t src_info = {0}; -+rga_info_t dst_info = {0}; -+ - static int get_driindex(void) - { - int available = -ENOENT; -@@ -330,6 +335,46 @@ static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data) - SDL_free(fb_info); - } - -+static void -+KMSDRM_InitRotateBuffer(_THIS, int frameWidth, int frameHeight) -+{ -+ int l_frameHeight; -+ SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); -+ -+ // initialize 2D raster graphic acceleration unit (RGA) -+ c_RkRgaInit(); -+ -+ l_frameHeight = frameHeight; -+ if(l_frameHeight % 32 != 0) { -+ l_frameHeight = (frameHeight + 32) & (~31); -+ } -+ -+ // create buffers for RGA with adjusted stride -+ for (int i = 0; i < RGA_BUFFERS_MAX; ++i) -+ { -+ viddata->rga_buffers[i] = KMSDRM_gbm_bo_create(viddata->gbm_dev, -+ frameWidth, l_frameHeight, -+ GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); -+ assert(viddata->rga_buffers[i]); -+ -+ viddata->rga_buffer_prime_fds[i] = KMSDRM_gbm_bo_get_fd(viddata->rga_buffers[i]); -+ } -+ viddata->rga_buffer_index = 0; -+ -+ // setup rotation -+ src_info.fd = -1; -+ src_info.mmuFlag = 1; -+ src_info.rotation = HAL_TRANSFORM_ROT_270; -+ -+ // swap width and height and adjust stride here because our source buffer is 480x854 -+ rga_set_rect(&src_info.rect, 0, 0, frameHeight, frameWidth, l_frameHeight, frameWidth, RK_FORMAT_BGRA_8888); -+ -+ dst_info.fd = -1; -+ dst_info.mmuFlag = 1; -+ -+ rga_set_rect(&dst_info.rect, 0, 0, frameWidth, frameHeight, frameWidth, frameHeight, RK_FORMAT_BGRA_8888); -+} -+ - KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) - { - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); -@@ -848,8 +893,8 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re - modedata->mode_index = mode_index; - - display.driverdata = dispdata; -- display.desktop_mode.w = dispdata->mode.hdisplay; -- display.desktop_mode.h = dispdata->mode.vdisplay; -+ display.desktop_mode.w = dispdata->mode.vdisplay; -+ display.desktop_mode.h = dispdata->mode.hdisplay; - display.desktop_mode.refresh_rate = dispdata->mode.vrefresh; - display.desktop_mode.format = SDL_PIXELFORMAT_ARGB8888; - display.desktop_mode.driverdata = modedata; -@@ -1124,7 +1169,8 @@ static void KMSDRM_DirtySurfaces(SDL_Window *window) - or SetWindowFullscreen, send a fake event for now since the actual - recreation is deferred */ - KMSDRM_GetModeToSet(window, &mode); -- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode.hdisplay, mode.vdisplay); -+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode.vdisplay, mode.hdisplay); -+ - } - - /* This determines the size of the fb, which comes from the GBM surface -@@ -1159,13 +1205,13 @@ int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window) - mode that's set in sync with what SDL_video.c thinks is set */ - KMSDRM_GetModeToSet(window, &dispdata->mode); - -- display->current_mode.w = dispdata->mode.hdisplay; -- display->current_mode.h = dispdata->mode.vdisplay; -+ display->current_mode.w = dispdata->mode.vdisplay; -+ display->current_mode.h = dispdata->mode.hdisplay; - display->current_mode.refresh_rate = dispdata->mode.vrefresh; - display->current_mode.format = SDL_PIXELFORMAT_ARGB8888; - - windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev, -- dispdata->mode.hdisplay, dispdata->mode.vdisplay, -+ dispdata->mode.vdisplay, dispdata->mode.hdisplay, - surface_fmt, surface_flags); - - if (!windata->gs) { -@@ -1189,7 +1235,7 @@ int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window) - ret = SDL_EGL_MakeCurrent(_this, windata->egl_surface, egl_context); - - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, -- dispdata->mode.hdisplay, dispdata->mode.vdisplay); -+ dispdata->mode.vdisplay, dispdata->mode.hdisplay); - - windata->egl_surface_dirty = SDL_FALSE; - -@@ -1272,8 +1318,8 @@ void KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay *display) - modedata->mode_index = i; - } - -- mode.w = conn->modes[i].hdisplay; -- mode.h = conn->modes[i].vdisplay; -+ mode.w = conn->modes[i].vdisplay; -+ mode.h = conn->modes[i].hdisplay; - mode.refresh_rate = conn->modes[i].vrefresh; - mode.format = SDL_PIXELFORMAT_ARGB8888; - mode.driverdata = modedata; -@@ -1386,6 +1432,13 @@ void KMSDRM_DestroyWindow(_THIS, SDL_Window *window) - /*********************************************************************/ - SDL_free(window->driverdata); - window->driverdata = NULL; -+ for (int i = 0; i < RGA_BUFFERS_MAX; ++i) { -+ close(viddata->rga_buffer_prime_fds[i]); -+ } -+ if (src_info.fd) { -+ close(src_info.fd); -+ } -+ c_RkRgaDeInit(); - } - - /**********************************************************************/ -@@ -1404,6 +1457,7 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window) - NativeDisplayType egl_display; - drmModeModeInfo *mode; - int ret = 0; -+ SDL_DisplayData *data; - - /* Allocate window internal data */ - windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); -@@ -1519,6 +1573,9 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window) - SDL_SetMouseFocus(window); - SDL_SetKeyboardFocus(window); - -+ data = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; -+ KMSDRM_InitRotateBuffer(_this, data->mode.hdisplay, data->mode.vdisplay); -+ - /* Tell the app that the window has moved to top-left. */ - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, 0, 0); - -diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h -index b48f6ef70..890575fb8 100644 ---- a/src/video/kmsdrm/SDL_kmsdrmvideo.h -+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h -@@ -32,6 +32,10 @@ - #include - #include - #include -+#include -+#include -+ -+#define RGA_BUFFERS_MAX (3) - - typedef struct SDL_VideoData - { -@@ -53,6 +57,10 @@ typedef struct SDL_VideoData - open 1 FD and create 1 gbm device. */ - SDL_bool gbm_init; - -+ struct gbm_bo* rga_buffers[RGA_BUFFERS_MAX]; -+ int rga_buffer_prime_fds[RGA_BUFFERS_MAX]; -+ int rga_buffer_index; -+ - } SDL_VideoData; - - typedef struct SDL_DisplayModeData --- -2.20.1 - diff --git a/packages/graphics/SDL2/patches/RK3566/0004-fix-touch-mouse.patch b/packages/graphics/SDL2/patches/RK3566/0004-fix-touch-mouse.patch deleted file mode 100644 index 2901e3ab2..000000000 --- a/packages/graphics/SDL2/patches/RK3566/0004-fix-touch-mouse.patch +++ /dev/null @@ -1,74 +0,0 @@ -diff -rupN SDL2.orig/src/events/SDL_touch.c SDL2-2.28.1/src/events/SDL_touch.c ---- SDL2.orig/src/events/SDL_touch.c 2023-07-01 17:04:05.000000000 +0000 -+++ SDL2-2.28.1/src/events/SDL_touch.c 2023-07-26 00:04:30.039436068 +0000 -@@ -34,6 +34,7 @@ static SDL_Touch **SDL_touchDevices = NU - #define SYNTHESIZE_TOUCH_TO_MOUSE 1 - - #if SYNTHESIZE_TOUCH_TO_MOUSE -+static SDL_bool cursor_init = SDL_FALSE; - static SDL_bool finger_touching = SDL_FALSE; - static SDL_FingerID track_fingerid; - static SDL_TouchID track_touchid; -@@ -245,6 +246,11 @@ int SDL_SendTouch(SDL_TouchID id, SDL_Fi - return -1; - } - -+ if (!window) { -+ // Fallback to the main application window. -+ window = SDL_GetWindowFromID(1); -+ } -+ - mouse = SDL_GetMouse(); - - #if SYNTHESIZE_TOUCH_TO_MOUSE -@@ -259,6 +265,13 @@ int SDL_SendTouch(SDL_TouchID id, SDL_Fi - /* FIXME: maybe we should only restrict to a few SDL_TouchDeviceType */ - if (id != SDL_MOUSE_TOUCHID) { - if (window) { -+ if (cursor_init == SDL_FALSE) { -+ // TODO - Initialization hack to reset cursor position to <0, 0> -+ SDL_SendMouseMotion(window, 0, SDL_TRUE, -window->w, -window->h); -+ mouse->x = 0; mouse->y = 0; -+ x = 0.0f; y = 0.0f; -+ cursor_init = SDL_TRUE; -+ } - if (down) { - if (finger_touching == SDL_FALSE) { - int pos_x = (int)(x * (float)window->w); -@@ -275,12 +288,12 @@ int SDL_SendTouch(SDL_TouchID id, SDL_Fi - if (pos_y > window->h - 1) { - pos_y = window->h - 1; - } -- SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y); -- SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT); -+ SDL_SendMouseMotion(window, 0, 0, pos_x, pos_y); -+ SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_LEFT); - } - } else { - if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) { -- SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT); -+ SDL_SendMouseButton(window, 0, SDL_RELEASED, SDL_BUTTON_LEFT); - } - } - } -@@ -374,6 +387,11 @@ int SDL_SendTouchMotion(SDL_TouchID id, - return -1; - } - -+ if (!window) { -+ // Fallback to the main application window. -+ window = SDL_GetWindowFromID(1); -+ } -+ - mouse = SDL_GetMouse(); - - #if SYNTHESIZE_TOUCH_TO_MOUSE -@@ -397,7 +415,7 @@ int SDL_SendTouchMotion(SDL_TouchID id, - if (pos_y > window->h - 1) { - pos_y = window->h - 1; - } -- SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y); -+ SDL_SendMouseMotion(window, 0, 0, pos_x, pos_y); - } - } - } diff --git a/packages/graphics/SDL2/patches/RK3566/0005-KMSDRM-Rotation-should-respect-panel-orientation.patch b/packages/graphics/SDL2/patches/RK3566/0005-KMSDRM-Rotation-should-respect-panel-orientation.patch deleted file mode 100644 index fdd443039..000000000 --- a/packages/graphics/SDL2/patches/RK3566/0005-KMSDRM-Rotation-should-respect-panel-orientation.patch +++ /dev/null @@ -1,356 +0,0 @@ -From 0e53103957dd75be9140a474be343a6b7cc3cc9e Mon Sep 17 00:00:00 2001 -From: JohnnyonFlame -Date: Tue, 8 Aug 2023 03:55:43 -0300 -Subject: [PATCH 5/7] KMSDRM: Rotation should respect panel orientation. - ---- - src/video/kmsdrm/SDL_kmsdrmdyn.h | 8 ++ - src/video/kmsdrm/SDL_kmsdrmmouse.c | 60 +++++++++++++- - src/video/kmsdrm/SDL_kmsdrmvideo.c | 122 +++++++++++++++++++++++------ - src/video/kmsdrm/SDL_kmsdrmvideo.h | 2 + - 4 files changed, 166 insertions(+), 26 deletions(-) - -diff --git a/src/video/kmsdrm/SDL_kmsdrmdyn.h b/src/video/kmsdrm/SDL_kmsdrmdyn.h -index 319e3f0e3..e17e97e8e 100644 ---- a/src/video/kmsdrm/SDL_kmsdrmdyn.h -+++ b/src/video/kmsdrm/SDL_kmsdrmdyn.h -@@ -32,6 +32,14 @@ - extern "C" { - #endif - -+enum drm_panel_orientation { -+ DRM_MODE_PANEL_ORIENTATION_UNKNOWN = -1, -+ DRM_MODE_PANEL_ORIENTATION_NORMAL = 0, -+ DRM_MODE_PANEL_ORIENTATION_LEFT_UP, -+ DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, -+ DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP, -+}; -+ - int SDL_KMSDRM_LoadSymbols(void); - void SDL_KMSDRM_UnloadSymbols(void); - -diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c -index 4c445ecf1..5dcaaaab6 100644 ---- a/src/video/kmsdrm/SDL_kmsdrmmouse.c -+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c -@@ -170,10 +170,30 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) - } - - /* Copy from the cursor buffer to a buffer that we can dump to the GBM BO. */ -+ uintptr_t src_buf = (uintptr_t)curdata->buffer; -+ uintptr_t dst_buf = (uintptr_t)ready_buffer; - for (i = 0; i < curdata->h; i++) { - for (j = 0; j < curdata->w; j++) { -- src_row = ((uint32_t*)curdata->buffer)[i * curdata->w + j]; -- SDL_memcpy(ready_buffer + ((curdata->w - j + 1) * bo_stride) + i, &src_row, 4); -+ uintptr_t src_pixel = src_buf + (i * curdata->w + j) * 4; -+ uintptr_t dst_pixel; -+ -+ int x, y; -+ if (dispdata->orientation == 0) { -+ x = j; -+ y = i; -+ } else if (dispdata->orientation == 1) { -+ x = curdata->w - i - 1; -+ y = j; -+ } else if (dispdata->orientation == 2) { -+ x = curdata->h - j - 1; -+ y = curdata->w - i - 1; -+ } else if (dispdata->orientation == 3) { -+ x = i; -+ y = curdata->h - j - 1; -+ } -+ -+ dst_pixel = dst_buf + (y * bo_stride + x * sizeof(uint32_t)); -+ *(uint32_t*)dst_pixel = *(uint32_t*)src_pixel; - } - } - -@@ -382,7 +402,23 @@ static int KMSDRM_WarpMouseGlobal(int x, int y) - if (dispdata->cursor_bo) { - int ret = 0; - -- ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, y, dispdata->mode.vdisplay + curdata->w - x); -+ if (dispdata->orientation == 0) { -+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, -+ x, -+ y); -+ } else if (dispdata->orientation == 1) { -+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, -+ dispdata->mode.hdisplay - curdata->h - y, -+ x); -+ } else if (dispdata->orientation == 2) { -+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, -+ dispdata->mode.hdisplay - curdata->w - x, -+ dispdata->mode.vdisplay - curdata->h - y); -+ } else if (dispdata->orientation == 3) { -+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, -+ y, -+ dispdata->mode.vdisplay - curdata->w - x); -+ } - - if (ret) { - SDL_SetError("drmModeMoveCursor() failed."); -@@ -443,7 +479,23 @@ static void KMSDRM_MoveCursor(SDL_Cursor *cursor) - return; - } - -- ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, mouse->y, dispdata->mode.vdisplay - curdata->w - mouse->x); -+ if (dispdata->orientation == 0) { -+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, -+ mouse->x, -+ mouse->y); -+ } else if (dispdata->orientation == 1) { -+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, -+ dispdata->mode.hdisplay - curdata->h - mouse->y, -+ mouse->x); -+ } else if (dispdata->orientation == 2) { -+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, -+ dispdata->mode.hdisplay - curdata->w - mouse->x, -+ dispdata->mode.vdisplay - curdata->h - mouse->y); -+ } else if (dispdata->orientation == 3) { -+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, -+ mouse->y, -+ dispdata->mode.vdisplay - curdata->w - mouse->x); -+ } - - if (ret) { - SDL_SetError("drmModeMoveCursor() failed."); -diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c -index c5340afa8..663c4707c 100644 ---- a/src/video/kmsdrm/SDL_kmsdrmvideo.c -+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c -@@ -336,24 +336,27 @@ static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data) - } - - static void --KMSDRM_InitRotateBuffer(_THIS, int frameWidth, int frameHeight) -+KMSDRM_InitRotateBuffer(_THIS, int orientation, int frameWidth, int frameHeight) - { -- int l_frameHeight; -+ int l_frameHeight, l_frameWidth; - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - - // initialize 2D raster graphic acceleration unit (RGA) - c_RkRgaInit(); - -- l_frameHeight = frameHeight; -- if(l_frameHeight % 32 != 0) { -- l_frameHeight = (frameHeight + 32) & (~31); -+ if (orientation & 1) { -+ l_frameWidth = frameWidth; -+ l_frameHeight = (frameHeight + 31) & (~31); -+ } else { -+ l_frameWidth = (frameWidth + 31) & (~31); -+ l_frameHeight = frameHeight; - } - - // create buffers for RGA with adjusted stride - for (int i = 0; i < RGA_BUFFERS_MAX; ++i) - { - viddata->rga_buffers[i] = KMSDRM_gbm_bo_create(viddata->gbm_dev, -- frameWidth, l_frameHeight, -+ l_frameWidth, l_frameHeight, - GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); - assert(viddata->rga_buffers[i]); - -@@ -364,10 +367,18 @@ KMSDRM_InitRotateBuffer(_THIS, int frameWidth, int frameHeight) - // setup rotation - src_info.fd = -1; - src_info.mmuFlag = 1; -- src_info.rotation = HAL_TRANSFORM_ROT_270; -+ switch (orientation) { -+ default: src_info.rotation = 0; break; -+ case 1: src_info.rotation = HAL_TRANSFORM_ROT_90; break; -+ case 2: src_info.rotation = HAL_TRANSFORM_ROT_180; break; -+ case 3: src_info.rotation = HAL_TRANSFORM_ROT_270; break; -+ } - - // swap width and height and adjust stride here because our source buffer is 480x854 -- rga_set_rect(&src_info.rect, 0, 0, frameHeight, frameWidth, l_frameHeight, frameWidth, RK_FORMAT_BGRA_8888); -+ if (orientation & 1) -+ rga_set_rect(&src_info.rect, 0, 0, frameHeight, frameWidth, l_frameHeight, l_frameWidth, RK_FORMAT_BGRA_8888); -+ else -+ rga_set_rect(&src_info.rect, 0, 0, frameWidth, frameHeight, l_frameWidth, l_frameHeight, RK_FORMAT_BGRA_8888); - - dst_info.fd = -1; - dst_info.mmuFlag = 1; -@@ -617,6 +628,52 @@ static SDL_bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vr - return SDL_TRUE; - } - -+static int KMSDRM_ConnectorGetOrientation(uint32_t drm_fd, -+ uint32_t output_id) -+{ -+ uint32_t i; -+ SDL_bool found = SDL_FALSE; -+ uint64_t orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; -+ -+ drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(drm_fd, -+ output_id, -+ DRM_MODE_OBJECT_CONNECTOR); -+ -+ // Allow forcing specific orientations for debugging. -+ const char *override = SDL_getenv("SDL_KMSDRM_ORIENTATION"); -+ if (override && override[0] != '\0') { -+ int val = SDL_atoi(override); -+ return SDL_clamp(val, 0, 3); -+ } -+ -+ if (!props) { -+ return 0; -+ } -+ -+ for (i = 0; !found && i < props->count_props; ++i) { -+ drmModePropertyPtr drm_prop = KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); -+ -+ if (!drm_prop) { -+ continue; -+ } -+ -+ if (SDL_strcasecmp(drm_prop->name, "panel orientation") == 0) { -+ orientation = props->prop_values[i]; -+ found = SDL_TRUE; -+ } -+ -+ KMSDRM_drmModeFreeProperty(drm_prop); -+ } -+ -+ /* librga expresses rotations clockwise. (e.g., dts = 90? rga = 270!) */ -+ switch (orientation) { -+ default: return 0; -+ case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP: return 2; -+ case DRM_MODE_PANEL_ORIENTATION_LEFT_UP: return 1; -+ case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP: return 3; -+ } -+} -+ - static SDL_bool KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, - uint32_t output_id, - char const *name) -@@ -869,6 +926,8 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re - dispdata->connector = connector; - dispdata->crtc = crtc; - -+ /* store current connector orientation */ -+ dispdata->orientation = KMSDRM_ConnectorGetOrientation(viddata->drm_fd, connector->connector_id); - /* save previous vrr state */ - dispdata->saved_vrr = KMSDRM_CrtcGetVrr(viddata->drm_fd, crtc->crtc_id); - /* try to enable vrr */ -@@ -893,8 +952,13 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re - modedata->mode_index = mode_index; - - display.driverdata = dispdata; -- display.desktop_mode.w = dispdata->mode.vdisplay; -- display.desktop_mode.h = dispdata->mode.hdisplay; -+ if (dispdata->orientation & 1) { -+ display.desktop_mode.w = dispdata->mode.vdisplay; -+ display.desktop_mode.h = dispdata->mode.hdisplay; -+ } else { -+ display.desktop_mode.w = dispdata->mode.hdisplay; -+ display.desktop_mode.h = dispdata->mode.vdisplay; -+ } - display.desktop_mode.refresh_rate = dispdata->mode.vrefresh; - display.desktop_mode.format = SDL_PIXELFORMAT_ARGB8888; - display.desktop_mode.driverdata = modedata; -@@ -1158,8 +1222,10 @@ static void KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode) - - static void KMSDRM_DirtySurfaces(SDL_Window *window) - { -- SDL_WindowData *windata = (SDL_WindowData *)window->driverdata; - drmModeModeInfo mode; -+ SDL_WindowData *windata = (SDL_WindowData *)window->driverdata; -+ SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); -+ SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; - - /* Can't recreate EGL surfaces right now, need to wait until SwapWindow - so the correct thread-local surface and context state are available */ -@@ -1169,8 +1235,10 @@ static void KMSDRM_DirtySurfaces(SDL_Window *window) - or SetWindowFullscreen, send a fake event for now since the actual - recreation is deferred */ - KMSDRM_GetModeToSet(window, &mode); -- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode.vdisplay, mode.hdisplay); -- -+ if (dispdata->orientation & 1) -+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode.vdisplay, mode.hdisplay); -+ else -+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode.hdisplay, mode.vdisplay); - } - - /* This determines the size of the fb, which comes from the GBM surface -@@ -1204,14 +1272,18 @@ int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window) - SDL_video.c expects. Hulk-smash the display's current_mode to keep the - mode that's set in sync with what SDL_video.c thinks is set */ - KMSDRM_GetModeToSet(window, &dispdata->mode); -- -- display->current_mode.w = dispdata->mode.vdisplay; -- display->current_mode.h = dispdata->mode.hdisplay; -+ if (dispdata->orientation & 1) { -+ display->current_mode.w = dispdata->mode.vdisplay; -+ display->current_mode.h = dispdata->mode.hdisplay; -+ } else { -+ display->current_mode.w = dispdata->mode.hdisplay; -+ display->current_mode.h = dispdata->mode.vdisplay; -+ } - display->current_mode.refresh_rate = dispdata->mode.vrefresh; - display->current_mode.format = SDL_PIXELFORMAT_ARGB8888; - - windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev, -- dispdata->mode.vdisplay, dispdata->mode.hdisplay, -+ display->current_mode.w, display->current_mode.h, - surface_fmt, surface_flags); - - if (!windata->gs) { -@@ -1235,7 +1307,7 @@ int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window) - ret = SDL_EGL_MakeCurrent(_this, windata->egl_surface, egl_context); - - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, -- dispdata->mode.vdisplay, dispdata->mode.hdisplay); -+ display->current_mode.w, display->current_mode.h); - - windata->egl_surface_dirty = SDL_FALSE; - -@@ -1318,8 +1390,14 @@ void KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay *display) - modedata->mode_index = i; - } - -- mode.w = conn->modes[i].vdisplay; -- mode.h = conn->modes[i].hdisplay; -+ if (dispdata->orientation & 1) { -+ mode.w = conn->modes[i].vdisplay; -+ mode.h = conn->modes[i].hdisplay; -+ } else { -+ mode.w = conn->modes[i].hdisplay; -+ mode.h = conn->modes[i].vdisplay; -+ } -+ - mode.refresh_rate = conn->modes[i].vrefresh; - mode.format = SDL_PIXELFORMAT_ARGB8888; - mode.driverdata = modedata; -@@ -1573,8 +1651,8 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window) - SDL_SetMouseFocus(window); - SDL_SetKeyboardFocus(window); - -- data = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; -- KMSDRM_InitRotateBuffer(_this, data->mode.hdisplay, data->mode.vdisplay); -+ data = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; -+ KMSDRM_InitRotateBuffer(_this, dispdata->orientation, data->mode.hdisplay, data->mode.vdisplay); - - /* Tell the app that the window has moved to top-left. */ - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, 0, 0); -diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h -index 890575fb8..8d2dc646f 100644 ---- a/src/video/kmsdrm/SDL_kmsdrmvideo.h -+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h -@@ -78,6 +78,8 @@ typedef struct SDL_DisplayData - - drmModeCrtc *saved_crtc; /* CRTC to restore on quit */ - SDL_bool saved_vrr; -+ -+ uint64_t orientation; - - /* DRM & GBM cursor stuff lives here, not in an SDL_Cursor's driverdata struct, - because setting/unsetting up these is done on window creation/destruction, --- -2.20.1 - diff --git a/packages/graphics/SDL2/patches/RK3566/0006-limit-rga-buffering-when-egl.patch b/packages/graphics/SDL2/patches/RK3566/0006-limit-rga-buffering-when-egl.patch deleted file mode 100644 index dbd293812..000000000 --- a/packages/graphics/SDL2/patches/RK3566/0006-limit-rga-buffering-when-egl.patch +++ /dev/null @@ -1,59 +0,0 @@ -diff -rupN SDL2-2.28.5.orig/src/video/kmsdrm/SDL_kmsdrmopengles.c SDL2-2.28.5/src/video/kmsdrm/SDL_kmsdrmopengles.c ---- SDL2-2.28.5.orig/src/video/kmsdrm/SDL_kmsdrmopengles.c 2024-01-30 16:22:00.475039122 +0000 -+++ SDL2-2.28.5/src/video/kmsdrm/SDL_kmsdrmopengles.c 2024-01-30 17:56:52.799111194 +0000 -@@ -29,11 +29,15 @@ - #include "SDL_kmsdrmopengles.h" - #include "SDL_kmsdrmdyn.h" - #include -+#include - - #ifndef EGL_PLATFORM_GBM_MESA - #define EGL_PLATFORM_GBM_MESA 0x31D7 - #endif - -+extern rga_info_t src_info; -+extern rga_info_t dst_info; -+ - /* EGL implementation of SDL OpenGL support */ - - void KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) -@@ -92,6 +96,7 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Wi - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - KMSDRM_FBInfo *fb_info; - int ret = 0; -+ struct gbm_bo* rga_buffer = NULL; - - /* Always wait for the previous issued flip before issuing a new one, - even if you do async flips. */ -@@ -135,7 +140,30 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Wi - } - - /* Get an actual usable fb for the next front buffer. */ -- fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); -+ if (dispdata->orientation == 0) { -+ fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); -+ } else { -+ if (src_info.fd) { -+ close(src_info.fd); -+ } -+ src_info.fd = KMSDRM_gbm_bo_get_fd(windata->next_bo); -+ dst_info.fd = viddata->rga_buffer_prime_fds[viddata->rga_buffer_index]; -+ if (c_RkRgaBlit(&src_info, &dst_info, NULL) < 0) { -+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO, -+ "Failed to rga blit\n"); -+ } -+ -+ rga_buffer = viddata->rga_buffers[viddata->rga_buffer_index]; -+ fb_info = KMSDRM_FBFromBO(_this, rga_buffer); -+ -+ if (!fb_info) { -+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer"); -+ return 0; -+ } -+ -+ viddata->rga_buffer_index = (viddata->rga_buffer_index + 1) % RGA_BUFFERS_MAX; -+ } -+ - if (fb_info == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer"); - return 0; From ca920aa5b39f6636c409f4b0768ad58a9b6f7be2 Mon Sep 17 00:00:00 2001 From: brooksytech <1673861+brooksytech@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:42:44 +0000 Subject: [PATCH 2/2] Update linux to 6.8.2 & update Mesa --- packages/graphics/mesa/package.mk | 4 ++-- packages/hardware/quirks/platforms/RK3588/090-ui_service | 2 +- packages/kernel/linux/package.mk | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/graphics/mesa/package.mk b/packages/graphics/mesa/package.mk index 09e16c382..86138cf8e 100644 --- a/packages/graphics/mesa/package.mk +++ b/packages/graphics/mesa/package.mk @@ -17,13 +17,13 @@ case ${DEVICE} in PKG_GIT_CLONE_BRANCH="csf" ;; RK3*) #Using upstream dev for panfrost - PKG_VERSION="b8ffa9f956c4bcb416a0ad94d8b65ce050a05357" + PKG_VERSION="db29984c254f60f5daeec0ea4e6048b6ee7902f8" PKG_SITE="https://gitlab.freedesktop.org/mesa/mesa" PKG_URL="${PKG_SITE}.git" PKG_PATCH_DIRS+=" panfrost" ;; *) - PKG_VERSION="24.0.2" + PKG_VERSION="24.0.4" PKG_SITE="http://www.mesa3d.org/" PKG_URL="https://gitlab.freedesktop.org/mesa/mesa/-/archive/mesa-${PKG_VERSION}/mesa-mesa-${PKG_VERSION}.tar.gz" ;; diff --git a/packages/hardware/quirks/platforms/RK3588/090-ui_service b/packages/hardware/quirks/platforms/RK3588/090-ui_service index 5da8b376c..bc7013fc9 100755 --- a/packages/hardware/quirks/platforms/RK3588/090-ui_service +++ b/packages/hardware/quirks/platforms/RK3588/090-ui_service @@ -4,5 +4,5 @@ ### Set the default device configuration cat </storage/.config/profile.d/090-ui_service -UI_SERVICE="sway.service essway.service" +UI_SERVICE="weston.service" EOF diff --git a/packages/kernel/linux/package.mk b/packages/kernel/linux/package.mk index 14ebe5c9f..c68eeeb08 100644 --- a/packages/kernel/linux/package.mk +++ b/packages/kernel/linux/package.mk @@ -21,7 +21,7 @@ case ${DEVICE} in PKG_GIT_CLONE_BRANCH="rk-5.10-rkr6" ;; *) - PKG_VERSION="6.8.1" + PKG_VERSION="6.8.2" PKG_URL="${PKG_SITE}/pub/linux/kernel/v6.x/${PKG_NAME}-${PKG_VERSION}.tar.xz" ;; esac