drm_hwcomposer: Tweak mode selection to pick the first DRM_MODE_TYPE_PREFERRED mode

With commit 1b1e35eb ("drm_hwcomposer: Chose preferred mode with
type DRM_MODE_TYPE_PREFERRED"), we now pick a preferred mode
rather then just the first mode to use.

However, on some systems there may erroniously be multiple modes
marked as DRM_MODE_TYPE_PREFERRED. In this case, the logic added
in that commit ends up selecting the *last* preferred mode.

This seems less likely to be the desired choice, compared to
what we had before (which picked first mode provided).

So this patch alters the selection logic to only use the first
DRM_MODE_TYPE_PREFERRED mode found, rather than the last.

Change-Id: Ieb3e5d946b96099f14c1c5a287ca8113360a39d1
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/drmconnector.cpp b/drmconnector.cpp
index f272024..f55c2d6 100644
--- a/drmconnector.cpp
+++ b/drmconnector.cpp
@@ -138,7 +138,9 @@
       m.set_id(drm_->next_mode_id());
       new_modes.push_back(m);
     }
-    if (new_modes.back().type() & DRM_MODE_TYPE_PREFERRED) {
+    // Use only the first DRM_MODE_TYPE_PREFERRED mode found
+    if (!preferred_mode_found &&
+        (new_modes.back().type() & DRM_MODE_TYPE_PREFERRED)) {
       preferred_mode_id_ = new_modes.back().id();
       preferred_mode_found = true;
     }