backend/drm: add wlr_drm_backend.name

Save the DRM device name in a wlr_drm_backend field, so that we can
easily use it for logging purposes.
master
Simon Ser 4 years ago
parent 60001a75a2
commit 9cd3f03f65
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -50,6 +50,8 @@ static void backend_destroy(struct wlr_backend *backend) {
finish_drm_resources(drm); finish_drm_resources(drm);
finish_drm_renderer(&drm->renderer); finish_drm_renderer(&drm->renderer);
free(drm->name);
wlr_session_close_file(drm->session, drm->dev); wlr_session_close_file(drm->session, drm->dev);
wl_event_source_remove(drm->drm_event); wl_event_source_remove(drm->drm_event);
free(drm); free(drm);
@ -108,9 +110,7 @@ static void drm_invalidated(struct wl_listener *listener, void *data) {
struct wlr_drm_backend *drm = struct wlr_drm_backend *drm =
wl_container_of(listener, drm, drm_invalidated); wl_container_of(listener, drm, drm_invalidated);
char *name = drmGetDeviceNameFromFd2(drm->fd); wlr_log(WLR_DEBUG, "%s invalidated", drm->name);
wlr_log(WLR_DEBUG, "%s invalidated", name);
free(name);
scan_drm_connectors(drm); scan_drm_connectors(drm);
} }
@ -137,7 +137,6 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
char *name = drmGetDeviceNameFromFd2(dev->fd); char *name = drmGetDeviceNameFromFd2(dev->fd);
drmVersion *version = drmGetVersion(dev->fd); drmVersion *version = drmGetVersion(dev->fd);
wlr_log(WLR_INFO, "Initializing DRM backend for %s (%s)", name, version->name); wlr_log(WLR_INFO, "Initializing DRM backend for %s (%s)", name, version->name);
free(name);
drmFreeVersion(version); drmFreeVersion(version);
struct wlr_drm_backend *drm = calloc(1, sizeof(struct wlr_drm_backend)); struct wlr_drm_backend *drm = calloc(1, sizeof(struct wlr_drm_backend));
@ -152,6 +151,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
drm->dev = dev; drm->dev = dev;
drm->fd = dev->fd; drm->fd = dev->fd;
drm->name = name;
if (parent != NULL) { if (parent != NULL) {
drm->parent = get_drm_backend_from_backend(parent); drm->parent = get_drm_backend_from_backend(parent);
} }

@ -75,6 +75,7 @@ struct wlr_drm_backend {
bool addfb2_modifiers; bool addfb2_modifiers;
int fd; int fd;
char *name;
struct wlr_device *dev; struct wlr_device *dev;
size_t num_crtcs; size_t num_crtcs;

Loading…
Cancel
Save