From 22d11eb9cbc8cad5b1d24b071143945ca0661408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 8 Feb 2022 15:58:33 +0100 Subject: [PATCH] drm-buffer: Keep track of handle as well This handle is used by the legacy KMS API; lets avoid having to have GBM specific code where this is done by letting the MetaDrmBuffer API, that already has this information, expose it. Part-of: --- src/backends/native/meta-drm-buffer-dumb.c | 1 + src/backends/native/meta-drm-buffer-gbm.c | 1 + src/backends/native/meta-drm-buffer-import.c | 1 + src/backends/native/meta-drm-buffer-private.h | 1 + src/backends/native/meta-drm-buffer.c | 11 +++++++++++ src/backends/native/meta-drm-buffer.h | 2 ++ 6 files changed, 17 insertions(+) diff --git a/src/backends/native/meta-drm-buffer-dumb.c b/src/backends/native/meta-drm-buffer-dumb.c index dcf994947..25d0ed328 100644 --- a/src/backends/native/meta-drm-buffer-dumb.c +++ b/src/backends/native/meta-drm-buffer-dumb.c @@ -248,6 +248,7 @@ init_dumb_buffer (MetaDrmBufferDumb *buffer_dumb, .width = width, .height = height, .format = format, + .handle = create_arg.handle, .handles = { create_arg.handle }, .strides = { create_arg.pitch }, }; diff --git a/src/backends/native/meta-drm-buffer-gbm.c b/src/backends/native/meta-drm-buffer-gbm.c index 5a7791582..8c27993a6 100644 --- a/src/backends/native/meta-drm-buffer-gbm.c +++ b/src/backends/native/meta-drm-buffer-gbm.c @@ -164,6 +164,7 @@ meta_drm_buffer_gbm_ensure_fb_id (MetaDrmBuffer *buffer, fb_args.width = gbm_bo_get_width (bo); fb_args.height = gbm_bo_get_height (bo); fb_args.format = gbm_bo_get_format (bo); + fb_args.handle = gbm_bo_get_handle (bo).u32; if (!meta_drm_buffer_do_ensure_fb_id (META_DRM_BUFFER (buffer_gbm), &fb_args, error)) diff --git a/src/backends/native/meta-drm-buffer-import.c b/src/backends/native/meta-drm-buffer-import.c index d858b18e6..c2a8f38c6 100644 --- a/src/backends/native/meta-drm-buffer-import.c +++ b/src/backends/native/meta-drm-buffer-import.c @@ -162,6 +162,7 @@ import_gbm_buffer (MetaDrmBufferImport *buffer_import, fb_args.width = gbm_bo_get_width (primary_bo); fb_args.height = gbm_bo_get_height (primary_bo); fb_args.format = gbm_bo_get_format (primary_bo); + fb_args.handle = gbm_bo_get_handle (primary_bo).u32; imported_bo = dmabuf_to_gbm_bo (importer, dmabuf_fd, diff --git a/src/backends/native/meta-drm-buffer-private.h b/src/backends/native/meta-drm-buffer-private.h index 859269114..e8c11f502 100644 --- a/src/backends/native/meta-drm-buffer-private.h +++ b/src/backends/native/meta-drm-buffer-private.h @@ -33,6 +33,7 @@ typedef struct _MetaDrmFbArgs uint32_t offsets[4]; uint32_t strides[4]; uint64_t modifiers[4]; + uint32_t handle; } MetaDrmFbArgs; struct _MetaDrmBufferClass diff --git a/src/backends/native/meta-drm-buffer.c b/src/backends/native/meta-drm-buffer.c index b7d4d8d30..86dfb16da 100644 --- a/src/backends/native/meta-drm-buffer.c +++ b/src/backends/native/meta-drm-buffer.c @@ -53,6 +53,7 @@ typedef struct _MetaDrmBufferPrivate MetaDrmBufferFlags flags; uint32_t fb_id; + uint32_t handle; } MetaDrmBufferPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaDrmBuffer, meta_drm_buffer, @@ -152,6 +153,8 @@ meta_drm_buffer_do_ensure_fb_id (MetaDrmBuffer *buffer, } priv->fb_id = fb_id; + priv->handle = fb_args->handle; + return TRUE; } @@ -185,6 +188,14 @@ meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer) return priv->fb_id; } +uint32_t +meta_drm_buffer_get_handle (MetaDrmBuffer *buffer) +{ + MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer); + + return priv->handle; +} + int meta_drm_buffer_get_width (MetaDrmBuffer *buffer) { diff --git a/src/backends/native/meta-drm-buffer.h b/src/backends/native/meta-drm-buffer.h index c393d4fee..5ce6862a7 100644 --- a/src/backends/native/meta-drm-buffer.h +++ b/src/backends/native/meta-drm-buffer.h @@ -50,6 +50,8 @@ gboolean meta_drm_buffer_ensure_fb_id (MetaDrmBuffer *buffer, uint32_t meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer); +uint32_t meta_drm_buffer_get_handle (MetaDrmBuffer *buffer); + int meta_drm_buffer_get_width (MetaDrmBuffer *buffer); int meta_drm_buffer_get_height (MetaDrmBuffer *buffer);