diff --git a/gdk/gdkdmabuf.c b/gdk/gdkdmabuf.c index 7805a10ab2..8546a2e8f8 100644 --- a/gdk/gdkdmabuf.c +++ b/gdk/gdkdmabuf.c @@ -741,7 +741,7 @@ gdk_dmabuf_direct_downloader_do_download (const GdkDmabufDownloader *downloader, /* be a good citizen and seek back to the start, as the docs recommend */ lseek (dmabuf->planes[i].fd, 0, SEEK_SET); - if (ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_START|DMA_BUF_SYNC_READ }) < 0) + if (gdk_dmabuf_ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_START|DMA_BUF_SYNC_READ }) < 0) g_warning ("Failed to sync dmabuf: %s", g_strerror (errno)); src_data[i] = mmap (NULL, sizes[i], PROT_READ, MAP_SHARED, dmabuf->planes[i].fd, dmabuf->planes[i].offset); @@ -770,7 +770,7 @@ out: munmap ((void *)src_data[i], sizes[i]); - if (ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_END|DMA_BUF_SYNC_READ }) < 0) + if (gdk_dmabuf_ioctl (dmabuf->planes[i].fd, DMA_BUF_IOCTL_SYNC, &(struct dma_buf_sync) { DMA_BUF_SYNC_END|DMA_BUF_SYNC_READ }) < 0) g_warning ("Failed to sync dmabuf: %s", g_strerror (errno)); } } @@ -821,6 +821,20 @@ gdk_dmabuf_get_direct_downloader (void) return &downloader; } +int +gdk_dmabuf_ioctl (int fd, + unsigned long request, + void *arg) +{ + int ret; + + do { + ret = ioctl (fd, request, arg); + } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); + + return ret; +} + /* * Tries to sanitize the dmabuf to conform to the values expected * by Vulkan/EGL which should also be the values expected by diff --git a/gdk/gdkdmabufprivate.h b/gdk/gdkdmabufprivate.h index 8ac8e42941..c5375c4824 100644 --- a/gdk/gdkdmabufprivate.h +++ b/gdk/gdkdmabufprivate.h @@ -43,6 +43,10 @@ struct _GdkDmabufDownloader const GdkDmabufDownloader * gdk_dmabuf_get_direct_downloader (void) G_GNUC_CONST; const GdkDmabufDownloader * gdk_dmabuf_get_egl_downloader (void) G_GNUC_CONST; +int gdk_dmabuf_ioctl (int fd, + unsigned long request, + void *arg); + gboolean gdk_dmabuf_sanitize (GdkDmabuf *dest, gsize width, gsize height,