summaryrefslogtreecommitdiff
authorsky zhou <sky.zhou@amlogic.com>2020-03-06 15:55:57 (GMT)
committer sky zhou <sky.zhou@amlogic.com>2020-05-21 11:01:26 (GMT)
commitf7caa15bfb315dbcfae282c99c3022408b6a4ebe (patch)
tree5ae70d1772ebbe3306e568ccceef7fc14d6e1604
parent22293984a60832ea5c29186e63aba7d29bd450df (diff)
downloadhwcomposer-f7caa15bfb315dbcfae282c99c3022408b6a4ebe.zip
hwcomposer-f7caa15bfb315dbcfae282c99c3022408b6a4ebe.tar.gz
hwcomposer-f7caa15bfb315dbcfae282c99c3022408b6a4ebe.tar.bz2
display: read panel info from lcd instead of vout. [2/2]
PD#SWPL-21855 Problem: hwc cannot get panel info before set display mode. Solution: read from /sys/class/lcd/vinfo to get panel info. Verify: verify on 905x3 Change-Id: I2b5fd5a38533d636da7dd211f955464ea155e8de Signed-off-by: sky zhou <sky.zhou@amlogic.com> Signed-off-by: Tianhua Sun <tianhua.sun@amlogic.com>
Diffstat
-rw-r--r--common/display/ConnectorPanel.cpp112
-rw-r--r--common/display/ConnectorPanel.h11
2 files changed, 110 insertions, 13 deletions
diff --git a/common/display/ConnectorPanel.cpp b/common/display/ConnectorPanel.cpp
index 71dab19..b60ca99 100644
--- a/common/display/ConnectorPanel.cpp
+++ b/common/display/ConnectorPanel.cpp
@@ -12,12 +12,19 @@
#include <MesonLog.h>
#include "AmFramebuffer.h"
#include "AmVinfo.h"
+#include <string>
+#include <systemcontrol.h>
#define DV_SUPPORT_INFO_LEN_MAX (40)
ConnectorPanel::ConnectorPanel(int32_t drvFd, uint32_t id)
: HwDisplayConnector(drvFd, id) {
- snprintf(mName, 64, "Panel-%d", id);
+ parseLcdInfo();
+ if (mTabletMode) {
+ snprintf(mName, 64, "Tablet-%d", id);
+ } else {
+ snprintf(mName, 64, "TV-%d", id);
+ }
}
ConnectorPanel::~ConnectorPanel() {
@@ -54,27 +61,106 @@ bool ConnectorPanel::isSecure(){
return true;
}
-int32_t ConnectorPanel::loadDisplayModes() {
- mDisplayModes.clear();
+int32_t ConnectorPanel::parseLcdInfo() {
+ /*
+ typical info:
+ "lcd vinfo:\n"
+ " lcd_mode: %s\n"
+ " name: %s\n"
+ " mode: %d\n"
+ " width: %d\n"
+ " height: %d\n"
+ " field_height: %d\n"
+ " aspect_ratio_num: %d\n"
+ " aspect_ratio_den: %d\n"
+ " sync_duration_num: %d\n"
+ " sync_duration_den: %d\n"
+ " screen_real_width: %d\n"
+ " screen_real_height: %d\n"
+ " htotal: %d\n"
+ " vtotal: %d\n"
+ " fr_adj_type: %d\n"
+ " video_clk: %d\n"
+ " viu_color_fmt: %d\n"
+ " viu_mux: %d\n\n",
+ */
+
+ const char * lcdInfoPath = "/sys/class/lcd/vinfo";
+ const int valLenMax = 64;
+ std::string lcdInfo;
+
+ if (sc_read_sysfs(lcdInfoPath, lcdInfo) == 0 &&
+ lcdInfo.size() > 0) {
+ // MESON_LOGD("Lcdinfo:(%s)", lcdInfo.c_str());
+
+ std::size_t lineStart = 0;
+
+ /*parse lcd mode*/
+ const char * modeStr = " lcd_mode: ";
+ lineStart = lcdInfo.find(modeStr);
+ lineStart += strlen(modeStr);
+ std::string valStr = lcdInfo.substr(lineStart, valLenMax);
+ MESON_LOGD("lcd_mode: value [%s]", valStr.c_str());
+ if (valStr.find("tablet", 0) != std::string::npos) {
+ mTabletMode = true;
+ } else {
+ mTabletMode = false;
+ }
- std::string dispmode;
- vmode_e vmode = VMODE_MAX;
- if (NULL != mCrtc) {
- mCrtc->readCurDisplayMode(dispmode);
- vmode = vmode_name_to_mode(dispmode.c_str());
+ if (mTabletMode) {
+ /*parse display info mode*/
+ const char * infoPrefix[] = {
+ " width:",
+ " height:",
+ " sync_duration_num:",
+ " sync_duration_den:",
+ };
+ const int infoValueIdx[] = {
+ LCD_WIDTH,
+ LCD_HEIGHT,
+ LCD_SYNC_DURATION_NUM,
+ LCD_SYNC_DURATION_DEN,
+ };
+ static int infoNum = sizeof(infoValueIdx) / sizeof(int);
+
+ MESON_LOGD("------------Lcdinfo parse start------------\n");
+ for (int i = 0; i < infoNum; i ++) {
+ lineStart = lcdInfo.find(infoPrefix[i], lineStart);
+ lineStart += strlen(infoPrefix[i]);
+ std::string valStr = lcdInfo.substr(lineStart, valLenMax);
+ mLcdValues[infoValueIdx[i]] = (uint32_t)std::stoul(valStr);
+ MESON_LOGD("[%s] : [%d]\n", infoPrefix[i], mLcdValues[infoValueIdx[i]]);
+ }
+ MESON_LOGD("------------Lcdinfo parse end------------\n");
+ }
+ } else {
+ MESON_LOGE("parseLcdInfo ERROR.");
}
- if (vmode == VMODE_MAX) {
+ return 0;
+}
+
+int32_t ConnectorPanel::loadDisplayModes() {
+ mDisplayModes.clear();
+
+ if (mTabletMode) {
drm_mode_info_t modeInfo = {
"panel",
DEFAULT_DISPLAY_DPI,
DEFAULT_DISPLAY_DPI,
- 1920,
- 1080,
- 60};
+ mLcdValues[LCD_WIDTH],
+ mLcdValues[LCD_HEIGHT],
+ (float)mLcdValues[LCD_SYNC_DURATION_NUM]/mLcdValues[LCD_SYNC_DURATION_DEN]};
mDisplayModes.emplace(mDisplayModes.size(), modeInfo);
- MESON_LOGE("use default value,get display mode: %s", dispmode.c_str());
+ MESON_LOGE("use default value,get display mode: %s", modeInfo.name);
} else {
+ std::string dispmode;
+ vmode_e vmode = VMODE_MAX;
+ if (NULL != mCrtc) {
+ mCrtc->readCurDisplayMode(dispmode);
+ vmode = vmode_name_to_mode(dispmode.c_str());
+ }
+
addDisplayMode(dispmode);
//for tv display mode.
diff --git a/common/display/ConnectorPanel.h b/common/display/ConnectorPanel.h
index 1af02c4..266d35b 100644
--- a/common/display/ConnectorPanel.h
+++ b/common/display/ConnectorPanel.h
@@ -31,6 +31,17 @@ public:
protected:
int32_t loadDisplayModes();
int32_t parseHdrCapabilities();
+ int32_t parseLcdInfo();
+
+ enum {
+ LCD_WIDTH = 0,
+ LCD_HEIGHT,
+ LCD_SYNC_DURATION_NUM,
+ LCD_SYNC_DURATION_DEN,
+ LCD_VALUE_MAX
+ };
+ bool mTabletMode;
+ uint32_t mLcdValues[LCD_VALUE_MAX];
char mName[64];