The main change introduced in this patch is the removal of the
back-and-forth between DDX and the driver.
The DDX now allocates the InputInfoRec and fills it with default values. The
DDX processes common options (and module-specific default options, if
appropriate) before passing the initialised struct to the driver.

The driver may do module-specific initializations and return Success or an
error code in the case of a failure.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 hw/xfree86/common/xf86Helper.c |   22 +++++++++++++++++++++-
 hw/xfree86/common/xf86Module.h |    2 +-
 hw/xfree86/common/xf86Xinput.c |   10 ++++++----
 hw/xfree86/common/xf86Xinput.h |    7 ++++---
 4 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 07f9f0a..897aaf3 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -276,7 +276,7 @@ xf86AllocateScrnInfoPrivateIndex(void)
 
 /* Allocate a new InputInfoRec and append it to the tail of xf86InputDevs. */
 InputInfoPtr
-xf86AllocateInput(InputDriverPtr drv, int flags)
+xf86AllocateInput(InputDriverPtr drv, IDevPtr idev)
 {
     InputInfoPtr new, *prev = NULL;
 
@@ -293,6 +293,26 @@ xf86AllocateInput(InputDriverPtr drv, int flags)
     *prev = new;
     new->next = NULL;
 
+    new->fd = -1;
+    new->name = idev->identifier;
+    new->type_name = "UNKNOWN";
+    new->device_control = NULL;
+    new->read_input = NULL;
+    new->history_size = 0;
+    new->control_proc = NULL;
+    new->close_proc = NULL;
+    new->switch_mode = NULL;
+    new->conversion_proc = NULL;
+    new->reverse_conversion_proc = NULL;
+    new->dev = NULL;
+    new->private_flags = 0;
+    new->always_core_feedback = NULL;
+    new->private = NULL;
+    new->conf_idev = idev;
+
+    xf86CollectInputOptions(new, (const char**)drv->default_options, NULL);
+    xf86ProcessCommonOptions(new, new->options);
+
     return new;
 }
 
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 51b9b16..aed2edc 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION      SET_ABI_VERSION(0, 4)
 #define ABI_VIDEODRV_VERSION   SET_ABI_VERSION(8, 0)
-#define ABI_XINPUT_VERSION     SET_ABI_VERSION(11, 0)
+#define ABI_XINPUT_VERSION     SET_ABI_VERSION(12, 0)
 #define ABI_EXTENSION_VERSION  SET_ABI_VERSION(4, 0)
 #define ABI_FONT_VERSION       SET_ABI_VERSION(0, 6)
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index dc9be2b..7b7f70c 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -779,11 +779,13 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL 
enable)
         goto unwind;
     }
 
-    pInfo = drv->PreInit(drv, idev, 0);
+    if (!(pInfo = xf86AllocateInput(drv, idev)))
+       goto unwind;
 
-    if (!pInfo) {
-        xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", 
idev->identifier);
-        rval = BadMatch;
+    rval = drv->PreInit(drv, pInfo, 0);
+
+    if (rval != Success) {
+        xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, 
idev->identifier);
         goto unwind;
     }
     else if (!(pInfo->flags & XI86_CONFIGURED)) {
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 20a3f1b..6789df6 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -97,13 +97,14 @@ typedef struct _InputDriverRec {
     int                            driverVersion;
     char *                 driverName;
     void                   (*Identify)(int flags);
-    struct _LocalDeviceRec *(*PreInit)(struct _InputDriverRec *drv,
-                                      IDevPtr dev, int flags);
+    int                            (*PreInit)(struct _InputDriverRec *drv,
+                                      struct _LocalDeviceRec* pInfo, int 
flags);
     void                   (*UnInit)(struct _InputDriverRec *drv,
                                      struct _LocalDeviceRec *pInfo,
                                      int flags);
     pointer                module;
     int                            refCount;
+    char **                default_options;
 } InputDriverRec, *InputDriverPtr;
 
 /* This is to input devices what the ScrnInfoRec is to screens. */
@@ -202,7 +203,7 @@ int xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, 
BOOL is_auto);
 /* xf86Helper.c */
 extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer 
module, int flags);
 extern _X_EXPORT void xf86DeleteInputDriver(int drvIndex);
-extern _X_EXPORT InputInfoPtr xf86AllocateInput(InputDriverPtr drv, int flags);
+extern _X_INTERNAL InputInfoPtr xf86AllocateInput(InputDriverPtr drv, IDevPtr 
idev);
 extern _X_EXPORT InputDriverPtr xf86LookupInputDriver(const char *name);
 extern _X_EXPORT InputInfoPtr xf86LookupInput(const char *name);
 extern _X_EXPORT void xf86DeleteInput(InputInfoPtr pInp, int flags);
-- 
1.7.2

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to