-
-
Save tiagovignatti/b49412615e1bce1ed2a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tests/kms_pwrite_crc.c b/tests/kms_pwrite_crc.c | |
index 05b9e38..419b46d 100644 | |
--- a/tests/kms_pwrite_crc.c | |
+++ b/tests/kms_pwrite_crc.c | |
@@ -50,6 +50,20 @@ typedef struct { | |
uint32_t devid; | |
} data_t; | |
+static char *dmabuf_mmap_framebuffer(int drm_fd, struct igt_fb *fb) | |
+{ | |
+ int dma_buf_fd; | |
+ char *ptr = NULL; | |
+ | |
+ dma_buf_fd = prime_handle_to_fd(drm_fd, fb->gem_handle); | |
+ igt_assert(errno == 0); | |
+ | |
+ ptr = mmap(NULL, fb->size, PROT_READ | PROT_WRITE, MAP_SHARED, dma_buf_fd, 0); | |
+ igt_assert(ptr != MAP_FAILED); | |
+ | |
+ return ptr; | |
+} | |
+ | |
static void test(data_t *data) | |
{ | |
igt_display_t *display = &data->display; | |
@@ -57,6 +71,7 @@ static void test(data_t *data) | |
struct igt_fb *fb = &data->fb[1]; | |
drmModeModeInfo *mode; | |
cairo_t *cr; | |
+ char *ptr; | |
uint32_t caching; | |
void *buf; | |
igt_crc_t crc; | |
@@ -67,6 +82,8 @@ static void test(data_t *data) | |
igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, | |
DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, fb); | |
+ ptr = dmabuf_mmap_framebuffer(data->drm_fd, fb); | |
+ | |
cr = igt_get_cairo_ctx(data->drm_fd, fb); | |
igt_paint_test_pattern(cr, fb->width, fb->height); | |
cairo_destroy(cr); | |
@@ -83,11 +100,11 @@ static void test(data_t *data) | |
caching = gem_get_caching(data->drm_fd, fb->gem_handle); | |
igt_assert(caching == I915_CACHING_NONE || caching == I915_CACHING_DISPLAY); | |
- /* use pwrite to make the other fb all white too */ | |
+ /* use dmabuf pointer to make the other fb all white too */ | |
buf = malloc(fb->size); | |
igt_assert(buf != NULL); | |
memset(buf, 0xff, fb->size); | |
- gem_write(data->drm_fd, fb->gem_handle, 0, buf, fb->size); | |
+ memcpy(ptr, buf, fb->size); | |
free(buf); | |
/* and flip to it */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment