diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp index 0e7a43e..ace66c9 100644 --- a/libgralloc/framebuffer.cpp +++ b/libgralloc/framebuffer.cpp @@ -236,7 +236,7 @@ static void *hdmi_ui_loop(void *ptr) float asWidthRatio = m->actionsafeWidthRatio/100.0f; float asHeightRatio = m->actionsafeHeightRatio/100.0f; bool waitForVsync = true; - + int flags = WAIT_FOR_VSYNC; if (m->pobjOverlay) { Overlay* pTemp = m->pobjOverlay; if (m->hdmiMirroringState == HDMI_NO_MIRRORING) @@ -254,11 +254,11 @@ static void *hdmi_ui_loop(void *ptr) info.size = hnd->size; if (m->trueMirrorSupport) - waitForVsync = false; + flags &= ~WAIT_FOR_VSYNC; // start the overlay Channel for mirroring // m->enableHDMIOutput corresponds to the fbnum if (pTemp->startChannel(info, m->enableHDMIOutput, - false, true, 0, VG0_PIPE, waitForVsync)) { + false, true, 0, VG0_PIPE, flags)) { pTemp->setFd(m->framebuffer->fd); pTemp->setCrop(0, 0, m->info.xres, m->info.yres); } else @@ -365,8 +365,8 @@ static void *hdmi_ui_loop(void *ptr) } if (m->trueMirrorSupport) { // if video is started the UI channel should be NO_WAIT. - waitForVsync = !m->videoOverlay; - pTemp->updateWaitForVsyncFlags(waitForVsync); + flags = !m->videoOverlay ? WAIT_FOR_VSYNC : 0; + pTemp->updateOverlayFlags(flags); } pTemp->queueBuffer(m->currentOffset); } diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index a17b21c..621435e 100755 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -395,7 +395,7 @@ int Overlay::getFBHeight(int channel) const { bool Overlay::startChannel(const overlay_buffer_info& info, int fbnum, bool norot, bool uichannel, unsigned int format3D, int channel, - bool ignoreFB, int num_buffers) { + int flags, int num_buffers) { int zorder = 0; int format = getColorFormat(info.format); mCroppedSrcWidth = info.width; @@ -408,7 +408,7 @@ bool Overlay::startChannel(const overlay_buffer_info& info, int fbnum, mChannelUP = objOvCtrlChannel[channel].startControlChannel(info.width, info.height, format, fbnum, norot, uichannel, - format3D, zorder, ignoreFB); + format3D, zorder, flags); if (!mChannelUP) { LOGE("startChannel for fb%d failed", fbnum); return mChannelUP; @@ -543,22 +543,13 @@ bool Overlay::setChannelPosition(int x, int y, uint32_t w, uint32_t h, int chann } bool Overlay::updateOverlaySource(const overlay_buffer_info& info, int orientation, - bool waitForVsync) { + int flags) { bool ret = false; int currentFlags = 0; - if (objOvCtrlChannel[0].isChannelUP()) { - currentFlags = objOvCtrlChannel[0].getOverlayFlags(); - } bool needUpdateFlags = false; - if (waitForVsync) { - if (currentFlags & MDP_OV_PLAY_NOWAIT) { - needUpdateFlags = true; - } - } else { - if (!(currentFlags & MDP_OV_PLAY_NOWAIT)) { - needUpdateFlags = true; - } + if (objOvCtrlChannel[0].isChannelUP()) { + needUpdateFlags = objOvCtrlChannel[0].doFlagsNeedUpdate(flags); } bool geometryChanged = true; @@ -581,10 +572,9 @@ bool Overlay::updateOverlaySource(const overlay_buffer_info& info, int orientati int orientPrimary = sHDMIAsPrimary ? 0 : orientation; int orient[2] = {orientPrimary, orientHdmi}; // disable waitForVsync on HDMI, since we call the wait ioctl - bool waitForHDMI = false; - bool waitForPrimary = sHDMIAsPrimary ? true : waitForVsync; - bool waitCond[2] = {waitForPrimary, waitForHDMI}; - + int ovFlagsExternal = 0; + int ovFlagsPrimary = sHDMIAsPrimary ? (flags |= WAIT_FOR_VSYNC): flags; + int ovFlags[2] = {flags, ovFlagsExternal}; switch(mState) { case OV_3D_VIDEO_3D_PANEL: orient[1] = sHDMIAsPrimary ? 0 : orientation; @@ -601,14 +591,14 @@ bool Overlay::updateOverlaySource(const overlay_buffer_info& info, int orientati // Only update the primary channel - we only need to update the // wait/no-wait flags if (objOvCtrlChannel[0].isChannelUP()) { - return objOvCtrlChannel[0].updateWaitForVsyncFlags(waitForVsync); + return objOvCtrlChannel[0].updateOverlayFlags(flags); } } // Set the overlay source info for (int i = 0; i < NUM_CHANNELS; i++) { if (objOvCtrlChannel[i].isChannelUP()) { - ret = objOvCtrlChannel[i].updateOverlaySource(info, orient[i], waitCond[i]); + ret = objOvCtrlChannel[i].updateOverlaySource(info, orient[i], ovFlags[i]); if (!ret) { LOGE("objOvCtrlChannel[%d].updateOverlaySource failed", i); return false; @@ -645,7 +635,7 @@ int Overlay::getS3DFormat(int format) { } bool Overlay::setSource(const overlay_buffer_info& info, int orientation, - int hdmiConnected, bool waitForVsync, int num_buffers) { + int hdmiConnected, int flags, int num_buffers) { // Separate the color format from the 3D format. // If there is 3D content; the effective format passed by the client is: // effectiveFormat = 3D_IN | 3D_OUT | ColorFormat @@ -682,18 +672,18 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, case OV_3D_VIDEO_2D_PANEL: closeChannel(); return startChannel(info, FRAMEBUFFER_0, noRot, false, - mS3DFormat, VG0_PIPE, waitForVsync, num_buffers); + mS3DFormat, VG0_PIPE, flags, num_buffers); break; case OV_3D_VIDEO_3D_PANEL: closeChannel(); if (sHDMIAsPrimary) { noRot = true; - waitForVsync = true; + flags |= WAIT_FOR_VSYNC; send3DInfoPacket(mS3DFormat & OUTPUT_MASK_3D); } for (int i=0; icanSupportTrueMirroring()) - flags &= ~MDP_OV_PIPE_SHARE; + flags &= ~OVERLAY_PIPE_SHARE; if (!openDevices(fbnum)) return false; @@ -1364,7 +1408,7 @@ bool OverlayControlChannel::startControlChannel(int w, int h, ovBufInfo.width = w; ovBufInfo.height = h; ovBufInfo.format = hw_format; - if (!setOverlayInformation(ovBufInfo, flags, orientation, zorder, ignoreFB, NEW_REQUEST)) + if (!setOverlayInformation(ovBufInfo, orientation, zorder, flags, NEW_REQUEST)) return false; return startOVRotatorSessions(ovBufInfo, orientation, NEW_REQUEST); @@ -1402,12 +1446,17 @@ bool OverlayControlChannel::closeControlChannel() { return true; } -bool OverlayControlChannel::updateWaitForVsyncFlags(bool waitForVsync) { - if (!waitForVsync) +bool OverlayControlChannel::updateOverlayFlags(int flags) { + if ((flags & WAIT_FOR_VSYNC) == 0) mOVInfo.flags |= MDP_OV_PLAY_NOWAIT; else mOVInfo.flags &= ~MDP_OV_PLAY_NOWAIT; + if (flags & DISABLE_FRAMEBUFFER_FETCH) + mOVInfo.is_fg = 1; + else + mOVInfo.is_fg = 0; + if (ioctl(mFD, MSMFB_OVERLAY_SET, &mOVInfo)) { LOGE("%s: OVERLAY_SET failed", __FUNCTION__); dump(mOVInfo); @@ -1906,11 +1955,11 @@ bool OverlayDataChannel::queue(uint32_t offset) { #if 0 bool OverlayDataChannel::waitForHdmiVsync() { if (!isChannelUP()) { - reportError("waitForHdmiVsync: channel not up"); + LOGE("%s: channel not up", __FUNCTION__); return false; } if (ioctl(mFD, MSMFB_OVERLAY_PLAY_WAIT, &mOvData)) { - reportError("waitForHdmiVsync: MSMFB_OVERLAY_PLAY_WAIT failed"); + LOGE("%s: MSMFB_OVERLAY_PLAY_WAIT failed", __FUNCTION__); return false; } return true; diff --git a/liboverlay/overlayLib.h b/liboverlay/overlayLib.h index 51ee09e..06ea381 100755 --- a/liboverlay/overlayLib.h +++ b/liboverlay/overlayLib.h @@ -84,6 +84,15 @@ enum { NEW_REQUEST, UPDATE_REQUEST }; + +enum { + WAIT_FOR_VSYNC = 1<<0, + DISABLE_FRAMEBUFFER_FETCH = 1<<1, + INTERLACED_CONTENT = 1<<2, + OVERLAY_PIPE_SHARE = 1<<3, + SECURE_OVERLAY_SESSION = 1<<4, +}; + /* ------------------------------- 3D defines ---------------------------------------*/ // The compound format passed to the overlay is // ABCCC where A is the input 3D format, @@ -297,11 +306,12 @@ enum { bool mIsChannelUpdated; bool openDevices(int fbnum = -1); bool setOverlayInformation(const overlay_buffer_info& info, - int flags, int orientation, int zorder = 0, bool ignoreFB = false, + int orientation, int zorder = 0, int flags = 0, int requestType = NEW_REQUEST); bool startOVRotatorSessions(const overlay_buffer_info& info, int orientation, int requestType); void swapOVRotWidthHeight(); int commitVisualParam(int8_t paramType, float paramValue); + void setInformationFromFlags(int flags, mdp_overlay& ov); public: OverlayControlChannel(); @@ -310,7 +320,7 @@ public: int fbnum, bool norot = false, bool uichannel = false, unsigned int format3D = 0, int zorder = 0, - bool ignoreFB = false); + int flags = 0); bool closeControlChannel(); bool setPosition(int x, int y, uint32_t w, uint32_t h); bool setTransform(int value, bool fetch = true); @@ -324,18 +334,18 @@ public: int getFBHeight() const { return mFBHeight; } int getFormat3D() const { return mFormat3D; } bool getOrientation(int& orientation) const; - bool updateWaitForVsyncFlags(bool waitForVsync); + bool updateOverlayFlags(int flags); bool getAspectRatioPosition(int w, int h, overlay_rect *rect); // Calculates the aspect ratio for video on HDMI based on primary // aspect ratio used in case of true mirroring bool getAspectRatioPosition(int w, int h, int orientation, overlay_rect *inRect, overlay_rect *outRect); bool getPositionS3D(int channel, int format, overlay_rect *rect); - bool updateOverlaySource(const overlay_buffer_info& info, int orientation, bool waitForVsync); + bool updateOverlaySource(const overlay_buffer_info& info, int orientation, int flags); bool getFormat() const { return mFormat; } bool setVisualParam(int8_t paramType, float paramValue); bool useVirtualFB (); - int getOverlayFlags() const { return mOVInfo.flags; } + bool doFlagsNeedUpdate(int flags); }; class OverlayDataChannel { @@ -408,7 +418,7 @@ public: static bool sHDMIAsPrimary; bool startChannel(const overlay_buffer_info& info, int fbnum, bool norot = false, bool uichannel = false, unsigned int format3D = 0, - int channel = 0, bool ignoreFB = false, + int channel = 0, int flags = 0, int num_buffers = 2); bool closeChannel(); bool setDeviceOrientation(int orientation); @@ -424,9 +434,9 @@ public: bool getOrientation(int& orientation, int channel = 0) const; bool queueBuffer(buffer_handle_t buffer); bool setSource(const overlay_buffer_info& info, int orientation, int hdmiConnected, - bool ignoreFB = false, int numBuffers = 2); + int flags, int numBuffers = 2); bool setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h); - bool updateWaitForVsyncFlags(bool waitForVsync); + bool updateOverlayFlags(int flags); void setVisualParam(int8_t paramType, float paramValue); bool waitForHdmiVsync(int channel); int getChannelStatus() const { return (mChannelUP ? OVERLAY_CHANNEL_UP: OVERLAY_CHANNEL_DOWN); } @@ -436,7 +446,7 @@ private: bool setChannelPosition(int x, int y, uint32_t w, uint32_t h, int channel = 0); bool setChannelCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h, int channel); bool queueBuffer(int fd, uint32_t offset, int channel); - bool updateOverlaySource(const overlay_buffer_info& info, int orientation, bool waitForVsync); + bool updateOverlaySource(const overlay_buffer_info& info, int orientation, int flags); int getS3DFormat(int format); };