void ExternalDisplay::setExternalDisplay(int connected) { hwc_context_t* ctx = mHwcContext; if(ctx) { ALOGD_IF(DEBUG, "%s: status = %d", __FUNCTION__, connected); if(connected) { readResolution(); //Get the best mode and set // TODO: Move this to activate setResolution(getBestMode()); setDpyAttr(); //enable hdmi vsync } else { // Disable the hdmi vsync closeFrameBuffer(); resetInfo(); } // Store the external display mExternalDisplay = connected; const char* prop = (connected) ? "1" : "0"; // set system property property_set("hw.hdmiON", prop); } return; }
void ExternalDisplay::processUEventOnline(const char *str) { const char *s1 = str + (strlen(str)-strlen(DEVICE_NODE_FB1)); // check if it is for FB1 if(strncmp(s1,DEVICE_NODE_FB1, strlen(DEVICE_NODE_FB1))== 0) { if(isHDMIConfigured()) { // HDMI connect event. // Tear-down WFD if it is active. if(mExternalDisplay == EXTERN_DISPLAY_FB2) { closeFrameBuffer(); setExternalDisplay(EXTERN_DISPLAY_NONE); triggerRefresh(); } } readResolution(); //Get the best mode and set setResolution(getBestMode()); enableHDMIVsync(EXTERN_DISPLAY_FB1); setExternalDisplay(EXTERN_DISPLAY_FB1); triggerRefresh(); } else if(strncmp(s1, DEVICE_NODE_FB2, strlen(DEVICE_NODE_FB2)) == 0) { // WFD connect event if(mExternalDisplay == EXTERN_DISPLAY_FB1) { // HDMI has higher priority. // Do Not Override. }else { // WFD is connected openFrameBuffer(EXTERN_DISPLAY_FB2); setExternalDisplay(EXTERN_DISPLAY_FB2); triggerRefresh(); } } }
int HDMIDisplay::configure() { if(!openFrameBuffer()) { ALOGE("%s: Failed to open FB: %d", __FUNCTION__, mFbNum); return -1; } readCEUnderscanInfo(); readResolution(); // TODO: Move this to activate /* Used for changing the resolution * getUserMode will get the preferred * mode set thru adb shell */ mCurrentMode = getUserMode(); if (mCurrentMode == -1) { //Get the best mode and set mCurrentMode = getBestMode(); } setAttributes(); // set system property property_set("hw.hdmiON", "1"); // Read the system property to determine if downscale feature is enabled. char value[PROPERTY_VALUE_MAX]; mMDPDownscaleEnabled = false; if(property_get("sys.hwc.mdp_downscale_enabled", value, "false") && !strcmp(value, "true")) { mMDPDownscaleEnabled = true; } return 0; }
void ExtDisplayObserver::handleUEvent(char* str){ int connected = 0; // TODO: check for fb2(WFD) driver also if(!strcasestr(str, DEVICE_NODE)) { ALOGD_IF(EXT_OBSERVER_DEBUG, "%s: Not Ext Disp Event ", __FUNCTION__); return; } // Event will be of the form: // change@/devices/virtual/graphics/fb1 ACTION=change // DEVPATH=/devices/virtual/graphics/fb1 // SUBSYSTEM=graphics HDCP_STATE=FAIL MAJOR=29 // for now just parse the online or offline are important for us. if(!(strncmp(str,"online@",strlen("online@")))) { ALOGD_IF(EXT_OBSERVER_DEBUG, "%s: external disp online", __FUNCTION__); connected = 1; readResolution(); //Get the best mode and set // TODO: DO NOT call this for WFD setResolution(getBestMode()); } else if(!(strncmp(str,"offline@",strlen("offline@")))) { ALOGD_IF(EXT_OBSERVER_DEBUG, "%s: external disp online", __FUNCTION__); connected = 0; close(fd); } setExternalDisplayStatus(connected); }
int ExternalDisplay::configureHDMIDisplay() { openFrameBuffer(mHdmiFbNum); if(mFd == -1) return -1; readCEUnderscanInfo(); readResolution(); // TODO: Move this to activate /* Used for changing the resolution * getUserMode will get the preferred * mode set thru adb shell */ int mode = getUserMode(); if (mode == -1) { //Get the best mode and set mode = getBestMode(); } setResolution(mode); setDpyHdmiAttr(); setExternalDisplay(true, mHdmiFbNum); return 0; }