mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
drm-buffer: Add API to export buffer file descriptor
Practically ends up in gbm_bo_get_fd(). For dumb buffer, an 'unsupported' error is returned. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
This commit is contained in:
parent
6ba86366b3
commit
a1266e19f4
@ -50,6 +50,15 @@ struct _MetaDrmBufferDumb
|
|||||||
|
|
||||||
G_DEFINE_TYPE (MetaDrmBufferDumb, meta_drm_buffer_dumb, META_TYPE_DRM_BUFFER)
|
G_DEFINE_TYPE (MetaDrmBufferDumb, meta_drm_buffer_dumb, META_TYPE_DRM_BUFFER)
|
||||||
|
|
||||||
|
static int
|
||||||
|
meta_drm_buffer_dumb_export_fd (MetaDrmBuffer *buffer,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||||
|
"Can't export fd for dumb buffer");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
meta_drm_buffer_dumb_get_width (MetaDrmBuffer *buffer)
|
meta_drm_buffer_dumb_get_width (MetaDrmBuffer *buffer)
|
||||||
{
|
{
|
||||||
@ -362,6 +371,7 @@ meta_drm_buffer_dumb_class_init (MetaDrmBufferDumbClass *klass)
|
|||||||
|
|
||||||
object_class->finalize = meta_drm_buffer_dumb_finalize;
|
object_class->finalize = meta_drm_buffer_dumb_finalize;
|
||||||
|
|
||||||
|
buffer_class->export_fd = meta_drm_buffer_dumb_export_fd;
|
||||||
buffer_class->get_width = meta_drm_buffer_dumb_get_width;
|
buffer_class->get_width = meta_drm_buffer_dumb_get_width;
|
||||||
buffer_class->get_height = meta_drm_buffer_dumb_get_height;
|
buffer_class->get_height = meta_drm_buffer_dumb_get_height;
|
||||||
buffer_class->get_stride = meta_drm_buffer_dumb_get_stride;
|
buffer_class->get_stride = meta_drm_buffer_dumb_get_stride;
|
||||||
|
@ -57,6 +57,24 @@ meta_drm_buffer_gbm_get_bo (MetaDrmBufferGbm *buffer_gbm)
|
|||||||
return buffer_gbm->bo;
|
return buffer_gbm->bo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
meta_drm_buffer_gbm_export_fd (MetaDrmBuffer *buffer,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MetaDrmBufferGbm *buffer_gbm = META_DRM_BUFFER_GBM (buffer);
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = gbm_bo_get_fd (buffer_gbm->bo);
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
|
||||||
|
"Failed to export buffer fd: %s", g_strerror (errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
meta_drm_buffer_gbm_get_width (MetaDrmBuffer *buffer)
|
meta_drm_buffer_gbm_get_width (MetaDrmBuffer *buffer)
|
||||||
{
|
{
|
||||||
@ -491,6 +509,7 @@ meta_drm_buffer_gbm_class_init (MetaDrmBufferGbmClass *klass)
|
|||||||
|
|
||||||
object_class->finalize = meta_drm_buffer_gbm_finalize;
|
object_class->finalize = meta_drm_buffer_gbm_finalize;
|
||||||
|
|
||||||
|
buffer_class->export_fd = meta_drm_buffer_gbm_export_fd;
|
||||||
buffer_class->get_width = meta_drm_buffer_gbm_get_width;
|
buffer_class->get_width = meta_drm_buffer_gbm_get_width;
|
||||||
buffer_class->get_height = meta_drm_buffer_gbm_get_height;
|
buffer_class->get_height = meta_drm_buffer_gbm_get_height;
|
||||||
buffer_class->get_stride = meta_drm_buffer_gbm_get_stride;
|
buffer_class->get_stride = meta_drm_buffer_gbm_get_stride;
|
||||||
|
@ -44,6 +44,16 @@ struct _MetaDrmBufferImport
|
|||||||
G_DEFINE_TYPE (MetaDrmBufferImport, meta_drm_buffer_import,
|
G_DEFINE_TYPE (MetaDrmBufferImport, meta_drm_buffer_import,
|
||||||
META_TYPE_DRM_BUFFER)
|
META_TYPE_DRM_BUFFER)
|
||||||
|
|
||||||
|
static int
|
||||||
|
meta_drm_buffer_import_export_fd (MetaDrmBuffer *buffer,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MetaDrmBufferImport *buffer_import = META_DRM_BUFFER_IMPORT (buffer);
|
||||||
|
|
||||||
|
return meta_drm_buffer_export_fd (META_DRM_BUFFER (buffer_import->importee),
|
||||||
|
error);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
meta_drm_buffer_import_get_width (MetaDrmBuffer *buffer)
|
meta_drm_buffer_import_get_width (MetaDrmBuffer *buffer)
|
||||||
{
|
{
|
||||||
@ -229,6 +239,7 @@ meta_drm_buffer_import_class_init (MetaDrmBufferImportClass *klass)
|
|||||||
|
|
||||||
object_class->finalize = meta_drm_buffer_import_finalize;
|
object_class->finalize = meta_drm_buffer_import_finalize;
|
||||||
|
|
||||||
|
buffer_class->export_fd = meta_drm_buffer_import_export_fd;
|
||||||
buffer_class->get_width = meta_drm_buffer_import_get_width;
|
buffer_class->get_width = meta_drm_buffer_import_get_width;
|
||||||
buffer_class->get_height = meta_drm_buffer_import_get_height;
|
buffer_class->get_height = meta_drm_buffer_import_get_height;
|
||||||
buffer_class->get_stride = meta_drm_buffer_import_get_stride;
|
buffer_class->get_stride = meta_drm_buffer_import_get_stride;
|
||||||
|
@ -158,6 +158,13 @@ meta_drm_buffer_release_fb_id (MetaDrmBuffer *buffer)
|
|||||||
priv->fb_id = 0;
|
priv->fb_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
meta_drm_buffer_export_fd (MetaDrmBuffer *buffer,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return META_DRM_BUFFER_GET_CLASS (buffer)->export_fd (buffer, error);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer)
|
meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer)
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,9 @@ G_DECLARE_DERIVABLE_TYPE (MetaDrmBuffer,
|
|||||||
META, DRM_BUFFER,
|
META, DRM_BUFFER,
|
||||||
GObject)
|
GObject)
|
||||||
|
|
||||||
|
int meta_drm_buffer_export_fd (MetaDrmBuffer *buffer,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
uint32_t meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer);
|
uint32_t meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer);
|
||||||
|
|
||||||
int meta_drm_buffer_get_width (MetaDrmBuffer *buffer);
|
int meta_drm_buffer_get_width (MetaDrmBuffer *buffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user