uterm: drm: share mode-setting between dumb+drm
The modesetting code of both DRM backends is almost the same so share it.
This also works around several race-conditions in some DRM drivers. In
particular, we cannot call drmModeSetCrtc while a drmModePageFlip is still
pending. Therefore, we wait for page-flips to complete before performing
an immediate mode-set.
This requires us to handle page-flip events synchronously so we can wait
for kernel page-flip events but the user-space bottom-half is executed in
an idle-handler.
Note that the chance that we have to wait for a page-flip to complete is
pretty small. In fact, without hacking the code to do fast page-flips, I
couldn't get kmscon to run into this condition.
Last but not least, this patch also makes the dumb-backend support
immediate page-flips like the DRM backend did all the time.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>