package/sdl2: fix sdl_init() error with kernel 5.15
PATCH 1/1 package/sdl2: fix sdl_init() error with kernel 5.15
Fixes #6421
Backport from: da9ba3a2a1536017e4ce1ee0f4276578d1ce6e29
--- 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
package/sdl2/0001-fix-CRTC-default-mode.patch new file +66 -0
@@ -0,0 +1,66 @@ +Patch to fix SDL_Init() error with kernel 5.15.x +Thanks to Sam Lantinga <[email protected]> for his help. +Fix: #6421 + +Backported from: da9ba3a2a1536017e4ce1ee0f4276578d1ce6e29 + +Signed-off-by: Michael Fischer <[email protected]> + + +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; + } + + /*********************************************/
Signature · 6 lines
2.20.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Yann E. MORIN
AppliedMichael, All,
On 2022-11-21 13:40 +0100, Michael Fischer spake thusly:
Quoted 15 lines
Fixes #6421
Backport from:da9ba3a2a1536017e4ce1ee0f4276578d1ce6e29Signed-off-by Michael Fischer <[email protected]>--- package/sdl2/0001-fix-CRTC-default-mode.patch | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 package/sdl2/0001-fix-CRTC-default-mode.patchpackage/sdl2/0001-fix-CRTC-default-mode.patch new file +0
-0
package/sdl2/0001-fix-CRTC-default-mode.patch line 5
Quoted 5 lines
package/sdl2/0001-fix-CRTC-default-mode.patch new file +5
-0@@ -0,0 +1,66 @@ +Patch to fix SDL_Init() error with kernel 5.15.x +Thanks to Sam Lantinga <[email protected]> for his help. +Fix: #6421 + +Backported from: da9ba3a2a1536017e4ce1ee0f4276578d1ce6e29
Since SDL2 is hosted as a git repository, we want this to be a git-formatted patch, epecially since it is a backport.
So I fixed that; please check commit 7928c51bf6.
Applied to master, thanks.
Regards,
Yann E. MORIN.
Quoted 67 lines
package/sdl2/0001-fix-CRTC-default-mode.patch new file +60
-0+Signed-off-by: Michael Fischer <[email protected]> + + +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; + } + + /*********************************************/Signature · 6 lines
2.20.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Michael" == Michael Fischer <[email protected]> writes:
Fixes #6421
Backport from:da9ba3a2a1536017e4ce1ee0f4276578d1ce6e29Signed-off-by Michael Fischer <[email protected]>
I take it that this #6421 is
https://github.com/libsdl-org/SDL/issues/6421?
Does this also apply to 2.0.22 as we have on 2022.08.x or 2.0.20 as we have on 2022.02.x or is it a new regression in 2.24.x?
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot