Skip to content

Commit 918fc16

Browse files
Sasha McIntoshAndroid (Google) Code Review
authored andcommitted
Merge "SF,HDR: Add HDR output type to modes" into main
2 parents 51166f2 + f08ed64 commit 918fc16

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
@@ -3509,6 +3510,9 @@ std::pair<DisplayModes, DisplayModePtr> SurfaceFlinger::loadDisplayModes(
35093510
DisplayModes newModes;
35103511
for (const auto& hwcMode : hwcModes) {
35113512
const auto id = nextModeId++;
3513+
OutputType hdrOutputType = FlagManager::getInstance().connected_display_hdr()
3514+
? hwcMode.hdrOutputType
3515+
: OutputType::INVALID;
35123516
newModes.try_emplace(id,
35133517
DisplayMode::Builder(hwcMode.hwcId)
35143518
.setId(id)
@@ -3519,6 +3523,7 @@ std::pair<DisplayModes, DisplayModePtr> SurfaceFlinger::loadDisplayModes(
35193523
.setDpiX(hwcMode.dpiX)
35203524
.setDpiY(hwcMode.dpiY)
35213525
.setGroup(hwcMode.configGroup)
3526+
.setHdrOutputType(hdrOutputType)
35223527
.build());
35233528
}
35243529

services/surfaceflinger/common/FlagManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ FLAG_MANAGER_ACONFIG_FLAG(flush_buffer_slots_to_uncache, "");
259259
FLAG_MANAGER_ACONFIG_FLAG(force_compile_graphite_renderengine, "");
260260
FLAG_MANAGER_ACONFIG_FLAG(true_hdr_screenshots, "debug.sf.true_hdr_screenshots");
261261
FLAG_MANAGER_ACONFIG_FLAG(display_config_error_hal, "");
262-
FLAG_MANAGER_ACONFIG_FLAG(connected_display_hdr, "");
262+
FLAG_MANAGER_ACONFIG_FLAG(connected_display_hdr, "debug.sf.connected_display_hdr");
263263
FLAG_MANAGER_ACONFIG_FLAG(deprecate_frame_tracker, "");
264264
FLAG_MANAGER_ACONFIG_FLAG(skip_invisible_windows_in_input, "");
265265
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)