[platforms/drm] Add better warnings in DrmBuffer if things fail

For virtual machines with Cirrus device the drmModeAddFB fails. So
far there was no error message at all, we only saw it failed.

With this change the drmModeAddFB is checked for error and a warning
is shown. Also further debug messages are added for other cases where
things can fail.

Reviewed-By: Eike Hein
This commit is contained in:
Martin Gräßlin 2016-07-15 08:34:06 +02:00
parent f0aeda0738
commit 1c275a02c8

View file

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// system // system
#include <sys/mman.h> #include <sys/mman.h>
#include <errno.h>
// drm // drm
#include <xf86drm.h> #include <xf86drm.h>
#if HAVE_GBM #if HAVE_GBM
@ -44,13 +45,16 @@ DrmBuffer::DrmBuffer(DrmBackend *backend, const QSize &size)
createArgs.width = size.width(); createArgs.width = size.width();
createArgs.height = size.height(); createArgs.height = size.height();
if (drmIoctl(m_backend->fd(), DRM_IOCTL_MODE_CREATE_DUMB, &createArgs) != 0) { if (drmIoctl(m_backend->fd(), DRM_IOCTL_MODE_CREATE_DUMB, &createArgs) != 0) {
qCWarning(KWIN_DRM) << "DRM_IOCTL_MODE_CREATE_DUMB failed";
return; return;
} }
m_handle = createArgs.handle; m_handle = createArgs.handle;
m_bufferSize = createArgs.size; m_bufferSize = createArgs.size;
m_stride = createArgs.pitch; m_stride = createArgs.pitch;
drmModeAddFB(m_backend->fd(), size.width(), size.height(), 24, 32, if (drmModeAddFB(m_backend->fd(), size.width(), size.height(), 24, 32,
m_stride, createArgs.handle, &m_bufferId); m_stride, createArgs.handle, &m_bufferId) != 0) {
qCWarning(KWIN_DRM) << "drmModeAddFB failed with errno" << errno;
}
} }