hwc/overlay: Get rot dest dimensions instead of manipulating source
Currently for Mdss rotator we manipulate the layer buffer dimensions
to be equal to what rotator's destination dimensions would be, so that
these could be fed to MDP. Instead, this patch introduces APIs in
rotator so that hwc can directly query destination crop, width, height,
format from rotator.
This also simplifies the updateSource() and configRotator() helpers.
Change-Id: I501d998f2e0574683c764af9422742b2426ba0c7
diff --git a/liboverlay/overlayMdpRot.cpp b/liboverlay/overlayMdpRot.cpp
index f456029..bb985d7 100755
--- a/liboverlay/overlayMdpRot.cpp
+++ b/liboverlay/overlayMdpRot.cpp
@@ -19,6 +19,7 @@
#include "overlayUtils.h"
#include "overlayRotator.h"
+#include "gr.h"
namespace ovutils = overlay::utils;
@@ -47,6 +48,24 @@
return mRotImgInfo.dst.format;
}
+//Added for completeness. Not expected to be called.
+utils::Whf MdpRot::getDstWhf() const {
+ int alW = 0, alH = 0;
+ int halFormat = ovutils::getHALFormat(mRotImgInfo.dst.format);
+ getBufferSizeAndDimensions(mRotImgInfo.dst.width, mRotImgInfo.dst.height,
+ halFormat, alW, alH);
+ return utils::Whf(alW, alH, mRotImgInfo.dst.format);
+}
+
+//Added for completeness. Not expected to be called.
+utils::Dim MdpRot::getDstDimensions() const {
+ int alW = 0, alH = 0;
+ int halFormat = ovutils::getHALFormat(mRotImgInfo.dst.format);
+ getBufferSizeAndDimensions(mRotImgInfo.dst.width, mRotImgInfo.dst.height,
+ halFormat, alW, alH);
+ return utils::Dim(0, 0, alW, alH);
+}
+
uint32_t MdpRot::getSessId() const { return mRotImgInfo.session_id; }
void MdpRot::setDownscale(int ds) {
diff --git a/liboverlay/overlayMdssRot.cpp b/liboverlay/overlayMdssRot.cpp
index f7bc87a..5783dcb 100644
--- a/liboverlay/overlayMdssRot.cpp
+++ b/liboverlay/overlayMdssRot.cpp
@@ -63,6 +63,21 @@
return mRotInfo.src.format;
}
+utils::Whf MdssRot::getDstWhf() const {
+ //For Mdss dst_rect itself represents buffer dimensions. We ignore actual
+ //aligned values during buffer allocation. Also the driver overwrites the
+ //src.format field if destination format is different.
+ //This implementation detail makes it possible to retrieve w,h even before
+ //buffer allocation, which happens in queueBuffer.
+ return utils::Whf(mRotInfo.dst_rect.w, mRotInfo.dst_rect.h,
+ mRotInfo.src.format);
+}
+
+utils::Dim MdssRot::getDstDimensions() const {
+ return utils::Dim(mRotInfo.dst_rect.x, mRotInfo.dst_rect.y,
+ mRotInfo.dst_rect.w, mRotInfo.dst_rect.h);
+}
+
uint32_t MdssRot::getSessId() const { return mRotInfo.id; }
bool MdssRot::init() {
@@ -82,16 +97,10 @@
}
void MdssRot::setCrop(const utils::Dim& crop) {
-
mRotInfo.src_rect.x = crop.x;
mRotInfo.src_rect.y = crop.y;
mRotInfo.src_rect.w = crop.w;
mRotInfo.src_rect.h = crop.h;
-
- mRotInfo.dst_rect.x = 0;
- mRotInfo.dst_rect.y = 0;
- mRotInfo.dst_rect.w = crop.w;
- mRotInfo.dst_rect.h = crop.h;
}
void MdssRot::setDownscale(int /*ds*/) {
@@ -119,7 +128,22 @@
}
bool MdssRot::commit() {
+ if (utils::isYuv(mRotInfo.src.format)) {
+ utils::normalizeCrop(mRotInfo.src_rect.x, mRotInfo.src_rect.w);
+ utils::normalizeCrop(mRotInfo.src_rect.y, mRotInfo.src_rect.h);
+ // For interlaced, crop.h should be 4-aligned
+ if ((mRotInfo.flags & utils::OV_MDP_DEINTERLACE) and
+ (mRotInfo.src_rect.h % 4))
+ mRotInfo.src_rect.h = utils::aligndown(mRotInfo.src_rect.h, 4);
+ }
+
+ mRotInfo.dst_rect.x = 0;
+ mRotInfo.dst_rect.y = 0;
+ mRotInfo.dst_rect.w = mRotInfo.src_rect.w;
+ mRotInfo.dst_rect.h = mRotInfo.src_rect.h;
+
doTransform();
+
mRotInfo.flags |= MDSS_MDP_ROT_ONLY;
mEnabled = true;
if(!overlay::mdp_wrapper::setOverlay(mFd.getFD(), mRotInfo)) {
diff --git a/liboverlay/overlayRotator.h b/liboverlay/overlayRotator.h
index e0f542c..64387cd 100644
--- a/liboverlay/overlayRotator.h
+++ b/liboverlay/overlayRotator.h
@@ -74,9 +74,14 @@
virtual void setTransform(const utils::eTransform& rot) = 0;
virtual bool commit() = 0;
virtual void setDownscale(int ds) = 0;
+ //Mem id and offset should be retrieved only after rotator kickoff
virtual int getDstMemId() const = 0;
virtual uint32_t getDstOffset() const = 0;
+ //Destination width, height, format, position should be retrieved only after
+ //rotator configuration is committed via commit API
virtual uint32_t getDstFormat() const = 0;
+ virtual utils::Whf getDstWhf() const = 0;
+ virtual utils::Dim getDstDimensions() const = 0;
virtual uint32_t getSessId() const = 0;
virtual bool queueBuffer(int fd, uint32_t offset) = 0;
virtual void dump() const = 0;
@@ -112,6 +117,8 @@
virtual int getDstMemId() const;
virtual uint32_t getDstOffset() const;
virtual uint32_t getDstFormat() const;
+ virtual utils::Whf getDstWhf() const;
+ virtual utils::Dim getDstDimensions() const;
virtual uint32_t getSessId() const;
virtual bool queueBuffer(int fd, uint32_t offset);
virtual void dump() const;
@@ -169,6 +176,8 @@
virtual int getDstMemId() const;
virtual uint32_t getDstOffset() const;
virtual uint32_t getDstFormat() const;
+ virtual utils::Whf getDstWhf() const;
+ virtual utils::Dim getDstDimensions() const;
virtual uint32_t getSessId() const;
virtual bool queueBuffer(int fd, uint32_t offset);
virtual void dump() const;
diff --git a/liboverlay/overlayUtils.h b/liboverlay/overlayUtils.h
index 2fcc4ef..530377b 100644
--- a/liboverlay/overlayUtils.h
+++ b/liboverlay/overlayUtils.h
@@ -543,6 +543,14 @@
value--;
}
+/* Prerotation adjusts crop co-ordinates to the new transformed values within
+ * destination buffer. This is necessary only when the entire buffer is rotated
+ * irrespective of crop (A-family). If only the crop portion of the buffer is
+ * rotated into a destination buffer matching the size of crop, we don't need to
+ * use this helper (B-family).
+ * @Deprecated as of now, retained for the case where a full buffer needs
+ * transform and also as a reference.
+ */
void preRotateSource(const eTransform& tr, Whf& whf, Dim& srcCrop);
void getDump(char *buf, size_t len, const char *prefix, const mdp_overlay& ov);
void getDump(char *buf, size_t len, const char *prefix, const msmfb_img& ov);