libhwc2.1: AFBC 32x8 flag changes

Bug: 253121964
Test: G2D scaling for some AFBC 32x8 samples using hwc-tester
Signed-off-by: Yoshita Sharma <yoshita.as@samsung.com>
Signed-off-by: Wiwit Rifa'i <wiwitrifai@google.com>
Change-Id: I74dcc0da916695d07df01ed812ea75525e20b7b5
diff --git a/libacryl/acrylic.cpp b/libacryl/acrylic.cpp
index 0039560..8936d5e 100644
--- a/libacryl/acrylic.cpp
+++ b/libacryl/acrylic.cpp
@@ -106,7 +106,8 @@
         return false;
     }
 
-    if (mCanvas.isCompressed() && !cap.isFeatureSupported(HW2DCapability::FEATURE_AFBC_ENCODE)) {
+    if ((mCanvas.isCompressed() || mCanvas.isCompressedWideblk()) &&
+        !cap.isFeatureSupported(HW2DCapability::FEATURE_AFBC_ENCODE)) {
         ALOGE("AFBC encoding is not supported");
         return false;
     }
@@ -127,7 +128,8 @@
             return false;
         }
 
-        if (layer->isCompressed() && !cap.isFeatureSupported(HW2DCapability::FEATURE_AFBC_DECODE)) {
+        if ((layer->isCompressed() || layer->isCompressedWideblk()) &&
+            !cap.isFeatureSupported(HW2DCapability::FEATURE_AFBC_DECODE)) {
             ALOGE("AFBC decoding is not supported");
             return false;
         }
diff --git a/libacryl/acrylic_g2d.cpp b/libacryl/acrylic_g2d.cpp
index 605e9f1..31dba77 100644
--- a/libacryl/acrylic_g2d.cpp
+++ b/libacryl/acrylic_g2d.cpp
@@ -701,6 +701,13 @@
             cmd[G2DSFR_IMG_COLORMODE] = G2D_FMT_BGR565;
         cmd[G2DSFR_IMG_COLORMODE] |= G2D_DATAFORMAT_AFBC;
         cmd[G2DSFR_IMG_STRIDE] = 0;
+    } else if (layer.isCompressedWideblk()) {
+        if (g2dfmt->g2dfmt == G2D_FMT_RGB565) cmd[G2DSFR_IMG_COLORMODE] = G2D_FMT_BGR565;
+        cmd[G2DSFR_IMG_COLORMODE] |= G2D_DATAFORMAT_AFBC;
+        cmd[G2DSFR_IMG_STRIDE] = 0;
+
+        /*Add AFBC image flags for 32x8 block size*/
+        image.flags |= G2D_LAYERFLAG_AFBC_WIDEBLK;
     } else if (g2dfmt->g2dfmt & G2D_DATAFORMAT_SBWC) {
         cmd[G2DSFR_IMG_STRIDE] = 0;
     } else {
@@ -889,7 +896,7 @@
     cmd[G2DSFR_SRC_DSTRIGHT]  = window.size.hori + window.pos.hori;
     cmd[G2DSFR_SRC_DSTBOTTOM] = window.size.vert + window.pos.vert;
 
-    if (layer.isCompressed()) {
+    if (layer.isCompressed() || layer.isCompressedWideblk()) {
         cmd[G2DSFR_IMG_WIDTH]--;
         cmd[G2DSFR_IMG_HEIGHT]--;
     }
diff --git a/libacryl/acrylic_layer.cpp b/libacryl/acrylic_layer.cpp
index b90d541..a7ce731 100644
--- a/libacryl/acrylic_layer.cpp
+++ b/libacryl/acrylic_layer.cpp
@@ -520,6 +520,7 @@
         attr |= ATTR_PROTECTED;
     if (other.isCompressed())
         attr |= ATTR_COMPRESSED;
+    if (other.isCompressedWideblk()) attr |= ATTR_COMPRESSED_WIDEBLK;
 
     if (other.getBufferType() == MT_DMABUF) {
         int fd[3];
diff --git a/libacryl/include/hardware/exynos/acryl.h b/libacryl/include/hardware/exynos/acryl.h
index 2d87887..1d6e307 100644
--- a/libacryl/include/hardware/exynos/acryl.h
+++ b/libacryl/include/hardware/exynos/acryl.h
@@ -442,13 +442,14 @@
      * - ATTR_SOLIDCOLOR : The image buffer is empty and should be filled with one RGBA value by H/W.
      */
     enum layer_attr_t {
-        ATTR_NONE       = 0,
-        ATTR_PROTECTED  = 1,
+        ATTR_NONE = 0,
+        ATTR_PROTECTED = 1,
         ATTR_COMPRESSED = 2,
-        ATTR_UORDER     = 4,
-        ATTR_OTF        = 8,
+        ATTR_UORDER = 4,
+        ATTR_OTF = 8,
         ATTR_SOLIDCOLOR = 16,
-        ATTR_ALL_MASK   = 0x1F
+        ATTR_COMPRESSED_WIDEBLK = 32,
+        ATTR_ALL_MASK = 0x3F
     };
     /*
      * Describes how the buffer of the image is identified.
@@ -569,6 +570,10 @@
      * Determine if the image in the buffer is or should be in a compressed form.
      */
     bool isCompressed() { return !!(mAttributes & ATTR_COMPRESSED); }
+
+    /*Check if the AFBC 32x8 format size is being used*/
+    bool isCompressedWideblk() { return !!(mAttributes & ATTR_COMPRESSED_WIDEBLK); }
+
     /*
      * Study if the image is or should be written in U-Order for accelerated
      * graphic processing instead of raster-scan order.
diff --git a/libacryl/local_include/uapi/g2d.h b/libacryl/local_include/uapi/g2d.h
index 23df906..c39a491 100644
--- a/libacryl/local_include/uapi/g2d.h
+++ b/libacryl/local_include/uapi/g2d.h
@@ -230,11 +230,12 @@
 };
 
 #define G2D_LAYERFLAG_ACQUIRE_FENCE (1 << 1)
-#define G2D_LAYERFLAG_SECURE        (1 << 2)
-#define G2D_LAYERFLAG_COLORFILL     (1 << 3)
-#define G2D_LAYERFLAG_MFC_STRIDE    (1 << 4)
+#define G2D_LAYERFLAG_SECURE (1 << 2)
+#define G2D_LAYERFLAG_COLORFILL (1 << 3)
+#define G2D_LAYERFLAG_MFC_STRIDE (1 << 4)
+#define G2D_LAYERFLAG_AFBC_WIDEBLK (1 << 5)
 #define G2D_LAYERFLAG_NO_CACHECLEAN (1 << 16)
-#define G2D_LAYERFLAG_NO_CACHEINV   (1 << 17)
+#define G2D_LAYERFLAG_NO_CACHEINV (1 << 17)
 
 struct g2d_layer {
     uint32_t          flags;
diff --git a/libhwc2.1/libresource/ExynosMPP.cpp b/libhwc2.1/libresource/ExynosMPP.cpp
index 6e89a77..0b6b3d4 100644
--- a/libhwc2.1/libresource/ExynosMPP.cpp
+++ b/libhwc2.1/libresource/ExynosMPP.cpp
@@ -1217,7 +1217,15 @@
     srcImgInfo->bufferType = getBufferType(srcHandle);
     if (srcImgInfo->bufferType == MPP_BUFFER_SECURE_DRM)
         attribute |= AcrylicCanvas::ATTR_PROTECTED;
-    if (src.compressionInfo.type != COMP_TYPE_NONE) attribute |= AcrylicCanvas::ATTR_COMPRESSED;
+    /*Change AFBC attribute on the basis of the modifier*/
+    if (src.compressionInfo.type != COMP_TYPE_NONE) {
+        if ((src.compressionInfo.modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK) ==
+            AFBC_FORMAT_MOD_BLOCK_SIZE_32x8) {
+            attribute |= AcrylicCanvas::ATTR_COMPRESSED_WIDEBLK;
+        } else {
+            attribute |= AcrylicCanvas::ATTR_COMPRESSED;
+        }
+    }
 
     srcImgInfo->bufferHandle = srcHandle;
     srcImgInfo->acrylicAcquireFenceFd =