summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-10-27 19:13:06 +0200
committerSimon Ser <contact@emersion.fr>2022-11-02 18:46:38 +0100
commite832f5b0b8770bb768f98a7bcd53d769c4fe432e (patch)
treea1184c7f5c0029bff6440589c4c873189da418d8
parentce223777789139e030548c8d3792bdd2095b592c (diff)
modetest: use dumb buffer helpers
Signed-off-by: Simon Ser <contact@emersion.fr>
-rw-r--r--tests/modetest/buffers.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c
index 8305db40..0b55aedd 100644
--- a/tests/modetest/buffers.c
+++ b/tests/modetest/buffers.c
@@ -37,6 +37,7 @@
#include "libdrm_macros.h"
#include "xf86drm.h"
+#include "xf86drmMode.h"
#include "buffers.h"
@@ -56,7 +57,6 @@ struct bo
static struct bo *
bo_create_dumb(int fd, unsigned int width, unsigned int height, unsigned int bpp)
{
- struct drm_mode_create_dumb arg;
struct bo *bo;
int ret;
@@ -66,12 +66,8 @@ bo_create_dumb(int fd, unsigned int width, unsigned int height, unsigned int bpp
return NULL;
}
- memset(&arg, 0, sizeof(arg));
- arg.bpp = bpp;
- arg.width = width;
- arg.height = height;
-
- ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
+ ret = drmModeCreateDumbBuffer(fd, width, height, bpp, 0, &bo->handle,
+ &bo->pitch, &bo->size);
if (ret) {
fprintf(stderr, "failed to create dumb buffer: %s\n",
strerror(errno));
@@ -80,28 +76,22 @@ bo_create_dumb(int fd, unsigned int width, unsigned int height, unsigned int bpp
}
bo->fd = fd;
- bo->handle = arg.handle;
- bo->size = arg.size;
- bo->pitch = arg.pitch;
return bo;
}
static int bo_map(struct bo *bo, void **out)
{
- struct drm_mode_map_dumb arg;
void *map;
int ret;
+ uint64_t offset;
- memset(&arg, 0, sizeof(arg));
- arg.handle = bo->handle;
-
- ret = drmIoctl(bo->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+ ret = drmModeMapDumbBuffer(bo->fd, bo->handle, &offset);
if (ret)
return ret;
map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
- bo->fd, arg.offset);
+ bo->fd, offset);
if (map == MAP_FAILED)
return -EINVAL;
@@ -339,13 +329,9 @@ bo_create(int fd, unsigned int format,
void bo_destroy(struct bo *bo)
{
- struct drm_mode_destroy_dumb arg;
int ret;
- memset(&arg, 0, sizeof(arg));
- arg.handle = bo->handle;
-
- ret = drmIoctl(bo->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
+ ret = drmModeDestroyDumbBuffer(bo->fd, bo->handle);
if (ret)
fprintf(stderr, "failed to destroy dumb buffer: %s\n",
strerror(errno));