diff options
author | Wim Taymans <wtaymans@redhat.com> | 2015-10-15 09:39:24 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2015-10-15 09:39:24 +0200 |
commit | 39e55a796d8cba26126540557990c647e85b552e (patch) | |
tree | 1038ed9887b2239ae698df58b3e8758b64f0f4b9 | |
parent | 792b3d498a29fbeebea4b6943972e3f28fd26ab5 (diff) |
add prime fd APIprime-fd
-rw-r--r-- | cogl/cogl-frame-info-private.h | 1 | ||||
-rw-r--r-- | cogl/cogl-frame-info.c | 8 | ||||
-rw-r--r-- | cogl/cogl-frame-info.h | 2 | ||||
-rw-r--r-- | cogl/cogl-framebuffer.h | 3 | ||||
-rw-r--r-- | cogl/winsys/cogl-winsys-egl-kms.c | 26 |
5 files changed, 40 insertions, 0 deletions
diff --git a/cogl/cogl-frame-info-private.h b/cogl/cogl-frame-info-private.h index 32f5ba8e..ec8ff9c4 100644 --- a/cogl/cogl-frame-info-private.h +++ b/cogl/cogl-frame-info-private.h @@ -43,6 +43,7 @@ struct _CoglFrameInfo float refresh_rate; CoglOutput *output; + int fd; }; CoglFrameInfo *_cogl_frame_info_new (void); diff --git a/cogl/cogl-frame-info.c b/cogl/cogl-frame-info.c index 2114a64b..91af5f59 100644 --- a/cogl/cogl-frame-info.c +++ b/cogl/cogl-frame-info.c @@ -53,6 +53,8 @@ _cogl_frame_info_new (void) static void _cogl_frame_info_free (CoglFrameInfo *info) { + if (info->fd) + close (info->fd); g_slice_free (CoglFrameInfo, info); } @@ -79,3 +81,9 @@ cogl_frame_info_get_output (CoglFrameInfo *info) { return info->output; } + +int +cogl_frame_info_get_fd (CoglFrameInfo *info) +{ + return info->fd; +} diff --git a/cogl/cogl-frame-info.h b/cogl/cogl-frame-info.h index 7304c530..6027937b 100644 --- a/cogl/cogl-frame-info.h +++ b/cogl/cogl-frame-info.h @@ -143,6 +143,8 @@ float cogl_frame_info_get_refresh_rate (CoglFrameInfo *info); CoglOutput * cogl_frame_info_get_output (CoglFrameInfo *info); +int cogl_frame_info_get_fd (CoglFrameInfo *info); + G_END_DECLS #endif /* __COGL_FRAME_INFO_H */ diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h index 58d65a82..24e4250c 100644 --- a/cogl/cogl-framebuffer.h +++ b/cogl/cogl-framebuffer.h @@ -1865,6 +1865,9 @@ typedef enum { /*< prefix=COGL_FRAMEBUFFER_ERROR >*/ CoglBool cogl_is_framebuffer (void *object); +int +cogl_framebuffer_get_prime_fd (CoglFramebuffer *framebuffer); + COGL_END_DECLS #endif /* __COGL_FRAMEBUFFER_H */ diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c index c5d014ad..3cf331c0 100644 --- a/cogl/winsys/cogl-winsys-egl-kms.c +++ b/cogl/winsys/cogl-winsys-egl-kms.c @@ -61,6 +61,7 @@ #include "cogl-version.h" #include "cogl-error-private.h" #include "cogl-poll-private.h" +#include "cogl-frame-info-private.h" static const CoglWinsysEGLVtable _cogl_winsys_egl_vtable; @@ -907,6 +908,7 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, kms_onscreen->surface = kms_onscreen->pending_surface; kms_onscreen->pending_surface = NULL; } + /* Now we need to set the CRTC to whatever is the front buffer */ kms_onscreen->next_bo = gbm_surface_lock_front_buffer (kms_onscreen->surface); @@ -1188,6 +1190,30 @@ cogl_kms_renderer_get_kms_fd (CoglRenderer *renderer) return -1; } +int +cogl_framebuffer_get_prime_fd (CoglFramebuffer *framebuffer) +{ + CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer); + CoglOnscreenEGL *egl_onscreen = onscreen->winsys; + CoglOnscreenKMS *kms_onscreen = egl_onscreen->platform; + CoglContext *context = framebuffer->context; + CoglRenderer *renderer = context->display->renderer; + CoglRendererEGL *egl_renderer = renderer->winsys; + CoglRendererKMS *kms_renderer = egl_renderer->platform; + int fd; + + if (drmPrimeHandleToFD (kms_renderer->fd, + kms_onscreen->current_fb_id, + DRM_CLOEXEC, + &fd)) + { + g_warning ("Failed to create prime fd"); + return -1; + } + + return fd; +} + void cogl_kms_display_queue_modes_reset (CoglDisplay *display) { |