kms-buffer: Rename to MetaDrmBuffer

MetaKms* will be a dedicated namespace, which MetaKmsBuffer doesn't fit
under.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
This commit is contained in:
Jonas Ådahl 2019-05-20 21:20:17 +02:00 committed by Georges Basile Stavracas Neto
parent 08aec58c22
commit 7fb7b28cd6
4 changed files with 94 additions and 96 deletions

View File

@ -24,7 +24,7 @@
#include "config.h" #include "config.h"
#include "backends/native/meta-kms-buffer.h" #include "backends/native/meta-drm-buffer.h"
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include <errno.h> #include <errno.h>
@ -33,17 +33,17 @@
#define INVALID_FB_ID 0U #define INVALID_FB_ID 0U
typedef enum _MetaKmsBufferType typedef enum _MetaDrmBufferType
{ {
META_KMS_BUFFER_TYPE_GBM, META_DRM_BUFFER_TYPE_GBM,
META_KMS_BUFFER_TYPE_WRAPPED_DUMB META_DRM_BUFFER_TYPE_WRAPPED_DUMB
} MetaKmsBufferType; } MetaDrmBufferType;
struct _MetaKmsBuffer struct _MetaDrmBuffer
{ {
GObject parent; GObject parent;
MetaKmsBufferType type; MetaDrmBufferType type;
union union
{ {
@ -64,10 +64,10 @@ struct _MetaKmsBuffer
}; };
}; };
G_DEFINE_TYPE (MetaKmsBuffer, meta_kms_buffer, G_TYPE_OBJECT) G_DEFINE_TYPE (MetaDrmBuffer, meta_drm_buffer, G_TYPE_OBJECT)
static gboolean static gboolean
meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer, meta_drm_buffer_acquire_swapped_buffer (MetaDrmBuffer *buffer,
gboolean use_modifiers, gboolean use_modifiers,
GError **error) GError **error)
{ {
@ -80,17 +80,17 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
int i; int i;
int drm_fd; int drm_fd;
g_return_val_if_fail (META_IS_KMS_BUFFER (kms_buffer), FALSE); g_return_val_if_fail (META_IS_DRM_BUFFER (buffer), FALSE);
g_return_val_if_fail (kms_buffer->type == META_KMS_BUFFER_TYPE_GBM, FALSE); g_return_val_if_fail (buffer->type == META_DRM_BUFFER_TYPE_GBM, FALSE);
g_return_val_if_fail (kms_buffer->gbm.bo == NULL, FALSE); g_return_val_if_fail (buffer->gbm.bo == NULL, FALSE);
g_return_val_if_fail (kms_buffer->gbm.surface != NULL, FALSE); g_return_val_if_fail (buffer->gbm.surface != NULL, FALSE);
g_return_val_if_fail (kms_buffer->gbm.gpu_kms != NULL, FALSE); g_return_val_if_fail (buffer->gbm.gpu_kms != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
drm_fd = meta_gpu_kms_get_fd (kms_buffer->gbm.gpu_kms); drm_fd = meta_gpu_kms_get_fd (buffer->gbm.gpu_kms);
g_return_val_if_fail (drm_fd >= 0, FALSE); g_return_val_if_fail (drm_fd >= 0, FALSE);
bo = gbm_surface_lock_front_buffer (kms_buffer->gbm.surface); bo = gbm_surface_lock_front_buffer (buffer->gbm.surface);
if (!bo) if (!bo)
{ {
g_set_error (error, g_set_error (error,
@ -133,7 +133,7 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
strides, strides,
offsets, offsets,
modifiers, modifiers,
&kms_buffer->fb_id, &buffer->fb_id,
DRM_MODE_FB_MODIFIERS)) DRM_MODE_FB_MODIFIERS))
{ {
g_set_error (error, g_set_error (error,
@ -141,7 +141,7 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
g_io_error_from_errno (errno), g_io_error_from_errno (errno),
"drmModeAddFB2WithModifiers failed: %s", "drmModeAddFB2WithModifiers failed: %s",
g_strerror (errno)); g_strerror (errno));
gbm_surface_release_buffer (kms_buffer->gbm.surface, bo); gbm_surface_release_buffer (buffer->gbm.surface, bo);
return FALSE; return FALSE;
} }
} }
@ -152,7 +152,7 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
handles, handles,
strides, strides,
offsets, offsets,
&kms_buffer->fb_id, &buffer->fb_id,
0)) 0))
{ {
if (format != DRM_FORMAT_XRGB8888) if (format != DRM_FORMAT_XRGB8888)
@ -162,7 +162,7 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
G_IO_ERROR_FAILED, G_IO_ERROR_FAILED,
"drmModeAddFB does not support format 0x%x", "drmModeAddFB does not support format 0x%x",
format); format);
gbm_surface_release_buffer (kms_buffer->gbm.surface, bo); gbm_surface_release_buffer (buffer->gbm.surface, bo);
return FALSE; return FALSE;
} }
@ -173,115 +173,114 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
32, 32,
strides[0], strides[0],
handles[0], handles[0],
&kms_buffer->fb_id)) &buffer->fb_id))
{ {
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
g_io_error_from_errno (errno), g_io_error_from_errno (errno),
"drmModeAddFB failed: %s", "drmModeAddFB failed: %s",
g_strerror (errno)); g_strerror (errno));
gbm_surface_release_buffer (kms_buffer->gbm.surface, bo); gbm_surface_release_buffer (buffer->gbm.surface, bo);
return FALSE; return FALSE;
} }
} }
kms_buffer->gbm.bo = bo; buffer->gbm.bo = bo;
return TRUE; return TRUE;
} }
static void static void
meta_kms_buffer_init (MetaKmsBuffer *kms_buffer) meta_drm_buffer_init (MetaDrmBuffer *buffer)
{ {
} }
static void static void
meta_kms_buffer_finalize (GObject *object) meta_drm_buffer_finalize (GObject *object)
{ {
MetaKmsBuffer *kms_buffer = META_KMS_BUFFER (object); MetaDrmBuffer *buffer = META_DRM_BUFFER (object);
if (kms_buffer->type == META_KMS_BUFFER_TYPE_GBM) if (buffer->type == META_DRM_BUFFER_TYPE_GBM)
{ {
if (kms_buffer->gbm.gpu_kms != NULL && if (buffer->gbm.gpu_kms != NULL &&
kms_buffer->gbm.fb_id != INVALID_FB_ID) buffer->gbm.fb_id != INVALID_FB_ID)
{ {
int drm_fd = meta_gpu_kms_get_fd (kms_buffer->gbm.gpu_kms); int drm_fd = meta_gpu_kms_get_fd (buffer->gbm.gpu_kms);
drmModeRmFB (drm_fd, buffer->fb_id);
drmModeRmFB (drm_fd, kms_buffer->fb_id); buffer->fb_id = INVALID_FB_ID;
kms_buffer->fb_id = INVALID_FB_ID;
} }
if (kms_buffer->gbm.surface && if (buffer->gbm.surface &&
kms_buffer->gbm.bo) buffer->gbm.bo)
{ {
gbm_surface_release_buffer (kms_buffer->gbm.surface, gbm_surface_release_buffer (buffer->gbm.surface,
kms_buffer->gbm.bo); buffer->gbm.bo);
} }
} }
G_OBJECT_CLASS (meta_kms_buffer_parent_class)->finalize (object); G_OBJECT_CLASS (meta_drm_buffer_parent_class)->finalize (object);
} }
static void static void
meta_kms_buffer_class_init (MetaKmsBufferClass *klass) meta_drm_buffer_class_init (MetaDrmBufferClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_kms_buffer_finalize; object_class->finalize = meta_drm_buffer_finalize;
} }
MetaKmsBuffer * MetaDrmBuffer *
meta_kms_buffer_new_from_gbm (MetaGpuKms *gpu_kms, meta_drm_buffer_new_from_gbm (MetaGpuKms *gpu_kms,
struct gbm_surface *gbm_surface, struct gbm_surface *gbm_surface,
gboolean use_modifiers, gboolean use_modifiers,
GError **error) GError **error)
{ {
MetaKmsBuffer *kms_buffer; MetaDrmBuffer *buffer;
g_return_val_if_fail (META_IS_GPU_KMS (gpu_kms), NULL); g_return_val_if_fail (META_IS_GPU_KMS (gpu_kms), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL);
kms_buffer = g_object_new (META_TYPE_KMS_BUFFER, NULL); buffer = g_object_new (META_TYPE_DRM_BUFFER, NULL);
kms_buffer->type = META_KMS_BUFFER_TYPE_GBM; buffer->type = META_DRM_BUFFER_TYPE_GBM;
kms_buffer->gbm.gpu_kms = gpu_kms; buffer->gbm.gpu_kms = gpu_kms;
kms_buffer->gbm.surface = gbm_surface; buffer->gbm.surface = gbm_surface;
if (!meta_kms_buffer_acquire_swapped_buffer (kms_buffer, if (!meta_drm_buffer_acquire_swapped_buffer (buffer,
use_modifiers, use_modifiers,
error)) error))
{ {
g_object_unref (kms_buffer); g_object_unref (buffer);
return NULL; return NULL;
} }
return kms_buffer; return buffer;
} }
MetaKmsBuffer * MetaDrmBuffer *
meta_kms_buffer_new_from_dumb (uint32_t dumb_fb_id) meta_drm_buffer_new_from_dumb (uint32_t dumb_fb_id)
{ {
MetaKmsBuffer *kms_buffer; MetaDrmBuffer *buffer;
kms_buffer = g_object_new (META_TYPE_KMS_BUFFER, NULL); buffer = g_object_new (META_TYPE_DRM_BUFFER, NULL);
kms_buffer->type = META_KMS_BUFFER_TYPE_WRAPPED_DUMB; buffer->type = META_DRM_BUFFER_TYPE_WRAPPED_DUMB;
kms_buffer->wrapped_dumb.fb_id = dumb_fb_id; buffer->wrapped_dumb.fb_id = dumb_fb_id;
return kms_buffer; return buffer;
} }
uint32_t uint32_t
meta_kms_buffer_get_fb_id (const MetaKmsBuffer *kms_buffer) meta_drm_buffer_get_fb_id (const MetaDrmBuffer *buffer)
{ {
g_return_val_if_fail (kms_buffer != NULL, INVALID_FB_ID); g_return_val_if_fail (buffer != NULL, INVALID_FB_ID);
return kms_buffer->fb_id; return buffer->fb_id;
} }
struct gbm_bo * struct gbm_bo *
meta_kms_buffer_get_bo (const MetaKmsBuffer *kms_buffer) meta_drm_buffer_get_bo (const MetaDrmBuffer *buffer)
{ {
g_return_val_if_fail (kms_buffer != NULL, NULL); g_return_val_if_fail (buffer, NULL);
g_return_val_if_fail (kms_buffer->type == META_KMS_BUFFER_TYPE_GBM, NULL); g_return_val_if_fail (buffer->type == META_DRM_BUFFER_TYPE_GBM, NULL);
return kms_buffer->gbm.bo; return buffer->gbm.bo;
} }

View File

@ -19,32 +19,31 @@
* Author: Daniel van Vugt <daniel.van.vugt@canonical.com> * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
*/ */
#ifndef META_KMS_BUFFER_H #ifndef META_DRM_BUFFER_H
#define META_KMS_BUFFER_H #define META_DRM_BUFFER_H
#include "backends/native/meta-gpu-kms.h" #include "backends/native/meta-gpu-kms.h"
#include <gbm.h> #include <gbm.h>
#include <glib-object.h> #include <glib-object.h>
#define META_TYPE_KMS_BUFFER (meta_kms_buffer_get_type ()) #define META_TYPE_DRM_BUFFER (meta_drm_buffer_get_type ())
G_DECLARE_FINAL_TYPE (MetaKmsBuffer, G_DECLARE_FINAL_TYPE (MetaDrmBuffer,
meta_kms_buffer, meta_drm_buffer,
META, META, DRM_BUFFER,
KMS_BUFFER,
GObject) GObject)
MetaKmsBuffer * MetaDrmBuffer *
meta_kms_buffer_new_from_gbm (MetaGpuKms *gpu_kms, meta_drm_buffer_new_from_gbm (MetaGpuKms *gpu_kms,
struct gbm_surface *gbm_surface, struct gbm_surface *gbm_surface,
gboolean use_modifiers, gboolean use_modifiers,
GError **error); GError **error);
MetaKmsBuffer * MetaDrmBuffer *
meta_kms_buffer_new_from_dumb (uint32_t dumb_fb_id); meta_drm_buffer_new_from_dumb (uint32_t dumb_fb_id);
uint32_t meta_kms_buffer_get_fb_id (const MetaKmsBuffer *kms_buffer); uint32_t meta_drm_buffer_get_fb_id (const MetaDrmBuffer *buffer);
struct gbm_bo *meta_kms_buffer_get_bo (const MetaKmsBuffer *kms_buffer); struct gbm_bo *meta_drm_buffer_get_bo (const MetaDrmBuffer *buffer);
#endif /* META_KMS_BUFFER_H */ #endif /* META_DRM_BUFFER_H */

View File

@ -58,8 +58,8 @@
#include "backends/meta-output.h" #include "backends/meta-output.h"
#include "backends/meta-renderer-view.h" #include "backends/meta-renderer-view.h"
#include "backends/native/meta-crtc-kms.h" #include "backends/native/meta-crtc-kms.h"
#include "backends/native/meta-drm-buffer.h"
#include "backends/native/meta-gpu-kms.h" #include "backends/native/meta-gpu-kms.h"
#include "backends/native/meta-kms-buffer.h"
#include "backends/native/meta-monitor-manager-kms.h" #include "backends/native/meta-monitor-manager-kms.h"
#include "backends/native/meta-renderer-native-gles3.h" #include "backends/native/meta-renderer-native-gles3.h"
#include "backends/native/meta-renderer-native.h" #include "backends/native/meta-renderer-native.h"
@ -145,8 +145,8 @@ typedef struct _MetaOnscreenNativeSecondaryGpuState
struct { struct {
struct gbm_surface *surface; struct gbm_surface *surface;
MetaKmsBuffer *current_fb; MetaDrmBuffer *current_fb;
MetaKmsBuffer *next_fb; MetaDrmBuffer *next_fb;
} gbm; } gbm;
struct { struct {
@ -167,8 +167,8 @@ typedef struct _MetaOnscreenNative
struct { struct {
struct gbm_surface *surface; struct gbm_surface *surface;
MetaKmsBuffer *current_fb; MetaDrmBuffer *current_fb;
MetaKmsBuffer *next_fb; MetaDrmBuffer *next_fb;
} gbm; } gbm;
#ifdef HAVE_EGL_DEVICE #ifdef HAVE_EGL_DEVICE
@ -1753,12 +1753,12 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen,
case META_RENDERER_NATIVE_MODE_GBM: case META_RENDERER_NATIVE_MODE_GBM:
if (gpu_kms == render_gpu) if (gpu_kms == render_gpu)
{ {
fb_id = meta_kms_buffer_get_fb_id (onscreen_native->gbm.next_fb); fb_id = meta_drm_buffer_get_fb_id (onscreen_native->gbm.next_fb);
} }
else else
{ {
secondary_gpu_state = get_secondary_gpu_state (onscreen, gpu_kms); secondary_gpu_state = get_secondary_gpu_state (onscreen, gpu_kms);
fb_id = meta_kms_buffer_get_fb_id (secondary_gpu_state->gbm.next_fb); fb_id = meta_drm_buffer_get_fb_id (secondary_gpu_state->gbm.next_fb);
} }
if (!meta_gpu_kms_flip_crtc (gpu_kms, if (!meta_gpu_kms_flip_crtc (gpu_kms,
@ -1824,7 +1824,7 @@ set_crtc_fb (CoglOnscreen *onscreen,
if (!secondary_gpu_state) if (!secondary_gpu_state)
return; return;
fb_id = meta_kms_buffer_get_fb_id (secondary_gpu_state->gbm.next_fb); fb_id = meta_drm_buffer_get_fb_id (secondary_gpu_state->gbm.next_fb);
} }
x = crtc->rect.x - logical_monitor->rect.x; x = crtc->rect.x - logical_monitor->rect.x;
@ -1867,7 +1867,7 @@ meta_onscreen_native_set_crtc_modes (CoglOnscreen *onscreen)
switch (renderer_gpu_data->mode) switch (renderer_gpu_data->mode)
{ {
case META_RENDERER_NATIVE_MODE_GBM: case META_RENDERER_NATIVE_MODE_GBM:
fb_id = meta_kms_buffer_get_fb_id (onscreen_native->gbm.next_fb); fb_id = meta_drm_buffer_get_fb_id (onscreen_native->gbm.next_fb);
break; break;
#ifdef HAVE_EGL_DEVICE #ifdef HAVE_EGL_DEVICE
case META_RENDERER_NATIVE_MODE_EGL_DEVICE: case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
@ -1935,7 +1935,7 @@ crtc_mode_set_fallback (CoglOnscreen *onscreen,
return FALSE; return FALSE;
} }
fb_id = meta_kms_buffer_get_fb_id (onscreen_native->gbm.next_fb); fb_id = meta_drm_buffer_get_fb_id (onscreen_native->gbm.next_fb);
set_crtc_fb (onscreen, logical_monitor, crtc, fb_id); set_crtc_fb (onscreen, logical_monitor, crtc, fb_id);
return TRUE; return TRUE;
} }
@ -2087,7 +2087,7 @@ copy_shared_framebuffer_gpu (CoglOnscreen *onscreen,
renderer_gpu_data->egl_display, renderer_gpu_data->egl_display,
renderer_gpu_data->secondary.egl_context, renderer_gpu_data->secondary.egl_context,
secondary_gpu_state->egl_surface, secondary_gpu_state->egl_surface,
meta_kms_buffer_get_bo (onscreen_native->gbm.next_fb), meta_drm_buffer_get_bo (onscreen_native->gbm.next_fb),
&error)) &error))
{ {
g_warning ("Failed to blit shared framebuffer: %s", error->message); g_warning ("Failed to blit shared framebuffer: %s", error->message);
@ -2107,13 +2107,13 @@ copy_shared_framebuffer_gpu (CoglOnscreen *onscreen,
g_clear_object (&secondary_gpu_state->gbm.next_fb); g_clear_object (&secondary_gpu_state->gbm.next_fb);
secondary_gpu_state->gbm.next_fb = secondary_gpu_state->gbm.next_fb =
meta_kms_buffer_new_from_gbm (secondary_gpu_state->gpu_kms, meta_drm_buffer_new_from_gbm (secondary_gpu_state->gpu_kms,
secondary_gpu_state->gbm.surface, secondary_gpu_state->gbm.surface,
renderer_native->use_modifiers, renderer_native->use_modifiers,
&error); &error);
if (!secondary_gpu_state->gbm.next_fb) if (!secondary_gpu_state->gbm.next_fb)
{ {
g_warning ("meta_kms_buffer_new_from_gbm failed: %s", g_warning ("meta_drm_buffer_new_from_gbm failed: %s",
error->message); error->message);
g_error_free (error); g_error_free (error);
return; return;
@ -2238,7 +2238,7 @@ copy_shared_framebuffer_cpu (CoglOnscreen *onscreen,
g_clear_object (&secondary_gpu_state->gbm.next_fb); g_clear_object (&secondary_gpu_state->gbm.next_fb);
secondary_gpu_state->gbm.next_fb = secondary_gpu_state->gbm.next_fb =
meta_kms_buffer_new_from_dumb (target_fb_id); meta_drm_buffer_new_from_dumb (target_fb_id);
} }
static void static void
@ -2350,13 +2350,13 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
g_warn_if_fail (onscreen_native->gbm.next_fb == NULL); g_warn_if_fail (onscreen_native->gbm.next_fb == NULL);
g_clear_object (&onscreen_native->gbm.next_fb); g_clear_object (&onscreen_native->gbm.next_fb);
onscreen_native->gbm.next_fb = onscreen_native->gbm.next_fb =
meta_kms_buffer_new_from_gbm (render_gpu, meta_drm_buffer_new_from_gbm (render_gpu,
onscreen_native->gbm.surface, onscreen_native->gbm.surface,
renderer_native->use_modifiers, renderer_native->use_modifiers,
&error); &error);
if (!onscreen_native->gbm.next_fb) if (!onscreen_native->gbm.next_fb)
{ {
g_warning ("meta_kms_buffer_new_from_gbm failed: %s", g_warning ("meta_drm_buffer_new_from_gbm failed: %s",
error->message); error->message);
return; return;
} }

View File

@ -574,12 +574,12 @@ if have_native_backend
'backends/native/meta-crtc-kms.h', 'backends/native/meta-crtc-kms.h',
'backends/native/meta-cursor-renderer-native.c', 'backends/native/meta-cursor-renderer-native.c',
'backends/native/meta-cursor-renderer-native.h', 'backends/native/meta-cursor-renderer-native.h',
'backends/native/meta-drm-buffer.c',
'backends/native/meta-drm-buffer.h',
'backends/native/meta-gpu-kms.c', 'backends/native/meta-gpu-kms.c',
'backends/native/meta-gpu-kms.h', 'backends/native/meta-gpu-kms.h',
'backends/native/meta-input-settings-native.c', 'backends/native/meta-input-settings-native.c',
'backends/native/meta-input-settings-native.h', 'backends/native/meta-input-settings-native.h',
'backends/native/meta-kms-buffer.c',
'backends/native/meta-kms-buffer.h',
'backends/native/meta-launcher.c', 'backends/native/meta-launcher.c',
'backends/native/meta-launcher.h', 'backends/native/meta-launcher.h',
'backends/native/meta-monitor-manager-kms.c', 'backends/native/meta-monitor-manager-kms.c',