merge in nyc-mr1-release history after reset to nyc-mr1-dev
diff --git a/msm8996/sdm/libs/hwc2/hwc_display.cpp b/msm8996/sdm/libs/hwc2/hwc_display.cpp
index 8bba9ed..90d1403 100644
--- a/msm8996/sdm/libs/hwc2/hwc_display.cpp
+++ b/msm8996/sdm/libs/hwc2/hwc_display.cpp
@@ -781,7 +781,12 @@
   for (const auto& change : layer_changes_) {
     auto hwc_layer = layer_map_[change.first];
     auto composition = change.second;
-    hwc_layer->UpdateClientCompositionType(composition);
+
+    if (hwc_layer == nullptr) {
+      DLOGW("Null layer: %" PRIu64, change.first);
+    } else {
+      hwc_layer->UpdateClientCompositionType(composition);
+    }
   }
   return HWC2::Error::None;
 }
diff --git a/msm8996/sdm/libs/hwc2/hwc_session.cpp b/msm8996/sdm/libs/hwc2/hwc_session.cpp
index 60db660..e4d6cac 100644
--- a/msm8996/sdm/libs/hwc2/hwc_session.cpp
+++ b/msm8996/sdm/libs/hwc2/hwc_session.cpp
@@ -215,7 +215,9 @@
 // HWC2 functions returned in GetFunction
 // Defined in the same order as in the HWC2 header
 
-static int32_t AcceptDisplayChanges(hwc2_device_t *device, hwc2_display_t display) {
+int32_t HWCSession::AcceptDisplayChanges(hwc2_device_t *device,
+                                         hwc2_display_t display) {
+  SCOPE_LOCK(locker_);
   return HWCSession::CallDisplayFunction(device, display, &HWCDisplay::AcceptDisplayChanges);
 }
 
@@ -590,7 +592,7 @@
 
   switch (descriptor) {
     case HWC2::FunctionDescriptor::AcceptDisplayChanges:
-      return AsFP<HWC2_PFN_ACCEPT_DISPLAY_CHANGES>(AcceptDisplayChanges);
+      return AsFP<HWC2_PFN_ACCEPT_DISPLAY_CHANGES>(HWCSession::AcceptDisplayChanges);
     case HWC2::FunctionDescriptor::CreateLayer:
       return AsFP<HWC2_PFN_CREATE_LAYER>(CreateLayer);
     case HWC2::FunctionDescriptor::CreateVirtualDisplay:
diff --git a/msm8996/sdm/libs/hwc2/hwc_session.h b/msm8996/sdm/libs/hwc2/hwc_session.h
index ce3e27f..7ae59ed 100644
--- a/msm8996/sdm/libs/hwc2/hwc_session.h
+++ b/msm8996/sdm/libs/hwc2/hwc_session.h
@@ -82,6 +82,7 @@
 
   // HWC2 Functions that require a concrete implementation in hwc session
   // and hence need to be member functions
+  static int32_t AcceptDisplayChanges(hwc2_device_t *device, hwc2_display_t display);
   static int32_t CreateLayer(hwc2_device_t *device, hwc2_display_t display,
                              hwc2_layer_t *out_layer_id);
   static int32_t CreateVirtualDisplay(hwc2_device_t *device, uint32_t width, uint32_t height,
diff --git a/msmcobalt/libgralloc/alloc_controller.cpp b/msmcobalt/libgralloc/alloc_controller.cpp
index 0ef0a9a..3ecc9fa 100644
--- a/msmcobalt/libgralloc/alloc_controller.cpp
+++ b/msmcobalt/libgralloc/alloc_controller.cpp
@@ -180,6 +180,18 @@
 
 }
 
+void AdrenoMemInfo::getUnalignedWidthAndHeight(const private_handle_t *hnd, int& unaligned_w,
+                                               int& unaligned_h) {
+    MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
+    if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+        unaligned_w = metadata->bufferDim.sliceWidth;
+        unaligned_h = metadata->bufferDim.sliceHeight;
+    } else {
+        unaligned_w = hnd->unaligned_width;
+        unaligned_h = hnd->unaligned_height;
+    }
+}
+
 bool isUncompressedRgbFormat(int format)
 {
     bool is_rgb_format = false;
@@ -709,7 +721,6 @@
     return size;
 }
 
-
 void getBufferAttributes(int width, int height, int format, int usage,
         int& alignedw, int &alignedh, int& tiled, unsigned int& size)
 {
@@ -892,7 +903,7 @@
 
     private_handle_t* hnd = new private_handle_t(data.fd, data.size,
                                                  data.allocType, 0, format,
-                                                 alignedw, alignedh);
+                                                 alignedw, alignedh, -1, 0, 0, w, h);
     hnd->base = (uint64_t) data.base;
     hnd->offset = data.offset;
     hnd->gpuaddr = 0;
@@ -989,7 +1000,8 @@
             aligned_h = VENUS_Y_SCANLINES(COLOR_FMT_NV12_UBWC, height);
             break;
         case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC:
-            aligned_w = VENUS_Y_STRIDE(COLOR_FMT_NV12_BPP10_UBWC, width);
+            // The macro returns the stride which is 4/3 times the width, hence * 3/4
+            aligned_w = (VENUS_Y_STRIDE(COLOR_FMT_NV12_BPP10_UBWC, width) * 3) / 4;
             aligned_h = VENUS_Y_SCANLINES(COLOR_FMT_NV12_BPP10_UBWC, height);
             break;
         default:
diff --git a/msmcobalt/libgralloc/alloc_controller.h b/msmcobalt/libgralloc/alloc_controller.h
index 8216b0c..45977e2 100644
--- a/msmcobalt/libgralloc/alloc_controller.h
+++ b/msmcobalt/libgralloc/alloc_controller.h
@@ -56,7 +56,7 @@
 
     virtual IMemAlloc* getAllocator(int flags) = 0;
 
-    virtual bool isDisableUBWCForEncoder();
+    virtual bool isDisableUBWCForEncoder() = 0;
 
     virtual ~IAllocController() {};
 
diff --git a/msmcobalt/libgralloc/gpu.cpp b/msmcobalt/libgralloc/gpu.cpp
index 5b22e6d..8bae926 100644
--- a/msmcobalt/libgralloc/gpu.cpp
+++ b/msmcobalt/libgralloc/gpu.cpp
@@ -53,6 +53,16 @@
 {
     int err = 0;
     int flags = 0;
+    int alignedw = 0;
+    int alignedh = 0;
+
+    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
+            height,
+            format,
+            usage,
+            alignedw,
+            alignedh);
+
     size = roundUpToPageSize(size);
     alloc_data data;
     data.offset = 0;
@@ -153,8 +163,8 @@
         flags |= data.allocType;
         uint64_t eBaseAddr = (uint64_t)(eData.base) + eData.offset;
         private_handle_t *hnd = new private_handle_t(data.fd, size, flags,
-                bufferType, format, width, height, eData.fd, eData.offset,
-                eBaseAddr);
+                bufferType, format, alignedw, alignedh,
+                eData.fd, eData.offset, eBaseAddr, width, height);
 
         hnd->offset = data.offset;
         hnd->base = (uint64_t)(data.base) + data.offset;
@@ -327,7 +337,7 @@
         err = gralloc_alloc_framebuffer(usage, pHandle);
     } else {
         err = gralloc_alloc_buffer(size, usage, pHandle, bufferType,
-                                   grallocFormat, alignedw, alignedh);
+                                   grallocFormat, w, h);
     }
 
     if (err < 0) {
diff --git a/msmcobalt/libgralloc/gr.h b/msmcobalt/libgralloc/gr.h
index 578240a..7d055fc 100644
--- a/msmcobalt/libgralloc/gr.h
+++ b/msmcobalt/libgralloc/gr.h
@@ -24,6 +24,7 @@
 #include <hardware/gralloc.h>
 #include <pthread.h>
 #include <errno.h>
+#include <unistd.h>
 
 #include <cutils/native_handle.h>
 #include <utils/Singleton.h>
@@ -35,7 +36,7 @@
 struct private_handle_t;
 
 inline unsigned int roundUpToPageSize(unsigned int x) {
-    return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
+    return (x + (getpagesize()-1)) & ~(getpagesize()-1);
 }
 
 template <class Type>
@@ -140,6 +141,15 @@
                             int tileEnabled, int& alignedw, int &alignedh);
 
     /*
+     * Function to compute unaligned width and unaligned height based on
+     * private handle
+     *
+     * @return unaligned width, unaligned height
+     */
+    void getUnalignedWidthAndHeight(const private_handle_t *hnd, int& unaligned_w,
+                            int& unaligned_h);
+
+    /*
      * Function to return whether GPU support MacroTile feature
      *
      * @return >0 : supported
diff --git a/msmcobalt/libgralloc/gralloc_priv.h b/msmcobalt/libgralloc/gralloc_priv.h
index 613c066..4c059cf 100644
--- a/msmcobalt/libgralloc/gralloc_priv.h
+++ b/msmcobalt/libgralloc/gralloc_priv.h
@@ -30,8 +30,8 @@
 
 #include <cutils/log.h>
 
-#define ROUND_UP_PAGESIZE(x) ( (((unsigned long)(x)) + PAGE_SIZE-1)  & \
-                               (~(PAGE_SIZE-1)) )
+#define ROUND_UP_PAGESIZE(x) (unsigned int)( ((x) + getpagesize()-1)  & \
+                                             (~(getpagesize()-1)) )
 
 /* Gralloc usage bits indicating the type of allocation that should be used */
 /* SYSTEM heap comes from kernel vmalloc (ION_SYSTEM_HEAP_ID)
@@ -118,7 +118,6 @@
 #define HAL_PIXEL_FORMAT_BGRX_1010102            0x11C
 #define HAL_PIXEL_FORMAT_XBGR_2101010            0x11D
 #define HAL_PIXEL_FORMAT_YCbCr_420_P010          0x11F
-#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC     0x120
 
 #define HAL_PIXEL_FORMAT_INTERLACE               0x180
 
@@ -131,6 +130,7 @@
 
 // UBWC aligned Venus format
 #define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06
+#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC     0x7FA30C09
 
 //Khronos ASTC formats
 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR             0x93B0
@@ -233,9 +233,11 @@
         // The gpu address mapped into the mmu.
         uint64_t gpuaddr __attribute__((aligned(8)));
         int     format;
-        int     width;
-        int     height;
+        int     width;   // holds aligned width of the actual buffer allocated
+        int     height;  // holds aligned height of the  actual buffer allocated
         uint64_t base_metadata __attribute__((aligned(8)));
+        int unaligned_width;   // holds width client asked to allocate
+        int unaligned_height;  // holds height client asked to allocate
 
 #ifdef __cplusplus
         static const int sNumFds = 2;
@@ -246,18 +248,40 @@
         static const int sMagic = 'gmsm';
 
         private_handle_t(int fd, unsigned int size, int flags, int bufferType,
-                         int format, int width, int height, int eFd = -1,
-                         unsigned int eOffset = 0, uint64_t eBase = 0) :
-            fd(fd), fd_metadata(eFd), magic(sMagic),
+                int format, int width, int height) :
+            fd(fd), fd_metadata(-1), magic(sMagic),
             flags(flags), size(size), offset(0), bufferType(bufferType),
-            base(0), offset_metadata(eOffset), gpuaddr(0),
+            base(0), offset_metadata(0), gpuaddr(0),
             format(format), width(width), height(height),
-            base_metadata(eBase)
+            base_metadata(0), unaligned_width(width),
+            unaligned_height(height)
         {
             version = (int) sizeof(native_handle);
             numInts = sNumInts();
             numFds = sNumFds;
         }
+
+        private_handle_t(int fd, unsigned int size, int flags, int bufferType,
+                int format, int width, int height,
+                int eFd, unsigned int eOffset, uint64_t eBase) :
+            private_handle_t(fd, size, flags, bufferType, format, width, height)
+        {
+            fd_metadata = eFd;
+            offset_metadata = eOffset;
+            base_metadata = eBase;
+        }
+
+        private_handle_t(int fd, unsigned int size, int flags, int bufferType,
+                int format, int width, int height,
+                int eFd, unsigned int eOffset, uint64_t eBase,
+                int unaligned_w, int unaligned_h) :
+            private_handle_t(fd, size, flags, bufferType, format, width, height,
+                    eFd, eOffset, eBase)
+        {
+            unaligned_width = unaligned_w;
+            unaligned_height = unaligned_h;
+        }
+
         ~private_handle_t() {
             magic = 0;
         }
diff --git a/msmcobalt/libgralloc/mapper.cpp b/msmcobalt/libgralloc/mapper.cpp
index 142586b..d8880ef 100644
--- a/msmcobalt/libgralloc/mapper.cpp
+++ b/msmcobalt/libgralloc/mapper.cpp
@@ -309,6 +309,7 @@
                 int width = va_arg(args, int);
                 int height = va_arg(args, int);
                 int format = va_arg(args, int);
+                int alignedw = 0, alignedh = 0;
 
                 native_handle_t** handle = va_arg(args, native_handle_t**);
                 private_handle_t* hnd = (private_handle_t*)native_handle_create(
@@ -321,8 +322,12 @@
                   hnd->offset = offset;
                   hnd->base = uint64_t(base) + offset;
                   hnd->gpuaddr = 0;
-                  hnd->width = width;
-                  hnd->height = height;
+                  AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
+                          height, format, 0, alignedw, alignedh);
+                  hnd->width = alignedw;
+                  hnd->height = alignedh;
+                  hnd->unaligned_width = width;
+                  hnd->unaligned_height = height;
                   hnd->format = format;
                   *handle = (native_handle_t *)hnd;
                   res = 0;
diff --git a/msmcobalt/libgralloc1/gr_allocator.cpp b/msmcobalt/libgralloc1/gr_allocator.cpp
index b45ba83..1a269be 100644
--- a/msmcobalt/libgralloc1/gr_allocator.cpp
+++ b/msmcobalt/libgralloc1/gr_allocator.cpp
@@ -670,6 +670,11 @@
       *aligned_w = VENUS_Y_STRIDE(COLOR_FMT_NV12_UBWC, width);
       *aligned_h = VENUS_Y_SCANLINES(COLOR_FMT_NV12_UBWC, height);
       break;
+    case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC:
+      // The macro returns the stride which is 4/3 times the width, hence * 3/4
+      *aligned_w = (VENUS_Y_STRIDE(COLOR_FMT_NV12_BPP10_UBWC, width) * 3) / 4;
+      *aligned_h = VENUS_Y_SCANLINES(COLOR_FMT_NV12_BPP10_UBWC, height);
+      break;
     default:
       ALOGE("%s: Unsupported pixel format: 0x%x", __FUNCTION__, format);
       *aligned_w = 0;
diff --git a/msmcobalt/libgralloc1/gr_buf_mgr.cpp b/msmcobalt/libgralloc1/gr_buf_mgr.cpp
index 33abd40..9bba82b 100644
--- a/msmcobalt/libgralloc1/gr_buf_mgr.cpp
+++ b/msmcobalt/libgralloc1/gr_buf_mgr.cpp
@@ -361,8 +361,8 @@
   return flags;
 }
 
-int BufferManager::AllocateBuffer(unsigned int size, int aligned_w, int aligned_h, int real_w,
-                                  int real_h, int format, int bufferType,
+int BufferManager::AllocateBuffer(unsigned int size, int aligned_w, int aligned_h, int unaligned_w,
+                                  int unaligned_h, int format, int bufferType,
                                   gralloc1_producer_usage_t prod_usage,
                                   gralloc1_consumer_usage_t cons_usage, buffer_handle_t *handle) {
   int err = 0;
@@ -405,7 +405,7 @@
   uint64_t eBaseAddr = (uint64_t)(e_data.base) + e_data.offset;
   private_handle_t *hnd = new private_handle_t(data.fd, size, flags, bufferType, format, aligned_w,
                                                aligned_h, e_data.fd, e_data.offset, eBaseAddr,
-                                               real_w, real_h, prod_usage, cons_usage);
+                                               unaligned_w, unaligned_h, prod_usage, cons_usage);
 
   hnd->offset = data.offset;
   hnd->base = (uint64_t)(data.base) + data.offset;
@@ -493,6 +493,7 @@
       private_handle_t *hnd = reinterpret_cast<private_handle_t *>(
           native_handle_create(private_handle_t::kNumFds, private_handle_t::NumInts()));
       if (hnd) {
+        unsigned int alignedw = 0, alignedh = 0;
         hnd->magic = private_handle_t::kMagic;
         hnd->fd = fd;
         hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION;
@@ -500,8 +501,12 @@
         hnd->offset = offset;
         hnd->base = uint64_t(base) + offset;
         hnd->gpuaddr = 0;
-        hnd->width = width;
-        hnd->height = height;
+        BufferDescriptor descriptor(width, height, format);
+        allocator_->GetAlignedWidthAndHeight(descriptor, &alignedw, &alignedh);
+        hnd->unaligned_width = width;
+        hnd->unaligned_height = height;
+        hnd->width = alignedw;
+        hnd->height = alignedh;
         hnd->format = format;
         *handle = reinterpret_cast<native_handle_t *>(hnd);
       }
diff --git a/msmcobalt/libgralloc1/gr_buf_mgr.h b/msmcobalt/libgralloc1/gr_buf_mgr.h
index d3c0e67..ed6b591 100644
--- a/msmcobalt/libgralloc1/gr_buf_mgr.h
+++ b/msmcobalt/libgralloc1/gr_buf_mgr.h
@@ -49,9 +49,10 @@
   int GetBufferType(int format);
   int AllocateBuffer(const BufferDescriptor &descriptor, buffer_handle_t *handle,
                      unsigned int bufferSize = 0);
-  int AllocateBuffer(unsigned int size, int aligned_w, int aligned_h, int real_w, int real_h,
-                     int format, int bufferType, gralloc1_producer_usage_t prod_usage,
-                     gralloc1_consumer_usage_t cons_usage, buffer_handle_t *handle);
+  int AllocateBuffer(unsigned int size, int aligned_w, int aligned_h, int unaligned_w,
+                     int unaligned_h, int format, int bufferType,
+                     gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage,
+                     buffer_handle_t *handle);
   int GetDataAlignment(int format, gralloc1_producer_usage_t prod_usage,
                        gralloc1_consumer_usage_t cons_usage);
   int GetHandleFlags(int format, gralloc1_producer_usage_t prod_usage,
diff --git a/msmcobalt/libgralloc1/gr_device_impl.cpp b/msmcobalt/libgralloc1/gr_device_impl.cpp
index 6258941..f837ee2 100644
--- a/msmcobalt/libgralloc1/gr_device_impl.cpp
+++ b/msmcobalt/libgralloc1/gr_device_impl.cpp
@@ -298,8 +298,8 @@
   gralloc1_error_t status = CheckDeviceAndHandle(device, buffer);
   if (status == GRALLOC1_ERROR_NONE) {
     const private_handle_t *hnd = PRIV_HANDLE_CONST(buffer);
-    *outWidth = UINT(hnd->GetRealWidth());
-    *outHeight = UINT(hnd->GetRealHeight());
+    *outWidth = UINT(hnd->GetUnalignedWidth());
+    *outHeight = UINT(hnd->GetUnalignedHeight());
   }
 
   return status;
diff --git a/msmcobalt/libgralloc1/gr_priv_handle.h b/msmcobalt/libgralloc1/gr_priv_handle.h
index 444fc80..ee38b4d 100644
--- a/msmcobalt/libgralloc1/gr_priv_handle.h
+++ b/msmcobalt/libgralloc1/gr_priv_handle.h
@@ -86,8 +86,8 @@
   uint64_t base_metadata __attribute__((aligned(8)));
 
   // added for gralloc1
-  int real_width;   // holds width client asked to allocate
-  int real_height;  // holds height client asked to allocate// holds width client asked to allocate
+  int unaligned_width;   // holds width client asked to allocate
+  int unaligned_height;  // holds height client asked to allocate
   gralloc1_producer_usage_t producer_usage __attribute__((aligned(8)));
   gralloc1_consumer_usage_t consumer_usage __attribute__((aligned(8)));
 
@@ -99,33 +99,50 @@
   }
 
   private_handle_t(int fd, unsigned int size, int flags, int buf_type, int format, int width,
-                   int height, int meta_fd = -1, unsigned int meta_offset = 0,
-                   uint64_t meta_base = 0, int rw = 0, int rh = 0,
-                   gralloc1_producer_usage_t prod_usage = GRALLOC1_PRODUCER_USAGE_NONE,
-                   gralloc1_consumer_usage_t cons_usage = GRALLOC1_CONSUMER_USAGE_NONE)
+                   int height)
       : fd(fd),
-        fd_metadata(meta_fd),
+        fd_metadata(-1),
         magic(kMagic),
         flags(flags),
         size(size),
         offset(0),
         buffer_type(buf_type),
         base(0),
-        offset_metadata(meta_offset),
+        offset_metadata(0),
         gpuaddr(0),
         format(format),
         width(width),
         height(height),
-        base_metadata(meta_base),
-        real_width(rw),
-        real_height(rh),
-        producer_usage(prod_usage),
-        consumer_usage(cons_usage) {
+        base_metadata(0),
+        unaligned_width(width),
+        unaligned_height(height),
+        producer_usage(GRALLOC1_PRODUCER_USAGE_NONE),
+        consumer_usage(GRALLOC1_CONSUMER_USAGE_NONE) {
     version = static_cast<int>(sizeof(native_handle));
     numInts = NumInts();
     numFds = kNumFds;
   }
 
+  private_handle_t(int fd, unsigned int size, int flags, int buf_type, int format, int width,
+                   int height, int meta_fd, unsigned int meta_offset, uint64_t meta_base)
+      : private_handle_t(fd, size, flags, buf_type, format, width, height) {
+    fd_metadata = meta_fd;
+    offset_metadata = meta_offset;
+    base_metadata = meta_base;
+  }
+
+  private_handle_t(int fd, unsigned int size, int flags, int buf_type, int format, int width,
+                   int height, int meta_fd, unsigned int meta_offset, uint64_t meta_base,
+                   int unaligned_w , int unaligned_h,
+                   gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage)
+      : private_handle_t(fd, size, flags, buf_type, format, width, height, meta_fd, meta_offset
+                         meta_base) {
+    unaligned_width = unaligned_w;
+    unaligned_height = unaligned_h;
+    producer_usage = prod_usage;
+    consumer_usage = cons_usage;
+  }
+
   ~private_handle_t() {
     magic = 0;
     ALOGE_IF(DBG_HANDLE, "deleting buffer handle %p", this);
@@ -151,9 +168,9 @@
     return 0;
   }
 
-  int GetRealWidth() const { return real_width; }
+  int GetUnalignedWidth() const { return unaligned_width; }
 
-  int GetRealHeight() const { return real_height; }
+  int GetUnalignedHeight() const { return unaligned_height; }
 
   int GetColorFormat() const { return format; }
 
diff --git a/msmcobalt/libgralloc1/gralloc_priv.h b/msmcobalt/libgralloc1/gralloc_priv.h
index 64cb1f5..f282070 100644
--- a/msmcobalt/libgralloc1/gralloc_priv.h
+++ b/msmcobalt/libgralloc1/gralloc_priv.h
@@ -20,9 +20,13 @@
 #ifndef __GRALLOC_PRIV_H__
 #define __GRALLOC_PRIV_H__
 
+#include <unistd.h>
 #include "gr_priv_handle.h"
 
-#define ROUND_UP_PAGESIZE(x) ((((unsigned int)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1)))
+#define ROUND_UP_PAGESIZE(x) roundUpToPageSize(x)
+inline unsigned int roundUpToPageSize(unsigned int x) {
+    return (x + (getpagesize()-1)) & ~(getpagesize()-1);
+}
 
 /* Gralloc usage bits indicating the type of allocation that should be used */
 /* Refer gralloc1_producer_usage_t & gralloc1_consumer_usage-t in gralloc1.h */
@@ -107,7 +111,6 @@
 #define HAL_PIXEL_FORMAT_BGRX_1010102 0x11C
 #define HAL_PIXEL_FORMAT_XBGR_2101010 0x11D
 #define HAL_PIXEL_FORMAT_YCbCr_420_P010 0x11F
-#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC 0x120
 
 #define HAL_PIXEL_FORMAT_INTERLACE 0x180
 
@@ -120,6 +123,7 @@
 
 // UBWC aligned Venus format
 #define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06
+#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC     0x7FA30C09
 
 // Khronos ASTC formats
 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
diff --git a/msmcobalt/sdm/include/core/buffer_allocator.h b/msmcobalt/sdm/include/core/buffer_allocator.h
index 0fd9388..1b47f79 100644
--- a/msmcobalt/sdm/include/core/buffer_allocator.h
+++ b/msmcobalt/sdm/include/core/buffer_allocator.h
@@ -61,7 +61,9 @@
 */
 struct AllocatedBufferInfo {
   int fd = -1;                   //!< Specifies the fd of the allocated buffer.
-  uint32_t stride = 0;           //!< Specifies aligned buffer width of the allocated buffer.
+  uint32_t stride = 0;           //!< Specifies allocated buffer stride in bytes.
+  uint32_t aligned_width = 0;    //!< Specifies aligned allocated buffer width in pixels.
+  uint32_t aligned_height = 0;   //!< Specifies aligned allocated buffer height in pixels.
   uint32_t size = 0;             //!< Specifies the size of the allocated buffer.
 };
 
diff --git a/msmcobalt/sdm/include/core/layer_buffer.h b/msmcobalt/sdm/include/core/layer_buffer.h
index 0bf1aa4..55318eb 100644
--- a/msmcobalt/sdm/include/core/layer_buffer.h
+++ b/msmcobalt/sdm/include/core/layer_buffer.h
@@ -222,8 +222,12 @@
   @sa LayerStack
 */
 struct LayerBuffer {
-  uint32_t width = 0;           //!< Actual width of the Layer that this buffer is for.
-  uint32_t height = 0;          //!< Actual height of the Layer that this buffer is for.
+  uint32_t width = 0;           //!< Aligned width of the Layer that this buffer is for.
+  uint32_t height = 0;          //!< Aligned height of the Layer that this buffer is for.
+  uint32_t unaligned_width = 0;
+                                //!< Unaligned width of the Layer that this buffer is for.
+  uint32_t unaligned_height = 0;
+                                //!< Unaligned height of the Layer that this buffer is for.
   uint32_t size = 0;            //!< Size of a single buffer (even if multiple clubbed together)
   LayerBufferFormat format = kFormatRGBA8888;     //!< Format of the buffer content.
   LayerCSC csc = kCSCFullRange601;                //!< Color Space of the layer.
diff --git a/msmcobalt/sdm/include/utils/rect.h b/msmcobalt/sdm/include/utils/rect.h
index d084556..6d3d482 100644
--- a/msmcobalt/sdm/include/utils/rect.h
+++ b/msmcobalt/sdm/include/utils/rect.h
@@ -55,8 +55,8 @@
                       bool flip_horizontal, LayerRect *out_rects);
   void SplitTopBottom(const LayerRect &in_rect, uint32_t split_count, uint32_t align_y,
                       bool flip_horizontal, LayerRect *out_rects);
-  void ScaleRect(const LayerRect &src_domain, const LayerRect &dst_domain, const LayerRect &in_rect,
-                 LayerRect *out_rect);
+  void MapRect(const LayerRect &src_domain, const LayerRect &dst_domain, const LayerRect &in_rect,
+               LayerRect *out_rect);
   RectOrientation GetOrientation(const LayerRect &in_rect);
 }  // namespace sdm
 
diff --git a/msmcobalt/sdm/include/utils/sys.h b/msmcobalt/sdm/include/utils/sys.h
index b90007a..6b40df4 100644
--- a/msmcobalt/sdm/include/utils/sys.h
+++ b/msmcobalt/sdm/include/utils/sys.h
@@ -54,6 +54,7 @@
 #else
   typedef int (*ioctl)(int, int, ...);
 #endif
+  typedef int (*access)(const char *, int);
   typedef int (*open)(const char *, int, ...);
   typedef int (*close)(int);
   typedef int (*poll)(struct pollfd *, nfds_t, int);
@@ -68,6 +69,7 @@
   static bool getline_(fstream &fs, std::string &line);  // NOLINT
 
   static ioctl ioctl_;
+  static access access_;
   static open open_;
   static close close_;
   static poll poll_;
diff --git a/msmcobalt/sdm/libs/core/display_base.cpp b/msmcobalt/sdm/libs/core/display_base.cpp
index bd2d7d3..050167c 100644
--- a/msmcobalt/sdm/libs/core/display_base.cpp
+++ b/msmcobalt/sdm/libs/core/display_base.cpp
@@ -188,7 +188,7 @@
   LayerRect dst_domain = (LayerRect){0.0f, 0.0f, layer_mixer_width, layer_mixer_height};
   LayerRect out_rect = gpu_target_layer->dst_rect;
 
-  ScaleRect(src_domain, dst_domain, gpu_target_layer->dst_rect, &out_rect);
+  MapRect(src_domain, dst_domain, gpu_target_layer->dst_rect, &out_rect);
 
   auto gpu_target_layer_dst_xpixels = out_rect.right - out_rect.left;
   auto gpu_target_layer_dst_ypixels = out_rect.bottom - out_rect.top;
diff --git a/msmcobalt/sdm/libs/core/fb/hw_device.cpp b/msmcobalt/sdm/libs/core/fb/hw_device.cpp
index ca43dd2..27168bb 100644
--- a/msmcobalt/sdm/libs/core/fb/hw_device.cpp
+++ b/msmcobalt/sdm/libs/core/fb/hw_device.cpp
@@ -107,12 +107,28 @@
 }
 
 DisplayError HWDevice::Init() {
-  char device_name[64] = {0};
-
   // Read the fb node index
   fb_node_index_ = GetFBNodeIndex(device_type_);
   if (fb_node_index_ == -1) {
-    DLOGE("%s should be present", device_name_);
+    DLOGE("device type = %d should be present", device_type_);
+    return kErrorHardware;
+  }
+
+  const char *dev_name = NULL;
+  vector<string> dev_paths = {"/dev/graphics/fb", "/dev/fb"};
+  for (size_t i = 0; i < dev_paths.size(); i++) {
+    dev_paths[i] += to_string(fb_node_index_);
+    if (Sys::access_(dev_paths[i].c_str(), F_OK) >= 0) {
+      dev_name = dev_paths[i].c_str();
+      DLOGI("access(%s) successful", dev_name);
+      break;
+    }
+
+    DLOGI("access(%s), errno = %d, error = %s", dev_paths[i].c_str(), errno, strerror(errno));
+  }
+
+  if (!dev_name) {
+    DLOGE("access() failed for all possible paths");
     return kErrorHardware;
   }
 
@@ -122,10 +138,9 @@
   hw_resource_ = HWResourceInfo();
   hw_info_intf_->GetHWResourceInfo(&hw_resource_);
 
-  snprintf(device_name, sizeof(device_name), "%s%d", "/dev/graphics/fb", fb_node_index_);
-  device_fd_ = Sys::open_(device_name, O_RDWR);
+  device_fd_ = Sys::open_(dev_name, O_RDWR);
   if (device_fd_ < 0) {
-    DLOGE("open %s failed err = %d errstr = %s", device_name, errno,  strerror(errno));
+    DLOGE("open %s failed errno = %d, error = %s", dev_name, errno, strerror(errno));
     return kErrorResources;
   }
 
diff --git a/msmcobalt/sdm/libs/hwc/blit_engine_c2d.cpp b/msmcobalt/sdm/libs/hwc/blit_engine_c2d.cpp
index 3ead9b7..e5cf81c 100644
--- a/msmcobalt/sdm/libs/hwc/blit_engine_c2d.cpp
+++ b/msmcobalt/sdm/libs/hwc/blit_engine_c2d.cpp
@@ -282,8 +282,8 @@
   num_blit_target_ = layer_count - blit_target_start_index_;
 
   LayerBuffer *layer_buffer = layer_stack->layers.at(gpu_target_index)->input_buffer;
-  int fbwidth = INT(layer_buffer->width);
-  int fbheight = INT(layer_buffer->height);
+  int fbwidth = INT(layer_buffer->unaligned_width);
+  int fbheight = INT(layer_buffer->unaligned_height);
   if ((fbwidth < 0) || (fbheight < 0)) {
     return -1;
   }
@@ -294,10 +294,16 @@
   for (uint32_t j = 0; j < num_blit_target_; j++, k++) {
     Layer *layer = layer_stack->layers.at(k);
     LayerBuffer *layer_buffer = layer->input_buffer;
+    int aligned_w = 0;
+    int aligned_h = 0;
 
     // Set the buffer height and width
-    layer_buffer->width = fbwidth;
-    layer_buffer->height = fbheight/3;
+    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(fbwidth, fbheight/3,
+                   INT(HAL_PIXEL_FORMAT_RGBA_8888), 0, aligned_w, aligned_h);
+    layer_buffer->width = aligned_w;
+    layer_buffer->height = aligned_h;
+    layer_buffer->unaligned_width = fbwidth;
+    layer_buffer->unaligned_height = fbheight/3;
 
     layer->plane_alpha = 0xFF;
     layer->blending = kBlendingOpaque;
@@ -313,6 +319,8 @@
   uint32_t num_app_layers = (uint32_t) content_list->numHwLayers-1;
   int target_width = 0;
   int target_height = 0;
+  int target_aligned_width = 0;
+  int target_aligned_height = 0;
   uint32_t processed_blit = 0;
   LayerRect dst_rects[kMaxBlitTargetLayers];
   bool blit_needed = false;
@@ -334,19 +342,24 @@
     LayerRect &blit_src_rect = blit_layer->src_rect;
     int width = INT(layer->dst_rect.right - layer->dst_rect.left);
     int height = INT(layer->dst_rect.bottom - layer->dst_rect.top);
+    int aligned_w = 0;
+    int aligned_h = 0;
     usage = GRALLOC_USAGE_PRIVATE_IOMMU_HEAP | GRALLOC_USAGE_HW_TEXTURE;
     if (blit_engine_c2d_->get(blit_engine_c2d_, COPYBIT_UBWC_SUPPORT) > 0) {
       usage |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
     }
     // TODO(user): FrameBuffer is assumed to be RGBA
-    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width, height,
-                                 INT(HAL_PIXEL_FORMAT_RGBA_8888), usage, width, height);
-
     target_width = std::max(target_width, width);
     target_height += height;
 
+    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width, height,
+                                 INT(HAL_PIXEL_FORMAT_RGBA_8888), usage, aligned_w, aligned_h);
+
+    target_aligned_width = std::max(target_aligned_width, aligned_w);
+    target_aligned_height += aligned_h;
+
     // Left will be zero always
-    dst_rects[processed_blit].top = FLOAT(target_height - height);
+    dst_rects[processed_blit].top = FLOAT(target_aligned_height - aligned_h);
     dst_rects[processed_blit].right = dst_rects[processed_blit].left +
                                       (layer->dst_rect.right - layer->dst_rect.left);
     dst_rects[processed_blit].bottom = (dst_rects[processed_blit].top +
@@ -367,8 +380,10 @@
       Layer *layer = layer_stack->layers.at(j + content_list->numHwLayers);
       private_handle_t *target_buffer = blit_target_buffer_[current_blit_target_index_];
       // Set the fd information
-        layer->input_buffer->width = target_width;
-        layer->input_buffer->height = target_height;
+        layer->input_buffer->width = target_aligned_width;
+        layer->input_buffer->height = target_aligned_height;
+        layer->input_buffer->unaligned_width = target_width;
+        layer->input_buffer->unaligned_height = target_height;
       if (target_buffer->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED) {
           layer->input_buffer->format = kFormatRGBA8888Ubwc;
       }
diff --git a/msmcobalt/sdm/libs/hwc/hwc_buffer_allocator.cpp b/msmcobalt/sdm/libs/hwc/hwc_buffer_allocator.cpp
index 0092402..7873627 100644
--- a/msmcobalt/sdm/libs/hwc/hwc_buffer_allocator.cpp
+++ b/msmcobalt/sdm/libs/hwc/hwc_buffer_allocator.cpp
@@ -103,7 +103,10 @@
   }
 
   alloc_buffer_info->fd = data.fd;
+  // TODO(user): define stride for all planes and fix stride in bytes
   alloc_buffer_info->stride = UINT32(aligned_width);
+  alloc_buffer_info->aligned_width = UINT32(aligned_width);
+  alloc_buffer_info->aligned_height = UINT32(aligned_height);
   alloc_buffer_info->size = buffer_size;
 
   meta_buffer_info->base_addr = data.base;
@@ -138,6 +141,8 @@
 
     alloc_buffer_info->fd = -1;
     alloc_buffer_info->stride = 0;
+    alloc_buffer_info->aligned_width = 0;
+    alloc_buffer_info->aligned_height = 0;
     alloc_buffer_info->size = 0;
 
     meta_buffer_info->base_addr = NULL;
diff --git a/msmcobalt/sdm/libs/hwc/hwc_display.cpp b/msmcobalt/sdm/libs/hwc/hwc_display.cpp
index b40884e..3dafeb6 100644
--- a/msmcobalt/sdm/libs/hwc/hwc_display.cpp
+++ b/msmcobalt/sdm/libs/hwc/hwc_display.cpp
@@ -346,8 +346,18 @@
 
   if (pvt_handle) {
     layer_buffer->format = GetSDMFormat(pvt_handle->format, pvt_handle->flags);
-    layer_buffer->width = UINT32(pvt_handle->width);
-    layer_buffer->height = UINT32(pvt_handle->height);
+    int aligned_width, aligned_height;
+    int unaligned_width, unaligned_height;
+
+    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(pvt_handle, aligned_width,
+                                                          aligned_height);
+    AdrenoMemInfo::getInstance().getUnalignedWidthAndHeight(pvt_handle, unaligned_width,
+                                                            unaligned_height);
+
+    layer_buffer->width = UINT32(aligned_width);
+    layer_buffer->height = UINT32(aligned_height);
+    layer_buffer->unaligned_width = UINT32(unaligned_width);
+    layer_buffer->unaligned_height = UINT32(unaligned_height);
 
     if (SetMetaData(pvt_handle, layer) != kErrorNone) {
       return -EINVAL;
@@ -398,6 +408,8 @@
                                                             usage, aligned_width, aligned_height);
       layer_buffer->width = UINT32(aligned_width);
       layer_buffer->height = UINT32(aligned_height);
+      layer_buffer->unaligned_width = x_pixels;
+      layer_buffer->unaligned_height = y_pixels;
       layer_buffer->format = GetSDMFormat(format, flags);
     }
   }
@@ -522,6 +534,8 @@
       LayerBuffer *input_buffer = layer->input_buffer;
       input_buffer->width = UINT32(layer->dst_rect.right - layer->dst_rect.left);
       input_buffer->height = UINT32(layer->dst_rect.bottom - layer->dst_rect.top);
+      input_buffer->unaligned_width = input_buffer->width;
+      input_buffer->unaligned_height = input_buffer->height;
       layer->src_rect.left = 0;
       layer->src_rect.top = 0;
       layer->src_rect.right = input_buffer->width;
@@ -1245,14 +1259,6 @@
     layer_buffer->format = GetSDMFormat(INT32(meta_data->linearFormat), 0);
   }
 
-  if (meta_data->operation & UPDATE_BUFFER_GEOMETRY) {
-    int actual_width = pvt_handle->width;
-    int actual_height = pvt_handle->height;
-    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(pvt_handle, actual_width, actual_height);
-    layer_buffer->width = UINT32(actual_width);
-    layer_buffer->height = UINT32(actual_height);
-  }
-
   if (meta_data->operation & SET_SINGLE_BUFFER_MODE) {
     layer->flags.single_buffer = meta_data->isSingleBufferMode;
     // Graphics can set this operation on all types of layers including FB and set the actual value
diff --git a/msmcobalt/sdm/libs/hwc/hwc_display_primary.cpp b/msmcobalt/sdm/libs/hwc/hwc_display_primary.cpp
index 50805d4..bf2d384 100644
--- a/msmcobalt/sdm/libs/hwc/hwc_display_primary.cpp
+++ b/msmcobalt/sdm/libs/hwc/hwc_display_primary.cpp
@@ -34,6 +34,7 @@
 #include <stdarg.h>
 #include <sys/mman.h>
 
+#include <gr.h>
 #include "hwc_display_primary.h"
 #include "hwc_debugger.h"
 
@@ -353,11 +354,16 @@
 }
 
 static void SetLayerBuffer(const BufferInfo& output_buffer_info, LayerBuffer *output_buffer) {
-  output_buffer->width = output_buffer_info.buffer_config.width;
-  output_buffer->height = output_buffer_info.buffer_config.height;
-  output_buffer->format = output_buffer_info.buffer_config.format;
-  output_buffer->planes[0].fd = output_buffer_info.alloc_buffer_info.fd;
-  output_buffer->planes[0].stride = output_buffer_info.alloc_buffer_info.stride;
+  const BufferConfig& buffer_config = output_buffer_info.buffer_config;
+  const AllocatedBufferInfo &alloc_buffer_info = output_buffer_info.alloc_buffer_info;
+
+  output_buffer->width = alloc_buffer_info.aligned_width;
+  output_buffer->height = alloc_buffer_info.aligned_height;
+  output_buffer->unaligned_width = buffer_config.width;
+  output_buffer->unaligned_height = buffer_config.height;
+  output_buffer->format = buffer_config.format;
+  output_buffer->planes[0].fd = alloc_buffer_info.fd;
+  output_buffer->planes[0].stride = alloc_buffer_info.stride;
 }
 
 void HWCDisplayPrimary::HandleFrameOutput() {
diff --git a/msmcobalt/sdm/libs/hwc/hwc_display_virtual.cpp b/msmcobalt/sdm/libs/hwc/hwc_display_virtual.cpp
index 25cd6fc..a4d343b 100644
--- a/msmcobalt/sdm/libs/hwc/hwc_display_virtual.cpp
+++ b/msmcobalt/sdm/libs/hwc/hwc_display_virtual.cpp
@@ -277,12 +277,18 @@
       return -EINVAL;
     }
 
-    int output_buffer_width, output_buffer_height;
-    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(output_handle, output_buffer_width,
-                                                          output_buffer_height);
+    int aligned_width, aligned_height;
+    int unaligned_width, unaligned_height;
 
-    output_buffer_->width = UINT32(output_buffer_width);
-    output_buffer_->height = UINT32(output_buffer_height);
+    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(output_handle, aligned_width,
+                                                          aligned_height);
+    AdrenoMemInfo::getInstance().getUnalignedWidthAndHeight(output_handle, unaligned_width,
+                                                            unaligned_height);
+
+    output_buffer_->width = UINT32(aligned_width);
+    output_buffer_->height = UINT32(aligned_height);
+    output_buffer_->unaligned_width = UINT32(unaligned_width);
+    output_buffer_->unaligned_height = UINT32(unaligned_height);
     output_buffer_->flags.secure = 0;
     output_buffer_->flags.video = 0;
 
diff --git a/msmcobalt/sdm/libs/hwc2/hwc_display.cpp b/msmcobalt/sdm/libs/hwc2/hwc_display.cpp
index 772d2c7..e5e1732 100644
--- a/msmcobalt/sdm/libs/hwc2/hwc_display.cpp
+++ b/msmcobalt/sdm/libs/hwc2/hwc_display.cpp
@@ -781,7 +781,12 @@
   for (const auto& change : layer_changes_) {
     auto hwc_layer = layer_map_[change.first];
     auto composition = change.second;
-    hwc_layer->UpdateClientCompositionType(composition);
+
+    if (hwc_layer == nullptr) {
+      DLOGI("Null layer in HWCDisplay::AcceptDisplayChanges.");
+    } else {
+      hwc_layer->UpdateClientCompositionType(composition);
+    }
   }
   return HWC2::Error::None;
 }
@@ -1318,6 +1323,8 @@
   client_target_layer->input_buffer->format = GetSDMFormat(format, flags);
   client_target_layer->input_buffer->width = UINT32(aligned_width);
   client_target_layer->input_buffer->height = UINT32(aligned_height);
+  client_target_layer->input_buffer->unaligned_width = x_pixels;
+  client_target_layer->input_buffer->unaligned_height = y_pixels;
   client_target_layer->plane_alpha = 255;
 
   DLOGI("New framebuffer resolution (%dx%d)", fb_config.x_pixels, fb_config.y_pixels);
@@ -1472,6 +1479,8 @@
     LayerBuffer *layer_buffer = solid_fill_layer_->input_buffer;
     layer_buffer->width = primary_width;
     layer_buffer->height = primary_height;
+    layer_buffer->unaligned_width = primary_width;
+    layer_buffer->unaligned_height = primary_height;
     layer_buffer->acquire_fence_fd = -1;
     layer_buffer->release_fence_fd = -1;
 
diff --git a/msmcobalt/sdm/libs/hwc2/hwc_display_primary.cpp b/msmcobalt/sdm/libs/hwc2/hwc_display_primary.cpp
index 198eddb..a99a8b1 100644
--- a/msmcobalt/sdm/libs/hwc2/hwc_display_primary.cpp
+++ b/msmcobalt/sdm/libs/hwc2/hwc_display_primary.cpp
@@ -403,11 +403,16 @@
 }
 
 static void SetLayerBuffer(const BufferInfo &output_buffer_info, LayerBuffer *output_buffer) {
-  output_buffer->width = output_buffer_info.buffer_config.width;
-  output_buffer->height = output_buffer_info.buffer_config.height;
-  output_buffer->format = output_buffer_info.buffer_config.format;
-  output_buffer->planes[0].fd = output_buffer_info.alloc_buffer_info.fd;
-  output_buffer->planes[0].stride = output_buffer_info.alloc_buffer_info.stride;
+  const BufferConfig& buffer_config = output_buffer_info.buffer_config;
+  const AllocatedBufferInfo &alloc_buffer_info = output_buffer_info.alloc_buffer_info;
+
+  output_buffer->width = alloc_buffer_info.aligned_width;
+  output_buffer->height = alloc_buffer_info.aligned_height;
+  output_buffer->unaligned_width = buffer_config.width;
+  output_buffer->unaligned_height = buffer_config.height;
+  output_buffer->format = buffer_config.format;
+  output_buffer->planes[0].fd = alloc_buffer_info.fd;
+  output_buffer->planes[0].stride = alloc_buffer_info.stride;
 }
 
 void HWCDisplayPrimary::HandleFrameOutput() {
diff --git a/msmcobalt/sdm/libs/hwc2/hwc_display_virtual.cpp b/msmcobalt/sdm/libs/hwc2/hwc_display_virtual.cpp
index 787640c..5436faa 100644
--- a/msmcobalt/sdm/libs/hwc2/hwc_display_virtual.cpp
+++ b/msmcobalt/sdm/libs/hwc2/hwc_display_virtual.cpp
@@ -188,12 +188,18 @@
       return HWC2::Error::BadParameter;
     }
 
-    int output_buffer_width, output_buffer_height;
-    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(output_handle, output_buffer_width,
-                                                          output_buffer_height);
+    int aligned_width, aligned_height;
+    int unaligned_width, unaligned_height;
 
-    output_buffer_->width = UINT32(output_buffer_width);
-    output_buffer_->height = UINT32(output_buffer_height);
+    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(output_handle, aligned_width,
+                                                          aligned_height);
+    AdrenoMemInfo::getInstance().getUnalignedWidthAndHeight(output_handle, unaligned_width,
+                                                            unaligned_height);
+
+    output_buffer_->width = UINT32(aligned_width);
+    output_buffer_->height = UINT32(aligned_height);
+    output_buffer_->unaligned_width = UINT32(unaligned_width);
+    output_buffer_->unaligned_height = UINT32(unaligned_height);
     // TODO(mkavm): Handle DRC and metadata changes
     output_buffer_->flags.secure = 0;
     output_buffer_->flags.video = 0;
diff --git a/msmcobalt/sdm/libs/hwc2/hwc_layers.cpp b/msmcobalt/sdm/libs/hwc2/hwc_layers.cpp
index a18cb4a..588ee8c 100644
--- a/msmcobalt/sdm/libs/hwc2/hwc_layers.cpp
+++ b/msmcobalt/sdm/libs/hwc2/hwc_layers.cpp
@@ -75,8 +75,18 @@
   }
 
   LayerBuffer *layer_buffer = layer_->input_buffer;
-  layer_buffer->width = UINT32(handle->width);
-  layer_buffer->height = UINT32(handle->height);
+  int aligned_width, aligned_height;
+  int unaligned_width, unaligned_height;
+
+  AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(handle, aligned_width, aligned_height);
+  AdrenoMemInfo::getInstance().getUnalignedWidthAndHeight(handle, unaligned_width,
+                                                          unaligned_height);
+
+  layer_buffer->width = UINT32(aligned_width);
+  layer_buffer->height = UINT32(aligned_height);
+  layer_buffer->unaligned_width = UINT32(unaligned_width);
+  layer_buffer->unaligned_height = UINT32(unaligned_height);
+
   layer_buffer->format = GetSDMFormat(handle->format, handle->flags);
   if (SetMetaData(handle, layer_) != kErrorNone) {
     return HWC2::Error::BadLayer;
@@ -456,14 +466,6 @@
     layer_buffer->format = GetSDMFormat(INT32(meta_data->linearFormat), 0);
   }
 
-  if (meta_data->operation & UPDATE_BUFFER_GEOMETRY) {
-    int actual_width = pvt_handle->width;
-    int actual_height = pvt_handle->height;
-    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(pvt_handle, actual_width, actual_height);
-    layer_buffer->width = UINT32(actual_width);
-    layer_buffer->height = UINT32(actual_height);
-  }
-
   if (meta_data->operation & S3D_FORMAT) {
     layer_buffer->s3d_format = GetS3DFormat(meta_data->s3dFormat);
   }
diff --git a/msmcobalt/sdm/libs/utils/rect.cpp b/msmcobalt/sdm/libs/utils/rect.cpp
index 3213b62..e1180e3 100644
--- a/msmcobalt/sdm/libs/utils/rect.cpp
+++ b/msmcobalt/sdm/libs/utils/rect.cpp
@@ -199,8 +199,8 @@
   }
 }
 
-void ScaleRect(const LayerRect &src_domain, const LayerRect &dst_domain, const LayerRect &in_rect,
-               LayerRect *out_rect) {
+void MapRect(const LayerRect &src_domain, const LayerRect &dst_domain, const LayerRect &in_rect,
+             LayerRect *out_rect) {
   if (!IsValid(src_domain) || !IsValid(dst_domain) || !IsValid(in_rect)) {
     return;
   }
@@ -213,10 +213,10 @@
   float width_ratio = dst_domain_width / src_domain_width;
   float height_ratio = dst_domain_height / src_domain_height;
 
-  out_rect->left = width_ratio * in_rect.left;
-  out_rect->top = height_ratio * in_rect.top;
-  out_rect->right = width_ratio * in_rect.right;
-  out_rect->bottom = height_ratio * in_rect.bottom;
+  out_rect->left = dst_domain.left + (width_ratio * in_rect.left);
+  out_rect->top = dst_domain.top + (height_ratio * in_rect.top);
+  out_rect->right = dst_domain.left + (width_ratio * in_rect.right);
+  out_rect->bottom = dst_domain.top + (height_ratio * in_rect.bottom);
 }
 
 RectOrientation GetOrientation(const LayerRect &in_rect) {
diff --git a/msmcobalt/sdm/libs/utils/sys.cpp b/msmcobalt/sdm/libs/utils/sys.cpp
index 0d1ab0e..f5e0f29 100644
--- a/msmcobalt/sdm/libs/utils/sys.cpp
+++ b/msmcobalt/sdm/libs/utils/sys.cpp
@@ -45,6 +45,7 @@
 
 // Pointer to actual driver interfaces.
 Sys::ioctl Sys::ioctl_ = ::ioctl;
+Sys::access Sys::access_ = ::access;
 Sys::open Sys::open_ = ::open;
 Sys::close Sys::close_ = ::close;
 Sys::poll Sys::poll_ = ::poll;