mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-12 10:26:12 +00:00
lib: Add wrapper for DRM_IOCTL_MODE_CREATE_DUMB
In order to test drivers that don't have support for proper buffer objects, add a wrapper for creating dumb buffer objects that will be called from the lib code for those subtests that don't need to care. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
85a1d45c4a
commit
dc84e7d6ad
@ -426,6 +426,42 @@ uint32_t kmstest_find_crtc_for_connector(int fd, drmModeRes *res,
|
|||||||
igt_assert(false);
|
igt_assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kmstest_dumb_create:
|
||||||
|
* @fd: open drm file descriptor
|
||||||
|
* @width: width of the buffer in pixels
|
||||||
|
* @height: height of the buffer in pixels
|
||||||
|
* @bpp: bytes per pixel of the buffer
|
||||||
|
*
|
||||||
|
* This wraps the CREATE_DUMB ioctl, which allocates a new dumb buffer object
|
||||||
|
* for the specified dimensions.
|
||||||
|
*
|
||||||
|
* Returns: The file-private handle of the created buffer object
|
||||||
|
*/
|
||||||
|
uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
|
||||||
|
unsigned *stride, unsigned *size)
|
||||||
|
{
|
||||||
|
struct drm_mode_create_dumb create;
|
||||||
|
|
||||||
|
memset(&create, 0, sizeof(create));
|
||||||
|
create.width = width;
|
||||||
|
create.height = height;
|
||||||
|
create.bpp = bpp;
|
||||||
|
|
||||||
|
create.handle = 0;
|
||||||
|
do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
|
||||||
|
igt_assert(create.handle);
|
||||||
|
igt_assert(create.size >= width * height * bpp / 8);
|
||||||
|
|
||||||
|
if (stride)
|
||||||
|
*stride = create.pitch;
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = create.size;
|
||||||
|
|
||||||
|
return create.handle;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was
|
* Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was
|
||||||
* found and nothing was done.
|
* found and nothing was done.
|
||||||
|
@ -175,6 +175,9 @@ uint32_t kmstest_find_crtc_for_connector(int fd, drmModeRes *res,
|
|||||||
drmModeConnector *connector,
|
drmModeConnector *connector,
|
||||||
uint32_t crtc_blacklist_idx_mask);
|
uint32_t crtc_blacklist_idx_mask);
|
||||||
|
|
||||||
|
uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
|
||||||
|
unsigned *stride, unsigned *size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A small modeset API
|
* A small modeset API
|
||||||
*/
|
*/
|
||||||
|
@ -120,20 +120,6 @@ static void test_invalid_buffer(int in)
|
|||||||
teardown(fd);
|
teardown(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t dumb_create(int fd)
|
|
||||||
{
|
|
||||||
struct drm_mode_create_dumb arg;
|
|
||||||
|
|
||||||
arg.bpp = 32;
|
|
||||||
arg.width = 32;
|
|
||||||
arg.height = 32;
|
|
||||||
|
|
||||||
do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
|
|
||||||
igt_assert(arg.size >= 4096);
|
|
||||||
|
|
||||||
return arg.handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_fault_buffer(int in)
|
static void test_fault_buffer(int in)
|
||||||
{
|
{
|
||||||
int fd = setup(in, 0);
|
int fd = setup(in, 0);
|
||||||
@ -141,7 +127,7 @@ static void test_fault_buffer(int in)
|
|||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
memset(&arg, 0, sizeof(arg));
|
memset(&arg, 0, sizeof(arg));
|
||||||
arg.handle = dumb_create(fd);
|
arg.handle = kmstest_dumb_create(fd, 32, 32, 32, NULL, NULL);
|
||||||
|
|
||||||
do_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
|
do_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
|
||||||
|
|
||||||
|
@ -170,22 +170,6 @@ static const char *bytes_per_sec(char *buf, double v)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t dumb_create(int fd)
|
|
||||||
{
|
|
||||||
struct drm_mode_create_dumb arg;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
arg.bpp = 32;
|
|
||||||
arg.width = 32;
|
|
||||||
arg.height = 32;
|
|
||||||
|
|
||||||
ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
|
|
||||||
igt_assert_eq(ret, 0);
|
|
||||||
igt_assert(arg.size >= 4096);
|
|
||||||
|
|
||||||
return arg.handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dcmp(const void *A, const void *B)
|
static int dcmp(const void *A, const void *B)
|
||||||
{
|
{
|
||||||
const double *a = A, *b = B;
|
const double *a = A, *b = B;
|
||||||
@ -209,7 +193,7 @@ static void run(int object_size, bool dumb)
|
|||||||
|
|
||||||
fd = drm_open_driver(DRIVER_INTEL);
|
fd = drm_open_driver(DRIVER_INTEL);
|
||||||
if (dumb)
|
if (dumb)
|
||||||
handle = dumb_create(fd);
|
handle = kmstest_dumb_create(fd, 32, 32, 32, NULL, NULL);
|
||||||
else
|
else
|
||||||
handle = gem_create(fd, 4096);
|
handle = gem_create(fd, 4096);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user