xserver: Branch 'master' - 4 commits

Peter Hutterer whot at kemper.freedesktop.org
Sun Nov 23 19:51:38 PST 2008


 dix/devices.c                  |   31 ++------
 dix/main.c                     |    3 
 hw/xfree86/common/xf86DGA.c    |    4 -
 hw/xfree86/common/xf86Init.c   |   34 ---------
 hw/xfree86/common/xf86Xinput.c |  143 ++++++++++++++++++++++-------------------
 hw/xfree86/common/xf86Xinput.h |    1 
 include/input.h                |    2 
 7 files changed, 95 insertions(+), 123 deletions(-)

New commits:
commit 554592cd70543f87cd8bee5ff47cc8281511e041
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Mon Nov 24 11:50:38 2008 +1000

    DGA: silence compiler warning.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>

diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 83bc411..a06f285 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -1048,7 +1048,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
     de->u.event.state = keyc->state | pointer->button->state;
 
     de->u.u.type = (IEventBase - 1) + coreEquiv; /* change to XI event */
-    UpdateDeviceState(keybd, de, 1);
+    UpdateDeviceState(keybd, (xEvent*)de, 1);
     de->u.u.type = *XDGAEventBase + coreEquiv; /* change back */
 
     /*
@@ -1095,7 +1095,7 @@ DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse)
     de->u.event.state = butc->state | GetPairedDevice(mouse)->key->state;
 
     de->u.u.type = (IEventBase - 1) + coreEquiv; /* change to XI event */
-    UpdateDeviceState(mouse, de, 1);
+    UpdateDeviceState(mouse, (xEvent*)de, 1);
     de->u.u.type = *XDGAEventBase + coreEquiv; /* change back */
 
     /*
commit 0dbcbd35f63db14734199a0beb2a91b6937f3838
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Fri Nov 21 12:02:02 2008 +1000

    xfree86: Split the working code of NIDR into new xf86NewInputDevice.
    
    The xfree86 server previously hat NewInputDeviceRequest and InitInput, and
    both basically did the same thing. Reduce NIDR to parameter checking and use
    xf86NewInputDevice from both InitInput and NIDR to actually create the device.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 86f25de..c35cb2c 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1242,8 +1242,7 @@ InitInput(argc, argv)
      char	  **argv;
 {
     IDevPtr* pDev;
-    InputDriverPtr pDrv;
-    InputInfoPtr pInfo;
+    DeviceIntPtr dev;
 
     xf86Info.vtRequestsPending = FALSE;
 
@@ -1254,36 +1253,7 @@ InitInput(argc, argv)
             strcpy((*pDev)->driver, "kbd");
         }
 
-        if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) {
-            xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver);
-            /* XXX For now, just continue. */
-            continue;
-        }
-        if (!pDrv->PreInit) {
-            xf86MsgVerb(X_WARNING, 0,
-                    "Input driver `%s' has no PreInit function (ignoring)\n",
-                    pDrv->driverName);
-            continue;
-        }
-        pInfo = pDrv->PreInit(pDrv, *pDev, 0);
-        if (!pInfo) {
-            xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
-                    (*pDev)->identifier);
-            continue;
-        } else if (!(pInfo->flags & XI86_CONFIGURED)) {
-            xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
-                    (*pDev)->identifier);
-            xf86DeleteInput(pInfo, 0);
-            continue;
-        }
-    }
-
-    /* Initialise all input devices. */
-    pInfo = xf86InputDevs;
-    while (pInfo) {
-        xf86Msg(X_INFO, "evaluating device (%s)\n", pInfo->name);
-	xf86ActivateDevice(pInfo);
-	pInfo = pInfo->next;
+        xf86NewInputDevice(*pDev, &dev, TRUE);
     }
 
     mieqInit();
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 7d90891..2cb41e5 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -467,14 +467,87 @@ AddOtherInputDevices()
 {
 }
 
+/**
+ * Create a new input device, activate and enable it.
+ *
+ * @param idev The device, already set up with identifier, driver, and the
+ * options.
+ * @param pdev Pointer to the new device, if Success was reported.
+ * @param enable Enable the device after activating it.
+ *
+ * @return Success or an error code
+ */
+_X_INTERNAL int
+xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
+{
+    InputDriverPtr drv = NULL;
+    InputInfoPtr pInfo = NULL;
+    DeviceIntPtr dev = NULL;
+    int rval;
+
+    /* Memory leak for every attached device if we don't
+     * test if the module is already loaded first */
+    drv = xf86LookupInputDriver(idev->driver);
+    if (!drv)
+        if (xf86LoadOneModule(idev->driver, NULL))
+            drv = xf86LookupInputDriver(idev->driver);
+    if (!drv) {
+        xf86Msg(X_ERROR, "No input driver matching `%s'\n", idev->driver);
+        rval = BadName;
+        goto unwind;
+    }
+
+    if (!drv->PreInit) {
+        xf86Msg(X_ERROR,
+                "Input driver `%s' has no PreInit function (ignoring)\n",
+                drv->driverName);
+        rval = BadImplementation;
+        goto unwind;
+    }
+
+    pInfo = drv->PreInit(drv, idev, 0);
+
+    if (!pInfo) {
+        xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", idev->identifier);
+        rval = BadMatch;
+        goto unwind;
+    }
+    else if (!(pInfo->flags & XI86_CONFIGURED)) {
+        xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
+                idev->identifier);
+        rval = BadMatch;
+        goto unwind;
+    }
+
+    xf86ActivateDevice(pInfo);
+
+    dev = pInfo->dev;
+    ActivateDevice(dev);
+    /* Enable it if it's properly initialised and we're currently in the VT */
+    if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
+        EnableDevice(dev);
+
+    /* send enter/leave event, update sprite window */
+    CheckMotion(NULL, dev);
+
+    *pdev = dev;
+    return Success;
+
+unwind:
+    if(pInfo) {
+        if(drv->UnInit)
+            drv->UnInit(drv, pInfo, 0);
+        else
+            xf86DeleteInput(pInfo, 0);
+    }
+    return rval;
+}
+
 _X_EXPORT int
 NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
 {
     IDevRec *idev = NULL;
-    InputDriverPtr drv = NULL;
-    InputInfoPtr pInfo = NULL;
     InputOption *option = NULL;
-    DeviceIntPtr dev = NULL;
     int rval = Success;
     int is_auto = 0;
 
@@ -488,18 +561,6 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
                 rval = BadRequest;
                 goto unwind;
             }
-            /* Memory leak for every attached device if we don't
-             * test if the module is already loaded first */
-            drv = xf86LookupInputDriver(option->value);
-            if (!drv)
-                if (xf86LoadOneModule(option->value, NULL))
-                    drv = xf86LookupInputDriver(option->value);
-            if (!drv) {
-                xf86Msg(X_ERROR, "No input driver matching `%s'\n",
-                        option->value);
-                rval = BadName;
-                goto unwind;
-            }
             idev->driver = xstrdup(option->value);
             if (!idev->driver) {
                 rval = BadAlloc;
@@ -537,24 +598,11 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
         goto unwind;
     }
 
-    if (!drv) {
-        xf86Msg(X_ERROR, "No input driver specified (ignoring)\n");
-        return BadMatch;
-    }
-
     if (!idev->identifier) {
         xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
         return BadMatch;
     }
 
-    if (!drv->PreInit) {
-        xf86Msg(X_ERROR,
-                "Input driver `%s' has no PreInit function (ignoring)\n",
-                drv->driverName);
-        rval = BadImplementation;
-        goto unwind;
-    }
-
     for (option = options; option; option = option->next) {
         /* Steal option key/value strings from the provided list.
          * We need those strings, the InputOption list doesn't. */
@@ -564,43 +612,12 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
         option->value = NULL;
     }
 
-    pInfo = drv->PreInit(drv, idev, 0);
-
-    if (!pInfo) {
-        xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", idev->identifier);
-        rval = BadMatch;
-        goto unwind;
-    }
-    else if (!(pInfo->flags & XI86_CONFIGURED)) {
-        xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
-                idev->identifier);
-        rval = BadMatch;
-        goto unwind;
-    }
-
-    xf86ActivateDevice(pInfo);
-
-    dev = pInfo->dev;
-    ActivateDevice(dev);
-    /* Enable it if it's properly initialised, we're currently in the VT, and
-     * either it's a manual request, or we're automatically enabling devices. */
-    if (dev->inited && dev->startup && xf86Screens[0]->vtSema &&
-        (!is_auto || xf86Info.autoEnableDevices))
-        EnableDevice(dev);
-
-    /* send enter/leave event, update sprite window */
-    CheckMotion(NULL, dev);
-
-    *pdev = dev;
-    return Success;
+    rval = xf86NewInputDevice(idev, pdev,
+                (!is_auto || (is_auto && xf86Info.autoEnableDevices)));
+    if (rval == Success)
+        return Success;
 
 unwind:
-    if(pInfo) {
-        if(drv->UnInit)
-            drv->UnInit(drv, pInfo, 0);
-        else
-            xf86DeleteInput(pInfo, 0);
-    }
     if(idev->driver)
         xfree(idev->driver);
     if(idev->identifier)
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 7617a3e..28a3315 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -185,6 +185,7 @@ void xf86AddEnabledDevice(InputInfoPtr pInfo);
 void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
 void xf86DisableDevice(DeviceIntPtr dev, Bool panic);
 void xf86EnableDevice(DeviceIntPtr dev);
+int xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL is_auto);
 
 /* xf86Helper.c */
 void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
commit e078901a4eca02bd3e7a80d9462dafbca939a187
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Fri Nov 21 12:39:55 2008 +1000

    dix: Enable core devices in InitCoreDevices already.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/devices.c b/dix/devices.c
index b179ce3..33b723a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -593,8 +593,6 @@ CorePointerProc(DeviceIntPtr pDev, int what)
  * Both devices are not tied to physical devices, but guarantee that there is
  * always a keyboard and a pointer present and keep the protocol semantics.
  *
- * The devices are activated but not enabled.
- *
  * Note that the server MUST have two core devices at all times, even if there
  * is no physical device connected.
  */
@@ -605,6 +603,12 @@ InitCoreDevices(void)
                           &inputInfo.pointer,
                           &inputInfo.keyboard) != Success)
         FatalError("Failed to allocate core devices");
+
+    if (inputInfo.pointer->inited && inputInfo.pointer->startup)
+        EnableDevice(inputInfo.pointer);
+    if (inputInfo.keyboard->inited && inputInfo.keyboard->startup)
+        EnableDevice(inputInfo.keyboard);
+
 }
 
 /**
@@ -619,7 +623,7 @@ InitCoreDevices(void)
  *
  * @return Success or error code on failure.
  */
-int
+void
 InitAndStartDevices()
 {
     DeviceIntPtr dev, next;
@@ -630,31 +634,14 @@ InitAndStartDevices()
             ActivateDevice(dev);
     }
 
-    if (!inputInfo.keyboard) { /* In theory, this cannot happen */
-	ErrorF("[dix] No core keyboard\n");
-	return BadImplementation;
-    }
-    if (!inputInfo.pointer) { /* In theory, this cannot happen */
-	ErrorF("[dix] No core pointer\n");
-	return BadImplementation;
-    }
-
-    /* Now enable all devices */
-    if (inputInfo.pointer->inited && inputInfo.pointer->startup)
-        EnableDevice(inputInfo.pointer);
-    if (inputInfo.keyboard->inited && inputInfo.keyboard->startup)
-        EnableDevice(inputInfo.keyboard);
-
     /* enable real devices */
     for (dev = inputInfo.off_devices; dev; dev = next)
     {
         DebugF("(dix) enabling device %d\n", dev->id);
 	next = dev->next;
 	if (dev->inited && dev->startup)
-	    (void)EnableDevice(dev);
+	    EnableDevice(dev);
     }
-
-    return Success;
 }
 
 /**
diff --git a/dix/main.c b/dix/main.c
index 7bd91e0..ee2e10d 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -361,8 +361,7 @@ int main(int argc, char *argv[], char *envp[])
 
         InitCoreDevices();
 	InitInput(argc, argv);
-	if (InitAndStartDevices() != Success)
-	    FatalError("failed to initialize core devices");
+	InitAndStartDevices();
 
 	dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
 
diff --git a/include/input.h b/include/input.h
index a41affd..30457f3 100644
--- a/include/input.h
+++ b/include/input.h
@@ -239,7 +239,7 @@ extern Bool ActivateDevice(
 extern Bool DisableDevice(
     DeviceIntPtr /*device*/);
 
-extern int InitAndStartDevices(void);
+extern void InitAndStartDevices(void);
 
 extern void CloseDownDevices(void);
 
commit d939f2482e71ad20bac28b7aa4b2e8c8196e9d65
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Fri Nov 21 12:21:45 2008 +1000

    dix: fix false comment.
    
    VCP and VCK are always present, this comment is a leftover from earlier MPX
    days.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>

diff --git a/dix/devices.c b/dix/devices.c
index 904c404..b179ce3 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -592,8 +592,6 @@ CorePointerProc(DeviceIntPtr pDev, int what)
  * Initialise the two core devices, VCP and VCK (see events.c).
  * Both devices are not tied to physical devices, but guarantee that there is
  * always a keyboard and a pointer present and keep the protocol semantics.
- * Both core devices are NOT part of the device list and act only as a
- * fallback if no physical device is available.
  *
  * The devices are activated but not enabled.
  *


More information about the xorg-commit mailing list