drm_hwcomposer: Basic support for shared primary planes

For now just bind the first suitable primary plane to the pipeline
on creation.

Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/68
Change-Id: Idc4a7a5ac9d768d2614e1cd8a460d742f406a1cc
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/drm/DrmDisplayPipeline.cpp b/drm/DrmDisplayPipeline.cpp
index f993d28..e81544d 100644
--- a/drm/DrmDisplayPipeline.cpp
+++ b/drm/DrmDisplayPipeline.cpp
@@ -86,15 +86,15 @@
     return {};
   }
 
-  if (primary_planes.size() > 1) {
-    ALOGE("Found more than 1 primary plane for CRTC %d", crtc.GetId());
-    return {};
+  for (const auto &plane : primary_planes) {
+    pipe->primary_plane = plane->BindPipeline(pipe.get());
+    if (pipe->primary_plane) {
+      break;
+    }
   }
 
-  pipe->primary_plane = primary_planes[0]->BindPipeline(pipe.get());
   if (!pipe->primary_plane) {
-    ALOGE("Primary plane %d is already owned. Internal error.",
-          primary_planes[0]->GetId());
+    ALOGE("Failed to bind primary plane");
     return {};
   }