Пример #1
0
void
LogPrintMarkers()
{
    /* Show what the message marker symbols mean. */
    ErrorF("Markers: ");
    LogMessageVerb(X_PROBED, -1, "probed, ");
    LogMessageVerb(X_CONFIG, -1, "from config file, ");
    LogMessageVerb(X_DEFAULT, -1, "default setting,\n\t");
    LogMessageVerb(X_CMDLINE, -1, "from command line, ");
    LogMessageVerb(X_NOTICE, -1, "notice, ");
    LogMessageVerb(X_INFO, -1, "informational,\n\t");
    LogMessageVerb(X_WARNING, -1, "warning, ");
    LogMessageVerb(X_ERROR, -1, "error, ");
    LogMessageVerb(X_NOT_IMPLEMENTED, -1, "not implemented, ");
    LogMessageVerb(X_UNKNOWN, -1, "unknown.\n");
}
Пример #2
0
static void
wscons_add_pointers(void)
{
    char devname[256];
    int fd, i, wsmouse_type;

    /* Check pointing devices */
    for (i = 0; i < 4; i++) {
        snprintf(devname, sizeof(devname), "%s%d",
                 WSCONS_MOUSE_PREFIX, i);
        LogMessageVerb(X_INFO, 10, "wsmouse: checking %s\n", devname);
        fd = priv_open_device(devname);
        if (fd == -1) {
            LogMessageVerb(X_WARNING, 10, "%s: %s\n", devname,
                           strerror(errno));
            continue;
        }
        if (ioctl(fd, WSMOUSEIO_GTYPE, &wsmouse_type) != 0) {
            LogMessageVerb(X_WARNING, 10,
                           "%s: WSMOUSEIO_GTYPE failed\n", devname);
            close(fd);
            continue;
        }
        close(fd);
        switch (wsmouse_type) {
          case WSMOUSE_TYPE_SYNAPTICS:
          case WSMOUSE_TYPE_ALPS:
          case WSMOUSE_TYPE_ELANTECH:
            wscons_add_pointer(devname, "synaptics",
                               ATTR_TOUCHPAD);
            break;
          case WSMOUSE_TYPE_TPANEL:
            wscons_add_pointer(devname, "ws", ATTR_TOUCHSCREEN);
            break;
          default:
            break;
        }
    }
    /* Add a default entry catching all other mux elements as "ws" */
    wscons_add_pointer(WSCONS_MOUSE_PREFIX, "ws", ATTR_POINTER);
}
Пример #3
0
void
LoaderInit(void)
{
#ifndef XORG_NO_SDKSYMS
    LogMessageVerb(X_INFO, 2, "Loader magic: %p\n", (void *) xorg_symbols);
#endif
    LogMessageVerb(X_INFO, 2, "Module ABI versions:\n");
    LogWrite(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC,
             GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion),
             GET_ABI_MINOR(LoaderVersionInfo.ansicVersion));
    LogWrite(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV,
             GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion),
             GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion));
    LogWrite(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT,
             GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion),
             GET_ABI_MINOR(LoaderVersionInfo.xinputVersion));
    LogWrite(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION,
             GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion),
             GET_ABI_MINOR(LoaderVersionInfo.extensionVersion));

}
Пример #4
0
static char *
get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name)
{
    char *prop, *ret;

    prop = libhal_device_get_property_string(hal_ctx, udi, name, NULL);
    LogMessageVerb(X_INFO, 10, "config/hal: getting %s on %s returned %s\n", name, udi, prop ? prop : "(null)");
    if (prop) {
        ret = xstrdup(prop);
        libhal_free_string(prop);
    }
    else {
        return NULL;
    }

    return ret;
}
Пример #5
0
void
InitExtensions(int argc, char *argv[])
{
    int i;
    ExtensionModule *ext;

    AddStaticExtensions();

    for (i = 0; i < numExtensionModules; i++) {
        ext = &ExtensionModuleList[i];
        if (ext->initFunc != NULL &&
            (ext->disablePtr == NULL || !*ext->disablePtr)) {
            LogMessageVerb(X_INFO, 3, "Initializing extension %s\n",
                           ext->name);

            (ext->initFunc) ();
        }
    }
}
Пример #6
0
static void GLAPIENTRY
glamor_debug_output_callback(GLenum source,
                             GLenum type,
                             GLuint id,
                             GLenum severity,
                             GLsizei length,
                             const GLchar *message,
                             const void *userParam)
{
    ScreenPtr screen = (void *)userParam;
    glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);

    if (glamor_priv->suppress_gl_out_of_memory_logging &&
        source == GL_DEBUG_SOURCE_API && type == GL_DEBUG_TYPE_ERROR) {
        return;
    }

    LogMessageVerb(X_ERROR, 0, "glamor%d: GL error: %*s\n",
               screen->myNum, length, message);
}
Пример #7
0
static int
LoadAuthorization(void)
{
    FILE *f;
    Xauth *auth;
    int i;
    int count = 0;

    ShouldLoadAuth = FALSE;
    if (!authorization_file)
        return 0;

    errno = 0;
    f = Fopen(authorization_file, "r");
    if (!f) {
        LogMessageVerb(X_ERROR, 0,
                       "Failed to open authorization file \"%s\": %s\n",
                       authorization_file,
                       errno != 0 ? strerror(errno) : "Unknown error");
        return -1;
    }

    while ((auth = XauReadAuth(f)) != 0) {
        for (i = 0; i < NUM_AUTHORIZATION; i++) {
            if (protocols[i].name_length == auth->name_length &&
                memcmp(protocols[i].name, auth->name,
                       (int) auth->name_length) == 0 && protocols[i].Add) {
                ++count;
                (*protocols[i].Add) (auth->data_length, auth->data,
                                     FakeClientID(0));
            }
        }
        XauDisposeAuth(auth);
    }

    Fclose(f);
    return count;
}
Пример #8
0
static void
device_added(LibHalContext *hal_ctx, const char *udi)
{
    char *path = NULL, *driver = NULL, *name = NULL, *config_info = NULL;
    InputOption *options = NULL, *tmpo = NULL;
    DeviceIntPtr dev = NULL;
    DBusError error;
    struct xkb_options xkb_opts = {0};
    int rc;

    LibHalPropertySet *set = NULL;
	LibHalPropertySetIterator set_iter;
    char *psi_key = NULL, *tmp_val;


    dbus_error_init(&error);

    driver = get_prop_string(hal_ctx, udi, "input.x11_driver");
    if (!driver){
        /* verbose, don't tell the user unless they _want_ to see it */
        LogMessageVerb(X_INFO,7,"config/hal: no driver specified for device %s\n", udi);
        goto unwind;
    }

    path = get_prop_string(hal_ctx, udi, "input.device");
    if (!path) {
        LogMessage(X_WARNING,"config/hal: no driver or path specified for %s\n", udi);
        goto unwind;
    }

    name = get_prop_string(hal_ctx, udi, "info.product");
    if (!name)
        name = xstrdup("(unnamed)");

    options = xcalloc(sizeof(*options), 1);
    if (!options){
        LogMessage(X_ERROR, "config/hal: couldn't allocate space for input options!\n");
        goto unwind;
    }

    options->key = xstrdup("_source");
    options->value = xstrdup("server/hal");
    if (!options->key || !options->value) {
        LogMessage(X_ERROR, "config/hal: couldn't allocate first key/value pair\n");
        goto unwind;
    }

    /* most drivers use device.. not path. evdev uses both however, but the
     * path version isn't documented apparently. support both for now. */
    add_option(&options, "path", path);
    add_option(&options, "device", path);

    add_option(&options, "driver", driver);
    add_option(&options, "name", name);

    config_info = xalloc(strlen(udi) + 5); /* "hal:" and NULL */
    if (!config_info) {
        LogMessage(X_ERROR, "config/hal: couldn't allocate name\n");
        goto unwind;
    }
    sprintf(config_info, "hal:%s", udi);

    /* Check for duplicate devices */
    if (device_is_duplicate(config_info))
    {
        LogMessage(X_WARNING, "config/hal: device %s already added. Ignoring.\n", name);
        goto unwind;
    }

    /* ok, grab options from hal.. iterate through all properties
    * and lets see if any of them are options that we can add */
    set = libhal_device_get_all_properties(hal_ctx, udi, &error);

    if (!set) {
        LogMessage(X_ERROR, "config/hal: couldn't get property list for %s: %s (%s)\n",
               udi, error.name, error.message);
        goto unwind;
    }

    libhal_psi_init(&set_iter,set);
    while (libhal_psi_has_more(&set_iter)) {
        /* we are looking for supported keys.. extract and add to options */
        psi_key = libhal_psi_get_key(&set_iter);

        if (psi_key){

            /* normal options first (input.x11_options.<propname>) */
            if (!strncasecmp(psi_key, LIBHAL_PROP_KEY, sizeof(LIBHAL_PROP_KEY)-1)){
                char* tmp;

                /* only support strings for all values */
                tmp_val = get_prop_string(hal_ctx, udi, psi_key);

                if (tmp_val){

                    /* xkb needs special handling. HAL specs include
                     * input.xkb.xyz options, but the x11-input.fdi specifies
                     * input.x11_options.Xkbxyz options. By default, we use
                     * the former, unless the specific X11 ones are specified.
                     * Since we can't predict the order in which the keys
                     * arrive, we need to store them.
                     */
                    if ((tmp = strcasestr(psi_key, "xkb")) && strlen(tmp) >= 4)
                    {
                        if (!strcasecmp(&tmp[3], "layout"))
                        {
                            if (xkb_opts.layout)
                                xfree(xkb_opts.layout);
                            xkb_opts.layout = strdup(tmp_val);
                        } else if (!strcasecmp(&tmp[3], "model"))
                        {
                            if (xkb_opts.model)
                                xfree(xkb_opts.model);
                            xkb_opts.model = strdup(tmp_val);
                        } else if (!strcasecmp(&tmp[3], "rules"))
                        {
                            if (xkb_opts.rules)
                                xfree(xkb_opts.rules);
                            xkb_opts.rules = strdup(tmp_val);
                        } else if (!strcasecmp(&tmp[3], "variant"))
                        {
                            if (xkb_opts.variant)
                                xfree(xkb_opts.variant);
                            xkb_opts.variant = strdup(tmp_val);
                        } else if (!strcasecmp(&tmp[3], "options"))
                        {
                            if (xkb_opts.options)
                                xfree(xkb_opts.options);
                            xkb_opts.options = strdup(tmp_val);
                        }
                    } else
                    {
                        /* all others */
                        add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val);
                        xfree(tmp_val);
                    }
                } else
                {
                    /* server 1.4 had xkb_options as strlist. */
                    if ((tmp = strcasestr(psi_key, "xkb")) &&
                        (strlen(tmp) >= 4) &&
                        (!strcasecmp(&tmp[3], "options")) &&
                        (tmp_val = get_prop_string_array(hal_ctx, udi, psi_key)))
                    {
                        if (xkb_opts.options)
                            xfree(xkb_opts.options);
                        xkb_opts.options = strdup(tmp_val);
                    }
                }
            } else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){
                char* tmp;

                /* only support strings for all values */
                tmp_val = get_prop_string(hal_ctx, udi, psi_key);

                if (tmp_val && strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY)) {

                    tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1];

                    if (!strcasecmp(tmp, "layout"))
                    {
                        if (!xkb_opts.layout)
                            xkb_opts.layout = strdup(tmp_val);
                    } else if (!strcasecmp(tmp, "rules"))
                    {
                        if (!xkb_opts.rules)
                            xkb_opts.rules = strdup(tmp_val);
                    } else if (!strcasecmp(tmp, "variant"))
                    {
                        if (!xkb_opts.variant)
                            xkb_opts.variant = strdup(tmp_val);
                    } else if (!strcasecmp(tmp, "model"))
                    {
                        if (!xkb_opts.model)
                            xkb_opts.model = strdup(tmp_val);
                    } else if (!strcasecmp(tmp, "options"))
                    {
                        if (!xkb_opts.options)
                            xkb_opts.options = strdup(tmp_val);
                    }
                    xfree(tmp_val);
                } else
                {
                    /* server 1.4 had xkb options as strlist */
                    tmp_val = get_prop_string_array(hal_ctx, udi, psi_key);
                    if (tmp_val && strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY))
                    {
                        tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1];
                        if (!strcasecmp(tmp, ".options") && (!xkb_opts.options))
                            xkb_opts.options = strdup(tmp_val);
                    }
                }
            }
        }

        /* psi_key doesn't need to be freed */
        libhal_psi_next(&set_iter);
    }


    /* Now add xkb options */
    if (xkb_opts.layout)
        add_option(&options, "xkb_layout", xkb_opts.layout);
    if (xkb_opts.rules)
        add_option(&options, "xkb_rules", xkb_opts.rules);
    if (xkb_opts.variant)
        add_option(&options, "xkb_variant", xkb_opts.variant);
    if (xkb_opts.model)
        add_option(&options, "xkb_model", xkb_opts.model);
    if (xkb_opts.options)
        add_option(&options, "xkb_options", xkb_opts.options);

    /* this isn't an error, but how else do you output something that the user can see? */
    LogMessage(X_INFO, "config/hal: Adding input device %s\n", name);
    if ((rc = NewInputDeviceRequest(options, &dev)) != Success) {
        LogMessage(X_ERROR, "config/hal: NewInputDeviceRequest failed (%d)\n", rc);
        dev = NULL;
        goto unwind;
    }

    for (; dev; dev = dev->next){
        if (dev->config_info)
            xfree(dev->config_info);
        dev->config_info = xstrdup(config_info);
    }

unwind:
    if (set)
        libhal_free_property_set(set);
    if (path)
        xfree(path);
    if (driver)
        xfree(driver);
    if (name)
        xfree(name);
    if (config_info)
        xfree(config_info);
    while (!dev && (tmpo = options)) {
        options = tmpo->next;
        xfree(tmpo->key);
        xfree(tmpo->value);
        xfree(tmpo);
    }

    if (xkb_opts.layout)
        xfree(xkb_opts.layout);
    if (xkb_opts.rules)
        xfree(xkb_opts.rules);
    if (xkb_opts.model)
        xfree(xkb_opts.model);
    if (xkb_opts.variant)
        xfree(xkb_opts.variant);
    if (xkb_opts.options)
        xfree(xkb_opts.options);

    dbus_error_free(&error);

    return;
}
Пример #9
0
_X_EXPORT Bool
InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo,
                         BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func)
{
    int	i;
    unsigned int check;
    XkbSrvInfoPtr xkbi;
    XkbDescPtr xkb;
    XkbSrvLedInfoPtr sli;
    XkbChangesRec changes;
    XkbEventCauseRec cause;
    XkbRMLVOSet rmlvo_dflts = { NULL };

    if (dev->key || dev->kbdfeed)
	return FALSE;

    if (!rmlvo)
    {
        rmlvo = &rmlvo_dflts;
        XkbGetRulesDflts(rmlvo);
    }


    memset(&changes, 0, sizeof(changes));
    XkbSetCauseUnknown(&cause);

    dev->key = calloc(1, sizeof(*dev->key));
    if (!dev->key) {
        ErrorF("XKB: Failed to allocate key class\n");
        return FALSE;
    }
    dev->key->sourceid = dev->id;

    dev->kbdfeed = calloc(1, sizeof(*dev->kbdfeed));
    if (!dev->kbdfeed) {
        ErrorF("XKB: Failed to allocate key feedback class\n");
        goto unwind_key;
    }

    xkbi = calloc(1, sizeof(*xkbi));
    if (!xkbi) {
        ErrorF("XKB: Failed to allocate XKB info\n");
        goto unwind_kbdfeed;
    }
    dev->key->xkbInfo = xkbi;

    if (xkb_cached_map && !XkbCompareUsedRMLVO(rmlvo)) {
        XkbFreeKeyboard(xkb_cached_map, XkbAllComponentsMask, TRUE);
        xkb_cached_map = NULL;
    }

    if (xkb_cached_map)
        LogMessageVerb(X_INFO, 4, "XKB: Reusing cached keymap\n");
    else {
        xkb_cached_map = XkbCompileKeymap(dev, rmlvo);
        if (!xkb_cached_map) {
            ErrorF("XKB: Failed to compile keymap\n");
            goto unwind_info;
        }
    }

    xkb = XkbAllocKeyboard();
    if (!xkb) {
        ErrorF("XKB: Failed to allocate keyboard description\n");
        goto unwind_info;
    }

    if (!XkbCopyKeymap(xkb, xkb_cached_map)) {
        ErrorF("XKB: Failed to copy keymap\n");
        goto unwind_desc;
    }
    xkb->defined = xkb_cached_map->defined;
    xkb->flags = xkb_cached_map->flags;
    xkb->device_spec = xkb_cached_map->device_spec;
    xkbi->desc = xkb;

    if (xkb->min_key_code == 0)
        xkb->min_key_code = 8;
    if (xkb->max_key_code == 0)
        xkb->max_key_code = 255;

    i = XkbNumKeys(xkb) / 3 + 1;
    if (XkbAllocClientMap(xkb, XkbAllClientInfoMask, 0) != Success)
        goto unwind_desc;
    if (XkbAllocServerMap(xkb, XkbAllServerInfoMask, i) != Success)
        goto unwind_desc;

    xkbi->dfltPtrDelta = 1;
    xkbi->device = dev;

    XkbInitSemantics(xkb);
    XkbInitNames(xkbi);
    XkbInitRadioGroups(xkbi);

    XkbInitControls(dev, xkbi);

    XkbInitIndicatorMap(xkbi);

    XkbUpdateActions(dev, xkb->min_key_code, XkbNumKeys(xkb), &changes,
                     &check, &cause);

    InitFocusClassDeviceStruct(dev);

    xkbi->kbdProc = ctrl_func;
    dev->kbdfeed->BellProc = bell_func;
    dev->kbdfeed->CtrlProc = XkbDDXKeybdCtrlProc;

    dev->kbdfeed->ctrl = defaultKeyboardControl;
    if (dev->kbdfeed->ctrl.autoRepeat)
        xkb->ctrls->enabled_ctrls |= XkbRepeatKeysMask;

    memcpy(dev->kbdfeed->ctrl.autoRepeats, xkb->ctrls->per_key_repeat,
           XkbPerKeyBitArraySize);

    sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass, XkbDfltXIId, 0);
    if (sli)
	XkbCheckIndicatorMaps(dev, sli, XkbAllIndicatorsMask);
    else
        DebugF("XKB: No indicator feedback in XkbFinishInit!\n");

    dev->kbdfeed->CtrlProc(dev,&dev->kbdfeed->ctrl);

    XkbSetRulesDflts(rmlvo);
    XkbSetRulesUsed(rmlvo);
    XkbFreeRMLVOSet(&rmlvo_dflts, FALSE);

    return TRUE;

unwind_desc:
    XkbFreeKeyboard(xkb, 0, TRUE);
unwind_info:
    free(xkbi);
    dev->key->xkbInfo = NULL;
unwind_kbdfeed:
    free(dev->kbdfeed);
    dev->kbdfeed = NULL;
unwind_key:
    free(dev->key);
    dev->key = NULL;
    return FALSE;
}
Пример #10
0
static void
wscons_add_keyboard(void)
{
    InputAttributes attrs = { };
    DeviceIntPtr dev = NULL;
    InputOption *input_options = NULL;
    char *config_info = NULL;
    int fd, i, rc;
    unsigned int type;
    kbd_t wsenc = 0;

    /* Find keyboard configuration */
    fd = priv_open_device(WSCONS_KBD_DEVICE);
    if (fd == -1) {
        LogMessage(X_ERROR, "wskbd: open %s: %s\n",
                   WSCONS_KBD_DEVICE, strerror(errno));
        return;
    }
    if (ioctl(fd, WSKBDIO_GETENCODING, &wsenc) == -1) {
        LogMessage(X_WARNING, "wskbd: ioctl(WSKBDIO_GETENCODING) "
                   "failed: %s\n", strerror(errno));
        close(fd);
        return;
    }
    if (ioctl(fd, WSKBDIO_GTYPE, &type) == -1) {
        LogMessage(X_WARNING, "wskbd: ioctl(WSKBDIO_GTYPE) "
                   "failed: %s\n", strerror(errno));
        close(fd);
        return;
    }
    close (fd);

    input_options = input_option_new(input_options, "_source", "server/wscons");
    if (input_options == NULL)
        return;

    LogMessage(X_INFO, "config/wscons: checking input device %s\n",
               WSCONS_KBD_DEVICE);
    input_options = input_option_new(input_options, "name", WSCONS_KBD_DEVICE);
    input_options = input_option_new(input_options, "driver", "kbd");

    config_info = Xprintf("wscons:%s", WSCONS_KBD_DEVICE);
    if (!config_info)
        goto unwind;
    if (KB_ENCODING(wsenc) == KB_USER) {
        /* Ignore wscons "user" layout */
        LogMessageVerb(X_INFO, 3, "wskbd: ignoring \"user\" layout\n");
        goto kbd_config_done;
    }
    for (i = 0; kbdenc[i].val; i++)
        if (KB_ENCODING(wsenc) == kbdenc[i].val) {
            LogMessageVerb(X_INFO, 3, "wskbd: using layout %s\n",
                           kbdenc[i].name);
            input_options = input_option_new(input_options,
                                             "xkb_layout", kbdenc[i].name);
            break;
        }
    for (i = 0; kbdvar[i].val; i++)
        if (wsenc == kbdvar[i].val || KB_VARIANT(wsenc) == kbdvar[i].val) {
            LogMessageVerb(X_INFO, 3, "wskbd: using variant %s\n",
                           kbdvar[i].name);
            input_options = input_option_new(input_options,
                                             "xkb_variant", kbdvar[i].name);
            break;
        }
    for (i = 0; kbdopt[i].val; i++)
        if (KB_VARIANT(wsenc) == kbdopt[i].val) {
            LogMessageVerb(X_INFO, 3, "wskbd: using option %s\n",
                           kbdopt[i].name);
            input_options = input_option_new(input_options,
                                             "xkb_options", kbdopt[i].name);
            break;
        }
    for (i = 0; kbdmodel[i].val; i++)
        if (type == kbdmodel[i].val) {
            LogMessageVerb(X_INFO, 3, "wskbd: using model %s\n",
                           kbdmodel[i].name);
            input_options = input_option_new(input_options,
                                             "xkb_model", kbdmodel[i].name);
            break;
        }

 kbd_config_done:
    attrs.flags |= ATTR_KEYBOARD;
    rc = NewInputDeviceRequest(input_options, &attrs, &dev);
    if (rc != Success)
        goto unwind;

    for (; dev; dev = dev->next) {
        free(dev->config_info);
        dev->config_info = strdup(config_info);
    }
 unwind:
    input_option_free_list(&input_options);
}
Пример #11
0
static void
device_added(struct udev_device *udev_device)
{
    const char *path, *name = NULL;
    char *config_info = NULL;
    const char *syspath;
    const char *tags_prop;
    const char *key, *value, *tmp;
    InputOption *options = NULL, *tmpo;
    InputAttributes attrs = {};
    DeviceIntPtr dev = NULL;
    struct udev_list_entry *set, *entry;
    struct udev_device *parent;
    int rc;

    path = udev_device_get_devnode(udev_device);

    syspath = udev_device_get_syspath(udev_device);

    if (!path || !syspath)
        return;

    if (!udev_device_get_property_value(udev_device, "ID_INPUT")) {
        LogMessageVerb(X_INFO, 10,
                       "config/udev: ignoring device %s without "
                       "property ID_INPUT set\n",
                       path);
        return;
    }

    options = calloc(sizeof(*options), 1);
    if (!options)
        return;

    options->key = strdup("_source");
    options->value = strdup("server/udev");
    if (!options->key || !options->value)
        goto unwind;

    parent = udev_device_get_parent(udev_device);
    if (parent) {
        const char *ppath = udev_device_get_devnode(parent);
        const char *product = udev_device_get_property_value(parent, "PRODUCT");
        const char *pnp_id = udev_device_get_sysattr_value(parent, "id");
        unsigned int usb_vendor, usb_model;

        name = udev_device_get_sysattr_value(parent, "name");
        LOG_SYSATTR(ppath, "name", name);
        if (!name) {
            name = udev_device_get_property_value(parent, "NAME");
            LOG_PROPERTY(ppath, "NAME", name);
        }

        if (pnp_id)
            attrs.pnp_id = strdup(pnp_id);
        LOG_SYSATTR(ppath, "id", pnp_id);

        /* construct USB ID in lowercase hex - "0000:ffff" */
        if (product && sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) {
            if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_model)
                == -1)
                attrs.usb_id = NULL;
            else
                LOG_PROPERTY(path, "PRODUCT", product);
        }
    }
    if (!name)
        name = "(unnamed)";
    else
        attrs.product = strdup(name);
    add_option(&options, "name", name);

    add_option(&options, "path", path);
    add_option(&options, "device", path);
    if (path)
        attrs.device = strdup(path);

    tags_prop = udev_device_get_property_value(udev_device, "ID_INPUT.tags");
    LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
    attrs.tags = xstrtokenize(tags_prop, ",");

    if (asprintf(&config_info, "udev:%s", syspath) == -1) {
        config_info = NULL;
        goto unwind;
    }

    if (device_is_duplicate(config_info)) {
        LogMessage(X_WARNING, "config/udev: device %s already added. "
                              "Ignoring.\n", name);
        goto unwind;
    }

    set = udev_device_get_properties_list_entry(udev_device);
    udev_list_entry_foreach(entry, set) {
        key = udev_list_entry_get_name(entry);
        if (!key)
            continue;
        value = udev_list_entry_get_value(entry);
        if (!strncasecmp(key, UDEV_XKB_PROP_KEY,
                                sizeof(UDEV_XKB_PROP_KEY) - 1)) {
            LOG_PROPERTY(path, key, value);
            tmp = key + sizeof(UDEV_XKB_PROP_KEY) - 1;
            if (!strcasecmp(tmp, "rules"))
                add_option(&options, "xkb_rules", value);
            else if (!strcasecmp(tmp, "layout"))
                add_option(&options, "xkb_layout", value);
            else if (!strcasecmp(tmp, "variant"))
                add_option(&options, "xkb_variant", value);
            else if (!strcasecmp(tmp, "model"))
                add_option(&options, "xkb_model", value);
            else if (!strcasecmp(tmp, "options"))
                add_option(&options, "xkb_options", value);
        } else if (!strcmp(key, "ID_VENDOR")) {
            LOG_PROPERTY(path, key, value);
            attrs.vendor = strdup(value);
        } else if (!strcmp(key, "ID_INPUT_KEY")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_KEYBOARD;
        } else if (!strcmp(key, "ID_INPUT_MOUSE")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_POINTER;
        } else if (!strcmp(key, "ID_INPUT_JOYSTICK")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_JOYSTICK;
        } else if (!strcmp(key, "ID_INPUT_TABLET")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_TABLET;
        } else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_TOUCHPAD;
        } else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_TOUCHSCREEN;
        }
    }
Пример #12
0
static int
glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
                                                 GLenum *tex_format,
                                                 GLenum *tex_type,
                                                 int *no_alpha,
                                                 int *revert,
                                                 int *swap_rb, int is_upload)
{
    int need_swap_rb = 0;

    *no_alpha = 0;
    *revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL;

    switch (format) {
    case PICT_b8g8r8x8:
        *no_alpha = 1;
    case PICT_b8g8r8a8:
        *tex_format = GL_RGBA;
        *tex_type = GL_UNSIGNED_BYTE;
        need_swap_rb = 1;
        *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
        break;

    case PICT_x8r8g8b8:
        *no_alpha = 1;
    case PICT_a8r8g8b8:
        *tex_format = GL_RGBA;
        *tex_type = GL_UNSIGNED_BYTE;
        need_swap_rb = 1;
        break;

    case PICT_x8b8g8r8:
        *no_alpha = 1;
    case PICT_a8b8g8r8:
        *tex_format = GL_RGBA;
        *tex_type = GL_UNSIGNED_BYTE;
        break;

    case PICT_x2r10g10b10:
        *no_alpha = 1;
    case PICT_a2r10g10b10:
        *tex_format = GL_RGBA;
        /* glReadPixmap doesn't support GL_UNSIGNED_INT_10_10_10_2.
         * we have to use GL_UNSIGNED_BYTE and do the conversion in
         * shader latter.*/
        *tex_type = GL_UNSIGNED_BYTE;
        if (is_upload == 1) {
            if (!IS_LITTLE_ENDIAN)
                *revert = REVERT_UPLOADING_10_10_10_2;
            else
                *revert = REVERT_UPLOADING_2_10_10_10;
        }
        else {
            if (!IS_LITTLE_ENDIAN) {
                *revert = REVERT_DOWNLOADING_10_10_10_2;
            }
            else {
                *revert = REVERT_DOWNLOADING_2_10_10_10;
            }
        }
        need_swap_rb = 1;

        break;

    case PICT_x2b10g10r10:
        *no_alpha = 1;
    case PICT_a2b10g10r10:
        *tex_format = GL_RGBA;
        *tex_type = GL_UNSIGNED_BYTE;
        if (is_upload == 1) {
            if (!IS_LITTLE_ENDIAN)
                *revert = REVERT_UPLOADING_10_10_10_2;
            else
                *revert = REVERT_UPLOADING_2_10_10_10;
        }
        else {
            if (!IS_LITTLE_ENDIAN) {
                *revert = REVERT_DOWNLOADING_10_10_10_2;
            }
            else {
                *revert = REVERT_DOWNLOADING_2_10_10_10;
            }
        }
        break;

    case PICT_r5g6b5:
        *tex_format = GL_RGB;
        *tex_type = GL_UNSIGNED_SHORT_5_6_5;
        *revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL;

        break;

    case PICT_b5g6r5:
        *tex_format = GL_RGB;
        *tex_type = GL_UNSIGNED_SHORT_5_6_5;
        need_swap_rb = IS_LITTLE_ENDIAN ? 1 : 0;;
        break;

    case PICT_x1b5g5r5:
        *no_alpha = 1;
    case PICT_a1b5g5r5:
        *tex_format = GL_RGBA;
        *tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
        if (IS_LITTLE_ENDIAN) {
            *revert =
                is_upload ? REVERT_UPLOADING_1_5_5_5 :
                REVERT_DOWNLOADING_1_5_5_5;
        }
        else
            *revert = REVERT_NONE;
        break;

    case PICT_x1r5g5b5:
        *no_alpha = 1;
    case PICT_a1r5g5b5:
        *tex_format = GL_RGBA;
        *tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
        if (IS_LITTLE_ENDIAN) {
            *revert =
                is_upload ? REVERT_UPLOADING_1_5_5_5 :
                REVERT_DOWNLOADING_1_5_5_5;
        }
        else
            *revert = REVERT_NONE;
        need_swap_rb = 1;
        break;

    case PICT_a1:
        *tex_format = GL_ALPHA;
        *tex_type = GL_UNSIGNED_BYTE;
        *revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
        break;

    case PICT_a8:
        *tex_format = GL_ALPHA;
        *tex_type = GL_UNSIGNED_BYTE;
        *revert = REVERT_NONE;
        break;

    case PICT_x4r4g4b4:
        *no_alpha = 1;
    case PICT_a4r4g4b4:
        *tex_format = GL_RGBA;
        *tex_type = GL_UNSIGNED_SHORT_4_4_4_4;
        *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
        need_swap_rb = 1;
        break;

    case PICT_x4b4g4r4:
        *no_alpha = 1;
    case PICT_a4b4g4r4:
        *tex_format = GL_RGBA;
        *tex_type = GL_UNSIGNED_SHORT_4_4_4_4;
        *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
        break;

    default:
        LogMessageVerb(X_INFO, 0,
                       "fail to get matched format for %x \n", format);
        return -1;
    }

    if (need_swap_rb)
        *swap_rb = is_upload ? SWAP_UPLOADING : SWAP_DOWNLOADING;
    else
        *swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING;
    return 0;
}
Пример #13
0
static void
device_added(struct udev_device *udev_device)
{
    const char *path, *name = NULL;
    char *config_info = NULL;
    const char *syspath;
    const char *tags_prop;
    const char *key, *value, *tmp;
    InputOption *input_options;
    InputAttributes attrs = { };
    DeviceIntPtr dev = NULL;
    struct udev_list_entry *set, *entry;
    struct udev_device *parent;
    int rc;
    const char *dev_seat;

    path = udev_device_get_devnode(udev_device);

    syspath = udev_device_get_syspath(udev_device);

    if (!path || !syspath)
        return;

    dev_seat = udev_device_get_property_value(udev_device, "ID_SEAT");
    if (!dev_seat)
        dev_seat = "seat0";

    if (SeatId && strcmp(dev_seat, SeatId))
        return;

    if (!SeatId && strcmp(dev_seat, "seat0"))
        return;

#ifdef CONFIG_UDEV_KMS
    if (!strcmp(udev_device_get_subsystem(udev_device), "drm")) {
        const char *sysname = udev_device_get_sysname(udev_device);

        if (strncmp(sysname, "card", 4) != 0)
            return;

        LogMessage(X_INFO, "config/udev: Adding drm device (%s)\n", path);

        config_udev_odev_setup_attribs(path, syspath, NewGPUDeviceRequest);
        return;
    }
#endif

    if (!udev_device_get_property_value(udev_device, "ID_INPUT")) {
        LogMessageVerb(X_INFO, 10,
                       "config/udev: ignoring device %s without "
                       "property ID_INPUT set\n", path);
        return;
    }

    input_options = input_option_new(NULL, "_source", "server/udev");
    if (!input_options)
        return;

    parent = udev_device_get_parent(udev_device);
    if (parent) {
        const char *ppath = udev_device_get_devnode(parent);
        const char *product = udev_device_get_property_value(parent, "PRODUCT");
        const char *pnp_id = udev_device_get_sysattr_value(parent, "id");
        unsigned int usb_vendor, usb_model;

        name = udev_device_get_sysattr_value(parent, "name");
        LOG_SYSATTR(ppath, "name", name);
        if (!name) {
            name = udev_device_get_property_value(parent, "NAME");
            LOG_PROPERTY(ppath, "NAME", name);
        }

        /* construct USB ID in lowercase hex - "0000:ffff" */
        if (product &&
            sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) {
            if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_model)
                == -1)
                attrs.usb_id = NULL;
            else
                LOG_PROPERTY(ppath, "PRODUCT", product);
        }

        while (!pnp_id && (parent = udev_device_get_parent(parent))) {
            pnp_id = udev_device_get_sysattr_value(parent, "id");
            if (!pnp_id)
                continue;

            attrs.pnp_id = strdup(pnp_id);
            ppath = udev_device_get_devnode(parent);
            LOG_SYSATTR(ppath, "id", pnp_id);
        }

    }
    if (!name)
        name = "(unnamed)";
    else
        attrs.product = strdup(name);
    input_options = input_option_new(input_options, "name", name);
    input_options = input_option_new(input_options, "path", path);
    input_options = input_option_new(input_options, "device", path);
    if (path)
        attrs.device = strdup(path);

    tags_prop = udev_device_get_property_value(udev_device, "ID_INPUT.tags");
    LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
    attrs.tags = xstrtokenize(tags_prop, ",");

    if (asprintf(&config_info, "udev:%s", syspath) == -1) {
        config_info = NULL;
        goto unwind;
    }

    if (device_is_duplicate(config_info)) {
        LogMessage(X_WARNING, "config/udev: device %s already added. "
                   "Ignoring.\n", name);
        goto unwind;
    }

    set = udev_device_get_properties_list_entry(udev_device);
    udev_list_entry_foreach(entry, set) {
        key = udev_list_entry_get_name(entry);
        if (!key)
            continue;
        value = udev_list_entry_get_value(entry);
        if (!strncasecmp(key, UDEV_XKB_PROP_KEY, sizeof(UDEV_XKB_PROP_KEY) - 1)) {
            LOG_PROPERTY(path, key, value);
            tmp = key + sizeof(UDEV_XKB_PROP_KEY) - 1;
            if (!strcasecmp(tmp, "rules"))
                input_options =
                    input_option_new(input_options, "xkb_rules", value);
            else if (!strcasecmp(tmp, "layout"))
                input_options =
                    input_option_new(input_options, "xkb_layout", value);
            else if (!strcasecmp(tmp, "variant"))
                input_options =
                    input_option_new(input_options, "xkb_variant", value);
            else if (!strcasecmp(tmp, "model"))
                input_options =
                    input_option_new(input_options, "xkb_model", value);
            else if (!strcasecmp(tmp, "options"))
                input_options =
                    input_option_new(input_options, "xkb_options", value);
        }
        else if (!strcmp(key, "ID_VENDOR")) {
            LOG_PROPERTY(path, key, value);
            attrs.vendor = strdup(value);
        }
        else if (!strcmp(key, "ID_INPUT_KEY")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_KEYBOARD;
        }
        else if (!strcmp(key, "ID_INPUT_MOUSE")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_POINTER;
        }
        else if (!strcmp(key, "ID_INPUT_JOYSTICK")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_JOYSTICK;
        }
        else if (!strcmp(key, "ID_INPUT_TABLET")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_TABLET;
        }
        else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_TOUCHPAD;
        }
        else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
            LOG_PROPERTY(path, key, value);
            attrs.flags |= ATTR_TOUCHSCREEN;
        }
    }