author | Stark Li <stark.li@amlogic.com> | 2017-01-19 11:27:15 (GMT) |
---|---|---|
committer | Stark Li <stark.li@amlogic.com> | 2017-01-25 06:20:27 (GMT) |
commit | d2aee80ebd18182961be2c10ea9f961be5a56bdb (patch) | |
tree | 1471e545131d1606330e59b73ab183f260f01410 | |
parent | 5d03c54e8d3c2a3d60790efafe19f5c28d52ee92 (diff) | |
download | hwcomposer-d2aee80ebd18182961be2c10ea9f961be5a56bdb.zip hwcomposer-d2aee80ebd18182961be2c10ea9f961be5a56bdb.tar.gz hwcomposer-d2aee80ebd18182961be2c10ea9f961be5a56bdb.tar.bz2 |
PD#138752:
1. fix memory alloction failure.
2. add blank fb0 when there is only one video overlay layer exists.
3. fix abs function can not work.
Change-Id: Ifc0eeb18d3b633d65f1a062d0ecda03c94a11fc2
-rw-r--r-- | hwc2/common/base/HwcLayer.cpp | 8 | ||||
-rw-r--r-- | hwc2/common/composers/GE2DComposer.cpp | 16 | ||||
-rw-r--r-- | hwc2/common/devices/PhysicalDevice.cpp | 36 | ||||
-rw-r--r-- | hwc2/common/devices/PrimaryDevice.cpp | 22 | ||||
-rw-r--r-- | hwc2/common/utils/Utils.h | 4 | ||||
-rw-r--r-- | hwc2/include/PhysicalDevice.h | 2 |
6 files changed, 55 insertions, 33 deletions
diff --git a/hwc2/common/base/HwcLayer.cpp b/hwc2/common/base/HwcLayer.cpp index 24a2992..42a7388 100644 --- a/hwc2/common/base/HwcLayer.cpp +++ b/hwc2/common/base/HwcLayer.cpp @@ -93,8 +93,8 @@ bool HwcLayer::isCropped() { float widthCmp = (mSourceCrop.right - mSourceCrop.left) / buffer->width; float heightCmp = (mSourceCrop.bottom - mSourceCrop.top) / buffer->height; - if (abs(widthCmp - 1.0f) <= 0.01f - && abs(heightCmp - 1.0f) <= 0.01f) { + if (Utils::abs(widthCmp - 1.0f) <= 0.01f + && Utils::abs(heightCmp - 1.0f) <= 0.01f) { rtn = false; } } @@ -114,8 +114,8 @@ bool HwcLayer::isScaled() { float widthCmp = sourceWidth / displayWidth; float heightCmp = sourceHeight / displayHeight; - if (abs(widthCmp - 1.0f) <= 0.01f - && abs(heightCmp - 1.0f) <= 0.01f) { + if (Utils::abs(widthCmp - 1.0f) <= 0.01f + && Utils::abs(heightCmp - 1.0f) <= 0.01f) { rtn = false; } } diff --git a/hwc2/common/composers/GE2DComposer.cpp b/hwc2/common/composers/GE2DComposer.cpp index ad1e696..fab48db 100644 --- a/hwc2/common/composers/GE2DComposer.cpp +++ b/hwc2/common/composers/GE2DComposer.cpp @@ -32,7 +32,7 @@ GE2DComposer::GE2DComposer(IDisplayDevice& disp) mGe2dFd(-1), mVideoLayerId(0), mSrcBufferInfo(NULL), - mDebug(false), + mDebug(true), mExitThread(false), mInitialized(false) { @@ -647,16 +647,9 @@ bool GE2DComposer::threadLoop() Vector< LayerState* > layersState = front->mLayersState; { // clear display region. - hwc2_layer_t videoLayerId = front->mVideoLayerId; bool clearBuffer = front->mClearBuffer; hwc_rect_t clipRect; - HwcLayer* videoLayer = mDisplayDevice.getLayerById(videoLayerId); uint32_t addr = mBasePhyAddr + slot * mFbInfo->finfo.line_length; - if (videoLayer) { - clipRect = videoLayer->getDisplayFrame(); - fillRectangle(clipRect, 0, addr); - } - if (clearBuffer) { clipRect.left = 0; clipRect.top = 0; @@ -664,6 +657,13 @@ bool GE2DComposer::threadLoop() clipRect.bottom = mFbInfo->info.yres; fillRectangle(clipRect, 0, addr); } + + hwc2_layer_t videoLayerId = front->mVideoLayerId; + HwcLayer* videoLayer = mDisplayDevice.getLayerById(videoLayerId); + if (!clearBuffer && videoLayer) { + clipRect = videoLayer->getDisplayFrame(); + fillRectangle(clipRect, 0, addr); + } } // wait all fence to be signaled here. diff --git a/hwc2/common/devices/PhysicalDevice.cpp b/hwc2/common/devices/PhysicalDevice.cpp index 04ea2fe..46a9c6f 100644 --- a/hwc2/common/devices/PhysicalDevice.cpp +++ b/hwc2/common/devices/PhysicalDevice.cpp @@ -48,10 +48,10 @@ PhysicalDevice::PhysicalDevice(hwc2_display_t id, Hwcomposer& hwc, DeviceControl mTargetAcquireFence(-1), mRenderMode(GLES_COMPOSE_MODE), mIsValidated(false), + mIsContinuousBuf(true), mDirectRenderLayerId(0), mVideoOverlayLayerId(0), mGE2DClearVideoRegionCount(0), - mOSD0Blank(false), mGE2DComposeFrameCount(0), mInitialized(false) { @@ -656,18 +656,21 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv }*/ } else if (mRenderMode == DIRECT_COMPOSE_MODE) { // if only one layer exists, let hwc do her work. directCompose(&fbInfo); - /* if (mGE2DComposeFrameCount != 0) { - addReleaseFence(mDirectRenderLayerId, HwcFenceControl::dupFence(mPriorFrameRetireFence)); - }*/ } else if (mRenderMode == GE2D_COMPOSE_MODE) { ge2dCompose(&fbInfo, hasVideoOverlay); } fbInfo.renderMode = mRenderMode; if (hasVideoOverlay && mHwcLayers.size() == 1) { - fbInfo.op |= 0x00000001; + if (mIsContinuousBuf) + fbInfo.op |= 0x00000001; + else + setOSD0Blank(true); } else { - fbInfo.op &= ~0x00000001; + if (mIsContinuousBuf) + fbInfo.op &= ~0x00000001; + else + setOSD0Blank(false); } if (!mClientTargetHnd || private_handle_t::validate(mClientTargetHnd) < 0 || mPowerMode == HWC2_POWER_MODE_OFF) { @@ -694,7 +697,7 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv // real post framebuffer here. DTRACE("fbInfo->renderMode: %d", fbInfo.renderMode); - if (mRenderMode == GLES_COMPOSE_MODE) { + if (!mIsContinuousBuf) { mPriorFrameRetireFence = fb_post_with_fence_locked(&fbInfo, mClientTargetHnd, mTargetAcquireFence); } else { mPriorFrameRetireFence = hwc_fb_post_with_fence_locked(&fbInfo, mClientTargetHnd, mTargetAcquireFence); @@ -728,6 +731,19 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv return HWC2_ERROR_NONE; } +// TODO: need add fence wait. +int32_t PhysicalDevice::setOSD0Blank(bool blank) { + framebuffer_info_t* fbInfo = mFramebufferContext->getInfo(); + + if (fbInfo->fd > 0 && blank != mFramebufferContext->getStatus()) { + mFramebufferContext->setStatus(blank); + DTRACE("UPDATE FB0 status to %d", blank); + ioctl(fbInfo->fd, FBIOBLANK, blank); + } + + return HWC2_ERROR_NONE; +} + int32_t PhysicalDevice::presentDisplay( int32_t* outRetireFence) { int32_t err = HWC2_ERROR_NONE; @@ -1042,10 +1058,10 @@ int32_t PhysicalDevice::validateDisplay(uint32_t* outNumTypes, HwcLayer* layer = NULL; bool istvp = false; bool glesCompose = false; - bool isContinuousBuf = true; mRenderMode = GLES_COMPOSE_MODE; mVideoOverlayLayerId = 0; + mIsContinuousBuf = true; swapReleaseFence(); for (uint32_t i=0; i<mHwcLayers.size(); i++) { @@ -1058,7 +1074,7 @@ int32_t PhysicalDevice::validateDisplay(uint32_t* outNumTypes, if (hnd) { if (!(hnd->flags & private_handle_t::PRIV_FLAGS_CONTINUOUS_BUF)) { DTRACE("continous buffer flag is not set!"); - isContinuousBuf = false; + mIsContinuousBuf = false; } if (hnd && layer->getCompositionType() == HWC2_COMPOSITION_DEVICE) { // video overlay. @@ -1118,7 +1134,7 @@ int32_t PhysicalDevice::validateDisplay(uint32_t* outNumTypes, #endif // dumpLayers(mHwcLayers); - if (isContinuousBuf && !glesCompose && !noDevComp) { + if (mIsContinuousBuf && !glesCompose && !noDevComp) { mRenderMode = composersFilter(mHwcGlesLayers); } diff --git a/hwc2/common/devices/PrimaryDevice.cpp b/hwc2/common/devices/PrimaryDevice.cpp index 550876c..6a695fe 100644 --- a/hwc2/common/devices/PrimaryDevice.cpp +++ b/hwc2/common/devices/PrimaryDevice.cpp @@ -84,17 +84,19 @@ void PrimaryDevice::hotplugListener(bool connected) { CTRACE(); - ETRACE("hotpug event: %d", connected); - - updateHotplugState(connected); - // update display configs - if (connected && !updateDisplayConfigs()) { - ETRACE("failed to update display config"); - return; + if (getDisplayId() == HWC_DISPLAY_EXTERNAL) { + ETRACE("hotpug event: %d", connected); + + updateHotplugState(connected); + // update display configs + if (connected && !updateDisplayConfigs()) { + ETRACE("failed to update display config"); + return; + } + + if (connected) + getDevice().hotplug(getDisplayId(), connected); } - - if (connected) - getDevice().hotplug(getDisplayId(), connected); } } // namespace amlogic diff --git a/hwc2/common/utils/Utils.h b/hwc2/common/utils/Utils.h index 351fb22..a580d19 100644 --- a/hwc2/common/utils/Utils.h +++ b/hwc2/common/utils/Utils.h @@ -60,6 +60,10 @@ public: } return false; } + template<typename T> + inline static T abs(const T& value) { + return value < 0 ? - value : value; + } template <typename T> static inline T min(T a, T b) { return a<b ? a : b; diff --git a/hwc2/include/PhysicalDevice.h b/hwc2/include/PhysicalDevice.h index 049e37f..a643f43 100644 --- a/hwc2/include/PhysicalDevice.h +++ b/hwc2/include/PhysicalDevice.h @@ -178,7 +178,6 @@ private: Hwcomposer& mHwc; DeviceControlFactory *mControlFactory; char mDisplayMode[32]; - bool mOSD0Blank; // display configs Vector<DisplayConfig*> mDisplayConfigs; @@ -207,6 +206,7 @@ private: int32_t mPriorFrameRetireFence; int32_t mRenderMode; bool mIsValidated; + bool mIsContinuousBuf; // num of composition type changed layer. uint32_t mNumLayersChangetype; |