mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
render-device: Add API to allocate DMA buffers
Only possible with the gbm implementation; aims to make it easier for users of render devices to allocate DMA buffers. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
This commit is contained in:
parent
9292eba035
commit
802e7eb56f
@ -31,6 +31,7 @@ typedef struct _MetaCrtcVirtual MetaCrtcVirtual;
|
|||||||
typedef struct _MetaCrtcModeVirtual MetaCrtcModeVirtual;
|
typedef struct _MetaCrtcModeVirtual MetaCrtcModeVirtual;
|
||||||
typedef struct _MetaDevicePool MetaDevicePool;
|
typedef struct _MetaDevicePool MetaDevicePool;
|
||||||
typedef struct _MetaDeviceFile MetaDeviceFile;
|
typedef struct _MetaDeviceFile MetaDeviceFile;
|
||||||
|
typedef struct _MetaDrmBuffer MetaDrmBuffer;
|
||||||
|
|
||||||
typedef enum _MetaSeatNativeFlag
|
typedef enum _MetaSeatNativeFlag
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <gbm.h>
|
#include <gbm.h>
|
||||||
|
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
|
#include "backends/native/meta-drm-buffer-gbm.h"
|
||||||
|
|
||||||
struct _MetaRenderDeviceGbm
|
struct _MetaRenderDeviceGbm
|
||||||
{
|
{
|
||||||
@ -115,6 +116,36 @@ meta_render_device_gbm_create_egl_display (MetaRenderDevice *render_device,
|
|||||||
return egl_display;
|
return egl_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MetaDrmBuffer *
|
||||||
|
meta_render_device_gbm_allocate_dma_buf (MetaRenderDevice *render_device,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
uint32_t format,
|
||||||
|
MetaDrmBufferFlags flags,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MetaRenderDeviceGbm *render_device_gbm =
|
||||||
|
META_RENDER_DEVICE_GBM (render_device);
|
||||||
|
MetaDeviceFile *device_file;
|
||||||
|
struct gbm_bo *gbm_bo;
|
||||||
|
MetaDrmBufferGbm *buffer_gbm;
|
||||||
|
|
||||||
|
gbm_bo = gbm_bo_create (render_device_gbm->gbm_device,
|
||||||
|
width, height, format,
|
||||||
|
GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR);
|
||||||
|
if (!gbm_bo)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Failed to gbm_bo: %s", g_strerror (errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
device_file = meta_render_device_get_device_file (render_device);
|
||||||
|
buffer_gbm = meta_drm_buffer_gbm_new_take (device_file, gbm_bo, flags,
|
||||||
|
error);
|
||||||
|
return META_DRM_BUFFER (buffer_gbm);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_render_device_gbm_finalize (GObject *object)
|
meta_render_device_gbm_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
@ -135,6 +166,8 @@ meta_render_device_gbm_class_init (MetaRenderDeviceGbmClass *klass)
|
|||||||
|
|
||||||
render_device_class->create_egl_display =
|
render_device_class->create_egl_display =
|
||||||
meta_render_device_gbm_create_egl_display;
|
meta_render_device_gbm_create_egl_display;
|
||||||
|
render_device_class->allocate_dma_buf =
|
||||||
|
meta_render_device_gbm_allocate_dma_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "backends/meta-egl.h"
|
#include "backends/meta-egl.h"
|
||||||
#include "backends/native/meta-device-pool.h"
|
#include "backends/native/meta-device-pool.h"
|
||||||
|
#include "backends/native/meta-drm-buffer.h"
|
||||||
#include "backends/native/meta-render-device.h"
|
#include "backends/native/meta-render-device.h"
|
||||||
|
|
||||||
struct _MetaRenderDeviceClass
|
struct _MetaRenderDeviceClass
|
||||||
@ -34,6 +35,13 @@ struct _MetaRenderDeviceClass
|
|||||||
|
|
||||||
EGLDisplay (* create_egl_display) (MetaRenderDevice *render_device,
|
EGLDisplay (* create_egl_display) (MetaRenderDevice *render_device,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
MetaDrmBuffer * (* allocate_dma_buf) (MetaRenderDevice *render_device,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
uint32_t format,
|
||||||
|
MetaDrmBufferFlags flags,
|
||||||
|
GError **error);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* META_RENDER_DEVICE_PRIVATE_H */
|
#endif /* META_RENDER_DEVICE_PRIVATE_H */
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
#include "backends/meta-egl.h"
|
#include "backends/meta-egl.h"
|
||||||
|
#include "backends/native/meta-backend-native-types.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -338,3 +339,28 @@ meta_render_device_get_name (MetaRenderDevice *render_device)
|
|||||||
else
|
else
|
||||||
return "(device-less)";
|
return "(device-less)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaDrmBuffer *
|
||||||
|
meta_render_device_allocate_dma_buf (MetaRenderDevice *render_device,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
uint32_t format,
|
||||||
|
MetaDrmBufferFlags flags,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MetaRenderDeviceClass *klass = META_RENDER_DEVICE_GET_CLASS (render_device);
|
||||||
|
|
||||||
|
if (klass->allocate_dma_buf)
|
||||||
|
{
|
||||||
|
return klass->allocate_dma_buf (render_device,
|
||||||
|
width, height, format,
|
||||||
|
flags,
|
||||||
|
error);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Render device '%s' doesn't support allocating DMA buffers",
|
||||||
|
meta_render_device_get_name (render_device));
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
#include "backends/meta-backend-types.h"
|
#include "backends/meta-backend-types.h"
|
||||||
|
#include "backends/native/meta-backend-native-types.h"
|
||||||
|
|
||||||
#define META_TYPE_RENDER_DEVICE (meta_render_device_get_type ())
|
#define META_TYPE_RENDER_DEVICE (meta_render_device_get_type ())
|
||||||
G_DECLARE_DERIVABLE_TYPE (MetaRenderDevice, meta_render_device,
|
G_DECLARE_DERIVABLE_TYPE (MetaRenderDevice, meta_render_device,
|
||||||
@ -40,4 +41,11 @@ gboolean meta_render_device_is_hardware_accelerated (MetaRenderDevice *render_de
|
|||||||
|
|
||||||
MetaDeviceFile * meta_render_device_get_device_file (MetaRenderDevice *render_device);
|
MetaDeviceFile * meta_render_device_get_device_file (MetaRenderDevice *render_device);
|
||||||
|
|
||||||
|
MetaDrmBuffer * meta_render_device_allocate_dma_buf (MetaRenderDevice *render_device,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
uint32_t format,
|
||||||
|
MetaDrmBufferFlags flags,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
#endif /* META_RENDER_DEVICE_H */
|
#endif /* META_RENDER_DEVICE_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user