diff options
author | Scott Anderson <ascent12@hotmail.com> | 2017-06-03 15:47:33 +1200 |
---|---|---|
committer | Scott Anderson <ascent12@hotmail.com> | 2017-06-03 15:47:33 +1200 |
commit | de44994dfcd433afbbf6d867a8dc6f4d0979b2f6 (patch) | |
tree | 85d0e81f7b1f04ef45e8e3eb640ac5a64dd53b9e /backend | |
parent | 40b85d992a0a8dcdbff5305e232fbcd26d873148 (diff) |
Udev event device matching
Diffstat (limited to 'backend')
-rw-r--r-- | backend/drm/backend.c | 23 | ||||
-rw-r--r-- | backend/drm/drm.c | 1 | ||||
-rw-r--r-- | backend/udev.c | 15 |
3 files changed, 22 insertions, 17 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c index bceb2184..73ccf413 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -5,6 +5,7 @@ #include <errno.h> #include <assert.h> #include <wayland-server.h> +#include <xf86drm.h> #include <sys/stat.h> #include <wlr/session.h> #include <wlr/types.h> @@ -30,7 +31,6 @@ static void wlr_drm_backend_destroy(struct wlr_backend_state *state) { } wlr_drm_renderer_free(&state->renderer); wlr_session_close_file(state->session, state->fd); - wlr_session_finish(state->session); wl_event_source_remove(state->drm_event); free(state); } @@ -73,14 +73,31 @@ static void device_resumed(struct wl_listener *listener, void *data) { } } -static void drm_invalidated(struct wl_listener *listener, void *state) { +static void drm_invalidated(struct wl_listener *listener, void *data) { struct wlr_backend_state *drm = wl_container_of(listener, drm, drm_invalidated); - wlr_drm_scan_connectors(drm); + dev_t *dev = data; + + if (drm->dev == *dev) { + char *name = drmGetDeviceNameFromFd2(drm->fd); + wlr_log(L_DEBUG, "%s invalidated", name); + free(name); + + wlr_drm_scan_connectors(drm); + } } struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, struct wlr_session *session, struct wlr_udev *udev, int gpu_fd) { assert(display && session && gpu_fd > 0); + + char *name = drmGetDeviceNameFromFd2(gpu_fd); + drmVersion *version = drmGetVersion(gpu_fd); + + wlr_log(L_INFO, "Initalizing DRM backend for %s (%s)", name, version->name); + + free(name); + drmFreeVersion(version); + struct wlr_backend_state *state = calloc(1, sizeof(struct wlr_backend_state)); if (!state) { wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 483c923c..27a5932f 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -276,7 +276,6 @@ static void wlr_drm_output_enable(struct wlr_output_state *output, bool enable) static void wlr_drm_output_destroy(struct wlr_output_state *output) { wlr_drm_output_cleanup(output, true); - wlr_drm_renderer_free(output->renderer); free(output); } diff --git a/backend/udev.c b/backend/udev.c index 30c24e49..f9577c12 100644 --- a/backend/udev.c +++ b/backend/udev.c @@ -73,7 +73,6 @@ int wlr_udev_find_gpu(struct wlr_udev *udev, struct wlr_session *session) { struct udev_list_entry *entry; int fd = -1; - char *drm_path = NULL; udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(en)) { bool is_boot_vga = false; @@ -117,9 +116,6 @@ int wlr_udev_find_gpu(struct wlr_udev *udev, struct wlr_session *session) { continue; } - free(drm_path); - drm_path = strdup(path); - udev_device_unref(dev); // We've found the primary GPU @@ -130,7 +126,6 @@ int wlr_udev_find_gpu(struct wlr_udev *udev, struct wlr_session *session) { udev_enumerate_unref(en); - udev->drm_path = drm_path; return fd; } @@ -143,21 +138,16 @@ static int udev_event(int fd, uint32_t mask, void *data) { } const char *action = udev_device_get_action(dev); - const char *path = udev_device_get_devnode(dev); wlr_log(L_DEBUG, "udev event for %s (%s)", udev_device_get_sysname(dev), action); - if (!path || strcmp(path, udev->drm_path) != 0) { - goto out; - } - if (!action || strcmp(action, "change") != 0) { goto out; } - // TODO: Specify the GPU that's being invalidated - wl_signal_emit(&udev->invalidate_drm, udev); + dev_t devnum = udev_device_get_devnum(dev); + wl_signal_emit(&udev->invalidate_drm, &devnum); out: udev_device_unref(dev); @@ -216,5 +206,4 @@ void wlr_udev_destroy(struct wlr_udev *udev) { udev_monitor_unref(udev->mon); udev_unref(udev->udev); - free(udev->drm_path); } |