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 "backends/native/meta-kms-buffer.h"
#include "backends/native/meta-drm-buffer.h"
#include <drm_fourcc.h>
#include <errno.h>
@ -33,17 +33,17 @@
#define INVALID_FB_ID 0U
typedef enum _MetaKmsBufferType
typedef enum _MetaDrmBufferType
{
META_KMS_BUFFER_TYPE_GBM,
META_KMS_BUFFER_TYPE_WRAPPED_DUMB
} MetaKmsBufferType;
META_DRM_BUFFER_TYPE_GBM,
META_DRM_BUFFER_TYPE_WRAPPED_DUMB
} MetaDrmBufferType;
struct _MetaKmsBuffer
struct _MetaDrmBuffer
{
GObject parent;
MetaKmsBufferType type;
MetaDrmBufferType type;
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
meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
meta_drm_buffer_acquire_swapped_buffer (MetaDrmBuffer *buffer,
gboolean use_modifiers,
GError **error)
{
@ -80,17 +80,17 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
int i;
int drm_fd;
g_return_val_if_fail (META_IS_KMS_BUFFER (kms_buffer), FALSE);
g_return_val_if_fail (kms_buffer->type == META_KMS_BUFFER_TYPE_GBM, FALSE);
g_return_val_if_fail (kms_buffer->gbm.bo == NULL, FALSE);
g_return_val_if_fail (kms_buffer->gbm.surface != NULL, FALSE);
g_return_val_if_fail (kms_buffer->gbm.gpu_kms != NULL, FALSE);
g_return_val_if_fail (META_IS_DRM_BUFFER (buffer), FALSE);
g_return_val_if_fail (buffer->type == META_DRM_BUFFER_TYPE_GBM, FALSE);
g_return_val_if_fail (buffer->gbm.bo == NULL, FALSE);
g_return_val_if_fail (buffer->gbm.surface != NULL, FALSE);
g_return_val_if_fail (buffer->gbm.gpu_kms != 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);
bo = gbm_surface_lock_front_buffer (kms_buffer->gbm.surface);
bo = gbm_surface_lock_front_buffer (buffer->gbm.surface);
if (!bo)
{
g_set_error (error,
@ -133,7 +133,7 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
strides,
offsets,
modifiers,
&kms_buffer->fb_id,
&buffer->fb_id,
DRM_MODE_FB_MODIFIERS))
{
g_set_error (error,
@ -141,7 +141,7 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
g_io_error_from_errno (errno),
"drmModeAddFB2WithModifiers failed: %s",
g_strerror (errno));
gbm_surface_release_buffer (kms_buffer->gbm.surface, bo);
gbm_surface_release_buffer (buffer->gbm.surface, bo);
return FALSE;
}
}
@ -152,7 +152,7 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
handles,
strides,
offsets,
&kms_buffer->fb_id,
&buffer->fb_id,
0))
{
if (format != DRM_FORMAT_XRGB8888)
@ -162,7 +162,7 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
G_IO_ERROR_FAILED,
"drmModeAddFB does not support format 0x%x",
format);
gbm_surface_release_buffer (kms_buffer->gbm.surface, bo);
gbm_surface_release_buffer (buffer->gbm.surface, bo);
return FALSE;
}
@ -173,115 +173,114 @@ meta_kms_buffer_acquire_swapped_buffer (MetaKmsBuffer *kms_buffer,
32,
strides[0],
handles[0],
&kms_buffer->fb_id))
&buffer->fb_id))
{
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
"drmModeAddFB failed: %s",
g_strerror (errno));
gbm_surface_release_buffer (kms_buffer->gbm.surface, bo);
gbm_surface_release_buffer (buffer->gbm.surface, bo);
return FALSE;
}
}
kms_buffer->gbm.bo = bo;
buffer->gbm.bo = bo;
return TRUE;
}
static void
meta_kms_buffer_init (MetaKmsBuffer *kms_buffer)
meta_drm_buffer_init (MetaDrmBuffer *buffer)
{
}
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 &&
kms_buffer->gbm.fb_id != INVALID_FB_ID)
if (buffer->gbm.gpu_kms != NULL &&
buffer->gbm.fb_id != INVALID_FB_ID)
{
int drm_fd = meta_gpu_kms_get_fd (kms_buffer->gbm.gpu_kms);
drmModeRmFB (drm_fd, kms_buffer->fb_id);
kms_buffer->fb_id = INVALID_FB_ID;
int drm_fd = meta_gpu_kms_get_fd (buffer->gbm.gpu_kms);
drmModeRmFB (drm_fd, buffer->fb_id);
buffer->fb_id = INVALID_FB_ID;
}
if (kms_buffer->gbm.surface &&
kms_buffer->gbm.bo)
if (buffer->gbm.surface &&
buffer->gbm.bo)
{
gbm_surface_release_buffer (kms_buffer->gbm.surface,
kms_buffer->gbm.bo);
gbm_surface_release_buffer (buffer->gbm.surface,
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
meta_kms_buffer_class_init (MetaKmsBufferClass *klass)
meta_drm_buffer_class_init (MetaDrmBufferClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_kms_buffer_finalize;
object_class->finalize = meta_drm_buffer_finalize;
}
MetaKmsBuffer *
meta_kms_buffer_new_from_gbm (MetaGpuKms *gpu_kms,
MetaDrmBuffer *
meta_drm_buffer_new_from_gbm (MetaGpuKms *gpu_kms,
struct gbm_surface *gbm_surface,
gboolean use_modifiers,
GError **error)
{
MetaKmsBuffer *kms_buffer;
MetaDrmBuffer *buffer;
g_return_val_if_fail (META_IS_GPU_KMS (gpu_kms), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
kms_buffer = g_object_new (META_TYPE_KMS_BUFFER, NULL);
kms_buffer->type = META_KMS_BUFFER_TYPE_GBM;
kms_buffer->gbm.gpu_kms = gpu_kms;
kms_buffer->gbm.surface = gbm_surface;
buffer = g_object_new (META_TYPE_DRM_BUFFER, NULL);
buffer->type = META_DRM_BUFFER_TYPE_GBM;
buffer->gbm.gpu_kms = gpu_kms;
buffer->gbm.surface = gbm_surface;
if (!meta_kms_buffer_acquire_swapped_buffer (kms_buffer,
if (!meta_drm_buffer_acquire_swapped_buffer (buffer,
use_modifiers,
error))
{
g_object_unref (kms_buffer);
g_object_unref (buffer);
return NULL;
}
return kms_buffer;
return buffer;
}
MetaKmsBuffer *
meta_kms_buffer_new_from_dumb (uint32_t dumb_fb_id)
MetaDrmBuffer *
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);
kms_buffer->type = META_KMS_BUFFER_TYPE_WRAPPED_DUMB;
kms_buffer->wrapped_dumb.fb_id = dumb_fb_id;
buffer = g_object_new (META_TYPE_DRM_BUFFER, NULL);
buffer->type = META_DRM_BUFFER_TYPE_WRAPPED_DUMB;
buffer->wrapped_dumb.fb_id = dumb_fb_id;
return kms_buffer;
return buffer;
}
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 *
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 (kms_buffer->type == META_KMS_BUFFER_TYPE_GBM, NULL);
g_return_val_if_fail (buffer, 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>
*/
#ifndef META_KMS_BUFFER_H
#define META_KMS_BUFFER_H
#ifndef META_DRM_BUFFER_H
#define META_DRM_BUFFER_H
#include "backends/native/meta-gpu-kms.h"
#include <gbm.h>
#include <glib-object.h>
#define META_TYPE_KMS_BUFFER (meta_kms_buffer_get_type ())
G_DECLARE_FINAL_TYPE (MetaKmsBuffer,
meta_kms_buffer,
META,
KMS_BUFFER,
#define META_TYPE_DRM_BUFFER (meta_drm_buffer_get_type ())
G_DECLARE_FINAL_TYPE (MetaDrmBuffer,
meta_drm_buffer,
META, DRM_BUFFER,
GObject)
MetaKmsBuffer *
meta_kms_buffer_new_from_gbm (MetaGpuKms *gpu_kms,
MetaDrmBuffer *
meta_drm_buffer_new_from_gbm (MetaGpuKms *gpu_kms,
struct gbm_surface *gbm_surface,
gboolean use_modifiers,
GError **error);
MetaKmsBuffer *
meta_kms_buffer_new_from_dumb (uint32_t dumb_fb_id);
MetaDrmBuffer *
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-renderer-view.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-kms-buffer.h"
#include "backends/native/meta-monitor-manager-kms.h"
#include "backends/native/meta-renderer-native-gles3.h"
#include "backends/native/meta-renderer-native.h"
@ -145,8 +145,8 @@ typedef struct _MetaOnscreenNativeSecondaryGpuState
struct {
struct gbm_surface *surface;
MetaKmsBuffer *current_fb;
MetaKmsBuffer *next_fb;
MetaDrmBuffer *current_fb;
MetaDrmBuffer *next_fb;
} gbm;
struct {
@ -167,8 +167,8 @@ typedef struct _MetaOnscreenNative
struct {
struct gbm_surface *surface;
MetaKmsBuffer *current_fb;
MetaKmsBuffer *next_fb;
MetaDrmBuffer *current_fb;
MetaDrmBuffer *next_fb;
} gbm;
#ifdef HAVE_EGL_DEVICE
@ -1753,12 +1753,12 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen,
case META_RENDERER_NATIVE_MODE_GBM:
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
{
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,
@ -1824,7 +1824,7 @@ set_crtc_fb (CoglOnscreen *onscreen,
if (!secondary_gpu_state)
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;
@ -1867,7 +1867,7 @@ meta_onscreen_native_set_crtc_modes (CoglOnscreen *onscreen)
switch (renderer_gpu_data->mode)
{
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;
#ifdef HAVE_EGL_DEVICE
case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
@ -1935,7 +1935,7 @@ crtc_mode_set_fallback (CoglOnscreen *onscreen,
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);
return TRUE;
}
@ -2087,7 +2087,7 @@ copy_shared_framebuffer_gpu (CoglOnscreen *onscreen,
renderer_gpu_data->egl_display,
renderer_gpu_data->secondary.egl_context,
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))
{
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);
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,
renderer_native->use_modifiers,
&error);
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);
g_error_free (error);
return;
@ -2238,7 +2238,7 @@ copy_shared_framebuffer_cpu (CoglOnscreen *onscreen,
g_clear_object (&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
@ -2350,13 +2350,13 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
g_warn_if_fail (onscreen_native->gbm.next_fb == NULL);
g_clear_object (&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,
renderer_native->use_modifiers,
&error);
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);
return;
}

View File

@ -574,12 +574,12 @@ if have_native_backend
'backends/native/meta-crtc-kms.h',
'backends/native/meta-cursor-renderer-native.c',
'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.h',
'backends/native/meta-input-settings-native.c',
'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.h',
'backends/native/meta-monitor-manager-kms.c',