diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp index e020a59..35235e1 100644 --- a/liboverlay/overlayMdp.cpp +++ b/liboverlay/overlayMdp.cpp @@ -23,6 +23,21 @@ namespace ovutils = overlay::utils; namespace overlay { + +//Helper to even out x,w and y,h pairs +//x,y are always evened to ceil and w,h are evened to floor +static void normalizeCrop(uint32_t& xy, uint32_t& wh) { + if(xy & 1) { + utils::even_ceil(xy); + if(wh & 1) + utils::even_floor(wh); + else + wh -= 2; + } else { + utils::even_floor(wh); + } +} + bool MdpCtrl::init(uint32_t fbnum) { // FD init if(!utils::openDev(mFd, fbnum, @@ -127,6 +142,14 @@ void MdpCtrl::doTransform() { bool MdpCtrl::set() { //deferred calcs, so APIs could be called in any order. doTransform(); + utils::Whf whf = getSrcWhf(); + if(utils::isYuv(whf.format)) { + normalizeCrop(mOVInfo.src_rect.x, mOVInfo.src_rect.w); + normalizeCrop(mOVInfo.src_rect.y, mOVInfo.src_rect.h); + utils::even_floor(mOVInfo.dst_rect.w); + utils::even_floor(mOVInfo.dst_rect.h); + } + if(this->ovChanged()) { if(!mdp_wrapper::setOverlay(mFd.getFD(), mOVInfo)) { ALOGE("MdpCtrl failed to setOverlay, restoring last known " @@ -138,6 +161,7 @@ bool MdpCtrl::set() { } this->save(); } + return true; } diff --git a/liboverlay/overlayUtils.h b/liboverlay/overlayUtils.h index bdc9eee..a4b9d6e 100644 --- a/liboverlay/overlayUtils.h +++ b/liboverlay/overlayUtils.h @@ -540,8 +540,11 @@ inline bool isYuv(uint32_t format) { case MDP_Y_CBCR_H2V1: case MDP_Y_CBCR_H2V2: case MDP_Y_CRCB_H2V2: + case MDP_Y_CRCB_H1V1: + case MDP_Y_CRCB_H2V1: case MDP_Y_CRCB_H2V2_TILE: case MDP_Y_CBCR_H2V2_TILE: + case MDP_Y_CR_CB_H2V2: return true; default: return false; @@ -812,6 +815,18 @@ inline void ScreenInfo::dump(const char* const s) const { s, mFBWidth, mFBHeight, mFBbpp, mFBystride); } +template +inline void even_ceil(T& value) { + if(value & 1) + value++; +} + +template +inline void even_floor(T& value) { + if(value & 1) + value--; +} + } // namespace utils ends //--------------------Class Res stuff (namespace overlay only) -----------