From ed35d42ee4f4da6f199cca268bcf7c33c5c43e45 Mon Sep 17 00:00:00 2001 From: "Arun Kumar K.R" Date: Thu, 31 Mar 2011 20:27:26 -0700 Subject: [PATCH] liboverlay: Always use rotator for UI mirroring on HDMI - Use rotator buffer for UI mirroring on HDMI - Avoid ioctl calls on getPosition CRs-fixed: 278858 Change-Id: Id390e2b85fe939d8388ed17f5f9c7fcd30499755 --- libgralloc-qsd8k/framebuffer.cpp | 15 ++++++++++----- libgralloc-qsd8k/gralloc_priv.h | 2 ++ liboverlay/overlay.cpp | 2 +- liboverlay/overlayLib.cpp | 23 ++++++++++------------- liboverlay/overlayLib.h | 2 ++ 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/libgralloc-qsd8k/framebuffer.cpp b/libgralloc-qsd8k/framebuffer.cpp index 5fbb5ad..f27ea5f 100644 --- a/libgralloc-qsd8k/framebuffer.cpp +++ b/libgralloc-qsd8k/framebuffer.cpp @@ -163,6 +163,7 @@ static void *disp_loop(void *ptr) pthread_mutex_lock(&m->overlayLock); m->orientation = neworientation; m->currentOffset = offset; + m->hdmiStateChanged = true; pthread_cond_signal(&(m->overlayPost)); pthread_mutex_unlock(&m->overlayLock); #endif @@ -210,7 +211,9 @@ static void *hdmi_ui_loop(void *ptr) ptr); while (1) { pthread_mutex_lock(&m->overlayLock); - pthread_cond_wait(&(m->overlayPost), &(m->overlayLock)); + while(!(m->hdmiStateChanged)) + pthread_cond_wait(&(m->overlayPost), &(m->overlayLock)); + m->hdmiStateChanged = false; if (m->exitHDMIUILoop) { pthread_mutex_unlock(&m->overlayLock); return NULL; @@ -226,7 +229,7 @@ static void *hdmi_ui_loop(void *ptr) if (!pTemp->isChannelUP()) { int alignedW = ALIGN(m->info.xres, 32); if (pTemp->startChannel(alignedW, m->info.yres, - m->fbFormat, 1, false, true)) { + m->fbFormat, 1, false, true, 0, VG0_PIPE, true)) { pTemp->setFd(m->framebuffer->fd); pTemp->setCrop(0, 0, m->info.xres, m->info.yres); } else @@ -312,11 +315,10 @@ static void *hdmi_ui_loop(void *ptr) break; } } - int currentOrientation = 0; - pTemp->getOrientation(currentOrientation); - if(rot != currentOrientation) { + if(rot != m->currentOrientation) { pTemp->setParameter(OVERLAY_TRANSFORM, rot); + m->currentOrientation = rot; } EVEN_OUT(asX); EVEN_OUT(asY); @@ -348,6 +350,7 @@ static int fb_videoOverlayStarted(struct framebuffer_device_t* dev, int started) pthread_mutex_lock(&m->overlayLock); Overlay* pTemp = m->pobjOverlay; if(started != m->videoOverlay) { + m->hdmiStateChanged = true; if (started && pTemp) { pTemp->closeChannel(); m->videoOverlay = true; @@ -371,6 +374,7 @@ static int fb_enableHDMIOutput(struct framebuffer_device_t* dev, int enable) if (!enable && pTemp) pTemp->closeChannel(); m->enableHDMIOutput = enable; + m->hdmiStateChanged = true; pthread_cond_signal(&(m->overlayPost)); pthread_mutex_unlock(&m->overlayLock); return 0; @@ -809,6 +813,7 @@ int mapFrameBufferLocked(struct private_module_t* module) module->pobjOverlay = new Overlay(); module->currentOffset = 0; module->exitHDMIUILoop = false; + module->hdmiStateChanged = false; pthread_t hdmiUIThread; pthread_create(&hdmiUIThread, NULL, &hdmi_ui_loop, (void *) module); #endif diff --git a/libgralloc-qsd8k/gralloc_priv.h b/libgralloc-qsd8k/gralloc_priv.h index 72160a1..04a15ce 100755 --- a/libgralloc-qsd8k/gralloc_priv.h +++ b/libgralloc-qsd8k/gralloc_priv.h @@ -235,6 +235,8 @@ struct private_module_t { bool exitHDMIUILoop; float actionsafeWidthRatio; float actionsafeHeightRatio; + int currentOrientation; + bool hdmiStateChanged; pthread_mutex_t overlayLock; pthread_cond_t overlayPost; #endif diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp index f97827d..aa2b524 100644 --- a/liboverlay/overlay.cpp +++ b/liboverlay/overlay.cpp @@ -173,7 +173,7 @@ public: mHandle.pobjControlChannel[index] = new OverlayControlChannel(); } bool ret = mHandle.pobjControlChannel[index]->startControlChannel( - mHandle.w, mHandle.h, mHandle.format, fbnum, norot, + mHandle.w, mHandle.h, mHandle.format, fbnum, norot, false, format3D, zorder, true); if (ret) { if (!(mHandle.pobjControlChannel[index]-> diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index af6a07c..08b5bc4 100644 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -164,7 +164,7 @@ bool Overlay::startChannel(int w, int h, int format, int fbnum, if (format3D) zorder = channel; mChannelUP = objOvCtrlChannel[channel].startControlChannel(w, h, format, fbnum, - norot, format3D, zorder, ignoreFB); + norot, uichannel, format3D, zorder, ignoreFB); if (!mChannelUP) { LOGE("startChannel for fb%d failed", fbnum); return mChannelUP; @@ -295,7 +295,6 @@ bool Overlay::setSource(uint32_t w, uint32_t h, int format, int orientation, int stateChanged = 0; int hw_format = get_mdp_format(colorFormat); - bool uichannel = isRGBType(hw_format); int s3dChanged =0, hdmiChanged = 0; if (format3D != mS3DFormat) @@ -322,7 +321,7 @@ bool Overlay::setSource(uint32_t w, uint32_t h, int format, int orientation, } } else { return startChannel(w, h, colorFormat, 0, !orientation, - uichannel, 0, VG0_PIPE, ignoreFB, num_buffers); + false, 0, VG0_PIPE, ignoreFB, num_buffers); } } else @@ -646,6 +645,8 @@ bool OverlayControlChannel::startOVRotatorSessions(int w, int h, mRotInfo.src_rect.y = 0; mRotInfo.rotations = 0; mRotInfo.enable = 0; + if(mUIChannel) + mRotInfo.enable = 1; mRotInfo.session_id = 0; int result = ioctl(mRotFD, MSM_ROTATOR_IOCTL_START, &mRotInfo); if (result) { @@ -676,9 +677,11 @@ bool OverlayControlChannel::startOVRotatorSessions(int w, int h, bool OverlayControlChannel::startControlChannel(int w, int h, int format, int fbnum, bool norot, + bool uichannel, unsigned int format3D, int zorder, bool ignoreFB) { mNoRot = norot; + mUIChannel = uichannel; fb_fix_screeninfo finfo; fb_var_screeninfo vinfo; int hw_format; @@ -940,7 +943,9 @@ bool OverlayControlChannel::setParameter(int param, int value, bool fetch) { else { if(mRotInfo.src.format == MDP_Y_CRCB_H2V2_TILE) mOVInfo.src.format = MDP_Y_CRCB_H2V2_TILE; - mRotInfo.enable = 0; + mRotInfo.enable = 0; + if(mUIChannel) + mRotInfo.enable = 1; } if (ioctl(mRotFD, MSM_ROTATOR_IOCTL_START, &mRotInfo)) { reportError("setParameter, rotator start failed"); @@ -965,15 +970,7 @@ bool OverlayControlChannel::getPosition(int& x, int& y, uint32_t& w, uint32_t& h) { if (!isChannelUP()) return false; - - mdp_overlay ov; - ov.id = mOVInfo.id; - if (ioctl(mFD, MSMFB_OVERLAY_GET, &ov)) { - reportError("getPosition, overlay GET failed"); - return false; - } - mOVInfo = ov; - + //mOVInfo has the current Overlay Position x = mOVInfo.dst_rect.x; y = mOVInfo.dst_rect.y; w = mOVInfo.dst_rect.w; diff --git a/liboverlay/overlayLib.h b/liboverlay/overlayLib.h index fed1d59..4551b51 100644 --- a/liboverlay/overlayLib.h +++ b/liboverlay/overlayLib.h @@ -96,6 +96,7 @@ class OverlayControlChannel { int mSize; int mOrientation; unsigned int mFormat3D; + bool mUIChannel; mdp_overlay mOVInfo; msm_rotator_img_info mRotInfo; bool openDevices(int fbnum = -1); @@ -109,6 +110,7 @@ public: ~OverlayControlChannel(); bool startControlChannel(int w, int h, int format, int fbnum, bool norot = false, + bool uichannel = false, unsigned int format3D = 0, int zorder = 0, bool ignoreFB = false); bool closeControlChannel();