Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/sdl2: fix sdl_init() error with kernel 5.15
@ 2022-11-21 12:40 Michael Fischer
  2022-11-21 20:07 ` Yann E. MORIN
  2022-11-24  9:12 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Fischer @ 2022-11-21 12:40 UTC (permalink / raw)
  To: buildroot; +Cc: Michael Fischer

Fixes #6421
Backport from: da9ba3a2a1536017e4ce1ee0f4276578d1ce6e29

Signed-off-by: Michael Fischer <mf@go-sys.de>
---
 package/sdl2/0001-fix-CRTC-default-mode.patch | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 package/sdl2/0001-fix-CRTC-default-mode.patch

diff --git a/package/sdl2/0001-fix-CRTC-default-mode.patch b/package/sdl2/0001-fix-CRTC-default-mode.patch
new file mode 100644
index 0000000000..5efc3f55c2
--- /dev/null
+++ b/package/sdl2/0001-fix-CRTC-default-mode.patch
@@ -0,0 +1,66 @@
+Patch to fix SDL_Init() error with kernel 5.15.x
+Thanks to Sam Lantinga <slouken@libsdl.org> for his help.
+Fix: #6421
+
+Backported from: da9ba3a2a1536017e4ce1ee0f4276578d1ce6e29
+
+Signed-off-by: Michael Fischer <mf@go-sys.de>
+
+
+diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
+index eae7214551a9..eeeefef2b2c1 100644
+--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
++++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
+@@ -666,8 +666,8 @@ KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id)
+ /* Gets a DRM connector, builds an SDL_Display with it, and adds it to the
+    list of SDL Displays in _this->displays[]  */
+ static void
+-KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) {
+-
++KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources)
++{
+     SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
+     SDL_DisplayData *dispdata = NULL;
+     SDL_VideoDisplay display = {0};
+@@ -770,14 +770,37 @@ KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) {
+         drmModeModeInfo *mode = &connector->modes[i];
+
+         if (!SDL_memcmp(mode, &crtc->mode, sizeof(crtc->mode))) {
+-          mode_index = i;
+-          break;
++            mode_index = i;
++            break;
+         }
+     }
+
+     if (mode_index == -1) {
+-      ret = SDL_SetError("Failed to find index of mode attached to the CRTC.");
+-      goto cleanup;
++        int current_area, largest_area = 0;
++
++        /* Find the preferred mode or the highest resolution mode */
++        for (i = 0; i < connector->count_modes; i++) {
++            drmModeModeInfo *mode = &connector->modes[i];
++
++            if (mode->type & DRM_MODE_TYPE_PREFERRED) {
++                mode_index = i;
++                break;
++            }
++
++            current_area = mode->hdisplay * mode->vdisplay;
++            if (current_area > largest_area) {
++                mode_index = i;
++                largest_area = current_area;
++            }
++        }
++        if (mode_index != -1) {
++            crtc->mode = connector->modes[mode_index];
++        }
++    }
++
++    if (mode_index == -1) {
++        ret = SDL_SetError("Failed to find index of mode attached to the CRTC.");
++        goto cleanup;
+     }
+
+     /*********************************************/
-- 
2.20.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-24  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-21 12:40 [Buildroot] [PATCH 1/1] package/sdl2: fix sdl_init() error with kernel 5.15 Michael Fischer
2022-11-21 20:07 ` Yann E. MORIN
2022-11-24  9:12 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox