xfree86: remove IDevRec, replace with InputInfoRec.

This struct is superfluous, maintaining the same info as the InputInfoRec
(with the exception of the driver name).

This is a rather large commit with the majority of changes being a rename
from the fields of the IDevRec (idev, commonOptions) to the InputInfoRec
(pInfo, options).

The actual changes affect the initialization process of the input device:
In NewInputDeviceRequest, the InputInfoRec is now always allocated and just
added to the internal list in xf86NewInputDevice() if the init process
succeeded.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
This commit is contained in:
Peter Hutterer 2010-09-02 14:30:11 +10:00
parent c5da32a610
commit b8d9c5ff00
6 changed files with 113 additions and 150 deletions

View File

@ -135,7 +135,7 @@ static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor); static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
Bool active); Bool active);
static Bool configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
MessageType from); MessageType from);
static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display); static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
static Bool addDefaultModes(MonPtr monitorp); static Bool addDefaultModes(MonPtr monitorp);
@ -444,8 +444,8 @@ xf86InputDriverlistFromConfig(void)
{ {
int count = 0; int count = 0;
char **modulearray; char **modulearray;
IDevPtr* idp; InputInfoPtr *idp;
/* /*
* make sure the config file has been parsed and that we have a * make sure the config file has been parsed and that we have a
* ModulePath set; if no ModulePath was given, use the default * ModulePath set; if no ModulePath was given, use the default
@ -1110,12 +1110,12 @@ Bool xf86DRI2Enabled(void)
static Bool static Bool
checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
{ {
IDevPtr corePointer = NULL, coreKeyboard = NULL; InputInfoPtr corePointer = NULL, coreKeyboard = NULL;
Bool foundPointer = FALSE, foundKeyboard = FALSE; Bool foundPointer = FALSE, foundKeyboard = FALSE;
const char *pointerMsg = NULL, *keyboardMsg = NULL; const char *pointerMsg = NULL, *keyboardMsg = NULL;
IDevPtr *devs, /* iterator */ InputInfoPtr *devs, /* iterator */
indp; indp;
IDevRec Pointer, Keyboard; InputInfoRec Pointer, Keyboard;
XF86ConfInputPtr confInput; XF86ConfInputPtr confInput;
XF86ConfInputRec defPtr, defKbd; XF86ConfInputRec defPtr, defKbd;
int count = 0; int count = 0;
@ -1131,26 +1131,26 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
*/ */
for (devs = servlayoutp->inputs; devs && *devs; devs++) { for (devs = servlayoutp->inputs; devs && *devs; devs++) {
indp = *devs; indp = *devs;
if (indp->commonOptions && if (indp->options &&
xf86CheckBoolOption(indp->commonOptions, "CorePointer", FALSE)) { xf86CheckBoolOption(indp->options, "CorePointer", FALSE)) {
if (!corePointer) { if (!corePointer) {
corePointer = indp; corePointer = indp;
} else { } else {
xf86ReplaceBoolOption(indp->commonOptions, "CorePointer", FALSE); xf86ReplaceBoolOption(indp->options, "CorePointer", FALSE);
xf86Msg(X_WARNING, "Duplicate core pointer devices. " xf86Msg(X_WARNING, "Duplicate core pointer devices. "
"Removing core pointer attribute from \"%s\"\n", "Removing core pointer attribute from \"%s\"\n",
indp->identifier); indp->name);
} }
} }
if (indp->commonOptions && if (indp->options &&
xf86CheckBoolOption(indp->commonOptions, "CoreKeyboard", FALSE)) { xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE)) {
if (!coreKeyboard) { if (!coreKeyboard) {
coreKeyboard = indp; coreKeyboard = indp;
} else { } else {
xf86ReplaceBoolOption(indp->commonOptions, "CoreKeyboard", FALSE); xf86ReplaceBoolOption(indp->options, "CoreKeyboard", FALSE);
xf86Msg(X_WARNING, "Duplicate core keyboard devices. " xf86Msg(X_WARNING, "Duplicate core keyboard devices. "
"Removing core keyboard attribute from \"%s\"\n", "Removing core keyboard attribute from \"%s\"\n",
indp->identifier); indp->name);
} }
} }
count++; count++;
@ -1177,7 +1177,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
if (*devs == corePointer) if (*devs == corePointer)
{ {
free(*devs); free(*devs);
*devs = (IDevPtr)0x1; /* ensure we dont skip next loop*/ *devs = (InputInfoPtr)0x1; /* ensure we dont skip next loop*/
break; break;
} }
for (; devs && *devs; devs++) for (; devs && *devs; devs++)
@ -1244,10 +1244,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
if (foundPointer) { if (foundPointer) {
count++; count++;
devs = xnfrealloc(servlayoutp->inputs, devs = xnfrealloc(servlayoutp->inputs,
(count + 1) * sizeof(IDevPtr)); (count + 1) * sizeof(InputInfoPtr));
devs[count - 1] = xnfalloc(sizeof(IDevRec)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
*devs[count - 1] = Pointer; *devs[count - 1] = Pointer;
devs[count - 1]->commonOptions = devs[count - 1]->options =
xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL); xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL);
devs[count] = NULL; devs[count] = NULL;
servlayoutp->inputs = devs; servlayoutp->inputs = devs;
@ -1288,10 +1288,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
if (foundPointer) { if (foundPointer) {
count++; count++;
devs = xnfrealloc(servlayoutp->inputs, devs = xnfrealloc(servlayoutp->inputs,
(count + 1) * sizeof(IDevPtr)); (count + 1) * sizeof(InputInfoPtr));
devs[count - 1] = xnfalloc(sizeof(IDevRec)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
*devs[count - 1] = Pointer; *devs[count - 1] = Pointer;
devs[count - 1]->commonOptions = devs[count - 1]->options =
xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL); xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
devs[count] = NULL; devs[count] = NULL;
servlayoutp->inputs = devs; servlayoutp->inputs = devs;
@ -1319,7 +1319,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
if (*devs == coreKeyboard) if (*devs == coreKeyboard)
{ {
free(*devs); free(*devs);
*devs = (IDevPtr)0x1; /* ensure we dont skip next loop */ *devs = (InputInfoPtr)0x1; /* ensure we dont skip next loop */
break; break;
} }
for (; devs && *devs; devs++) for (; devs && *devs; devs++)
@ -1384,10 +1384,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
if (foundKeyboard) { if (foundKeyboard) {
count++; count++;
devs = xnfrealloc(servlayoutp->inputs, devs = xnfrealloc(servlayoutp->inputs,
(count + 1) * sizeof(IDevPtr)); (count + 1) * sizeof(InputInfoPtr));
devs[count - 1] = xnfalloc(sizeof(IDevRec)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
*devs[count - 1] = Keyboard; *devs[count - 1] = Keyboard;
devs[count - 1]->commonOptions = devs[count - 1]->options =
xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL); xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL);
devs[count] = NULL; devs[count] = NULL;
servlayoutp->inputs = devs; servlayoutp->inputs = devs;
@ -1459,7 +1459,7 @@ static Bool
configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp) configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
{ {
XF86ConfInputrefPtr irp; XF86ConfInputrefPtr irp;
IDevPtr *indp; InputInfoPtr *indp;
int count = 0; int count = 0;
/* /*
@ -1472,19 +1472,19 @@ configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
} }
DebugF("Found %d input devices in the layout section %s\n", DebugF("Found %d input devices in the layout section %s\n",
count, layout->lay_identifier); count, layout->lay_identifier);
indp = xnfcalloc((count + 1), sizeof(IDevPtr)); indp = xnfcalloc((count + 1), sizeof(InputInfoPtr));
indp[count] = NULL; indp[count] = NULL;
irp = layout->lay_input_lst; irp = layout->lay_input_lst;
count = 0; count = 0;
while (irp) { while (irp) {
indp[count] = xnfalloc(sizeof(IDevRec)); indp[count] = xnfalloc(sizeof(InputInfoRec));
if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) { if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
while(count--) while(count--)
free(indp[count]); free(indp[count]);
free(indp); free(indp);
return FALSE; return FALSE;
} }
indp[count]->commonOptions = irp->iref_option_lst; indp[count]->options = irp->iref_option_lst;
count++; count++;
irp = (XF86ConfInputrefPtr)irp->list.next; irp = (XF86ConfInputrefPtr)irp->list.next;
} }
@ -1707,7 +1707,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
MessageType from; MessageType from;
XF86ConfScreenPtr s; XF86ConfScreenPtr s;
screenLayoutPtr slp; screenLayoutPtr slp;
IDevPtr *indp; InputInfoPtr *indp;
XF86ConfLayoutRec layout; XF86ConfLayoutRec layout;
if (!servlayoutp) if (!servlayoutp)
@ -1753,7 +1753,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
from = X_DEFAULT; from = X_DEFAULT;
} else { } else {
/* Set up an empty input device list, then look for some core devices. */ /* Set up an empty input device list, then look for some core devices. */
indp = xnfalloc(sizeof(IDevPtr)); indp = xnfalloc(sizeof(InputInfoPtr));
*indp = NULL; *indp = NULL;
servlayoutp->inputs = indp; servlayoutp->inputs = indp;
} }
@ -2300,12 +2300,12 @@ configExtensions(XF86ConfExtensionsPtr conf_ext)
} }
static Bool static Bool
configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from) configInput(InputInfoPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
{ {
xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier); xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
inputp->identifier = conf_input->inp_identifier; inputp->name = conf_input->inp_identifier;
inputp->driver = conf_input->inp_driver; inputp->driver = conf_input->inp_driver;
inputp->commonOptions = conf_input->inp_option_lst; inputp->options = conf_input->inp_option_lst;
inputp->attrs = NULL; inputp->attrs = NULL;
return TRUE; return TRUE;
@ -2359,7 +2359,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
*/ */
if (xf86Info.allowEmptyInput && layout->inputs) if (xf86Info.allowEmptyInput && layout->inputs)
{ {
IDevPtr *dev = layout->inputs; InputInfoPtr *dev = layout->inputs;
BOOL warned = FALSE; BOOL warned = FALSE;
while(*dev) while(*dev)
@ -2368,7 +2368,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
strcmp((*dev)->driver, "mouse") == 0 || strcmp((*dev)->driver, "mouse") == 0 ||
strcmp((*dev)->driver, "vmmouse") == 0) strcmp((*dev)->driver, "vmmouse") == 0)
{ {
IDevPtr *current; InputInfoPtr *current;
if (!warned) if (!warned)
{ {
xf86Msg(X_WARNING, "AllowEmptyInput is on, devices using " xf86Msg(X_WARNING, "AllowEmptyInput is on, devices using "
@ -2376,7 +2376,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
warned = TRUE; warned = TRUE;
} }
xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->identifier); xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->name);
current = dev; current = dev;
free(*dev); free(*dev);

View File

@ -822,7 +822,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
void void
InitInput(int argc, char **argv) InitInput(int argc, char **argv)
{ {
IDevPtr* pDev; InputInfoPtr* pDev;
DeviceIntPtr dev; DeviceIntPtr dev;
xf86Info.vtRequestsPending = FALSE; xf86Info.vtRequestsPending = FALSE;

View File

@ -118,38 +118,22 @@ xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts)
} }
/* /*
* xf86CollectInputOptions collects the options for an InputDevice. * xf86CollectInputOptions collects extra options for an InputDevice (other
* This function requires that the following has been initialised: * than those added by the config backend).
* * The options are merged into the existing ones and thus take precedence
* pInfo->conf_idev * over the others.
*
* The extraOpts parameter may optionally contain a list of additional options
* to include.
*
* The order of precedence for options is:
*
* extraOpts, pInfo->conf_idev->extraOptions,
* pInfo->conf_idev->commonOptions, defaultOpts
*/ */
void void
xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts) xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts)
{ {
XF86OptionPtr tmp;
pInfo->options = NULL;
if (defaultOpts) { if (defaultOpts) {
pInfo->options = xf86OptionListCreate(defaultOpts, -1, 0); XF86OptionPtr tmp =xf86optionListCreate(defaultOpts, -1, 0);
}
if (pInfo->conf_idev && pInfo->conf_idev->commonOptions) {
tmp = xf86optionListDup(pInfo->conf_idev->commonOptions);
if (pInfo->options) if (pInfo->options)
pInfo->options = xf86optionListMerge(pInfo->options, tmp); pInfo->options = xf86optionListMerge(pInfo->options, tmp);
else else
pInfo->options = tmp; pInfo->options = tmp;
} }
if (pInfo->conf_idev && pInfo->conf_idev->attrs) {
pInfo->attrs = pInfo->conf_idev->attrs;
}
} }
/* Created for new XInput stuff -- essentially extensions to the parser */ /* Created for new XInput stuff -- essentially extensions to the parser */

View File

@ -505,7 +505,7 @@ MatchAttrToken(const char *attr, struct list *patterns,
* statements must match. * statements must match.
*/ */
static Bool static Bool
InputClassMatches(const XF86ConfInputClassPtr iclass, const IDevPtr idev, InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
const InputAttributes *attrs) const InputAttributes *attrs)
{ {
/* MatchProduct substring */ /* MatchProduct substring */
@ -585,7 +585,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const IDevPtr idev,
* well as any previous InputClass sections. * well as any previous InputClass sections.
*/ */
static int static int
MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs) MergeInputClasses(const InputInfoPtr idev, const InputAttributes *attrs)
{ {
XF86ConfInputClassPtr cl; XF86ConfInputClassPtr cl;
XF86OptionPtr classopts; XF86OptionPtr classopts;
@ -610,9 +610,8 @@ MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
/* Apply options to device with InputClass settings preferred. */ /* Apply options to device with InputClass settings preferred. */
xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n", xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
idev->identifier, cl->identifier); idev->name, cl->identifier);
idev->commonOptions = xf86optionListMerge(idev->commonOptions, idev->options = xf86optionListMerge(idev->options, classopts);
classopts);
} }
return Success; return Success;
@ -623,7 +622,7 @@ MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
* value of the last matching class and holler when returning TRUE. * value of the last matching class and holler when returning TRUE.
*/ */
static Bool static Bool
IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs) IgnoreInputClass(const InputInfoPtr idev, const InputAttributes *attrs)
{ {
XF86ConfInputClassPtr cl; XF86ConfInputClassPtr cl;
Bool ignore = FALSE; Bool ignore = FALSE;
@ -640,38 +639,43 @@ IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
if (ignore) if (ignore)
xf86Msg(X_CONFIG, "%s: Ignoring device from InputClass \"%s\"\n", xf86Msg(X_CONFIG, "%s: Ignoring device from InputClass \"%s\"\n",
idev->identifier, ignore_class); idev->name, ignore_class);
return ignore; return ignore;
} }
/* Allocate a new InputInfoRec and append it to the tail of xf86InputDevs. */
static InputInfoPtr static InputInfoPtr
xf86AllocateInput(InputDriverPtr drv, IDevPtr idev) xf86AllocateInput(void)
{ {
InputInfoPtr new, *prev = NULL; InputInfoPtr pInfo;
if (!(new = calloc(sizeof(InputInfoRec), 1))) pInfo = calloc(sizeof(*pInfo), 1);
return NULL; if (!pInfo)
return NULL;
new->drv = drv; pInfo->fd = -1;
pInfo->type_name = "UNKNOWN";
return pInfo;
}
/* Append InputInfoRec to the tail of xf86InputDevs. */
static void
xf86AddInput(InputDriverPtr drv, InputInfoPtr pInfo)
{
InputInfoPtr *prev = NULL;
pInfo->drv = drv;
drv->refCount++; drv->refCount++;
new->module = DuplicateModule(drv->module, NULL); pInfo->module = DuplicateModule(drv->module, NULL);
for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next) for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
; ;
*prev = new; *prev = pInfo;
new->next = NULL; pInfo->next = NULL;
new->fd = -1; xf86CollectInputOptions(pInfo, (const char**)drv->default_options);
new->name = idev->identifier; xf86ProcessCommonOptions(pInfo, pInfo->options);
new->type_name = "UNKNOWN";
new->conf_idev = idev;
xf86CollectInputOptions(new, (const char**)drv->default_options);
xf86ProcessCommonOptions(new, new->options);
return new;
} }
/* /*
@ -710,6 +714,10 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
p->next = pInp->next; p->next = pInp->next;
/* Else the entry wasn't in the xf86InputDevs list (ignore this). */ /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
} }
free(pInp->driver);
free(pInp->name);
xf86optionListFree(pInp->options);
free(pInp); free(pInp);
} }
@ -744,21 +752,20 @@ xf86InputDevicePostInit(DeviceIntPtr dev) {
* @return Success or an error code * @return Success or an error code
*/ */
_X_INTERNAL int _X_INTERNAL int
xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable) xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
{ {
InputDriverPtr drv = NULL; InputDriverPtr drv = NULL;
InputInfoPtr pInfo = NULL;
DeviceIntPtr dev = NULL; DeviceIntPtr dev = NULL;
int rval; int rval;
/* Memory leak for every attached device if we don't /* Memory leak for every attached device if we don't
* test if the module is already loaded first */ * test if the module is already loaded first */
drv = xf86LookupInputDriver(idev->driver); drv = xf86LookupInputDriver(pInfo->driver);
if (!drv) if (!drv)
if (xf86LoadOneModule(idev->driver, NULL)) if (xf86LoadOneModule(pInfo->driver, NULL))
drv = xf86LookupInputDriver(idev->driver); drv = xf86LookupInputDriver(pInfo->driver);
if (!drv) { if (!drv) {
xf86Msg(X_ERROR, "No input driver matching `%s'\n", idev->driver); xf86Msg(X_ERROR, "No input driver matching `%s'\n", pInfo->driver);
rval = BadName; rval = BadName;
goto unwind; goto unwind;
} }
@ -771,13 +778,12 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
goto unwind; goto unwind;
} }
if (!(pInfo = xf86AllocateInput(drv, idev))) xf86AddInput(drv, pInfo);
goto unwind;
rval = drv->PreInit(drv, pInfo, 0); rval = drv->PreInit(drv, pInfo, 0);
if (rval != Success) { if (rval != Success) {
xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, idev->identifier); xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, pInfo->name);
goto unwind; goto unwind;
} }
@ -790,7 +796,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
rval = ActivateDevice(dev, TRUE); rval = ActivateDevice(dev, TRUE);
if (rval != Success) if (rval != Success)
{ {
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier); xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
RemoveDevice(dev, TRUE); RemoveDevice(dev, TRUE);
goto unwind; goto unwind;
} }
@ -798,7 +804,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
rval = xf86InputDevicePostInit(dev); rval = xf86InputDevicePostInit(dev);
if (rval != Success) if (rval != Success)
{ {
xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", idev->identifier); xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", pInfo->name);
RemoveDevice(dev, TRUE); RemoveDevice(dev, TRUE);
goto unwind; goto unwind;
} }
@ -809,7 +815,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
EnableDevice(dev, TRUE); EnableDevice(dev, TRUE);
if (!dev->enabled) if (!dev->enabled)
{ {
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier); xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
rval = BadMatch; rval = BadMatch;
goto unwind; goto unwind;
} }
@ -822,7 +828,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
unwind: unwind:
if(pInfo) { if(pInfo) {
if(drv->UnInit) if(drv && drv->UnInit)
drv->UnInit(drv, pInfo, 0); drv->UnInit(drv, pInfo, 0);
else else
xf86DeleteInput(pInfo, 0); xf86DeleteInput(pInfo, 0);
@ -834,23 +840,23 @@ int
NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
DeviceIntPtr *pdev) DeviceIntPtr *pdev)
{ {
IDevRec *idev = NULL; InputInfoPtr pInfo = NULL;
InputOption *option = NULL; InputOption *option = NULL;
int rval = Success; int rval = Success;
int is_auto = 0; int is_auto = 0;
idev = calloc(sizeof(*idev), 1); pInfo = xf86AllocateInput();
if (!idev) if (!pInfo)
return BadAlloc; return BadAlloc;
for (option = options; option; option = option->next) { for (option = options; option; option = option->next) {
if (strcasecmp(option->key, "driver") == 0) { if (strcasecmp(option->key, "driver") == 0) {
if (idev->driver) { if (pInfo->driver) {
rval = BadRequest; rval = BadRequest;
goto unwind; goto unwind;
} }
idev->driver = xstrdup(option->value); pInfo->driver = xstrdup(option->value);
if (!idev->driver) { if (!pInfo->driver) {
rval = BadAlloc; rval = BadAlloc;
goto unwind; goto unwind;
} }
@ -858,12 +864,12 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
if (strcasecmp(option->key, "name") == 0 || if (strcasecmp(option->key, "name") == 0 ||
strcasecmp(option->key, "identifier") == 0) { strcasecmp(option->key, "identifier") == 0) {
if (idev->identifier) { if (pInfo->name) {
rval = BadRequest; rval = BadRequest;
goto unwind; goto unwind;
} }
idev->identifier = xstrdup(option->value); pInfo->name = xstrdup(option->value);
if (!idev->identifier) { if (!pInfo->name) {
rval = BadAlloc; rval = BadAlloc;
goto unwind; goto unwind;
} }
@ -883,7 +889,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
for (option = options; option; option = option->next) { for (option = options; option; option = option->next) {
/* Steal option key/value strings from the provided list. /* Steal option key/value strings from the provided list.
* We need those strings, the InputOption list doesn't. */ * We need those strings, the InputOption list doesn't. */
idev->commonOptions = xf86addNewOption(idev->commonOptions, pInfo->options = xf86addNewOption(pInfo->options,
option->key, option->value); option->key, option->value);
option->key = NULL; option->key = NULL;
option->value = NULL; option->value = NULL;
@ -891,42 +897,39 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
/* Apply InputClass settings */ /* Apply InputClass settings */
if (attrs) { if (attrs) {
if (IgnoreInputClass(idev, attrs)) { if (IgnoreInputClass(pInfo, attrs)) {
rval = BadIDChoice; rval = BadIDChoice;
goto unwind; goto unwind;
} }
rval = MergeInputClasses(idev, attrs); rval = MergeInputClasses(pInfo, attrs);
if (rval != Success) if (rval != Success)
goto unwind; goto unwind;
idev->attrs = DuplicateInputAttributes(attrs); pInfo->attrs = DuplicateInputAttributes(attrs);
} }
if (!idev->driver || !idev->identifier) { if (!pInfo->driver || !pInfo->name) {
xf86Msg(X_INFO, "No input driver/identifier specified (ignoring)\n"); xf86Msg(X_INFO, "No input driver/identifier specified (ignoring)\n");
rval = BadRequest; rval = BadRequest;
goto unwind; goto unwind;
} }
if (!idev->identifier) { if (!pInfo->name) {
xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n"); xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
rval = BadMatch; rval = BadMatch;
goto unwind; goto unwind;
} }
rval = xf86NewInputDevice(idev, pdev, rval = xf86NewInputDevice(pInfo, pdev,
(!is_auto || (is_auto && xf86Info.autoEnableDevices))); (!is_auto || (is_auto && xf86Info.autoEnableDevices)));
if (rval == Success)
return Success; return rval;
unwind: unwind:
if (is_auto && !xf86Info.autoAddDevices) if (is_auto && !xf86Info.autoAddDevices)
xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n"); xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
free(idev->driver); xf86DeleteInput(pInfo, 0);
free(idev->identifier);
xf86optionListFree(idev->commonOptions);
free(idev);
return rval; return rval;
} }
@ -935,15 +938,10 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
{ {
InputInfoPtr pInfo = (InputInfoPtr) pDev->public.devicePrivate; InputInfoPtr pInfo = (InputInfoPtr) pDev->public.devicePrivate;
InputDriverPtr drv = NULL; InputDriverPtr drv = NULL;
IDevRec *idev = NULL;
IDevPtr *it;
Bool isMaster = IsMaster(pDev); Bool isMaster = IsMaster(pDev);
if (pInfo) /* need to get these before RemoveDevice */ if (pInfo) /* need to get these before RemoveDevice */
{
drv = pInfo->drv; drv = pInfo->drv;
idev = pInfo->conf_idev;
}
OsBlockSignals(); OsBlockSignals();
RemoveDevice(pDev, TRUE); RemoveDevice(pDev, TRUE);
@ -954,19 +952,6 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
drv->UnInit(drv, pInfo, 0); drv->UnInit(drv, pInfo, 0);
else else
xf86DeleteInput(pInfo, 0); xf86DeleteInput(pInfo, 0);
/* devices added by the config backend aren't in the config layout */
it = xf86ConfigLayout.inputs;
while(*it && *it != idev)
it++;
if (!(*it)) /* end of list, not in the layout */
{
free(idev->driver);
free(idev->identifier);
xf86optionListFree(idev->commonOptions);
free(idev);
}
} }
OsReleaseSignals(); OsReleaseSignals();
} }

View File

@ -78,8 +78,6 @@
#define TS_Raw 60 #define TS_Raw 60
#define TS_Scaled 61 #define TS_Scaled 61
struct _InputInfoRec;
/* This holds the input driver entry and module information. */ /* This holds the input driver entry and module information. */
typedef struct _InputDriverRec { typedef struct _InputDriverRec {
int driverVersion; int driverVersion;
@ -100,6 +98,8 @@ typedef struct _InputDriverRec {
typedef struct _InputInfoRec { typedef struct _InputInfoRec {
struct _InputInfoRec *next; struct _InputInfoRec *next;
char * name; char * name;
char * driver;
int flags; int flags;
Bool (*device_control)(DeviceIntPtr device, int what); Bool (*device_control)(DeviceIntPtr device, int what);
@ -117,12 +117,11 @@ typedef struct _InputInfoRec {
DeviceIntPtr dev; DeviceIntPtr dev;
pointer private; pointer private;
char * type_name; char * type_name;
IDevPtr conf_idev;
InputDriverPtr drv; InputDriverPtr drv;
pointer module; pointer module;
pointer options; pointer options;
InputAttributes *attrs; InputAttributes *attrs;
} InputInfoRec, *InputInfoPtr; } *InputInfoPtr;
/* xf86Globals.c */ /* xf86Globals.c */
extern _X_EXPORT InputInfoPtr xf86InputDevs; extern _X_EXPORT InputInfoPtr xf86InputDevs;
@ -163,7 +162,7 @@ extern _X_EXPORT void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
extern _X_EXPORT void xf86DisableDevice(DeviceIntPtr dev, Bool panic); extern _X_EXPORT void xf86DisableDevice(DeviceIntPtr dev, Bool panic);
extern _X_EXPORT void xf86EnableDevice(DeviceIntPtr dev); extern _X_EXPORT void xf86EnableDevice(DeviceIntPtr dev);
/* not exported */ /* not exported */
int xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL is_auto); int xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL is_auto);
/* xf86Helper.c */ /* xf86Helper.c */
extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags); extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);

View File

@ -401,13 +401,6 @@ typedef struct {
int screen; /* For multi-CRTC cards */ int screen; /* For multi-CRTC cards */
} GDevRec, *GDevPtr; } GDevRec, *GDevPtr;
typedef struct {
char * identifier;
char * driver;
pointer commonOptions;
InputAttributes *attrs;
} IDevRec, *IDevPtr;
typedef struct { typedef struct {
int frameX0; int frameX0;
int frameY0; int frameY0;
@ -477,11 +470,13 @@ typedef struct _screenlayoutrec {
confScreenPtr refscreen; confScreenPtr refscreen;
} screenLayoutRec, *screenLayoutPtr; } screenLayoutRec, *screenLayoutPtr;
typedef struct _InputInfoRec InputInfoRec;
typedef struct _serverlayoutrec { typedef struct _serverlayoutrec {
char * id; char * id;
screenLayoutPtr screens; screenLayoutPtr screens;
GDevPtr inactives; GDevPtr inactives;
IDevPtr* inputs; /* NULL terminated */ InputInfoRec** inputs; /* NULL terminated */
pointer options; pointer options;
} serverLayoutRec, *serverLayoutPtr; } serverLayoutRec, *serverLayoutPtr;