After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 726198 - egl: Add a way to set the KMS FD
egl: Add a way to set the KMS FD
Status: RESOLVED FIXED
Product: clutter
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: clutter-maint
clutter-maint
Depends on:
Blocks:
 
 
Reported: 2014-03-12 19:36 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2014-03-15 19:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
egl: Add a way to set the KMS FD (2.58 KB, patch)
2014-03-12 19:36 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
egl: Add a way to set the KMS FD (2.72 KB, patch)
2014-03-12 20:07 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
egl: Add a way to set the KMS FD (2.77 KB, patch)
2014-03-13 19:26 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
egl: Only expose clutter_egl_set_kms_fd if we have KMS support (2.03 KB, patch)
2014-03-15 01:30 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2014-03-12 19:36:08 UTC
See patch. This is needed for the mutter logind integration work.
Comment 1 Jasper St. Pierre (not reading bugmail) 2014-03-12 19:36:10 UTC
Created attachment 271642 [details] [review]
egl: Add a way to set the KMS FD

This is needed for the logind integration work, where logind will
send us an already-opened FD to KMS.
Comment 2 Emmanuele Bassi (:ebassi) 2014-03-12 19:41:55 UTC
Review of attachment 271642 [details] [review]:

it looks generally okay to me.

do we also need a clutter_egl_get_kms_fd()?

::: clutter/egl/clutter-backend-eglnative.c
@@ +82,3 @@
+  renderer = cogl_renderer_new ();
+  cogl_renderer_set_winsys_id (renderer, COGL_WINSYS_ID_EGL_KMS);
+{

what happens if _kms_fd is -1?

what happens if you want to run this on non-KMS EGL framebuffers?

::: clutter/egl/clutter-egl.h
@@ +88,3 @@
 EGLDisplay      clutter_egl_get_egl_display     (void);
 
+void clutter_egl_native_set_kms_fd (int fd);

this should probably be called clutter_egl_set_kms_fd(), without the 'native'.
Comment 3 Jasper St. Pierre (not reading bugmail) 2014-03-12 19:46:40 UTC
(In reply to comment #2)
> do we also need a clutter_egl_get_kms_fd()?

Don't think so. It's supposed to be fire-and-forget. And you can get it anyway by digging into Cogl: cogl_kms_renderer_get_kms_fd.

> what happens if _kms_fd is -1?

Cogl tries to open its own FD by opening /dev/dri/card0.

> what happens if you want to run this on non-KMS EGL framebuffers?

Run what? An app with the CLUTTER_BACKEND=eglnative envvar set?

> this should probably be called clutter_egl_set_kms_fd(), without the 'native'.

The backend is called "eglnative", and the backend class is called "CLUTTER_EGL_NATIVE". I'm not really sure about the difference between "eglnative" and "egl" though.
Comment 4 Emmanuele Bassi (:ebassi) 2014-03-12 19:51:06 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > do we also need a clutter_egl_get_kms_fd()?
> 
> Don't think so. It's supposed to be fire-and-forget. And you can get it anyway
> by digging into Cogl: cogl_kms_renderer_get_kms_fd.

okay.

> > what happens if _kms_fd is -1?
> 
> Cogl tries to open its own FD by opening /dev/dri/card0.

maybe leave a comment, but okay.

> > what happens if you want to run this on non-KMS EGL framebuffers?
> 
> Run what? An app with the CLUTTER_BACKEND=eglnative envvar set?

if possible, yes.

> > this should probably be called clutter_egl_set_kms_fd(), without the 'native'.
> 
> The backend is called "eglnative", and the backend class is called
> "CLUTTER_EGL_NATIVE". I'm not really sure about the difference between
> "eglnative" and "egl" though.

the API is namespaced as ClutterEGL, so that would translate to ClutterEGL.native_set_kms_fd().
Comment 5 Jasper St. Pierre (not reading bugmail) 2014-03-12 20:05:15 UTC
(In reply to comment #4)
> if possible, yes.

I'm not sure what will happen right now, but after this patch if you use CLUTTER_BACKEND=eglnative we force the winsys to be EGL_KMS.
Comment 6 Jasper St. Pierre (not reading bugmail) 2014-03-12 20:07:04 UTC
Created attachment 271649 [details] [review]
egl: Add a way to set the KMS FD

This is needed for the logind integration work, where logind will
send us an already-opened FD to KMS.
Comment 7 Emmanuele Bassi (:ebassi) 2014-03-13 15:40:43 UTC
Review of attachment 271649 [details] [review]:

::: clutter/egl/clutter-backend-eglnative.c
@@ +80,3 @@
+  CoglRenderer *renderer;
+
+  renderer = cogl_renderer_new ();

we could do this conditionally: if _kms_fd is -1 then we chain up; otherwise, we set the winsys id and the KMS fd. this would retain the existing behaviour (untested as it may be) while adding the new KMS functionality.
Comment 8 Jasper St. Pierre (not reading bugmail) 2014-03-13 19:26:44 UTC
Created attachment 271781 [details] [review]
egl: Add a way to set the KMS FD

This is needed for the logind integration work, where logind will
send us an already-opened FD to KMS.
Comment 9 Emmanuele Bassi (:ebassi) 2014-03-14 17:23:44 UTC
Review of attachment 271781 [details] [review]:

looks good, thanks.
Comment 10 Jasper St. Pierre (not reading bugmail) 2014-03-14 18:12:43 UTC
Attachment 271781 [details] pushed as a96daf8 - egl: Add a way to set the KMS FD
Comment 11 Allison Karlitskaya (desrt) 2014-03-14 22:54:50 UTC
This tripped up the FreeBSD builder (due to cogl_kms_renderer_set_kms_fd).  We don't have kms on FreeBSD.  Probably needs a check...
Comment 12 Jasper St. Pierre (not reading bugmail) 2014-03-15 01:30:45 UTC
Created attachment 271982 [details] [review]
egl: Only expose clutter_egl_set_kms_fd if we have KMS support

And only call the proper Cogl functions in that case, too. This
fixes the build on platforms without KMS, like the BSDs.
Comment 13 Allison Karlitskaya (desrt) 2014-03-15 03:42:45 UTC
Review of attachment 271982 [details] [review]:

I can verify that this fixes the build under:

  jhbuild --conditions=-wayland build clutter
Comment 14 Koop Mast (kwm) 2014-03-15 07:49:11 UTC
Review of attachment 271982 [details] [review]:

I can report that this fixes the build on FreeBSD.
Comment 15 Emmanuele Bassi (:ebassi) 2014-03-15 19:09:32 UTC
Review of attachment 271982 [details] [review]:

let's get this in.

::: clutter/egl/clutter-egl.h
@@ +88,3 @@
 EGLDisplay      clutter_egl_get_egl_display     (void);
 
+#ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT

this should not be needed, but it's fine: the platform specific headers are currently a mess, I'll have to clean them up anyway.
Comment 16 Emmanuele Bassi (:ebassi) 2014-03-15 19:24:59 UTC
Attachment 271982 [details] pushed as 79ece18 - egl: Only expose clutter_egl_set_kms_fd if we have KMS support
Comment 17 Jasper St. Pierre (not reading bugmail) 2014-03-15 19:28:45 UTC
(In reply to comment #15)
> this should not be needed, but it's fine: the platform specific headers are
> currently a mess, I'll have to clean them up anyway.

I wanted an "undefined function" warning rather than a linking error. It's also more clear from a documentation / introspection standpoint as well.