|
|
|
|
@ -19,9 +19,13 @@ |
|
|
|
|
#include <cerrno> |
|
|
|
|
// drm
|
|
|
|
|
#include <drm_fourcc.h> |
|
|
|
|
#include <sys/ioctl.h> |
|
|
|
|
#include <unistd.h> |
|
|
|
|
#include <xf86drm.h> |
|
|
|
|
#include <xf86drmMode.h> |
|
|
|
|
#ifdef Q_OS_LINUX |
|
|
|
|
#include <linux/dma-buf.h> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifndef DRM_IOCTL_MODE_CLOSEFB |
|
|
|
|
#define DRM_IOCTL_MODE_CLOSEFB 0xD0 |
|
|
|
|
@ -42,6 +46,16 @@ DrmFramebuffer::DrmFramebuffer(DrmGpu *gpu, uint32_t fbId, GraphicsBuffer *buffe |
|
|
|
|
// buffer readability checks cause frames to be wrongly delayed on some Intel laptops
|
|
|
|
|
// See https://gitlab.freedesktop.org/drm/intel/-/issues/9415
|
|
|
|
|
m_readable = true; |
|
|
|
|
} else { |
|
|
|
|
#ifdef Q_OS_LINUX |
|
|
|
|
dma_buf_export_sync_file req{ |
|
|
|
|
.flags = DMA_BUF_SYNC_READ, |
|
|
|
|
.fd = -1, |
|
|
|
|
}; |
|
|
|
|
if (drmIoctl(buffer->dmabufAttributes()->fd[0].get(), DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &req) == 0) { |
|
|
|
|
m_syncFd = FileDescriptor{req.fd}; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -68,10 +82,17 @@ void DrmFramebuffer::releaseBuffer() |
|
|
|
|
m_bufferRef = nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const FileDescriptor &DrmFramebuffer::syncFd() const |
|
|
|
|
{ |
|
|
|
|
return m_syncFd; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool DrmFramebuffer::isReadable() |
|
|
|
|
{ |
|
|
|
|
if (m_readable) { |
|
|
|
|
return true; |
|
|
|
|
} else if (m_syncFd.isValid()) { |
|
|
|
|
return m_readable = m_syncFd.isReadable(); |
|
|
|
|
} else { |
|
|
|
|
const auto &fds = m_bufferRef->dmabufAttributes()->fd; |
|
|
|
|
return m_readable = std::all_of(fds.begin(), fds.end(), [](const auto &fd) { |
|
|
|
|
|