Merge "composer: Add validation for display Id for DSI clock binder APIs"
diff --git a/composer/Android.mk b/composer/Android.mk
index 2ed324d..0202fed 100644
--- a/composer/Android.mk
+++ b/composer/Android.mk
@@ -10,7 +10,7 @@
 LOCAL_C_INCLUDES              := $(common_includes)
 LOCAL_C_INCLUDES              += $(kernel_includes)
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
-LOCAL_HEADER_LIBRARIES        := display_headers
+LOCAL_HEADER_LIBRARIES        := display_headers libThermal_headers
 
 LOCAL_CFLAGS                  := -Wno-missing-field-initializers -Wno-unused-parameter \
                                  -DLOG_TAG=\"SDM\" $(common_flags) -fcolor-diagnostics
@@ -33,7 +33,7 @@
                                  android.hardware.graphics.allocator@2.0 \
                                  android.hardware.graphics.allocator@3.0 \
                                  libdisplayconfig.qti \
-                                 libdrm
+                                 libdrm libthermalclient
 
 LOCAL_SRC_FILES               := QtiComposer.cpp QtiComposerClient.cpp service.cpp \
                                  QtiComposerHandleImporter.cpp \
diff --git a/composer/gl_layer_stitch.h b/composer/gl_layer_stitch.h
index 83ea6a5..e21e5da 100644
--- a/composer/gl_layer_stitch.h
+++ b/composer/gl_layer_stitch.h
@@ -41,7 +41,7 @@
   static void Destroy(GLLayerStitch *intf);
 
   virtual int Blit(const private_handle_t *src_hnd, const private_handle_t *dst_hnd,
-                   const GLRect &src_rect, const GLRect &dst_rect,
+                   const GLRect &src_rect, const GLRect &dst_rect, const GLRect &scissor_rect,
                    const shared_ptr<Fence> &src_acquire_fence,
                    const shared_ptr<Fence> &dst_acquire_fence,
                    shared_ptr<Fence> *release_fence) = 0;
diff --git a/composer/gl_layer_stitch_impl.cpp b/composer/gl_layer_stitch_impl.cpp
index cf838d4..af83ab8 100644
--- a/composer/gl_layer_stitch_impl.cpp
+++ b/composer/gl_layer_stitch_impl.cpp
@@ -132,6 +132,7 @@
 
 int GLLayerStitchImpl::Blit(const private_handle_t *src_hnd, const private_handle_t *dst_hnd,
                             const GLRect &src_rect, const GLRect &dst_rect,
+                            const GLRect &scissor_rect,
                             const shared_ptr<Fence> &src_acquire_fence,
                             const shared_ptr<Fence> &dst_acquire_fence,
                             shared_ptr<Fence> *release_fence) {
@@ -141,6 +142,8 @@
 
   SetProgram(ctx_.program_id);
 
+  ClearWithTransparency(scissor_rect);
+
   SetSourceBuffer(src_hnd);
   SetDestinationBuffer(dst_hnd, dst_rect);
 
@@ -170,6 +173,15 @@
   return 0;
 }
 
+void GLLayerStitchImpl::ClearWithTransparency(const GLRect &scissor_rect) {
+  DTRACE_SCOPED();
+  GL(glScissor(scissor_rect.left, scissor_rect.top, scissor_rect.right - scissor_rect.left,
+               scissor_rect.bottom - scissor_rect.top));
+  GL(glEnable(GL_SCISSOR_TEST));
+  GL(glClearColor(0, 0, 0, 0));
+  GL(glClear(GL_COLOR_BUFFER_BIT));
+}
+
 GLLayerStitchImpl::~GLLayerStitchImpl() {}
 
 GLLayerStitchImpl::GLLayerStitchImpl(bool secure) {
diff --git a/composer/gl_layer_stitch_impl.h b/composer/gl_layer_stitch_impl.h
index a1cddc5..9bef544 100644
--- a/composer/gl_layer_stitch_impl.h
+++ b/composer/gl_layer_stitch_impl.h
@@ -42,7 +42,7 @@
   explicit GLLayerStitchImpl(bool secure);
   virtual ~GLLayerStitchImpl();
   virtual int Blit(const private_handle_t *src_hnd, const private_handle_t *dst_hnd,
-                   const GLRect &src_rect, const GLRect &dst_rect,
+                   const GLRect &src_rect, const GLRect &dst_rect, const GLRect &scissor_rect,
                    const shared_ptr<Fence> &src_acquire_fence,
                    const shared_ptr<Fence> &dst_acquire_fence,
                    shared_ptr<Fence> *release_fence);
@@ -52,6 +52,8 @@
  private:
   bool secure_ = false;
   GLContext ctx_;
+
+  void ClearWithTransparency(const GLRect &scissor_rect);
 };
 
 }  // namespace sdm
diff --git a/composer/hwc_debugger.cpp b/composer/hwc_debugger.cpp
index 2f372e3..411079d 100644
--- a/composer/hwc_debugger.cpp
+++ b/composer/hwc_debugger.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 - 2019, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2020, 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
@@ -179,35 +179,35 @@
   DebugHandler::SetLogMask(debug_handler_.log_mask_);
 }
 
-void HWCDebugHandler::Error(const char *format, ...) {
+void HWCDebugHandler::Error(const char *fmt, ...) {
   va_list list;
-  va_start(list, format);
-  __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, list);
+  va_start(list, fmt);
+  __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, fmt, list);
 }
 
-void HWCDebugHandler::Warning(const char *format, ...) {
+void HWCDebugHandler::Warning(const char *fmt, ...) {
   va_list list;
-  va_start(list, format);
-  __android_log_vprint(ANDROID_LOG_WARN, LOG_TAG, format, list);
+  va_start(list, fmt);
+  __android_log_vprint(ANDROID_LOG_WARN, LOG_TAG, fmt, list);
 }
 
-void HWCDebugHandler::Info(const char *format, ...) {
+void HWCDebugHandler::Info(const char *fmt, ...) {
   va_list list;
-  va_start(list, format);
-  __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, list);
+  va_start(list, fmt);
+  __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, fmt, list);
 }
 
-void HWCDebugHandler::Debug(const char *format, ...) {
+void HWCDebugHandler::Debug(const char *fmt, ...) {
   va_list list;
-  va_start(list, format);
-  __android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG, format, list);
+  va_start(list, fmt);
+  __android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG, fmt, list);
 }
 
-void HWCDebugHandler::Verbose(const char *format, ...) {
+void HWCDebugHandler::Verbose(const char *fmt, ...) {
   if (debug_handler_.verbose_level_) {
     va_list list;
-    va_start(list, format);
-    __android_log_vprint(ANDROID_LOG_VERBOSE, LOG_TAG, format, list);
+    va_start(list, fmt);
+    __android_log_vprint(ANDROID_LOG_VERBOSE, LOG_TAG, fmt, list);
   }
 }
 
diff --git a/composer/hwc_debugger.h b/composer/hwc_debugger.h
index db8c2a6..321c67b 100644
--- a/composer/hwc_debugger.h
+++ b/composer/hwc_debugger.h
@@ -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.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -61,11 +61,11 @@
   static void DebugDisplay(bool enable, int verbose_level);
   static int  GetIdleTimeoutMs();
 
-  virtual void Error(const char *format, ...);
-  virtual void Warning(const char *format, ...);
-  virtual void Info(const char *format, ...);
-  virtual void Debug(const char *format, ...);
-  virtual void Verbose(const char *format, ...);
+  virtual void Error(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+  virtual void Warning(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+  virtual void Info(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+  virtual void Debug(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+  virtual void Verbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
   virtual void BeginTrace(const char *class_name, const char *function_name,
                           const char *custom_string);
   virtual void EndTrace();
diff --git a/composer/hwc_display.cpp b/composer/hwc_display.cpp
index ed07ece..b0e811c 100644
--- a/composer/hwc_display.cpp
+++ b/composer/hwc_display.cpp
@@ -241,7 +241,7 @@
     std::string color_gamut_string, dynamic_range_string;
     error = display_intf_->GetColorModeAttr(mode_string, &attr);
     if (error) {
-      DLOGE("Failed to get mode attributes for mode %d", mode_string.c_str());
+      DLOGE("Failed to get mode attributes for mode %s", mode_string.c_str());
       return HWC2::Error::BadParameter;
     }
 
@@ -534,7 +534,7 @@
 
   game_supported_ = display_intf_->GameEnhanceSupported();
 
-  DLOGI("Display created with id: %d, game_supported_: %d", id_, game_supported_);
+  DLOGI("Display created with id: %d, game_supported_: %d", UINT32(id_), game_supported_);
 
   return 0;
 }
@@ -876,7 +876,7 @@
 }
 
 HWC2::Error HWCDisplay::SetVsyncEnabled(HWC2::Vsync enabled) {
-  DLOGV("Display ID: %d enabled: %s", id_, to_string(enabled).c_str());
+  DLOGV("Display ID: %" PRId64 " enabled: %s", id_, to_string(enabled).c_str());
   ATRACE_INT("SetVsyncState ", enabled == HWC2::Vsync::Enable ? 1 : 0);
   DisplayError error = kErrorNone;
 
@@ -929,7 +929,7 @@
 }
 
 HWC2::Error HWCDisplay::SetPowerMode(HWC2::PowerMode mode, bool teardown) {
-  DLOGV("display = %d, mode = %s", id_, to_string(mode).c_str());
+  DLOGV("display = %" PRId64 ", mode = %s", id_, to_string(mode).c_str());
   DisplayState state = kStateOff;
   bool flush_on_error = flush_on_error_;
 
@@ -1324,7 +1324,7 @@
       if (event_handler_) {
         event_handler_->DisplayPowerReset();
       } else {
-        DLOGW("Cannot execute DisplayPowerReset (client_id = %d), event_handler_ is nullptr",
+        DLOGW("Cannot execute DisplayPowerReset (client_id = %" PRId64 "), event_handler_ is null",
               id_);
       }
     } break;
@@ -1584,7 +1584,7 @@
   DTRACE_SCOPED();
 
   if (!validated_) {
-    DLOGV_IF(kTagClient, "Display %d is not validated", id_);
+    DLOGV_IF(kTagClient, "Display %" PRIu64 "is not validated", id_);
     return HWC2::Error::NotValidated;
   }
 
@@ -1593,7 +1593,7 @@
   }
 
   if (skip_commit_) {
-    DLOGV_IF(kTagClient, "Skipping Refresh on display %d", id_);
+    DLOGV_IF(kTagClient, "Skipping Refresh on display %" PRIu64 , id_);
     return HWC2::Error::None;
   }
 
@@ -1750,8 +1750,8 @@
         reinterpret_cast<const private_handle_t *>(layer->input_buffer.buffer_id);
     Fence::Wait(layer->input_buffer.acquire_fence);
 
-    DLOGI("Dump layer[%d] of %d pvt_handle %x pvt_handle->base %x", i, layer_stack_.layers.size(),
-          pvt_handle, pvt_handle? pvt_handle->base : 0);
+    DLOGI("Dump layer[%d] of %d pvt_handle %p pvt_handle->base %" PRIx64, i,
+          UINT32(layer_stack_.layers.size()), pvt_handle, pvt_handle? pvt_handle->base : 0);
 
     if (!pvt_handle) {
       DLOGE("Buffer handle is null");
@@ -1906,7 +1906,6 @@
   if (windowed_display_) {
     x_pixels -= UINT32(window_rect_.right + window_rect_.left);
     y_pixels -= UINT32(window_rect_.bottom + window_rect_.top);
-    windowed_display_ = false;
   }
   auto client_target_layer = client_target_->GetSDMLayer();
 
@@ -2144,7 +2143,7 @@
   visible_rect->top = INT(display_rect_.top);
   visible_rect->right = INT(display_rect_.right);
   visible_rect->bottom = INT(display_rect_.bottom);
-  DLOGI("Dpy = %d Visible Display Rect(%d %d %d %d)", visible_rect->left, visible_rect->top,
+  DLOGI("Visible Display Rect(%d %d %d %d)", visible_rect->left, visible_rect->top,
         visible_rect->right, visible_rect->bottom);
 
   return 0;
@@ -2167,7 +2166,7 @@
       *power_on_pending = true;
     }
 
-    DLOGI("SecureDisplay state changed from %d to %d for display %d-%d",
+    DLOGI("SecureDisplay state changed from %d to %d for display %" PRId64 "-%d",
           active_secure_sessions_.test(kSecureDisplay), secure_sessions.test(kSecureDisplay),
           id_, type_);
   }
@@ -2335,14 +2334,14 @@
   for (auto hwc_layer : layer_set_) {
     Layer *layer = hwc_layer->GetSDMLayer();
     if (hwc_layer->NeedsValidation()) {
-      DLOGV_IF(kTagClient, "hwc_layer[%d] needs validation. Returning false.",
+      DLOGV_IF(kTagClient, "hwc_layer[%" PRIu64 "] needs validation. Returning false.",
                hwc_layer->GetId());
       return false;
     }
 
     // Do not allow Skip Validate, if any layer needs GPU Composition.
     if (layer->composition == kCompositionGPU || layer->composition == kCompositionNone) {
-      DLOGV_IF(kTagClient, "hwc_layer[%d] is %s. Returning false.", hwc_layer->GetId(),
+      DLOGV_IF(kTagClient, "hwc_layer[%" PRIu64 "] is %s. Returning false.", hwc_layer->GetId(),
                (layer->composition == kCompositionGPU) ? "GPU composed": "Dropped");
       return false;
     }
diff --git a/composer/hwc_display.h b/composer/hwc_display.h
index c96fe61..0360e8c 100644
--- a/composer/hwc_display.h
+++ b/composer/hwc_display.h
@@ -521,7 +521,7 @@
   std::deque<TransientRefreshRateInfo> transient_refresh_rate_info_;
   std::mutex transient_refresh_rate_lock_;
   LayerRect window_rect_ = {};
-  bool windowed_display_ = true;
+  bool windowed_display_ = false;
 
  private:
   void DumpInputBuffers(void);
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index 8d3bb4e..45d9db8 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -131,7 +131,7 @@
   HWCDebugHandler::Get()->GetProperty(ENABLE_OPTIMIZE_REFRESH, &optimize_refresh);
   enable_optimize_refresh_ = (optimize_refresh == 1);
   if (enable_optimize_refresh_) {
-    DLOGI("Drop redundant drawcycles %d", id_);
+    DLOGI("Drop redundant drawcycles %" PRIu64 , id_);
   }
 
   int vsyncs = 0;
@@ -143,10 +143,16 @@
   is_primary_ = display_intf_->IsPrimaryDisplay();
 
   if (is_primary_) {
-    Debug::GetWindowRect(&window_rect_.left, &window_rect_.top,
-                                 &window_rect_.right, &window_rect_.bottom);
+    int enable_bw_limits = 0;
+    HWCDebugHandler::Get()->GetProperty(ENABLE_BW_LIMITS, &enable_bw_limits);
+    enable_bw_limits_ = (enable_bw_limits == 1);
+    if (enable_bw_limits_) {
+      DLOGI("Enable BW Limits %" PRIu64, id_);
+    }
+    windowed_display_ = Debug::GetWindowRect(&window_rect_.left, &window_rect_.top,
+                      &window_rect_.right, &window_rect_.bottom) != kErrorUndefined;
     DLOGI("Window rect : [%f %f %f %f]", window_rect_.left, window_rect_.top,
-           window_rect_.right, window_rect_.bottom);
+          window_rect_.right, window_rect_.bottom);
   }
   return status;
 }
@@ -292,7 +298,8 @@
     Layer *stitch_layer = stitch_target_->GetSDMLayer();
     LayerBuffer &output_buffer = stitch_layer->input_buffer;
     ctx.dst_hnd = reinterpret_cast<const private_handle_t *>(output_buffer.buffer_id);
-    SetRect(layer->stitch_dst_rect, &ctx.dst_rect);
+    SetRect(layer->stitch_info.dst_rect, &ctx.dst_rect);
+    SetRect(layer->stitch_info.slice_rect, &ctx.scissor_rect);
     ctx.src_acquire_fence = input_buffer.acquire_fence;
 
     layer_stitch_task_.PerformTask(LayerStitchTaskCode::kCodeStitch, &ctx);
@@ -342,6 +349,60 @@
   return true;
 }
 
+int HWCDisplayBuiltIn::GetBwCode(const DisplayConfigVariableInfo &attr) {
+  uint32_t min_refresh_rate = 0, max_refresh_rate = 0;
+  display_intf_->GetRefreshRateRange(&min_refresh_rate, &max_refresh_rate);
+  uint32_t fps = attr.smart_panel ? attr.fps : max_refresh_rate;
+
+  if (fps <= 60) {
+    return kBwLow;
+  } else if (fps <= 90) {
+    return kBwMedium;
+  } else {
+    return kBwHigh;
+  }
+}
+
+void HWCDisplayBuiltIn::SetBwLimitHint(bool enable) {
+  if (!enable_bw_limits_) {
+    return;
+  }
+
+  if (!enable) {
+    thermal_bandwidth_client_cancel_request(const_cast<char*>(kDisplayBwName));
+    curr_refresh_rate_ = 0;
+    return;
+  }
+
+  uint32_t config_index = 0;
+  DisplayConfigVariableInfo attr = {};
+  GetActiveDisplayConfig(&config_index);
+  GetDisplayAttributesForConfig(INT(config_index), &attr);
+  if (attr.fps != curr_refresh_rate_ || attr.smart_panel != is_smart_panel_) {
+    int bw_code = GetBwCode(attr);
+    int req_data = thermal_bandwidth_client_merge_input_info(bw_code, 0);
+    int error = thermal_bandwidth_client_request(const_cast<char*>(kDisplayBwName), req_data);
+    if (error) {
+      DLOGE("Thermal bandwidth request failed %d", error);
+    }
+    curr_refresh_rate_ = attr.fps;
+    is_smart_panel_ = attr.smart_panel;
+  }
+}
+
+HWC2::Error HWCDisplayBuiltIn::SetPowerMode(HWC2::PowerMode mode, bool teardown) {
+  auto status = HWCDisplay::SetPowerMode(mode, teardown);
+  if (status != HWC2::Error::None) {
+    return status;
+  }
+
+  if (mode == HWC2::PowerMode::Off) {
+    SetBwLimitHint(false);
+  }
+
+  return HWC2::Error::None;
+}
+
 HWC2::Error HWCDisplayBuiltIn::Present(shared_ptr<Fence> *out_retire_fence) {
   auto status = HWC2::Error::None;
 
@@ -369,6 +430,7 @@
       HandleFrameOutput();
       PostCommitStitchLayers();
       status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
+      SetBwLimitHint(true);
     }
   }
 
@@ -731,7 +793,7 @@
       return err;
     }
 
-    DLOGI("SecureDisplay state changed from %d to %d for display %d-%d",
+    DLOGI("SecureDisplay state changed from %d to %d for display %" PRIu64 "-%d",
           active_secure_sessions_.test(kSecureDisplay), secure_sessions.test(kSecureDisplay),
           id_, type_);
   }
@@ -1051,7 +1113,7 @@
   DisablePartialUpdateOneFrame();
   DisplayError error = display_intf_->SetDynamicDSIClock(bitclk);
   if (error != kErrorNone) {
-    DLOGE(" failed: Clk: %llu Error: %d", bitclk, error);
+    DLOGE(" failed: Clk: %" PRIu64 " Error: %d", bitclk, error);
     return error;
   }
 
@@ -1136,6 +1198,11 @@
     return error;
   }
 
+  // windowed_display and dynamic scaling are not supported.
+  if (windowed_display_) {
+    return HWC2::Error::None;
+  }
+
   Layer *sdm_layer = client_target_->GetSDMLayer();
   uint32_t fb_width = 0, fb_height = 0;
 
@@ -1182,8 +1249,8 @@
         DTRACE_SCOPED();
         LayerStitchContext* ctx = reinterpret_cast<LayerStitchContext*>(task_context);
         gl_layer_stitch_->Blit(ctx->src_hnd, ctx->dst_hnd, ctx->src_rect, ctx->dst_rect,
-                               ctx->src_acquire_fence, ctx->dst_acquire_fence,
-                               &(ctx->release_fence));
+                               ctx->scissor_rect, ctx->src_acquire_fence,
+                               ctx->dst_acquire_fence, &(ctx->release_fence));
       }
       break;
     case LayerStitchTaskCode::kCodeDestroyInstance: {
diff --git a/composer/hwc_display_builtin.h b/composer/hwc_display_builtin.h
index 0bbf034..9864eeb 100644
--- a/composer/hwc_display_builtin.h
+++ b/composer/hwc_display_builtin.h
@@ -30,6 +30,7 @@
 #ifndef __HWC_DISPLAY_BUILTIN_H__
 #define __HWC_DISPLAY_BUILTIN_H__
 
+#include <thermal_client.h>
 #include <mutex>
 #include <string>
 #include <vector>
@@ -59,6 +60,7 @@
   const private_handle_t* dst_hnd = nullptr;
   GLRect src_rect = {};
   GLRect dst_rect = {};
+  GLRect scissor_rect = {};
   shared_ptr<Fence> src_acquire_fence = nullptr;
   shared_ptr<Fence> dst_acquire_fence = nullptr;
   shared_ptr<Fence> release_fence = nullptr;
@@ -144,6 +146,7 @@
       int32_t samples_size[NUM_HISTOGRAM_COLOR_COMPONENTS],
       uint64_t *samples[NUM_HISTOGRAM_COLOR_COMPONENTS]);
   void Dump(std::ostringstream *os) override;
+  virtual HWC2::Error SetPowerMode(HWC2::PowerMode mode, bool teardown);
   virtual bool HasReadBackBufferSupport();
 
  private:
@@ -171,11 +174,17 @@
   bool AllocateStitchBuffer();
   void CacheAvrStatus();
   void PostCommitStitchLayers();
+  int GetBwCode(const DisplayConfigVariableInfo &attr);
+  void SetBwLimitHint(bool enable);
 
   // SyncTask methods.
   void OnTask(const LayerStitchTaskCode &task_code,
               SyncTask<LayerStitchTaskCode>::TaskContext *task_context);
 
+  constexpr static int kBwLow = 2;
+  constexpr static int kBwMedium = 3;
+  constexpr static int kBwHigh = 4;
+
   BufferAllocator *buffer_allocator_ = nullptr;
   CPUHint *cpu_hint_ = nullptr;
   CWBClient cwb_client_ = kCWBClientNone;
@@ -212,6 +221,10 @@
   std::mutex sampling_mutex;
   bool api_sampling_vote = false;
   bool vndservice_sampling_vote = false;
+  int curr_refresh_rate_ = 0;
+  bool is_smart_panel_ = false;
+  const char *kDisplayBwName = "display_bw";
+  bool enable_bw_limits_ = false;
 };
 
 }  // namespace sdm
diff --git a/composer/hwc_display_pluggable_test.cpp b/composer/hwc_display_pluggable_test.cpp
index e73c208..0e638ee 100644
--- a/composer/hwc_display_pluggable_test.cpp
+++ b/composer/hwc_display_pluggable_test.cpp
@@ -495,9 +495,9 @@
     }
   }
 
-  DLOGI("CRC red %x", crc_red.to_ulong());
-  DLOGI("CRC green %x", crc_green.to_ulong());
-  DLOGI("CRC blue %x", crc_blue.to_ulong());
+  DLOGI("CRC red %lx", crc_red.to_ulong());
+  DLOGI("CRC green %lx", crc_green.to_ulong());
+  DLOGI("CRC blue %lx", crc_blue.to_ulong());
 }
 
 void HWCDisplayPluggableTest::GenerateBWVertical(uint8_t *buffer) {
@@ -541,9 +541,9 @@
     }
   }
 
-  DLOGI("CRC red %x", crc_red.to_ulong());
-  DLOGI("CRC green %x", crc_green.to_ulong());
-  DLOGI("CRC blue %x", crc_blue.to_ulong());
+  DLOGI("CRC red %lx", crc_red.to_ulong());
+  DLOGI("CRC green %lx", crc_green.to_ulong());
+  DLOGI("CRC blue %lx", crc_blue.to_ulong());
 }
 
 void HWCDisplayPluggableTest::GenerateColorSquare(uint8_t *buffer) {
@@ -609,9 +609,9 @@
     }
   }
 
-  DLOGI("CRC red %x", crc_red.to_ulong());
-  DLOGI("CRC green %x", crc_green.to_ulong());
-  DLOGI("CRC blue %x", crc_blue.to_ulong());
+  DLOGI("CRC red %lx", crc_red.to_ulong());
+  DLOGI("CRC green %lx", crc_green.to_ulong());
+  DLOGI("CRC blue %lx", crc_blue.to_ulong());
 }
 
 int HWCDisplayPluggableTest::InitLayer(Layer *layer) {
diff --git a/composer/hwc_layers.cpp b/composer/hwc_layers.cpp
index f934040..00f4f1b 100644
--- a/composer/hwc_layers.cpp
+++ b/composer/hwc_layers.cpp
@@ -231,8 +231,8 @@
   if (!buffer) {
     if (client_requested_ == HWC2::Composition::Device ||
         client_requested_ == HWC2::Composition::Cursor) {
-      DLOGW("Invalid buffer handle: %p on layer: %d client requested comp type %d", buffer, id_,
-            client_requested_);
+      DLOGW("Invalid buffer handle: %p on layer: %d client requested comp type %d", buffer,
+            UINT32(id_), client_requested_);
       return HWC2::Error::BadParameter;
     } else {
       return HWC2::Error::None;
@@ -974,8 +974,8 @@
         layer_buffer->color_metadata.matrixCoefficients = new_metadata.matrixCoefficients;
         layer_->update_mask.set(kMetadataUpdate);
       }
-      DLOGV_IF(kTagClient, "Layer id = %lld ColorVolEnabled = %d ContentLightLevelEnabled = %d "
-               "cRIEnabled = %d Dynamic Metadata valid = %d size = %d", id_,
+      DLOGV_IF(kTagClient, "Layer id = %d ColorVolEnabled = %d ContentLightLevelEnabled = %d "
+               "cRIEnabled = %d Dynamic Metadata valid = %d size = %d", UINT32(id_),
                new_metadata.masteringDisplayInfo.colorVolumeSEIEnabled,
                new_metadata.contentLightLevel.lightLevelSEIEnabled,
                new_metadata.cRI.criEnabled, new_metadata.dynamicMetaDataValid,
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp
index 7e93b7f..179a820 100644
--- a/composer/hwc_session.cpp
+++ b/composer/hwc_session.cpp
@@ -351,7 +351,8 @@
   std::copy(map_info_builtin_.begin(), map_info_builtin_.end(), std::back_inserter(map_info));
   std::copy(map_info_pluggable_.begin(), map_info_pluggable_.end(), std::back_inserter(map_info));
   for (auto &map : map_info) {
-    DLOGI("Display Pairs: map.client_id: %d, start_index: %d", map.client_id, start_index);
+    DLOGI("Display Pairs: map.client_id: %d, start_index: %d", INT32(map.client_id),
+          INT32(start_index));
     map_hwc_display_.insert(std::make_pair(map.client_id, start_index++));
   }
 }
@@ -370,7 +371,7 @@
     return;
   }
 
-  DLOGI("Display Pairs: map.client_id: %d, start_index: %d", map_info_primary_.client_id,
+  DLOGI("Display Pairs: map.client_id: %d, start_index: %d", INT32(map_info_primary_.client_id),
                                                              HWCCallbacks::kNumRealDisplays);
   map_hwc_display_.insert(std::make_pair(map_info_primary_.client_id,
                                          HWCCallbacks::kNumRealDisplays));
@@ -469,7 +470,7 @@
 
   auto status = CreateVirtualDisplayObj(width, height, format, out_display_id);
   if (status == HWC2::Error::None) {
-    DLOGI("Created virtual display id:% " PRIu64 ", res: %dx%d", *out_display_id, width, height);
+    DLOGI("Created virtual display id:%" PRIu64 ", res: %dx%d", *out_display_id, width, height);
   } else {
     DLOGE("Failed to create virtual display: %s", to_string(status).c_str());
   }
@@ -877,7 +878,7 @@
         }
       }
       for (auto client_id : updated_pending_hotplugs) {
-        DLOGI("Re-hotplug display connected: client id = %d", client_id);
+        DLOGI("Re-hotplug display connected: client id = %d", UINT32(client_id));
         callbacks_.Hotplug(client_id, HWC2::Connection::Connected);
       }
     }
@@ -1121,7 +1122,7 @@
   }
 
   if (display >= HWCCallbacks::kNumDisplays || (hwc_display_[display] == nullptr)) {
-    DLOGE("Invalid Display %d Handle %s ", display, hwc_display_[display] ?
+    DLOGE("Invalid Display %d Handle %s ", UINT32(display), hwc_display_[display] ?
           "Valid" : "NULL");
     return HWC2_ERROR_BAD_DISPLAY;
   }
@@ -1244,7 +1245,7 @@
         is_hdr_display_[UINT32(client_id)] = HasHDRSupport(hwc_display);
       }
 
-      DLOGI("Created virtual display id:% " PRIu64 " with res: %dx%d", client_id, width, height);
+      DLOGI("Created virtual display id:%" PRIu64 " with res: %dx%d", client_id, width, height);
 
       *out_display_id = client_id;
       map_info.disp_type = kVirtual;
@@ -2271,7 +2272,7 @@
 android::status_t HWCSession::SetDsiClk(const android::Parcel *input_parcel) {
   int disp_id = input_parcel->readInt32();
   uint64_t clk = UINT64(input_parcel->readInt64());
-  if (disp_id < 0) {
+  if (disp_id != HWC_DISPLAY_PRIMARY) {
     return -EINVAL;
   }
 
@@ -2286,7 +2287,7 @@
 android::status_t HWCSession::GetDsiClk(const android::Parcel *input_parcel,
                                         android::Parcel *output_parcel) {
   int disp_id = input_parcel->readInt32();
-  if (disp_id < 0) {
+  if (disp_id != HWC_DISPLAY_PRIMARY) {
     return -EINVAL;
   }
 
@@ -2305,7 +2306,7 @@
 android::status_t HWCSession::GetSupportedDsiClk(const android::Parcel *input_parcel,
                                                  android::Parcel *output_parcel) {
   int disp_id = input_parcel->readInt32();
-  if (disp_id < 0) {
+  if (disp_id != HWC_DISPLAY_PRIMARY) {
     return -EINVAL;
   }
 
@@ -2499,7 +2500,7 @@
 
     if (!status) {
       DLOGI("Created primary display type = %d, sdm id = %d, client id = %d", info.display_type,
-             info.display_id, client_id);
+             info.display_id, UINT32(client_id));
       {
          SCOPE_LOCK(hdr_locker_[client_id]);
          is_hdr_display_[UINT32(client_id)] = HasHDRSupport(*hwc_display);
@@ -2533,7 +2534,7 @@
   HWCDisplayDummy::Create(core_intf_, &buffer_allocator_, &callbacks_, this, qservice_,
                     0, 0, hwc_display_dummy);
   if (!*hwc_display_dummy) {
-    DLOGE("Dummy display creation failed for %d display\n", client_id);
+    DLOGE("Dummy display creation failed for %d display\n", UINT32(client_id));
   }
 }
 
@@ -2569,7 +2570,8 @@
           continue;
         }
 
-        DLOGI("Create builtin display, sdm id = %d, client id = %d", info.display_id, client_id);
+        DLOGI("Create builtin display, sdm id = %d, client id = %d", info.display_id,
+              UINT32(client_id));
         status = HWCDisplayBuiltIn::Create(core_intf_, &buffer_allocator_, &callbacks_, this,
                                            qservice_, client_id, info.display_id,
                                            &hwc_display_[client_id]);
@@ -2583,13 +2585,15 @@
           is_hdr_display_[UINT32(client_id)] = HasHDRSupport(hwc_display_[client_id]);
         }
 
-        DLOGI("Builtin display created: sdm id = %d, client id = %d", info.display_id, client_id);
+        DLOGI("Builtin display created: sdm id = %d, client id = %d", info.display_id,
+              UINT32(client_id));
         map_info.disp_type = info.display_type;
         map_info.sdm_id = info.display_id;
         CreateDummyDisplay(client_id);
       }
 
-      DLOGI("Hotplugging builtin display, sdm id = %d, client id = %d", info.display_id, client_id);
+      DLOGI("Hotplugging builtin display, sdm id = %d, client id = %d", info.display_id,
+            UINT32(client_id));
       callbacks_.Hotplug(client_id, HWC2::Connection::Connected);
       break;
     }
@@ -2710,7 +2714,8 @@
           continue;
         }
 
-        DLOGI("Create pluggable display, sdm id = %d, client id = %d", info.display_id, client_id);
+        DLOGI("Create pluggable display, sdm id = %d, client id = %d", info.display_id,
+              UINT32(client_id));
 
         // Test pattern generation ?
         map_info.test_pattern = (hpd_bpp_ > 0) && (hpd_pattern_ > 0);
@@ -2740,7 +2745,7 @@
         }
 
         DLOGI("Created pluggable display successfully: sdm id = %d, client id = %d",
-              info.display_id, client_id);
+              info.display_id, UINT32(client_id));
         CreateDummyDisplay(client_id);
       }
 
@@ -2766,7 +2771,7 @@
   }
 
   for (auto client_id : pending_hotplugs) {
-    DLOGI("Notify hotplug display connected: client id = %d", client_id);
+    DLOGI("Notify hotplug display connected: client id = %d", UINT32(client_id));
     callbacks_.Hotplug(client_id, HWC2::Connection::Connected);
   }
 
@@ -2826,7 +2831,7 @@
 void HWCSession::DestroyPluggableDisplay(DisplayMapInfo *map_info) {
   hwc2_display_t client_id = map_info->client_id;
 
-  DLOGI("Notify hotplug display disconnected: client id = %d", client_id);
+  DLOGI("Notify hotplug display disconnected: client id = %d", UINT32(client_id));
   callbacks_.Hotplug(client_id, HWC2::Connection::Disconnected);
 
   {
@@ -2836,7 +2841,7 @@
       return;
     }
     DLOGI("Destroy display %d-%d, client id = %d", map_info->sdm_id, map_info->disp_type,
-         client_id);
+         UINT32(client_id));
     {
       SCOPE_LOCK(hdr_locker_[client_id]);
       is_hdr_display_[UINT32(client_id)] = false;
@@ -2873,7 +2878,7 @@
     return;
   }
   DLOGI("Destroy display %d-%d, client id = %d", map_info->sdm_id, map_info->disp_type,
-        client_id);
+        UINT32(client_id));
   {
     SCOPE_LOCK(hdr_locker_[client_id]);
     is_hdr_display_[UINT32(client_id)] = false;
@@ -2961,11 +2966,11 @@
     display < HWCCallbacks::kNumDisplays; display++) {
     if (hwc_display_[display] != NULL) {
       last_power_mode[display] = hwc_display_[display]->GetCurrentPowerMode();
-      DLOGI("Powering off display = %d", display);
+      DLOGI("Powering off display = %d", INT32(display));
       status = hwc_display_[display]->SetPowerMode(HWC2::PowerMode::Off,
                                                    true /* teardown */);
       if (status != HWC2::Error::None) {
-        DLOGE("Power off for display = %d failed with error = %d", display, status);
+        DLOGE("Power off for display = %d failed with error = %d", INT32(display), status);
       }
     }
   }
@@ -2973,15 +2978,15 @@
     display < HWCCallbacks::kNumDisplays; display++) {
     if (hwc_display_[display] != NULL) {
       HWC2::PowerMode mode = last_power_mode[display];
-      DLOGI("Setting display %d to mode = %d", display, mode);
+      DLOGI("Setting display %d to mode = %d", INT32(display), mode);
       status = hwc_display_[display]->SetPowerMode(mode, false /* teardown */);
       if (status != HWC2::Error::None) {
-        DLOGE("%d mode for display = %d failed with error = %d", mode, display, status);
+        DLOGE("%d mode for display = %d failed with error = %d", mode, INT32(display), status);
       }
       ColorMode color_mode = hwc_display_[display]->GetCurrentColorMode();
       status = hwc_display_[display]->SetColorMode(color_mode);
       if (status != HWC2::Error::None) {
-        DLOGE("SetColorMode failed for display = %d error = %d", display, status);
+        DLOGE("SetColorMode failed for display = %d error = %d", INT32(display), status);
       }
     }
   }
diff --git a/composer/hwc_session_services.cpp b/composer/hwc_session_services.cpp
index acfe157..66ed32b 100644
--- a/composer/hwc_session_services.cpp
+++ b/composer/hwc_session_services.cpp
@@ -571,7 +571,7 @@
     return 0;
   }
 
-  DLOGW("Display = %d is not connected.", active_builtin_disp_id);
+  DLOGW("Display = %d is not connected.", UINT32(active_builtin_disp_id));
   return -ENODEV;
 }
 
@@ -822,7 +822,7 @@
   hwc2_display_t disp_id = hwc_session_->GetActiveBuiltinDisplay();
 
   if (disp_id >= HWCCallbacks::kNumDisplays) {
-    DLOGE("Invalid display = %d", disp_id);
+    DLOGE("Invalid display = %d", UINT32(disp_id));
   } else {
     if (hwc_session_->hwc_display_[disp_id]) {
       uint32_t config_index = 0;
@@ -1147,7 +1147,7 @@
   auto status = hwc_session_->CreateVirtualDisplayObj(width, height, &format,
                                                       &hwc_session_->virtual_id_);
   if (status == HWC2::Error::None) {
-    DLOGI("Created virtual display id:% " PRIu64 ", res: %dx%d",
+    DLOGI("Created virtual display id:%" PRIu64 ", res: %dx%d",
           hwc_session_->virtual_id_, width, height);
     if (active_builtin_disp_id < HWCCallbacks::kNumRealDisplays) {
       hwc_session_->WaitForResources(true, active_builtin_disp_id, hwc_session_->virtual_id_);
diff --git a/composer/hwc_tonemapper.cpp b/composer/hwc_tonemapper.cpp
index 5a1f9ef..1038d1d 100644
--- a/composer/hwc_tonemapper.cpp
+++ b/composer/hwc_tonemapper.cpp
@@ -292,7 +292,7 @@
 
   error = buffer_allocator_->MapBuffer(target_buffer, acquire_fd);
   if (error != kErrorNone) {
-    DLOGE("MapBuffer failed, base addr = %x", target_buffer->base);
+    DLOGE("MapBuffer failed, base addr = %" PRIx64, target_buffer->base);
     return;
   }
 
@@ -304,7 +304,7 @@
 
   FILE* fp = fopen(dump_file_name, "w+");
   if (fp) {
-    DLOGI("base addr = %x", target_buffer->base);
+    DLOGI("base addr = %" PRIx64, target_buffer->base);
     result = fwrite(reinterpret_cast<void *>(target_buffer->base), target_buffer->size, 1, fp);
     fclose(fp);
   }
diff --git a/config/display-product.mk b/config/display-product.mk
index 0c91d89..636644f 100644
--- a/config/display-product.mk
+++ b/config/display-product.mk
@@ -7,7 +7,6 @@
     android.hardware.memtrack@1.0-impl \
     android.hardware.memtrack@1.0-service \
     android.hardware.light@2.0-impl \
-    android.hardware.light@2.0-service \
     gralloc.$(TARGET_BOARD_PLATFORM) \
     lights.$(TARGET_BOARD_PLATFORM) \
     hwcomposer.$(TARGET_BOARD_PLATFORM) \
@@ -89,6 +88,14 @@
     vendor.display.disable_layer_stitch=0
 endif
 
+ifeq ($(TARGET_BOARD_PLATFORM)$(TARGET_BOARD_SUFFIX),bengal_32go)
+    PRODUCT_PACKAGES += \
+        android.hardware.light@2.0-service-lazy
+else
+    PRODUCT_PACKAGES += \
+        android.hardware.light@2.0-service
+endif
+
 ifeq ($(TARGET_BOARD_PLATFORM),kona)
 PRODUCT_PROPERTY_OVERRIDES += \
     debug.sf.enable_gl_backpressure=1
diff --git a/gralloc/gr_adreno_info.cpp b/gralloc/gr_adreno_info.cpp
index 08e0033..2b82dc6 100644
--- a/gralloc/gr_adreno_info.cpp
+++ b/gralloc/gr_adreno_info.cpp
@@ -204,6 +204,8 @@
        return ADRENO_PIXELFORMAT_R16G16B16A16_FLOAT;
     case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
       return ADRENO_PIXELFORMAT_NV12;
+    case HAL_PIXEL_FORMAT_NV21_ENCODEABLE:
+      return ADRENO_PIXELFORMAT_NV21;
     case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
     case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC:
       return ADRENO_PIXELFORMAT_NV12_EXT;
diff --git a/gralloc/gr_utils.cpp b/gralloc/gr_utils.cpp
index 07ad9e2..c012d1d 100644
--- a/gralloc/gr_utils.cpp
+++ b/gralloc/gr_utils.cpp
@@ -49,6 +49,7 @@
     case HAL_PIXEL_FORMAT_YCbCr_422_SP:
     case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
     case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:  // Same as YCbCr_420_SP_VENUS
+    case HAL_PIXEL_FORMAT_NV21_ENCODEABLE:
     case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC:
     case HAL_PIXEL_FORMAT_YCrCb_420_SP:
     case HAL_PIXEL_FORMAT_YCrCb_422_SP:
@@ -544,6 +545,7 @@
       c_size = ALIGN(2 * ALIGN(unaligned_width / 2, 32) * ALIGN(unaligned_height / 2, 32), 4096);
       break;
     case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
+    case HAL_PIXEL_FORMAT_NV21_ENCODEABLE:
       c_height = VENUS_UV_SCANLINES(COLOR_FMT_NV21, height);
       c_size = c_stride * c_height;
       break;
@@ -1069,6 +1071,7 @@
       aligned_h = INT(VENUS_Y_SCANLINES(COLOR_FMT_NV12, height));
       break;
     case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
+    case HAL_PIXEL_FORMAT_NV21_ENCODEABLE:
       aligned_w = INT(VENUS_Y_STRIDE(COLOR_FMT_NV21, width));
       aligned_h = INT(VENUS_Y_SCANLINES(COLOR_FMT_NV21, height));
       break;
@@ -1130,6 +1133,7 @@
     case HAL_PIXEL_FORMAT_YCrCb_420_SP:
     case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
     case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+    case HAL_PIXEL_FORMAT_NV21_ENCODEABLE:
       offset[1] = static_cast<uint32_t>(reinterpret_cast<uint64_t>(yuvInfo.cr) - hnd->base);
       break;
     case HAL_PIXEL_FORMAT_YV12:
@@ -1373,6 +1377,7 @@
     case HAL_PIXEL_FORMAT_YCbCr_422_SP:
     case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
     case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:  // Same as YCbCr_420_SP_VENUS
+    case HAL_PIXEL_FORMAT_NV21_ENCODEABLE:
     case HAL_PIXEL_FORMAT_NV12_HEIF:
     case HAL_PIXEL_FORMAT_YCrCb_420_SP:
     case HAL_PIXEL_FORMAT_YCrCb_422_SP:
@@ -1604,6 +1609,7 @@
     case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
     case HAL_PIXEL_FORMAT_YCrCb_420_SP:
     case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:  // Same as YCbCr_420_SP_VENUS
+    case HAL_PIXEL_FORMAT_NV21_ENCODEABLE:
     case HAL_PIXEL_FORMAT_YV12:
     case HAL_PIXEL_FORMAT_NV12_HEIF:
       *h_subsampling = 1;
diff --git a/include/display_properties.h b/include/display_properties.h
index 45e6db6..a0e445f 100644
--- a/include/display_properties.h
+++ b/include/display_properties.h
@@ -117,6 +117,9 @@
 #define CAMERA_NOC_EFFICIENCY_FACTOR         DISPLAY_PROP("camera_noc_efficiency_factor")
 #define ENABLE_HISTOGRAM_INTR                DISPLAY_PROP("enable_hist_intr")
 #define DEFER_FPS_FRAME_COUNT                DISPLAY_PROP("defer_fps_frame_count")
+#define ENABLE_BW_LIMITS                     DISPLAY_PROP("enable_bw_limits")
+#define DISABLE_ROTATOR_PRE_DOWNSCALER_PROP  DISPLAY_PROP("disable_pre_downscaler")
+#define DISABLE_INLINE_ROTATOR_UI_PROP       DISPLAY_PROP("disable_inline_rotator_ui")
 
 // Add all vendor.display properties above
 
@@ -131,6 +134,7 @@
 #define ZERO_SWAP_INTERVAL                   "vendor.debug.egl.swapinterval"
 #define WINDOW_RECT_PROP                     DISPLAY_PROP("window_rect")
 #define DISABLE_IDLE_TIME_HDR                DISPLAY_PROP("disable_idle_time_hdr")
+#define DISABLE_IDLE_TIME_VIDEO              DISPLAY_PROP("disable_idle_time_video")
 // Add all other.properties above
 // End of property
 #endif  // __DISPLAY_PROPERTIES_H__
diff --git a/libdebug/debug_handler.h b/libdebug/debug_handler.h
index 81795e4..6e6f7ee 100644
--- a/libdebug/debug_handler.h
+++ b/libdebug/debug_handler.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2018, 2020 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
@@ -62,11 +62,12 @@
 
 class DebugHandler {
  public:
-  virtual void Error(const char *format, ...) = 0;
-  virtual void Warning(const char *format, ...) = 0;
-  virtual void Info(const char *format, ...) = 0;
-  virtual void Debug(const char *format, ...) = 0;
-  virtual void Verbose(const char *format, ...) = 0;
+  // __format__(printf hints the compiler to validate format specifiers vs arguments provided.
+  virtual void Error(const char *format, ...) __attribute__ ((__format__(printf, 2, 3))) = 0;
+  virtual void Warning(const char *format, ...) __attribute__ ((__format__(printf, 2, 3))) = 0;
+  virtual void Info(const char *format, ...) __attribute__ ((__format__(printf, 2, 3))) = 0;
+  virtual void Debug(const char *format, ...) __attribute__ ((__format__(printf, 2, 3))) = 0;
+  virtual void Verbose(const char *format, ...) __attribute__ ((__format__(printf, 2, 3))) = 0;
   virtual void BeginTrace(const char *class_name, const char *function_name,
                           const char *custom_string) = 0;
   virtual void EndTrace() = 0;
diff --git a/libdrmutils/drm_interface.h b/libdrmutils/drm_interface.h
index ba04800..5afab4d 100644
--- a/libdrmutils/drm_interface.h
+++ b/libdrmutils/drm_interface.h
@@ -486,6 +486,7 @@
 enum struct InlineRotationVersion {
   kInlineRotationNone,
   kInlineRotationV1,
+  kInlineRotationV2,
 };
 
 /* Per CRTC Resource Info*/
diff --git a/sde-drm/drm_connector.cpp b/sde-drm/drm_connector.cpp
index aeb9d7c..ff501e5 100644
--- a/sde-drm/drm_connector.cpp
+++ b/sde-drm/drm_connector.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2019, The Linux Foundation. All rights reserved.
+* Copyright (c) 2019-2020, 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
@@ -493,7 +493,7 @@
   memcpy (fmt_str, blob->data, blob->length);
   fmt_str[blob->length] = '\0';
   stringstream stream(fmt_str);
-  DRM_LOGI("stream str %s len %d blob str %s len %d", stream.str().c_str(), stream.str().length(),
+  DRM_LOGI("stream str %s len %zu blob str %s len %d", stream.str().c_str(), stream.str().length(),
            blob->data, blob->length);
   string line = {};
   const string display_type = "display type=";
@@ -576,7 +576,7 @@
   memcpy (fmt_str, blob->data, blob->length);
   fmt_str[blob->length] = '\0';
   stringstream stream(fmt_str);
-  DRM_LOGI("stream str %s len %d blob str %s len %d", stream.str().c_str(), stream.str().length(),
+  DRM_LOGI("stream str %s len %zu blob str %s len %d", stream.str().c_str(), stream.str().length(),
            blob->data, blob->length);
 
   string line = {};
diff --git a/sde-drm/drm_crtc.cpp b/sde-drm/drm_crtc.cpp
index 3af43f1..1a49600 100644
--- a/sde-drm/drm_crtc.cpp
+++ b/sde-drm/drm_crtc.cpp
@@ -323,7 +323,7 @@
   memcpy (fmt_str, blob->data, blob->length);
   fmt_str[blob->length] = '\0';
   stringstream stream(fmt_str);
-  DRM_LOGI("stream str %s len %d blob str %s len %d", stream.str().c_str(), stream.str().length(),
+  DRM_LOGI("stream str %s len %zu blob str %s len %d", stream.str().c_str(), stream.str().length(),
            blob->data, blob->length);
   string line = {};
   string max_blendstages = "max_blendstages=";
diff --git a/sde-drm/drm_dpps_mgr_imp.cpp b/sde-drm/drm_dpps_mgr_imp.cpp
index 23e8cc4..5b2768c 100644
--- a/sde-drm/drm_dpps_mgr_imp.cpp
+++ b/sde-drm/drm_dpps_mgr_imp.cpp
@@ -463,7 +463,7 @@
   }
 
   if (!info->payload || info->payload_size != sizeof(struct DRMDppsLtmBuffers)) {
-    DRM_LOGE("Invalid payload %p size %d expected %d", info->payload, info->payload_size,
+    DRM_LOGE("Invalid payload %p size %d expected %zu", info->payload, info->payload_size,
        sizeof(struct DRMDppsLtmBuffers));
     return -EINVAL;
   }
diff --git a/sde-drm/drm_plane.cpp b/sde-drm/drm_plane.cpp
index 8934a3b..c457331 100644
--- a/sde-drm/drm_plane.cpp
+++ b/sde-drm/drm_plane.cpp
@@ -193,6 +193,7 @@
     case 0x0000: return InlineRotationVersion::kInlineRotationNone;
     case 0x0001:
     case 0x0100: return InlineRotationVersion::kInlineRotationV1;
+    case 0x0200: return InlineRotationVersion::kInlineRotationV2;
     default: return InlineRotationVersion::kInlineRotationNone;
   }
 }
@@ -446,7 +447,7 @@
   // We may have multiple lines with each one dedicated for something specific
   // like formats etc
   stringstream stream(fmt_str);
-  DRM_LOGI("stream str %s len %d blob str %s len %d", stream.str().c_str(), stream.str().length(),
+  DRM_LOGI("stream str %s len %zu blob str %s len %d", stream.str().c_str(), stream.str().length(),
            blob->data, blob->length);
 
   string line = {};
@@ -1102,8 +1103,7 @@
                 reinterpret_cast<uint64_t>(csc_v1_data), false /* cache */,
                 tmp_prop_val_map_);
     dgm_csc_in_use_ = (csc_v1_data != 0);
-    DRM_LOGV("Plane %d Dgm CSC = %lld in_use = %d", drm_plane_->plane_id, csc_v1_data,
-             dgm_csc_in_use_);
+    DRM_LOGV("Plane %d in_use = %d", drm_plane_->plane_id, dgm_csc_in_use_);
 
     return true;
   }
diff --git a/sdm/include/core/layer_stack.h b/sdm/include/core/layer_stack.h
index 8802d48..d61a782 100644
--- a/sdm/include/core/layer_stack.h
+++ b/sdm/include/core/layer_stack.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014-2020, 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:
@@ -305,6 +305,13 @@
   uint32_t count = 0;      //!< Number of elements in the array.
 };
 
+struct LayerStitchInfo {
+  LayerRect dst_rect = {};          //!< The target position where the frame will be
+                                    //!< rendered onto internal FrameBuffer.
+
+  LayerRect slice_rect = {};        //!<  Target slice that this stitch rect belongs to.
+};
+
 /*! @brief This structure defines solidfill structure.
 
   @sa LayerSolidFill
@@ -348,8 +355,9 @@
                                                    //!< fit into this rectangle. The origin is the
                                                    //!< top-left corner of the screen.
 
-  LayerRect stitch_dst_rect = {};                  //!< The target position where the frame will be
-                                                   //!< rendered onto internal FrameBuffer.
+  LayerStitchInfo stitch_info = {};                //!< This structure defines all parameters needed
+                                                   //!< for stitching like position to render,
+                                                   //!< boundaries etc;
 
   std::vector<LayerRect> visible_regions = {};     //!< Visible rectangular areas in screen space.
                                                    //!< The visible region includes areas overlapped
diff --git a/sdm/include/private/hw_info_types.h b/sdm/include/private/hw_info_types.h
index 524fb1f..48a6b80 100644
--- a/sdm/include/private/hw_info_types.h
+++ b/sdm/include/private/hw_info_types.h
@@ -243,7 +243,7 @@
   std::string device_path = "";
   float min_downscale = 2.0f;
   bool downscale_compression = false;
-  uint64_t max_line_width = 0;
+  uint32_t max_line_width = 0;
 };
 
 enum HWQseedStepVersion {
@@ -271,12 +271,14 @@
 enum InlineRotationVersion {
   kInlineRotationNone,
   kInlineRotationV1,
+  kInlineRotationV2,
 };
 
 struct InlineRotationInfo {
   InlineRotationVersion inrot_version = kInlineRotationNone;
   std::vector<LayerBufferFormat> inrot_fmts_supported;
   float max_downscale_rt = 2.2f;    // max downscale real time display
+  float max_ds_without_pre_downscaler = 2.2f;
 };
 
 
@@ -337,7 +339,7 @@
   uint32_t cache_size = 0;  // cache size in bytes
   HWQseedStepVersion pipe_qseed3_version = kQseed3v2;  // only valid when has_qseed3=true
   uint32_t min_prefill_lines = 0;
-  InlineRotationInfo inline_rot_info;
+  InlineRotationInfo inline_rot_info = {};
   std::bitset<32> src_tone_map = 0;  //!< Stores the bit mask of src tone map capability
   int secure_disp_blend_stage = -1;
   uint32_t line_width_constraints_count = 0;
@@ -578,6 +580,11 @@
   uint32_t y_rgb_sep_lut_idx = 0;
   uint32_t uv_sep_lut_idx = 0;
   HWDetailEnhanceData detail_enhance {};
+
+  uint32_t src_x_pre_down_scale_0 = 0;
+  uint32_t src_x_pre_down_scale_1 = 0;
+  uint32_t src_y_pre_down_scale_0 = 0;
+  uint32_t src_y_pre_down_scale_1 = 0;
 };
 
 struct HWDestScaleInfo {
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index 1ba4e40..174be7a 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -229,7 +229,7 @@
   }
 
   hw_layers_info.stitch_target_index = hw_layers_info.gpu_target_index + 1;
-  DLOGD_IF(kTagDisplay, "LayerStack layer_count: %d, app_layer_count: %d, "
+  DLOGD_IF(kTagDisplay, "LayerStack layer_count: %zu, app_layer_count: %d, "
                         "gpu_target_index: %d, stitch_index: %d game_present: %d, display: %d-%d",
                         layers.size(), hw_layers_info.app_layer_count,
                         hw_layers_info.gpu_target_index, hw_layers_info.stitch_target_index,
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index c6e914f..b4531e8 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -305,21 +305,25 @@
 
   for (uint32_t i = 0; i < hw_layer_count; i++) {
     Layer &layer = hw_layer_info.hw_layers.at(i);
-    LayerBuffer *input_buffer = &layer.input_buffer;
+    LayerBuffer input_buffer = layer.input_buffer;
     HWRotatorSession *hw_rotator_session = &hw_layers->config[i].hw_rotator_session;
     HWRotateInfo *hw_rotate_info = &hw_rotator_session->hw_rotate_info[0];
-    fbid_cache_limit_ = input_buffer->flags.video ? VIDEO_FBID_LIMIT : UI_FBID_LIMIT;
+    fbid_cache_limit_ = input_buffer.flags.video ? VIDEO_FBID_LIMIT : UI_FBID_LIMIT;
 
     if (hw_rotator_session->mode == kRotatorOffline && hw_rotate_info->valid) {
-      input_buffer = &hw_rotator_session->output_buffer;
+      input_buffer = hw_rotator_session->output_buffer;
       fbid_cache_limit_ = OFFLINE_ROTATOR_FBID_LIMIT;
     }
 
+    if (input_buffer.flags.interlace) {
+      input_buffer.width *= 2;
+      input_buffer.height /= 2;
+    }
     MapBufferToFbId(&layer, input_buffer);
   }
 }
 
-int HWDeviceDRM::Registry::CreateFbId(LayerBuffer *buffer, uint32_t *fb_id) {
+int HWDeviceDRM::Registry::CreateFbId(const LayerBuffer &buffer, uint32_t *fb_id) {
   DRMMaster *master = nullptr;
   DRMMaster::GetInstance(&master);
   int ret = -1;
@@ -331,10 +335,10 @@
 
   DRMBuffer layout{};
   AllocatedBufferInfo buf_info{};
-  buf_info.fd = layout.fd = buffer->planes[0].fd;
-  buf_info.aligned_width = layout.width = buffer->width;
-  buf_info.aligned_height = layout.height = buffer->height;
-  buf_info.format = buffer->format;
+  buf_info.fd = layout.fd = buffer.planes[0].fd;
+  buf_info.aligned_width = layout.width = buffer.width;
+  buf_info.aligned_height = layout.height = buffer.height;
+  buf_info.format = buffer.format;
   GetDRMFormat(buf_info.format, &layout.drm_format, &layout.drm_format_modifier);
   buffer_allocator_->GetBufferLayout(buf_info, layout.stride, layout.offset, &layout.num_planes);
   ret = master->CreateFbId(layout, fb_id);
@@ -346,12 +350,12 @@
   return ret;
 }
 
-void HWDeviceDRM::Registry::MapBufferToFbId(Layer* layer, LayerBuffer* buffer) {
-  if (buffer->planes[0].fd < 0) {
+void HWDeviceDRM::Registry::MapBufferToFbId(Layer* layer, const LayerBuffer &buffer) {
+  if (buffer.planes[0].fd < 0) {
     return;
   }
 
-  uint64_t handle_id = buffer->handle_id;
+  uint64_t handle_id = buffer.handle_id;
   if (!handle_id || disable_fbid_cache_) {
     // In legacy path, clear fb_id map in each frame.
     layer->buffer_map->buffer_map.clear();
@@ -359,7 +363,7 @@
     auto it = layer->buffer_map->buffer_map.find(handle_id);
     if (it != layer->buffer_map->buffer_map.end()) {
       FrameBufferObject *fb_obj = static_cast<FrameBufferObject*>(it->second.get());
-      if (fb_obj->IsEqual(buffer->format, buffer->width, buffer->height)) {
+      if (fb_obj->IsEqual(buffer.format, buffer.width, buffer.height)) {
         // Found fb_id for given handle_id key
         return;
       } else {
@@ -378,7 +382,7 @@
   if (CreateFbId(buffer, &fb_id) >= 0) {
     // Create and cache the fb_id in map
     layer->buffer_map->buffer_map[handle_id] = std::make_shared<FrameBufferObject>(fb_id,
-        buffer->format, buffer->width, buffer->height);
+        buffer.format, buffer.width, buffer.height);
   }
 }
 
@@ -409,7 +413,7 @@
   }
 
   uint32_t fb_id = 0;
-  if (CreateFbId(output_buffer, &fb_id) >= 0) {
+  if (CreateFbId(*output_buffer, &fb_id) >= 0) {
     output_buffer_map_[handle_id] = std::make_shared<FrameBufferObject>(fb_id,
         output_buffer->format, output_buffer->width, output_buffer->height);
   }
@@ -486,7 +490,7 @@
   }
 
   if (!connector_info_.is_connected || connector_info_.modes.empty()) {
-    DLOGW("Device removal detected on connector id %u. Connector status %s and %d modes.",
+    DLOGW("Device removal detected on connector id %u. Connector status %s and %zu modes.",
           token_.conn_id, connector_info_.is_connected ? "connected":"disconnected",
           connector_info_.modes.size());
     drm_mgr_intf_->DestroyAtomicReq(drm_atomic_intf_);
@@ -521,6 +525,7 @@
     // connector (i.e., any connector which did not have a display commit on it and a crtc path
     // setup), so token_.conn_id may have been removed if there was no commit, resulting in
     // drmModeAtomicCommit() failure with ENOENT, 'No such file or directory'.
+    ClearSolidfillStages();
     drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, token_.conn_id, 0);
     drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::OFF);
     drm_atomic_intf_->Perform(DRMOps::CRTC_SET_MODE, token_.crtc_id, nullptr);
@@ -1283,12 +1288,13 @@
     drm_atomic_intf_->Perform(DRMOps::CONNECTOR_GET_RETIRE_FENCE, token_.conn_id, retire_fence_fd);
   }
 
-  DLOGI_IF(kTagDriverConfig, "%s::%s System Clock=%d Hz, Core: AB=%llu Bps, IB=%llu Bps, " \
-           "LLCC: AB=%llu Bps, IB=%llu Bps, DRAM AB=%llu Bps, IB=%llu Bps, "\
-           "Rot: Bw=%llu Bps, Clock=%d Hz", validate ? "Validate" : "Commit", device_name_,
-           qos_data.clock_hz, qos_data.core_ab_bps, qos_data.core_ib_bps, qos_data.llcc_ab_bps,
-           qos_data.llcc_ib_bps, qos_data.dram_ab_bps, qos_data.dram_ib_bps,
-           qos_data.rot_prefill_bw_bps, qos_data.rot_clock_hz);
+  DLOGI_IF(kTagDriverConfig, "%s::%s System Clock=%d Hz, Core: AB=%f KBps, IB=%f Bps, " \
+           "LLCC: AB=%f Bps, IB=%f Bps, DRAM AB=%f Bps, IB=%f Bps, "\
+           "Rot: Bw=%f Bps, Clock=%d Hz", validate ? "Validate" : "Commit", device_name_,
+           qos_data.clock_hz, qos_data.core_ab_bps / 1000.f, qos_data.core_ib_bps / 1000.f,
+           qos_data.llcc_ab_bps / 1000.f, qos_data.llcc_ib_bps / 1000.f,
+           qos_data.dram_ab_bps / 1000.f, qos_data.dram_ib_bps / 1000.f,
+           qos_data.rot_prefill_bw_bps / 1000.f, qos_data.rot_clock_hz);
 
   // Set refresh rate
   if (vrefresh_) {
@@ -1599,7 +1605,7 @@
 void HWDeviceDRM::SetSrcConfig(const LayerBuffer &input_buffer, const HWRotatorMode &mode,
                                uint32_t *config) {
   // In offline rotation case, rotator will handle deinterlacing.
-  if (mode != kRotatorOffline) {
+  if (mode == kRotatorInline) {
     if (input_buffer.flags.interlace) {
       *config |= (0x01 << UINT32(DRMSrcConfig::DEINTERLACE));
     }
@@ -2122,7 +2128,7 @@
   uint32_t i = 0;
   for (i = 0; i < MAX_CSC_MATRIX_COEFF_SIZE; i++) {
     csc_v1->ctm_coeff[i] = dgm_csc.ctm_coeff[i];
-    DLOGV_IF(kTagDriverConfig, " DGM csc_v1[%d] = %d", i, csc_v1->ctm_coeff[i]);
+    DLOGV_IF(kTagDriverConfig, " DGM csc_v1[%d] = %" PRId64, i, csc_v1->ctm_coeff[i]);
   }
   for (i = 0; i < MAX_CSC_BIAS_SIZE; i++) {
     csc_v1->pre_bias[i] = dgm_csc.pre_bias[i];
@@ -2245,10 +2251,11 @@
   std::vector<LayerRect> &right_frame_roi = hw_layer_info.right_frame_roi;
   DLOGI("HWLayers Stack: layer_count: %d, app_layer_count: %d, gpu_target_index: %d",
          hw_layer_count, hw_layer_info.app_layer_count, hw_layer_info.gpu_target_index);
-  DLOGI("LayerStackFlags = 0x%X,  blend_cs = {primaries = %d, transfer = %d}",
-         stack->flags, stack->blend_cs.primaries, stack->blend_cs.transfer);
+  DLOGI("LayerStackFlags = 0x%" PRIu32 ",  blend_cs = {primaries = %d, transfer = %d}",
+         UINT32(stack->flags.flags), UINT32(stack->blend_cs.primaries),
+         UINT32(stack->blend_cs.transfer));
   for (uint32_t i = 0; i < left_frame_roi.size(); i++) {
-  DLOGI("left_frame_roi: x = %d, y = %d, w = %d, h = %d", INT(left_frame_roi[i].left),
+    DLOGI("left_frame_roi: x = %d, y = %d, w = %d, h = %d", INT(left_frame_roi[i].left),
         INT(left_frame_roi[i].top), INT(left_frame_roi[i].right), INT(left_frame_roi[i].bottom));
   }
   for (uint32_t i = 0; i < right_frame_roi.size(); i++) {
@@ -2275,11 +2282,11 @@
     HWRotatorSession &hw_rotator_session = hw_config.hw_rotator_session;
     HWSessionConfig &hw_session_config = hw_rotator_session.hw_session_config;
     DLOGI("========================= HW_layer: %d =========================", i);
-    DLOGI("src_width = %d, src_height = %d, src_format = %d, src_LayerBufferFlags = 0x%X",
+    DLOGI("src_width = %d, src_height = %d, src_format = %d, src_LayerBufferFlags = 0x%" PRIx32 ,
              hw_layer_info.hw_layers[i].input_buffer.width,
              hw_layer_info.hw_layers[i].input_buffer.height,
              hw_layer_info.hw_layers[i].input_buffer.format,
-             hw_layer_info.hw_layers[i].input_buffer.flags);
+             hw_layer_info.hw_layers[i].input_buffer.flags.flags);
     if (hw_config.use_inline_rot) {
       DLOGI("rotator = %s, rotation = %d, flip_horizontal = %s, flip_vertical = %s",
             "inline rotator", INT(hw_session_config.transform.rotation),
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index c5ab70f..18ac4f4 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_drm.h
@@ -193,9 +193,9 @@
     // Called on display disconnect to clear output buffer map and remove fb_ids.
     void Clear();
     // Create the fd_id for the given buffer.
-    int CreateFbId(LayerBuffer *buffer, uint32_t *fb_id);
+    int CreateFbId(const LayerBuffer &buffer, uint32_t *fb_id);
     // Find handle_id in the layer map. Else create fb_id and add <handle_id,fb_id> in map.
-    void MapBufferToFbId(Layer* layer, LayerBuffer* buffer);
+    void MapBufferToFbId(Layer* layer, const LayerBuffer &buffer);
     // Find handle_id in output buffer map. Else create fb_id and add <handle_id,fb_id> in map.
     void MapOutputBufferToFbId(LayerBuffer* buffer);
     // Find fb_id for given handle_id in the layer map.
diff --git a/sdm/libs/core/drm/hw_events_drm.cpp b/sdm/libs/core/drm/hw_events_drm.cpp
index 56c5799..d3b0129 100644
--- a/sdm/libs/core/drm/hw_events_drm.cpp
+++ b/sdm/libs/core/drm/hw_events_drm.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+* Copyright (c) 2017-2020, 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
@@ -308,8 +308,8 @@
       uint64_t exit_value = 1;
       ssize_t write_size = Sys::write_(poll_fds_[i].fd, &exit_value, sizeof(uint64_t));
       if (write_size != sizeof(uint64_t)) {
-        DLOGW("Error triggering exit fd (%d). write size = %d, error = %s", poll_fds_[i].fd,
-              write_size, strerror(errno));
+        DLOGW("Error triggering exit fd (%d). write size = %zu, error = %s", poll_fds_[i].fd,
+              static_cast<size_t>(write_size), strerror(errno));
       }
       break;
     }
@@ -604,7 +604,7 @@
   }
 
   if (size > kMaxStringLength) {
-    DLOGE("event size %d is greater than event buffer size %zd\n", size, kMaxStringLength);
+    DLOGE("event size %d is greater than event buffer size %d\n", size, kMaxStringLength);
     return;
   }
 
@@ -654,7 +654,7 @@
   }
 
   if (size > kMaxStringLength) {
-    DLOGE("event size %d is greater than event buffer size %zd\n", size, kMaxStringLength);
+    DLOGE("event size %d is greater than event buffer size %d\n", size, kMaxStringLength);
     return;
   }
 
@@ -700,7 +700,7 @@
   }
 
   if (size > kMaxStringLength) {
-    DLOGE("event size %d is greater than event buffer size %zd\n", size, kMaxStringLength);
+    DLOGE("event size %d is greater than event buffer size %d\n", size, kMaxStringLength);
     return;
   }
 
@@ -745,7 +745,7 @@
   }
 
   if (size > kMaxStringLength) {
-    DLOGE("Hardware recovery event size %d is greater than event buffer size %zd\n", size,
+    DLOGE("Hardware recovery event size %d is greater than event buffer size %d\n", size,
           kMaxStringLength);
     return;
   }
@@ -765,7 +765,7 @@
                                    (sizeof(event_resp->base) + sizeof(event_resp->info));
         // expect up to uint32_t from driver
         if (size_of_data > sizeof(uint32_t)) {
-          DLOGE("Size of hardware recovery event data: %" PRIu32 " exceeds %zd", size_of_data,
+          DLOGE("Size of hardware recovery event data: %zu exceeds %zu", size_of_data,
                 sizeof(uint32_t));
           return;
         }
@@ -796,7 +796,7 @@
   std::array<char, expected_size> event_data{'\0'};
   auto size = Sys::pread_(poll_fds_[histogram_index_].fd, event_data.data(), event_data.size(), 0);
   if (size != expected_size) {
-    DLOGE("event size %d is unexpected. skipping this histogram event", size);
+    DLOGE("event size %d is unexpected. skipping this histogram event", UINT32(size));
     return;
   }
 
diff --git a/sdm/libs/core/drm/hw_info_drm.cpp b/sdm/libs/core/drm/hw_info_drm.cpp
index dd6a085..c9d52c0 100644
--- a/sdm/libs/core/drm/hw_info_drm.cpp
+++ b/sdm/libs/core/drm/hw_info_drm.cpp
@@ -110,6 +110,8 @@
   switch (drm_version) {
     case sde_drm::InlineRotationVersion::kInlineRotationV1:
       return InlineRotationVersion::kInlineRotationV1;
+    case sde_drm::InlineRotationVersion::kInlineRotationV2:
+      return InlineRotationVersion::kInlineRotationV2;
     default:
       return kInlineRotationNone;
   }
@@ -242,12 +244,12 @@
   DLOGI("Has UBWC = %d", hw_resource->has_ubwc);
   DLOGI("Has Micro Idle = %d", hw_resource->has_micro_idle);
   DLOGI("Has Concurrent Writeback = %d", hw_resource->has_concurrent_writeback);
-  DLOGI("Has Src Tonemap = %d", hw_resource->src_tone_map);
+  DLOGI("Has Src Tonemap = %lx", hw_resource->src_tone_map.to_ulong());
   DLOGI("Max Low Bw = %" PRIu64 "", hw_resource->dyn_bw_info.total_bw_limit[kBwVFEOn]);
-  DLOGI("Max High Bw = % " PRIu64 "", hw_resource->dyn_bw_info.total_bw_limit[kBwVFEOff]);
+  DLOGI("Max High Bw = %" PRIu64 "", hw_resource->dyn_bw_info.total_bw_limit[kBwVFEOff]);
   DLOGI("Max Pipe Bw = %" PRIu64 " KBps", hw_resource->dyn_bw_info.pipe_bw_limit[kBwVFEOn]);
   DLOGI("Max Pipe Bw High= %" PRIu64 " KBps", hw_resource->dyn_bw_info.pipe_bw_limit[kBwVFEOff]);
-  DLOGI("MaxSDEClock = % " PRIu64 " Hz", hw_resource->max_sde_clk);
+  DLOGI("MaxSDEClock = %d Hz", hw_resource->max_sde_clk);
   DLOGI("Clock Fudge Factor = %f", hw_resource->clk_fudge_factor);
   DLOGI("Prefill factors:");
   DLOGI("\tTiled_NV12 = %d", hw_resource->macrotile_nv12_factor);
@@ -263,7 +265,7 @@
 
   DLOGI("Has Support for multiple bw limits shown below");
   for (int index = 0; index < kBwModeMax; index++) {
-    DLOGI("Mode-index=%d  total_bw_limit=%d and pipe_bw_limit=%d", index,
+    DLOGI("Mode-index=%d  total_bw_limit=%" PRIu64 " and pipe_bw_limit=%" PRIu64, index,
           hw_resource->dyn_bw_info.total_bw_limit[index],
           hw_resource->dyn_bw_info.pipe_bw_limit[index]);
   }
diff --git a/sdm/libs/core/drm/hw_peripheral_drm.cpp b/sdm/libs/core/drm/hw_peripheral_drm.cpp
index b147d2e..623441b 100644
--- a/sdm/libs/core/drm/hw_peripheral_drm.cpp
+++ b/sdm/libs/core/drm/hw_peripheral_drm.cpp
@@ -114,13 +114,13 @@
       if (std::find(bitclk_rates_.begin(), bitclk_rates_.end(), mode_info.bit_clk_rate) ==
             bitclk_rates_.end()) {
         bitclk_rates_.push_back(mode_info.bit_clk_rate);
-        DLOGI("Possible bit_clk_rates %d", mode_info.bit_clk_rate);
+        DLOGI("Possible bit_clk_rates %" PRIu64 , mode_info.bit_clk_rate);
       }
     }
   }
 
   hw_panel_info_.bitclk_rates = bitclk_rates_;
-  DLOGI("bit_clk_rates Size %d", bitclk_rates_.size());
+  DLOGI("bit_clk_rates Size %zu", bitclk_rates_.size());
 }
 
 DisplayError HWPeripheralDRM::SetDynamicDSIClock(uint64_t bit_clk_rate) {
@@ -273,7 +273,7 @@
   uint64_t value = 0;
 
   if (size != sizeof(DppsFeaturePayload)) {
-    DLOGE("invalid payload size %d, expected %d", size, sizeof(DppsFeaturePayload));
+    DLOGE("invalid payload size %zu, expected %zu", size, sizeof(DppsFeaturePayload));
     return kErrorParameters;
   }
 
@@ -287,7 +287,7 @@
       DisplayDppsAd4RoiCfg *params = reinterpret_cast<DisplayDppsAd4RoiCfg *>
                                                       (feature_payload->value);
       if (!params) {
-        DLOGE("invalid playload value %d", feature_payload->value);
+        DLOGE("invalid playload value %" PRIu64, feature_payload->value);
         return kErrorNotSupported;
       }
 
@@ -317,7 +317,7 @@
 
 DisplayError HWPeripheralDRM::GetDppsFeatureInfo(void *payload, size_t size) {
   if (size != sizeof(DRMDppsFeatureInfo)) {
-    DLOGE("invalid payload size %d, expected %d", size, sizeof(DRMDppsFeatureInfo));
+    DLOGE("invalid payload size %zu, expected %zu", size, sizeof(DRMDppsFeatureInfo));
     return kErrorParameters;
   }
   DRMDppsFeatureInfo *feature_info = reinterpret_cast<DRMDppsFeatureInfo *>(payload);
diff --git a/sdm/libs/core/drm/hw_scale_drm.cpp b/sdm/libs/core/drm/hw_scale_drm.cpp
index f553c65..9d6075f 100644
--- a/sdm/libs/core/drm/hw_scale_drm.cpp
+++ b/sdm/libs/core/drm/hw_scale_drm.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016-2020, 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
@@ -161,6 +161,13 @@
     }
   }
 
+#ifdef SDE_DRM_INLINE_PREDOWNSCALE
+  scaler->pre_downscale_x_0 = scale_data.src_x_pre_down_scale_0;
+  scaler->pre_downscale_x_1 = scale_data.src_x_pre_down_scale_1;
+  scaler->pre_downscale_y_0 = scale_data.src_y_pre_down_scale_0;
+  scaler->pre_downscale_y_1 = scale_data.src_y_pre_down_scale_1;
+#endif
+
   return;
 }
 
diff --git a/sdm/libs/core/resource_default.cpp b/sdm/libs/core/resource_default.cpp
index d2db08b..f018dd3 100644
--- a/sdm/libs/core/resource_default.cpp
+++ b/sdm/libs/core/resource_default.cpp
@@ -330,7 +330,7 @@
   HWBlockType hw_block_type = display_resource_ctx->hw_block_type;
   uint64_t frame_count = display_resource_ctx->frame_count;
 
-  DLOGV_IF(kTagResources, "Resource for hw_block = %d, frame_count = %d", hw_block_type,
+  DLOGV_IF(kTagResources, "Resource for hw_block = %d, frame_count = %" PRIu64 , hw_block_type,
            frame_count);
 
   // handoff pipes which are used by splash screen