summaryrefslogtreecommitdiff
path: root/tests/kms_prime.c
diff options
context:
space:
mode:
authorRamalingam C <ramalingam.c@intel.com>2021-09-16 19:02:39 +0530
committerRamalingam C <ramalingam.c@intel.com>2021-09-20 08:07:20 +0530
commit0faa6b2533da9416a3428c34ca99661725577449 (patch)
tree6d5edb3b9e9198ca2ea4d42bd506ed6997a38f2e /tests/kms_prime.c
parent7b275b3eb17ddf6e7c5b7b9ba359b7f5345a5311 (diff)
tests/kms_prime: Create the exporting BO with smem
On i915, to avail the dmabuf, the shared object needs to migratable into smem. So if the shared object is lmem, then it needs to have smem as second placement option. Currently kms_prime sharing the dumb buffer between the devices. But dumb buffer can't have the placements and resides at lmem for the dgfx. Hence to meet the i915 expectation for dgfx, we create the BO using the gem_create with smem as second placement option. v2: Used gem_mmap__device_coherent for mmaped ptr (Ashutosh) v3: dumb buffer ioctls are used for non i915 drivers Signed-off-by: Ramalingam C <ramalingam.c@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> (v2) Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Diffstat (limited to 'tests/kms_prime.c')
-rw-r--r--tests/kms_prime.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/tests/kms_prime.c b/tests/kms_prime.c
index 2e20c58b..5cdb5597 100644
--- a/tests/kms_prime.c
+++ b/tests/kms_prime.c
@@ -100,18 +100,27 @@ static void prepare_scratch(int exporter_fd, struct dumb_bo *scratch,
scratch->height = mode->vdisplay;
scratch->bpp = 32;
- scratch->handle = kmstest_dumb_create(exporter_fd,
- ALIGN(scratch->width, 256),
- scratch->height,
- scratch->bpp,
- &scratch->pitch,
- &scratch->size);
-
-
- ptr = kmstest_dumb_map_buffer(exporter_fd,
- scratch->handle,
- scratch->size,
- PROT_WRITE);
+ if (!is_i915_device(exporter_fd)) {
+ scratch->handle = kmstest_dumb_create(exporter_fd,
+ ALIGN(scratch->width, 256),
+ scratch->height, scratch->bpp,
+ &scratch->pitch, &scratch->size);
+
+ ptr = kmstest_dumb_map_buffer(exporter_fd, scratch->handle,
+ scratch->size, PROT_WRITE);
+ } else {
+ igt_calc_fb_size(exporter_fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_NONE, &scratch->size, &scratch->pitch);
+ if (gem_has_lmem(exporter_fd))
+ scratch->handle = gem_create_in_memory_regions(exporter_fd, scratch->size,
+ REGION_LMEM(0), REGION_SMEM);
+ else
+ scratch->handle = gem_create_in_memory_regions(exporter_fd, scratch->size,
+ REGION_SMEM);
+
+ ptr = gem_mmap__device_coherent(exporter_fd, scratch->handle, 0, scratch->size,
+ PROT_WRITE | PROT_READ);
+ }
for (size_t idx = 0; idx < scratch->size / sizeof(*ptr); ++idx)
ptr[idx] = color;