[KMS/DRM] Don't use primary plane for scaling because that's unsupported on most LEGACY-only HW.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.c b/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.c
index bc3d58a..c4acd75 100644
--- a/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.c
+++ b/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.c
@@ -135,33 +135,6 @@ KMSDRM_LEGACY_GLES_SwapWindow(_THIS, SDL_Window * window) {
return 0;
}
- if (!windata->bo) {
- /***************************************************************************/
- /* This is fundamental. */
- /* We can't display an fb smaller than the resolution currently configured */
- /* on the CRTC, because the CRTC would be scanning out of bounds. */
- /* So instead of using drmModeSetCrtc() to tell CRTC to scan the fb */
- /* directly, we use a plane (overlay or primary, doesn't mind if we */
- /* activated the UNVERSAL PLANES cap) to scale the buffer to the */
- /* resolution currently configured on the CRTC. */
- /* */
- /* We can't do this sooner, on CreateWindow(), because we don't have a */
- /* framebuffer there yet, and DRM doesn't like 0 or -1 as the fb_id. */
- /***************************************************************************/
- ret = KMSDRM_LEGACY_drmModeSetPlane(viddata->drm_fd, dispdata->plane_id,
- dispdata->crtc->crtc_id, fb_info->fb_id, 0,
- windata->output_x, 0,
- windata->output_w, windata->output_h,
- 0, 0,
- windata->src_w << 16, windata->src_h << 16);
-
- if (ret) {
- SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set PLANE");
- }
-
- return 0;
- }
-
/* Issue pageflip on the next front buffer.
The pageflip will be done during the next vblank. */
ret = KMSDRM_LEGACY_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id,
diff --git a/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c b/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c
index 5a9993d..b7607a3 100644
--- a/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c
+++ b/src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c
@@ -411,7 +411,6 @@ VideoBootStrap KMSDRM_LEGACY_bootstrap = {
KMSDRM_LEGACY_CreateDevice
};
-
static void
KMSDRM_LEGACY_FBDestroyCallback(struct gbm_bo *bo, void *data)
{
@@ -1192,6 +1191,15 @@ KMSDRM_LEGACY_CreateWindow(_THIS, SDL_Window * window)
See previous comment on why. */
window->flags |= SDL_WINDOW_OPENGL;
+ /* We need that the fb that SDL gives us has the same size as the videomode
+ currently configure on the CRTC, because the LEGACY interface doesn't
+ support scaling on the primary plane on most hardware (and overlay
+ planes are not present in all hw), so the CRTC reads the PRIMARY PLANE
+ without any scaling, and that's all.
+ So AR-correctin is also impossible on the LEGACY interface. */
+ window->w = dispdata->mode.hdisplay;
+ window->h = dispdata->mode.vdisplay;
+
/* Reopen FD, create gbm dev, setup display plane, etc,.
but only when we come here for the first time,
and only if it's not a VK window. */
@@ -1266,6 +1274,25 @@ KMSDRM_LEGACY_CreateWindow(_THIS, SDL_Window * window)
if ((ret = KMSDRM_LEGACY_CreateSurfaces(_this, window))) {
goto cleanup;
}
+
+ /***************************************************************************/
+ /* This is fundamental. */
+ /* We can't display an fb smaller than the resolution currently configured */
+ /* on the CRTC, because the CRTC would be scanning out of bounds, and */
+ /* drmModeSetCrtc() would fail. */
+ /* A possible solution would be scaling on the primary plane with */
+ /* drmModeSetPlane(), but primary plane scaling is not supported in most */
+ /* LEGACY-only hardware, so never use drmModeSetPlane(). */
+ /***************************************************************************/
+
+ ret = KMSDRM_LEGACY_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id,
+ /*fb_info->fb_id*/ -1, 0, 0, &dispdata->connector->connector_id, 1,
+ &dispdata->mode);
+
+ if (ret) {
+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set CRTC");
+ goto cleanup;
+ }
}
/* Add window to the internal list of tracked windows. Note, while it may