aboutsummaryrefslogtreecommitdiffstats
path: root/drmtest.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-12-02 12:47:15 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-12-02 12:47:15 +0100
commit1585a3d507c08d8f5fb07783983331a36a6e066d (patch)
tree32856ccc889fc561c8622ac74dd51fe4b0052c79 /drmtest.c
parent7612977a7e685461db033a8509d0bce6a0a28dc6 (diff)
downloaddrminfo-1585a3d507c08d8f5fb07783983331a36a6e066d.tar.gz
complete & fix vgem test
Diffstat (limited to 'drmtest.c')
-rw-r--r--drmtest.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drmtest.c b/drmtest.c
index 52615b9..d6d3381 100644
--- a/drmtest.c
+++ b/drmtest.c
@@ -238,12 +238,12 @@ static void drm_init_dumb_obj(int fd, bool use_pixman, bool create_dmabuf)
/* map gem object */
memset(&mreq, 0, sizeof(mreq));
mreq.handle = creq.handle;
- rc = drmIoctl(drm_fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq);
+ rc = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq);
if (rc < 0) {
fprintf(stderr, "DRM_IOCTL_MODE_MAP_DUMB: %s\n", strerror(errno));
exit(1);
}
- fbmem = mmap(0, creq.size, PROT_READ | PROT_WRITE, MAP_SHARED, drm_fd, mreq.offset);
+ fbmem = mmap(0, creq.size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mreq.offset);
if (fbmem == MAP_FAILED) {
fprintf(stderr, "framebuffer mmap: %s\n", strerror(errno));
exit(1);
@@ -251,7 +251,7 @@ static void drm_init_dumb_obj(int fd, bool use_pixman, bool create_dmabuf)
if (create_dmabuf) {
print_head("create dma-buf");
- rc = drmPrimeHandleToFD(drm_fd, creq.handle, 0, &dmabuf_fd);
+ rc = drmPrimeHandleToFD(fd, creq.handle, 0, &dmabuf_fd);
print_test_errno("dma-buf export", rc < 0, errno);
if (rc == 0) {
dmabuf_mem = mmap(NULL, creq.size, PROT_READ, MAP_SHARED, dmabuf_fd, 0);
@@ -296,13 +296,11 @@ static void drm_init_dumb_obj(int fd, bool use_pixman, bool create_dmabuf)
}
}
-static void drm_init_dumb_fb(bool use_pixman, bool create_dmabuf)
+static void drm_init_dumb_fb(void)
{
uint32_t zero = 0;
int rc;
- drm_init_dumb_obj(drm_fd, use_pixman, create_dmabuf);
-
if (fmt->fourcc) {
rc = drmModeAddFB2(drm_fd, creq.width, creq.height, fmt->fourcc,
&creq.handle, &creq.pitch, &zero,
@@ -500,7 +498,18 @@ int main(int argc, char **argv)
}
}
- drm_init_dumb_fb(pixman, dmabuf);
+ if (vgem) {
+ drm_init_dumb_obj(vgem_fd, pixman, true);
+ rc = drmPrimeFDToHandle(drm_fd, dmabuf_fd, &creq.handle);
+ if (rc < 0) {
+ fprintf(stderr, "import vgem dmabuf failed\n");
+ exit(1);
+ }
+ drm_init_dumb_fb();
+ } else {
+ drm_init_dumb_obj(drm_fd, pixman, dmabuf);
+ drm_init_dumb_fb();
+ }
drm_draw_dumb_fb(autotest, 0);
drm_check_content("pre-show content");
drm_show_fb();