eglkms: fixes
this MR fixes some problems in eglkms.
I'm relatively new to EGL and GBM, so sorry in advance if I have some misconception here, but given that it's the only KMS demo we had I thought it would be useful.
-
the return value of gbm_surface_create() and eglCreateWindowSurface() is not checked, causing a crash for many people later on.
-
a hardcoded DRM format is used when allocating the GBM surface which often doesn't match with the one chosen by EGL.
my understanding is that the correct approach here is toquery the format chosen by EGL.after investigating a bit more I think it's better to do it the other way around, iterate through EGL configs and pick the one matching the DRM format, since KMS tends to support less formats. -
allow user to supply a different DRM node instead of using a hardcoded /dev/dri/card0 (my setup doesn't even have a card0).
-
fix order of glClearColor and glClear calls
-
fix cleanup in case of framebuffer creation failure (don't attempt to remove FB).
-
don't leak KMS resource list in
setup_kms
. -
don't assume an encoder and CRTC to be present already. the current code checks that a KMS connector was selected, but doesn't check that an encoder or CRTC were selected.