cogl-winsys-egl-kms: Add cogl_kms_renderer_set_kms_fd
Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 7bc7ea4cb5e8134a3aeed9615477f4152b558509) Conflicts: cogl/winsys/cogl-winsys-egl-kms.c
This commit is contained in:
parent
76cdaabc15
commit
0d91085193
@ -38,6 +38,22 @@
|
||||
|
||||
COGL_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* cogl_kms_renderer_set_kms_fd:
|
||||
* @renderer: A #CoglRenderer
|
||||
* @fd: The fd to kms to use
|
||||
*
|
||||
* Sets the file descriptor Cogl should use to communicate
|
||||
* to the kms driver. If -1 (the default), then Cogl will
|
||||
* open its own FD by trying to open "/dev/dri/card0".
|
||||
*
|
||||
* Since: 1.18
|
||||
* Stability: unstable
|
||||
*/
|
||||
void
|
||||
cogl_kms_renderer_set_kms_fd (CoglRenderer *renderer,
|
||||
int fd);
|
||||
|
||||
/**
|
||||
* cogl_kms_renderer_get_kms_fd:
|
||||
* @renderer: A #CoglRenderer
|
||||
|
@ -88,6 +88,10 @@ struct _CoglRenderer
|
||||
CoglBool wayland_enable_event_dispatch;
|
||||
#endif
|
||||
|
||||
#if defined (COGL_HAS_EGL_PLATFORM_KMS_SUPPORT)
|
||||
int kms_fd;
|
||||
#endif
|
||||
|
||||
#ifdef COGL_HAS_SDL_SUPPORT
|
||||
CoglBool sdl_event_type_set;
|
||||
uint32_t sdl_event_type;
|
||||
|
@ -303,6 +303,10 @@ cogl_renderer_new (void)
|
||||
renderer->wayland_enable_event_dispatch = TRUE;
|
||||
#endif
|
||||
|
||||
#ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
|
||||
renderer->kms_fd = -1;
|
||||
#endif
|
||||
|
||||
return _cogl_renderer_object_new (renderer);
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ static const CoglWinsysVtable *parent_vtable;
|
||||
typedef struct _CoglRendererKMS
|
||||
{
|
||||
int fd;
|
||||
int opened_fd;
|
||||
struct gbm_device *gbm;
|
||||
CoglClosure *swap_notify_idle;
|
||||
} CoglRendererKMS;
|
||||
@ -285,14 +286,25 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
|
||||
* we're doing here... */
|
||||
g_setenv ("EGL_PLATFORM", "drm", 1);
|
||||
|
||||
kms_renderer->fd = open (device_name, O_RDWR);
|
||||
if (kms_renderer->fd < 0)
|
||||
kms_renderer->fd = -1;
|
||||
kms_renderer->opened_fd = -1;
|
||||
|
||||
if (renderer->kms_fd >= 0)
|
||||
{
|
||||
/* Probably permissions error */
|
||||
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
||||
COGL_WINSYS_ERROR_INIT,
|
||||
"Couldn't open %s", device_name);
|
||||
return FALSE;
|
||||
kms_renderer->fd = renderer->kms_fd;
|
||||
}
|
||||
else
|
||||
{
|
||||
kms_renderer->opened_fd = open (device_name, O_RDWR);
|
||||
kms_renderer->fd = kms_renderer->opened_fd;
|
||||
if (kms_renderer->fd < 0)
|
||||
{
|
||||
/* Probably permissions error */
|
||||
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
||||
COGL_WINSYS_ERROR_INIT,
|
||||
"Couldn't open %s", device_name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
kms_renderer->gbm = gbm_create_device (kms_renderer->fd);
|
||||
@ -330,7 +342,8 @@ egl_terminate:
|
||||
destroy_gbm_device:
|
||||
gbm_device_destroy (kms_renderer->gbm);
|
||||
close_fd:
|
||||
close (kms_renderer->fd);
|
||||
if (kms_renderer->opened_fd >= 0)
|
||||
close (kms_renderer->opened_fd);
|
||||
|
||||
_cogl_winsys_renderer_disconnect (renderer);
|
||||
|
||||
@ -1075,6 +1088,17 @@ _cogl_winsys_egl_kms_get_vtable (void)
|
||||
return &vtable;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_kms_renderer_set_kms_fd (CoglRenderer *renderer,
|
||||
int fd)
|
||||
{
|
||||
_COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer));
|
||||
/* NB: Renderers are considered immutable once connected */
|
||||
_COGL_RETURN_IF_FAIL (!renderer->connected);
|
||||
|
||||
renderer->kms_fd = fd;
|
||||
}
|
||||
|
||||
int
|
||||
cogl_kms_renderer_get_kms_fd (CoglRenderer *renderer)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user