add alternative mmap method for i915

This commit is contained in:
JerryXiao 2023-04-27 19:51:16 +08:00
parent 8a71fc150f
commit c088426932
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
2 changed files with 16 additions and 7 deletions

22
drm.c
View file

@ -270,9 +270,6 @@ static int drm_kmsbuf_dumb() {
drm->mmap_size = open_arg.size; drm->mmap_size = open_arg.size;
drm->mmap_offset = mreq.offset; drm->mmap_offset = mreq.offset;
drm->funcs->sync_start = &drm_sync_noop;
drm->funcs->sync_end = &drm_sync_noop;
return 0; return 0;
} }
@ -310,9 +307,6 @@ int drm_vendors() {
drm->mmap_size = open_arg.size; drm->mmap_size = open_arg.size;
drm->mmap_offset = mmap_arg.out.addr_ptr; 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) else if (strcmp(driver_name, "nvidia-drm") == 0)
{ {
@ -336,6 +330,22 @@ int drm_vendors() {
{ {
if (drm_kmsbuf_dumb()) return 1; 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 else
{ {
fprintf(stderr, "Untested drm driver, use at your own risk!\n"); fprintf(stderr, "Untested drm driver, use at your own risk!\n");

View file

@ -140,7 +140,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
switch (key) { switch (key) {
case 'd': case 'd':
argp_usage(state);
kmsvnc->card = arg; kmsvnc->card = arg;
break; break;
case 0xfefe: case 0xfefe: