Commit 0b7b7721b94835a538217488677a6ebf2dc8a9f6

Manuel Alfayate Corchete 2020-08-23T03:13:50

kmsdrm: remove redundant function, use drm_atomic_setbuffers() for disconnecting planes instead.

diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 29a3478..4b3f6e0 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -119,7 +119,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
     }
 
     /* Add the pageflip to te request list. */
-    drm_atomic_setbuffer(_this, dispdata->display_plane, fb->fb_id);
+    drm_atomic_setbuffer(_this, dispdata->display_plane, fb->fb_id, dispdata->crtc->crtc->crtc_id);
 
     /* Issue the one and only atomic commit where all changes will be requested!.
        We need e a non-blocking atomic commit for triple buffering, because we 
@@ -188,7 +188,7 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
     }
 
     /* Add the pageflip to te request list. */
-    drm_atomic_setbuffer(_this, dispdata->display_plane, fb->fb_id);
+    drm_atomic_setbuffer(_this, dispdata->display_plane, fb->fb_id, dispdata->crtc->crtc->crtc_id);
 
     /* Issue the one and only atomic commit where all changes will be requested!. 
        Blocking for double buffering: won't return until completed. */
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 57c24ad..b8f0d1c 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -466,7 +466,7 @@ free_plane(struct plane **plane) {
 /*   buffers and/or the GBM surface containig them.                               */
 /**********************************************************************************/
 void
-drm_atomic_setbuffer(_THIS, struct plane *plane, uint32_t fb_id)
+drm_atomic_setbuffer(_THIS, struct plane *plane, uint32_t fb_id, uint32_t crtc_id)
 {
     SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
 
@@ -475,7 +475,7 @@ drm_atomic_setbuffer(_THIS, struct plane *plane, uint32_t fb_id)
         dispdata->atomic_req = KMSDRM_drmModeAtomicAlloc();
    
     add_plane_property(dispdata->atomic_req, plane, "FB_ID", fb_id);
-    add_plane_property(dispdata->atomic_req, plane, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
+    add_plane_property(dispdata->atomic_req, plane, "CRTC_ID", crtc_id);
     add_plane_property(dispdata->atomic_req, plane, "SRC_W", dispdata->mode.hdisplay << 16);
     add_plane_property(dispdata->atomic_req, plane, "SRC_H", dispdata->mode.vdisplay << 16);
     add_plane_property(dispdata->atomic_req, plane, "SRC_X", 0);
@@ -492,33 +492,6 @@ drm_atomic_setbuffer(_THIS, struct plane *plane, uint32_t fb_id)
     }
 }
 
-void
-drm_atomic_unsetbuffer(_THIS, struct plane *plane)
-{
-    SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
-
-    /* Do we have a set of changes already in the making? If not, allocate a new one. */
-    if (!dispdata->atomic_req)
-        dispdata->atomic_req = KMSDRM_drmModeAtomicAlloc();
-
-    add_plane_property(dispdata->atomic_req, plane, "FB_ID", 0);
-    add_plane_property(dispdata->atomic_req, plane, "CRTC_ID", 0);
-    add_plane_property(dispdata->atomic_req, plane, "SRC_W", 0);
-    add_plane_property(dispdata->atomic_req, plane, "SRC_H", 0);
-    add_plane_property(dispdata->atomic_req, plane, "SRC_X", 0);
-    add_plane_property(dispdata->atomic_req, plane, "SRC_Y", 0);
-    add_plane_property(dispdata->atomic_req, plane, "CRTC_W", 0);
-    add_plane_property(dispdata->atomic_req, plane, "CRTC_H", 0);
-    add_plane_property(dispdata->atomic_req, plane, "CRTC_X", 0);
-    add_plane_property(dispdata->atomic_req, plane, "CRTC_Y", 0);
-
-    if (dispdata->kms_in_fence_fd != -1) {
-	add_crtc_property(dispdata->atomic_req, dispdata->crtc, "OUT_FENCE_PTR",
-			  VOID2U64(&dispdata->kms_out_fence_fd));
-	add_plane_property(dispdata->atomic_req, plane, "IN_FENCE_FD", dispdata->kms_in_fence_fd);
-    }
-}
-
 int
 drm_atomic_setcursor(KMSDRM_CursorData *curdata, int x, int y)
 {
@@ -849,7 +822,7 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window * window)
        the display plane from the GBM surface buffer it's reading by setting 
        it's CRTC_ID and FB_ID props to 0.
     */
-    drm_atomic_unsetbuffer(_this, dispdata->display_plane);
+    drm_atomic_setbuffer(_this, dispdata->display_plane, 0, 0);
     drm_atomic_commit(_this, SDL_TRUE);
 
     if (windata->bo) {
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h
index fe15b71..9948897 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
@@ -138,7 +138,7 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo);
 
 /* Atomic functions that are used from SDL_kmsdrmopengles.c and SDL_kmsdrmmouse.c */
 void drm_atomic_modeset(_THIS, int mode_index);
-void drm_atomic_setbuffer(_THIS, struct plane *plane, uint32_t fb_id);
+void drm_atomic_setbuffer(_THIS, struct plane *plane, uint32_t fb_id, uint32_t crtc_id);
 void drm_atomic_waitpending(_THIS);
 int drm_atomic_commit(_THIS, SDL_bool blocking);
 int drm_atomic_setcursor(KMSDRM_CursorData *curdata, int x, int y);