From d8588e1c12ae022f2b61e89df5b624c698a0b332 Mon Sep 17 00:00:00 2001 From: Naomi Luis Date: Fri, 27 Jan 2012 19:08:01 -0800 Subject: [PATCH] overlay: Close correct channels during state change events. When there is a state change, open/close only the required channels instead of blindly closing all the channels. When HDMI is connected, open the overlay for queueing the frames on the external, and when hdmi is disconnected, only close the external overlay channel. CRs-fixed: 333324 (cherry picked from commit a6b5ac4c385e03b3c798bb07d0d3ba6140aebbe8) Change-Id: I7333a6fe106cd0aa99471542daf3c84c04c5d056 --- libhwcomposer/hwcomposer.cpp | 5 ++--- liboverlay/overlayLib.cpp | 37 +++++++++++++++++++++++++++++++++--- liboverlay/overlayLib.h | 3 +-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/libhwcomposer/hwcomposer.cpp b/libhwcomposer/hwcomposer.cpp index 50cb9be..5a24a3b 100644 --- a/libhwcomposer/hwcomposer.cpp +++ b/libhwcomposer/hwcomposer.cpp @@ -678,10 +678,9 @@ static void handleHDMIStateChange(hwc_composer_device_t *dev, int externaltype) if(ctx && ctx->mOverlayLibObject) { overlay::Overlay *ovLibObject = ctx->mOverlayLibObject; - ovLibObject->setHDMIStatus(externaltype); if (!externaltype) { - // Close the overlay channels if HDMI is disconnected - ovLibObject->closeChannel(); + // Close the external overlay channels if HDMI is disconnected + ovLibObject->closeExternalChannel(); } } #endif diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index 99fee1c..a17b21c 100755 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -448,6 +448,13 @@ bool Overlay::closeChannel() { return true; } +void Overlay::closeExternalChannel() { + if (objOvCtrlChannel[VG1_PIPE].isChannelUP()) { + objOvCtrlChannel[VG1_PIPE].closeControlChannel(); + objOvDataChannel[VG1_PIPE].closeDataChannel(); + } +} + bool Overlay::getPosition(int& x, int& y, uint32_t& w, uint32_t& h, int channel) { return objOvCtrlChannel[channel].getPosition(x, y, w, h); } @@ -643,16 +650,17 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, // If there is 3D content; the effective format passed by the client is: // effectiveFormat = 3D_IN | 3D_OUT | ColorFormat int newState = mState; - bool stateChange = false, ret = false; + bool stateChange = false, ret = true; + bool isHDMIStateChange = (mHDMIConnected != hdmiConnected) && (mState != -1); unsigned int format3D = getS3DFormat(info.format); int colorFormat = getColorFormat(info.format); - if (-1 == mState) { + if (isHDMIStateChange || -1 == mState) { + // we were mirroring UI. Also HDMI state stored was stale newState = getOverlayConfig (format3D, false, hdmiConnected); stateChange = (mState == newState) ? false : true; } if (stateChange) { - closeChannel(); mHDMIConnected = hdmiConnected; mState = newState; mS3DFormat = format3D; @@ -666,11 +674,18 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, int fbnum = 0; switch(mState) { case OV_2D_VIDEO_ON_PANEL: + if(isHDMIStateChange) { + //close HDMI Only + closeExternalChannel(); + break; + } case OV_3D_VIDEO_2D_PANEL: + closeChannel(); return startChannel(info, FRAMEBUFFER_0, noRot, false, mS3DFormat, VG0_PIPE, waitForVsync, num_buffers); break; case OV_3D_VIDEO_3D_PANEL: + closeChannel(); if (sHDMIAsPrimary) { noRot = true; waitForVsync = true; @@ -685,7 +700,22 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, } break; case OV_2D_VIDEO_ON_TV: + if(isHDMIStateChange) { + //start only HDMI channel + noRot = true; + bool waitForVsync = true; + if(!startChannel(info, FRAMEBUFFER_1, noRot, false, mS3DFormat, + VG1_PIPE, waitForVsync, num_buffers)) { + LOGE("%s:failed to open channel %d", __func__, VG1_PIPE); + return false; + } + overlay_rect rect; + objOvCtrlChannel[VG1_PIPE].getAspectRatioPosition(info.width, + info.height, &rect); + return setChannelPosition(rect.x, rect.y, rect.w, rect.h, VG1_PIPE); + } case OV_3D_VIDEO_2D_TV: + closeChannel(); for (int i=0; i