|
|
f7d48e |
From acb3e966b26ea55019a148d6482f5aa4c05275a9 Mon Sep 17 00:00:00 2001
|
|
|
f7d48e |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
f7d48e |
Date: Tue, 8 Feb 2022 15:58:33 +0100
|
|
|
f7d48e |
Subject: [PATCH 1/4] drm-buffer: Keep track of handle as well
|
|
|
f7d48e |
|
|
|
f7d48e |
This handle is used by the legacy KMS API; lets avoid having to have GBM
|
|
|
f7d48e |
specific code where this is done by letting the MetaDrmBuffer API, that
|
|
|
f7d48e |
already has this information, expose it.
|
|
|
f7d48e |
---
|
|
|
f7d48e |
src/backends/native/meta-drm-buffer-dumb.c | 1 +
|
|
|
f7d48e |
src/backends/native/meta-drm-buffer-gbm.c | 1 +
|
|
|
f7d48e |
src/backends/native/meta-drm-buffer-import.c | 1 +
|
|
|
f7d48e |
src/backends/native/meta-drm-buffer-private.h | 1 +
|
|
|
f7d48e |
src/backends/native/meta-drm-buffer.c | 10 ++++++++++
|
|
|
f7d48e |
src/backends/native/meta-drm-buffer.h | 2 ++
|
|
|
f7d48e |
6 files changed, 16 insertions(+)
|
|
|
f7d48e |
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-drm-buffer-dumb.c b/src/backends/native/meta-drm-buffer-dumb.c
|
|
|
f7d48e |
index 373eb5c73581..b5e15528a1c6 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-drm-buffer-dumb.c
|
|
|
f7d48e |
+++ b/src/backends/native/meta-drm-buffer-dumb.c
|
|
|
f7d48e |
@@ -194,6 +194,7 @@ init_dumb_buffer_in_impl (MetaKmsImpl *impl,
|
|
|
f7d48e |
.width = data->width,
|
|
|
f7d48e |
.height = data->height,
|
|
|
f7d48e |
.format = data->format,
|
|
|
f7d48e |
+ .handle = create_arg.handle,
|
|
|
f7d48e |
.handles = { create_arg.handle },
|
|
|
f7d48e |
.strides = { create_arg.pitch },
|
|
|
f7d48e |
};
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-drm-buffer-gbm.c b/src/backends/native/meta-drm-buffer-gbm.c
|
|
|
f7d48e |
index 48ee9eb048ba..fa45dd98b91e 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-drm-buffer-gbm.c
|
|
|
f7d48e |
+++ b/src/backends/native/meta-drm-buffer-gbm.c
|
|
|
f7d48e |
@@ -119,6 +119,7 @@ init_fb_id (MetaDrmBufferGbm *buffer_gbm,
|
|
|
f7d48e |
fb_args.width = gbm_bo_get_width (bo);
|
|
|
f7d48e |
fb_args.height = gbm_bo_get_height (bo);
|
|
|
f7d48e |
fb_args.format = gbm_bo_get_format (bo);
|
|
|
f7d48e |
+ fb_args.handle = gbm_bo_get_handle (bo).u32;
|
|
|
f7d48e |
|
|
|
f7d48e |
if (!meta_drm_buffer_ensure_fb_id (META_DRM_BUFFER (buffer_gbm),
|
|
|
f7d48e |
use_modifiers, &fb_args, error))
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-drm-buffer-import.c b/src/backends/native/meta-drm-buffer-import.c
|
|
|
f7d48e |
index 1e5a38246172..ea744953cb9b 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-drm-buffer-import.c
|
|
|
f7d48e |
+++ b/src/backends/native/meta-drm-buffer-import.c
|
|
|
f7d48e |
@@ -125,6 +125,7 @@ import_gbm_buffer (MetaDrmBufferImport *buffer_import,
|
|
|
f7d48e |
fb_args.width = gbm_bo_get_width (primary_bo);
|
|
|
f7d48e |
fb_args.height = gbm_bo_get_height (primary_bo);
|
|
|
f7d48e |
fb_args.format = gbm_bo_get_format (primary_bo);
|
|
|
f7d48e |
+ fb_args.handle = gbm_bo_get_handle (primary_bo).u32;
|
|
|
f7d48e |
|
|
|
f7d48e |
imported_bo = dmabuf_to_gbm_bo (importer,
|
|
|
f7d48e |
dmabuf_fd,
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-drm-buffer-private.h b/src/backends/native/meta-drm-buffer-private.h
|
|
|
f7d48e |
index 2c77eb957948..f660d3a7f363 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-drm-buffer-private.h
|
|
|
f7d48e |
+++ b/src/backends/native/meta-drm-buffer-private.h
|
|
|
f7d48e |
@@ -33,6 +33,7 @@ typedef struct _MetaDrmFbArgs
|
|
|
f7d48e |
uint32_t offsets[4];
|
|
|
f7d48e |
uint32_t strides[4];
|
|
|
f7d48e |
uint64_t modifiers[4];
|
|
|
f7d48e |
+ uint32_t handle;
|
|
|
f7d48e |
} MetaDrmFbArgs;
|
|
|
f7d48e |
|
|
|
f7d48e |
struct _MetaDrmBufferClass
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-drm-buffer.c b/src/backends/native/meta-drm-buffer.c
|
|
|
f7d48e |
index 81a36196e528..a0f8055b3107 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-drm-buffer.c
|
|
|
f7d48e |
+++ b/src/backends/native/meta-drm-buffer.c
|
|
|
f7d48e |
@@ -50,6 +50,7 @@ typedef struct _MetaDrmBufferPrivate
|
|
|
f7d48e |
{
|
|
|
f7d48e |
MetaKmsDevice *device;
|
|
|
f7d48e |
uint32_t fb_id;
|
|
|
f7d48e |
+ uint32_t handle;
|
|
|
f7d48e |
} MetaDrmBufferPrivate;
|
|
|
f7d48e |
|
|
|
f7d48e |
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaDrmBuffer, meta_drm_buffer,
|
|
|
f7d48e |
@@ -139,6 +140,7 @@ meta_drm_buffer_ensure_fb_in_impl (MetaDrmBuffer *buffer,
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
priv->fb_id = fb_id;
|
|
|
f7d48e |
+ priv->handle = fb_args->handle;
|
|
|
f7d48e |
|
|
|
f7d48e |
return TRUE;
|
|
|
f7d48e |
}
|
|
|
f7d48e |
@@ -242,6 +244,14 @@ meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer)
|
|
|
f7d48e |
return priv->fb_id;
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
+uint32_t
|
|
|
f7d48e |
+meta_drm_buffer_get_handle (MetaDrmBuffer *buffer)
|
|
|
f7d48e |
+{
|
|
|
f7d48e |
+ MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer);
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ return priv->handle;
|
|
|
f7d48e |
+}
|
|
|
f7d48e |
+
|
|
|
f7d48e |
int
|
|
|
f7d48e |
meta_drm_buffer_get_width (MetaDrmBuffer *buffer)
|
|
|
f7d48e |
{
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-drm-buffer.h b/src/backends/native/meta-drm-buffer.h
|
|
|
f7d48e |
index 1647d399e7f2..476264ce753e 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-drm-buffer.h
|
|
|
f7d48e |
+++ b/src/backends/native/meta-drm-buffer.h
|
|
|
f7d48e |
@@ -34,6 +34,8 @@ G_DECLARE_DERIVABLE_TYPE (MetaDrmBuffer,
|
|
|
f7d48e |
|
|
|
f7d48e |
uint32_t meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer);
|
|
|
f7d48e |
|
|
|
f7d48e |
+uint32_t meta_drm_buffer_get_handle (MetaDrmBuffer *buffer);
|
|
|
f7d48e |
+
|
|
|
f7d48e |
int meta_drm_buffer_get_width (MetaDrmBuffer *buffer);
|
|
|
f7d48e |
|
|
|
f7d48e |
int meta_drm_buffer_get_height (MetaDrmBuffer *buffer);
|
|
|
f7d48e |
--
|
|
|
f7d48e |
2.34.1
|
|
|
f7d48e |
|
|
|
f7d48e |
|
|
|
f7d48e |
From bdd2f1dd0a67743085c84f6e060160fbd28122df Mon Sep 17 00:00:00 2001
|
|
|
f7d48e |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
f7d48e |
Date: Tue, 8 Feb 2022 16:00:17 +0100
|
|
|
f7d48e |
Subject: [PATCH 2/4] kms/impl-device/simple: Get the buffer handle from
|
|
|
f7d48e |
MetaDrmBuffer
|
|
|
f7d48e |
|
|
|
f7d48e |
This avoids buffer implementation specific code where it shouldn't
|
|
|
f7d48e |
matter.
|
|
|
f7d48e |
---
|
|
|
f7d48e |
src/backends/native/meta-kms-impl-device-simple.c | 15 ++-------------
|
|
|
f7d48e |
1 file changed, 2 insertions(+), 13 deletions(-)
|
|
|
f7d48e |
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-kms-impl-device-simple.c b/src/backends/native/meta-kms-impl-device-simple.c
|
|
|
f7d48e |
index 1519962b8ed7..1663a2e9cacd 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-kms-impl-device-simple.c
|
|
|
f7d48e |
+++ b/src/backends/native/meta-kms-impl-device-simple.c
|
|
|
f7d48e |
@@ -1182,20 +1182,9 @@ process_cursor_plane_assignment (MetaKmsImplDevice *impl_device,
|
|
|
f7d48e |
height = plane_assignment->dst_rect.height;
|
|
|
f7d48e |
|
|
|
f7d48e |
if (plane_assignment->buffer)
|
|
|
f7d48e |
- {
|
|
|
f7d48e |
- MetaDrmBufferGbm *buffer_gbm =
|
|
|
f7d48e |
- META_DRM_BUFFER_GBM (plane_assignment->buffer);
|
|
|
f7d48e |
- struct gbm_bo *bo;
|
|
|
f7d48e |
- union gbm_bo_handle handle;
|
|
|
f7d48e |
-
|
|
|
f7d48e |
- bo = meta_drm_buffer_gbm_get_bo (buffer_gbm);
|
|
|
f7d48e |
- handle = gbm_bo_get_handle (bo);
|
|
|
f7d48e |
- handle_u32 = handle.u32;
|
|
|
f7d48e |
- }
|
|
|
f7d48e |
+ handle_u32 = meta_drm_buffer_get_handle (plane_assignment->buffer);
|
|
|
f7d48e |
else
|
|
|
f7d48e |
- {
|
|
|
f7d48e |
- handle_u32 = 0;
|
|
|
f7d48e |
- }
|
|
|
f7d48e |
+ handle_u32 = 0;
|
|
|
f7d48e |
|
|
|
f7d48e |
meta_topic (META_DEBUG_KMS,
|
|
|
f7d48e |
"[simple] Setting HW cursor of CRTC %u (%s) to %u "
|
|
|
f7d48e |
--
|
|
|
f7d48e |
2.34.1
|
|
|
f7d48e |
|
|
|
f7d48e |
|
|
|
f7d48e |
From d781f140b7197d3c9cd67f8fded4e2b58a4eda92 Mon Sep 17 00:00:00 2001
|
|
|
f7d48e |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
f7d48e |
Date: Tue, 8 Feb 2022 15:05:32 +0100
|
|
|
f7d48e |
Subject: [PATCH 3/4] cursor-renderer/native: Move buffer creation to helper
|
|
|
f7d48e |
|
|
|
f7d48e |
---
|
|
|
f7d48e |
.../native/meta-cursor-renderer-native.c | 134 ++++++++++++------
|
|
|
f7d48e |
1 file changed, 89 insertions(+), 45 deletions(-)
|
|
|
f7d48e |
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c
|
|
|
f7d48e |
index 098ef24bdf2e..2bcbe6b2c8b0 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-cursor-renderer-native.c
|
|
|
f7d48e |
+++ b/src/backends/native/meta-cursor-renderer-native.c
|
|
|
f7d48e |
@@ -1215,6 +1215,81 @@ ensure_cursor_priv (MetaCursorSprite *cursor_sprite)
|
|
|
f7d48e |
return cursor_priv;
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
+static MetaDrmBuffer *
|
|
|
f7d48e |
+create_cursor_drm_buffer_gbm (MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
+ uint8_t *pixels,
|
|
|
f7d48e |
+ int width,
|
|
|
f7d48e |
+ int height,
|
|
|
f7d48e |
+ int stride,
|
|
|
f7d48e |
+ int cursor_width,
|
|
|
f7d48e |
+ int cursor_height,
|
|
|
f7d48e |
+ uint32_t format,
|
|
|
f7d48e |
+ GError **error)
|
|
|
f7d48e |
+{
|
|
|
f7d48e |
+ MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
|
|
|
f7d48e |
+ struct gbm_device *gbm_device;
|
|
|
f7d48e |
+ struct gbm_bo *bo;
|
|
|
f7d48e |
+ uint8_t buf[4 * cursor_width * cursor_height];
|
|
|
f7d48e |
+ int i;
|
|
|
f7d48e |
+ MetaDrmBufferGbm *buffer_gbm;
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ gbm_device = meta_gbm_device_from_gpu (gpu_kms);
|
|
|
f7d48e |
+ if (!gbm_device_is_format_supported (gbm_device, format,
|
|
|
f7d48e |
+ GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
|
|
|
f7d48e |
+ {
|
|
|
f7d48e |
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
|
|
f7d48e |
+ "Buffer format not supported");
|
|
|
f7d48e |
+ return NULL;
|
|
|
f7d48e |
+ }
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ bo = gbm_bo_create (gbm_device, cursor_width, cursor_height,
|
|
|
f7d48e |
+ format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
|
|
f7d48e |
+ if (!bo)
|
|
|
f7d48e |
+ {
|
|
|
f7d48e |
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
|
|
f7d48e |
+ "Failed to allocate gbm_bo: %s", g_strerror (errno));
|
|
|
f7d48e |
+ return NULL;
|
|
|
f7d48e |
+ }
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ memset (buf, 0, sizeof (buf));
|
|
|
f7d48e |
+ for (i = 0; i < height; i++)
|
|
|
f7d48e |
+ memcpy (buf + i * 4 * cursor_width, pixels + i * stride, width * 4);
|
|
|
f7d48e |
+ if (gbm_bo_write (bo, buf, cursor_width * cursor_height * 4) != 0)
|
|
|
f7d48e |
+ {
|
|
|
f7d48e |
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
|
|
f7d48e |
+ "Failed write to gbm_bo: %s", g_strerror (errno));
|
|
|
f7d48e |
+ gbm_bo_destroy (bo);
|
|
|
f7d48e |
+ return NULL;
|
|
|
f7d48e |
+ }
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ buffer_gbm = meta_drm_buffer_gbm_new_take (kms_device, bo, FALSE, error);
|
|
|
f7d48e |
+ if (!buffer_gbm)
|
|
|
f7d48e |
+ {
|
|
|
f7d48e |
+ gbm_bo_destroy (bo);
|
|
|
f7d48e |
+ return NULL;
|
|
|
f7d48e |
+ }
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ return META_DRM_BUFFER (buffer_gbm);
|
|
|
f7d48e |
+}
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+static MetaDrmBuffer *
|
|
|
f7d48e |
+create_cursor_drm_buffer (MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
+ uint8_t *pixels,
|
|
|
f7d48e |
+ int width,
|
|
|
f7d48e |
+ int height,
|
|
|
f7d48e |
+ int stride,
|
|
|
f7d48e |
+ int cursor_width,
|
|
|
f7d48e |
+ int cursor_height,
|
|
|
f7d48e |
+ uint32_t format,
|
|
|
f7d48e |
+ GError **error)
|
|
|
f7d48e |
+{
|
|
|
f7d48e |
+ return create_cursor_drm_buffer_gbm (gpu_kms, pixels,
|
|
|
f7d48e |
+ width, height, stride,
|
|
|
f7d48e |
+ cursor_width, cursor_height,
|
|
|
f7d48e |
+ format,
|
|
|
f7d48e |
+ error);
|
|
|
f7d48e |
+}
|
|
|
f7d48e |
+
|
|
|
f7d48e |
static void
|
|
|
f7d48e |
load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
|
|
|
f7d48e |
MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
@@ -1226,8 +1301,9 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
|
|
|
f7d48e |
uint32_t gbm_format)
|
|
|
f7d48e |
{
|
|
|
f7d48e |
uint64_t cursor_width, cursor_height;
|
|
|
f7d48e |
+ MetaDrmBuffer *buffer;
|
|
|
f7d48e |
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
|
|
|
f7d48e |
- struct gbm_device *gbm_device;
|
|
|
f7d48e |
+ g_autoptr (GError) error = NULL;
|
|
|
f7d48e |
|
|
|
f7d48e |
cursor_renderer_gpu_data =
|
|
|
f7d48e |
meta_cursor_renderer_native_gpu_data_from_gpu (gpu_kms);
|
|
|
f7d48e |
@@ -1244,52 +1320,20 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
|
|
|
f7d48e |
return;
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
- gbm_device = meta_gbm_device_from_gpu (gpu_kms);
|
|
|
f7d48e |
- if (gbm_device_is_format_supported (gbm_device, gbm_format,
|
|
|
f7d48e |
- GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
|
|
|
f7d48e |
- {
|
|
|
f7d48e |
- MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
|
|
|
f7d48e |
- struct gbm_bo *bo;
|
|
|
f7d48e |
- uint8_t buf[4 * cursor_width * cursor_height];
|
|
|
f7d48e |
- uint i;
|
|
|
f7d48e |
- g_autoptr (GError) error = NULL;
|
|
|
f7d48e |
- MetaDrmBufferGbm *buffer_gbm;
|
|
|
f7d48e |
-
|
|
|
f7d48e |
- bo = gbm_bo_create (gbm_device, cursor_width, cursor_height,
|
|
|
f7d48e |
- gbm_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
|
|
f7d48e |
- if (!bo)
|
|
|
f7d48e |
- {
|
|
|
f7d48e |
- meta_warning ("Failed to allocate HW cursor buffer");
|
|
|
f7d48e |
- return;
|
|
|
f7d48e |
- }
|
|
|
f7d48e |
-
|
|
|
f7d48e |
- memset (buf, 0, sizeof(buf));
|
|
|
f7d48e |
- for (i = 0; i < height; i++)
|
|
|
f7d48e |
- memcpy (buf + i * 4 * cursor_width, pixels + i * rowstride, width * 4);
|
|
|
f7d48e |
- if (gbm_bo_write (bo, buf, cursor_width * cursor_height * 4) != 0)
|
|
|
f7d48e |
- {
|
|
|
f7d48e |
- meta_warning ("Failed to write cursors buffer data: %s",
|
|
|
f7d48e |
- g_strerror (errno));
|
|
|
f7d48e |
- gbm_bo_destroy (bo);
|
|
|
f7d48e |
- return;
|
|
|
f7d48e |
- }
|
|
|
f7d48e |
-
|
|
|
f7d48e |
- buffer_gbm = meta_drm_buffer_gbm_new_take (kms_device, bo, FALSE, &error);
|
|
|
f7d48e |
- if (!buffer_gbm)
|
|
|
f7d48e |
- {
|
|
|
f7d48e |
- meta_warning ("Failed to create DRM buffer wrapper: %s",
|
|
|
f7d48e |
- error->message);
|
|
|
f7d48e |
- gbm_bo_destroy (bo);
|
|
|
f7d48e |
- return;
|
|
|
f7d48e |
- }
|
|
|
f7d48e |
-
|
|
|
f7d48e |
- set_pending_cursor_sprite_buffer (cursor_sprite, gpu_kms,
|
|
|
f7d48e |
- META_DRM_BUFFER (buffer_gbm));
|
|
|
f7d48e |
- }
|
|
|
f7d48e |
- else
|
|
|
f7d48e |
+ buffer = create_cursor_drm_buffer (gpu_kms,
|
|
|
f7d48e |
+ pixels,
|
|
|
f7d48e |
+ width, height, rowstride,
|
|
|
f7d48e |
+ cursor_width,
|
|
|
f7d48e |
+ cursor_height,
|
|
|
f7d48e |
+ gbm_format,
|
|
|
f7d48e |
+ &error);
|
|
|
f7d48e |
+ if (!buffer)
|
|
|
f7d48e |
{
|
|
|
f7d48e |
- meta_warning ("HW cursor for format %d not supported", gbm_format);
|
|
|
f7d48e |
+ g_warning ("Realizing HW cursor failed: %s", error->message);
|
|
|
f7d48e |
+ return;
|
|
|
f7d48e |
}
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ set_pending_cursor_sprite_buffer (cursor_sprite, gpu_kms, buffer);
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
static gboolean
|
|
|
f7d48e |
--
|
|
|
f7d48e |
2.34.1
|
|
|
f7d48e |
|
|
|
f7d48e |
|
|
|
f7d48e |
From 717baf8dc1dd2f043350dd354bc4905285ba3337 Mon Sep 17 00:00:00 2001
|
|
|
f7d48e |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
f7d48e |
Date: Tue, 8 Feb 2022 15:38:37 +0100
|
|
|
f7d48e |
Subject: [PATCH 4/4] cursor-renderer/native: Support allocating dumb buffers
|
|
|
f7d48e |
|
|
|
f7d48e |
---
|
|
|
f7d48e |
.../native/meta-cursor-renderer-native.c | 88 ++++++++++++++-----
|
|
|
f7d48e |
1 file changed, 67 insertions(+), 21 deletions(-)
|
|
|
f7d48e |
|
|
|
f7d48e |
diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c
|
|
|
f7d48e |
index 2bcbe6b2c8b0..18ffdf37dac4 100644
|
|
|
f7d48e |
--- a/src/backends/native/meta-cursor-renderer-native.c
|
|
|
f7d48e |
+++ b/src/backends/native/meta-cursor-renderer-native.c
|
|
|
f7d48e |
@@ -39,6 +39,7 @@
|
|
|
f7d48e |
#include "backends/meta-monitor-manager-private.h"
|
|
|
f7d48e |
#include "backends/meta-output.h"
|
|
|
f7d48e |
#include "backends/native/meta-crtc-kms.h"
|
|
|
f7d48e |
+#include "backends/native/meta-drm-buffer-dumb.h"
|
|
|
f7d48e |
#include "backends/native/meta-drm-buffer-gbm.h"
|
|
|
f7d48e |
#include "backends/native/meta-kms-device.h"
|
|
|
f7d48e |
#include "backends/native/meta-kms-plane.h"
|
|
|
f7d48e |
@@ -1216,24 +1217,23 @@ ensure_cursor_priv (MetaCursorSprite *cursor_sprite)
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
static MetaDrmBuffer *
|
|
|
f7d48e |
-create_cursor_drm_buffer_gbm (MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
- uint8_t *pixels,
|
|
|
f7d48e |
- int width,
|
|
|
f7d48e |
- int height,
|
|
|
f7d48e |
- int stride,
|
|
|
f7d48e |
- int cursor_width,
|
|
|
f7d48e |
- int cursor_height,
|
|
|
f7d48e |
- uint32_t format,
|
|
|
f7d48e |
- GError **error)
|
|
|
f7d48e |
+create_cursor_drm_buffer_gbm (MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
+ struct gbm_device *gbm_device,
|
|
|
f7d48e |
+ uint8_t *pixels,
|
|
|
f7d48e |
+ int width,
|
|
|
f7d48e |
+ int height,
|
|
|
f7d48e |
+ int stride,
|
|
|
f7d48e |
+ int cursor_width,
|
|
|
f7d48e |
+ int cursor_height,
|
|
|
f7d48e |
+ uint32_t format,
|
|
|
f7d48e |
+ GError **error)
|
|
|
f7d48e |
{
|
|
|
f7d48e |
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
|
|
|
f7d48e |
- struct gbm_device *gbm_device;
|
|
|
f7d48e |
struct gbm_bo *bo;
|
|
|
f7d48e |
uint8_t buf[4 * cursor_width * cursor_height];
|
|
|
f7d48e |
int i;
|
|
|
f7d48e |
MetaDrmBufferGbm *buffer_gbm;
|
|
|
f7d48e |
|
|
|
f7d48e |
- gbm_device = meta_gbm_device_from_gpu (gpu_kms);
|
|
|
f7d48e |
if (!gbm_device_is_format_supported (gbm_device, format,
|
|
|
f7d48e |
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
|
|
|
f7d48e |
{
|
|
|
f7d48e |
@@ -1272,6 +1272,38 @@ create_cursor_drm_buffer_gbm (MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
return META_DRM_BUFFER (buffer_gbm);
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
+static MetaDrmBuffer *
|
|
|
f7d48e |
+create_cursor_drm_buffer_dumb (MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
+ uint8_t *pixels,
|
|
|
f7d48e |
+ int width,
|
|
|
f7d48e |
+ int height,
|
|
|
f7d48e |
+ int stride,
|
|
|
f7d48e |
+ int cursor_width,
|
|
|
f7d48e |
+ int cursor_height,
|
|
|
f7d48e |
+ uint32_t format,
|
|
|
f7d48e |
+ GError **error)
|
|
|
f7d48e |
+{
|
|
|
f7d48e |
+ MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
|
|
|
f7d48e |
+ MetaDrmBufferDumb *buffer_dumb;
|
|
|
f7d48e |
+ int i;
|
|
|
f7d48e |
+ uint8_t *data;
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ buffer_dumb = meta_drm_buffer_dumb_new (kms_device,
|
|
|
f7d48e |
+ cursor_width, cursor_height,
|
|
|
f7d48e |
+ format,
|
|
|
f7d48e |
+ error);
|
|
|
f7d48e |
+ if (!buffer_dumb)
|
|
|
f7d48e |
+ return NULL;
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ data = meta_drm_buffer_dumb_get_data (buffer_dumb);
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ memset (data, 0, cursor_width * cursor_height * 4);
|
|
|
f7d48e |
+ for (i = 0; i < height; i++)
|
|
|
f7d48e |
+ memcpy (data + i * 4 * cursor_width, pixels + i * stride, width * 4);
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ return META_DRM_BUFFER (buffer_dumb);
|
|
|
f7d48e |
+}
|
|
|
f7d48e |
+
|
|
|
f7d48e |
static MetaDrmBuffer *
|
|
|
f7d48e |
create_cursor_drm_buffer (MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
uint8_t *pixels,
|
|
|
f7d48e |
@@ -1283,11 +1315,27 @@ create_cursor_drm_buffer (MetaGpuKms *gpu_kms,
|
|
|
f7d48e |
uint32_t format,
|
|
|
f7d48e |
GError **error)
|
|
|
f7d48e |
{
|
|
|
f7d48e |
- return create_cursor_drm_buffer_gbm (gpu_kms, pixels,
|
|
|
f7d48e |
- width, height, stride,
|
|
|
f7d48e |
- cursor_width, cursor_height,
|
|
|
f7d48e |
- format,
|
|
|
f7d48e |
- error);
|
|
|
f7d48e |
+ struct gbm_device *gbm_device;
|
|
|
f7d48e |
+
|
|
|
f7d48e |
+ gbm_device = meta_gbm_device_from_gpu (gpu_kms);
|
|
|
f7d48e |
+ if (gbm_device)
|
|
|
f7d48e |
+ {
|
|
|
f7d48e |
+ return create_cursor_drm_buffer_gbm (gpu_kms, gbm_device,
|
|
|
f7d48e |
+ pixels,
|
|
|
f7d48e |
+ width, height, stride,
|
|
|
f7d48e |
+ cursor_width, cursor_height,
|
|
|
f7d48e |
+ format,
|
|
|
f7d48e |
+ error);
|
|
|
f7d48e |
+ }
|
|
|
f7d48e |
+ else
|
|
|
f7d48e |
+ {
|
|
|
f7d48e |
+ return create_cursor_drm_buffer_dumb (gpu_kms,
|
|
|
f7d48e |
+ pixels,
|
|
|
f7d48e |
+ width, height, stride,
|
|
|
f7d48e |
+ cursor_width, cursor_height,
|
|
|
f7d48e |
+ format,
|
|
|
f7d48e |
+ error);
|
|
|
f7d48e |
+ }
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
static void
|
|
|
f7d48e |
@@ -1629,6 +1677,9 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
|
|
|
f7d48e |
}
|
|
|
f7d48e |
|
|
|
f7d48e |
gbm_device = meta_gbm_device_from_gpu (gpu_kms);
|
|
|
f7d48e |
+ if (!gbm_device)
|
|
|
f7d48e |
+ return;
|
|
|
f7d48e |
+
|
|
|
f7d48e |
bo = gbm_bo_import (gbm_device,
|
|
|
f7d48e |
GBM_BO_IMPORT_WL_BUFFER,
|
|
|
f7d48e |
buffer,
|
|
|
f7d48e |
@@ -1807,13 +1858,8 @@ init_hw_cursor_support_for_gpu (MetaGpuKms *gpu_kms)
|
|
|
f7d48e |
{
|
|
|
f7d48e |
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
|
|
|
f7d48e |
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
|
|
|
f7d48e |
- struct gbm_device *gbm_device;
|
|
|
f7d48e |
uint64_t width, height;
|
|
|
f7d48e |
|
|
|
f7d48e |
- gbm_device = meta_gbm_device_from_gpu (gpu_kms);
|
|
|
f7d48e |
- if (!gbm_device)
|
|
|
f7d48e |
- return;
|
|
|
f7d48e |
-
|
|
|
f7d48e |
cursor_renderer_gpu_data =
|
|
|
f7d48e |
meta_create_cursor_renderer_native_gpu_data (gpu_kms);
|
|
|
f7d48e |
|
|
|
f7d48e |
--
|
|
|
f7d48e |
2.34.1
|
|
|
f7d48e |
|