Fix return value check of drmIoctl()

When the drmModeSetCursor2() call was replaced with bare drmIoctl() call in
b344e155, a bug was introduced.  With the use of drmModeSetCursor2(),
the return value from drmIoctl() (which calls ioctl()) were mangled, if
they were negative, they were replaced by -errno by a wrapper function
in xf86drMode.c in libdrm.  After replacing drmModeSetCursor2() with the
call to drmIoctl(), this mangling no longer happens, and we need to
explicitly check if the call to drmIoctl() fails, which is indicated by
returning -1, and then why it failed, by checking errno.
If the error indicated by errno is EINVAL, then we can't use the
DRM_IOCTL_MODE_CURSOR2 ioctl(), and need to fall back to the
DRM_IOCTL_MODE_CURSOR ioctl().

This bug can manifest itself by an invisible hw cursor on systems where the
DRM_IOCTL_MODE_CURSOR2 is not implemented by the graphics driver.

Signed-off-by: Niclas Zeising <zeising@daemonic.se>
12 jobs for zeising/drmioctl in 2 minutes and 1 second (queued for 2 seconds)
Status Job ID Name Coverage
  Docker Image
passed #2845266
container-build

00:00:44

 
  Build
passed #2845269
xserver-1.13

00:01:07

passed #2845270
xserver-1.14

00:00:33

passed #2845271
xserver-1.15

00:00:33

passed #2845272
xserver-1.16

00:01:07

passed #2845273
xserver-1.17

00:00:34

passed #2845274
xserver-1.18

00:00:34

passed #2845275
xserver-1.18-clang

00:00:36

passed #2845276
xserver-1.19

00:01:07

passed #2845277
xserver-1.19-clang

00:00:40

passed #2845267
xserver-1.20

00:01:16

passed #2845268
xserver-1.20-clang

00:00:37