diff options
author | Manuel Stoeckl <code@mstoeckl.com> | 2023-01-28 21:07:54 -0500 |
---|---|---|
committer | Manuel Stoeckl <code@mstoeckl.com> | 2023-01-29 11:53:56 -0500 |
commit | d731037211b834840adf10d2cafb4f1eb072679b (patch) | |
tree | 153cefa42edc1f0f3187e3bee6dae1c351cd7fa6 | |
parent | cc09a5c68d6bb350c1e66245f2f7cb04d4dc4b93 (diff) |
Provide dmabuf main device from opened drm fd
-rw-r--r-- | src/handlers.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/handlers.c b/src/handlers.c index 8db31eb..6c789ee 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -30,6 +30,7 @@ #include <errno.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h> #include <time.h> #include <unistd.h> @@ -1666,6 +1667,7 @@ void do_zwp_linux_dmabuf_feedback_v1_evt_format_table( void do_zwp_linux_dmabuf_feedback_v1_evt_main_device(struct context *ctx, uint32_t device_count, const uint8_t *device_val) { + struct obj_zwp_linux_dmabuf_feedback *obj = (struct obj_zwp_linux_dmabuf_feedback *)ctx->obj; if ((size_t)device_count != sizeof(dev_t)) { @@ -1673,7 +1675,20 @@ void do_zwp_linux_dmabuf_feedback_v1_evt_main_device(struct context *ctx, (size_t)device_count, sizeof(dev_t)); return; } - memcpy(&obj->main_device, device_val, sizeof(dev_t)); + + if (ctx->on_display_side) { + memcpy(&obj->main_device, device_val, sizeof(dev_t)); + } else { + // adopt the main device from the render fd being used + struct stat fsdata; + memset(&fsdata, 0, sizeof(fsdata)); + int ret = fstat(ctx->g->render.drm_fd, &fsdata); + if (ret == -1) { + wp_error("Failed to get render device info"); + return; + } + obj->main_device = fsdata.st_rdev; + } /* todo: add support for changing render devices in waypipe */ } @@ -1681,7 +1696,7 @@ void do_zwp_linux_dmabuf_feedback_v1_evt_tranche_done(struct context *ctx) { struct obj_zwp_linux_dmabuf_feedback *obj = (struct obj_zwp_linux_dmabuf_feedback *)ctx->obj; - if (obj->main_device != obj->current_device) { + if (obj->main_device != obj->current_device && ctx->on_display_side) { /* Filter out/ignore all tranches for anything but the main * device. */ return; |