hwc: Clean up scattered definitions of commonly used constants/values

Clean up scattered definitions of commonly used constants/values.
There is no need in re-defining these in several places.

Change-Id: I22c082b56646cb02d5ae4733d110afc81aaff50a
diff --git a/libexternal/external.cpp b/libexternal/external.cpp
index 982146e..d12d9f0 100644
--- a/libexternal/external.cpp
+++ b/libexternal/external.cpp
@@ -37,14 +37,11 @@
 #include "qd_utils.h"
 
 using namespace android;
+using namespace qdutils;
 
 namespace qhwc {
-#define MAX_SYSFS_FILE_PATH             255
 #define UNKNOWN_STRING                  "unknown"
 #define SPD_NAME_LENGTH                 16
-/* Max. resolution assignable to when downscale */
-#define SUPPORTED_DOWNSCALE_EXT_AREA    (1920*1080)
-
 
 int ExternalDisplay::configure() {
     if(!openFrameBuffer()) {
@@ -594,7 +591,7 @@
             // downscale mode
             // Restrict this upto 1080p resolution max
             if(((priW * priH) > (width * height)) &&
-               ((priW * priH) <= SUPPORTED_DOWNSCALE_EXT_AREA)) {
+               ((priW * priH) <= SUPPORTED_DOWNSCALE_AREA)) {
                 // tmpW and tmpH will hold the primary dimensions before we
                 // update the aspect ratio if necessary.
                 int tmpW = priW;
@@ -611,7 +608,7 @@
                 // We get around this by calculating a new resolution by
                 // keeping aspect ratio intact.
                 hwc_rect r = {0, 0, 0, 0};
-                getAspectRatioPosition(tmpW, tmpH, width, height, r);
+                qdutils::getAspectRatioPosition(tmpW, tmpH, width, height, r);
                 mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres =
                                                               r.right - r.left;
                 mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres =
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 3696c05..5cecbaa 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -488,8 +488,8 @@
     if(extOrientation & HAL_TRANSFORM_ROT_90) {
         // Swap width/height for input position
         swapWidthHeight(actualWidth, actualHeight);
-        getAspectRatioPosition((int)fbWidth, (int)fbHeight, (int)actualWidth,
-                               (int)actualHeight, rect);
+        qdutils::getAspectRatioPosition((int)fbWidth, (int)fbHeight,
+                                (int)actualWidth, (int)actualHeight, rect);
         xPos = rect.left;
         yPos = rect.top;
         width = float(rect.right - rect.left);
@@ -520,7 +520,7 @@
         xRatio = (float)(outPos.x - xPos)/width;
         // GetaspectRatio -- tricky to get the correct aspect ratio
         // But we need to do this.
-        getAspectRatioPosition((int)width, (int)height,
+        qdutils::getAspectRatioPosition((int)width, (int)height,
                                (int)width,(int)height, r);
         xPos = r.left;
         yPos = r.top;
@@ -603,7 +603,7 @@
                 if(!isPrimaryPortrait(ctx)) {
                     swap(srcWidth, srcHeight);
                 }                    // Get Aspect Ratio for external
-                getAspectRatioPosition(dstWidth, dstHeight, srcWidth,
+                qdutils::getAspectRatioPosition(dstWidth, dstHeight, srcWidth,
                                     srcHeight, displayFrame);
                 // Crop - this is needed, because for sidesync, the dest fb will
                 // be in portrait orientation, so update the crop to not show the
diff --git a/libhwcomposer/hwc_vsync.cpp b/libhwcomposer/hwc_vsync.cpp
index 6c6ba63..66988f7 100644
--- a/libhwcomposer/hwc_vsync.cpp
+++ b/libhwcomposer/hwc_vsync.cpp
@@ -27,16 +27,17 @@
 #include <sys/prctl.h>
 #include <poll.h>
 #include "hwc_utils.h"
+#include "qd_utils.h"
 #include "string.h"
 #include "external.h"
 #include "overlay.h"
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 
+using namespace qdutils;
 namespace qhwc {
 
 #define HWC_VSYNC_THREAD_NAME "hwcVsyncThread"
-#define MAX_SYSFS_FILE_PATH             255
 #define PANEL_ON_STR "panel_power_on ="
 #define ARRAY_LENGTH(array) (sizeof((array))/sizeof((array)[0]))
 #define MAX_THERMAL_LEVEL 3
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index de880c6..46b6275 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -32,6 +32,7 @@
 #include "pipes/overlayGenPipe.h"
 #include "mdp_version.h"
 #include "qdMetaData.h"
+#include "qd_utils.h"
 
 #define PIPE_DEBUG 0
 
@@ -430,7 +431,6 @@
     }
 
     FILE *displayDeviceFP = NULL;
-    const int MAX_FRAME_BUFFER_NAME_SIZE = 128;
     char fbType[MAX_FRAME_BUFFER_NAME_SIZE];
     char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE];
     const char *strDtvPanel = "dtv panel";
diff --git a/libqdutils/mdp_version.cpp b/libqdutils/mdp_version.cpp
index 48f7cb7..a064317 100644
--- a/libqdutils/mdp_version.cpp
+++ b/libqdutils/mdp_version.cpp
@@ -29,6 +29,7 @@
 #include <cutils/log.h>
 #include <linux/msm_mdp.h>
 #include "mdp_version.h"
+#include "qd_utils.h"
 
 #define DEBUG 0
 
@@ -146,7 +147,6 @@
 void  MDPVersion::updatePanelInfo() {
     FILE *displayDeviceFP = NULL;
     FILE *panelInfoNodeFP = NULL;
-    const int MAX_FRAME_BUFFER_NAME_SIZE = 128;
     char fbType[MAX_FRAME_BUFFER_NAME_SIZE];
     const char *strCmdPanel = "mipi dsi cmd panel";
     const char *strVideoPanel = "mipi dsi video panel";
diff --git a/libqdutils/qd_utils.cpp b/libqdutils/qd_utils.cpp
index f67de52..5726202 100644
--- a/libqdutils/qd_utils.cpp
+++ b/libqdutils/qd_utils.cpp
@@ -28,11 +28,10 @@
  */
 
 #include "qd_utils.h"
-
-
-#define MAX_FRAME_BUFFER_NAME_SIZE      (80)
 #define QD_UTILS_DEBUG 0
 
+namespace qdutils {
+
 int getHDMINode(void)
 {
     FILE *displayDeviceFP = NULL;
@@ -121,3 +120,4 @@
     rect.bottom = srcHeight + rect.top;
 }
 
+}; //namespace qdutils
diff --git a/libqdutils/qd_utils.h b/libqdutils/qd_utils.h
index a35f255..2124c38 100644
--- a/libqdutils/qd_utils.h
+++ b/libqdutils/qd_utils.h
@@ -44,11 +44,18 @@
 #include <cutils/properties.h>
 #include <hardware/hwcomposer.h>
 
-#define EDID_RAW_DATA_SIZE 640
+namespace qdutils {
+#define EDID_RAW_DATA_SIZE              640
+
+enum qd_utils {
+    MAX_FRAME_BUFFER_NAME_SIZE = 128,
+    MAX_SYSFS_FILE_PATH = 255,
+    SUPPORTED_DOWNSCALE_AREA = (1920*1080)
+};
 
 int getEdidRawData(char *buffer);
 
 void getAspectRatioPosition(int destWidth, int destHeight, int srcWidth,
                                 int srcHeight, hwc_rect_t& rect);
-
+}; //namespace qdutils
 #endif
diff --git a/libvirtual/virtual.cpp b/libvirtual/virtual.cpp
index 264d045..44d0603 100644
--- a/libvirtual/virtual.cpp
+++ b/libvirtual/virtual.cpp
@@ -50,14 +50,10 @@
 #include "qd_utils.h"
 
 using namespace android;
+using namespace qdutils;
 
 namespace qhwc {
 
-#define MAX_SYSFS_FILE_PATH             255
-
-/* Max. resolution assignable to virtual display. */
-#define SUPPORTED_VIRTUAL_AREA          (1920*1080)
-
 int VirtualDisplay::configure() {
     if(!openFrameBuffer())
         return -1;
@@ -124,9 +120,9 @@
     // for eg., primary in 1600p and WFD in 1080p
     // we wont use downscale feature because MAX MDP
     // writeback resolution supported is 1080p (tracked
-    // by SUPPORTED_VIRTUAL_AREA).
+    // by SUPPORTED_DOWNSCALE_AREA).
     if((maxArea == (priW * priH))
-        && (maxArea <= SUPPORTED_VIRTUAL_AREA)) {
+        && (maxArea <= SUPPORTED_DOWNSCALE_AREA)) {
         // tmpW and tmpH will hold the primary dimensions before we
         // update the aspect ratio if necessary.
         uint32_t tmpW = priW;
@@ -143,7 +139,7 @@
         // We get around this by calculating a new resolution by
         // keeping aspect ratio intact.
         hwc_rect r = {0, 0, 0, 0};
-        getAspectRatioPosition(tmpW, tmpH, extW, extH, r);
+        qdutils::getAspectRatioPosition(tmpW, tmpH, extW, extH, r);
         extW = r.right - r.left;
         extH = r.bottom - r.top;
     }
@@ -156,13 +152,13 @@
    2. WFD down scale path i.e. when WFD resolution is lower than
       primary resolution.
    Furthermore, downscale mode is only valid when downscaling from
-   SUPPORTED_VIRTUAL_AREA to a lower resolution.
-   (SUPPORTED_VIRTUAL_AREA represents the maximum resolution that
+   SUPPORTED_DOWNSCALE_AREA to a lower resolution.
+   (SUPPORTED_DOWNSCALE_AREA represents the maximum resolution that
    we can configure to the virtual display)
 */
 void VirtualDisplay::setDownScaleMode(uint32_t maxArea) {
     if((maxArea > (mVInfo.xres * mVInfo.yres))
-        && (maxArea <= SUPPORTED_VIRTUAL_AREA)) {
+        && (maxArea <= SUPPORTED_DOWNSCALE_AREA)) {
         mHwcContext->dpyAttr[HWC_DISPLAY_VIRTUAL].mDownScaleMode = true;
     }else {
         mHwcContext->dpyAttr[HWC_DISPLAY_VIRTUAL].mDownScaleMode = false;
@@ -214,7 +210,7 @@
         int fbNum = overlay::Overlay::getInstance()->
                                    getFbForDpy(HWC_DISPLAY_VIRTUAL);
 
-        char strDevPath[MAX_SYSFS_FILE_PATH];
+        char strDevPath[qdutils::MAX_SYSFS_FILE_PATH];
         snprintf(strDevPath,sizeof(strDevPath), "/dev/graphics/fb%d", fbNum);
 
         mFd = open(strDevPath, O_RDWR);