Merge "display: Clean up binder interface"
diff --git a/libqdutils/mdp_version.cpp b/libqdutils/mdp_version.cpp
index 1850801..0809fd0 100644
--- a/libqdutils/mdp_version.cpp
+++ b/libqdutils/mdp_version.cpp
@@ -27,9 +27,6 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cutils/log.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <linux/fb.h>
#include <linux/msm_mdp.h>
#include "mdp_version.h"
@@ -42,81 +39,33 @@
MDPVersion::MDPVersion()
{
- int fb_fd = open("/dev/graphics/fb0", O_RDWR);
- char panel_type = 0;
- struct fb_fix_screeninfo fb_finfo;
-
- mMDPVersion = MDP_V_UNKNOWN;
+ mMDPVersion = MDSS_V5;
mMdpRev = 0;
mRGBPipes = 0;
mVGPipes = 0;
mDMAPipes = 0;
mFeatures = 0;
mMDPUpscale = 0;
- //TODO get this from driver, default for A-fam to 8
- mMDPDownscale = 8;
- mFd = fb_fd;
+ mMDPDownscale = 0;
+ mPanelType = NO_PANEL;
- if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fb_finfo) < 0) {
- ALOGE("FBIOGET_FSCREENINFO failed");
- } else {
- if(!strncmp(fb_finfo.id, "msmfb", 5)) {
- char str_ver[4] = { 0 };
- memcpy(str_ver, &fb_finfo.id[5], 3);
- str_ver[3] = '\0';
- mMDPVersion = atoi(str_ver);
- //Normalize MDP version to ease comparison.
- //This is needed only because
- //MDP 3.0.3 reports value as 303 which
- //is more than all the others
- if (mMDPVersion < 100)
- mMDPVersion *= 10;
-
- mRGBPipes = mVGPipes = 2;
-
- } else if (!strncmp(fb_finfo.id, "mdssfb", 6)) {
- mMDPVersion = MDSS_V5;
- if(!updateSysFsInfo()) {
- ALOGE("Unable to read updateSysFsInfo");
- }
- if (mMdpRev == MDP_V3_0_4){
- mMDPVersion = MDP_V3_0_4;
- }
- }
-
- /* Assumes panel type is 2nd element in '_' delimited id string */
- char * ptype = strstr(fb_finfo.id, "_");
- if (!ptype || (*(++ptype) == '\0')) {
- ALOGE("Invalid framebuffer info string: %s", fb_finfo.id);
- ptype = fb_finfo.id;
- }
- panel_type = *ptype;
+ if(!updatePanelInfo()) {
+ ALOGE("Unable to read Primary Panel Information");
}
- mPanelType = panel_type;
+ if(!updateSysFsInfo()) {
+ ALOGE("Unable to read display sysfs node");
+ }
+ if (mMdpRev == MDP_V3_0_4){
+ mMDPVersion = MDP_V3_0_4;
+ }
+
mHasOverlay = false;
if((mMDPVersion >= MDP_V4_0) ||
(mMDPVersion == MDP_V_UNKNOWN) ||
(mMDPVersion == MDP_V3_0_4))
mHasOverlay = true;
- if(mMDPVersion >= MDSS_V5) {
- char split[64] = {0};
- FILE* fp = fopen("/sys/class/graphics/fb0/msm_fb_split", "r");
- if(fp){
- //Format "left right" space as delimiter
- if(fread(split, sizeof(char), 64, fp)) {
- mSplit.mLeft = atoi(split);
- ALOGI_IF(mSplit.mLeft, "Left Split=%d", mSplit.mLeft);
- char *rght = strpbrk(split, " ");
- if(rght)
- mSplit.mRight = atoi(rght + 1);
- ALOGI_IF(rght, "Right Split=%d", mSplit.mRight);
- }
- } else {
- ALOGE("Failed to open mdss_fb_split node");
- }
-
- if(fp)
- fclose(fp);
+ if(!updateSplitInfo()) {
+ ALOGE("Unable to read display split node");
}
}
@@ -140,7 +89,39 @@
*idx = index;
return 0;
}
+// This function reads the sysfs node to read the primary panel type
+// and updates information accordingly
+bool MDPVersion::updatePanelInfo() {
+ FILE *displayDeviceFP = NULL;
+ const int MAX_FRAME_BUFFER_NAME_SIZE = 128;
+ char fbType[MAX_FRAME_BUFFER_NAME_SIZE];
+ const char *strCmdPanel = "mipi dsi cmd panel";
+ const char *strVideoPanel = "mipi dsi video panel";
+ const char *strLVDSPanel = "lvds panel";
+ const char *strEDPPanel = "edp panel";
+ displayDeviceFP = fopen("/sys/class/graphics/fb0/msm_fb_type", "r");
+ if(displayDeviceFP){
+ fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE,
+ displayDeviceFP);
+ if(strncmp(fbType, strCmdPanel, strlen(strCmdPanel)) == 0) {
+ mPanelType = MIPI_CMD_PANEL;
+ }
+ else if(strncmp(fbType, strVideoPanel, strlen(strVideoPanel)) == 0) {
+ mPanelType = MIPI_VIDEO_PANEL;
+ }
+ else if(strncmp(fbType, strLVDSPanel, strlen(strLVDSPanel)) == 0) {
+ mPanelType = LVDS_PANEL;
+ }
+ else if(strncmp(fbType, strEDPPanel, strlen(strEDPPanel)) == 0) {
+ mPanelType = EDP_PANEL;
+ }
+ fclose(displayDeviceFP);
+ return true;
+ }else {
+ return false;
+ }
+}
// This function reads the sysfs node to read MDP capabilities
// and parses and updates information accordingly.
@@ -213,6 +194,33 @@
return true;
}
+// This function reads the sysfs node to read MDP capabilities
+// and parses and updates information accordingly.
+bool MDPVersion::updateSplitInfo() {
+ if(mMDPVersion >= MDSS_V5) {
+ char split[64] = {0};
+ FILE* fp = fopen("/sys/class/graphics/fb0/msm_fb_split", "r");
+ if(fp){
+ //Format "left right" space as delimiter
+ if(fread(split, sizeof(char), 64, fp)) {
+ mSplit.mLeft = atoi(split);
+ ALOGI_IF(mSplit.mLeft, "Left Split=%d", mSplit.mLeft);
+ char *rght = strpbrk(split, " ");
+ if(rght)
+ mSplit.mRight = atoi(rght + 1);
+ ALOGI_IF(mSplit.mRight, "Right Split=%d", mSplit.mRight);
+ }
+ } else {
+ ALOGE("Failed to open mdss_fb_split node");
+ return false;
+ }
+ if(fp)
+ fclose(fp);
+ }
+ return true;
+}
+
+
bool MDPVersion::supportsDecimation() {
return mFeatures & MDP_DECIMATION_EN;
}
diff --git a/libqdutils/mdp_version.h b/libqdutils/mdp_version.h
index b995582..1e1e35e 100644
--- a/libqdutils/mdp_version.h
+++ b/libqdutils/mdp_version.h
@@ -38,6 +38,10 @@
*/
using namespace android;
namespace qdutils {
+// These panel definitions are available at mdss_mdp.h which is internal header
+// file and is not available at <linux/mdss_mdp.h>.
+// ToDo: once it is available at linux/mdss_mdp.h, these below definitions can
+// be removed.
enum mdp_version {
MDP_V_UNKNOWN = 0,
MDP_V2_2 = 220,
@@ -65,6 +69,7 @@
MAX_DISPLAY_DIM = 2048,
};
+#define NO_PANEL '0'
#define MDDI_PANEL '1'
#define EBI2_PANEL '2'
#define LCDC_PANEL '3'
@@ -75,6 +80,7 @@
#define MIPI_CMD_PANEL '9'
#define WRITEBACK_PANEL 'a'
#define LVDS_PANEL 'b'
+#define EDP_PANEL 'c'
class MDPVersion;
@@ -109,6 +115,8 @@
int getRightSplit() { return mSplit.right(); }
private:
bool updateSysFsInfo();
+ bool updatePanelInfo();
+ bool updateSplitInfo();
int tokenizeParams(char *inputParams, const char *delim,
char* tokenStr[], int *idx);
int mFd;