liboverlay: Refactor, bug-fixes, upgrade.
* Fix memory leak during copying pipe objects.
* Remove unused / unnecessary code.
* setMemoryId API is merged with queueBuffer.
* setParameter API is setTransform now.
* Rotator upgraded to:
--Allow different rotator hardware types.
--Remove dependency on MDP code.
--Allocate memory only during first playback,
close when the associated pipe is closed.
* Have single commit implementation.
* Include new format types.
* Remove WAIT and CHANNEL enums and usage. Replace BypassPipe with
GenericPipe. Client expected to set alignments and parameters.
Add transform combination enums.
* Allow APIs to be called in any order. Do transform calcs in commit.
Move ext type setter and getter functions.
* Add calculations for 180 transform.
* Add secure session support in rotator
* Implement all rotations in terms of H flip, V flip and 90 rotation.
Change-Id: I34a9a2a0f1255b3467a0abbaa254d0b584e901ce
diff --git a/liboverlay/overlayUtils.cpp b/liboverlay/overlayUtils.cpp
index 38e3ab2..8c9ca99 100644
--- a/liboverlay/overlayUtils.cpp
+++ b/liboverlay/overlayUtils.cpp
@@ -70,7 +70,7 @@
namespace overlay {
//----------From class Res ------------------------------
-const char* const Res::devTemplate = "/dev/graphics/fb%u";
+const char* const Res::fbPath = "/dev/graphics/fb%u";
const char* const Res::rotPath = "/dev/msm_rotator";
const char* const Res::format3DFile =
"/sys/class/graphics/fb1/format_3d";
@@ -92,7 +92,7 @@
OvFD mFd;
// Use open defined in overlayFD file to open fd for fb0
- if(!overlay::open(mFd, 0, Res::devTemplate)) {
+ if(!overlay::open(mFd, 0, Res::fbPath)) {
ALOGE("FrameBufferInfo: failed to open fd");
return;
}
@@ -146,41 +146,6 @@
}
//--------------------------------------------------------
-uint32_t getSize(const Whf& whf) {
- int aligned_height=0, pitch=0;
-
- uint32_t size = whf.w * whf.h;
- switch (whf.format) {
- case MDP_RGBA_8888:
- case MDP_BGRA_8888:
- case MDP_RGBX_8888:
- size *= 4;
- break;
- case MDP_RGB_565:
- case MDP_Y_CBCR_H2V1:
- size *= 2;
- break;
- case MDP_Y_CBCR_H2V2:
- case MDP_Y_CRCB_H2V2:
- size = (size * 3) / 2;
- break;
- case MDP_Y_CRCB_H2V2_TILE:
- case MDP_Y_CBCR_H2V2_TILE:
- aligned_height = align(whf.h , 32);
- pitch = align(whf.w, 128);
- size = pitch * aligned_height;
- size = align(size, 8192);
-
- aligned_height = align(whf.h >> 1, 32);
- size += pitch * aligned_height;
- size = align(size, 8192);
- break;
- default:
- ALOGE("getSize unknown format %d", whf.format);
- return 0;
- }
- return size;
-}
int getMdpFormat(int format) {
switch (format) {
@@ -205,18 +170,25 @@
case HAL_PIXEL_FORMAT_YV12:
return MDP_Y_CR_CB_H2V2;
default:
- ALOGE("Error getMdpFormat format=%d", format);
+ ALOGE("Error getMdpFormat format=0x%x", format);
return -1;
}
// not reached
return -1;
}
-bool isHDMIConnected () {
- char value[PROPERTY_VALUE_MAX] = {0};
- property_get("hw.hdmiON", value, "0");
- int isHDMI = atoi(value);
- return isHDMI ? true : false;
+//Set by client as HDMI/WFD
+void setExtType(const int& type) {
+ if(type != HDMI && type != WFD) {
+ ALOGE("%s: Unrecognized type %d", __func__, type);
+ return;
+ }
+ sExtType = type;
+}
+
+//Return External panel type set by client.
+int getExtType() {
+ return sExtType;
}
bool is3DTV() {
@@ -229,7 +201,7 @@
bool isPanel3D() {
OvFD fd;
- if(!overlay::open(fd, 0 /*fb*/, Res::devTemplate)){
+ if(!overlay::open(fd, 0 /*fb*/, Res::fbPath)){
ALOGE("isPanel3D Can't open framebuffer 0");
return false;
}
@@ -299,39 +271,6 @@
return fmt3D;
}
-void normalizeCrop(uint32_t& xy, uint32_t& wh) {
- if (xy & 0x0001) {
- // x or y is odd, increment it's value
- xy += 1;
- // Since we've incremented x(y), we need to decrement
- // w(h) accordingly
- if (wh & 0x0001) {
- // w or h is odd, decrement it by 1, to make it even
- even_out(wh);
- } else {
- // w(h) is already even, hence we decrement by 2
- wh -=2;
- }
- } else {
- even_out(wh);
- }
-}
-
-void scale(mdp_overlay& ov)
-{
- /* Scaling of upto a max of 8 times supported */
- overlay::utils::Dim dst(overlay::utils::getDstRectDim(ov));
- overlay::utils::Dim src(overlay::utils::getSrcRectDim(ov));
- if(dst.w >(src.w * overlay::utils::HW_OV_MAGNIFICATION_LIMIT)) {
- dst.w = overlay::utils::HW_OV_MAGNIFICATION_LIMIT * src.w;
- }
- if(dst.h >(src.h * overlay::utils::HW_OV_MAGNIFICATION_LIMIT)) {
- dst.h = overlay::utils::HW_OV_MAGNIFICATION_LIMIT * src.h;
- }
-
- setDstRectDim(dst, ov);
-}
-
} // utils
} // overlay