[PATCH igt 7/8] tests/kms_fbc_crc: extract fill_mmap_{cpu, gtt}()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx>

Just like we have fill_render() and fill_blt(). I'm also going to use
fill_mmap_gtt() for the code that generates the reference CRCs.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx>
---
 tests/kms_fbc_crc.c | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index a66aa51..b52ac29 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -190,6 +190,29 @@ static void fill_render(data_t *data, uint32_t handle,
 	gem_bo_busy(data->drm_fd, handle);
 }
 
+static void fill_mmap_cpu(data_t *data, uint32_t handle, unsigned char color)
+{
+	void *ptr;
+
+	ptr = gem_mmap__cpu(data->drm_fd, handle, 0, 4096, PROT_WRITE);
+	gem_set_domain(data->drm_fd, handle, I915_GEM_DOMAIN_CPU,
+		       I915_GEM_DOMAIN_CPU);
+	memset(ptr, color, 4);
+	munmap(ptr, 4096);
+	gem_sw_finish(data->drm_fd, handle);
+}
+
+static void fill_mmap_gtt(data_t *data, uint32_t handle, unsigned char color)
+{
+	void *ptr;
+
+	ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE);
+	gem_set_domain(data->drm_fd, handle, I915_GEM_DOMAIN_GTT,
+		       I915_GEM_DOMAIN_GTT);
+	memset(ptr, color, 4);
+	munmap(ptr, 4096);
+}
+
 static bool fbc_enabled(data_t *data)
 {
 	FILE *status;
@@ -237,24 +260,16 @@ static void test_crc(data_t *data, enum test_mode mode)
 	}
 
 	switch (mode) {
-		void *ptr;
 		drm_intel_context *context = NULL;
 	case TEST_PAGE_FLIP:
 		break;
 	case TEST_MMAP_CPU:
 	case TEST_PAGE_FLIP_AND_MMAP_CPU:
-		ptr = gem_mmap__cpu(data->drm_fd, handle, 0, 4096, PROT_WRITE);
-		gem_set_domain(data->drm_fd, handle, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
-		memset(ptr, 0xff, 4);
-		munmap(ptr, 4096);
-		gem_sw_finish(data->drm_fd, handle);
+		fill_mmap_cpu(data, handle, 0xff);
 		break;
 	case TEST_MMAP_GTT:
 	case TEST_PAGE_FLIP_AND_MMAP_GTT:
-		ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE);
-		gem_set_domain(data->drm_fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
-		memset(ptr, 0xff, 4);
-		munmap(ptr, 4096);
+		fill_mmap_gtt(data, handle, 0xff);
 		break;
 	case TEST_BLT:
 	case TEST_PAGE_FLIP_AND_BLT:
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux