gralloc/qdutils: Remove unused gralloc code, add driver type check

Remove unused code related to macro tiling from galloc and qdutils.
Add API to check for driver type and query caps based on driver.

Change-Id: I36cfa5529395c69deb886080be1c904ff5c9ad15
CRs-fixed: 1109207
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 583767a..7190fc0 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 - 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011 - 2017, 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
@@ -107,7 +107,6 @@
 
 //------------- MDPCapabilityInfo-----------------------//
 MDPCapabilityInfo :: MDPCapabilityInfo() {
-  qdutils::querySDEInfo(HAS_MACRO_TILE, &isMacroTileSupported);
   qdutils::querySDEInfo(HAS_UBWC, &isUBwcSupported);
   qdutils::querySDEInfo(HAS_WB_UBWC, &isWBUBWCSupported);
 }
@@ -117,7 +116,6 @@
 {
     LINK_adreno_compute_aligned_width_and_height = NULL;
     LINK_adreno_compute_padding = NULL;
-    LINK_adreno_isMacroTilingSupportedByGpu = NULL;
     LINK_adreno_compute_compressedfmt_aligned_width_and_height = NULL;
     LINK_adreno_isUBWCSupportedByGpu = NULL;
     LINK_adreno_get_gpu_pixel_alignment = NULL;
@@ -128,8 +126,6 @@
                 ::dlsym(libadreno_utils, "compute_aligned_width_and_height");
         *(void **)&LINK_adreno_compute_padding =
                 ::dlsym(libadreno_utils, "compute_surface_padding");
-        *(void **)&LINK_adreno_isMacroTilingSupportedByGpu =
-                ::dlsym(libadreno_utils, "isMacroTilingSupportedByGpu");
         *(void **)&LINK_adreno_compute_compressedfmt_aligned_width_and_height =
                 ::dlsym(libadreno_utils,
                         "compute_compressedfmt_aligned_width_and_height");
@@ -157,16 +153,6 @@
     }
 }
 
-int AdrenoMemInfo::isMacroTilingSupportedByGPU()
-{
-    if ((libadreno_utils)) {
-        if(LINK_adreno_isMacroTilingSupportedByGpu) {
-            return LINK_adreno_isMacroTilingSupportedByGpu();
-        }
-    }
-    return 0;
-}
-
 void AdrenoMemInfo::getAlignedWidthAndHeight(const private_handle_t *hnd, int& aligned_w,
                           int& aligned_h) {
     MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
@@ -241,7 +227,7 @@
 
     // Currently surface padding is only computed for RGB* surfaces.
     if (isUncompressedRgbFormat(format) == true) {
-        int tileEnabled = ubwc_enabled || isMacroTileEnabled(format, usage);
+        int tileEnabled = ubwc_enabled;
         getGpuAlignedWidthHeight(width, height, format, tileEnabled, aligned_w, aligned_h);
     } else if (ubwc_enabled) {
         getYuvUBwcWidthHeight(width, height, format, aligned_w, aligned_h);
@@ -538,38 +524,6 @@
     return memalloc;
 }
 
-bool isMacroTileEnabled(int format, int usage)
-{
-    bool tileEnabled = false;
-    // Check whether GPU & MDSS supports MacroTiling feature
-    if(AdrenoMemInfo::getInstance().isMacroTilingSupportedByGPU() &&
-       MDPCapabilityInfo::getInstance().isMacroTilingSupportedByMDP())
-    {
-        // check the format
-        switch(format)
-        {
-            case  HAL_PIXEL_FORMAT_RGBA_8888:
-            case  HAL_PIXEL_FORMAT_RGBX_8888:
-            case  HAL_PIXEL_FORMAT_BGRA_8888:
-            case  HAL_PIXEL_FORMAT_RGB_565:
-            case  HAL_PIXEL_FORMAT_BGR_565:
-                {
-                    tileEnabled = true;
-                    // check the usage flags
-                    if (usage & (GRALLOC_USAGE_SW_READ_MASK |
-                                GRALLOC_USAGE_SW_WRITE_MASK)) {
-                        // Application intends to use CPU for rendering
-                        tileEnabled = false;
-                    }
-                    break;
-                }
-            default:
-                break;
-        }
-    }
-    return tileEnabled;
-}
-
 // helper function
 unsigned int getSize(int format, int width, int height, int usage,
         const int alignedw, const int alignedh) {
@@ -736,20 +690,6 @@
     return size;
 }
 
-void getBufferAttributes(int width, int height, int format, int usage,
-        int& alignedw, int &alignedh, int& tiled, unsigned int& size)
-{
-    tiled = isUBwcEnabled(format, usage) || isMacroTileEnabled(format, usage);
-
-    AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
-            height,
-            format,
-            usage,
-            alignedw,
-            alignedh);
-    size = getSize(format, width, height, usage, alignedw, alignedh);
-}
-
 void getYuvUbwcSPPlaneInfo(uint64_t base, int width, int height,
                            int color_format, struct android_ycbcr* ycbcr)
 {
diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp
index 5911314..a0339b4 100644
--- a/libgralloc/gpu.cpp
+++ b/libgralloc/gpu.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
- * Copyright (c) 2011-2014 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2014,2017 The Linux Foundation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -134,10 +134,6 @@
             flags |= private_handle_t::PRIV_FLAGS_SECURE_DISPLAY;
         }
 
-        if(isMacroTileEnabled(format, usage)) {
-            flags |= private_handle_t::PRIV_FLAGS_TILE_RENDERED;
-        }
-
         if (isUBwcEnabled(format, usage)) {
             flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED;
         }
diff --git a/libgralloc/gr.h b/libgralloc/gr.h
index 7d055fc..ae26df9 100644
--- a/libgralloc/gr.h
+++ b/libgralloc/gr.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2008 The Android Open Source Project
- * Copyright (c) 2011 - 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011 - 2017, The Linux Foundation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,15 +54,6 @@
 unsigned int getBufferSizeAndDimensions(int width, int height, int format,
         int& alignedw, int &alignedh);
 
-
-// Attributes include aligned width, aligned height, tileEnabled and size of the buffer
-void getBufferAttributes(int width, int height, int format, int usage,
-                           int& alignedw, int &alignedh,
-                           int& tileEnabled, unsigned int &size);
-
-
-bool isMacroTileEnabled(int format, int usage);
-
 int decideBufferHandlingMechanism(int format, const char *compositionUsed,
                                   int hasBlitEngine, int *needConversion,
                                   int *useBufferDirectly);
@@ -148,15 +139,6 @@
      */
     void getUnalignedWidthAndHeight(const private_handle_t *hnd, int& unaligned_w,
                             int& unaligned_h);
-
-    /*
-     * Function to return whether GPU support MacroTile feature
-     *
-     * @return >0 : supported
-     *          0 : not supported
-     */
-    int isMacroTilingSupportedByGPU();
-
     /*
      * Function to query whether GPU supports UBWC for given HAL format
      * @return > 0 : supported
@@ -190,8 +172,6 @@
                                                 int *aligned_w,
                                                 int *aligned_h);
 
-        int (*LINK_adreno_isMacroTilingSupportedByGpu) (void);
-
         void(*LINK_adreno_compute_compressedfmt_aligned_width_and_height)(
                                                 int width,
                                                 int height,
@@ -211,20 +191,12 @@
 
 class MDPCapabilityInfo : public android::Singleton <MDPCapabilityInfo>
 {
-    int isMacroTileSupported = 0;
     int isUBwcSupported = 0;
     int isWBUBWCSupported = 0;
 
     public:
         MDPCapabilityInfo();
         /*
-        * Function to return whether MDP support MacroTile feature
-        *
-        * @return  1 : supported
-        *          0 : not supported
-        */
-        int isMacroTilingSupportedByMDP() { return isMacroTileSupported; }
-        /*
         * Function to return whether MDP supports UBWC feature
         *
         * @return  1 : supported
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index 132c768..acf5e2c 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2008 The Android Open Source Project
- * Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -397,8 +397,7 @@
                 int *alignedWidth = va_arg(args, int *);
                 int *alignedHeight = va_arg(args, int *);
                 int *tileEnabled = va_arg(args,int *);
-                *tileEnabled = isUBwcEnabled(format, usage) ||
-                               isMacroTileEnabled(format, usage);
+                *tileEnabled = isUBwcEnabled(format, usage);
                 AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
                         height, format, usage, *alignedWidth, *alignedHeight);
                 res = 0;