distribution/packages/graphics/SDL2/patches/0006-drm-resolution.patch

70 lines
2.1 KiB
Diff

From 2b837f662b12330e2d5afa867f1b6c1476b93102 Mon Sep 17 00:00:00 2001
From: JohnnyonFlame <johnnyonflame@hotmail.com>
Date: Tue, 8 Aug 2023 04:01:53 -0300
Subject: [PATCH 6/7] drm resolution
---
src/video/kmsdrm/SDL_kmsdrmvideo.c | 39 +++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 663c4707c..39eff8c1d 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -842,6 +842,24 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re
goto cleanup;
}
+ // batocera - set resolution
+ {
+ FILE* fdDrmMode;
+ int drmMode;
+ if((fdDrmMode = fopen("/var/run/drmMode", "r")) != NULL) {
+ if(fscanf(fdDrmMode, "%i", &drmMode) == 1) {
+ if(drmMode>=0 && drmMode<connector->count_modes) {
+ drmModeCrtc *pcrtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
+ if(pcrtc != NULL) {
+ KMSDRM_drmModeSetCrtc(viddata->drm_fd, pcrtc->crtc_id, pcrtc->buffer_id, 0, 0, &connector->connector_id, 1, &connector->modes[drmMode]);
+ }
+ }
+ }
+ fclose(fdDrmMode);
+ }
+ }
+ //
+
/* Try to find a CRTC connected to this encoder */
crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
@@ -1383,8 +1401,27 @@ void KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
SDL_DisplayMode mode;
int i;
+ // batocera
+ int wantedMode = 0;
+ {
+ FILE* fdDrmMode;
+ int drmMode;
+ if((fdDrmMode = fopen("/var/run/drmMode", "r")) != NULL) {
+ if(fscanf(fdDrmMode, "%i", &drmMode) == 1) {
+ if(drmMode>=0 && drmMode<conn->count_modes) {
+ wantedMode = drmMode;
+ }
+ }
+ fclose(fdDrmMode);
+ }
+ }
+ //
+
for (i = 0; i < conn->count_modes; i++) {
- SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
+ SDL_DisplayModeData *modedata;
+ if(i != wantedMode) continue; // batocera
+
+ modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
if (modedata) {
modedata->mode_index = i;
--
2.20.1