[PATCH xserver v3 09/24] present: Add more hooks to internal flip mode API

Roman Gilg subdiff at gmail.com
Tue Mar 13 15:00:42 UTC 2018


Add hooks to query caps, get crtcs, abort vblanks and destroy
a flip.

Signed-off-by: Roman Gilg <subdiff at gmail.com>
---
 present/present.c        | 28 ++++++++++++++++++++++++++++
 present/present_priv.h   | 33 +++++++++++++++++++++++++--------
 present/present_scmd.c   | 38 ++++++++++++++------------------------
 present/present_screen.c |  6 ++++--
 4 files changed, 71 insertions(+), 34 deletions(-)

diff --git a/present/present.c b/present/present.c
index 8ba8647..37cbf07 100644
--- a/present/present.c
+++ b/present/present.c
@@ -38,6 +38,34 @@ msc_is_equal_or_after(uint64_t test, uint64_t reference)
     return (int64_t)(test - reference) >= 0;
 }
 
+uint32_t
+present_query_capabilities(RRCrtcPtr crtc)
+{
+    present_screen_priv_ptr screen_priv;
+
+    if (!crtc)
+        return 0;
+
+    screen_priv = present_screen_priv(crtc->pScreen);
+
+    if (!screen_priv)
+        return 0;
+
+    return screen_priv->query_capabilities(screen_priv);
+}
+
+RRCrtcPtr
+present_get_crtc(WindowPtr window)
+{
+    ScreenPtr                   screen = window->drawable.pScreen;
+    present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
+
+    if (!screen_priv)
+        return NULL;
+
+    return screen_priv->get_crtc(screen_priv, window);
+}
+
 /*
  * Copies the update region from a pixmap to the target drawable
  */
diff --git a/present/present_priv.h b/present/present_priv.h
index 261f0e4..ba607e2 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -85,9 +85,15 @@ struct present_vblank {
     Bool                has_suboptimal; /* whether client can support SuboptimalCopy mode */
 };
 
+typedef struct present_screen_priv present_screen_priv_rec, *present_screen_priv_ptr;
+
 /*
  * Mode hooks
  */
+typedef uint32_t (*present_priv_query_capabilities_ptr)(present_screen_priv_ptr screen_priv);
+typedef RRCrtcPtr (*present_priv_get_crtc_ptr)(present_screen_priv_ptr screen_priv,
+                                               WindowPtr window);
+
 typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
                                             WindowPtr window,
                                             PixmapPtr pixmap,
@@ -125,7 +131,13 @@ typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
 typedef void (*present_priv_flush_ptr)(WindowPtr window);
 typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
 
-typedef struct present_screen_priv {
+typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
+                                              RRCrtcPtr crtc,
+                                              uint64_t event_id,
+                                              uint64_t msc);
+typedef void (*present_priv_flip_destroy_ptr)(ScreenPtr screen);
+
+struct present_screen_priv {
     CloseScreenProcPtr          CloseScreen;
     ConfigNotifyProcPtr         ConfigNotify;
     DestroyWindowProcPtr        DestroyWindow;
@@ -147,6 +159,9 @@ typedef struct present_screen_priv {
     present_screen_info_ptr     info;
 
     /* Mode hooks */
+    present_priv_query_capabilities_ptr query_capabilities;
+    present_priv_get_crtc_ptr           get_crtc;
+
     present_priv_check_flip_ptr         check_flip;
     present_priv_check_flip_window_ptr  check_flip_window;
     present_priv_can_window_flip_ptr    can_window_flip;
@@ -158,7 +173,9 @@ typedef struct present_screen_priv {
     present_priv_flush_ptr              flush;
     present_priv_re_execute_ptr         re_execute;
 
-} present_screen_priv_rec, *present_screen_priv_ptr;
+    present_priv_abort_vblank_ptr       abort_vblank;
+    present_priv_flip_destroy_ptr       flip_destroy;
+};
 
 #define wrap(priv,real,mem,func) {\
     priv->mem = real->mem; \
@@ -224,6 +241,12 @@ msc_is_after(uint64_t test, uint64_t reference)
 /*
  * present.c
  */
+uint32_t
+present_query_capabilities(RRCrtcPtr crtc);
+
+RRCrtcPtr
+present_get_crtc(WindowPtr window);
+
 void
 present_copy_region(DrawablePtr drawable,
                     PixmapPtr pixmap,
@@ -398,12 +421,6 @@ present_restore_screen_pixmap(ScreenPtr screen);
 void
 present_set_abort_flip(ScreenPtr screen);
 
-RRCrtcPtr
-present_get_crtc(WindowPtr window);
-
-uint32_t
-present_query_capabilities(RRCrtcPtr crtc);
-
 Bool
 present_init(void);
 
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 71c8fb9..18ce619 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -158,34 +158,18 @@ present_flip(RRCrtcPtr crtc,
     return (*screen_priv->info->flip) (crtc, event_id, target_msc, pixmap, sync_flip);
 }
 
-RRCrtcPtr
-present_get_crtc(WindowPtr window)
+static RRCrtcPtr
+present_scmd_get_crtc(present_screen_priv_ptr screen_priv, WindowPtr window)
 {
-    ScreenPtr                   screen = window->drawable.pScreen;
-    present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
-
-    if (!screen_priv)
-        return NULL;
-
     if (!screen_priv->info)
         return NULL;
 
     return (*screen_priv->info->get_crtc)(window);
 }
 
-uint32_t
-present_query_capabilities(RRCrtcPtr crtc)
+static uint32_t
+present_scmd_query_capabilities(present_screen_priv_ptr screen_priv)
 {
-    present_screen_priv_ptr     screen_priv;
-
-    if (!crtc)
-        return 0;
-
-    screen_priv = present_screen_priv(crtc->pScreen);
-
-    if (!screen_priv)
-        return 0;
-
     if (!screen_priv->info)
         return 0;
 
@@ -779,8 +763,8 @@ present_scmd_pixmap(WindowPtr window,
     return Success;
 }
 
-void
-present_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
+static void
+present_scmd_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 {
     present_vblank_ptr  vblank;
 
@@ -810,8 +794,8 @@ present_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, uint64
     }
 }
 
-void
-present_flip_destroy(ScreenPtr screen)
+static void
+present_scmd_flip_destroy(ScreenPtr screen)
 {
     present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
 
@@ -826,6 +810,9 @@ present_flip_destroy(ScreenPtr screen)
 void
 present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv)
 {
+    screen_priv->query_capabilities =   &present_scmd_query_capabilities;
+    screen_priv->get_crtc           =   &present_scmd_get_crtc;
+
     screen_priv->check_flip         =   &present_check_flip;
     screen_priv->check_flip_window  =   &present_check_flip_window;
     screen_priv->can_window_flip    =   &present_scmd_can_window_flip;
@@ -836,6 +823,9 @@ present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv)
     screen_priv->queue_vblank       =   &present_queue_vblank;
     screen_priv->flush              =   &present_flush;
     screen_priv->re_execute         =   &present_re_execute;
+
+    screen_priv->abort_vblank       =   &present_scmd_abort_vblank;
+    screen_priv->flip_destroy       =   &present_scmd_flip_destroy;
 }
 
 Bool
diff --git a/present/present_screen.c b/present/present_screen.c
index 454cc53..98f701a 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -58,7 +58,7 @@ present_close_screen(ScreenPtr screen)
 {
     present_screen_priv_ptr screen_priv = present_screen_priv(screen);
 
-    present_flip_destroy(screen);
+    screen_priv->flip_destroy(screen);
 
     unwrap(screen_priv, screen, CloseScreen);
     (*screen->CloseScreen) (screen);
@@ -72,11 +72,13 @@ present_close_screen(ScreenPtr screen)
 static void
 present_free_window_vblank(WindowPtr window)
 {
+    ScreenPtr                   screen = window->drawable.pScreen;
+    present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
     present_window_priv_ptr     window_priv = present_window_priv(window);
     present_vblank_ptr          vblank, tmp;
 
     xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->vblank, window_list) {
-        present_abort_vblank(window->drawable.pScreen, vblank->crtc, vblank->event_id, vblank->target_msc);
+        screen_priv->abort_vblank(window->drawable.pScreen, vblank->crtc, vblank->event_id, vblank->target_msc);
         present_vblank_destroy(vblank);
     }
 }
-- 
2.7.4



More information about the xorg-devel mailing list