diff --git a/libexternal/external.cpp b/libexternal/external.cpp index 982146e6..d12d9f08 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 @@ void ExternalDisplay::setAttributes() { // 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 @@ void ExternalDisplay::setAttributes() { // 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 337d6ab2..e57e5738 100644 --- a/libhwcomposer/hwc_utils.cpp +++ b/libhwcomposer/hwc_utils.cpp @@ -488,8 +488,8 @@ void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation, 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 @@ void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation, 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 @@ void calcExtDisplayPosition(hwc_context_t *ctx, 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 6c6ba63d..66988f74 100644 --- a/libhwcomposer/hwc_vsync.cpp +++ b/libhwcomposer/hwc_vsync.cpp @@ -27,16 +27,17 @@ #include #include #include "hwc_utils.h" +#include "qd_utils.h" #include "string.h" #include "external.h" #include "overlay.h" #define __STDC_FORMAT_MACROS 1 #include +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 26c8845e..c016d3dd 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 @@ -452,7 +453,6 @@ int Overlay::initOverlay() { } 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 be7c2aaa..108313bd 100644 --- a/libqdutils/mdp_version.cpp +++ b/libqdutils/mdp_version.cpp @@ -29,6 +29,7 @@ #include #include #include "mdp_version.h" +#include "qd_utils.h" #define DEBUG 0 @@ -146,7 +147,6 @@ int MDPVersion::tokenizeParams(char *inputParams, const char *delim, 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 f67de52a..57262023 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 @@ void getAspectRatioPosition(int destWidth, int destHeight, int srcWidth, rect.bottom = srcHeight + rect.top; } +}; //namespace qdutils diff --git a/libqdutils/qd_utils.h b/libqdutils/qd_utils.h index a35f255a..2124c387 100644 --- a/libqdutils/qd_utils.h +++ b/libqdutils/qd_utils.h @@ -44,11 +44,18 @@ #include #include -#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 264d045e..44d06038 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 @@ void VirtualDisplay::setToPrimary(uint32_t maxArea, // 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 @@ void VirtualDisplay::setToPrimary(uint32_t maxArea, // 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 @@ void VirtualDisplay::setToPrimary(uint32_t maxArea, 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 @@ bool VirtualDisplay::openFrameBuffer() 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);