From eee6309c4f11d795bfb921539ffad691857a3f4b Mon Sep 17 00:00:00 2001 From: "Arun Kumar K.R" Date: Tue, 7 Feb 2012 11:32:06 -0800 Subject: [PATCH] qcom/display: fixes for the external overlay channel - During video playback, when the external display is connected, start the overlay channel on the right framebuffer. - set the correct position for the new external display channel - fix minor bug in the function getAspectRatioPosition for external display CRs-fixed: 336674 (cherry picked from commit 6afc95ee1197718332461c8f0ddf9cf5f94cc7aa) Change-Id: Ifa30dfea349c2a0f133790ab2dc91527d53152f8 --- libhwcomposer/hwcomposer.cpp | 3 +- liboverlay/overlayLib.cpp | 61 +++++++++++++++++++++--------------- liboverlay/overlayLib.h | 4 +-- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/libhwcomposer/hwcomposer.cpp b/libhwcomposer/hwcomposer.cpp index 3efcce0..e0c3d00 100644 --- a/libhwcomposer/hwcomposer.cpp +++ b/libhwcomposer/hwcomposer.cpp @@ -288,7 +288,8 @@ static int prepareOverlay(hwc_context_t *ctx, hwc_layer_t *layer, const bool wai int hdmiConnected = 0; #if defined HDMI_DUAL_DISPLAY - hdmiConnected = (int)ctx->mHDMIEnabled; + if(!ctx->pendingHDMI) //makes sure the UI channel is opened first + hdmiConnected = (int)ctx->mHDMIEnabled; #endif ret = ovLibObject->setSource(info, layer->transform, hdmiConnected, waitForVsync); diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index 657f281..dbfebc9 100755 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -416,7 +416,7 @@ int overlay::initOverlay() { return 0; } -Overlay::Overlay() : mChannelUP(false), mHDMIConnected(false), +Overlay::Overlay() : mChannelUP(false), mExternalDisplay(false), mS3DFormat(0), mCroppedSrcWidth(0), mCroppedSrcHeight(0), mState(-1) { mOVBufferInfo.width = mOVBufferInfo.height = 0; @@ -468,7 +468,7 @@ bool Overlay::closeChannel() { return true; if(mS3DFormat) { - if (mHDMIConnected) + if (mExternalDisplay) overlay::send3DInfoPacket(0); else if (mState == OV_3D_VIDEO_3D_PANEL) { if (sHDMIAsPrimary) @@ -692,7 +692,7 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, // effectiveFormat = 3D_IN | 3D_OUT | ColorFormat int newState = mState; bool stateChange = false, ret = true; - bool isHDMIStateChange = (mHDMIConnected != hdmiConnected) && (mState != -1); + bool isHDMIStateChange = (mExternalDisplay != hdmiConnected) && (mState != -1); unsigned int format3D = getS3DFormat(info.format); int colorFormat = getColorFormat(info.format); if (isHDMIStateChange || -1 == mState) { @@ -702,7 +702,7 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, } if (stateChange) { - mHDMIConnected = hdmiConnected; + mExternalDisplay = hdmiConnected; mState = newState; mS3DFormat = format3D; if (mState == OV_3D_VIDEO_2D_PANEL || mState == OV_3D_VIDEO_2D_TV) { @@ -745,15 +745,29 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, //start only HDMI channel noRot = true; bool waitForVsync = true; - if(!startChannel(info, FRAMEBUFFER_1, noRot, false, mS3DFormat, - VG1_PIPE, waitForVsync, num_buffers)) { + // External display connected, start corresponding channel + // mExternalDisplay will hold the fbnum + if(!startChannel(info, mExternalDisplay, 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); + } + int currX, currY; + uint32_t currW, currH; + overlay_rect priDest; + overlay_rect secDest; + objOvCtrlChannel[VG0_PIPE].getPosition(currX, currY, currW, currH); + priDest.x = currX, priDest.y = currY; + priDest.w = currW, priDest.h = currH; + if (FrameBufferInfo::getInstance()->canSupportTrueMirroring()) { + objOvCtrlChannel[VG1_PIPE].getAspectRatioPosition( + mCroppedSrcWidth, mCroppedSrcHeight, mDevOrientation, + &priDest, &secDest); + } else { + objOvCtrlChannel[VG1_PIPE].getAspectRatioPosition( + mCroppedSrcWidth, mCroppedSrcHeight, &secDest); + } + return setChannelPosition(secDest.x, secDest.y, secDest.w, secDest.h, VG1_PIPE); } case OV_3D_VIDEO_2D_TV: closeChannel(); @@ -1042,7 +1056,6 @@ bool OverlayControlChannel::getAspectRatioPosition(int w, int h, int orientation int xPos = 0; int yPos = 0; int tmp = 0; - float actualWidth = fbWidth; overlay_rect rect; switch(orientation) { case MDP_ROT_NOP: @@ -1052,7 +1065,6 @@ bool OverlayControlChannel::getAspectRatioPosition(int w, int h, int orientation yPos = rect.y; fbWidth = rect.w; fbHeight = rect.h; - actualWidth = fbWidth; if(orientation == MDP_ROT_180) { inRect->x = priWidth - (inRect->x + inRect->w); @@ -1061,16 +1073,6 @@ bool OverlayControlChannel::getAspectRatioPosition(int w, int h, int orientation break; case MDP_ROT_90: case MDP_ROT_270: - // Swap width/height for primary - swapWidthHeight(priWidth, priHeight); - //Swap the destination width/height - swapWidthHeight(inRect->w, inRect->h); - getAspectRatioPosition((int)priWidth, (int)priHeight, &rect); - xPos = rect.x; - yPos = rect.y; - fbWidth = rect.w; - actualWidth = fbWidth; - fbHeight = rect.h; if(orientation == MDP_ROT_90) { tmp = inRect->y; inRect->y = priWidth - (inRect->x + inRect->w); @@ -1081,6 +1083,15 @@ bool OverlayControlChannel::getAspectRatioPosition(int w, int h, int orientation inRect->x = priHeight - (inRect->y + inRect->h); inRect->y = tmp; } + //Swap the destination width/height + swapWidthHeight(inRect->w, inRect->h); + // Swap width/height for primary + swapWidthHeight(priWidth, priHeight); + getAspectRatioPosition((int)priWidth, (int)priHeight, &rect); + xPos = rect.x; + yPos = rect.y; + fbWidth = rect.w; + fbHeight = rect.h; break; default: LOGE("In %s: Unknown Orientation", __FUNCTION__); @@ -1092,10 +1103,10 @@ bool OverlayControlChannel::getAspectRatioPosition(int w, int h, int orientation wRatio = inRect->w/priWidth; hRatio = inRect->h/priHeight; - outRect->x = (xRatio * actualWidth) + xPos; + outRect->x = (xRatio * fbWidth) + xPos; outRect->y = (yRatio * fbHeight) + yPos; - outRect->w = (wRatio * actualWidth); + outRect->w = (wRatio * fbWidth); outRect->h = hRatio * fbHeight; LOGD("Calculated AS Position for HDMI: X= %d, y = %d w = %d h = %d", outRect->x, outRect->y,outRect->w, outRect->h); diff --git a/liboverlay/overlayLib.h b/liboverlay/overlayLib.h index 45798bc..353764b 100755 --- a/liboverlay/overlayLib.h +++ b/liboverlay/overlayLib.h @@ -390,8 +390,8 @@ public: class Overlay { bool mChannelUP; - ////stores the connected external display - int mHDMIConnected; + //stores the connected external display Ex: HDMI(1) WFD(2) + int mExternalDisplay; unsigned int mS3DFormat; //Actual cropped source width and height of overlay int mCroppedSrcWidth;