hwc: Trigger dynamic refresh-rate change for more usecases

* Until now it's been the case that refresh-rates were set to
the standard values of 24, 30, 48 and 60 for video playback
usecases. Since of the most panel vendors can only support
refresh-rates above 45, in many of the use-cases with fps < 45,
dynamic change in panel refresh rate doesn't happen.

* To address this, following are the changes done:
    1. Refresh-rate will no longer be limited to standard values
    for video-playback usecases and any value above the
    minfpsSupported which is advertised by the mdss driver will
    be considered.
    2. If the fps of the use-case is 'x' and it falls less than
    minfpsSupported, a multiple of it 'k*x' will be considered as
    the new refresh-rate, provided k*x < 60. If
    abs(k*x - stdRefreshRate) < 2, set the refresh-rate to the
    standard value rather than k*x.

* With the above two optimizations in place, if the panel has
a minfpsSupported value of 45, and if the use-case fps is 12,
the new refresh-rate would be set as 12 * 4(= 48) instead of 60
which had been the case.

* The above two optimizations will result in dynamic change in
refresh-rate happening more often, in local video and streaming
use-cases and will help in improving DOU(Days Of Use) metric.

Change-Id: I2051e4d91280867135bf592e8f561911adcb6228
This commit is contained in:
Raj Kamal
2015-04-08 13:52:58 +05:30
committed by Gerrit - the friendly Code Review server
parent c37bd88fc1
commit f8829b9a9a
2 changed files with 42 additions and 13 deletions

View File

@@ -554,7 +554,37 @@ void closeContext(hwc_context_t *ctx)
}
}
//Helper to roundoff the refreshrates
uint32_t getRefreshRate(hwc_context_t* ctx, uint32_t requestedRefreshRate) {
qdutils::MDPVersion& mdpHw = qdutils::MDPVersion::getInstance();
int dpy = HWC_DISPLAY_PRIMARY;
uint32_t defaultRefreshRate = ctx->dpyAttr[dpy].refreshRate;
uint32_t rate = defaultRefreshRate;
if(!requestedRefreshRate)
return defaultRefreshRate;
uint32_t maxNumIterations =
(uint32_t)ceil(
(float)mdpHw.getMaxFpsSupported()/
(float)requestedRefreshRate);
for(uint32_t i = 1; i <= maxNumIterations; i++) {
rate = roundOff(i * requestedRefreshRate);
if(rate < mdpHw.getMinFpsSupported()) {
continue;
} else if((rate >= mdpHw.getMinFpsSupported() &&
rate <= mdpHw.getMaxFpsSupported())) {
break;
} else {
rate = defaultRefreshRate;
break;
}
}
return rate;
}
//Helper to roundoff the refreshrates to the std refresh-rates
uint32_t roundOff(uint32_t refreshRate) {
int count = (int) (sizeof(stdRefreshRates)/sizeof(stdRefreshRates[0]));
uint32_t rate = refreshRate;
@@ -1175,24 +1205,21 @@ void setListStats(hwc_context_t *ctx,
#ifdef DYNAMIC_FPS
if (!dpy && mdpHw.isDynFpsSupported() && ctx->mUseMetaDataRefreshRate){
//dyn fps: get refreshrate from metadata
//Support multiple refresh rates if they are same
//else set to default
/* Dyn fps: get refreshrate from metadata */
MetaData_t *mdata = hnd ? (MetaData_t *)hnd->base_metadata : NULL;
if (mdata && (mdata->operation & UPDATE_REFRESH_RATE)) {
// Valid refreshRate in metadata and within the range
uint32_t rate = roundOff(mdata->refreshrate);
if((rate >= mdpHw.getMinFpsSupported() &&
rate <= mdpHw.getMaxFpsSupported())) {
uint32_t rate = getRefreshRate(ctx, mdata->refreshrate);
if (!refreshRate) {
refreshRate = rate;
} else if(refreshRate != rate) {
// multiple refreshrate requests, set to default
/* Support multiple refresh rates if they are same
* else set to default.
*/
refreshRate = ctx->dpyAttr[dpy].refreshRate;
}
}
}
}
#endif
}

View File

@@ -352,6 +352,8 @@ void getActionSafePosition(hwc_context_t *ctx, int dpy, hwc_rect_t& dst);
void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
hwc_rect_t& inRect, hwc_rect_t& outRect);
uint32_t getRefreshRate(hwc_context_t* ctx, uint32_t requestedRefreshRate);
uint32_t roundOff(uint32_t refreshRate);
void setRefreshRate(hwc_context_t *ctx, int dpy, uint32_t refreshRate);