Snap for 7486544 from e53791a6fc7af7ba90376ae1dba389b1476269b6 to sc-release

Change-Id: I1f5b13f99105ef35b0d1911ffd3d00da27098cc0
diff --git a/common.mk b/common.mk
index dc5ccd0..6038b89 100644
--- a/common.mk
+++ b/common.mk
@@ -13,6 +13,10 @@
     common_flags += -DUSE_COLOR_METADATA
 endif
 
+ifeq ($(TARGET_USES_5.4_KERNEL),true)
+    common_flags += -DKERNEL_5_4
+endif
+
 ifeq ($(TARGET_USES_QCOM_BSP),true)
     common_flags += -DQTI_BSP
 endif
@@ -75,4 +79,8 @@
 # failing which, they are picked from bionic.
     common_deps += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
     kernel_includes += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+ifeq ($(TARGET_USES_5.4_KERNEL), true)
+    kernel_includes += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include/display
+    kernel_includes += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include/vidc
+endif
 endif
diff --git a/composer/QtiComposerClient.cpp b/composer/QtiComposerClient.cpp
index 7e0a5b4..05d9832 100644
--- a/composer/QtiComposerClient.cpp
+++ b/composer/QtiComposerClient.cpp
@@ -1908,7 +1908,7 @@
   for (const auto& m : metadata) {
     keys.push_back(static_cast<int32_t>(m.key));
     sizes_of_metablob_.push_back(m.blob.size());
-    for (uint8_t i = 0; i < m.blob.size(); i++) {
+    for (size_t i = 0; i < m.blob.size(); i++) {
       blob_of_data_.push_back(m.blob[i]);
     }
   }
diff --git a/composer/display_null.cpp b/composer/display_null.cpp
index e0697d5..4a7e205 100644
--- a/composer/display_null.cpp
+++ b/composer/display_null.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
+* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -118,7 +118,9 @@
   }
 
   for (auto layer : layer_stack->layers) {
-    layer->composition = kCompositionGPU;
+    if (layer->composition != kCompositionGPUTarget) {
+      layer->composition = kCompositionGPU;
+    }
   }
   return kErrorNone;
 }
diff --git a/composer/display_null.h b/composer/display_null.h
index ba2cfb4..34a44ae 100644
--- a/composer/display_null.h
+++ b/composer/display_null.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+* Copyright (c) 2017-2019, 2021, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -123,6 +123,12 @@
   MAKE_NO_OP(SetDisplayElapseTime(uint64_t))
   MAKE_NO_OP(ClearLUTs())
 
+  void SetActive(bool active) { active_ = active; }
+  bool IsActive() { return active_; }
+
+ private:
+  bool active_ = false;
+
  protected:
   DisplayConfigVariableInfo default_variable_config_ = {};
   DisplayConfigFixedInfo default_fixed_config_ = {};
@@ -150,11 +156,7 @@
   virtual DisplayError GetFrameBufferConfig(DisplayConfigVariableInfo *variable_info);
   virtual DisplayError GetDisplayIdentificationData(uint8_t *out_port, uint32_t *out_data_size,
                                                     uint8_t *out_data);
-  void SetActive(bool active) { active_ = active; }
-  bool IsActive() { return active_; }
-
  private:
-  bool active_ = false;
   DisplayState state_ = kStateOff;
   DisplayConfigVariableInfo fb_config_ = {};
 };
diff --git a/composer/hwc_display.cpp b/composer/hwc_display.cpp
index affc189..9bf05b7 100644
--- a/composer/hwc_display.cpp
+++ b/composer/hwc_display.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright 2015 The Android Open Source Project
@@ -727,6 +727,10 @@
       is_secure = true;
     }
 
+    if (IS_RGB_FORMAT(layer->input_buffer.format) && hwc_layer->IsScalingPresent()) {
+      layer_stack_.flags.scaling_rgb_layer_present = true;
+    }
+
     if (hwc_layer->IsSingleBuffered() &&
        !(hwc_layer->IsRotationPresent() || hwc_layer->IsScalingPresent())) {
       layer->flags.single_buffer = true;
@@ -1090,9 +1094,9 @@
 
   DisplayConfigVariableInfo variable_config = variable_config_map_.at(config);
 
-  variable_config.x_pixels -= UINT32(window_rect_.right + window_rect_.left);
-  variable_config.y_pixels -= UINT32(window_rect_.bottom + window_rect_.top);
-  if (variable_config.x_pixels <= 0 || variable_config.y_pixels <= 0) {
+  uint32_t x_pixels = variable_config.x_pixels - UINT32(window_rect_.right + window_rect_.left);
+  uint32_t y_pixels = variable_config.y_pixels - UINT32(window_rect_.bottom + window_rect_.top);
+  if (x_pixels <= 0 || y_pixels <= 0) {
     DLOGE("window rects are not within the supported range");
     return HWC2::Error::BadDisplay;
   }
@@ -1102,10 +1106,10 @@
       *out_value = INT32(variable_config.vsync_period_ns);
       break;
     case HwcAttribute::WIDTH:
-      *out_value = INT32(variable_config.x_pixels);
+      *out_value = INT32(x_pixels);
       break;
     case HwcAttribute::HEIGHT:
-      *out_value = INT32(variable_config.y_pixels);
+      *out_value = INT32(y_pixels);
       break;
     case HwcAttribute::DPI_X:
       *out_value = INT32(variable_config.x_dpi * 1000.0f);
diff --git a/composer/hwc_display.h b/composer/hwc_display.h
index a156b8f..1574a04 100644
--- a/composer/hwc_display.h
+++ b/composer/hwc_display.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright 2015 The Android Open Source Project
@@ -266,6 +266,9 @@
   virtual int SetState(bool connected) {
     return kErrorNotSupported;
   }
+  virtual DisplayError SetStandByMode(bool enable) {
+    return kErrorNotSupported;
+  }
   virtual DisplayError Flush() {
     return kErrorNotSupported;
   }
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index 6123e82..edf9a98 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -1334,6 +1334,29 @@
   return kErrorNotSupported;
 }
 
+DisplayError HWCDisplayBuiltIn::SetStandByMode(bool enable) {
+  if (enable) {
+    if (!display_null_.IsActive()) {
+      stored_display_intf_ = display_intf_;
+      display_intf_ = &display_null_;
+      display_null_.SetActive(true);
+      DLOGD("Null display is connected successfully");
+    } else {
+      DLOGD("Null display is already connected.");
+    }
+  } else {
+    if (display_null_.IsActive()) {
+      display_intf_ = stored_display_intf_;
+      validated_ = false;
+      display_null_.SetActive(false);
+      DLOGD("Display is connected successfully");
+    } else {
+      DLOGD("Display is already connected.");
+    }
+  }
+  return kErrorNone;
+}
+
 HWC2::Error HWCDisplayBuiltIn::UpdateDisplayId(hwc2_display_t id) {
   id_ = id;
   return HWC2::Error::None;
diff --git a/composer/hwc_display_builtin.h b/composer/hwc_display_builtin.h
index f608e7e..eba9597 100644
--- a/composer/hwc_display_builtin.h
+++ b/composer/hwc_display_builtin.h
@@ -41,6 +41,7 @@
 #include "cpuhint.h"
 #include "hwc_display.h"
 #include "hwc_layers.h"
+#include "display_null.h"
 
 #include "gl_layer_stitch.h"
 
@@ -113,6 +114,7 @@
   virtual DisplayError SetDynamicDSIClock(uint64_t bitclk);
   virtual DisplayError GetDynamicDSIClock(uint64_t *bitclk);
   virtual DisplayError GetSupportedDSIClock(std::vector<uint64_t> *bitclk_rates);
+  virtual DisplayError SetStandByMode(bool enable);
   virtual HWC2::Error UpdateDisplayId(hwc2_display_t id);
   virtual HWC2::Error SetPendingRefresh();
   virtual HWC2::Error SetPanelBrightness(float brightness);
@@ -244,6 +246,10 @@
   bool enhance_idle_time_ = false;
   bool force_reset_validate_ = false;
 
+  // NULL display
+  DisplayNull display_null_;
+  DisplayInterface *stored_display_intf_ = NULL;
+
   // Members for HBM feature
   static constexpr const char kHighBrightnessModeNode[] =
       "/sys/class/backlight/panel0-backlight/hbm_mode";
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp
index fe52a52..6c5dcac 100644
--- a/composer/hwc_session.cpp
+++ b/composer/hwc_session.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright 2015 The Android Open Source Project
@@ -1722,6 +1722,14 @@
       status = SetDisplayBrightnessScale(input_parcel);
       break;
 
+    case qService::IQService::SET_STAND_BY_MODE:
+      if (!input_parcel) {
+        DLOGE("QService command = %d: input_parcel needed.", command);
+        break;
+      }
+      status = SetStandByMode(input_parcel);
+      break;
+
     default:
       DLOGW("QService command = %d is not supported.", command);
       break;
@@ -2572,6 +2580,21 @@
   return android::NO_ERROR;
 }
 
+android::status_t HWCSession::SetStandByMode(const android::Parcel *input_parcel) {
+  SCOPE_LOCK(locker_[HWC_DISPLAY_PRIMARY]);
+
+  bool enable = (input_parcel->readInt32() > 0);
+
+  if (!hwc_display_[HWC_DISPLAY_PRIMARY]) {
+    DLOGI("Primary display is not initialized");
+    return -EINVAL;
+  }
+
+  hwc_display_[HWC_DISPLAY_PRIMARY]->SetStandByMode(enable);
+
+  return android::NO_ERROR;
+}
+
 int HWCSession::CreatePrimaryDisplay() {
   int status = -EINVAL;
   HWDisplaysInfo hw_displays_info = {};
diff --git a/composer/hwc_session.h b/composer/hwc_session.h
index 7f198ac..ee1a861 100644
--- a/composer/hwc_session.h
+++ b/composer/hwc_session.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright 2015 The Android Open Source Project
@@ -63,6 +63,9 @@
 int32_t GetDataspaceFromColorMode(ColorMode mode);
 
 typedef DisplayConfig::DisplayType DispType;
+#ifdef DISPLAY_CONFIG_CAMERA_SMOOTH_APIs_1_0
+typedef DisplayConfig::CameraSmoothOp CameraSmoothOp;
+#endif
 
 // Create a singleton uevent listener thread valid for life of hardware composer process.
 // This thread blocks on uevents poll inside uevent library implementation. This poll exits
@@ -400,7 +403,10 @@
     virtual int IsRotatorSupportedFormat(int hal_format, bool ubwc, bool *supported);
     virtual int ControlQsyncCallback(bool enable);
     virtual int ControlIdleStatusCallback(bool enable);
-
+#ifdef DISPLAY_CONFIG_CAMERA_SMOOTH_APIs_1_0
+    virtual int SetCameraSmoothInfo(CameraSmoothOp op, uint32_t fps);
+    virtual int ControlCameraSmoothCallback(bool enable);
+#endif
     std::weak_ptr<DisplayConfig::ConfigCallback> callback_;
     HWCSession *hwc_session_ = nullptr;
   };
@@ -492,6 +498,7 @@
   android::status_t SetColorModeById(const android::Parcel *input_parcel);
   android::status_t SetColorModeFromClient(const android::Parcel *input_parcel);
   android::status_t getComposerStatus();
+  android::status_t SetStandByMode(const android::Parcel *input_parcel);
   android::status_t SetQSyncMode(const android::Parcel *input_parcel);
   android::status_t SetIdlePC(const android::Parcel *input_parcel);
   android::status_t SetDisplayDeviceStatus(const android::Parcel *input_parcel);
@@ -565,6 +572,9 @@
   CWB cwb_;
   std::weak_ptr<DisplayConfig::ConfigCallback> qsync_callback_;
   std::weak_ptr<DisplayConfig::ConfigCallback> idle_callback_;
+#ifdef DISPLAY_CONFIG_CAMERA_SMOOTH_APIs_1_0
+  std::weak_ptr<DisplayConfig::ConfigCallback> camera_callback_;
+#endif
   bool async_powermode_ = false;
   bool async_power_mode_triggered_ = false;
   bool async_vds_creation_ = false;
diff --git a/composer/hwc_session_services.cpp b/composer/hwc_session_services.cpp
index ceff82b..bf884e5 100644
--- a/composer/hwc_session_services.cpp
+++ b/composer/hwc_session_services.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
+* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -512,6 +512,29 @@
   return hwc_session_->SetCameraLaunchStatus(on);
 }
 
+#ifdef DISPLAY_CONFIG_CAMERA_SMOOTH_APIs_1_0
+int HWCSession::DisplayConfigImpl::SetCameraSmoothInfo(CameraSmoothOp op, uint32_t fps) {
+  std::shared_ptr<DisplayConfig::ConfigCallback> callback = hwc_session_->camera_callback_.lock();
+  if (!callback) {
+    return -EAGAIN;
+  }
+
+  callback->NotifyCameraSmoothInfo(op, fps);
+
+  return 0;
+}
+
+int HWCSession::DisplayConfigImpl::ControlCameraSmoothCallback(bool enable) {
+  if (enable) {
+    hwc_session_->camera_callback_ = callback_;
+  } else {
+    hwc_session_->camera_callback_.reset();
+  }
+
+  return 0;
+}
+#endif
+
 int HWCSession::DisplayBWTransactionPending(bool *status) {
   SEQUENCE_WAIT_SCOPE_LOCK(locker_[HWC_DISPLAY_PRIMARY]);
 
diff --git a/config/display-product.mk b/config/display-product.mk
index f349a1d..63d22cc 100644
--- a/config/display-product.mk
+++ b/config/display-product.mk
@@ -32,7 +32,8 @@
     vendor.display.comp_mask=0 \
     vendor.display.enable_posted_start_dyn=1 \
     vendor.display.enable_optimize_refresh=1 \
-    vendor.display.use_smooth_motion=1
+    vendor.display.use_smooth_motion=1 \
+    vendor.display.enable_camera_smooth=1
 
 # Enable offline rotator for Bengal.
 ifneq ($(TARGET_BOARD_PLATFORM),bengal)
diff --git a/libdrmutils/Android.mk b/libdrmutils/Android.mk
index 9620635..297fdaf 100644
--- a/libdrmutils/Android.mk
+++ b/libdrmutils/Android.mk
@@ -1,5 +1,6 @@
 ifneq ($(TARGET_IS_HEADLESS), true)
 LOCAL_PATH := $(call my-dir)
+include $(LOCAL_PATH)/../common.mk
 include $(CLEAR_VARS)
 
 LOCAL_MODULE                  := libdrmutils
@@ -9,10 +10,11 @@
 LOCAL_VENDOR_MODULE           := true
 LOCAL_MODULE_TAGS             := optional
 LOCAL_C_INCLUDES              := external/libdrm \
-                                 $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+                                 $(kernel_includes)
 LOCAL_HEADER_LIBRARIES        := display_headers
 LOCAL_SHARED_LIBRARIES        := libdrm libdl libdisplaydebug
 LOCAL_CFLAGS                  := -DLOG_TAG=\"DRMUTILS\" -Wall -Werror -fno-operator-names
+LOCAL_CFLAGS                  += $(common_flags)
 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/libdrmutils/drm_interface.h b/libdrmutils/drm_interface.h
index 5afab4d..9947a55 100644
--- a/libdrmutils/drm_interface.h
+++ b/libdrmutils/drm_interface.h
@@ -41,6 +41,10 @@
 #include <drm/msm_drm.h>
 #include <drm/msm_drm_pp.h>
 
+#ifdef KERNEL_5_4
+#include <drm/sde_drm.h>
+#endif
+
 namespace sde_drm {
 
 typedef std::map<std::pair<uint32_t, uint64_t>, float> CompRatioMap;
diff --git a/libhistogram/Android.mk b/libhistogram/Android.mk
index bf7d058..6dccb5f 100644
--- a/libhistogram/Android.mk
+++ b/libhistogram/Android.mk
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 LOCAL_PATH:= $(call my-dir)
+include $(LOCAL_PATH)/../common.mk
 include $(CLEAR_VARS)
 
 LOCAL_MODULE := libhistogram
@@ -22,7 +23,7 @@
 LOCAL_MODULE_TAGS := optional
 LOCAL_HEADER_LIBRARIES := display_headers
 LOCAL_SHARED_LIBRARIES := libdrm liblog libcutils libutils libbase
-LOCAL_C_INCLUDES          := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include/ \
+LOCAL_C_INCLUDES          := $(kernel_includes) \
                              -isystem external/libdrm
 LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
 LOCAL_CFLAGS := -DLOG_TAG=\"SDM-histogram\" -Wall -std=c++14 -Werror -fno-operator-names \
@@ -41,7 +42,7 @@
 LOCAL_LICENSE_CONDITIONS := notice
 LOCAL_SRC_FILES := color_sampling_tool.cpp
 LOCAL_SHARED_LIBRARIES := libhistogram libdrm liblog libcutils libutils libbase
-LOCAL_C_INCLUDES          := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include/ \
+LOCAL_C_INCLUDES          := $(kernel_includes) \
                              -isystem external/libdrm
 LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
 LOCAL_CFLAGS := -DLOG_TAG=\"SDM-histogram\" -Wall -std=c++14 -Werror -fno-operator-names \
@@ -61,7 +62,7 @@
 LOCAL_SRC_FILES := ringbuffer_test.cpp
 LOCAL_STATIC_LIBRARIES := libgtest libgmock
 LOCAL_SHARED_LIBRARIES := libhistogram libdrm liblog libcutils libutils libbase
-LOCAL_C_INCLUDES          := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include/ \
+LOCAL_C_INCLUDES          := $(kernel_includes) \
                              -isystem external/libdrm
 LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
 LOCAL_CFLAGS := -DLOG_TAG=\"SDM-histogram\" -Wall -std=c++14 -Werror -fno-operator-names \
diff --git a/libqdutils/display_config.cpp b/libqdutils/display_config.cpp
index 8f27200..0157a53 100644
--- a/libqdutils/display_config.cpp
+++ b/libqdutils/display_config.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2013-2014, 2016, 2018-2020, The Linux Foundation. All rights reserved.
+* Copyright (c) 2013-2014, 2016, 2018-2021, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -393,3 +393,19 @@
 
     return !status;
 }
+
+extern "C" int setStandByMode(int mode) {
+    status_t err = (status_t) FAILED_TRANSACTION;
+    sp<IQService> binder = getBinder();
+    Parcel inParcel, outParcel;
+
+    if(binder != NULL) {
+        inParcel.writeInt32(mode);
+        err = binder->dispatch(IQService::SET_STAND_BY_MODE,
+              &inParcel, &outParcel);
+        if(err) {
+            ALOGE("%s() failed with err %d", __FUNCTION__, err);
+        }
+    }
+    return err;
+}
diff --git a/libqdutils/display_config.h b/libqdutils/display_config.h
index 21aea60..81f22d7 100644
--- a/libqdutils/display_config.h
+++ b/libqdutils/display_config.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 - 2016, 2018 - 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013 - 2016, 2018 - 2021, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -170,6 +170,9 @@
 // Sets the specified min and max luminance values.
 int setPanelLuminanceAttributes(int dpy, float min_lum, float max_lum);
 
+// Sets display standy mode
+extern "C" int setStandByMode(int mode);
+
 }; //namespace
 
 
diff --git a/libqservice/IQService.h b/libqservice/IQService.h
index 02bd687..7aae146 100644
--- a/libqservice/IQService.h
+++ b/libqservice/IQService.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012-2014, 2016-2019 The Linux Foundation. All rights reserved.
+ * Copyright (C) 2012-2014, 2016-2019, 2021, The Linux Foundation. All rights reserved.
  *
  * Not a Contribution, Apache license notifications and license are
  * retained for attribution purposes only.
@@ -79,6 +79,7 @@
       SET_PANEL_LUMINANCE = 47,                // Set Panel Luminance attributes.
       SET_BRIGHTNESS_SCALE = 48,               // Set brightness scale ratio
       SET_COLOR_SAMPLING_ENABLED = 49,         // Toggle the collection of display color stats
+      SET_STAND_BY_MODE = 50,                  // Set stand by mode for MDP hardware
       SET_DISPLAY_DEVICE_STATUS = 100,         // Set display device status
       SET_PANEL_GAMMA_TABLE_SOURCE = 101,      // Update panel gamma table
       COMMAND_LIST_END = 400,
diff --git a/sde-drm/Android.mk b/sde-drm/Android.mk
index 6bcae01..1a96769 100644
--- a/sde-drm/Android.mk
+++ b/sde-drm/Android.mk
@@ -1,5 +1,6 @@
 ifneq ($(TARGET_IS_HEADLESS), true)
 LOCAL_PATH := $(call my-dir)
+include $(LOCAL_PATH)/../common.mk
 include $(CLEAR_VARS)
 
 common_header_export_path := qcom/display
@@ -11,11 +12,12 @@
 LOCAL_MODULE_TAGS         := optional
 LOCAL_SHARED_LIBRARIES    := libdrm libdrmutils libdisplaydebug libcutils
 LOCAL_HEADER_LIBRARIES    := display_headers
-LOCAL_C_INCLUDES          := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include/ \
+LOCAL_C_INCLUDES          := $(kernel_includes) \
                              -isystem external/libdrm
 LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
 LOCAL_CFLAGS              := -Wno-missing-field-initializers -Wall -Werror -fno-operator-names \
                              -Wno-unused-parameter -DLOG_TAG=\"SDE_DRM\"
+LOCAL_CFLAGS              += $(common_flags)
 LOCAL_CLANG               := true
 LOCAL_SRC_FILES           := drm_manager.cpp \
                              drm_connector.cpp \
diff --git a/sdm/include/core/layer_stack.h b/sdm/include/core/layer_stack.h
index a27692b..620934f 100644
--- a/sdm/include/core/layer_stack.h
+++ b/sdm/include/core/layer_stack.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are permitted
 * provided that the following conditions are met:
@@ -270,6 +270,8 @@
       uint32_t mask_present : 1;  //!< Set if layer stack has mask layers.
 
       uint32_t config_changed : 1;  //!< This flag indicates Display config must be validated.
+
+      uint32_t scaling_rgb_layer_present : 1; //!< This flag indicates scaling rgb layer presense
     };
 
     uint32_t flags = 0;               //!< For initialization purpose only.