Merge pull request #2765 from fewtarius/dev

Add support for Powkiddy RGB10 Max 3
This commit is contained in:
fewtarius 2024-01-30 15:08:30 -05:00 committed by GitHub
commit 6679338e7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 1136 additions and 6 deletions

View file

@ -101,7 +101,7 @@ jobs:
|**Device/Platform**|**Download Package**|**Documentation**|
|----|----|----|
|**Anbernic RG351P/M, ODROID Go Advance, ODROID Go Super, Magicx XU10**|[JELOS-RK3326.aarch64-${{ steps.version.outputs.version }}.img.gz](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-RK3326.aarch64-${{ steps.version.outputs.version }}.img.gz)|[documentation](/documentation/PER_DEVICE_DOCUMENTATION/RK3326/)|
|**Anbernic RG353P/M/V/VS, RG503, Powkiddy RK2023, RGB30**|[JELOS-RK3566.aarch64-${{ steps.version.outputs.version }}.img.gz](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-RK3566.aarch64-${{ steps.version.outputs.version }}.img.gz)|[documentation](/documentation/PER_DEVICE_DOCUMENTATION/RK3566/)|
|**Anbernic RG353P/M/V/VS, RG503, Powkiddy RK2023, RGB30, RGB10 Max 3**|[JELOS-RK3566.aarch64-${{ steps.version.outputs.version }}.img.gz](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-RK3566.aarch64-${{ steps.version.outputs.version }}.img.gz)|[documentation](/documentation/PER_DEVICE_DOCUMENTATION/RK3566/)|
|**Anbernic RG552**|[JELOS-RK3399.aarch64-${{ steps.version.outputs.version }}.img.gz](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-RK3399.aarch64-${{ steps.version.outputs.version }}.img.gz)|[documentation](/documentation/PER_DEVICE_DOCUMENTATION/RK3399/)|
|**Atari VCS, AOKZOE, Ayaneo, Ayn, GPD, and other x86_64 devices**|[JELOS-AMD64.x86_64-${{ steps.version.outputs.version }}.img.gz](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-AMD64.x86_64-${{ steps.version.outputs.version }}.img.gz)|[documentation](/documentation/PER_DEVICE_DOCUMENTATION/AMD64/)|
|**Hardkernel ODROID Go Ultra, Powkiddy RGB10 Max 3 Pro**|[JELOS-S922X.aarch64-${{ steps.version.outputs.version }}-Odroid_GOU.img.gz](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-S922X.aarch64-${{ steps.version.outputs.version }}-Odroid_GOU.img.gz)|[documentation](/documentation/PER_DEVICE_DOCUMENTATION/S922X/)|
@ -121,7 +121,7 @@ jobs:
|**Device/Platform**|**Download Package**|
|----|----|
|**Anbernic RG351P/M, ODROID Go Advance, ODROID Go Super, Magicx XU10**|[JELOS-RK3326.aarch64-${{ steps.version.outputs.version }}.tar](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-RK3326.aarch64-${{ steps.version.outputs.version }}.tar)|
|**Anbernic RG353P/M/V/VS, RG503, Powkiddy RK2023, RGB30**|[JELOS-RK3566.aarch64-${{ steps.version.outputs.version }}.tar](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-RK3566.aarch64-${{ steps.version.outputs.version }}.tar)|
|**Anbernic RG353P/M/V/VS, RG503, Powkiddy RK2023, RGB30, RGB10 Max 3**|[JELOS-RK3566.aarch64-${{ steps.version.outputs.version }}.tar](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-RK3566.aarch64-${{ steps.version.outputs.version }}.tar)|
|**Anbernic RG552**|[JELOS-RK3399.aarch64-${{ steps.version.outputs.version }}.tar](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-RK3399.aarch64-${{ steps.version.outputs.version }}.tar)|
|****Atari VCS, AOKZOE, Ayaneo, Ayn, GPD, and other x86_64 devices****|[JELOS-AMD64.x86_64-${{ steps.version.outputs.version }}.tar](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-AMD64.x86_64-${{ steps.version.outputs.version }}.tar)|
|**Hardkernel ODROID Go Ultra, N2/N2+/N2L, Powkiddy RGB10 Max 3 Pro**|[JELOS-S922X.aarch64-${{ steps.version.outputs.version }}.tar](https://github.com/JustEnoughLinuxOS/distribution/releases/download/${{ steps.version.outputs.version }}/JELOS-S922X.aarch64-${{ steps.version.outputs.version }}.tar)|

View file

@ -27,7 +27,7 @@ src-pkg:
docs:
./tools/foreach './scripts/clean emulators && ./scripts/build emulators'
world: AMD64 RK3588 S922X RK3326 RK3399
world: AMD64 RK3588 S922X RK3566 RK3566-X55 RK3326 RK3399
AMD64:
unset DEVICE_ROOT

View file

@ -128,6 +128,7 @@ JELOS supports a variety of ARM and Intel/AMD based devices.
| Orange Pi | [Orange Pi 5](http://jelos.org/devices/orange-pi/orange-pi-5) | Rockchip RK3588S / Mali G610 (ARMv8-A) | Rockchip 5.10 BSP Linux | Panfrost | Weston + Emulation Station |
| Magicx | [XU10](http://jelos.org/devices/magicx/xu10) | Rockchip RK3326 (ARM) | Mainline Linux | Panfrost | Weston + Emulation Station |
| Powkiddy | [RGB10](http://jelos.org/devices/powkiddy/rgb10) | Rockchip RK3326 (ARM) | Mainline Linux | Panfrost | Weston + Emulation Station |
| Powkiddy | [RGB10 Max 3](http://jelos.org/devices/powkiddy/rgb10-max-3) | Rockchip RK3566 (ARM) | Rockchip BSP 4.19 | Mali | KMS/DRM + Emulation Station |
| Powkiddy | [RGB10 Max 3 Pro](http://jelos.org/devices/powkiddy/rgb10-max-3-pro) | Amlogic A311D / Mali G52 M4 (ARMv8-A) | Mainline Linux | Mali | Weston + Emulation Station |
| Powkiddy | [RGB30](http://jelos.org/devices/powkiddy/rgb30) | Rockchip RK3566 (ARM) | Rockchip BSP 4.19 | Mali | KMS/DRM + Emulation Station |
| Powkiddy | [RK2023](http://jelos.org/devices/powkiddy/rk2023) | Rockchip RK3566 (ARM) | Rockchip BSP 4.19 | Mali | KMS/DRM + Emulation Station |

View file

@ -38,7 +38,7 @@ case ${PROJECT} in
esac
case ${DEVICE} in
RK3566-X55)
RK3566*)
PKG_DEPENDS_TARGET+=" libgo2"
PKG_CONFIGURE_OPTS_TARGET+=" --enable-odroidgo2"
;;

View file

@ -0,0 +1,12 @@
diff -rupN retroarch.orig/gfx/drivers/oga_gfx.c retroarch/gfx/drivers/oga_gfx.c
--- retroarch.orig/gfx/drivers/oga_gfx.c 2022-02-28 19:40:46.222185295 -0500
+++ retroarch/gfx/drivers/oga_gfx.c 2022-02-28 19:44:14.187909576 -0500
@@ -22,7 +22,7 @@
#include "../../verbosity.h"
#include <fcntl.h>
#include <rga/RgaApi.h>
-#include <rga/RockchipRgaMacro.h>
+#include <rga/drmrga.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <drm/drm_fourcc.h>

View file

@ -0,0 +1,35 @@
Correct DRM format on Powkiddy x55, extracted from PowKiddy x55 sources.
diff --git a/deps/libgo2/src/display.c b/deps/libgo2/src/display.c
index b91cf0624b..936b677fc4 100644
--- a/deps/libgo2/src/display.c
+++ b/deps/libgo2/src/display.c
@@ -550,7 +550,7 @@ static uint32_t go2_rkformat_get(uint32_t drm_fourcc)
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_XRGB8888:
- return RK_FORMAT_BGRA_8888;
+ return RK_FORMAT_RGBA_8888;
case DRM_FORMAT_RGB565:
return RK_FORMAT_RGB_565;
@@ -586,6 +586,7 @@ void go2_surface_blit(go2_surface_t* srcSurface, int srcX, int srcY, int srcWidt
dst.rect.hstride = dstSurface->height;
dst.rect.format = go2_rkformat_get(dstSurface->format);
+
rga_info_t src = { 0 };
src.fd = go2_surface_prime_fd(srcSurface);
src.mmuFlag = 1;
diff --git a/gfx/drivers_context/drm_go2_ctx.c b/gfx/drivers_context/drm_go2_ctx.c
index b758137703..dbcb992279 100644
--- a/gfx/drivers_context/drm_go2_ctx.c
+++ b/gfx/drivers_context/drm_go2_ctx.c
@@ -133,7 +133,7 @@ static void *gfx_ctx_go2_drm_init(void *video_driver)
}
drm->presenter = go2_presenter_create(drm->display,
- DRM_FORMAT_RGB565, 0xff000000, true);
+ DRM_FORMAT_XRGB8888, 0xff000000, true);
return drm;
}

View file

@ -0,0 +1,13 @@
diff --git a/gfx/drivers_context/drm_go2_ctx.c b/gfx/drivers_context/drm_go2_ctx.c
index 856aa0f9a2..baa0ca723a 100644
--- a/gfx/drivers_context/drm_go2_ctx.c
+++ b/gfx/drivers_context/drm_go2_ctx.c
@@ -122,7 +122,7 @@ static void *gfx_ctx_go2_drm_init(void *video_driver)
drm->native_height = go2_display_width_get(drm->display);
/* This driver should only be used on rotated screens */
- if (drm->native_width < drm->native_height)
+ if (drm->native_width <= drm->native_height)
{
/* This should be fixed by using wayland/weston... */
go2_display_destroy(drm->display);

View file

@ -0,0 +1,248 @@
From d60c64d4142a0a706632c50b79474ee51464f973 Mon Sep 17 00:00:00 2001
From: Johnny on Flame <johnnyonflame@hotmail.com>
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 <sys/ioctl.h>
#include "SDL_kmsdrmvulkan.h"
#include <sys/stat.h>
#include <sys/param.h>
@@ -51,6 +52,7 @@
#include <dirent.h>
#include <poll.h>
#include <errno.h>
+#include<stdbool.h>
#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 <xf86drmMode.h>
#include <gbm.h>
#include <EGL/egl.h>
+#include <rga/RgaApi.h>
+#include <assert.h>
+
+#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

View file

@ -0,0 +1,356 @@
From 0e53103957dd75be9140a474be343a6b7cc3cc9e Mon Sep 17 00:00:00 2001
From: JohnnyonFlame <johnnyonflame@hotmail.com>
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

View file

@ -0,0 +1,59 @@
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 <errno.h>
+#include<stdbool.h>
#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;

View file

@ -0,0 +1,9 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
cat <<EOF >/storage/.config/profile.d/010-governors
CPU_FREQ=("/sys/devices/system/cpu/cpufreq/policy0")
GPU_FREQ="/sys/devices/platform/fde60000.gpu/devfreq/fde60000.gpu"
DMC_FREQ="/sys/devices/platform/dmc/devfreq/dmc"
EOF

View file

@ -0,0 +1,15 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
cat <<EOF >/storage/.config/profile.d/020-gpios
DEVICE_WIFI="0"
DEVICE_PWM_MOTOR="pwmchip1"
EOF
. /storage/.config/profile.d/020-gpios
# Enable PWM for rumble and turn rumble off during startup.
echo 0 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/export
echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/period
echo 1 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/enable
echo 1000000 > /sys/class/pwm/${DEVICE_PWM_MOTOR}/pwm0/duty_cycle

View file

@ -0,0 +1,14 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile.d/001-functions
MYSLEEPMODE=$(get_setting system.suspendmode)
if [ -z "${MYSLEEPMODE}" ]
then
/usr/bin/suspendmode mem
fi
echo s2idle >/sys/power/mem_sleep

View file

@ -0,0 +1,16 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
# Configure default contrast saturation and hue values
for PROPERTY in brightness contrast saturation hue
do
MYVAL=$(get_setting display.${PROPERTY})
if [ -z "${MYVAL}" ]
then
MYVAL=$(drm_tool list | sed -n '/Connector: 133/,$p' | awk '/'${PROPERTY}'/ {print $5}')
fi
paneladj ${PROPERTY} ${MYVAL}
done

View file

@ -0,0 +1,9 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
cat <<EOF >/storage/.config/profile.d/002-audio_path
DEVICE_PLAYBACK_PATH_SPK="HP"
DEVICE_PLAYBACK_PATH_HP="SPK"
DEVICE_PLAYBACK_PATH="Playback Path"
EOF

View file

@ -0,0 +1,14 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
#Set up gzdoom
if [ ! -d "/storage/.config/gzdoom/" ]; then
cp -rf /usr/config/gzdoom /storage/.config/
sed -i '/Joy10=/c\Joy10=togglemap;
/Joy9=/c\Joy9=menu_main;
/vid_defheight=/c\vid_defheight=480;
/vid_defwidth=/c\vid_defwidth=640' /storage/.config/gzdoom/gzdoom.ini
fi

View file

@ -32,7 +32,7 @@
PARTITION_TABLE="gpt"
UBOOT_LABEL="uboot"
TRUST_LABEL="resource"
DEVICE_DTB=("rk3566-rg353p-linux" "rk3566-rg353v-linux" "rk3566-rg353m-linux" "rk3566-rg503-linux" "rk3566-rk2023-linux" "rk3566-rgb30-linux")
DEVICE_DTB=("rk3566-rg353p-linux" "rk3566-rg353v-linux" "rk3566-rg353m-linux" "rk3566-rg503-linux" "rk3566-rk2023-linux" "rk3566-rgb30-linux" "rk3566-max3pro-linux")
UBOOT_DTB="rk3566"
UBOOT_CONFIG="rk3568_defconfig"
PKG_SOC="rk356x"

View file

@ -25,7 +25,7 @@ case ${DEVICE} in
;;
RK3566)
PKG_URL="${PKG_SITE}/rk356x-kernel.git"
PKG_VERSION="d346337a7b3e3e7e0d12dbdcc4fc62efc86cbda3"
PKG_VERSION="7284f2a43"
GET_HANDLER_SUPPORT="git"
PKG_GIT_CLONE_BRANCH="main"
;;

View file

@ -0,0 +1,103 @@
From c74b76bb8a4da44a9f8cf06f4aba9f3334e1a148 Mon Sep 17 00:00:00 2001
From: Derek Basehore <dbasehore@chromium.org>
Date: Tue, 9 Jul 2019 19:16:56 -0700
Subject: [PATCH 1/4] drm/panel: Add helper for reading DT rotation
This adds a helper function for reading the rotation (panel
orientation) from the device tree.
Signed-off-by: Derek Basehore <dbasehore@chromium.org>
---
drivers/gpu/drm/drm_panel.c | 43 +++++++++++++++++++++++++++++++++++++
include/drm/drm_panel.h | 9 ++++++++
2 files changed, 52 insertions(+)
diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index d37b83f40..b2d8fa2c3 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -168,6 +168,49 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np)
return ERR_PTR(-EPROBE_DEFER);
}
EXPORT_SYMBOL(of_drm_find_panel);
+
+/**
+ * of_drm_get_panel_orientation - look up the orientation of the panel through
+ * the "rotation" binding from a device tree node
+ * @np: device tree node of the panel
+ * @orientation: orientation enum to be filled in
+ *
+ * Looks up the rotation of a panel in the device tree. The orientation of the
+ * panel is expressed as a property name "rotation" in the device tree. The
+ * rotation in the device tree is counter clockwise.
+ *
+ * Return: 0 when a valid rotation value (0, 90, 180, or 270) is read or the
+ * rotation property doesn't exist. -EERROR otherwise.
+ */
+int of_drm_get_panel_orientation(const struct device_node *np,
+ enum drm_panel_orientation *orientation)
+{
+ int rotation, ret;
+
+ ret = of_property_read_u32(np, "rotation", &rotation);
+ if (ret == -EINVAL) {
+ /* Don't return an error if there's no rotation property. */
+ *orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
+ return 0;
+ }
+
+ if (ret < 0)
+ return ret;
+
+ if (rotation == 0)
+ *orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
+ else if (rotation == 90)
+ *orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP;
+ else if (rotation == 180)
+ *orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP;
+ else if (rotation == 270)
+ *orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+EXPORT_SYMBOL(of_drm_get_panel_orientation);
#endif
int drm_panel_notifier_register(struct drm_panel *panel,
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index 6aab8fefc..c58c4c19f 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -53,6 +53,8 @@ struct drm_device;
struct drm_panel;
struct display_timing;
+enum drm_panel_orientation;
+
/**
* @loader_protect: protect loader logo panel's power
* struct drm_panel_funcs - perform operations on a given panel
@@ -240,11 +242,18 @@ int drm_panel_notifier_call_chain(struct drm_panel *panel,
#if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL)
struct drm_panel *of_drm_find_panel(const struct device_node *np);
+int of_drm_get_panel_orientation(const struct device_node *np,
+ enum drm_panel_orientation *orientation);
#else
static inline struct drm_panel *of_drm_find_panel(const struct device_node *np)
{
return ERR_PTR(-ENODEV);
}
+static inline int of_drm_get_panel_orientation(const struct device_node *np,
+ enum drm_panel_orientation *orientation)
+{
+ return -ENODEV;
+}
#endif
#endif
--
2.34.1

View file

@ -0,0 +1,171 @@
From b76306d4adb2e169f8425fb417de565d555fcf22 Mon Sep 17 00:00:00 2001
From: Derek Basehore <dbasehore@chromium.org>
Date: Sun, 5 Jan 2020 16:51:19 +0100
Subject: [PATCH 2/4] drm/connector: Split out orientation quirk detection (v2)
Not every platform needs quirk detection for panel orientation, so
split the drm_connector_init_panel_orientation_property into two
functions. One for platforms without the need for quirks, and the
other for platforms that need quirks.
Hans de Goede (changes in v2):
Rename the function from drm_connector_init_panel_orientation_property
to drm_connector_set_panel_orientation[_with_quirk] and pass in the
panel-orientation to set.
Beside the rename, also make the function set the passed in value
only once, if the value was set before (to a value other then
DRM_MODE_PANEL_ORIENTATION_UNKNOWN) make any further set calls a no-op.
This change is preparation for allowing the user to override the
panel-orientation for any connector from the kernel commandline.
When the panel-orientation is overridden this way, then we must ignore
the panel-orientation detection done by the driver.
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Derek Basehore <dbasehore@chromium.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200105155120.96466-1-hdegoede@redhat.com
---
drivers/gpu/drm/drm_connector.c | 74 ++++++++++++++++++++++++---------
include/drm/drm_connector.h | 9 +++-
2 files changed, 61 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 8a2a1965e..77a2087bf 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -996,7 +996,8 @@ static const struct drm_prop_enum_list dp_colorspaces[] = {
* coordinates, so if userspace rotates the picture to adjust for
* the orientation it must also apply the same transformation to the
* touchscreen input coordinates. This property is initialized by calling
- * drm_connector_init_panel_orientation_property().
+ * drm_connector_set_panel_orientation() or
+ * drm_connector_set_panel_orientation_with_quirk()
*
* scaling mode:
* This property defines how a non-native mode is upscaled to the native
@@ -1713,38 +1714,41 @@ void drm_connector_set_link_status_property(struct drm_connector *connector,
EXPORT_SYMBOL(drm_connector_set_link_status_property);
/**
- * drm_connector_init_panel_orientation_property -
- * initialize the connecters panel_orientation property
- * @connector: connector for which to init the panel-orientation property.
- * @width: width in pixels of the panel, used for panel quirk detection
- * @height: height in pixels of the panel, used for panel quirk detection
+ * drm_connector_set_panel_orientation - sets the connecter's panel_orientation
+ * @connector: connector for which to set the panel-orientation property.
+ * @panel_orientation: drm_panel_orientation value to set
+ *
+ * This function sets the connector's panel_orientation and attaches
+ * a "panel orientation" property to the connector.
*
- * This function should only be called for built-in panels, after setting
- * connector->display_info.panel_orientation first (if known).
+ * Calling this function on a connector where the panel_orientation has
+ * already been set is a no-op (e.g. the orientation has been overridden with
+ * a kernel commandline option).
*
- * This function will check for platform specific (e.g. DMI based) quirks
- * overriding display_info.panel_orientation first, then if panel_orientation
- * is not DRM_MODE_PANEL_ORIENTATION_UNKNOWN it will attach the
- * "panel orientation" property to the connector.
+ * It is allowed to call this function with a panel_orientation of
+ * DRM_MODE_PANEL_ORIENTATION_UNKNOWN, in which case it is a no-op.
*
* Returns:
* Zero on success, negative errno on failure.
*/
-int drm_connector_init_panel_orientation_property(
- struct drm_connector *connector, int width, int height)
+int drm_connector_set_panel_orientation(
+ struct drm_connector *connector,
+ enum drm_panel_orientation panel_orientation)
{
struct drm_device *dev = connector->dev;
struct drm_display_info *info = &connector->display_info;
struct drm_property *prop;
- int orientation_quirk;
- orientation_quirk = drm_get_panel_orientation_quirk(width, height);
- if (orientation_quirk != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
- info->panel_orientation = orientation_quirk;
+ /* Already set? */
+ if (info->panel_orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
+ return 0;
- if (info->panel_orientation == DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
+ /* Don't attach the property if the orientation is unknown */
+ if (panel_orientation == DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
return 0;
+ info->panel_orientation = panel_orientation;
+
prop = dev->mode_config.panel_orientation_property;
if (!prop) {
prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
@@ -1761,7 +1765,37 @@ int drm_connector_init_panel_orientation_property(
info->panel_orientation);
return 0;
}
-EXPORT_SYMBOL(drm_connector_init_panel_orientation_property);
+EXPORT_SYMBOL(drm_connector_set_panel_orientation);
+
+/**
+ * drm_connector_set_panel_orientation_with_quirk -
+ * set the connecter's panel_orientation after checking for quirks
+ * @connector: connector for which to init the panel-orientation property.
+ * @panel_orientation: drm_panel_orientation value to set
+ * @width: width in pixels of the panel, used for panel quirk detection
+ * @height: height in pixels of the panel, used for panel quirk detection
+ *
+ * Like drm_connector_set_panel_orientation(), but with a check for platform
+ * specific (e.g. DMI based) quirks overriding the passed in panel_orientation.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_connector_set_panel_orientation_with_quirk(
+ struct drm_connector *connector,
+ enum drm_panel_orientation panel_orientation,
+ int width, int height)
+{
+ int orientation_quirk;
+
+ orientation_quirk = drm_get_panel_orientation_quirk(width, height);
+ if (orientation_quirk != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
+ panel_orientation = orientation_quirk;
+
+ return drm_connector_set_panel_orientation(connector,
+ panel_orientation);
+}
+EXPORT_SYMBOL(drm_connector_set_panel_orientation_with_quirk);
int drm_connector_set_obj_prop(struct drm_mode_object *obj,
struct drm_property *property,
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 1d81bb31f..44b6c7f85 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1473,8 +1473,13 @@ int drm_connector_update_edid_property(struct drm_connector *connector,
const struct edid *edid);
void drm_connector_set_link_status_property(struct drm_connector *connector,
uint64_t link_status);
-int drm_connector_init_panel_orientation_property(
- struct drm_connector *connector, int width, int height);
+int drm_connector_set_panel_orientation(
+ struct drm_connector *connector,
+ enum drm_panel_orientation panel_orientation);
+int drm_connector_set_panel_orientation_with_quirk(
+ struct drm_connector *connector,
+ enum drm_panel_orientation panel_orientation,
+ int width, int height);
/**
* struct drm_tile_group - Tile group metadata
--
2.34.1

View file

@ -0,0 +1,55 @@
From 953791baf27ea161378af5c78d8db337472507c8 Mon Sep 17 00:00:00 2001
From: Dmitry Osipenko <digetx@gmail.com>
Date: Fri, 14 Aug 2020 00:56:09 +0300
Subject: [PATCH 3/4] drm/panel-simple: Read panel orientation
The panel orientation needs to parsed from a device-tree and assigned to
the panel's connector in order to make orientation property available to
userspace. That's what this patch does for the panel-simple driver.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200813215609.28643-5-digetx@gmail.com
---
drivers/gpu/drm/panel/panel-simple.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index f41d4e091..f10181b93 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -127,6 +127,8 @@ struct panel_simple {
struct gpio_desc *spi_scl_gpio;
struct gpio_desc *spi_cs_gpio;
struct device_node *np_crtc;
+
+ enum drm_panel_orientation orientation;
};
enum rockchip_cmd_type {
@@ -442,6 +444,9 @@ static int panel_simple_get_fixed_modes(struct panel_simple *panel)
if (panel->desc->bus_flags)
connector->display_info.bus_flags = panel->desc->bus_flags;
+ /* set up connector's "panel orientation" property */
+ drm_connector_set_panel_orientation(connector, panel->orientation);
+
return num;
}
@@ -789,6 +794,12 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
return -EPROBE_DEFER;
}
+ err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
+ if (err) {
+ dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err);
+ return err;
+ }
+
ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
if (ddc) {
panel->ddc = of_find_i2c_adapter_by_node(ddc);
--
2.34.1