Closing/Disowning DRM FD and then reopening it

Hugh Cole-Baker <[email protected]>
Newsgroups gmane.comp.video.mesa3d.user
Message-ID <[email protected]>
Hello! I'm trying to write an application which uses EGL and libdrm to render directly to the display without X running. I've been following what examples I could find on the Web but they're from 2011 and 2013 [1] [2] so probably what I'm doing is fairly out of date and I suspect that's related to a problem I've been having.

What I want to do is open() /dev/dri/card0, locate a KMS connector, encoder and CRTC to use, create an EGL surface and render to it, and then display that surface using drmModePageFlip() or drmModeSetCrtc(). This part is working fine. Then I want to de-init all the DRM related resources, close the DRM file descriptor, and launch a subprocess that will also use DRM to render to the display. So there will only be one process using DRM at any time. When that subprocess exits, I want to re-init all the DRM and EGL stuff, and resume drawing and displaying as before.

The problem I'm having is that I can't re-init and resume using DRM in my app after the subprocess has exited. Even with no subprocess launching, I can't use drmModePageFlip() after close()ing the file descriptor for /dev/dri/card0 and reopening it. It works fine the first time, but after closing, reopening and re-initialising EGL in the same process, I always get EACCES when calling drmModePageFlip().

I've modified this kmscube example app to show the problem [3]. The second call to draw_some_frames() always fails. The same thing happens on both a Raspberry Pi (VC4 GPU) with Mesa 11.1, and on Ubuntu 16.04 with Mesa 11.2 (Nouveau driver).

Can anyone give me a pointer on how to completely "disown" the /dev/dri/card0 so that another app can use it, and then reopen it later?

thanks in advance,
--
Hugh

[1] https://github.com/dvdhrm/docs/blob/master/drm-howto/modeset-vsync.c
[2] http://virtuousgeek.org/blog/index.php/jbarnes/2011/10/31/writing_stanalone_programs_with_egl_and_
[3] https://github.com/sigmaris/kmscube/blob/reinit/kmscube.c
_______________________________________________
mesa-users mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.