Merge remote-tracking branch 'aosp/upstream-master' into HEAD

Resync w/ upstream master branch

* aosp/upstream-master:
  drm_hwcomposer: platformhisi: extend conditional of AFBC support
  drm_hwcomposer: Move hwcomposer.drm_hikey and hwcomposer.drm_hikey960
  drm_hwcomposer: Convert external/drm_hwcomposer to Android.bp
  drm_hwcomposer: Remove unnecessary parentheses in the conditional
  drm_hwcomposer: Tweak mode selection to pick the first DRM_MODE_TYPE_PREFERRED mode

Change-Id: I12fcd32cde036074a79ef56fbaae85fb9af2b43b
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/drmconnector.cpp b/drmconnector.cpp
index f272024..ead9312 100644
--- a/drmconnector.cpp
+++ b/drmconnector.cpp
@@ -138,13 +138,15 @@
       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;
     }
   }
   modes_.swap(new_modes);
-  if ((!preferred_mode_found) && (modes_.size() != 0)) {
+  if (!preferred_mode_found && modes_.size() != 0) {
     preferred_mode_id_ = modes_[0].id();
   }
   return 0;
diff --git a/platformhisi.cpp b/platformhisi.cpp
index d4002f1..e022010 100644
--- a/platformhisi.cpp
+++ b/platformhisi.cpp
@@ -70,7 +70,8 @@
   return 0;
 }
 
-#ifdef MALI_GRALLOC_INTFMT_AFBC_BASIC
+#if defined(MALI_GRALLOC_INTFMT_AFBC_BASIC) && \
+    defined(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16)
 uint64_t HisiImporter::ConvertGrallocFormatToDrmModifiers(uint64_t flags,
                                                           bool is_rgb) {
   uint64_t features = 0UL;