drm-buffer: Create from MetaDeviceFile instead of MetaKmsDevice

The DRM buffers aren't really tied to mode setting, so they shouldn't
need to have an associated mode setting device. Now that we have a
device file level object that can fill this role, port over
MetaDrmBuffer and friends away from MetaKmsDevice to MetaDeviceFile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
This commit is contained in:
Jonas Ådahl 2021-04-12 16:13:29 +02:00
parent 6613463f58
commit 10c4bc6e3f
14 changed files with 185 additions and 260 deletions

View File

@ -38,7 +38,9 @@
#include "backends/meta-monitor.h" #include "backends/meta-monitor.h"
#include "backends/meta-monitor-manager-private.h" #include "backends/meta-monitor-manager-private.h"
#include "backends/meta-output.h" #include "backends/meta-output.h"
#include "backends/native/meta-backend-native-private.h"
#include "backends/native/meta-crtc-kms.h" #include "backends/native/meta-crtc-kms.h"
#include "backends/native/meta-device-pool.h"
#include "backends/native/meta-drm-buffer-gbm.h" #include "backends/native/meta-drm-buffer-gbm.h"
#include "backends/native/meta-kms-device.h" #include "backends/native/meta-kms-device.h"
#include "backends/native/meta-kms-plane.h" #include "backends/native/meta-kms-plane.h"
@ -1225,6 +1227,8 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
int rowstride, int rowstride,
uint32_t gbm_format) uint32_t gbm_format)
{ {
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
uint64_t cursor_width, cursor_height; uint64_t cursor_width, cursor_height;
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data; MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
struct gbm_device *gbm_device; struct gbm_device *gbm_device;
@ -1248,13 +1252,28 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
if (gbm_device_is_format_supported (gbm_device, gbm_format, if (gbm_device_is_format_supported (gbm_device, gbm_format,
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
{ {
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms); MetaBackendNative *backend_native = META_BACKEND_NATIVE (priv->backend);
MetaDevicePool *device_pool =
meta_backend_native_get_device_pool (backend_native);
g_autoptr (MetaDeviceFile) device_file = NULL;
struct gbm_bo *bo; struct gbm_bo *bo;
uint8_t buf[4 * cursor_width * cursor_height]; uint8_t buf[4 * cursor_width * cursor_height];
uint i; uint i;
g_autoptr (GError) error = NULL; g_autoptr (GError) error = NULL;
MetaDrmBufferGbm *buffer_gbm; MetaDrmBufferGbm *buffer_gbm;
device_file = meta_device_pool_open (device_pool,
meta_gpu_kms_get_file_path (gpu_kms),
META_DEVICE_FILE_FLAG_TAKE_CONTROL,
&error);
if (!device_file)
{
g_warning ("Failed to open '%s' for updating the cursor: %s",
meta_gpu_kms_get_file_path (gpu_kms),
error->message);
return;
}
bo = gbm_bo_create (gbm_device, cursor_width, cursor_height, bo = gbm_bo_create (gbm_device, cursor_width, cursor_height,
gbm_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE); gbm_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
if (!bo) if (!bo)
@ -1274,7 +1293,7 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
return; return;
} }
buffer_gbm = meta_drm_buffer_gbm_new_take (kms_device, bo, FALSE, &error); buffer_gbm = meta_drm_buffer_gbm_new_take (device_file, bo, FALSE, &error);
if (!buffer_gbm) if (!buffer_gbm)
{ {
meta_warning ("Failed to create DRM buffer wrapper: %s", meta_warning ("Failed to create DRM buffer wrapper: %s",
@ -1468,6 +1487,8 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
MetaCursorSpriteWayland *sprite_wayland) MetaCursorSpriteWayland *sprite_wayland)
{ {
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer); MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_wayland); MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_wayland);
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data; MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
uint64_t cursor_width, cursor_height; uint64_t cursor_width, cursor_height;
@ -1559,12 +1580,27 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
} }
else else
{ {
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms); MetaBackendNative *backend_native = META_BACKEND_NATIVE (priv->backend);
MetaDevicePool *device_pool =
meta_backend_native_get_device_pool (backend_native);
g_autoptr (MetaDeviceFile) device_file = NULL;
struct gbm_device *gbm_device; struct gbm_device *gbm_device;
struct gbm_bo *bo; struct gbm_bo *bo;
g_autoptr (GError) error = NULL; g_autoptr (GError) error = NULL;
MetaDrmBufferGbm *buffer_gbm; MetaDrmBufferGbm *buffer_gbm;
device_file = meta_device_pool_open (device_pool,
meta_gpu_kms_get_file_path (gpu_kms),
META_DEVICE_FILE_FLAG_TAKE_CONTROL,
&error);
if (!device_file)
{
g_warning ("Failed to open '%s' for updating the cursor: %s",
meta_gpu_kms_get_file_path (gpu_kms),
error->message);
return;
}
/* HW cursors have a predefined size (at least 64x64), which usually is /* HW cursors have a predefined size (at least 64x64), which usually is
* bigger than cursor theme size, so themed cursors must be padded with * bigger than cursor theme size, so themed cursors must be padded with
* transparent pixels to fill the overlay. This is trivial if we have CPU * transparent pixels to fill the overlay. This is trivial if we have CPU
@ -1597,7 +1633,7 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
unset_can_preprocess (cursor_sprite); unset_can_preprocess (cursor_sprite);
buffer_gbm = meta_drm_buffer_gbm_new_take (kms_device, bo, FALSE, &error); buffer_gbm = meta_drm_buffer_gbm_new_take (device_file, bo, FALSE, &error);
if (!buffer_gbm) if (!buffer_gbm)
{ {
meta_warning ("Failed to create DRM buffer wrapper: %s", meta_warning ("Failed to create DRM buffer wrapper: %s",

View File

@ -25,13 +25,12 @@
#include "backends/native/meta-drm-buffer-dumb.h" #include "backends/native/meta-drm-buffer-dumb.h"
#include <gio/gio.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include "backends/native/meta-kms-device-private.h" #include "backends/native/meta-device-pool.h"
#include "backends/native/meta-kms-impl-device.h"
#include "backends/native/meta-kms-private.h"
struct _MetaDrmBufferDumb struct _MetaDrmBufferDumb
{ {
@ -81,28 +80,18 @@ meta_drm_buffer_dumb_get_format (MetaDrmBuffer *buffer)
return buffer_dumb->drm_format; return buffer_dumb->drm_format;
} }
typedef struct static int
handle_to_dmabuf_fd (MetaDrmBufferDumb *buffer_dumb,
GError **error)
{ {
MetaDrmBufferDumb *buffer_dumb;
int out_dmabuf_fd;
} HandleToFdData;
static gpointer
handle_to_fd_in_impl (MetaKmsImpl *impl,
gpointer user_data,
GError **error)
{
HandleToFdData *data = user_data;
MetaDrmBufferDumb *buffer_dumb = data->buffer_dumb;
MetaDrmBuffer *buffer = META_DRM_BUFFER (buffer_dumb); MetaDrmBuffer *buffer = META_DRM_BUFFER (buffer_dumb);
MetaKmsDevice *device = meta_drm_buffer_get_device (buffer); MetaDeviceFile *device_file;
MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device);
int fd; int fd;
int ret; int ret;
int dmabuf_fd; int dmabuf_fd;
fd = meta_kms_impl_device_get_fd (impl_device); device_file = meta_drm_buffer_get_device_file (buffer);
fd = meta_device_file_get_fd (device_file);
ret = drmPrimeHandleToFD (fd, buffer_dumb->handle, DRM_CLOEXEC, ret = drmPrimeHandleToFD (fd, buffer_dumb->handle, DRM_CLOEXEC,
&dmabuf_fd); &dmabuf_fd);
@ -110,36 +99,20 @@ handle_to_fd_in_impl (MetaKmsImpl *impl,
{ {
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret), g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret),
"drmPrimeHandleToFd: %s", g_strerror (-ret)); "drmPrimeHandleToFd: %s", g_strerror (-ret));
return GINT_TO_POINTER (FALSE); return -1;
} }
data->out_dmabuf_fd = dmabuf_fd; return dmabuf_fd;
return GINT_TO_POINTER (TRUE);
} }
int int
meta_drm_buffer_dumb_ensure_dmabuf_fd (MetaDrmBufferDumb *buffer_dumb, meta_drm_buffer_dumb_ensure_dmabuf_fd (MetaDrmBufferDumb *buffer_dumb,
GError **error) GError **error)
{ {
MetaDrmBuffer *buffer = META_DRM_BUFFER (buffer_dumb);
MetaKmsDevice *device = meta_drm_buffer_get_device (buffer);
HandleToFdData data;
if (buffer_dumb->dmabuf_fd != -1) if (buffer_dumb->dmabuf_fd != -1)
return buffer_dumb->dmabuf_fd; return buffer_dumb->dmabuf_fd;
data = (HandleToFdData) { buffer_dumb->dmabuf_fd = handle_to_dmabuf_fd (buffer_dumb, error);
.buffer_dumb = buffer_dumb,
};
if (!meta_kms_run_impl_task_sync (meta_kms_device_get_kms (device),
handle_to_fd_in_impl,
&data,
error))
return -1;
buffer_dumb->dmabuf_fd = data.out_dmabuf_fd;
return buffer_dumb->dmabuf_fd; return buffer_dumb->dmabuf_fd;
} }
@ -149,24 +122,15 @@ meta_drm_buffer_dumb_get_data (MetaDrmBufferDumb *buffer_dumb)
return buffer_dumb->map; return buffer_dumb->map;
} }
typedef struct static gboolean
init_dumb_buffer (MetaDrmBufferDumb *buffer_dumb,
int width,
int height,
uint32_t format,
GError **error)
{ {
MetaDrmBufferDumb *buffer_dumb;
int width;
int height;
uint32_t format;
} InitDumbData;
static gpointer
init_dumb_buffer_in_impl (MetaKmsImpl *impl,
gpointer user_data,
GError **error)
{
InitDumbData *data = user_data;
MetaDrmBufferDumb *buffer_dumb = data->buffer_dumb;
MetaDrmBuffer *buffer = META_DRM_BUFFER (buffer_dumb); MetaDrmBuffer *buffer = META_DRM_BUFFER (buffer_dumb);
MetaKmsDevice *device = meta_drm_buffer_get_device (buffer); MetaDeviceFile *device_file;
MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device);
int fd; int fd;
struct drm_mode_create_dumb create_arg; struct drm_mode_create_dumb create_arg;
struct drm_mode_destroy_dumb destroy_arg; struct drm_mode_destroy_dumb destroy_arg;
@ -174,12 +138,13 @@ init_dumb_buffer_in_impl (MetaKmsImpl *impl,
void *map; void *map;
MetaDrmFbArgs fb_args; MetaDrmFbArgs fb_args;
fd = meta_kms_impl_device_get_fd (impl_device); device_file = meta_drm_buffer_get_device_file (buffer);
fd = meta_device_file_get_fd (device_file);
create_arg = (struct drm_mode_create_dumb) { create_arg = (struct drm_mode_create_dumb) {
.bpp = 32, /* RGBX8888 */ .bpp = 32, /* RGBX8888 */
.width = data->width, .width = width,
.height = data->height .height = height
}; };
if (drmIoctl (fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_arg) != 0) if (drmIoctl (fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_arg) != 0)
{ {
@ -191,9 +156,9 @@ init_dumb_buffer_in_impl (MetaKmsImpl *impl,
} }
fb_args = (MetaDrmFbArgs) { fb_args = (MetaDrmFbArgs) {
.width = data->width, .width = width,
.height = data->height, .height = height,
.format = data->format, .format = format,
.handles = { create_arg.handle }, .handles = { create_arg.handle },
.strides = { create_arg.pitch }, .strides = { create_arg.pitch },
}; };
@ -227,10 +192,10 @@ init_dumb_buffer_in_impl (MetaKmsImpl *impl,
buffer_dumb->handle = create_arg.handle; buffer_dumb->handle = create_arg.handle;
buffer_dumb->map = map; buffer_dumb->map = map;
buffer_dumb->map_size = create_arg.size; buffer_dumb->map_size = create_arg.size;
buffer_dumb->width = data->width; buffer_dumb->width = width;
buffer_dumb->height = data->height; buffer_dumb->height = height;
buffer_dumb->stride_bytes = create_arg.pitch; buffer_dumb->stride_bytes = create_arg.pitch;
buffer_dumb->drm_format = data->format; buffer_dumb->drm_format = format;
return FALSE; return FALSE;
@ -247,30 +212,19 @@ err_ioctl:
} }
MetaDrmBufferDumb * MetaDrmBufferDumb *
meta_drm_buffer_dumb_new (MetaKmsDevice *device, meta_drm_buffer_dumb_new (MetaDeviceFile *device_file,
int width, int width,
int height, int height,
uint32_t format, uint32_t format,
GError **error) GError **error)
{ {
MetaDrmBufferDumb *buffer_dumb; MetaDrmBufferDumb *buffer_dumb;
InitDumbData data;
buffer_dumb = g_object_new (META_TYPE_DRM_BUFFER_DUMB, buffer_dumb = g_object_new (META_TYPE_DRM_BUFFER_DUMB,
"device", device, "device-file", device_file,
NULL); NULL);
data = (InitDumbData) { if (!init_dumb_buffer (buffer_dumb, width, height, format, error))
.buffer_dumb = buffer_dumb,
.width = width,
.height = height,
.format = format,
};
if (meta_kms_run_impl_task_sync (meta_kms_device_get_kms (device),
init_dumb_buffer_in_impl,
&data,
error))
{ {
g_object_unref (buffer_dumb); g_object_unref (buffer_dumb);
return NULL; return NULL;
@ -279,19 +233,16 @@ meta_drm_buffer_dumb_new (MetaKmsDevice *device,
return buffer_dumb; return buffer_dumb;
} }
static gpointer static void
destroy_dumb_in_impl (MetaKmsImpl *impl, destroy_dumb_buffer (MetaDrmBufferDumb *buffer_dumb)
gpointer user_data,
GError **error)
{ {
MetaDrmBufferDumb *buffer_dumb = user_data;
MetaDrmBuffer *buffer = META_DRM_BUFFER (buffer_dumb); MetaDrmBuffer *buffer = META_DRM_BUFFER (buffer_dumb);
MetaKmsDevice *device = meta_drm_buffer_get_device (buffer); MetaDeviceFile *device_file;
MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device);
int fd; int fd;
struct drm_mode_destroy_dumb destroy_arg; struct drm_mode_destroy_dumb destroy_arg;
fd = meta_kms_impl_device_get_fd (impl_device); device_file = meta_drm_buffer_get_device_file (buffer);
fd = meta_device_file_get_fd (device_file);
munmap (buffer_dumb->map, buffer_dumb->map_size); munmap (buffer_dumb->map, buffer_dumb->map_size);
@ -302,8 +253,6 @@ destroy_dumb_in_impl (MetaKmsImpl *impl,
if (buffer_dumb->dmabuf_fd != -1) if (buffer_dumb->dmabuf_fd != -1)
close (buffer_dumb->dmabuf_fd); close (buffer_dumb->dmabuf_fd);
return GINT_TO_POINTER (TRUE);
} }
static void static void
@ -312,15 +261,7 @@ meta_drm_buffer_dumb_finalize (GObject *object)
MetaDrmBufferDumb *buffer_dumb = META_DRM_BUFFER_DUMB (object); MetaDrmBufferDumb *buffer_dumb = META_DRM_BUFFER_DUMB (object);
if (buffer_dumb->handle) if (buffer_dumb->handle)
{ destroy_dumb_buffer (buffer_dumb);
MetaDrmBuffer *buffer = META_DRM_BUFFER (buffer_dumb);
MetaKmsDevice *device = meta_drm_buffer_get_device (buffer);
meta_kms_run_impl_task_sync (meta_kms_device_get_kms (device),
destroy_dumb_in_impl,
buffer_dumb,
NULL);
}
G_OBJECT_CLASS (meta_drm_buffer_dumb_parent_class)->finalize (object); G_OBJECT_CLASS (meta_drm_buffer_dumb_parent_class)->finalize (object);
} }

View File

@ -22,8 +22,8 @@
#ifndef META_DRM_BUFFER_DUMB_H #ifndef META_DRM_BUFFER_DUMB_H
#define META_DRM_BUFFER_DUMB_H #define META_DRM_BUFFER_DUMB_H
#include "backends/native/meta-backend-native-types.h"
#include "backends/native/meta-drm-buffer-private.h" #include "backends/native/meta-drm-buffer-private.h"
#include "backends/native/meta-kms-device.h"
#define META_TYPE_DRM_BUFFER_DUMB (meta_drm_buffer_dumb_get_type ()) #define META_TYPE_DRM_BUFFER_DUMB (meta_drm_buffer_dumb_get_type ())
G_DECLARE_FINAL_TYPE (MetaDrmBufferDumb, G_DECLARE_FINAL_TYPE (MetaDrmBufferDumb,
@ -31,11 +31,11 @@ G_DECLARE_FINAL_TYPE (MetaDrmBufferDumb,
META, DRM_BUFFER_DUMB, META, DRM_BUFFER_DUMB,
MetaDrmBuffer) MetaDrmBuffer)
MetaDrmBufferDumb * meta_drm_buffer_dumb_new (MetaKmsDevice *device, MetaDrmBufferDumb * meta_drm_buffer_dumb_new (MetaDeviceFile *device,
int width, int width,
int height, int height,
uint32_t format, uint32_t format,
GError **error); GError **error);
int meta_drm_buffer_dumb_ensure_dmabuf_fd (MetaDrmBufferDumb *buffer_dumb, int meta_drm_buffer_dumb_ensure_dmabuf_fd (MetaDrmBufferDumb *buffer_dumb,
GError **error); GError **error);

View File

@ -27,11 +27,13 @@
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include <errno.h> #include <errno.h>
#include <gio/gio.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include "backends/native/meta-drm-buffer-private.h" #include "backends/meta-backend-private.h"
#include "backends/native/meta-cogl-utils.h" #include "backends/native/meta-cogl-utils.h"
#include "backends/native/meta-drm-buffer-private.h"
struct _MetaDrmBufferGbm struct _MetaDrmBufferGbm
{ {
@ -146,7 +148,7 @@ lock_front_buffer (MetaDrmBufferGbm *buffer_gbm,
} }
MetaDrmBufferGbm * MetaDrmBufferGbm *
meta_drm_buffer_gbm_new_lock_front (MetaKmsDevice *device, meta_drm_buffer_gbm_new_lock_front (MetaDeviceFile *device_file,
struct gbm_surface *gbm_surface, struct gbm_surface *gbm_surface,
gboolean use_modifiers, gboolean use_modifiers,
GError **error) GError **error)
@ -154,7 +156,7 @@ meta_drm_buffer_gbm_new_lock_front (MetaKmsDevice *device,
MetaDrmBufferGbm *buffer_gbm; MetaDrmBufferGbm *buffer_gbm;
buffer_gbm = g_object_new (META_TYPE_DRM_BUFFER_GBM, buffer_gbm = g_object_new (META_TYPE_DRM_BUFFER_GBM,
"device", device, "device-file", device_file,
NULL); NULL);
buffer_gbm->surface = gbm_surface; buffer_gbm->surface = gbm_surface;
@ -168,15 +170,15 @@ meta_drm_buffer_gbm_new_lock_front (MetaKmsDevice *device,
} }
MetaDrmBufferGbm * MetaDrmBufferGbm *
meta_drm_buffer_gbm_new_take (MetaKmsDevice *device, meta_drm_buffer_gbm_new_take (MetaDeviceFile *device_file,
struct gbm_bo *bo, struct gbm_bo *bo,
gboolean use_modifiers, gboolean use_modifiers,
GError **error) GError **error)
{ {
MetaDrmBufferGbm *buffer_gbm; MetaDrmBufferGbm *buffer_gbm;
buffer_gbm = g_object_new (META_TYPE_DRM_BUFFER_GBM, buffer_gbm = g_object_new (META_TYPE_DRM_BUFFER_GBM,
"device", device, "device-file", device_file,
NULL); NULL);
if (!init_fb_id (buffer_gbm, bo, use_modifiers, error)) if (!init_fb_id (buffer_gbm, bo, use_modifiers, error))

View File

@ -24,8 +24,8 @@
#include <gbm.h> #include <gbm.h>
#include "backends/native/meta-backend-native-types.h"
#include "backends/native/meta-drm-buffer-private.h" #include "backends/native/meta-drm-buffer-private.h"
#include "backends/native/meta-gpu-kms.h"
#define META_TYPE_DRM_BUFFER_GBM (meta_drm_buffer_gbm_get_type ()) #define META_TYPE_DRM_BUFFER_GBM (meta_drm_buffer_gbm_get_type ())
G_DECLARE_FINAL_TYPE (MetaDrmBufferGbm, G_DECLARE_FINAL_TYPE (MetaDrmBufferGbm,
@ -33,16 +33,16 @@ G_DECLARE_FINAL_TYPE (MetaDrmBufferGbm,
META, DRM_BUFFER_GBM, META, DRM_BUFFER_GBM,
MetaDrmBuffer) MetaDrmBuffer)
MetaDrmBufferGbm * meta_drm_buffer_gbm_new_lock_front (MetaKmsDevice *device, MetaDrmBufferGbm * meta_drm_buffer_gbm_new_lock_front (MetaDeviceFile *device_file,
struct gbm_surface *gbm_surface, struct gbm_surface *gbm_surface,
gboolean use_modifiers, gboolean use_modifiers,
GError **error); GError **error);
MetaDrmBufferGbm * meta_drm_buffer_gbm_new_take (MetaKmsDevice *device, MetaDrmBufferGbm * meta_drm_buffer_gbm_new_take (MetaDeviceFile *device_file,
struct gbm_bo *gbm_bo, struct gbm_bo *gbm_bo,
gboolean use_modifiers, gboolean use_modifiers,
GError **error); GError **error);
struct gbm_bo * meta_drm_buffer_gbm_get_bo (MetaDrmBufferGbm *buffer_gbm); struct gbm_bo * meta_drm_buffer_gbm_get_bo (MetaDrmBufferGbm *buffer_gbm);

View File

@ -158,7 +158,7 @@ out_close:
} }
MetaDrmBufferImport * MetaDrmBufferImport *
meta_drm_buffer_import_new (MetaKmsDevice *device, meta_drm_buffer_import_new (MetaDeviceFile *device_file,
struct gbm_device *gbm_device, struct gbm_device *gbm_device,
MetaDrmBufferGbm *buffer_gbm, MetaDrmBufferGbm *buffer_gbm,
GError **error) GError **error)
@ -166,7 +166,7 @@ meta_drm_buffer_import_new (MetaKmsDevice *device,
MetaDrmBufferImport *buffer_import; MetaDrmBufferImport *buffer_import;
buffer_import = g_object_new (META_TYPE_DRM_BUFFER_IMPORT, buffer_import = g_object_new (META_TYPE_DRM_BUFFER_IMPORT,
"device", device, "device-file", device_file,
NULL); NULL);
g_set_object (&buffer_import->importee, buffer_gbm); g_set_object (&buffer_import->importee, buffer_gbm);

View File

@ -47,7 +47,7 @@ G_DECLARE_FINAL_TYPE (MetaDrmBufferImport,
* The import has a high chance of failing under normal operating * The import has a high chance of failing under normal operating
* conditions and needs to be handled with fallbacks to something else. * conditions and needs to be handled with fallbacks to something else.
*/ */
MetaDrmBufferImport * meta_drm_buffer_import_new (MetaKmsDevice *device, MetaDrmBufferImport * meta_drm_buffer_import_new (MetaDeviceFile *device_file,
struct gbm_device *gbm_device, struct gbm_device *gbm_device,
MetaDrmBufferGbm *buffer_gbm, MetaDrmBufferGbm *buffer_gbm,
GError **error); GError **error);

View File

@ -21,8 +21,8 @@
#ifndef META_DRM_BUFFER_PRIVATE_H #ifndef META_DRM_BUFFER_PRIVATE_H
#define META_DRM_BUFFER_PRIVATE_H #define META_DRM_BUFFER_PRIVATE_H
#include "backends/native/meta-backend-native-types.h"
#include "backends/native/meta-drm-buffer.h" #include "backends/native/meta-drm-buffer.h"
#include "backends/native/meta-kms-device.h"
typedef struct _MetaDrmFbArgs typedef struct _MetaDrmFbArgs
{ {
@ -45,7 +45,7 @@ struct _MetaDrmBufferClass
uint32_t (* get_format) (MetaDrmBuffer *buffer); uint32_t (* get_format) (MetaDrmBuffer *buffer);
}; };
MetaKmsDevice * meta_drm_buffer_get_device (MetaDrmBuffer *buffer); MetaDeviceFile * meta_drm_buffer_get_device_file (MetaDrmBuffer *buffer);
gboolean meta_drm_buffer_ensure_fb_id (MetaDrmBuffer *buffer, gboolean meta_drm_buffer_ensure_fb_id (MetaDrmBuffer *buffer,
gboolean use_modifiers, gboolean use_modifiers,

View File

@ -28,10 +28,8 @@
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include "backends/native/meta-kms-device-private.h" #include "backends/native/meta-device-pool.h"
#include "backends/native/meta-kms-impl-device.h"
#include "backends/native/meta-kms-utils.h" #include "backends/native/meta-kms-utils.h"
#include "backends/native/meta-kms-private.h"
#define INVALID_FB_ID 0U #define INVALID_FB_ID 0U
@ -39,7 +37,7 @@ enum
{ {
PROP_0, PROP_0,
PROP_DEVICE, PROP_DEVICE_FILE,
N_PROPS N_PROPS
}; };
@ -48,35 +46,33 @@ static GParamSpec *obj_props[N_PROPS];
typedef struct _MetaDrmBufferPrivate typedef struct _MetaDrmBufferPrivate
{ {
MetaKmsDevice *device; MetaDeviceFile *device_file;
uint32_t fb_id; uint32_t fb_id;
} MetaDrmBufferPrivate; } MetaDrmBufferPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaDrmBuffer, meta_drm_buffer, G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaDrmBuffer, meta_drm_buffer,
G_TYPE_OBJECT) G_TYPE_OBJECT)
MetaKmsDevice * MetaDeviceFile *
meta_drm_buffer_get_device (MetaDrmBuffer *buffer) meta_drm_buffer_get_device_file (MetaDrmBuffer *buffer)
{ {
MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer); MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer);
return priv->device; return priv->device_file;
} }
gboolean gboolean
meta_drm_buffer_ensure_fb_in_impl (MetaDrmBuffer *buffer, meta_drm_buffer_ensure_fb_id (MetaDrmBuffer *buffer,
gboolean use_modifiers, gboolean use_modifiers,
const MetaDrmFbArgs *fb_args, const MetaDrmFbArgs *fb_args,
GError **error) GError **error)
{ {
MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer); MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer);
MetaKmsDevice *device = priv->device;
MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device);
int fd; int fd;
MetaDrmFormatBuf tmp; MetaDrmFormatBuf tmp;
uint32_t fb_id; uint32_t fb_id;
fd = meta_kms_impl_device_get_fd (impl_device); fd = meta_device_file_get_fd (priv->device_file);
if (use_modifiers && fb_args->modifiers[0] != DRM_FORMAT_MOD_INVALID) if (use_modifiers && fb_args->modifiers[0] != DRM_FORMAT_MOD_INVALID)
{ {
@ -139,98 +135,21 @@ meta_drm_buffer_ensure_fb_in_impl (MetaDrmBuffer *buffer,
} }
priv->fb_id = fb_id; priv->fb_id = fb_id;
return TRUE; return TRUE;
} }
typedef struct
{
MetaDrmBuffer *buffer;
gboolean use_modifiers;
MetaDrmFbArgs fb_args;
} AddFbData;
static gpointer
add_fb_in_impl (MetaKmsImpl *impl,
gpointer user_data,
GError **error)
{
AddFbData *data = user_data;
if (meta_drm_buffer_ensure_fb_in_impl (data->buffer,
data->use_modifiers,
&data->fb_args,
error))
return GINT_TO_POINTER (TRUE);
else
return GINT_TO_POINTER (FALSE);
}
gboolean
meta_drm_buffer_ensure_fb_id (MetaDrmBuffer *buffer,
gboolean use_modifiers,
const MetaDrmFbArgs *fb_args,
GError **error)
{
MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer);
AddFbData data;
data = (AddFbData) {
.buffer = buffer,
.use_modifiers = use_modifiers,
.fb_args = *fb_args,
};
if (!meta_kms_run_impl_task_sync (meta_kms_device_get_kms (priv->device),
add_fb_in_impl,
&data,
error))
return FALSE;
return TRUE;
}
typedef struct
{
MetaKmsDevice *device;
uint32_t fb_id;
} RmFbData;
static gpointer
rm_fb_in_impl (MetaKmsImpl *impl,
gpointer user_data,
GError **error)
{
RmFbData *data = user_data;
MetaKmsDevice *device = data->device;
MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device);
uint32_t fb_id = data->fb_id;
int fd;
int ret;
fd = meta_kms_impl_device_get_fd (impl_device);
ret = drmModeRmFB (fd, fb_id);
if (ret != 0)
g_warning ("drmModeRmFB: %s", g_strerror (-ret));
return GINT_TO_POINTER (TRUE);
}
static void static void
meta_drm_buffer_release_fb_id (MetaDrmBuffer *buffer) meta_drm_buffer_release_fb_id (MetaDrmBuffer *buffer)
{ {
MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer); MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer);
RmFbData data; int fd;
int ret;
data = (RmFbData) { fd = meta_device_file_get_fd (priv->device_file);
.device = priv->device, ret = drmModeRmFB (fd, priv->fb_id);
.fb_id = priv->fb_id, if (ret != 0)
}; g_warning ("drmModeRmFB: %s", g_strerror (-ret));
meta_kms_run_impl_task_sync (meta_kms_device_get_kms (priv->device),
rm_fb_in_impl,
&data,
NULL);
priv->fb_id = 0; priv->fb_id = 0;
} }
@ -277,8 +196,8 @@ meta_drm_buffer_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_DEVICE: case PROP_DEVICE_FILE:
g_value_set_object (value, priv->device); g_value_set_pointer (value, priv->device_file);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -297,8 +216,8 @@ meta_drm_buffer_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_DEVICE: case PROP_DEVICE_FILE:
priv->device = g_value_get_object (value); priv->device_file = g_value_get_pointer (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -314,10 +233,22 @@ meta_drm_buffer_finalize (GObject *object)
if (priv->fb_id != INVALID_FB_ID) if (priv->fb_id != INVALID_FB_ID)
meta_drm_buffer_release_fb_id (buffer); meta_drm_buffer_release_fb_id (buffer);
meta_device_file_release (priv->device_file);
G_OBJECT_CLASS (meta_drm_buffer_parent_class)->finalize (object); G_OBJECT_CLASS (meta_drm_buffer_parent_class)->finalize (object);
} }
static void
meta_drm_buffer_constructed (GObject *object)
{
MetaDrmBuffer *buffer = META_DRM_BUFFER (object);
MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer);
meta_device_file_acquire (priv->device_file);
G_OBJECT_CLASS (meta_drm_buffer_parent_class)->constructed (object);
}
static void static void
meta_drm_buffer_init (MetaDrmBuffer *buffer) meta_drm_buffer_init (MetaDrmBuffer *buffer)
{ {
@ -330,15 +261,15 @@ meta_drm_buffer_class_init (MetaDrmBufferClass *klass)
object_class->get_property = meta_drm_buffer_get_property; object_class->get_property = meta_drm_buffer_get_property;
object_class->set_property = meta_drm_buffer_set_property; object_class->set_property = meta_drm_buffer_set_property;
object_class->constructed = meta_drm_buffer_constructed;
object_class->finalize = meta_drm_buffer_finalize; object_class->finalize = meta_drm_buffer_finalize;
obj_props[PROP_DEVICE] = obj_props[PROP_DEVICE_FILE] =
g_param_spec_object ("device", g_param_spec_pointer ("device-file",
"device", "device file",
"MetaKmsDevice", "MetaDeviceFile",
META_TYPE_KMS_DEVICE, G_PARAM_READWRITE |
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props); g_object_class_install_properties (object_class, N_PROPS, obj_props);
} }

View File

@ -560,7 +560,7 @@ import_shared_framebuffer (CoglOnscreen *onscreen,
{ {
MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen); MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen);
MetaGpuKms *gpu_kms; MetaGpuKms *gpu_kms;
MetaKmsDevice *kms_device; MetaDeviceFile *device_file;
struct gbm_device *gbm_device; struct gbm_device *gbm_device;
MetaDrmBufferGbm *buffer_gbm; MetaDrmBufferGbm *buffer_gbm;
MetaDrmBufferImport *buffer_import; MetaDrmBufferImport *buffer_import;
@ -569,9 +569,9 @@ import_shared_framebuffer (CoglOnscreen *onscreen,
buffer_gbm = META_DRM_BUFFER_GBM (onscreen_native->gbm.next_fb); buffer_gbm = META_DRM_BUFFER_GBM (onscreen_native->gbm.next_fb);
gpu_kms = secondary_gpu_state->gpu_kms; gpu_kms = secondary_gpu_state->gpu_kms;
kms_device = meta_gpu_kms_get_kms_device (gpu_kms); device_file = secondary_gpu_state->renderer_gpu_data->device_file;
gbm_device = meta_gbm_device_from_gpu (gpu_kms); gbm_device = meta_gbm_device_from_gpu (gpu_kms);
buffer_import = meta_drm_buffer_import_new (kms_device, buffer_import = meta_drm_buffer_import_new (device_file,
gbm_device, gbm_device,
buffer_gbm, buffer_gbm,
&error); &error);
@ -639,7 +639,7 @@ copy_shared_framebuffer_gpu (CoglOnscreen *onscreen,
MetaGles3 *gles3 = meta_renderer_native_get_gles3 (renderer_native); MetaGles3 *gles3 = meta_renderer_native_get_gles3 (renderer_native);
GError *error = NULL; GError *error = NULL;
gboolean use_modifiers; gboolean use_modifiers;
MetaKmsDevice *kms_device; MetaDeviceFile *device_file;
MetaDrmBufferGbm *buffer_gbm; MetaDrmBufferGbm *buffer_gbm;
struct gbm_bo *bo; struct gbm_bo *bo;
@ -690,9 +690,9 @@ copy_shared_framebuffer_gpu (CoglOnscreen *onscreen,
} }
use_modifiers = meta_renderer_native_use_modifiers (renderer_native); use_modifiers = meta_renderer_native_use_modifiers (renderer_native);
kms_device = meta_gpu_kms_get_kms_device (secondary_gpu_state->gpu_kms); device_file = secondary_gpu_state->renderer_gpu_data->device_file;
buffer_gbm = buffer_gbm =
meta_drm_buffer_gbm_new_lock_front (kms_device, meta_drm_buffer_gbm_new_lock_front (device_file,
secondary_gpu_state->gbm.surface, secondary_gpu_state->gbm.surface,
use_modifiers, use_modifiers,
&error); &error);
@ -992,7 +992,7 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
MetaKms *kms = meta_backend_native_get_kms (backend_native); MetaKms *kms = meta_backend_native_get_kms (backend_native);
MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen); MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen);
MetaGpuKms *render_gpu = onscreen_native->render_gpu; MetaGpuKms *render_gpu = onscreen_native->render_gpu;
MetaKmsDevice *render_kms_device = meta_gpu_kms_get_kms_device (render_gpu); MetaDeviceFile *render_device_file;
ClutterFrame *frame = user_data; ClutterFrame *frame = user_data;
CoglOnscreenClass *parent_class; CoglOnscreenClass *parent_class;
gboolean egl_context_changed = FALSE; gboolean egl_context_changed = FALSE;
@ -1020,6 +1020,7 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
renderer_gpu_data = meta_renderer_native_get_gpu_data (renderer_native, renderer_gpu_data = meta_renderer_native_get_gpu_data (renderer_native,
render_gpu); render_gpu);
render_device_file = renderer_gpu_data->device_file;
switch (renderer_gpu_data->mode) switch (renderer_gpu_data->mode)
{ {
case META_RENDERER_NATIVE_MODE_GBM: case META_RENDERER_NATIVE_MODE_GBM:
@ -1028,7 +1029,7 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
use_modifiers = meta_renderer_native_use_modifiers (renderer_native); use_modifiers = meta_renderer_native_use_modifiers (renderer_native);
buffer_gbm = buffer_gbm =
meta_drm_buffer_gbm_new_lock_front (render_kms_device, meta_drm_buffer_gbm_new_lock_front (render_device_file,
onscreen_native->gbm.surface, onscreen_native->gbm.surface,
use_modifiers, use_modifiers,
&error); &error);
@ -1700,7 +1701,7 @@ meta_onscreen_native_allocate (CoglFramebuffer *framebuffer,
int width; int width;
int height; int height;
#ifdef HAVE_EGL_DEVICE #ifdef HAVE_EGL_DEVICE
MetaKmsDevice *render_kms_device; MetaDeviceFile *render_device_file;
EGLStreamKHR egl_stream; EGLStreamKHR egl_stream;
#endif #endif
CoglFramebufferClass *parent_class; CoglFramebufferClass *parent_class;
@ -1737,10 +1738,9 @@ meta_onscreen_native_allocate (CoglFramebuffer *framebuffer,
break; break;
#ifdef HAVE_EGL_DEVICE #ifdef HAVE_EGL_DEVICE
case META_RENDERER_NATIVE_MODE_EGL_DEVICE: case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
render_kms_device = render_device_file = renderer_gpu_data->device_file;
meta_gpu_kms_get_kms_device (onscreen_native->render_gpu);
onscreen_native->egl.dumb_fb = onscreen_native->egl.dumb_fb =
meta_drm_buffer_dumb_new (render_kms_device, meta_drm_buffer_dumb_new (render_device_file,
width, height, width, height,
DRM_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888,
error); error);
@ -1896,7 +1896,7 @@ init_secondary_gpu_state_cpu_copy_mode (MetaRendererNative *renderer_nat
MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen); MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen);
MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state; MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state;
MetaGpuKms *gpu_kms; MetaGpuKms *gpu_kms;
MetaKmsDevice *kms_device; MetaDeviceFile *device_file;
int width, height; int width, height;
unsigned int i; unsigned int i;
uint32_t drm_format; uint32_t drm_format;
@ -1914,7 +1914,7 @@ init_secondary_gpu_state_cpu_copy_mode (MetaRendererNative *renderer_nat
height = cogl_framebuffer_get_height (framebuffer); height = cogl_framebuffer_get_height (framebuffer);
gpu_kms = META_GPU_KMS (meta_crtc_get_gpu (onscreen_native->crtc)); gpu_kms = META_GPU_KMS (meta_crtc_get_gpu (onscreen_native->crtc));
kms_device = meta_gpu_kms_get_kms_device (gpu_kms); device_file = renderer_gpu_data->device_file;
g_debug ("Secondary GPU %s using DRM format '%s' (0x%x) for a %dx%d output.", g_debug ("Secondary GPU %s using DRM format '%s' (0x%x) for a %dx%d output.",
meta_gpu_kms_get_file_path (gpu_kms), meta_gpu_kms_get_file_path (gpu_kms),
meta_drm_format_to_string (&tmp, drm_format), meta_drm_format_to_string (&tmp, drm_format),
@ -1929,7 +1929,7 @@ init_secondary_gpu_state_cpu_copy_mode (MetaRendererNative *renderer_nat
for (i = 0; i < G_N_ELEMENTS (secondary_gpu_state->cpu.dumb_fbs); i++) for (i = 0; i < G_N_ELEMENTS (secondary_gpu_state->cpu.dumb_fbs); i++)
{ {
secondary_gpu_state->cpu.dumb_fbs[i] = secondary_gpu_state->cpu.dumb_fbs[i] =
meta_drm_buffer_dumb_new (kms_device, meta_drm_buffer_dumb_new (device_file,
width, height, width, height,
drm_format, drm_format,
error); error);

View File

@ -166,6 +166,17 @@ meta_renderer_native_get_primary_gpu (MetaRendererNative *renderer_native)
return renderer_native->primary_gpu_kms; return renderer_native->primary_gpu_kms;
} }
MetaDeviceFile *
meta_renderer_native_get_primary_device_file (MetaRendererNative *renderer_native)
{
MetaGpuKms *gpu_kms = renderer_native->primary_gpu_kms;
MetaRendererNativeGpuData *renderer_gpu_data;
renderer_gpu_data = meta_renderer_native_get_gpu_data (renderer_native,
gpu_kms);
return renderer_gpu_data->device_file;
}
static MetaRendererNativeGpuData * static MetaRendererNativeGpuData *
meta_create_renderer_native_gpu_data (void) meta_create_renderer_native_gpu_data (void)
{ {

View File

@ -54,6 +54,8 @@ struct gbm_device * meta_gbm_device_from_gpu (MetaGpuKms *gpu_kms);
MetaGpuKms * meta_renderer_native_get_primary_gpu (MetaRendererNative *renderer_native); MetaGpuKms * meta_renderer_native_get_primary_gpu (MetaRendererNative *renderer_native);
MetaDeviceFile * meta_renderer_native_get_primary_device_file (MetaRendererNative *renderer_native);
void meta_renderer_native_prepare_frame (MetaRendererNative *renderer_native, void meta_renderer_native_prepare_frame (MetaRendererNative *renderer_native,
MetaRendererView *view, MetaRendererView *view,
ClutterFrame *frame); ClutterFrame *frame);

View File

@ -688,7 +688,7 @@ try_acquire_egl_image_scanout (MetaWaylandBuffer *buffer,
MetaRenderer *renderer = meta_backend_get_renderer (backend); MetaRenderer *renderer = meta_backend_get_renderer (backend);
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer); MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
MetaGpuKms *gpu_kms; MetaGpuKms *gpu_kms;
MetaKmsDevice *kms_device; MetaDeviceFile *device_file;
struct gbm_device *gbm_device; struct gbm_device *gbm_device;
struct gbm_bo *gbm_bo; struct gbm_bo *gbm_bo;
uint32_t drm_format; uint32_t drm_format;
@ -698,7 +698,7 @@ try_acquire_egl_image_scanout (MetaWaylandBuffer *buffer,
g_autoptr (GError) error = NULL; g_autoptr (GError) error = NULL;
gpu_kms = meta_renderer_native_get_primary_gpu (renderer_native); gpu_kms = meta_renderer_native_get_primary_gpu (renderer_native);
kms_device = meta_gpu_kms_get_kms_device (gpu_kms); device_file = meta_renderer_native_get_primary_device_file (renderer_native);
gbm_device = meta_gbm_device_from_gpu (gpu_kms); gbm_device = meta_gbm_device_from_gpu (gpu_kms);
gbm_bo = gbm_bo_import (gbm_device, gbm_bo = gbm_bo_import (gbm_device,
@ -719,7 +719,8 @@ try_acquire_egl_image_scanout (MetaWaylandBuffer *buffer,
return NULL; return NULL;
} }
fb = meta_drm_buffer_gbm_new_take (kms_device, gbm_bo, fb = meta_drm_buffer_gbm_new_take (device_file,
gbm_bo,
drm_modifier != DRM_FORMAT_MOD_INVALID, drm_modifier != DRM_FORMAT_MOD_INVALID,
&error); &error);
if (!fb) if (!fb)

View File

@ -273,8 +273,8 @@ meta_wayland_dma_buf_try_acquire_scanout (MetaWaylandDmaBufBuffer *dma_buf,
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
MetaRenderer *renderer = meta_backend_get_renderer (backend); MetaRenderer *renderer = meta_backend_get_renderer (backend);
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer); MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
MetaDeviceFile *device_file;
MetaGpuKms *gpu_kms; MetaGpuKms *gpu_kms;
MetaKmsDevice *kms_device;
int n_planes; int n_planes;
uint32_t drm_format; uint32_t drm_format;
uint64_t drm_modifier; uint64_t drm_modifier;
@ -299,8 +299,8 @@ meta_wayland_dma_buf_try_acquire_scanout (MetaWaylandDmaBufBuffer *dma_buf,
stride)) stride))
return NULL; return NULL;
device_file = meta_renderer_native_get_primary_device_file (renderer_native);
gpu_kms = meta_renderer_native_get_primary_gpu (renderer_native); gpu_kms = meta_renderer_native_get_primary_gpu (renderer_native);
kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
gbm_bo = import_scanout_gbm_bo (dma_buf, gpu_kms, n_planes, &use_modifier); gbm_bo = import_scanout_gbm_bo (dma_buf, gpu_kms, n_planes, &use_modifier);
if (!gbm_bo) if (!gbm_bo)
{ {
@ -308,7 +308,8 @@ meta_wayland_dma_buf_try_acquire_scanout (MetaWaylandDmaBufBuffer *dma_buf,
return NULL; return NULL;
} }
fb = meta_drm_buffer_gbm_new_take (kms_device, gbm_bo, fb = meta_drm_buffer_gbm_new_take (device_file,
gbm_bo,
use_modifier, use_modifier,
&error); &error);
if (!fb) if (!fb)