author | sky zhou <sky.zhou@amlogic.com> | 2020-05-07 13:59:06 (GMT) |
---|---|---|
committer | sky zhou <sky.zhou@amlogic.com> | 2020-05-21 12:19:12 (GMT) |
commit | 21a882b4a5fdf9272354ebb191dd34edd6ebc232 (patch) | |
tree | e6ff5fde5ad8ce2dcc860022f671bedd46cef6b9 | |
parent | 248ba809554004e5c60db4ccd0800f1884454910 (diff) | |
download | hwcomposer-21a882b4a5fdf9272354ebb191dd34edd6ebc232.zip hwcomposer-21a882b4a5fdf9272354ebb191dd34edd6ebc232.tar.gz hwcomposer-21a882b4a5fdf9272354ebb191dd34edd6ebc232.tar.bz2 |
DebugHelper: add test pattern for plane [2/2]
PD#SWPL-25594
Problem:
add debug method for flicker problem
Solution:
add a testpartten to check if app layer blank.
Verify:
verify on 805y
Change-Id: I773e129ec805b8d8fd30d30f601112dcb1710c4f
Signed-off-by: sky zhou <sky.zhou@amlogic.com>
-rw-r--r-- | common/debug/DebugHelper.cpp | 94 | ||||
-rwxr-xr-x[-rw-r--r--] | common/debug/include/DebugHelper.h | 14 | ||||
-rw-r--r-- | common/display/HwDisplayPlane.cpp | 15 | ||||
-rw-r--r-- | common/display/OsdPlane.cpp | 67 | ||||
-rw-r--r-- | common/display/OsdPlane.h | 2 | ||||
-rw-r--r-- | common/display/include/HwDisplayPlane.h | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | hwc2/Hwc2Display.cpp | 37 | ||||
-rw-r--r-- | hwc2/Hwc2Display.h | 1 |
8 files changed, 170 insertions, 70 deletions
diff --git a/common/debug/DebugHelper.cpp b/common/debug/DebugHelper.cpp index 44a3c5f..b3b695e 100644 --- a/common/debug/DebugHelper.cpp +++ b/common/debug/DebugHelper.cpp @@ -31,11 +31,17 @@ ANDROID_SINGLETON_STATIC_INSTANCE(DebugHelper) #define COMMAND_HIDE_LAYER "--hide-layer" #define COMMAND_SHOW_PLANE "--show-plane" #define COMMAND_HIDE_PLANE "--hide-plane" +#define COMMAND_SHOW_PATTERN_ON_PLANE "--show-pattern" +#define COMMAND_HIDE_PATTERN_ON_PLANE "--hide-pattern" #define COMMAND_MONITOR_DEVICE_COMPOSITION "--monitor-composition" #define COMMAND_DEVICE_COMPOSITION_THRESHOLD "--device-layers-threshold" #define MAX_DEBUG_COMMANDS (20) +#define PLANE_DBG_IDLE (1 << 0) +#define PLANE_DBG_PATTERN (1 << 1) + + #define INT_PARAMERTER_TO_BOOL(param) \ atoi(param) > 0 ? true : false @@ -72,10 +78,10 @@ void DebugHelper::clearPersistCmd() { mHideLayers.clear(); mSaveLayers.clear(); - mHidePlanes.clear(); - mDebugHideLayer = false; - mDebugHidePlane = false; + + mPlanesDebugFlag.clear(); + mDebugPlane = false; } void DebugHelper::addHideLayer(int id) { @@ -102,31 +108,33 @@ void DebugHelper::removeHideLayer(int id) { } } -void DebugHelper::addHidePlane(int id) { - bool bExist = false; - std::vector<int>::iterator it; - for (it = mHidePlanes.begin(); it < mHidePlanes.end(); it++) { - if (*it == id) { - bExist = true; - } +void DebugHelper::addPlaneDebugFlag(int id, int flag) { + auto it = mPlanesDebugFlag.find(id); + if (it != mPlanesDebugFlag.end()) { + int val = it->second; + val |= flag; + mPlanesDebugFlag.emplace(id, val); + } else { + mPlanesDebugFlag.emplace(id, flag); } - if (!bExist) { - mHidePlanes.push_back(id); - } + mDebugPlane = true; } -void DebugHelper::removeHidePlane(int id) { - std::vector<int>::iterator it; - for (it = mHidePlanes.begin(); it < mHidePlanes.end(); it++) { - if (*it == id) { - mHidePlanes.erase(it); - break; - } +void DebugHelper::removePlaneDebugFlag(int id, int flag) { + auto it = mPlanesDebugFlag.find(id); + if (it != mPlanesDebugFlag.end()) { + int val = it->second; + val &= ~flag; + if (val != 0) + mPlanesDebugFlag.emplace(id, val); + else + mPlanesDebugFlag.erase(id); + } else { + MESON_LOGE("remove plane (%d-%x) fail", id, flag); } } - void DebugHelper::resolveCmd() { #ifdef HWC_RELEASE return; @@ -257,8 +265,7 @@ void DebugHelper::resolveCmd() { if (planeId < 0) { MESON_LOGE("Show invalid plane (%d)", planeId); } else { - addHidePlane(planeId); - mDebugHidePlane = true; + addPlaneDebugFlag(planeId, PLANE_DBG_IDLE); } continue; } @@ -270,8 +277,31 @@ void DebugHelper::resolveCmd() { if (planeId < 0) { MESON_LOGE("Show invalid plane (%d)", planeId); } else { - removeHidePlane(planeId); - mDebugHidePlane = true; + removePlaneDebugFlag(planeId, PLANE_DBG_IDLE); + } + continue; + } + + if (strcmp(paramArray[i], COMMAND_SHOW_PATTERN_ON_PLANE) == 0) { + i++; + CHECK_CMD_INT_PARAMETER(); + int planeId = atoi(paramArray[i]); + if (planeId < 0) { + MESON_LOGE("Show invalid plane (%d)", planeId); + } else { + addPlaneDebugFlag(planeId, PLANE_DBG_PATTERN); + } + continue; + } + + if (strcmp(paramArray[i], COMMAND_HIDE_PATTERN_ON_PLANE) == 0) { + i++; + CHECK_CMD_INT_PARAMETER(); + int planeId = atoi(paramArray[i]); + if (planeId < 0) { + MESON_LOGE("Show invalid plane (%d)", planeId); + } else { + removePlaneDebugFlag(planeId, PLANE_DBG_PATTERN); } continue; } @@ -342,6 +372,7 @@ void DebugHelper::dump(String8 & dumpstr) { "\t " COMMAND_LOG_COMPOSITION_DETAIL " 0|1: enable/disable composition detail info.\n" "\t " COMMAND_HIDE_LAYER "/" COMMAND_SHOW_LAYER " [layerId]: hide/unhide specific layers by zorder. \n" "\t " COMMAND_HIDE_PLANE "/" COMMAND_SHOW_PLANE " [planeId]: hide/unhide specific plane by plane id. \n" + "\t " COMMAND_SHOW_PATTERN_ON_PLANE "/" COMMAND_HIDE_PATTERN_ON_PLANE " [planeId]: set/unset test pattern on plane id. \n" "\t " COMMAND_LOG_FPS " 0|1: start/stop log fps.\n" "\t " COMMAND_SAVE_LAYER " [layerId]: save specific layer's raw data by layer id. \n" "\t " COMMAND_MONITOR_DEVICE_COMPOSITION " 0|1: monitor non device composition. \n"; @@ -350,8 +381,6 @@ void DebugHelper::dump(String8 & dumpstr) { dumpstr.append(usage); dumpstr.append("\n"); } else { - std::vector<int>::iterator it; - dumpstr.append("Debug Command:\n"); dumpstr.appendFormat(COMMAND_NOHWC " (%d)\n", mDisableUiHwc); dumpstr.appendFormat(COMMAND_DUMP_DETAIL " (%d)\n", mDumpDetail); @@ -363,20 +392,21 @@ void DebugHelper::dump(String8 & dumpstr) { dumpstr.appendFormat(COMMAND_MONITOR_DEVICE_COMPOSITION " (%d)\n", mMonitorDeviceComposition); dumpstr.appendFormat(COMMAND_DEVICE_COMPOSITION_THRESHOLD " (%d)\n", mDeviceCompositionThreshold); - dumpstr.append(COMMAND_HIDE_PLANE " ("); - for (it = mHidePlanes.begin(); it < mHidePlanes.end(); it++) { - dumpstr.appendFormat("%d ", *it); + dumpstr.append(COMMAND_HIDE_PLANE "/" COMMAND_SHOW_PATTERN_ON_PLANE " ("); + + for (auto planeFlag = mPlanesDebugFlag.begin(); planeFlag != mPlanesDebugFlag.end(); planeFlag++) { + dumpstr.appendFormat("%d-%d ", planeFlag->first, planeFlag->second); } dumpstr.append(")\n"); dumpstr.append(COMMAND_HIDE_LAYER " ("); - for (it = mHideLayers.begin(); it < mHideLayers.end(); it++) { + for (auto it = mHideLayers.begin(); it < mHideLayers.end(); it++) { dumpstr.appendFormat("%d ", *it); } dumpstr.append(")\n"); dumpstr.append(COMMAND_SAVE_LAYER " ("); - for (it = mSaveLayers.begin(); it < mSaveLayers.end(); it++) { + for (auto it = mSaveLayers.begin(); it < mSaveLayers.end(); it++) { dumpstr.appendFormat("%d ", *it); } dumpstr.append(")\n"); diff --git a/common/debug/include/DebugHelper.h b/common/debug/include/DebugHelper.h index a08da22..af1ec6c 100644..100755 --- a/common/debug/include/DebugHelper.h +++ b/common/debug/include/DebugHelper.h @@ -42,8 +42,8 @@ public: inline void getHideLayers(std::vector<int> & layers) {layers = mHideLayers;} inline bool debugHideLayers() {return mDebugHideLayer;} - inline void getHidePlanes(std::vector<int> & planes) {planes = mHidePlanes;} - inline bool debugHidePlanes() {return mDebugHidePlane;} + inline void getPlaneDebugFlags(std::map<int, int> & planeFlags) {planeFlags = mPlanesDebugFlag;} + inline bool debugPlanes() {return mDebugPlane;} /*save layer's raw data by layerid.*/ inline void getSavedLayers(std::vector<int> & layers) {layers = mSaveLayers;} @@ -59,8 +59,8 @@ protected: void addHideLayer(int id); void removeHideLayer(int id); - void addHidePlane(int id); - void removeHidePlane(int id); + void addPlaneDebugFlag(int id, int flag); + void removePlaneDebugFlag(int id, int flag); protected: bool mEnabled; @@ -77,10 +77,10 @@ protected: std::vector<int> mSaveLayers; std::vector<int> mHideLayers; - std::vector<int> mHidePlanes; - bool mDebugHideLayer; - bool mDebugHidePlane; + + std::map<int, int> mPlanesDebugFlag; + bool mDebugPlane; /*handle osd in/out fence in hwc.*/ bool mDiscardInFence; diff --git a/common/display/HwDisplayPlane.cpp b/common/display/HwDisplayPlane.cpp index 2502033..1606e22 100644 --- a/common/display/HwDisplayPlane.cpp +++ b/common/display/HwDisplayPlane.cpp @@ -13,10 +13,23 @@ HwDisplayPlane::HwDisplayPlane(int32_t drvFd, uint32_t id) { mDrvFd = drvFd; mId = id; - mIdle = false; + mDebugIdle = false; + mDebugPattern = false; } HwDisplayPlane::~HwDisplayPlane() { close(mDrvFd); } +void HwDisplayPlane::setDebugFlag(int dbgFlag) { + if (dbgFlag & PLANE_DBG_IDLE) + mDebugIdle = true; + else + mDebugIdle = false; + + if (dbgFlag & PLANE_DBG_PATTERN) + mDebugPattern = true; + else + mDebugPattern = false; +} + diff --git a/common/display/OsdPlane.cpp b/common/display/OsdPlane.cpp index 5e6f564..2437120 100644 --- a/common/display/OsdPlane.cpp +++ b/common/display/OsdPlane.cpp @@ -11,6 +11,8 @@ #include <MesonLog.h> #include <DebugHelper.h> +#define OSD_PATTERN_SIZE (128) + OsdPlane::OsdPlane(int32_t drvFd, uint32_t id) : HwDisplayPlane(drvFd, id), mBlank(false), @@ -65,7 +67,7 @@ const char * OsdPlane::getName() { } uint32_t OsdPlane::getPlaneType() { - if (mIdle) { + if (mDebugIdle) { return INVALID_PLANE; } @@ -178,9 +180,17 @@ int32_t OsdPlane::setPlane(std::shared_ptr<DrmFramebuffer> fb, uint32_t zorder, return 0; } - drm_rect_t srcCrop = fb->mSourceCrop; + std::shared_ptr<DrmFramebuffer> postFb = fb; + if (mDebugPattern) { + if (!mPatternFb.get()) + createPatternFb(); + if (mPatternFb.get()) + postFb = mPatternFb; + } + + drm_rect_t srcCrop = postFb->mSourceCrop; + buffer_handle_t buf = postFb->mBufferHandle; drm_rect_t disFrame = fb->mDisplayFrame; - buffer_handle_t buf = fb->mBufferHandle; mPlaneInfo.xoffset = srcCrop.left; mPlaneInfo.yoffset = srcCrop.top; @@ -194,8 +204,8 @@ int32_t OsdPlane::setPlane(std::shared_ptr<DrmFramebuffer> fb, uint32_t zorder, mPlaneInfo.op |= OSD_BLANK_OP_BIT; if (fb->mBufferHandle != NULL) { - mPlaneInfo.fb_width = am_gralloc_get_width(fb->mBufferHandle); - mPlaneInfo.fb_height = am_gralloc_get_height(fb->mBufferHandle); + mPlaneInfo.fb_width = am_gralloc_get_width(buf); + mPlaneInfo.fb_height = am_gralloc_get_height(buf); } else { mPlaneInfo.fb_width = -1; mPlaneInfo.fb_height = -1; @@ -278,6 +288,53 @@ int32_t OsdPlane::setPlane(std::shared_ptr<DrmFramebuffer> fb, uint32_t zorder, return 0; } +void OsdPlane::createPatternFb() { + buffer_handle_t hnd = gralloc_alloc_dma_buf( + OSD_PATTERN_SIZE, OSD_PATTERN_SIZE, + HAL_PIXEL_FORMAT_RGBA_8888, + true, false); + mPatternFb = std::make_shared<DrmFramebuffer>(hnd, -1); + + void * fbmem = NULL; + if (mPatternFb->lock(&fbmem) == 0) { + native_handle_t * handle = mPatternFb->mBufferHandle; + int w = am_gralloc_get_width(handle); + int h = am_gralloc_get_height(handle); + int type = mId % 3; + char r = 0, g = 0, b = 0; + switch (type) { + case 0: + r = g = b = 255; + break; + case 1: + r = 255; + break; + case 2: + g = 255; + break; + case 3: + b = 255; + break; + default: + r = g = b = 128; + break; + }; + MESON_LOGD("Plane setpattern (%d-%d,%d,%d)", mId, r, g, b); + + char * colorbuf = (char *) fbmem; + for (int ir = 0; ir < h; ir++) { + for (int ic = 0; ic < w; ic++) { + colorbuf[0] = r; + colorbuf[1] = g; + colorbuf[2] = b; + colorbuf[3] = 0xff; + colorbuf += 4; + } + } + mPatternFb->unlock(); + } +} + void OsdPlane::dump(String8 & dumpstr) { if (!mBlank) { dumpstr.appendFormat("| osd%2d |" diff --git a/common/display/OsdPlane.h b/common/display/OsdPlane.h index 60175ca..d9ef7c5 100644 --- a/common/display/OsdPlane.h +++ b/common/display/OsdPlane.h @@ -33,12 +33,14 @@ public: protected: int32_t getProperties(); + void createPatternFb(); private: bool mBlank; uint32_t mPossibleCrtcs; osd_plane_info_t mPlaneInfo; std::shared_ptr<DrmFramebuffer> mDrmFb; + std::shared_ptr<DrmFramebuffer> mPatternFb; char mName[64]; }; diff --git a/common/display/include/HwDisplayPlane.h b/common/display/include/HwDisplayPlane.h index 9143e4e..a9fa002 100644 --- a/common/display/include/HwDisplayPlane.h +++ b/common/display/include/HwDisplayPlane.h @@ -33,7 +33,12 @@ public: uint32_t zorder, int blankOp) = 0; /*For debug, plane return a invalid type.*/ - virtual void setIdle(bool idle) { mIdle = idle;} + enum { + PLANE_DBG_IDLE = 1 << 0, + PLANE_DBG_PATTERN = 1 << 1, + }; + virtual void setDebugFlag(int dbgFlag); + virtual void dump(String8 & dumpstr) = 0; int32_t getDrvFd() {return mDrvFd;} @@ -43,7 +48,8 @@ protected: int32_t mDrvFd; uint32_t mId; int32_t mCapability; - bool mIdle; + bool mDebugIdle; + bool mDebugPattern; }; #endif/*HW_DISPLAY_PLANE_H*/ diff --git a/hwc2/Hwc2Display.cpp b/hwc2/Hwc2Display.cpp index d0d2735..a8b3dcc 100644..100755 --- a/hwc2/Hwc2Display.cpp +++ b/hwc2/Hwc2Display.cpp @@ -496,12 +496,20 @@ hwc2_error_t Hwc2Display::collectLayersForPresent() { hwc2_error_t Hwc2Display::collectPlanesForPresent() { mPresentPlanes = mPlanes; - for (auto it = mPresentPlanes.begin(); it != mPresentPlanes.end(); it++) { - std::shared_ptr<HwDisplayPlane> plane = *it; - if (isPlaneHideForDebug(plane->getPlaneId())) { - plane->setIdle(true); - } else { - plane->setIdle(false); + + if (DebugHelper::getInstance().debugPlanes()) { + std::map<int, int> planeFlags; + DebugHelper::getInstance().getPlaneDebugFlags(planeFlags); + + for (auto it = mPresentPlanes.begin(); it != mPresentPlanes.end(); it++) { + std::shared_ptr<HwDisplayPlane> plane = *it; + + auto dbgIt = planeFlags.find(plane->getPlaneId()); + if (dbgIt != planeFlags.end()) { + plane->setDebugFlag(dbgIt->second); + } else { + plane->setDebugFlag(0); + } } } @@ -988,21 +996,6 @@ bool Hwc2Display::isLayerHideForDebug(hwc2_layer_t id) { return false; } -bool Hwc2Display::isPlaneHideForDebug(int id) { - std::vector<int> hidePlanes; - DebugHelper::getInstance().getHidePlanes(hidePlanes); - if (hidePlanes.empty()) - return false; - - for (auto it = hidePlanes.begin(); it < hidePlanes.end(); it++) { - if (*it == id) { - return true; - } - } - - return false; -} - hwc2_error_t Hwc2Display::getDisplayCapabilities( uint32_t* outNumCapabilities, uint32_t* outCapabilities) { if (outCapabilities == nullptr) { @@ -1076,7 +1069,7 @@ void Hwc2Display::dumpHwDisplayPlane(String8 &dumpstr) { void Hwc2Display::dump(String8 & dumpstr) { /*update for debug*/ if (DebugHelper::getInstance().debugHideLayers() || - DebugHelper::getInstance().debugHidePlanes()) { + DebugHelper::getInstance().debugPlanes()) { //ask for auto refresh for debug layers update. if (mObserver != NULL) { mObserver->refresh(); diff --git a/hwc2/Hwc2Display.h b/hwc2/Hwc2Display.h index e70c24e..0608d13 100644 --- a/hwc2/Hwc2Display.h +++ b/hwc2/Hwc2Display.h @@ -140,7 +140,6 @@ protected: /*For debug*/ void dumpPresentLayers(String8 & dumpstr); bool isLayerHideForDebug(hwc2_layer_t id); - bool isPlaneHideForDebug(int id); void dumpHwDisplayPlane(String8 &dumpstr); protected: |