drm_hwcomposer: Ensure composer has master access to DRM/KMS

Allocator service is always loaded before Composer service.
Kernel will assign master access to the first client that
opened /dev/dri/cardX node.

Allocator should immediately execute drmDropMaster() to
allow Composer service to acquire master privileges.

If this does not happen, the composer should gracefully exit,
otherwise a lot of DRM ioctls will fail without displaying anything
on the UI.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/drm/DrmDevice.cpp b/drm/DrmDevice.cpp
index bf1a5e2..5d46c36 100644
--- a/drm/DrmDevice.cpp
+++ b/drm/DrmDevice.cpp
@@ -145,6 +145,12 @@
   }
 #endif
 
+  ret = drmSetMaster(fd());
+  if (ret) {
+    ALOGE("drmSetMaster() failed with errno: %d", errno);
+    return std::make_tuple(ret, 0);
+  }
+
   drmModeResPtr res = drmModeGetResources(fd());
   if (!res) {
     ALOGE("Failed to get DrmDevice resources");