This commit is contained in:
JerryXiao 2023-04-25 20:52:50 +08:00
parent 00d252c958
commit 078fdc1539
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5

View file

@ -13,17 +13,6 @@
#include <math.h> #include <math.h>
struct drm_nvidia_gem_map_offset_params {
uint32_t handle; /* IN Handle to gem object */
uint32_t __pad;
uint64_t offset; /* OUT Fake offset */
};
#define DRM_NVIDIA_GEM_MAP_OFFSET 0x0a
#define DRM_IOCTL_NVIDIA_GEM_MAP_OFFSET \
DRM_IOWR((DRM_COMMAND_BASE + DRM_NVIDIA_GEM_MAP_OFFSET), \
struct drm_nvidia_gem_map_offset_params)
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
/* 10 frames per second (if we can) */ /* 10 frames per second (if we can) */
#define PICTURE_TIMEOUT (1.0/10.0) #define PICTURE_TIMEOUT (1.0/10.0)
@ -436,15 +425,16 @@ int main(int argc, const char **argv)
else if (strcmp(drm_ver->name, "nvidia-drm") == 0) { else if (strcmp(drm_ver->name, "nvidia-drm") == 0) {
convert_func = &convert_nv_stripe; convert_func = &convert_nv_stripe;
vblank_func = &drm_wait_vblank_noop; vblank_func = &drm_wait_vblank_noop;
struct drm_nvidia_gem_map_offset_params mmap_arg;
memset(&mmap_arg, 0, sizeof(mmap_arg)); struct drm_mode_map_dumb mreq;
mmap_arg.handle = open_arg.handle; memset(&mreq, 0, sizeof(mreq));
if (ioctl_err = drmIoctl(drmfd, DRM_IOCTL_NVIDIA_GEM_MAP_OFFSET, &mmap_arg)) { mreq.handle = open_arg.handle;
if (ioctl_err = drmIoctl(drmfd, DRM_IOCTL_MODE_MAP_DUMB, &mreq)) {
fprintf(stderr, "DRM ioctl error %d on line %d\n", ioctl_err, __LINE__); fprintf(stderr, "DRM ioctl error %d on line %d\n", ioctl_err, __LINE__);
goto cleanup; goto cleanup;
} }
mmap_size = open_arg.size; mmap_size = open_arg.size;
mmap_offset = mmap_arg.offset; mmap_offset = mreq.offset;
} }
else { else {
fprintf(stderr, "Unimplemented drm driver\n"); fprintf(stderr, "Unimplemented drm driver\n");