liboverlay: Adjust values to align with MDP requirement
For YUV only: Crop rectangle (src_rect) needs to be even for x/y and w/h Destination dst_rect w/h need to be even (x/y can be odd). Change-Id: Ib0c1b7d31773e71d60f080b4beacaa68e32a990e
This commit is contained in:
parent
cefb36db5c
commit
4796f2588d
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 <class T>
|
||||
inline void even_ceil(T& value) {
|
||||
if(value & 1)
|
||||
value++;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void even_floor(T& value) {
|
||||
if(value & 1)
|
||||
value--;
|
||||
}
|
||||
|
||||
} // namespace utils ends
|
||||
|
||||
//--------------------Class Res stuff (namespace overlay only) -----------
|
||||
|
Loading…
Reference in New Issue
Block a user