Skip to content

Commit bee1902

Browse files
author
ramindani
committed
Adds getSupportedRefreshRates support
Source values for refresh rates from the RefreshRateSelector through SurfaceComposerClient. Test: atest android.display.cts.DisplayTest BUG: 365163968 Flag: com.android.server.display.feature.flags.enable_get_supported_refresh_rates Change-Id: I149e6e51b3b3718ef53e522f1fca5650dbbd8b7b
1 parent 2a8a1ae commit bee1902

6 files changed

Lines changed: 33 additions & 0 deletions

File tree

libs/gui/SurfaceComposerClient.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,6 +2873,11 @@ void SurfaceComposerClient::getDynamicDisplayInfoInternal(gui::DynamicDisplayInf
28732873
outInfo->hasArrSupport = ginfo.hasArrSupport;
28742874
outInfo->frameRateCategoryRate = ui::FrameRateCategoryRate(ginfo.frameRateCategoryRate.normal,
28752875
ginfo.frameRateCategoryRate.high);
2876+
outInfo->supportedRefreshRates.clear();
2877+
outInfo->supportedRefreshRates.reserve(ginfo.supportedRefreshRates.size());
2878+
for (const auto rate : ginfo.supportedRefreshRates) {
2879+
outInfo->supportedRefreshRates.push_back(static_cast<float>(rate));
2880+
}
28762881
}
28772882

28782883
status_t SurfaceComposerClient::getDynamicDisplayInfoFromId(int64_t displayId,

libs/gui/aidl/android/gui/DynamicDisplayInfo.aidl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ parcelable DynamicDisplayInfo {
5050

5151
// Represents frame rate for FrameRateCategory Normal and High.
5252
FrameRateCategoryRate frameRateCategoryRate;
53+
54+
// All the refresh rates supported for the default display mode.
55+
float[] supportedRefreshRates;
5356
}

libs/ui/include/ui/DynamicDisplayInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ struct DynamicDisplayInfo {
5959

6060
// Represents frame rate for FrameRateCategory Normal and High.
6161
ui::FrameRateCategoryRate frameRateCategoryRate;
62+
63+
// All the refresh rates supported for the default display mode.
64+
std::vector<float> supportedRefreshRates;
6265
};
6366

6467
} // namespace android::ui

services/surfaceflinger/Scheduler/RefreshRateSelector.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,19 @@ Fps RefreshRateSelector::findClosestKnownFrameRate(Fps frameRate) const {
15691569
return distance1 < distance2 ? *lowerBound : *std::prev(lowerBound);
15701570
}
15711571

1572+
std::vector<float> RefreshRateSelector::getSupportedFrameRates() const {
1573+
std::scoped_lock lock(mLock);
1574+
// TODO(b/356986687) Remove the limit once we have the anchor list implementation.
1575+
const size_t frameRatesSize = std::min<size_t>(11, mPrimaryFrameRates.size());
1576+
std::vector<float> supportedFrameRates;
1577+
supportedFrameRates.reserve(frameRatesSize);
1578+
std::transform(mPrimaryFrameRates.rbegin(),
1579+
mPrimaryFrameRates.rbegin() + static_cast<int>(frameRatesSize),
1580+
std::back_inserter(supportedFrameRates),
1581+
[](FrameRateMode mode) { return mode.fps.getValue(); });
1582+
return supportedFrameRates;
1583+
}
1584+
15721585
auto RefreshRateSelector::getIdleTimerAction() const -> KernelIdleTimerAction {
15731586
std::lock_guard lock(mLock);
15741587

services/surfaceflinger/Scheduler/RefreshRateSelector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ class RefreshRateSelector {
441441

442442
std::pair<Fps, Fps> getFrameRateCategoryRates() const { return kFrameRateCategoryRates; }
443443

444+
std::vector<float> getSupportedFrameRates() const EXCLUDES(mLock);
445+
444446
private:
445447
friend struct TestableRefreshRateSelector;
446448

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,8 @@ void SurfaceFlinger::getDynamicDisplayInfoInternal(ui::DynamicDisplayInfo*& info
12291229
const auto [normal, high] = display->refreshRateSelector().getFrameRateCategoryRates();
12301230
ui::FrameRateCategoryRate frameRateCategoryRate(normal.getValue(), high.getValue());
12311231
info->frameRateCategoryRate = frameRateCategoryRate;
1232+
1233+
info->supportedRefreshRates = display->refreshRateSelector().getSupportedFrameRates();
12321234
info->activeColorMode = display->getCompositionDisplay()->getState().colorMode;
12331235
info->hdrCapabilities = filterOut4k30(display->getHdrCapabilities());
12341236

@@ -8581,6 +8583,11 @@ void SurfaceComposerAIDL::getDynamicDisplayInfoInternal(ui::DynamicDisplayInfo&
85818583
gui::FrameRateCategoryRate& frameRateCategoryRate = outInfo->frameRateCategoryRate;
85828584
frameRateCategoryRate.normal = info.frameRateCategoryRate.getNormal();
85838585
frameRateCategoryRate.high = info.frameRateCategoryRate.getHigh();
8586+
outInfo->supportedRefreshRates.clear();
8587+
outInfo->supportedRefreshRates.reserve(info.supportedRefreshRates.size());
8588+
for (float supportedRefreshRate : info.supportedRefreshRates) {
8589+
outInfo->supportedRefreshRates.push_back(supportedRefreshRate);
8590+
}
85848591

85858592
outInfo->supportedColorModes.clear();
85868593
outInfo->supportedColorModes.reserve(info.supportedColorModes.size());

0 commit comments

Comments
 (0)