Browse Source

[KMS/DRM] Don't use primary plane for scaling because that's unsupported on most LEGACY-only HW.

Manuel Alfayate Corchete 4 years ago
parent
commit
d079130c24

+ 0 - 27
src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_opengles.c

@@ -135,33 +135,6 @@ KMSDRM_LEGACY_GLES_SwapWindow(_THIS, SDL_Window * window) {
         return 0;
         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.
     /* Issue pageflip on the next front buffer.
        The pageflip will be done during the next vblank. */
        The pageflip will be done during the next vblank. */
     ret = KMSDRM_LEGACY_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id,
     ret = KMSDRM_LEGACY_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id,

+ 28 - 1
src/video/kmsdrm_legacy/SDL_kmsdrm_legacy_video.c

@@ -411,7 +411,6 @@ VideoBootStrap KMSDRM_LEGACY_bootstrap = {
     KMSDRM_LEGACY_CreateDevice
     KMSDRM_LEGACY_CreateDevice
 };
 };
 
 
-
 static void
 static void
 KMSDRM_LEGACY_FBDestroyCallback(struct gbm_bo *bo, void *data)
 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. */
             See previous comment on why. */
          window->flags |= SDL_WINDOW_OPENGL;
          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,.
          /* Reopen FD, create gbm dev, setup display plane, etc,.
             but only when we come here for the first time,
             but only when we come here for the first time,
             and only if it's not a VK window. */
             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))) {
         if ((ret = KMSDRM_LEGACY_CreateSurfaces(_this, window))) {
             goto cleanup;
             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
     /* Add window to the internal list of tracked windows. Note, while it may