Commit 4ca3d1de authored by Deepak Rawat's avatar Deepak Rawat Committed by Daniel Vetter

lib/igt_fb: Call dumb_destroy ioctl in case of dumb buffers

vmwgfx does not support GEM interface so calling gem_close on vmwgfx
results in error.

v2: Use drmIoctl with error when ioctl() failed.

v3: Seperate ioctl wrapper.
Signed-off-by: default avatarDeepak Rawat <drawat@vmware.com>
Signed-off-by: Daniel Vetter's avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 0ac43db3
......@@ -2121,7 +2121,10 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
cairo_surface_destroy(fb->cairo_surface);
do_or_die(drmModeRmFB(fd, fb->fb_id));
gem_close(fd, fb->gem_handle);
if (fb->is_dumb)
kmstest_dumb_destroy(fd, fb->gem_handle);
else
gem_close(fd, fb->gem_handle);
fb->fb_id = 0;
}
......
......@@ -641,6 +641,28 @@ void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
return ptr;
}
static int __kmstest_dumb_destroy(int fd, uint32_t handle)
{
struct drm_mode_destroy_dumb arg = { handle };
int err = 0;
if (drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg))
err = -errno;
errno = 0;
return err;
}
/**
* kmstest_dumb_destroy:
* @fd: Opened drm file descriptor
* @handle: Offset in the file referred to by fd
*/
void kmstest_dumb_destroy(int fd, uint32_t handle)
{
igt_assert_eq(__kmstest_dumb_destroy(fd, handle), 0);
}
/*
* Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was
* found and nothing was done.
......
......@@ -222,6 +222,7 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
unsigned prot);
void kmstest_dumb_destroy(int fd, uint32_t handle);
void kmstest_wait_for_pageflip(int fd);
unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment