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