[Spice-devel] [PATCH xf86-video-qxl 3/3] Add support for server managed fds

Hans de Goede hdegoede at redhat.com
Thu Apr 24 02:27:04 PDT 2014


Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/qxl_driver.c |  4 ++++
 src/qxl_kms.c    | 32 +++++++++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index c81b243..b9aa0e9 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -1432,6 +1432,10 @@ qxl_driver_func(ScrnInfoPtr pScrn, xorgDriverFuncOp op, void *data)
         *hw_flags = HW_IO | HW_MMIO;
 #endif
         return TRUE;
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,902,0)
+    case SUPPORTS_SERVER_FDS:
+        return TRUE;
+#endif
     default:
         return FALSE;
     }
diff --git a/src/qxl_kms.c b/src/qxl_kms.c
index d6dfcee..c31c62d 100644
--- a/src/qxl_kms.c
+++ b/src/qxl_kms.c
@@ -46,6 +46,17 @@ static Bool qxl_open_drm_master(ScrnInfoPtr pScrn)
     drmSetVersion sv;
     int err;
 
+#if defined(ODEV_ATTRIB_FD)
+    if (qxl->platform_dev) {
+        qxl->drm_fd = xf86_get_platform_device_int_attrib(qxl->platform_dev,
+                                                          ODEV_ATTRIB_FD, -1);
+        if (qxl->drm_fd != -1) {
+            qxl->drmmode.fd = qxl->drm_fd;
+            return TRUE;
+        }
+    }
+#endif
+
 #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,9,99,901,0)
     XNFasprintf(&busid, "pci:%04x:%02x:%02x.%d",
                 dev->domain, dev->bus, dev->dev, dev->func);
@@ -218,11 +229,17 @@ qxl_enter_vt_kms (VT_FUNC_ARGS_DECL)
     qxl_screen_t *qxl = pScrn->driverPrivate;
     int ret;
 
-    ret = drmSetMaster(qxl->drm_fd);
-    if (ret) {
-	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		   "drmSetMaster failed: %s\n",
-		   strerror(errno));
+#ifdef XF86_PDEV_SERVER_FD
+    if (!(qxl->platform_dev &&
+            (qxl->platform_dev->flags & XF86_PDEV_SERVER_FD)))
+#endif
+    {
+        ret = drmSetMaster(qxl->drm_fd);
+        if (ret) {
+            xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                       "drmSetMaster failed: %s\n",
+                       strerror(errno));
+        }
     }
 
     if (!xf86SetDesiredModes(pScrn))
@@ -241,6 +258,11 @@ qxl_leave_vt_kms (VT_FUNC_ARGS_DECL)
     xf86_hide_cursors (pScrn);
     //    pScrn->EnableDisableFBAccess (XF86_SCRN_ARG (pScrn), FALSE);
 
+#ifdef XF86_PDEV_SERVER_FD
+    if (qxl->platform_dev && (qxl->platform_dev->flags & XF86_PDEV_SERVER_FD))
+        return;
+#endif
+
     ret = drmDropMaster(qxl->drm_fd);
     if (ret) {
 	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-- 
1.9.0



More information about the Spice-devel mailing list