2 * Copyright © 2006-2007 Daniel Stone
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Author: Daniel Stone <daniel@fooishbar.org>
26 #ifdef HAVE_DIX_CONFIG_H
27 #include <dix-config.h>
33 #include "config-backends.h"
39 if (!config_udev_pre_init())
40 ErrorF("[config] failed to pre-init udev\n");
48 if (!config_udev_init())
49 ErrorF("[config] failed to initialise udev\n");
50 #elif defined(CONFIG_NEED_DBUS)
51 if (config_dbus_core_init()) {
52 #ifdef CONFIG_DBUS_API
53 if (!config_dbus_init())
54 ErrorF("[config] failed to initialise D-Bus API\n");
57 if (!config_hal_init())
58 ErrorF("[config] failed to initialise HAL\n");
62 ErrorF("[config] failed to initialise D-Bus core\n");
64 #elif defined(CONFIG_WSCONS)
65 if (!config_wscons_init())
66 ErrorF("[config] failed to initialise wscons\n");
73 #if defined(CONFIG_UDEV)
75 #elif defined(CONFIG_NEED_DBUS)
79 #ifdef CONFIG_DBUS_API
82 config_dbus_core_fini();
83 #elif defined(CONFIG_WSCONS)
89 config_odev_probe(config_odev_probe_proc_ptr probe_callback
)
91 #if defined(CONFIG_UDEV_KMS)
92 config_udev_odev_probe(probe_callback
);
97 remove_device(const char *backend
, DeviceIntPtr dev
)
99 /* this only gets called for devices that have already been added */
100 LogMessage(X_INFO
, "config/%s: removing device %s\n", backend
, dev
->name
);
102 /* Call PIE here so we don't try to dereference a device that's
103 * already been removed. */
105 ProcessInputEvents();
106 DeleteInputDeviceRequest(dev
);
111 remove_devices(const char *backend
, const char *config_info
)
113 DeviceIntPtr dev
, next
;
115 for (dev
= inputInfo
.devices
; dev
; dev
= next
) {
117 if (dev
->config_info
&& strcmp(dev
->config_info
, config_info
) == 0)
118 remove_device(backend
, dev
);
120 for (dev
= inputInfo
.off_devices
; dev
; dev
= next
) {
122 if (dev
->config_info
&& strcmp(dev
->config_info
, config_info
) == 0)
123 remove_device(backend
, dev
);
128 device_is_duplicate(const char *config_info
)
132 for (dev
= inputInfo
.devices
; dev
; dev
= dev
->next
) {
133 if (dev
->config_info
&& (strcmp(dev
->config_info
, config_info
) == 0))
137 for (dev
= inputInfo
.off_devices
; dev
; dev
= dev
->next
) {
138 if (dev
->config_info
&& (strcmp(dev
->config_info
, config_info
) == 0))
145 struct OdevAttributes
*
146 config_odev_allocate_attribute_list(void)
148 struct OdevAttributes
*attriblist
;
150 attriblist
= malloc(sizeof(struct OdevAttributes
));
154 xorg_list_init(&attriblist
->list
);
159 config_odev_free_attribute_list(struct OdevAttributes
*attribs
)
161 config_odev_free_attributes(attribs
);
166 config_odev_add_attribute(struct OdevAttributes
*attribs
, int attrib
,
167 const char *attrib_name
)
169 struct OdevAttribute
*oa
;
171 oa
= malloc(sizeof(struct OdevAttribute
));
175 oa
->attrib_id
= attrib
;
176 oa
->attrib_name
= strdup(attrib_name
);
177 xorg_list_append(&oa
->member
, &attribs
->list
);
182 config_odev_free_attributes(struct OdevAttributes
*attribs
)
184 struct OdevAttribute
*iter
, *safe
;
186 xorg_list_for_each_entry_safe(iter
, safe
, &attribs
->list
, member
) {
187 xorg_list_del(&iter
->member
);
188 free(iter
->attrib_name
);