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>
This commit is contained in:
Peter Hutterer 2010-07-21 16:00:26 +10:00
parent 79ee78de9d
commit de0cc5a72d
4 changed files with 32 additions and 9 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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)) {

View File

@ -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);