[Spice-devel] [PATCH xf86-qxl 13/27] qxl_driver: introduce qxl_crtc, crtc private

Marc-André Lureau marcandre.lureau at gmail.com
Mon Jul 16 08:38:37 PDT 2012


From: Alon Levy <alevy at redhat.com>

Additionally prevents disabling of the primary crtc.
---
 src/qxl.h        |    6 ++++++
 src/qxl_driver.c |   25 ++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/qxl.h b/src/qxl.h
index 6c97f1f..44c9b47 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -266,6 +266,12 @@ typedef struct qxl_output_private {
     int           head;
 } qxl_output_private;
 
+typedef struct qxl_crtc_private {
+    qxl_screen_t *qxl;
+    int           head;
+    xf86OutputPtr output;
+} qxl_crtc_private;
+
 static inline uint64_t
 physical_address (qxl_screen_t *qxl, void *virtual, uint8_t slot_id)
 {
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 280aa70..e1cd097 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -1654,7 +1654,14 @@ static Bool
 qxl_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
                         Rotation rotation, int x, int y)
 {
-    qxl_screen_t *qxl = crtc->driver_private;
+    qxl_crtc_private *crtc_private = crtc->driver_private;
+    qxl_screen_t *qxl = crtc_private->qxl;
+
+    if (crtc == qxl->crtcs[0] && mode == NULL) {
+        /* disallow disabling of monitor 0 mode */
+        ErrorF ("%s: not allowing crtc 0 disablement\n", __func__);
+        return FALSE;
+    }
 
     crtc->mode = *mode;
     crtc->x = x;
@@ -1701,7 +1708,8 @@ qxl_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t *red, uint16_t *green,
 static void
 qxl_crtc_destroy (xf86CrtcPtr crtc)
 {
-    qxl_screen_t *qxl = crtc->driver_private;
+    qxl_crtc_private *crtc_private = crtc->driver_private;
+    qxl_screen_t *qxl = crtc_private->qxl;
 
     xf86DrvMsg(qxl->pScrn->scrnIndex, X_INFO, "%s\n", __func__);
 }
@@ -1709,7 +1717,8 @@ qxl_crtc_destroy (xf86CrtcPtr crtc)
 static Bool
 qxl_crtc_lock (xf86CrtcPtr crtc)
 {
-    qxl_screen_t *qxl = crtc->driver_private;
+    qxl_crtc_private *crtc_private = crtc->driver_private;
+    qxl_screen_t *qxl = crtc_private->qxl;
 
     xf86DrvMsg(qxl->pScrn->scrnIndex, X_INFO, "%s\n", __func__);
     return TRUE;
@@ -1718,7 +1727,8 @@ qxl_crtc_lock (xf86CrtcPtr crtc)
 static void
 qxl_crtc_unlock (xf86CrtcPtr crtc)
 {
-    qxl_screen_t *qxl = crtc->driver_private;
+    qxl_crtc_private *crtc_private = crtc->driver_private;
+    qxl_screen_t *qxl = crtc_private->qxl;
 
     xf86DrvMsg(qxl->pScrn->scrnIndex, X_INFO, "%s\n", __func__);
     qxl_update_monitors_config(qxl);
@@ -1762,6 +1772,7 @@ qxl_init_randr(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
 {
     char name[32];
     qxl_output_private *qxl_output;
+    qxl_crtc_private *qxl_crtc;
     int i;
     xf86OutputPtr output;
     int maxWidth;
@@ -1795,7 +1806,10 @@ qxl_init_randr(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
             xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "failed to create Crtc %d",
                        i);
         }
-        qxl->crtcs[i]->driver_private = qxl;
+        qxl_crtc = xnfcalloc(sizeof(qxl_crtc_private), 1);
+        qxl->crtcs[i]->driver_private = qxl_crtc;
+        qxl_crtc->head = i;
+        qxl_crtc->qxl = qxl;
         snprintf(name, sizeof(name), "qxl-%d", i);
         qxl->outputs[i] = output = xf86OutputCreate(pScrn, &qxl_output_funcs, name);
         if (!output) {
@@ -1808,6 +1822,7 @@ qxl_init_randr(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
         output->driver_private = qxl_output;
         qxl_output->head = i;
         qxl_output->qxl = qxl;
+        qxl_crtc->output = output;
     }
 
     qxl->virtual_x = 1024;
-- 
1.7.10.4



More information about the Spice-devel mailing list