void ExternalDisplay::setDpyAttr() { int width = 0, height = 0, fps = 0; getAttrForMode(width, height, fps); if(mHwcContext) { ALOGD("ExtDisplay setting xres = %d, yres = %d", width, height); mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres = width; mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres = height; mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].vsync_period = 1000000000l / fps; } }
void HDMIDisplay::setAttributes() { uint32_t fps = 0; // Always set dpyAttr res to mVInfo res getAttrForMode(mXres, mYres, fps); mMDPScalingMode = false; if(overlay::Overlay::getInstance()->isUIScalingOnExternalSupported() && mMDPDownscaleEnabled) { // if primary resolution is more than the hdmi resolution // configure dpy attr to primary resolution and set MDP // scaling mode // Restrict this upto 1080p resolution max, if target does not // support source split feature. uint32_t primaryArea = mPrimaryWidth * mPrimaryHeight; if(((primaryArea) > (mXres * mYres)) && (((primaryArea) <= SUPPORTED_DOWNSCALE_AREA) || qdutils::MDPVersion::getInstance().isSrcSplit())) { // tmpW and tmpH will hold the primary dimensions before we // update the aspect ratio if necessary. int tmpW = mPrimaryWidth; int tmpH = mPrimaryHeight; // HDMI is always in landscape, so always assign the higher // dimension to hdmi's xres if(mPrimaryHeight > mPrimaryWidth) { tmpW = mPrimaryHeight; tmpH = mPrimaryWidth; } // The aspect ratios of the external and primary displays // can be different. As a result, directly assigning primary // resolution could lead to an incorrect final image. // We get around this by calculating a new resolution by // keeping aspect ratio intact. hwc_rect r = {0, 0, 0, 0}; qdutils::getAspectRatioPosition(tmpW, tmpH, mXres, mYres, r); uint32_t newExtW = r.right - r.left; uint32_t newExtH = r.bottom - r.top; uint32_t alignedExtW; uint32_t alignedExtH; // On 8994 and below targets MDP supports only 4X downscaling, // Restricting selected external resolution to be exactly 4X // greater resolution than actual external resolution uint32_t maxMDPDownScale = qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); if((mXres * mYres * maxMDPDownScale) < (newExtW * newExtH)) { float upScaleFactor = (float)maxMDPDownScale / 2.0f; newExtW = (int)((float)mXres * upScaleFactor); newExtH = (int)((float)mYres * upScaleFactor); } // Align it down so that the new aligned resolution does not // exceed the maxMDPDownscale factor alignedExtW = overlay::utils::aligndown(newExtW, 4); alignedExtH = overlay::utils::aligndown(newExtH, 4); mXres = alignedExtW; mYres = alignedExtH; // Set External Display MDP Downscale mode indicator mMDPScalingMode = true; } } ALOGD_IF(DEBUG_MDPDOWNSCALE, "Selected external resolution [%d X %d] " "maxMDPDownScale %d mMDPScalingMode %d srcSplitEnabled %d " "MDPDownscale feature %d", mXres, mYres, qdutils::MDPVersion::getInstance().getMaxMDPDownscale(), mMDPScalingMode, qdutils::MDPVersion::getInstance().isSrcSplit(), mMDPDownscaleEnabled); mVsyncPeriod = (int) 1000000000l / fps; ALOGD_IF(DEBUG, "%s xres=%d, yres=%d", __FUNCTION__, mXres, mYres); }
void HDMIDisplay::getAttributes(uint32_t& width, uint32_t& height) { uint32_t fps = 0; getAttrForMode(width, height, fps); }