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

60 lines
1.8 KiB
Diff
Raw Normal View History

diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index fbc2c96..cedc739 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -609,6 +609,24 @@ void KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resource
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);
@@ -1107,8 +1125,27 @@ 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;