From edb867bc051878eccbca4a46ee2d5db0b5cdf393 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 27 Feb 2024 18:38:12 +0100 Subject: [PATCH] render/drm_syncobj: add wlr_drm_syncobj_timeline_export() --- include/wlr/render/drm_syncobj.h | 4 ++++ render/drm_syncobj.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/include/wlr/render/drm_syncobj.h b/include/wlr/render/drm_syncobj.h index 232c13a0..bf406d87 100644 --- a/include/wlr/render/drm_syncobj.h +++ b/include/wlr/render/drm_syncobj.h @@ -62,6 +62,10 @@ struct wlr_drm_syncobj_timeline *wlr_drm_syncobj_timeline_ref(struct wlr_drm_syn * Unreference a synchronization timeline. */ void wlr_drm_syncobj_timeline_unref(struct wlr_drm_syncobj_timeline *timeline); +/** + * Export a drm_syncobj FD from a timeline. + */ +int wlr_drm_syncobj_timeline_export(struct wlr_drm_syncobj_timeline *timeline); /** * Transfer a point from a timeline to another. * diff --git a/render/drm_syncobj.c b/render/drm_syncobj.c index a612e20f..f7120df3 100644 --- a/render/drm_syncobj.c +++ b/render/drm_syncobj.c @@ -67,6 +67,15 @@ void wlr_drm_syncobj_timeline_unref(struct wlr_drm_syncobj_timeline *timeline) { free(timeline); } +int wlr_drm_syncobj_timeline_export(struct wlr_drm_syncobj_timeline *timeline) { + int drm_syncobj_fd = -1; + if (drmSyncobjHandleToFD(timeline->drm_fd, timeline->handle, &drm_syncobj_fd) != 0) { + wlr_log_errno(WLR_ERROR, "drmSyncobjHandleToFD failed"); + return -1; + } + return drm_syncobj_fd; +} + bool wlr_drm_syncobj_timeline_transfer(struct wlr_drm_syncobj_timeline *dst, uint64_t dst_point, struct wlr_drm_syncobj_timeline *src, uint64_t src_point) { assert(dst->drm_fd == src->drm_fd);