[xf86-video-qxl (take 2)] Make the Deferred FPS mode available in all cases, not just XSPICE.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jeremy White <jwhite@xxxxxxxxxxxxxxx>
---

This time without the spice-server build requirements of the prior version.


 src/Makefile.am  |    1 +
 src/dfps.c       |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 src/dfps.h       |   17 +---------------
 src/qxl.h        |   11 +++++++----
 src/qxl_driver.c |   23 +++++++---------------
 src/qxl_uxa.c    |    4 ----
 6 files changed, 70 insertions(+), 43 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 8632297..5a48a4d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,6 +56,7 @@ qxl_drv_la_SOURCES =				\
 	qxl_uxa.c			\
 	qxl_ums_mode.c                  \
 	qxl_io.c                        \
+	dfps.c				\
 	compat-api.h 
 endif
 
diff --git a/src/dfps.c b/src/dfps.c
index 6ac29f9..5cc1890 100644
--- a/src/dfps.c
+++ b/src/dfps.c
@@ -44,14 +44,65 @@
 #include "qxl.h"
 #include "dfps.h"
 
-struct dfps_info_t
+typedef struct _dfps_info_t
 {
     RegionRec   updated_region;
 
     PixmapPtr   copy_src;
     Pixel       solid_pixel;
     GCPtr       pgc;
-};
+} dfps_info_t;
+
+static inline dfps_info_t *dfps_get_info (PixmapPtr pixmap)
+{
+#if HAS_DEVPRIVATEKEYREC
+    return dixGetPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
+#else
+    return dixLookupPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
+#endif
+}
+
+static inline void dfps_set_info (PixmapPtr pixmap, dfps_info_t *info)
+{
+    dixSetPrivate(&pixmap->devPrivates, &uxa_pixmap_index, info);
+}
+typedef struct FrameTimer {
+    OsTimerPtr xorg_timer;
+    FrameTimerFunc func;
+    void *opaque; // also stored in xorg_timer, but needed for timer_start
+} Timer;
+
+static CARD32 xorg_timer_callback(
+    OsTimerPtr xorg_timer,
+    CARD32 time,
+    pointer arg)
+{
+    FrameTimer *timer = (FrameTimer*)arg;
+
+    timer->func(timer->opaque);
+    return 0; // if non zero xorg does a TimerSet, we don't want that.
+}
+
+static FrameTimer* timer_add(FrameTimerFunc func, void *opaque)
+{
+    FrameTimer *timer = calloc(sizeof(FrameTimer), 1);
+
+    timer->xorg_timer = TimerSet(NULL, 0, 1e9 /* TODO: infinity? */, xorg_timer_callback, timer);
+    timer->func = func;
+    timer->opaque = opaque;
+    return timer;
+}
+
+static void timer_start(FrameTimer *timer, uint32_t ms)
+{
+    TimerSet(timer->xorg_timer, 0 /* flags */, ms, xorg_timer_callback, timer);
+}
+
+void dfps_start_ticker(qxl_screen_t *qxl)
+{
+    qxl->frames_timer = timer_add(dfps_ticker, qxl);
+    timer_start(qxl->frames_timer, 1000 / qxl->deferred_fps);
+}
 
 void dfps_ticker(void *opaque)
 {
@@ -68,7 +119,7 @@ void dfps_ticker(void *opaque)
         RegionUninit(&info->updated_region);
         RegionInit(&info->updated_region, NULL, 0);
     }
-    qxl->core->timer_start(qxl->frames_timer, 1000 / qxl->deferred_fps);
+    timer_start(qxl->frames_timer, 1000 / qxl->deferred_fps);
 }
 
 
diff --git a/src/dfps.h b/src/dfps.h
index ea38a46..b5ce88c 100644
--- a/src/dfps.h
+++ b/src/dfps.h
@@ -22,21 +22,6 @@
  *
  */
 
-typedef struct dfps_info_t dfps_info_t;
-
+void dfps_start_ticker(qxl_screen_t *qxl);
 void dfps_ticker(void *opaque);
 void dfps_set_uxa_functions(qxl_screen_t *qxl, ScreenPtr screen);
-
-static inline dfps_info_t *dfps_get_info (PixmapPtr pixmap)
-{
-#if HAS_DEVPRIVATEKEYREC
-    return dixGetPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
-#else
-    return dixLookupPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
-#endif
-}
-
-static inline void dfps_set_info (PixmapPtr pixmap, dfps_info_t *info)
-{
-    dixSetPrivate(&pixmap->devPrivates, &uxa_pixmap_index, info);
-}
diff --git a/src/qxl.h b/src/qxl.h
index c26ea8f..2d170a9 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -105,6 +105,7 @@ enum {
     OPTION_ENABLE_FALLBACK_CACHE,
     OPTION_ENABLE_SURFACES,
     OPTION_NUM_HEADS,
+    OPTION_SPICE_DEFERRED_FPS,
 #ifdef XSPICE
     OPTION_SPICE_PORT,
     OPTION_SPICE_TLS_PORT,
@@ -128,7 +129,6 @@ enum {
     OPTION_SPICE_TLS_CIPHERS,
     OPTION_SPICE_CACERT_FILE,
     OPTION_SPICE_DH_FILE,
-    OPTION_SPICE_DEFERRED_FPS,
     OPTION_SPICE_EXIT_ON_DISCONNECT,
     OPTION_SPICE_PLAYBACK_FIFO_DIR,
 #endif
@@ -177,6 +177,9 @@ void qxl_ums_setup_funcs(qxl_screen_t *qxl);
 struct qxl_bo *qxl_ums_surf_mem_alloc(qxl_screen_t *qxl, uint32_t size);
 struct qxl_bo *qxl_ums_lookup_phy_addr(qxl_screen_t *qxl, uint64_t phy_addr);
 
+typedef struct FrameTimer FrameTimer;
+typedef void (*FrameTimerFunc)(void *opaque);
+
 struct _qxl_screen_t
 {
     /* These are the names QXL uses */
@@ -275,12 +278,13 @@ struct _qxl_screen_t
     int				enable_fallback_cache;
     int				enable_surfaces;
     
+    FrameTimer *        frames_timer;
+
 #ifdef XSPICE
     /* XSpice specific */
     struct QXLRom		shadow_rom;    /* Parameter RAM */
     SpiceServer *       spice_server;
     SpiceCoreInterface *core;
-    SpiceTimer *        frames_timer;
 
     QXLWorker *         worker;
     int                 worker_running;
@@ -307,11 +311,10 @@ struct _qxl_screen_t
         uint8_t        *data, *flipped;
     } guest_primary;
 
-    uint32_t           deferred_fps;
-
     char playback_fifo_dir[PATH_MAX];
 #endif /* XSPICE */
 
+    uint32_t deferred_fps;
     struct xorg_list ums_bos;
     struct qxl_bo_funcs *bo_funcs;
 };
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index f1f6592..ae898b6 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -54,10 +54,11 @@
 #include "spiceqxl_inputs.h"
 #include "spiceqxl_io_port.h"
 #include "spiceqxl_spice_server.h"
-#include "dfps.h"
 #include "spiceqxl_audio.h"
 #endif /* XSPICE */
 
+#include "dfps.h"
+
 extern void compat_init_scrn (ScrnInfoPtr);
 
 #define BREAKPOINT()   do { __asm__ __volatile__ ("int $03"); } while (0)
@@ -78,6 +79,8 @@ const OptionInfoRec DefaultOptions[] =
       "EnableSurfaces",           OPTV_BOOLEAN, { 1 }, FALSE },
     { OPTION_NUM_HEADS,
       "NumHeads",                 OPTV_INTEGER, { 4 }, FALSE },
+    { OPTION_SPICE_DEFERRED_FPS,
+      "SpiceDeferredFPS",         OPTV_INTEGER, { 0 }, FALSE},
 #ifdef XSPICE
     { OPTION_SPICE_PORT,
       "SpicePort",                OPTV_INTEGER,   {5900}, FALSE },
@@ -124,8 +127,6 @@ const OptionInfoRec DefaultOptions[] =
       "SpiceCacertFile",          OPTV_STRING,    {0}, FALSE},
     { OPTION_SPICE_DH_FILE,
       "SpiceDhFile",              OPTV_STRING,    {0}, FALSE},
-    { OPTION_SPICE_DEFERRED_FPS,
-      "SpiceDeferredFPS",         OPTV_INTEGER,   {0}, FALSE},
     { OPTION_SPICE_EXIT_ON_DISCONNECT,
       "SpiceExitOnDisconnect",    OPTV_BOOLEAN,   {0}, FALSE},
     { OPTION_SPICE_PLAYBACK_FIFO_DIR,
@@ -543,9 +544,7 @@ qxl_resize_primary_to_virtual (qxl_screen_t *qxl)
     {
 	PixmapPtr root = pScreen->GetScreenPixmap (pScreen);
 
-#ifdef XSPICE
         if (qxl->deferred_fps <= 0)
-#endif
         {
             qxl_surface_t *surf;
 
@@ -606,9 +605,7 @@ qxl_create_screen_resources (ScreenPtr pScreen)
     
     pPixmap = pScreen->GetScreenPixmap (pScreen);
 
-#ifdef XSPICE
     if (qxl->deferred_fps <= 0)
-#endif
     {
         set_screen_pixmap_header (pScreen);
 
@@ -640,11 +637,6 @@ spiceqxl_screen_init (ScrnInfoPtr pScrn, qxl_screen_t *qxl)
 	qxl_add_spice_playback_interface (qxl);
 	qxl->worker->start (qxl->worker);
 	qxl->worker_running = TRUE;
-        if (qxl->deferred_fps)
-        {
-            qxl->frames_timer = qxl->core->timer_add(dfps_ticker, qxl);
-            qxl->core->timer_start(qxl->frames_timer, 1000 / qxl->deferred_fps);
-        }
     }
     qxl->spice_server = qxl->spice_server;
 }
@@ -802,6 +794,9 @@ qxl_screen_init (SCREEN_INIT_ARGS_DECL)
     /* bounds" */
     xf86RandR12SetTransformSupport (pScreen, TRUE);
     
+    if (qxl->deferred_fps)
+        dfps_start_ticker(qxl);
+
     return TRUE;
     
 out:
@@ -854,9 +849,7 @@ qxl_leave_vt (VT_FUNC_ARGS_DECL)
 
     pScrn->EnableDisableFBAccess (XF86_SCRN_ARG (pScrn), FALSE);
 
-#ifdef XSPICE
     if (qxl->deferred_fps <= 0)
-#endif
         qxl->vt_surfaces = qxl_surface_cache_evacuate_all (qxl->surface_cache);
 
     ioport_write (qxl, QXL_IO_RESET, 0);
@@ -977,13 +970,11 @@ qxl_pre_init_common(ScrnInfoPtr pScrn)
     qxl->num_heads =
         get_int_option (qxl->options, OPTION_NUM_HEADS, "QXL_NUM_HEADS");
 
-#ifdef XSPICE
     qxl->deferred_fps = get_int_option(qxl->options, OPTION_SPICE_DEFERRED_FPS, "XSPICE_DEFERRED_FPS");
     if (qxl->deferred_fps > 0)
         xf86DrvMsg(scrnIndex, X_INFO, "Deferred FPS: %d\n", qxl->deferred_fps);
     else
         xf86DrvMsg(scrnIndex, X_INFO, "Deferred Frames: Disabled\n");
-#endif
 
     xf86DrvMsg (scrnIndex, X_INFO, "Offscreen Surfaces: %s\n",
                 qxl->enable_surfaces ? "Enabled" : "Disabled");
diff --git a/src/qxl_uxa.c b/src/qxl_uxa.c
index 1810181..9ac78ee 100644
--- a/src/qxl_uxa.c
+++ b/src/qxl_uxa.c
@@ -34,9 +34,7 @@
 #endif
 
 #include "qxl.h"
-#ifdef XSPICE
 #include "dfps.h"
-#endif
 #include <spice/protocol.h>
 
 #if HAS_DEVPRIVATEKEYREC
@@ -490,11 +488,9 @@ qxl_uxa_init (qxl_screen_t *qxl, ScreenPtr screen)
     qxl->uxa->uxa_major = 1;
     qxl->uxa->uxa_minor = 0;
 
-#ifdef XSPICE
     if (qxl->deferred_fps)
         dfps_set_uxa_functions(qxl, screen);
     else
-#endif
         set_uxa_functions(qxl, screen);
 
     if (!uxa_driver_init (screen, qxl->uxa))
-- 
1.7.10.4


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]