From e2de425bc44ef4983c4b43721f2e64bba41162a5 Mon Sep 17 00:00:00 2001 From: Naomi Luis Date: Mon, 28 Nov 2011 15:29:08 -0800 Subject: [PATCH] Display: Set WAIT on primary and NO_WAIT on HDMI When queuing buffers using the overlay: - Set the NO_WAIT flag for the HDMI channel. - Set the WAIT flag for the primary channel. - Queue the buffer on the HDMI first. - Queue the buffer on the primary. - Wait for the HDMI Vsync. Change-Id: Id24e9551230b7a7134bd21a7b3a9e8658f7de222 --- libhwcomposer/hwcomposer.cpp | 2 +- liboverlay/overlayLib.cpp | 30 ++++++++++++++++++++++++++---- liboverlay/overlayLib.h | 2 ++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libhwcomposer/hwcomposer.cpp b/libhwcomposer/hwcomposer.cpp index 8a5676f..6fa6b41 100755 --- a/libhwcomposer/hwcomposer.cpp +++ b/libhwcomposer/hwcomposer.cpp @@ -768,7 +768,7 @@ static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) { continue; } if (hnd && (hnd->bufferType == BUFFER_TYPE_VIDEO) && (yuvBufferCount == 1)) { - bool waitForVsync = skipComposition ? true:false; + bool waitForVsync = true; if (!isValidDestination(hwcModule->fbDevice, list->hwLayers[i].displayFrame)) { list->hwLayers[i].compositionType = HWC_FRAMEBUFFER; #ifdef USE_OVERLAY diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index c468c4e..5245fc2 100755 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -466,8 +466,8 @@ bool Overlay::updateOverlaySource(const overlay_buffer_info& info, int orientati int orientHdmi = 0; int orientPrimary = sHDMIAsPrimary ? 0 : orientation; int orient[2] = {orientPrimary, orientHdmi}; - // enable waitForVsync on HDMI - bool waitForHDMI = true; + // disable waitForVsync on HDMI, since we call the wait ioctl + bool waitForHDMI = false; bool waitForPrimary = sHDMIAsPrimary ? true : waitForVsync; bool waitCond[2] = {waitForPrimary, waitForHDMI}; @@ -582,7 +582,7 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, if (FRAMEBUFFER_1 == i) { // Disable rotation for HDMI noRot = true; - waitForVsync = true; + waitForVsync = false; } if(!startChannel(info, i, noRot, false, mS3DFormat, i, waitForVsync, num_buffers)) { @@ -715,6 +715,10 @@ bool Overlay::queueBuffer(uint32_t offset, int channel) { return objOvDataChannel[channel].queueBuffer(offset); } +bool Overlay::waitForHdmiVsync(int channel) { + return objOvDataChannel[channel].waitForHdmiVsync(); +} + bool Overlay::queueBuffer(buffer_handle_t buffer) { private_handle_t const* hnd = reinterpret_cast (buffer); @@ -737,12 +741,17 @@ bool Overlay::queueBuffer(buffer_handle_t buffer) { case OV_3D_VIDEO_3D_PANEL: case OV_3D_VIDEO_2D_TV: case OV_3D_VIDEO_3D_TV: - for (int i=0; i=0; i--) { if(!queueBuffer(fd, offset, i)) { LOGE("%s:failed for channel %d", __FUNCTION__, i); return false; } } + //Wait for HDMI done.. + if(!waitForHdmiVsync(VG1_PIPE)) { + LOGE("%s: waitforHdmiVsync failed", __FUNCTION__); + return false; + } break; default: LOGE("%s:Unknown state %d", __FUNCTION__, mState); @@ -1608,6 +1617,19 @@ bool OverlayDataChannel::queue(uint32_t offset) { reportError("overlay play failed."); return false; } + + return true; +} + +bool OverlayDataChannel::waitForHdmiVsync() { + if (!isChannelUP()) { + reportError("waitForHdmiVsync: channel not up"); + return false; + } + if (ioctl(mFD, MSMFB_OVERLAY_PLAY_WAIT, &mOvData)) { + reportError("waitForHdmiVsync: MSMFB_OVERLAY_PLAY_WAIT failed"); + return false; + } return true; } diff --git a/liboverlay/overlayLib.h b/liboverlay/overlayLib.h index aebb075..0a502ea 100755 --- a/liboverlay/overlayLib.h +++ b/liboverlay/overlayLib.h @@ -250,6 +250,7 @@ public: bool closeDataChannel(); bool setFd(int fd); bool queueBuffer(uint32_t offset); + bool waitForHdmiVsync(); bool setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h); bool getCropS3D(overlay_rect *inRect, int channel, int format, overlay_rect *rect); bool isChannelUP() const { return (mFD > 0); } @@ -297,6 +298,7 @@ public: bool setSource(const overlay_buffer_info& info, int orientation, bool hdmiConnected, bool ignoreFB = false, int numBuffers = 2); bool setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h); + bool waitForHdmiVsync(int channel); int getChannelStatus() const { return (mChannelUP ? OVERLAY_CHANNEL_UP: OVERLAY_CHANNEL_DOWN); } void setHDMIStatus (bool isHDMIConnected) { mHDMIConnected = isHDMIConnected; mState = -1; } int getHDMIStatus() const {return (mHDMIConnected ? HDMI_ON : HDMI_OFF); }