diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-07-21 16:00:26 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-09-01 15:26:46 +1000 |
commit | de0cc5a72deb7c477e368aa4fe9a713788d7ae4c (patch) | |
tree | 57ff497440528209fb6e56d46b689851939b6ee7 /hw | |
parent | 79ee78de9de49d0cab03401662baa476a18e53b8 (diff) |
xfree86: rework driver PreInit API - XInput ABI 12
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.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xfree86/common/xf86Helper.c | 22 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Module.h | 2 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Xinput.c | 10 | ||||
-rw-r--r-- | 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 07f9f0a52..897aaf352 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 51b9b16a3..aed2edcdc 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 bd77fe663..cc8b96878 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -775,11 +775,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 20a3f1bab..6789df6fe 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); |