overlay: Add support for using scalar calculations
Add support for using scalar calculations from custom library.
The calculation will override pipe configurations if required on
basis of format, scaling, split display etc.
Change-Id: I53c73431b70b5b339ad09c19ac8792f0fc96aaaa
diff --git a/liboverlay/Android.mk b/liboverlay/Android.mk
index 560b57f..d8c2ab5 100644
--- a/liboverlay/Android.mk
+++ b/liboverlay/Android.mk
@@ -6,8 +6,12 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes)
-LOCAL_SHARED_LIBRARIES := $(common_libs) libqdutils libmemalloc libsync
+LOCAL_SHARED_LIBRARIES := $(common_libs) libqdutils libmemalloc \
+ libsync libdl
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdoverlay\"
+ifeq ($(TARGET_USES_QSEED_SCALAR),true)
+ LOCAL_CFLAGS += -DUSES_QSEED_SCALAR
+endif
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
LOCAL_SRC_FILES := \
overlay.cpp \
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index b095e9e..9222af5 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -27,16 +27,23 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <dlfcn.h>
#include "overlay.h"
#include "pipes/overlayGenPipe.h"
#include "mdp_version.h"
#include "qdMetaData.h"
+#ifdef USES_QSEED_SCALAR
+#include <scale/scale.h>
+using namespace scale;
+#endif
+
#define PIPE_DEBUG 0
namespace overlay {
using namespace utils;
+
Overlay::Overlay() {
PipeBook::NUM_PIPES = qdutils::MDPVersion::getInstance().getTotalPipes();
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
@@ -44,12 +51,14 @@
}
mDumpStr[0] = '\0';
+ initScalar();
}
Overlay::~Overlay() {
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
mPipeBook[i].destroy();
}
+ destroyScalar();
}
void Overlay::configBegin() {
@@ -60,6 +69,13 @@
}
sForceSetBitmap = 0;
mDumpStr[0] = '\0';
+
+#ifdef USES_QSEED_SCALAR
+ Scale *scalar = getScalar();
+ if(scalar) {
+ scalar->configBegin();
+ }
+#endif
}
void Overlay::configDone() {
@@ -81,6 +97,13 @@
}
dump();
PipeBook::save();
+
+#ifdef USES_QSEED_SCALAR
+ Scale *scalar = getScalar();
+ if(scalar) {
+ scalar->configDone();
+ }
+#endif
}
eDest Overlay::nextPipe(eMdpPipeType type, int dpy, int mixer) {
@@ -381,6 +404,42 @@
}
}
+void Overlay::initScalar() {
+#ifdef USES_QSEED_SCALAR
+ if(sLibScaleHandle == NULL) {
+ sLibScaleHandle = dlopen("libscale.so", RTLD_NOW);
+ }
+
+ if(sLibScaleHandle) {
+ if(sScale == NULL) {
+ Scale* (*getInstance)();
+ *(void **) &getInstance = dlsym(sLibScaleHandle, "getInstance");
+ if(getInstance) {
+ sScale = getInstance();
+ }
+ }
+ }
+#endif
+}
+
+void Overlay::destroyScalar() {
+#ifdef USES_QSEED_SCALAR
+ if(sLibScaleHandle) {
+ if(sScale) {
+ void (*destroyInstance)(Scale*);
+ *(void **) &destroyInstance = dlsym(sLibScaleHandle,
+ "destroyInstance");
+ if(destroyInstance) {
+ destroyInstance(sScale);
+ sScale = NULL;
+ }
+ }
+ dlclose(sLibScaleHandle);
+ sLibScaleHandle = NULL;
+ }
+#endif
+}
+
void Overlay::PipeBook::init() {
mPipe = NULL;
mDisplay = DPY_UNUSED;
@@ -406,5 +465,7 @@
int Overlay::PipeBook::sAllocatedBitmap = 0;
utils::eMdpPipeType Overlay::PipeBook::pipeTypeLUT[utils::OV_MAX] =
{utils::OV_MDP_PIPE_ANY};
+void *Overlay::sLibScaleHandle = NULL;
+scale::Scale *Overlay::sScale = NULL;
}; // namespace overlay
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index c16f6e6..854fa30 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -34,6 +34,9 @@
#include "utils/threads.h"
struct MetaData_t;
+namespace scale {
+class Scale;
+};
namespace overlay {
class GenericPipe;
@@ -111,6 +114,8 @@
static int getFbForDpy(const int& dpy);
static bool displayCommit(const int& fd, const utils::Dim& roi);
static bool displayCommit(const int& fd);
+ /* Returns the scalar object */
+ static scale::Scale *getScalar();
private:
/* Ctor setup */
@@ -118,6 +123,10 @@
/*Validate index range, abort if invalid */
void validate(int index);
void dump() const;
+ /* Creates a scalar object using libscale.so */
+ static void initScalar();
+ /* Destroys the scalar object using libscale.so */
+ static void destroyScalar();
/* Just like a Facebook for pipes, but much less profile info */
struct PipeBook {
@@ -177,6 +186,8 @@
static int sDpyFbMap[DPY_MAX];
static int sDMAMode;
static int sForceSetBitmap;
+ static void *sLibScaleHandle;
+ static scale::Scale *sScale;
};
inline void Overlay::validate(int index) {
@@ -249,6 +260,10 @@
sForceSetBitmap |= (1 << dpy);
}
+inline scale::Scale *Overlay::getScalar() {
+ return sScale;
+}
+
inline bool Overlay::PipeBook::valid() {
return (mPipe != NULL);
}
diff --git a/liboverlay/overlayCtrlData.h b/liboverlay/overlayCtrlData.h
index c3a7aa3..6746792 100644
--- a/liboverlay/overlayCtrlData.h
+++ b/liboverlay/overlayCtrlData.h
@@ -53,7 +53,7 @@
/* dtor close */
~Ctrl();
/* init fd etc*/
- bool init(uint32_t fbnum);
+ bool init(uint32_t dpy);
/* close underlying mdp */
bool close();
@@ -100,7 +100,7 @@
/* calls close */
~Data();
/* init fd etc */
- bool init(uint32_t fbnum);
+ bool init(uint32_t dpy);
/* calls underlying mdp close */
bool close();
/* set overlay pipe id in the mdp struct */
@@ -145,10 +145,10 @@
return true;
}
-inline bool Ctrl::init(uint32_t fbnum) {
+inline bool Ctrl::init(uint32_t dpy) {
// MDP/FD init
- if(!mMdp.init(fbnum)) {
- ALOGE("Ctrl failed to init fbnum=%d", fbnum);
+ if(!mMdp.init(dpy)) {
+ ALOGE("Ctrl failed to init dpy=%d", dpy);
return false;
}
return true;
@@ -239,8 +239,8 @@
inline int Data::getPipeId() const { return mMdp.getPipeId(); }
-inline bool Data::init(uint32_t fbnum) {
- if(!mMdp.init(fbnum)) {
+inline bool Data::init(uint32_t dpy) {
+ if(!mMdp.init(dpy)) {
ALOGE("Data cannot init mdp");
return false;
}
diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp
index 674e62d..b4058bd 100644
--- a/liboverlay/overlayMdp.cpp
+++ b/liboverlay/overlayMdp.cpp
@@ -20,6 +20,12 @@
#include "overlayUtils.h"
#include "overlayMdp.h"
#include "mdp_version.h"
+#include <overlay.h>
+
+#ifdef USES_QSEED_SCALAR
+#include <scale/scale.h>
+using namespace scale;
+#endif
#define HSIC_SETTINGS_DEBUG 0
@@ -39,13 +45,20 @@
namespace ovutils = overlay::utils;
namespace overlay {
-bool MdpCtrl::init(uint32_t fbnum) {
+bool MdpCtrl::init(uint32_t dpy) {
+ int fbnum = Overlay::getFbForDpy(dpy);
+ if( fbnum < 0 ) {
+ ALOGE("%s: Invalid FB for the display: %d",__FUNCTION__, dpy);
+ return false;
+ }
+
// FD init
if(!utils::openDev(mFd, fbnum,
Res::fbPath, O_RDWR)){
ALOGE("Ctrl failed to init fbnum=%d", fbnum);
return false;
}
+ mDpy = dpy;
return true;
}
@@ -57,6 +70,7 @@
mOrientation = utils::OVERLAY_TRANSFORM_0;
mDownscale = 0;
mForceSet = false;
+ mDpy = 0;
#ifdef USES_POST_PROCESSING
mPPChanged = false;
memset(&mParams, 0, sizeof(struct compute_params));
@@ -201,11 +215,22 @@
mdp_wrapper::dump("== Bad OVInfo is: ", mOVInfo);
mdp_wrapper::dump("== Last good known OVInfo is: ", mLkgo);
this->restore();
+#ifdef USES_QSEED_SCALAR
+ if(Overlay::getScalar()) {
+ Overlay::getScalar()->configAbort(mDpy);
+ }
+#endif
return false;
}
this->save();
}
+#ifdef USES_QSEED_SCALAR
+ if(Overlay::getScalar()) {
+ Overlay::getScalar()->configSet(mOVInfo, mDpy, mFd.getFD());
+ }
+#endif
+
return true;
}
@@ -371,4 +396,21 @@
return true;
}
+
+//// MdpData ////////////
+bool MdpData::init(uint32_t dpy) {
+ int fbnum = Overlay::getFbForDpy(dpy);
+ if( fbnum < 0 ) {
+ ALOGE("%s: Invalid FB for the display: %d",__FUNCTION__, dpy);
+ return false;
+ }
+
+ // FD init
+ if(!utils::openDev(mFd, fbnum, Res::fbPath, O_RDWR)){
+ ALOGE("Ctrl failed to init fbnum=%d", fbnum);
+ return false;
+ }
+ return true;
+}
+
} // overlay
diff --git a/liboverlay/overlayMdp.h b/liboverlay/overlayMdp.h
index 5bfec6b..fe4ad69 100644
--- a/liboverlay/overlayMdp.h
+++ b/liboverlay/overlayMdp.h
@@ -39,8 +39,8 @@
explicit MdpCtrl();
/* dtor close */
~MdpCtrl();
- /* init underlying device using fbnum */
- bool init(uint32_t fbnum);
+ /* init underlying device using fbnum for dpy */
+ bool init(uint32_t dpy);
/* unset overlay, reset and close fd */
bool close();
/* reset and set ov id to -1 / MSMFB_NEW_REQUEST */
@@ -132,6 +132,7 @@
OvFD mFd;
int mDownscale;
bool mForceSet;
+ int mDpy;
#ifdef USES_POST_PROCESSING
/* PP Compute Params */
@@ -174,7 +175,7 @@
/* dtor close*/
~MdpData();
/* init FD */
- bool init(uint32_t fbnum);
+ bool init(uint32_t dpy);
/* memset0 the underlying mdp object */
void reset();
/* close fd, and reset */
@@ -395,15 +396,6 @@
inline MdpData::~MdpData() { close(); }
-inline bool MdpData::init(uint32_t fbnum) {
- // FD init
- if(!utils::openDev(mFd, fbnum, Res::fbPath, O_RDWR)){
- ALOGE("Ctrl failed to init fbnum=%d", fbnum);
- return false;
- }
- return true;
-}
-
inline void MdpData::reset() {
overlay::utils::memset0(mOvData);
mOvData.data.memory_id = -1;
diff --git a/liboverlay/pipes/overlayGenPipe.cpp b/liboverlay/pipes/overlayGenPipe.cpp
index 35f686c..06e8257 100644
--- a/liboverlay/pipes/overlayGenPipe.cpp
+++ b/liboverlay/pipes/overlayGenPipe.cpp
@@ -28,7 +28,6 @@
*/
#include "overlayGenPipe.h"
-#include "overlay.h"
#include "mdp_version.h"
namespace overlay {
@@ -47,20 +46,12 @@
ALOGE_IF(DEBUG_OVERLAY, "GenericPipe init");
mRotDownscaleOpt = false;
- int fbNum = Overlay::getFbForDpy(mDpy);
- if( fbNum < 0 ) {
- ALOGE("%s: Invalid FB for the display: %d",__FUNCTION__, mDpy);
- return false;
- }
-
- ALOGD_IF(DEBUG_OVERLAY,"%s: mFbNum:%d",__FUNCTION__, fbNum);
-
- if(!mCtrlData.ctrl.init(fbNum)) {
+ if(!mCtrlData.ctrl.init(mDpy)) {
ALOGE("GenericPipe failed to init ctrl");
return false;
}
- if(!mCtrlData.data.init(fbNum)) {
+ if(!mCtrlData.data.init(mDpy)) {
ALOGE("GenericPipe failed to init data");
return false;
}