Skip to content

Commit

Permalink
Fix KMS cursor capture on Nvidia GPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
cgutman committed Jan 28, 2024
1 parent 8182f59 commit cf416f5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/platform/linux/kmsgrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,20 @@ namespace platf {
// We will map the entire region, but only copy what the source rectangle specifies
size_t mapped_size = ((size_t) fb->pitches[0]) * fb->height;
void *mapped_data = mmap(nullptr, mapped_size, PROT_READ, MAP_SHARED, plane_fd.el, fb->offsets[0]);

// If we got ENOSYS back, let's try to map it as a dumb buffer instead (required for Nvidia GPUs)
if (mapped_data == MAP_FAILED && errno == ENOSYS) {
drm_mode_map_dumb map = {};
map.handle = fb->handles[0];
if (drmIoctl(card.fd.el, DRM_IOCTL_MODE_MAP_DUMB, &map) < 0) {
BOOST_LOG(error) << "Failed to map cursor FB as dumb buffer: "sv << strerror(errno);
captured_cursor.visible = false;
return;
}

mapped_data = mmap(nullptr, mapped_size, PROT_READ, MAP_SHARED, card.fd.el, map.offset);
}

if (mapped_data == MAP_FAILED) {
BOOST_LOG(error) << "Failed to mmap cursor FB: "sv << strerror(errno);
captured_cursor.visible = false;
Expand Down

0 comments on commit cf416f5

Please sign in to comment.