xserver: Branch 'master' - 2 commits

Keith Packard keithp at kemper.freedesktop.org
Thu Apr 3 16:48:36 PDT 2014


 hw/xfree86/common/xf86Events.c     |   28 ++++++++++++++++++++++++++++
 hw/xfree86/common/xf86Init.c       |   16 +++++++++++++++-
 hw/xfree86/common/xf86Module.h     |    2 +-
 hw/xfree86/common/xf86Privstr.h    |    4 ++++
 hw/xfree86/modes/xf86Crtc.h        |    4 ++--
 hw/xfree86/modes/xf86Cursors.c     |   35 ++++++++++++++++++++++-------------
 hw/xfree86/ramdac/IBM.c            |    6 ++++--
 hw/xfree86/ramdac/TI.c             |    3 ++-
 hw/xfree86/ramdac/xf86Cursor.c     |   11 ++++++-----
 hw/xfree86/ramdac/xf86Cursor.h     |    4 ++--
 hw/xfree86/ramdac/xf86CursorPriv.h |    2 +-
 hw/xfree86/ramdac/xf86HWCurs.c     |   15 +++++++++------
 12 files changed, 96 insertions(+), 34 deletions(-)

New commits:
commit 901fbfbbbd71c0d82080957f8ba09eebbc786f2b
Author: Michael Thayer <michael.thayer at oracle.com>
Date:   Mon Mar 31 11:21:42 2014 +0200

    Add a return value to load_cursor_argb() to allow it to report failure
    
    load_cursor_argb() may need to be able to fail and have the server fall back
    to a software cursor in at least the following circumstances.
    1) The hardware can only support some ARGB cursors and this does not just
    depend on cursor size.
    2) Virtual hardware may not wish to pass through a cursor to the host at a
    particular time but may wish to accept the same cursor at another time.
    This patch adds a return value to the API and makes the server do the
    software fall-back on failure.
    
    Signed-off-by: Michael Thayer <michael.thayer at oracle.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index e8c24f2..62ac95d 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -80,7 +80,7 @@ typedef enum {
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(16, 0)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(17, 0)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(21, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(8, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index c127d78..5407deb 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -186,13 +186,13 @@ typedef struct _xf86CrtcFuncs {
     /**
      * Load monochrome image
      */
-    void
+    Bool
      (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
 
     /**
      * Load ARGB image
      */
-    void
+    Bool
      (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
 
     /**
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 2b0db34..10ef6f6 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -211,7 +211,7 @@ set_bit(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
 /*
  * Load a two color cursor into a driver that supports only ARGB cursors
  */
-static void
+static Bool
 xf86_crtc_convert_cursor_to_argb(xf86CrtcPtr crtc, unsigned char *src)
 {
     ScrnInfoPtr scrn = crtc->scrn;
@@ -244,7 +244,7 @@ xf86_crtc_convert_cursor_to_argb(xf86CrtcPtr crtc, unsigned char *src)
                 bits = 0;
             cursor_image[y * cursor_info->MaxWidth + x] = bits;
         }
-    crtc->funcs->load_cursor_argb(crtc, cursor_image);
+    return crtc->funcs->load_cursor_argb(crtc, cursor_image);
 }
 
 /*
@@ -415,7 +415,7 @@ xf86_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
 /*
  * Load a two-color cursor into a crtc, performing rotation as needed
  */
-static void
+static Bool
 xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src)
 {
     ScrnInfoPtr scrn = crtc->scrn;
@@ -450,13 +450,13 @@ xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src)
                     set_bit(cursor_image, cursor_info, x, y, TRUE);
             }
     }
-    crtc->funcs->load_cursor_image(crtc, cursor_image);
+    return crtc->funcs->load_cursor_image(crtc, cursor_image);
 }
 
 /*
  * Load a cursor image into all active CRTCs
  */
-static void
+static Bool
 xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src)
 {
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -466,12 +466,17 @@ xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src)
         xf86CrtcPtr crtc = xf86_config->crtc[c];
 
         if (crtc->enabled) {
-            if (crtc->funcs->load_cursor_image)
-                xf86_crtc_load_cursor_image(crtc, src);
-            else if (crtc->funcs->load_cursor_argb)
-                xf86_crtc_convert_cursor_to_argb(crtc, src);
+            if (crtc->funcs->load_cursor_image) {
+                if (!xf86_crtc_load_cursor_image(crtc, src))
+                    return FALSE;
+            } else if (crtc->funcs->load_cursor_argb) {
+                if (!xf86_crtc_convert_cursor_to_argb(crtc, src))
+                    return FALSE;
+            } else
+                return FALSE;
         }
     }
+    return TRUE;
 }
 
 static Bool
@@ -516,7 +521,7 @@ xf86_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
     return TRUE;
 }
 
-static void
+static Bool
 xf86_crtc_load_cursor_argb(xf86CrtcPtr crtc, CursorPtr cursor)
 {
     ScrnInfoPtr scrn = crtc->scrn;
@@ -544,10 +549,10 @@ xf86_crtc_load_cursor_argb(xf86CrtcPtr crtc, CursorPtr cursor)
             cursor_image[y * image_width + x] = bits;
         }
 
-    crtc->funcs->load_cursor_argb(crtc, cursor_image);
+    return crtc->funcs->load_cursor_argb(crtc, cursor_image);
 }
 
-static void
+static Bool
 xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
 {
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -557,8 +562,10 @@ xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
         xf86CrtcPtr crtc = xf86_config->crtc[c];
 
         if (crtc->enabled)
-            xf86_crtc_load_cursor_argb(crtc, cursor);
+            if (!xf86_crtc_load_cursor_argb(crtc, cursor))
+                return FALSE;
     }
+    return TRUE;
 }
 
 Bool
@@ -608,6 +615,8 @@ xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags)
  * Called when anything on the screen is reconfigured.
  *
  * Reloads cursor images as needed, then adjusts cursor positions
+ * @note We assume that all hardware cursors to be loaded have already been
+ *       found to be usable by the hardware.
  */
 
 void
diff --git a/hw/xfree86/ramdac/IBM.c b/hw/xfree86/ramdac/IBM.c
index bc71623..872d3d4 100644
--- a/hw/xfree86/ramdac/IBM.c
+++ b/hw/xfree86/ramdac/IBM.c
@@ -570,7 +570,7 @@ IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
     (*ramdacPtr->WriteData) (pScrn, bg);
 }
 
-static void
+static Bool
 IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
 {
     RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
@@ -582,9 +582,10 @@ IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
      */
     for (i = 0; i < 1024; i++)
         (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_array + i, 0x00, (*src++));
+    return TRUE;
 }
 
-static void
+static Bool
 IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
 {
     RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
@@ -596,6 +597,7 @@ IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
      */
     for (i = 0; i < 1024; i++)
         (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++));
+    return TRUE;
 }
 
 static Bool
diff --git a/hw/xfree86/ramdac/TI.c b/hw/xfree86/ramdac/TI.c
index 393b774..7d4e0d7 100644
--- a/hw/xfree86/ramdac/TI.c
+++ b/hw/xfree86/ramdac/TI.c
@@ -642,7 +642,7 @@ TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
     (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0, (fg & 0x000000ff));
 }
 
-static void
+static Bool
 TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
 {
     RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
@@ -657,6 +657,7 @@ TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
         /* NOT_DONE: might need a delay here */
         (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++));
     }
+    return TRUE;
 }
 
 static Bool
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 860704e..fac6822 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -352,12 +352,13 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
                 (*ScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen,
                                                        NullCursor, x, y);
 
-            xf86SetCursor(pScreen, cursor, x, y);
-            ScreenPriv->SWCursor = FALSE;
-            ScreenPriv->isUp = TRUE;
+            if (xf86SetCursor(pScreen, cursor, x, y)) {
+                ScreenPriv->SWCursor = FALSE;
+                ScreenPriv->isUp = TRUE;
 
-            miPointerSetWaitForUpdate(pScreen, !infoPtr->pScrn->silkenMouse);
-            return;
+                miPointerSetWaitForUpdate(pScreen, !infoPtr->pScrn->silkenMouse);
+                return;
+            }
         }
 
         miPointerSetWaitForUpdate(pScreen, TRUE);
diff --git a/hw/xfree86/ramdac/xf86Cursor.h b/hw/xfree86/ramdac/xf86Cursor.h
index 5658e7b..1ecbdcd 100644
--- a/hw/xfree86/ramdac/xf86Cursor.h
+++ b/hw/xfree86/ramdac/xf86Cursor.h
@@ -12,7 +12,7 @@ typedef struct _xf86CursorInfoRec {
     int MaxHeight;
     void (*SetCursorColors) (ScrnInfoPtr pScrn, int bg, int fg);
     void (*SetCursorPosition) (ScrnInfoPtr pScrn, int x, int y);
-    void (*LoadCursorImage) (ScrnInfoPtr pScrn, unsigned char *bits);
+    Bool (*LoadCursorImage) (ScrnInfoPtr pScrn, unsigned char *bits);
     void (*HideCursor) (ScrnInfoPtr pScrn);
     void (*ShowCursor) (ScrnInfoPtr pScrn);
     unsigned char *(*RealizeCursor) (struct _xf86CursorInfoRec *, CursorPtr);
@@ -20,7 +20,7 @@ typedef struct _xf86CursorInfoRec {
 
 #ifdef ARGB_CURSOR
     Bool (*UseHWCursorARGB) (ScreenPtr, CursorPtr);
-    void (*LoadCursorARGB) (ScrnInfoPtr, CursorPtr);
+    Bool (*LoadCursorARGB) (ScrnInfoPtr, CursorPtr);
 #endif
 
 } xf86CursorInfoRec, *xf86CursorInfoPtr;
diff --git a/hw/xfree86/ramdac/xf86CursorPriv.h b/hw/xfree86/ramdac/xf86CursorPriv.h
index a5d2aab..f34c1c7 100644
--- a/hw/xfree86/ramdac/xf86CursorPriv.h
+++ b/hw/xfree86/ramdac/xf86CursorPriv.h
@@ -37,7 +37,7 @@ typedef struct {
     void *transparentData;
 } xf86CursorScreenRec, *xf86CursorScreenPtr;
 
-void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y);
+Bool xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y);
 void xf86SetTransparentCursor(ScreenPtr pScreen);
 void xf86MoveCursor(ScreenPtr pScreen, int x, int y);
 void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed);
diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index 3b69698..0b5caa2 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -119,7 +119,7 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
     return TRUE;
 }
 
-void
+Bool
 xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
 {
     xf86CursorScreenPtr ScreenPriv =
@@ -130,7 +130,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
 
     if (pCurs == NullCursor) {
         (*infoPtr->HideCursor) (infoPtr->pScrn);
-        return;
+        return TRUE;
     }
 
     bits =
@@ -152,18 +152,21 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
         (*infoPtr->HideCursor) (infoPtr->pScrn);
 
 #ifdef ARGB_CURSOR
-    if (pCurs->bits->argb && infoPtr->LoadCursorARGB)
-        (*infoPtr->LoadCursorARGB) (infoPtr->pScrn, pCurs);
-    else
+    if (pCurs->bits->argb && infoPtr->LoadCursorARGB) {
+        if (!(*infoPtr->LoadCursorARGB) (infoPtr->pScrn, pCurs))
+            return FALSE;
+    } else
 #endif
     if (bits)
-        (*infoPtr->LoadCursorImage) (infoPtr->pScrn, bits);
+        if (!(*infoPtr->LoadCursorImage) (infoPtr->pScrn, bits))
+            return FALSE;
 
     xf86RecolorCursor(pScreen, pCurs, 1);
 
     (*infoPtr->SetCursorPosition) (infoPtr->pScrn, x, y);
 
     (*infoPtr->ShowCursor) (infoPtr->pScrn);
+    return TRUE;
 }
 
 void
commit 62ab4102260fd3342a0e5ae3a4f77b430af64f4e
Author: Michael Thayer <michael.thayer at oracle.com>
Date:   Mon Mar 31 11:19:16 2014 +0200

    Set a flag property on the root window to say if the X server VT is active
    
    An X11 client may need to know whether the X server virtual terminal is
    currently the active one.  This change adds a root window property which
    provides that information.  Intended interface user: the VirtualBox Guest
    Additions.
    
    Signed-off-by: Michael Thayer <michael.thayer at oracle.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 06af739..35a673d 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -56,6 +56,7 @@
 #include <X11/X.h>
 #include <X11/Xpoll.h>
 #include <X11/Xproto.h>
+#include <X11/Xatom.h>
 #include "misc.h"
 #include "compiler.h"
 #include "xf86.h"
@@ -431,6 +432,29 @@ xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo)
     pInfo->flags &= ~XI86_DEVICE_DISABLED;
 }
 
+/*
+ * xf86UpdateHasVTProperty --
+ *    Update a flag property on the root window to say whether the server VT
+ *    is currently the active one as some clients need to know this.
+ */
+static void
+xf86UpdateHasVTProperty(Bool hasVT)
+{
+    Atom property_name;
+    int32_t value = hasVT ? 1 : 0;
+    int i;
+
+    property_name = MakeAtom(HAS_VT_ATOM_NAME, sizeof(HAS_VT_ATOM_NAME) - 1,
+                             FALSE);
+    if (property_name == BAD_RESOURCE)
+        FatalError("Failed to retrieve \"HAS_VT\" atom\n");
+    for (i = 0; i < xf86NumScreens; i++) {
+        ChangeWindowProperty(xf86ScrnToScreen(xf86Screens[i])->root,
+                             property_name, XA_INTEGER, 32,
+                             PropModeReplace, 1, &value, TRUE);
+    }
+}
+
 void
 xf86VTLeave(void)
 {
@@ -490,6 +514,8 @@ xf86VTLeave(void)
     if (xorgHWAccess)
         xf86DisableIO();
 
+    xf86UpdateHasVTProperty(FALSE);
+
     return;
 
 switch_failed:
@@ -574,6 +600,8 @@ xf86VTEnter(void)
     xf86platformVTProbe();
 #endif
 
+    xf86UpdateHasVTProperty(TRUE);
+
     OsReleaseSIGIO();
 }
 
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 4579ff5..5a45004 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -387,6 +387,11 @@ InstallSignalHandlers(void)
     }
 }
 
+/* The memory storing the initial value of the XFree86_has_VT root window
+ * property.  This has to remain available until server start-up, so we just
+ * use a global. */
+static CARD32 HasVTValue = 1;
+
 /*
  * InitOutput --
  *	Initialize screenInfo for all actually accessible framebuffers.
@@ -731,7 +736,9 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
         if (xf86Info.vtno >= 0) {
 #define VT_ATOM_NAME         "XFree86_VT"
             Atom VTAtom = -1;
+            Atom HasVTAtom = -1;
             CARD32 *VT = NULL;
+            CARD32 *HasVT = &HasVTValue;
             int ret;
 
             /* This memory needs to stay available until the screen has been
@@ -744,6 +751,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
             *VT = xf86Info.vtno;
 
             VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
+            HasVTAtom = MakeAtom(HAS_VT_ATOM_NAME,
+                                 sizeof(HAS_VT_ATOM_NAME) - 1, TRUE);
 
             for (i = 0, ret = Success; i < xf86NumScreens && ret == Success;
                  i++) {
@@ -751,9 +760,14 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
                     xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
                                                    VTAtom, XA_INTEGER, 32, 1,
                                                    VT);
+                if (ret == Success)
+                    ret = xf86RegisterRootWindowProperty(xf86Screens[i]
+                                                             ->scrnIndex,
+                                                         HasVTAtom, XA_INTEGER,
+                                                         32, 1, HasVT);
                 if (ret != Success)
                     xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
-                               "Failed to register VT property\n");
+                               "Failed to register VT properties\n");
             }
         }
 
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index f7a9c9f..410ef17 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -163,4 +163,8 @@ typedef struct _RootWinProp {
 #define WSCONS		  32
 #endif
 
+/* Root window property to tell clients whether our VT is currently active.
+ * Name chosen to match the "XFree86_VT" property. */
+#define HAS_VT_ATOM_NAME "XFree86_has_VT"
+
 #endif                          /* _XF86PRIVSTR_H */


More information about the xorg-commit mailing list