overlay: rotator: Remove previous allocation for a session
When ION was not ref counted, we needed to maintain the previous
session memory until the new one was taken by MDP. ION being
ref counted now, it is not necessary to maintain previous memory
allocation.
Change-Id: I102df065bb288a661d509912f4c7b894505df393
diff --git a/liboverlay/overlayMdssRot.cpp b/liboverlay/overlayMdssRot.cpp
index 083e507..ce9d9d5 100644
--- a/liboverlay/overlayMdssRot.cpp
+++ b/liboverlay/overlayMdssRot.cpp
@@ -134,30 +134,21 @@
mRotData.data.memory_id = fd;
mRotData.data.offset = offset;
- remap(RotMem::Mem::ROT_NUM_BUFS);
- OVASSERT(mMem.curr().m.numBufs(), "queueBuffer numbufs is 0");
+ if(false == remap(RotMem::ROT_NUM_BUFS)) {
+ ALOGE("%s Remap failed, not queuing", __FUNCTION__);
+ return false;
+ }
mRotData.dst_data.offset =
- mMem.curr().mRotOffset[mMem.curr().mCurrOffset];
- mMem.curr().mCurrOffset =
- (mMem.curr().mCurrOffset + 1) % mMem.curr().m.numBufs();
+ mMem.mRotOffset[mMem.mCurrIndex];
+ mMem.mCurrIndex =
+ (mMem.mCurrIndex + 1) % mMem.mem.numBufs();
if(!overlay::mdp_wrapper::play(mFd.getFD(), mRotData)) {
ALOGE("MdssRot play failed!");
dump();
return false;
}
-
- // if the prev mem is valid, we need to close
- if(mMem.prev().valid()) {
- // FIXME if no wait for vsync the above
- // play will return immediatly and might cause
- // tearing when prev.close is called.
- if(!mMem.prev().close()) {
- ALOGE("%s error in closing prev rot mem", __FUNCTION__);
- return false;
- }
- }
}
return true;
}
@@ -179,7 +170,7 @@
mRotData.dst_data.memory_id = mem.getFD();
mRotData.dst_data.offset = 0;
- mMem.curr().m = mem;
+ mMem.mem = mem;
return true;
}
@@ -187,23 +178,27 @@
// Calculate the size based on rotator's dst format, w and h.
uint32_t opBufSize = calcOutputBufSize();
// If current size changed, remap
- if(opBufSize == mMem.curr().size()) {
+ if(opBufSize == mMem.size()) {
ALOGE_IF(DEBUG_OVERLAY, "%s: same size %d", __FUNCTION__, opBufSize);
return true;
}
ALOGE_IF(DEBUG_OVERLAY, "%s: size changed - remapping", __FUNCTION__);
- OVASSERT(!mMem.prev().valid(), "Prev should not be valid");
- // ++mMem will make curr to be prev, and prev will be curr
- ++mMem;
+ if(!mMem.close()) {
+ ALOGE("%s error in closing prev rot mem", __FUNCTION__);
+ return false;
+ }
+
if(!open_i(numbufs, opBufSize)) {
ALOGE("%s Error could not open", __FUNCTION__);
return false;
}
+
for (uint32_t i = 0; i < numbufs; ++i) {
- mMem.curr().mRotOffset[i] = i * opBufSize;
+ mMem.mRotOffset[i] = i * opBufSize;
}
+
return true;
}
@@ -234,17 +229,15 @@
ovutils::memset0(mRotData);
mRotData.data.memory_id = -1;
mRotInfo.id = MSMFB_NEW_REQUEST;
- ovutils::memset0(mMem.curr().mRotOffset);
- ovutils::memset0(mMem.prev().mRotOffset);
- mMem.curr().mCurrOffset = 0;
- mMem.prev().mCurrOffset = 0;
+ ovutils::memset0(mMem.mRotOffset);
+ mMem.mCurrIndex = 0;
mOrientation = utils::OVERLAY_TRANSFORM_0;
}
void MdssRot::dump() const {
ALOGE("== Dump MdssRot start ==");
mFd.dump();
- mMem.curr().m.dump();
+ mMem.mem.dump();
mdp_wrapper::dump("mRotInfo", mRotInfo);
mdp_wrapper::dump("mRotData", mRotData);
ALOGE("== Dump MdssRot end ==");