Skip to content

Commit f08ed64

Browse files
author
Sasha McIntosh
committed
SF,HDR: Add HDR output type to modes
Add hdr output types to display configuration and display mode. This will be used by HWC to infer the minimum bits per color required for the link. If we do not specify the minimum bit depth for HDR displays, we may run into bandwidth contention, resulting in a low quality visual experience. Bug: 374183675 Test: HWComposerTest#getModesWithDisplayConfigurations* Flag: com.android.graphics.surfaceflinger.flags.connected_display_hdr Change-Id: I2d680d257ed9fbd7aad00282363a2e784da4cce5 Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
1 parent b03dfd3 commit f08ed64

6 files changed

Lines changed: 33 additions & 8 deletions

File tree

services/surfaceflinger/DisplayHardware/DisplayMode.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
#include <common/FlagManager.h>
3232
#include <scheduler/Fps.h>
3333

34-
#include "DisplayHardware/Hal.h"
34+
#include "Hal.h"
3535

3636
namespace android {
3737

38+
using aidl::android::hardware::graphics::composer3::OutputType;
3839
namespace hal = android::hardware::graphics::composer::hal;
3940

4041
class DisplayMode;
@@ -114,6 +115,11 @@ class DisplayMode {
114115
return *this;
115116
}
116117

118+
Builder& setHdrOutputType(OutputType type) {
119+
mDisplayMode->mHdrOutputType = type;
120+
return *this;
121+
}
122+
117123
private:
118124
float getDefaultDensity() {
119125
// Default density is based on TVs: 1080p displays get XHIGH density, lower-
@@ -166,6 +172,8 @@ class DisplayMode {
166172
// without visual interruptions such as a black screen.
167173
int32_t getGroup() const { return mGroup; }
168174

175+
OutputType getHdrOutputType() const { return mHdrOutputType; }
176+
169177
private:
170178
explicit DisplayMode(hal::HWConfigId id) : mHwcId(id) {}
171179

@@ -179,21 +187,25 @@ class DisplayMode {
179187
Dpi mDpi;
180188
int32_t mGroup = -1;
181189
std::optional<hal::VrrConfig> mVrrConfig;
190+
OutputType mHdrOutputType;
182191
};
183192

184193
inline bool equalsExceptDisplayModeId(const DisplayMode& lhs, const DisplayMode& rhs) {
185194
return lhs.getHwcId() == rhs.getHwcId() && lhs.getResolution() == rhs.getResolution() &&
186195
lhs.getVsyncRate().getPeriodNsecs() == rhs.getVsyncRate().getPeriodNsecs() &&
187-
lhs.getDpi() == rhs.getDpi() && lhs.getGroup() == rhs.getGroup();
196+
lhs.getDpi() == rhs.getDpi() && lhs.getGroup() == rhs.getGroup() &&
197+
lhs.getVrrConfig() == rhs.getVrrConfig() &&
198+
lhs.getHdrOutputType() == rhs.getHdrOutputType();
188199
}
189200

190201
inline std::string to_string(const DisplayMode& mode) {
191202
return base::StringPrintf("{id=%d, hwcId=%d, resolution=%dx%d, vsyncRate=%s, "
192-
"dpi=%.2fx%.2f, group=%d, vrrConfig=%s}",
203+
"dpi=%.2fx%.2f, group=%d, vrrConfig=%s, supportedHdrTypes=%s}",
193204
ftl::to_underlying(mode.getId()), mode.getHwcId(), mode.getWidth(),
194205
mode.getHeight(), to_string(mode.getVsyncRate()).c_str(),
195206
mode.getDpi().x, mode.getDpi().y, mode.getGroup(),
196-
to_string(mode.getVrrConfig()).c_str());
207+
to_string(mode.getVrrConfig()).c_str(),
208+
toString(mode.getHdrOutputType()).c_str());
197209
}
198210

199211
template <typename... DisplayModePtrs>

services/surfaceflinger/DisplayHardware/HWComposer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ std::vector<HWComposer::HWCDisplayMode> HWComposer::getModesFromDisplayConfigura
336336
.height = config.height,
337337
.vsyncPeriod = config.vsyncPeriod,
338338
.configGroup = config.configGroup,
339-
.vrrConfig = config.vrrConfig};
339+
.vrrConfig = config.vrrConfig,
340+
.hdrOutputType = config.hdrOutputType};
340341

341342
const DisplayConfiguration::Dpi estimatedDPI =
342343
getEstimatedDotsPerInchFromSize(hwcDisplayId, hwcMode);

services/surfaceflinger/DisplayHardware/HWComposer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
5656
#include <aidl/android/hardware/graphics/composer3/DisplayLuts.h>
5757
#include <aidl/android/hardware/graphics/composer3/LutProperties.h>
58+
#include <aidl/android/hardware/graphics/composer3/OutputType.h>
5859
#include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>
5960

6061
namespace android {
@@ -112,12 +113,14 @@ class HWComposer {
112113
float dpiY = -1.f;
113114
int32_t configGroup = -1;
114115
std::optional<hal::VrrConfig> vrrConfig;
116+
OutputType hdrOutputType;
115117

116118
friend std::ostream& operator<<(std::ostream& os, const HWCDisplayMode& mode) {
117119
return os << "id=" << mode.hwcId << " res=" << mode.width << "x" << mode.height
118120
<< " vsyncPeriod=" << mode.vsyncPeriod << " dpi=" << mode.dpiX << "x"
119121
<< mode.dpiY << " group=" << mode.configGroup
120-
<< " vrrConfig=" << to_string(mode.vrrConfig).c_str();
122+
<< " vrrConfig=" << to_string(mode.vrrConfig).c_str()
123+
<< " hdrOutputType=" << toString(mode.hdrOutputType);
121124
}
122125
};
123126

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172

173173
#include <aidl/android/hardware/graphics/common/DisplayDecorationSupport.h>
174174
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
175+
#include <aidl/android/hardware/graphics/composer3/OutputType.h>
175176
#include <aidl/android/hardware/graphics/composer3/RenderIntent.h>
176177

177178
#undef NO_THREAD_SAFETY_ANALYSIS
@@ -3498,6 +3499,9 @@ std::pair<DisplayModes, DisplayModePtr> SurfaceFlinger::loadDisplayModes(
34983499
DisplayModes newModes;
34993500
for (const auto& hwcMode : hwcModes) {
35003501
const auto id = nextModeId++;
3502+
OutputType hdrOutputType = FlagManager::getInstance().connected_display_hdr()
3503+
? hwcMode.hdrOutputType
3504+
: OutputType::INVALID;
35013505
newModes.try_emplace(id,
35023506
DisplayMode::Builder(hwcMode.hwcId)
35033507
.setId(id)
@@ -3508,6 +3512,7 @@ std::pair<DisplayModes, DisplayModePtr> SurfaceFlinger::loadDisplayModes(
35083512
.setDpiX(hwcMode.dpiX)
35093513
.setDpiY(hwcMode.dpiY)
35103514
.setGroup(hwcMode.configGroup)
3515+
.setHdrOutputType(hdrOutputType)
35113516
.build());
35123517
}
35133518

services/surfaceflinger/common/FlagManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ FLAG_MANAGER_ACONFIG_FLAG(flush_buffer_slots_to_uncache, "");
257257
FLAG_MANAGER_ACONFIG_FLAG(force_compile_graphite_renderengine, "");
258258
FLAG_MANAGER_ACONFIG_FLAG(true_hdr_screenshots, "debug.sf.true_hdr_screenshots");
259259
FLAG_MANAGER_ACONFIG_FLAG(display_config_error_hal, "");
260-
FLAG_MANAGER_ACONFIG_FLAG(connected_display_hdr, "");
260+
FLAG_MANAGER_ACONFIG_FLAG(connected_display_hdr, "debug.sf.connected_display_hdr");
261261
FLAG_MANAGER_ACONFIG_FLAG(deprecate_frame_tracker, "");
262262
FLAG_MANAGER_ACONFIG_FLAG(skip_invisible_windows_in_input, "");
263263
FLAG_MANAGER_ACONFIG_FLAG(begone_bright_hlg, "debug.sf.begone_bright_hlg");

services/surfaceflinger/tests/unittests/HWComposerTest.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_ON) {
384384
const ui::Size size = info->preferredDetailedTimingDescriptor->physicalSizeInMm;
385385
const float expectedDpiX = (kWidth * kMmPerInch / size.width);
386386
const float expectedDpiY = (kHeight * kMmPerInch / size.height);
387+
const OutputType hdrOutputType = OutputType::SYSTEM;
387388
const hal::VrrConfig vrrConfig =
388389
hal::VrrConfig{.minFrameIntervalNs = static_cast<Fps>(120_Hz).getPeriodNsecs(),
389390
.notifyExpectedPresentConfig = hal::VrrConfig::
@@ -394,7 +395,8 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_ON) {
394395
.height = kHeight,
395396
.configGroup = kConfigGroup,
396397
.vsyncPeriod = kVsyncPeriod,
397-
.vrrConfig = vrrConfig};
398+
.vrrConfig = vrrConfig,
399+
.hdrOutputType = hdrOutputType};
398400

399401
EXPECT_CALL(*mHal, getDisplayConfigurations(kHwcDisplayId, _, _))
400402
.WillOnce(DoAll(SetArgPointee<2>(std::vector<hal::DisplayConfiguration>{
@@ -410,6 +412,7 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_ON) {
410412
EXPECT_EQ(modes.front().configGroup, kConfigGroup);
411413
EXPECT_EQ(modes.front().vsyncPeriod, kVsyncPeriod);
412414
EXPECT_EQ(modes.front().vrrConfig, vrrConfig);
415+
EXPECT_EQ(modes.front().hdrOutputType, hdrOutputType);
413416
if (!FlagManager::getInstance().correct_dpi_with_display_size()) {
414417
EXPECT_EQ(modes.front().dpiX, -1);
415418
EXPECT_EQ(modes.front().dpiY, -1);
@@ -435,6 +438,7 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_ON) {
435438
EXPECT_EQ(modes.front().configGroup, kConfigGroup);
436439
EXPECT_EQ(modes.front().vsyncPeriod, kVsyncPeriod);
437440
EXPECT_EQ(modes.front().vrrConfig, vrrConfig);
441+
EXPECT_EQ(modes.front().hdrOutputType, hdrOutputType);
438442
EXPECT_EQ(modes.front().dpiX, kDpi);
439443
EXPECT_EQ(modes.front().dpiY, kDpi);
440444

0 commit comments

Comments
 (0)