diff options
author | marha <marha@users.sourceforge.net> | 2012-07-09 08:08:20 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-07-09 08:08:20 +0200 |
commit | c29d91cfd8df084f16d0d2dfa82c3a86f7719a73 (patch) | |
tree | f0ac6c2a9f9da0ce818aa4fc04a1be6e8121962f /xorg-server/config | |
parent | 336bad93d146931c160d8517edfdf0bee49ad9f7 (diff) | |
download | vcxsrv-c29d91cfd8df084f16d0d2dfa82c3a86f7719a73.tar.gz vcxsrv-c29d91cfd8df084f16d0d2dfa82c3a86f7719a73.tar.bz2 vcxsrv-c29d91cfd8df084f16d0d2dfa82c3a86f7719a73.zip |
fontconfig libX11 mesa pixman xserver git update 9 Jul 2012
Diffstat (limited to 'xorg-server/config')
-rw-r--r-- | xorg-server/config/config-backends.h | 1 | ||||
-rw-r--r-- | xorg-server/config/config.c | 56 | ||||
-rw-r--r-- | xorg-server/config/udev.c | 111 |
3 files changed, 168 insertions, 0 deletions
diff --git a/xorg-server/config/config-backends.h b/xorg-server/config/config-backends.h index 62abc0a5f..6423701fc 100644 --- a/xorg-server/config/config-backends.h +++ b/xorg-server/config/config-backends.h @@ -36,6 +36,7 @@ BOOL device_is_duplicate(const char *config_info); int config_udev_pre_init(void); int config_udev_init(void); void config_udev_fini(void); +void config_udev_odev_probe(config_odev_probe_proc_ptr probe_callback); #else #ifdef CONFIG_NEED_DBUS diff --git a/xorg-server/config/config.c b/xorg-server/config/config.c index 24e7ba7a0..d0889a394 100644 --- a/xorg-server/config/config.c +++ b/xorg-server/config/config.c @@ -85,6 +85,14 @@ config_fini(void) #endif } +void +config_odev_probe(config_odev_probe_proc_ptr probe_callback) +{ +#if defined(CONFIG_UDEV_KMS) + config_udev_odev_probe(probe_callback); +#endif +} + static void remove_device(const char *backend, DeviceIntPtr dev) { @@ -133,3 +141,51 @@ device_is_duplicate(const char *config_info) return FALSE; } + +struct OdevAttributes * +config_odev_allocate_attribute_list(void) +{ + struct OdevAttributes *attriblist; + + attriblist = malloc(sizeof(struct OdevAttributes)); + if (!attriblist) + return NULL; + + xorg_list_init(&attriblist->list); + return attriblist; +} + +void +config_odev_free_attribute_list(struct OdevAttributes *attribs) +{ + config_odev_free_attributes(attribs); + free(attribs); +} + +Bool +config_odev_add_attribute(struct OdevAttributes *attribs, int attrib, + const char *attrib_name) +{ + struct OdevAttribute *oa; + + oa = malloc(sizeof(struct OdevAttribute)); + if (!oa) + return FALSE; + + oa->attrib_id = attrib; + oa->attrib_name = strdup(attrib_name); + xorg_list_append(&oa->member, &attribs->list); + return TRUE; +} + +void +config_odev_free_attributes(struct OdevAttributes *attribs) +{ + struct OdevAttribute *iter, *safe; + + xorg_list_for_each_entry_safe(iter, safe, &attribs->list, member) { + xorg_list_del(&iter->member); + free(iter->attrib_name); + free(iter); + } +} diff --git a/xorg-server/config/udev.c b/xorg-server/config/udev.c index 1995184f3..5297b9009 100644 --- a/xorg-server/config/udev.c +++ b/xorg-server/config/udev.c @@ -52,6 +52,12 @@ static struct udev_monitor *udev_monitor; +#ifdef CONFIG_UDEV_KMS +static Bool +config_udev_odev_setup_attribs(const char *path, const char *syspath, + config_odev_probe_proc_ptr probe_callback); +#endif + static void device_added(struct udev_device *udev_device) { @@ -85,6 +91,20 @@ device_added(struct udev_device *udev_device) 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 " @@ -240,6 +260,22 @@ device_removed(struct udev_device *device) char *value; const char *syspath = udev_device_get_syspath(device); +#ifdef CONFIG_UDEV_KMS + if (!strcmp(udev_device_get_subsystem(device), "drm")) { + const char *sysname = udev_device_get_sysname(device); + const char *path = udev_device_get_devnode(device); + + if (strncmp(sysname,"card", 4) != 0) + return; + ErrorF("removing GPU device %s %d\n", syspath, path); + if (!path) + return; + + config_udev_odev_setup_attribs(path, syspath, DeleteGPUDeviceRequest); + return; + } +#endif + if (asprintf(&value, "udev:%s", syspath) == -1) return; @@ -296,6 +332,9 @@ config_udev_pre_init(void) udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "input", NULL); udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "tty", NULL); /* For Wacom serial devices */ +#ifdef CONFIG_UDEV_KMS + udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "drm", NULL); /* For output GPU devices */ +#endif #ifdef HAVE_UDEV_MONITOR_FILTER_ADD_MATCH_TAG if (SeatId && strcmp(SeatId, "seat0")) @@ -322,6 +361,9 @@ config_udev_init(void) udev_enumerate_add_match_subsystem(enumerate, "input"); udev_enumerate_add_match_subsystem(enumerate, "tty"); +#ifdef CONFIG_UDEV_KMS + udev_enumerate_add_match_subsystem(enumerate, "drm"); +#endif #ifdef HAVE_UDEV_ENUMERATE_ADD_MATCH_TAG if (SeatId && strcmp(SeatId, "seat0")) @@ -366,3 +408,72 @@ config_udev_fini(void) udev_monitor = NULL; udev_unref(udev); } + +#ifdef CONFIG_UDEV_KMS + +static Bool +config_udev_odev_setup_attribs(const char *path, const char *syspath, + config_odev_probe_proc_ptr probe_callback) +{ + struct OdevAttributes *attribs = config_odev_allocate_attribute_list(); + int ret; + + if (!attribs) + return FALSE; + + ret = config_odev_add_attribute(attribs, ODEV_ATTRIB_PATH, path); + if (ret == FALSE) + goto fail; + + ret = config_odev_add_attribute(attribs, ODEV_ATTRIB_SYSPATH, syspath); + if (ret == FALSE) + goto fail; + + /* ownership of attribs is passed to probe layer */ + probe_callback(attribs); + return TRUE; +fail: + config_odev_free_attributes(attribs); + free(attribs); + return FALSE; +} + +void +config_udev_odev_probe(config_odev_probe_proc_ptr probe_callback) +{ + struct udev *udev; + struct udev_enumerate *enumerate; + struct udev_list_entry *devices, *device; + + udev = udev_monitor_get_udev(udev_monitor); + enumerate = udev_enumerate_new(udev); + if (!enumerate) + return; + + udev_enumerate_add_match_subsystem(enumerate, "drm"); + udev_enumerate_add_match_sysname(enumerate, "card[0-9]*"); + udev_enumerate_scan_devices(enumerate); + devices = udev_enumerate_get_list_entry(enumerate); + udev_list_entry_foreach(device, devices) { + const char *syspath = udev_list_entry_get_name(device); + struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath); + const char *path = udev_device_get_devnode(udev_device); + const char *sysname = udev_device_get_sysname(udev_device); + + if (!path || !syspath) + goto no_probe; + else if (strcmp(udev_device_get_subsystem(udev_device), "drm") != 0) + goto no_probe; + else if (strncmp(sysname, "card", 4) != 0) + goto no_probe; + + config_udev_odev_setup_attribs(path, syspath, probe_callback); + + no_probe: + udev_device_unref(udev_device); + } + udev_enumerate_unref(enumerate); + return; +} +#endif + |