hwc/overlay: Crop x, y, w and h should be even for MDSS Rotator.
MDSS driver requires Rotator crop x, y, w and h to be even for YUV
formats.
CRs-Fixed: 485216
Change-Id: I9a066970f8cedaed7ba18534bb99edd1bcf421dd
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 5df31b0..05bdfb9 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -754,12 +754,23 @@
}
inline int configRotator(Rotator *rot, const Whf& whf,
- const hwc_rect_t& crop, const eMdpFlags& mdpFlags,
+ hwc_rect_t& crop, const eMdpFlags& mdpFlags,
const eTransform& orient, const int& downscale) {
- Dim rotCrop(crop.left, crop.top, (crop.right - crop.left),
- (crop.bottom - crop.top));
+
rot->setSource(whf);
- rot->setCrop(rotCrop);
+
+ if (qdutils::MDPVersion::getInstance().getMDPVersion() >=
+ qdutils::MDSS_V5) {
+ uint32_t crop_w = (crop.right - crop.left);
+ uint32_t crop_h = (crop.bottom - crop.top);
+ ovutils::normalizeCrop((uint32_t&)crop.left, crop_w);
+ ovutils::normalizeCrop((uint32_t&)crop.top, crop_h);
+ crop.right = crop.left + crop_w;
+ crop.bottom = crop.top + crop_h;
+ Dim rotCrop(crop.left, crop.top, crop_w, crop_h);
+ rot->setCrop(rotCrop);
+ }
+
rot->setFlags(mdpFlags);
rot->setTransform(orient);
rot->setDownscale(downscale);
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index db5880a..c65c09a 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -157,7 +157,7 @@
int rotDownscale = 0, int transform = 0);
int configRotator(overlay::Rotator *rot, const ovutils::Whf& whf,
- const hwc_rect_t& crop, const ovutils::eMdpFlags& mdpFlags,
+ hwc_rect_t& crop, const ovutils::eMdpFlags& mdpFlags,
const ovutils::eTransform& orient, const int& downscale);
int configMdp(overlay::Overlay *ov, const ovutils::PipeArgs& parg,
diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp
index 4578115..4c77f2e 100644
--- a/liboverlay/overlayMdp.cpp
+++ b/liboverlay/overlayMdp.cpp
@@ -37,20 +37,6 @@
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,
@@ -189,8 +175,8 @@
doDownscale();
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::normalizeCrop(mOVInfo.src_rect.x, mOVInfo.src_rect.w);
+ utils::normalizeCrop(mOVInfo.src_rect.y, mOVInfo.src_rect.h);
if(mdpVersion < MDSS_V5) {
utils::even_floor(mOVInfo.dst_rect.w);
utils::even_floor(mOVInfo.dst_rect.h);
diff --git a/liboverlay/overlayUtils.cpp b/liboverlay/overlayUtils.cpp
index e595cef..4b81ed3 100644
--- a/liboverlay/overlayUtils.cpp
+++ b/liboverlay/overlayUtils.cpp
@@ -428,6 +428,20 @@
getDump(buf, len, "\tdst", rot.dst);
}
+//Helper to even out x,w and y,h pairs
+//x,y are always evened to ceil and w,h are evened to floor
+void normalizeCrop(uint32_t& xy, uint32_t& wh) {
+ if(xy & 1) {
+ even_ceil(xy);
+ if(wh & 1)
+ even_floor(wh);
+ else
+ wh -= 2;
+ } else {
+ even_floor(wh);
+ }
+}
+
} // utils
} // overlay
diff --git a/liboverlay/overlayUtils.h b/liboverlay/overlayUtils.h
index 0893328..3fa0979 100644
--- a/liboverlay/overlayUtils.h
+++ b/liboverlay/overlayUtils.h
@@ -143,6 +143,7 @@
bool enableBarrier (uint32_t orientation);
uint32_t getS3DFormat(uint32_t fmt);
bool isMdssRotator();
+void normalizeCrop(uint32_t& xy, uint32_t& wh);
template <int CHAN>
bool getPositionS3D(const Whf& whf, Dim& out);