~ubuntu-branches/ubuntu/precise/xorg-server/precise-updates

« back to all changes in this revision

Viewing changes to hw/xfree86/common/xf86Helper.c

Tags: 2:1.10.1-2
* Build xserver-xorg-core-udeb on hurd-i386.  Thanks, Samuel Thibault!
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
                                xnfalloc(sizeof(InputDriverRec));
126
126
    *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver;
127
127
    xf86InputDriverList[xf86NumInputDrivers - 1]->module = module;
128
 
    xf86InputDriverList[xf86NumInputDrivers - 1]->refCount = 0;
129
128
}
130
129
 
131
130
void
274
273
    return idx;
275
274
}
276
275
 
277
 
/* Allocate a new InputInfoRec and append it to the tail of xf86InputDevs. */
278
 
InputInfoPtr
279
 
xf86AllocateInput(InputDriverPtr drv, int flags)
280
 
{
281
 
    InputInfoPtr new, *prev = NULL;
282
 
 
283
 
    if (!(new = calloc(sizeof(InputInfoRec), 1)))
284
 
        return NULL;
285
 
 
286
 
    new->drv = drv;
287
 
    drv->refCount++;
288
 
    new->module = DuplicateModule(drv->module, NULL);
289
 
 
290
 
    for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
291
 
        ;
292
 
 
293
 
    *prev = new;
294
 
    new->next = NULL;
295
 
 
296
 
    return new;
297
 
}
298
 
 
299
 
 
300
 
/*
301
 
 * Remove an entry from xf86InputDevs.  Ideally it should free all allocated
302
 
 * data.  To do this properly may require a driver hook.
303
 
 */
304
 
 
305
 
void
306
 
xf86DeleteInput(InputInfoPtr pInp, int flags)
307
 
{
308
 
    InputInfoPtr p;
309
 
 
310
 
    /* First check if the inputdev is valid. */
311
 
    if (pInp == NULL)
312
 
        return;
313
 
 
314
 
#if 0
315
 
    /* If a free function is defined, call it here. */
316
 
    if (pInp->free)
317
 
        pInp->free(pInp, 0);
318
 
#endif
319
 
 
320
 
    if (pInp->module)
321
 
        UnloadModule(pInp->module);
322
 
 
323
 
    if (pInp->drv)
324
 
        pInp->drv->refCount--;
325
 
 
326
 
    /* This should *really* be handled in drv->UnInit(dev) call instead, but
327
 
     * if the driver forgets about it make sure we free it or at least crash
328
 
     * with flying colors */
329
 
    free(pInp->private);
330
 
 
331
 
    FreeInputAttributes(pInp->attrs);
332
 
 
333
 
    /* Remove the entry from the list. */
334
 
    if (pInp == xf86InputDevs)
335
 
        xf86InputDevs = pInp->next;
336
 
    else {
337
 
        p = xf86InputDevs;
338
 
        while (p && p->next != pInp)
339
 
            p = p->next;
340
 
        if (p)
341
 
            p->next = pInp->next;
342
 
        /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
343
 
    }
344
 
    free(pInp);
345
 
}
346
 
 
347
276
Bool
348
277
xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad)
349
278
{
1183
1112
    if (enable)
1184
1113
    {
1185
1114
        /*
1186
 
         * Restore the screen pixmap devPrivate field
1187
 
         */
1188
 
        pspix->devPrivate = pScrnInfo->pixmapPrivate;
1189
 
        /*
1190
1115
         * Restore all of the clip lists on the screen
1191
1116
         */
1192
1117
        if (!xf86Resetting)
1199
1124
         * Empty all of the clip lists on the screen
1200
1125
         */
1201
1126
        xf86SetRootClip (pScreen, FALSE);
1202
 
        /*
1203
 
         * save the screen pixmap devPrivate field and
1204
 
         * replace it with NULL so accidental references
1205
 
         * to the frame buffer are caught
1206
 
         */
1207
 
        pScrnInfo->pixmapPrivate = pspix->devPrivate;
1208
 
        pspix->devPrivate.ptr = NULL;
1209
1127
    }
1210
1128
}
1211
1129
 
1263
1181
    va_end(ap);
1264
1182
}
1265
1183
 
 
1184
/* Print input driver messages in the standard format of
 
1185
   <driver>: <device name>: <message> */
 
1186
void
 
1187
xf86VIDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *format,
 
1188
                 va_list args)
 
1189
{
 
1190
    char *msg;
 
1191
 
 
1192
    if (asprintf(&msg, "%s: %s: %s", dev->drv->driverName, dev->name, format)
 
1193
        == -1) {
 
1194
        LogVMessageVerb(type, verb, "%s", args);
 
1195
    } else {
 
1196
        LogVMessageVerb(type, verb, msg, args);
 
1197
        free(msg);
 
1198
    }
 
1199
}
 
1200
 
 
1201
/* Print input driver message, with verbose level specified directly */
 
1202
void
 
1203
xf86IDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *format,
 
1204
               ...)
 
1205
{
 
1206
    va_list ap;
 
1207
 
 
1208
    va_start(ap, format);
 
1209
    xf86VIDrvMsgVerb(dev, type, verb, format, ap);
 
1210
    va_end(ap);
 
1211
}
 
1212
 
 
1213
/* Print input driver messages, with verbose level of 1 (default) */
 
1214
void
 
1215
xf86IDrvMsg(InputInfoPtr dev, MessageType type, const char *format, ...)
 
1216
{
 
1217
    va_list ap;
 
1218
 
 
1219
    va_start(ap, format);
 
1220
    xf86VIDrvMsgVerb(dev, type, 1, format, ap);
 
1221
    va_end(ap);
 
1222
}
 
1223
 
 
1224
 
1266
1225
/* Print non-driver messages with verbose level specified directly */
1267
1226
void
1268
1227
xf86MsgVerb(MessageType type, int verb, const char *format, ...)
1270
1229
    va_list ap;
1271
1230
 
1272
1231
    va_start(ap, format);
1273
 
    xf86VDrvMsgVerb(-1, type, verb, format, ap);
 
1232
    LogVMessageVerb(type, verb, format, ap);
1274
1233
    va_end(ap);
1275
1234
}
1276
1235
 
1281
1240
    va_list ap;
1282
1241
 
1283
1242
    va_start(ap, format);
1284
 
    xf86VDrvMsgVerb(-1, type, 1, format, ap);
 
1243
    LogVMessageVerb(type, 1, format, ap);
1285
1244
    va_end(ap);
1286
1245
}
1287
1246
 
1321
1280
    /* Get the log file name */
1322
1281
    if (xf86LogFileFrom == X_DEFAULT) {
1323
1282
        /* Append the display number and ".log" */
1324
 
        lf = malloc(strlen(xf86LogFile) + strlen("%s") +
1325
 
                    strlen(LOGSUFFIX) + 1);
1326
 
        if (!lf)
 
1283
        if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1)
1327
1284
            FatalError("Cannot allocate space for the log file name\n");
1328
 
        sprintf(lf, "%s%%s" LOGSUFFIX, xf86LogFile);
1329
1285
        xf86LogFile = lf;
1330
1286
    }
1331
1287
 
1975
1931
 
1976
1932
    xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
1977
1933
 
 
1934
    free(pEnt);
1978
1935
    return pScrn;
1979
1936
}
1980
1937
 
2086
2043
}
2087
2044
 
2088
2045
void
2089
 
xf86MotionHistoryAllocate(LocalDevicePtr local)
 
2046
xf86MotionHistoryAllocate(InputInfoPtr pInfo)
2090
2047
{
2091
 
    AllocateMotionHistory(local->dev);
 
2048
    AllocateMotionHistory(pInfo->dev);
2092
2049
}