drm-timeline: Add meta_drm_timeline_create_syncobj
Creates a kernel syncobj and returns a file descriptor representing it. v2: * Call drmSyncobjDestroy also after drmSyncobjHandleToFD returns 0, or we leak the original syncobj reference. (Sebastian Wick) * Add errno based error messages. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3876>
This commit is contained in:
parent
fcf1a5163d
commit
12d12eb278
2 changed files with 34 additions and 0 deletions
|
@ -141,6 +141,37 @@ initable_iface_init (GInitableIface *initable_iface)
|
|||
initable_iface->init = meta_drm_timeline_initable_init;
|
||||
}
|
||||
|
||||
int
|
||||
meta_drm_timeline_create_syncobj (int drm_fd,
|
||||
GError **error)
|
||||
{
|
||||
uint32_t syncobj_handle;
|
||||
int syncobj_fd;
|
||||
|
||||
if (drmSyncobjCreate (drm_fd, 0, &syncobj_handle))
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
"drmSyncobjCreate failed: %s",
|
||||
g_strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (drmSyncobjHandleToFD (drm_fd, syncobj_handle, &syncobj_fd) < 0)
|
||||
{
|
||||
syncobj_fd = -1;
|
||||
g_set_error (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
"drmSyncobjHandleToFD failed: %s",
|
||||
g_strerror (errno));
|
||||
}
|
||||
|
||||
drmSyncobjDestroy (drm_fd, syncobj_handle);
|
||||
return syncobj_fd;
|
||||
}
|
||||
|
||||
MetaDrmTimeline *
|
||||
meta_drm_timeline_import_syncobj (int fd,
|
||||
int drm_syncobj,
|
||||
|
|
|
@ -30,6 +30,9 @@ G_DECLARE_FINAL_TYPE (MetaDrmTimeline, meta_drm_timeline,
|
|||
|
||||
typedef struct _MetaDrmTimeline MetaDrmTimeline;
|
||||
|
||||
int meta_drm_timeline_create_syncobj (int fd,
|
||||
GError **error);
|
||||
|
||||
MetaDrmTimeline * meta_drm_timeline_import_syncobj (int fd,
|
||||
int drm_syncobj,
|
||||
GError **error);
|
||||
|
|
Loading…
Add table
Reference in a new issue