From c088426932524e65af78ca53ee6998a0c2781e50 Mon Sep 17 00:00:00 2001 From: Jerry Date: Thu, 27 Apr 2023 19:51:16 +0800 Subject: [PATCH] add alternative mmap method for i915 --- drm.c | 22 ++++++++++++++++------ kmsvnc.c | 1 - 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drm.c b/drm.c index f320995..6d749e6 100644 --- a/drm.c +++ b/drm.c @@ -270,9 +270,6 @@ static int drm_kmsbuf_dumb() { drm->mmap_size = open_arg.size; drm->mmap_offset = mreq.offset; - - drm->funcs->sync_start = &drm_sync_noop; - drm->funcs->sync_end = &drm_sync_noop; return 0; } @@ -310,9 +307,6 @@ int drm_vendors() { drm->mmap_size = open_arg.size; drm->mmap_offset = mmap_arg.out.addr_ptr; - - drm->funcs->sync_start = &drm_sync_noop; - drm->funcs->sync_end = &drm_sync_noop; } else if (strcmp(driver_name, "nvidia-drm") == 0) { @@ -336,6 +330,22 @@ int drm_vendors() { { if (drm_kmsbuf_dumb()) return 1; } + else if (strcmp(driver_name, "test-i915-gem") == 0) + { + struct drm_gem_flink flink; + flink.handle = drm->mfb->handle; + DRM_IOCTL_MUST(drm->drm_fd, DRM_IOCTL_GEM_FLINK, &flink); + + struct drm_gem_open open_arg; + open_arg.name = flink.name; + DRM_IOCTL_MUST(drm->drm_fd, DRM_IOCTL_GEM_OPEN, &open_arg); + + struct drm_i915_gem_mmap_gtt mmap_arg; + mmap_arg.handle = open_arg.handle; + DRM_IOCTL_MUST(drm->drm_fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg); + drm->mmap_size = open_arg.size; + drm->mmap_offset = mmap_arg.offset; + } else { fprintf(stderr, "Untested drm driver, use at your own risk!\n"); diff --git a/kmsvnc.c b/kmsvnc.c index 5a5187e..26a76ff 100644 --- a/kmsvnc.c +++ b/kmsvnc.c @@ -140,7 +140,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { switch (key) { case 'd': - argp_usage(state); kmsvnc->card = arg; break; case 0xfefe: