hwc: support WFD external display
Change-Id: I3d24ff1757e79c4b41ff6c6db17d0274cd665671
(cherry picked from commit f8942672226a7af26218aa8d325c1677ae2b83dd)
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index 7b7719c..04deee5 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -220,6 +220,7 @@
}
Overlay* Overlay::sInstance = 0;
+int Overlay::sExtFbIndex = 1;
int Overlay::PipeBook::NUM_PIPES = 0;
int Overlay::PipeBook::sPipeUsageBitmap = 0;
int Overlay::PipeBook::sLastUsageBitmap = 0;
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 523e3f7..2378889 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -31,6 +31,7 @@
#define OVERLAY_H
#include "overlayUtils.h"
+#include "utils/threads.h"
namespace overlay {
class GenericPipe;
@@ -72,6 +73,10 @@
static Overlay* getInstance();
/* Returns total of available ("unallocated") pipes */
static int availablePipes();
+ /* set the framebuffer index for external display */
+ void setExtFbNum(int fbNum);
+ /* Returns framebuffer index of the current external display */
+ int getExtFbNum();
private:
/* Ctor setup */
@@ -130,8 +135,11 @@
/* Dump string */
char mDumpStr[256];
+ mutable android::Mutex mOvExtFbLock;
+
/* Singleton Instance*/
static Overlay *sInstance;
+ static int sExtFbIndex;
};
inline void Overlay::validate(int index) {
@@ -145,6 +153,16 @@
return PipeBook::availablePipes();
}
+inline void Overlay::setExtFbNum(int fbNum) {
+ android::Mutex::Autolock lock(mOvExtFbLock);
+ sExtFbIndex = fbNum;
+}
+
+inline int Overlay::getExtFbNum() {
+ android::Mutex::Autolock lock(mOvExtFbLock);
+ return sExtFbIndex;
+}
+
inline int Overlay::PipeBook::availablePipes() {
int used = 0;
int bmp = sAllocatedBitmap;
diff --git a/liboverlay/pipes/overlayGenPipe.cpp b/liboverlay/pipes/overlayGenPipe.cpp
index ecb3b16..9f08c14 100644
--- a/liboverlay/pipes/overlayGenPipe.cpp
+++ b/liboverlay/pipes/overlayGenPipe.cpp
@@ -28,6 +28,7 @@
*/
#include "overlayGenPipe.h"
+#include "overlay.h"
namespace overlay {
@@ -44,6 +45,10 @@
{
ALOGE_IF(DEBUG_OVERLAY, "GenericPipe init");
mRotUsed = false;
+ if(mFbNum)
+ mFbNum = Overlay::getInstance()->getExtFbNum();
+
+ ALOGD_IF(DEBUG_OVERLAY,"%s: mFbNum:%d",__FUNCTION__, mFbNum);
if(!mCtrlData.ctrl.init(mFbNum)) {
ALOGE("GenericPipe failed to init ctrl");