Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)

Bug: 166295507
Merged-In: I8695ee884ff9163eab82670e0dd3c711fa37258a
Change-Id: I9442538fdd0e5c1b7ad7b31dae5d175e292818ea
diff --git a/Android.bp b/Android.bp
index 2864898..9d00645 100644
--- a/Android.bp
+++ b/Android.bp
@@ -5,7 +5,6 @@
         "-Wconversion",
         "-Wall",
         "-Werror",
-        "-std=c++14",
     ],
     shared_libs: [
         "liblog",
@@ -35,6 +34,19 @@
     export_header_lib_headers: ["libhardware_headers"],
 }
 
+cc_library_headers {
+    name: "display_intf_headers",
+    vendor_available: true,
+    export_include_dirs: [
+        "include",
+        "libcopybit",
+        "libqdutils",
+        "gralloc",
+    ],
+    header_libs: ["libhardware_headers"],
+    export_header_lib_headers: ["libhardware_headers"],
+}
+
 subdirs = [
     "libqservice",
     "libqdutils",
diff --git a/CleanSpec.mk b/CleanSpec.mk
new file mode 100644
index 0000000..a4802d9
--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,49 @@
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list.  These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+#     $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+#     $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list.  E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# move to system_ext b/138285503
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libdisplayconfig.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/libdisplayconfig.so)
diff --git a/gpu_tonemapper/Android.mk b/gpu_tonemapper/Android.mk
index 6c6ccd1..3c3d8d3 100644
--- a/gpu_tonemapper/Android.mk
+++ b/gpu_tonemapper/Android.mk
@@ -17,7 +17,7 @@
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) $(kernel_deps)
 
 LOCAL_CFLAGS              := $(version_flag) -Wno-missing-field-initializers -Wall \
-                             -Wno-unused-parameter -std=c++11 -DLOG_TAG=\"GPU_TONEMAPPER\"
+                             -Wno-unused-parameter -DLOG_TAG=\"GPU_TONEMAPPER\"
 
 LOCAL_SRC_FILES           := TonemapFactory.cpp \
                              glengine.cpp \
diff --git a/gralloc/QtiMapper.cpp b/gralloc/QtiMapper.cpp
index 8065536..ee1d36f 100644
--- a/gralloc/QtiMapper.cpp
+++ b/gralloc/QtiMapper.cpp
@@ -245,13 +245,15 @@
   auto err = Error::BAD_BUFFER;
   auto hnd = static_cast<private_handle_t *>(buffer);
   uint32_t num_fds = 0, num_ints = 0;
-  if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+  if (buffer != nullptr && private_handle_t::validate(hnd) == 0 &&
+      buf_mgr_->IsBufferImported(hnd) == Error::NONE) {
     num_fds = 2;
     // TODO(user): reduce to transported values;
     num_ints = static_cast<uint32_t >(hnd->numInts);
     err = Error::NONE;
   }
-  ALOGD_IF(DEBUG, "GetTransportSize: num fds: %d num ints: %d err:%d", num_fds, num_ints, err);
+  ALOGD_IF(DEBUG, "GetTransportSize: num fds: %d num ints: %d IsBufferImported:%d err:%d",
+                   num_fds, num_ints, buf_mgr_->IsBufferImported(hnd), err);
   hidl_cb(err, num_fds, num_ints);
   return Void();
 }
diff --git a/libdebug/Android.mk b/libdebug/Android.mk
index 14e5de0..bbe8555 100644
--- a/libdebug/Android.mk
+++ b/libdebug/Android.mk
@@ -5,7 +5,7 @@
 LOCAL_VENDOR_MODULE           := true
 LOCAL_MODULE_TAGS             := optional
 LOCAL_SHARED_LIBRARIES        := libdl
-LOCAL_CFLAGS                  := -DLOG_TAG=\"SDM\" -Wall -std=c++11 -Werror -fno-operator-names
+LOCAL_CFLAGS                  := -DLOG_TAG=\"SDM\" -Wall -Werror -fno-operator-names
 LOCAL_CLANG                   := true
 LOCAL_SRC_FILES               := debug_handler.cpp
 
diff --git a/libdisplayconfig/Android.mk b/libdisplayconfig/Android.mk
index 2ee753e..f719c9d 100644
--- a/libdisplayconfig/Android.mk
+++ b/libdisplayconfig/Android.mk
@@ -2,6 +2,7 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE                  := libdisplayconfig
+LOCAL_SYSTEM_EXT_MODULE       := true
 LOCAL_MODULE_TAGS             := optional
 LOCAL_VENDOR_MODULE           := true
 LOCAL_HEADER_LIBRARIES        := display_headers
diff --git a/libdrmutils/Android.mk b/libdrmutils/Android.mk
index 97c052b..172233f 100644
--- a/libdrmutils/Android.mk
+++ b/libdrmutils/Android.mk
@@ -8,7 +8,7 @@
                                  $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
 LOCAL_HEADER_LIBRARIES        := display_headers
 LOCAL_SHARED_LIBRARIES        := libdrm libdl libdisplaydebug
-LOCAL_CFLAGS                  := -DLOG_TAG=\"DRMUTILS\" -Wall -std=c++11 -Werror -fno-operator-names
+LOCAL_CFLAGS                  := -DLOG_TAG=\"DRMUTILS\" -Wall  -Werror -fno-operator-names
 LOCAL_CLANG                   := true
 LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
 LOCAL_SRC_FILES               := drm_master.cpp drm_res_mgr.cpp drm_lib_loader.cpp
diff --git a/libhistogram/Android.mk b/libhistogram/Android.mk
index d67b228..144ee9a 100644
--- a/libhistogram/Android.mk
+++ b/libhistogram/Android.mk
@@ -18,7 +18,7 @@
 LOCAL_HEADER_LIBRARIES := display_headers
 LOCAL_MODULE := libhistogram
 LOCAL_SRC_FILES := histogram_collector.cpp ringbuffer.cpp
-LOCAL_SHARED_LIBRARIES := libdrm.vendor liblog libcutils libutils
+LOCAL_SHARED_LIBRARIES := libdrm liblog libcutils libutils
 LOCAL_CFLAGS := -DLOG_TAG=\"SDM-histogram\" -Wall -std=c++14 -Werror -fno-operator-names
 LOCAL_CLANG  := true
 LOCAL_MODULE_TAGS := optional
@@ -34,7 +34,7 @@
 LOCAL_SRC_FILES := color_sampling_tool.cpp
 
 LOCAL_STATIC_LIBRARIES := libhistogram
-LOCAL_SHARED_LIBRARIES := libdrm.vendor liblog libcutils libutils libbase
+LOCAL_SHARED_LIBRARIES := libdrm liblog libcutils libutils libbase
 LOCAL_CFLAGS := -DLOG_TAG=\"SDM-histogram\" -Wall -std=c++14 -Werror -fno-operator-names
 LOCAL_CLANG  := true
 LOCAL_MODULE_TAGS := optional
@@ -49,7 +49,7 @@
 LOCAL_SRC_FILES := ringbuffer_test.cpp
 
 LOCAL_STATIC_LIBRARIES := libhistogram libgtest libgmock
-LOCAL_SHARED_LIBRARIES := libdrm.vendor liblog libcutils libutils libbase
+LOCAL_SHARED_LIBRARIES := libdrm liblog libcutils libutils libbase
 LOCAL_CFLAGS := -DLOG_TAG=\"SDM-histogram\" -Wall -std=c++14 -Werror -fno-operator-names
 LOCAL_CLANG  := true
 LOCAL_MODULE_TAGS := optional
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index f0efc2d..d096f24 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -204,8 +204,8 @@
   auto gpu_target_layer_dst_xpixels = out_rect.right - out_rect.left;
   auto gpu_target_layer_dst_ypixels = out_rect.bottom - out_rect.top;
 
-  if (gpu_target_layer_dst_xpixels > mixer_attributes_.width ||
-    gpu_target_layer_dst_ypixels > mixer_attributes_.height) {
+  if (gpu_target_layer_dst_xpixels > layer_mixer_width ||
+    gpu_target_layer_dst_ypixels > layer_mixer_height) {
     DLOGE("GPU target layer dst rect is not with in limits gpu wxh %fx%f, mixer wxh %dx%d",
                   gpu_target_layer_dst_xpixels, gpu_target_layer_dst_ypixels,
                   mixer_attributes_.width, mixer_attributes_.height);
@@ -1173,7 +1173,7 @@
 
     // Align the width and height according to fb's aspect ratio
     *new_mixer_width = FloorToMultipleOf(UINT32((FLOAT(fb_width) / FLOAT(fb_height)) *
-                                         layer_height), align_x);
+                                         FLOAT(layer_height)), align_x);
     *new_mixer_height = FloorToMultipleOf(layer_height, align_y);
 
     LayerRect dst_domain = {0.0f, 0.0f, FLOAT(*new_mixer_width), FLOAT(*new_mixer_height)};
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index 5d6dfde..aa0e13c 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -1521,7 +1521,7 @@
 
   float scale_x = FLOAT(display_attributes_[index].x_pixels) / FLOAT(mixer_attributes.width);
   float scale_y = FLOAT(display_attributes_[index].y_pixels) / FLOAT(mixer_attributes.height);
-  float max_scale_up = hw_resource_.hw_dest_scalar_info.max_scale_up;
+  float max_scale_up = FLOAT(hw_resource_.hw_dest_scalar_info.max_scale_up);
   if (scale_x > max_scale_up || scale_y > max_scale_up) {
     DLOGW(
         "Up scaling ratio exceeds for destination scalar upscale limit scale_x %f scale_y %f "
diff --git a/sdm/libs/core/drm/hw_tv_drm.cpp b/sdm/libs/core/drm/hw_tv_drm.cpp
index 8e141e3..da1a179 100644
--- a/sdm/libs/core/drm/hw_tv_drm.cpp
+++ b/sdm/libs/core/drm/hw_tv_drm.cpp
@@ -261,8 +261,8 @@
     // metadata. This will be replaced with an idle timer implementation in the future.
     if (reset_hdr_flag) {
       gettimeofday(&hdr_reset_end, NULL);
-      float hdr_reset_time_start = ((hdr_reset_start.tv_sec*1000) + (hdr_reset_start.tv_usec/1000));
-      float hdr_reset_time_end = ((hdr_reset_end.tv_sec*1000) + (hdr_reset_end.tv_usec/1000));
+      float hdr_reset_time_start = FLOAT((hdr_reset_start.tv_sec*1000) + (hdr_reset_start.tv_usec/1000));
+      float hdr_reset_time_end = FLOAT((hdr_reset_end.tv_sec*1000) + (hdr_reset_end.tv_usec/1000));
 
       if (((hdr_reset_time_end-hdr_reset_time_start)/1000) >= MIN_HDR_RESET_WAITTIME) {
         memset(&hdr_metadata_, 0, sizeof(hdr_metadata_));
diff --git a/sdm/libs/core/fb/hw_device.cpp b/sdm/libs/core/fb/hw_device.cpp
index 148f866..c7a004c 100644
--- a/sdm/libs/core/fb/hw_device.cpp
+++ b/sdm/libs/core/fb/hw_device.cpp
@@ -1325,7 +1325,7 @@
 
   float scale_x = FLOAT(display_attributes_.x_pixels) / FLOAT(mixer_attributes.width);
   float scale_y = FLOAT(display_attributes_.y_pixels) / FLOAT(mixer_attributes.height);
-  float max_scale_up = hw_resource_.hw_dest_scalar_info.max_scale_up;
+  float max_scale_up = FLOAT(hw_resource_.hw_dest_scalar_info.max_scale_up);
   if (scale_x > max_scale_up || scale_y > max_scale_up) {
     DLOGW_IF(kTagDriverConfig, "Up scaling ratio exceeds for destination scalar upscale " \
              "limit scale_x %f scale_y %f max_scale_up %f", scale_x, scale_y, max_scale_up);
diff --git a/sdm/libs/core/resource_default.cpp b/sdm/libs/core/resource_default.cpp
index e8cce43..6dd7026 100644
--- a/sdm/libs/core/resource_default.cpp
+++ b/sdm/libs/core/resource_default.cpp
@@ -467,9 +467,10 @@
   HWPipeInfo *right_pipe = &layer_config->right_pipe;
   float src_width = src_rect.right - src_rect.left;
   float dst_width = dst_rect.right - dst_rect.left;
+  float fmax_pipe_width = FLOAT(hw_res_info_.max_pipe_width);
 
   // Layer cannot qualify for SrcSplit if source or destination width exceeds max pipe width.
-  if ((src_width > hw_res_info_.max_pipe_width) || (dst_width > hw_res_info_.max_pipe_width)) {
+  if ((src_width > fmax_pipe_width) || (dst_width > fmax_pipe_width)) {
     SplitRect(src_rect, dst_rect, &left_pipe->src_roi, &left_pipe->dst_roi, &right_pipe->src_roi,
               &right_pipe->dst_roi);
     left_pipe->valid = true;
diff --git a/sdm/libs/core/strategy.cpp b/sdm/libs/core/strategy.cpp
index d682070..a2a3ba2 100644
--- a/sdm/libs/core/strategy.cpp
+++ b/sdm/libs/core/strategy.cpp
@@ -159,8 +159,8 @@
     return;
   }
 
-  float layer_mixer_width = mixer_attributes_.width;
-  float layer_mixer_height = mixer_attributes_.height;
+  float layer_mixer_width = FLOAT(mixer_attributes_.width);
+  float layer_mixer_height = FLOAT(mixer_attributes_.height);
 
   if (!hw_resource_info_.is_src_split && display_attributes_.is_device_split) {
     split_display = true;
diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk
index 2ba928d..57d9b37 100644
--- a/sdm/libs/hwc2/Android.mk
+++ b/sdm/libs/hwc2/Android.mk
@@ -27,7 +27,7 @@
                                  android.hardware.graphics.allocator@2.0 \
                                  libdisplaydebug \
                                  hardware.google.light@1.0 \
-                                 libdrm.vendor \
+                                 libdrm \
 
 LOCAL_STATIC_LIBRARIES        := libhistogram
 
diff --git a/sdm/libs/hwc2/hwc_callbacks.cpp b/sdm/libs/hwc2/hwc_callbacks.cpp
index 48593f1..806214b 100644
--- a/sdm/libs/hwc2/hwc_callbacks.cpp
+++ b/sdm/libs/hwc2/hwc_callbacks.cpp
@@ -35,6 +35,7 @@
 namespace sdm {
 
 HWC2::Error HWCCallbacks::Hotplug(hwc2_display_t display, HWC2::Connection state) {
+  std::lock_guard<std::mutex> hotplug_lock(hotplug_mutex_);
   if (!hotplug_) {
     return HWC2::Error::NoResources;
   }
@@ -43,6 +44,7 @@
 }
 
 HWC2::Error HWCCallbacks::Refresh(hwc2_display_t display) {
+  std::lock_guard<std::mutex> refresh_lock(refresh_mutex_);
   if (!refresh_) {
     return HWC2::Error::NoResources;
   }
@@ -51,6 +53,7 @@
 }
 
 HWC2::Error HWCCallbacks::Vsync(hwc2_display_t display, int64_t timestamp) {
+  std::lock_guard<std::mutex> vsync_lock(vsync_mutex_);
   if (!vsync_) {
     return HWC2::Error::NoResources;
   }
@@ -62,18 +65,21 @@
 HWC2::Error HWCCallbacks::Register(HWC2::Callback descriptor, hwc2_callback_data_t callback_data,
                                    hwc2_function_pointer_t pointer) {
   switch (descriptor) {
-    case HWC2::Callback::Hotplug:
+    case HWC2::Callback::Hotplug: {
+      std::lock_guard<std::mutex> hotplug_lock(hotplug_mutex_);
       hotplug_data_ = callback_data;
       hotplug_ = reinterpret_cast<HWC2_PFN_HOTPLUG>(pointer);
-      break;
-    case HWC2::Callback::Refresh:
+    } break;
+    case HWC2::Callback::Refresh: {
+      std::lock_guard<std::mutex> refresh_lock(refresh_mutex_);
       refresh_data_ = callback_data;
       refresh_ = reinterpret_cast<HWC2_PFN_REFRESH>(pointer);
-      break;
-    case HWC2::Callback::Vsync:
+    } break;
+    case HWC2::Callback::Vsync: {
+      std::lock_guard<std::mutex> vsync_lock(vsync_mutex_);
       vsync_data_ = callback_data;
       vsync_ = reinterpret_cast<HWC2_PFN_VSYNC>(pointer);
-      break;
+    } break;
     default:
       return HWC2::Error::BadParameter;
   }
diff --git a/sdm/libs/hwc2/hwc_callbacks.h b/sdm/libs/hwc2/hwc_callbacks.h
index d3f4e52..8cb60fc 100644
--- a/sdm/libs/hwc2/hwc_callbacks.h
+++ b/sdm/libs/hwc2/hwc_callbacks.h
@@ -36,6 +36,8 @@
 #undef HWC2_INCLUDE_STRINGIFICATION
 #undef HWC2_USE_CPP11
 
+#include <mutex>
+
 namespace sdm {
 
 class HWCCallbacks {
@@ -56,6 +58,10 @@
   HWC2_PFN_HOTPLUG hotplug_ = nullptr;
   HWC2_PFN_REFRESH refresh_ = nullptr;
   HWC2_PFN_VSYNC vsync_ = nullptr;
+
+  std::mutex hotplug_mutex_;
+  std::mutex refresh_mutex_;
+  std::mutex vsync_mutex_;
 };
 
 }  // namespace sdm
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 18923b0..1f267e0 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -281,7 +281,8 @@
   // g_ratio = g/kCompensatedMaxRGB
   // b_ratio = b/kCompensatedMaxRGB
   auto rgb_ratio = [=](int rgb, float c2, float c1, float c0) {
-    return ((c2 * rgb * rgb + c1 * rgb + c0) / kCompensatedMaxRGB);
+    float frgb = FLOAT(rgb);
+    return ((c2 * frgb * frgb + c1 * frgb + c0) / kCompensatedMaxRGB);
   };
 
   compensated_red_ratio_ =
@@ -806,8 +807,8 @@
       layer_buffer->release_fence_fd = -1;
       layer->src_rect.left = 0;
       layer->src_rect.top = 0;
-      layer->src_rect.right = layer_buffer->width;
-      layer->src_rect.bottom = layer_buffer->height;
+      layer->src_rect.right = FLOAT(layer_buffer->width);
+      layer->src_rect.bottom = FLOAT(layer_buffer->height);
     }
 
     if (hwc_layer->HasMetaDataRefreshRate() && layer->frame_rate > metadata_refresh_rate_) {
@@ -1278,11 +1279,12 @@
       break;
     }
     case kThermalEvent:
-    case kIdlePowerCollapse:
     case kPanelDeadEvent: {
       SEQUENCE_WAIT_SCOPE_LOCK(HWCSession::locker_[type_]);
       validated_ = false;
     } break;
+    case kIdlePowerCollapse:
+      break;
     default:
       DLOGW("Unknown event: %d", event);
       break;
diff --git a/sdm/libs/hwc2/hwc_display_external.cpp b/sdm/libs/hwc2/hwc_display_external.cpp
index 21a9284..90dd214 100644
--- a/sdm/libs/hwc2/hwc_display_external.cpp
+++ b/sdm/libs/hwc2/hwc_display_external.cpp
@@ -166,8 +166,8 @@
     return;
   }
 
-  uint32_t new_mixer_width = UINT32(mixer_width * FLOAT(1.0f - width_ratio));
-  uint32_t new_mixer_height = UINT32(mixer_height * FLOAT(1.0f - height_ratio));
+  uint32_t new_mixer_width = UINT32(FLOAT(mixer_width) * (1.0f - width_ratio));
+  uint32_t new_mixer_height = UINT32(FLOAT(mixer_height) * (1.0f - height_ratio));
 
   int x_offset = INT((FLOAT(mixer_width) * width_ratio) / 2.0f);
   int y_offset = INT((FLOAT(mixer_height) * height_ratio) / 2.0f);
diff --git a/sdm/libs/hwc2/hwc_display_external_test.cpp b/sdm/libs/hwc2/hwc_display_external_test.cpp
index 8551854..a6fcb08 100644
--- a/sdm/libs/hwc2/hwc_display_external_test.cpp
+++ b/sdm/libs/hwc2/hwc_display_external_test.cpp
@@ -625,7 +625,8 @@
   GetDisplayAttributesForConfig(INT32(active_config), &var_info);
 
   layer->flags.updating = 1;
-  layer->src_rect = LayerRect(0, 0, var_info.x_pixels, var_info.y_pixels);
+  layer->src_rect = LayerRect(0, 0, FLOAT(var_info.x_pixels),
+      FLOAT(var_info.y_pixels));
   layer->dst_rect = layer->src_rect;
   layer->frame_rate = var_info.fps;
   layer->blending = kBlendingPremultiplied;
diff --git a/sdm/libs/hwc2/hwc_display_primary.h b/sdm/libs/hwc2/hwc_display_primary.h
index b0e54f9..4295f52 100644
--- a/sdm/libs/hwc2/hwc_display_primary.h
+++ b/sdm/libs/hwc2/hwc_display_primary.h
@@ -83,6 +83,7 @@
   virtual HWC2::Error GetReadbackBufferFence(int32_t *release_fence);
   virtual HWC2::Error PostCommitLayerStack(int32_t *out_retire_fence);
   virtual HWC2::Error ControlIdlePowerCollapse(bool enable, bool synchronous);
+  virtual DisplayError TeardownConcurrentWriteback(void);
 
   virtual HWC2::Error SetDisplayedContentSamplingEnabledVndService(bool enabled);
   virtual HWC2::Error SetDisplayedContentSamplingEnabled(int32_t enabled, uint8_t component_mask, uint64_t max_frames) override;
@@ -93,7 +94,6 @@
                                                 int32_t samples_size[NUM_HISTOGRAM_COLOR_COMPONENTS],
                                                 uint64_t* samples[NUM_HISTOGRAM_COLOR_COMPONENTS]) override;
   std::string Dump() override;
-  virtual DisplayError TeardownConcurrentWriteback(void);
 
  private:
   HWCDisplayPrimary(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp
index eff1f80..dd287b1 100644
--- a/sdm/libs/hwc2/hwc_layers.cpp
+++ b/sdm/libs/hwc2/hwc_layers.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2018, 2020, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright 2015 The Android Open Source Project
@@ -699,6 +699,7 @@
       format = kFormatYCrCb420PlanarStride16;
       break;
     case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+    case HAL_PIXEL_FORMAT_NV21_ZSL:
       format = kFormatYCrCb420SemiPlanar;
       break;
     case HAL_PIXEL_FORMAT_YCbCr_420_SP: