Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f08ed64b authored by Sasha McIntosh's avatar Sasha McIntosh
Browse files

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: default avatarSasha McIntosh <sashamcintosh@google.com>
parent b03dfd3b
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -31,10 +31,11 @@
#include <common/FlagManager.h>
#include <scheduler/Fps.h>

#include "DisplayHardware/Hal.h"
#include "Hal.h"

namespace android {

using aidl::android::hardware::graphics::composer3::OutputType;
namespace hal = android::hardware::graphics::composer::hal;

class DisplayMode;
@@ -114,6 +115,11 @@ public:
            return *this;
        }

        Builder& setHdrOutputType(OutputType type) {
            mDisplayMode->mHdrOutputType = type;
            return *this;
        }

    private:
        float getDefaultDensity() {
            // Default density is based on TVs: 1080p displays get XHIGH density, lower-
@@ -166,6 +172,8 @@ public:
    // without visual interruptions such as a black screen.
    int32_t getGroup() const { return mGroup; }

    OutputType getHdrOutputType() const { return mHdrOutputType; }

private:
    explicit DisplayMode(hal::HWConfigId id) : mHwcId(id) {}

@@ -179,21 +187,25 @@ private:
    Dpi mDpi;
    int32_t mGroup = -1;
    std::optional<hal::VrrConfig> mVrrConfig;
    OutputType mHdrOutputType;
};

inline bool equalsExceptDisplayModeId(const DisplayMode& lhs, const DisplayMode& rhs) {
    return lhs.getHwcId() == rhs.getHwcId() && lhs.getResolution() == rhs.getResolution() &&
            lhs.getVsyncRate().getPeriodNsecs() == rhs.getVsyncRate().getPeriodNsecs() &&
            lhs.getDpi() == rhs.getDpi() && lhs.getGroup() == rhs.getGroup();
            lhs.getDpi() == rhs.getDpi() && lhs.getGroup() == rhs.getGroup() &&
            lhs.getVrrConfig() == rhs.getVrrConfig() &&
            lhs.getHdrOutputType() == rhs.getHdrOutputType();
}

inline std::string to_string(const DisplayMode& mode) {
    return base::StringPrintf("{id=%d, hwcId=%d, resolution=%dx%d, vsyncRate=%s, "
                              "dpi=%.2fx%.2f, group=%d, vrrConfig=%s}",
                              "dpi=%.2fx%.2f, group=%d, vrrConfig=%s, supportedHdrTypes=%s}",
                              ftl::to_underlying(mode.getId()), mode.getHwcId(), mode.getWidth(),
                              mode.getHeight(), to_string(mode.getVsyncRate()).c_str(),
                              mode.getDpi().x, mode.getDpi().y, mode.getGroup(),
                              to_string(mode.getVrrConfig()).c_str());
                              to_string(mode.getVrrConfig()).c_str(),
                              toString(mode.getHdrOutputType()).c_str());
}

template <typename... DisplayModePtrs>
+2 −1
Original line number Diff line number Diff line
@@ -336,7 +336,8 @@ std::vector<HWComposer::HWCDisplayMode> HWComposer::getModesFromDisplayConfigura
                                      .height = config.height,
                                      .vsyncPeriod = config.vsyncPeriod,
                                      .configGroup = config.configGroup,
                                      .vrrConfig = config.vrrConfig};
                                      .vrrConfig = config.vrrConfig,
                                      .hdrOutputType = config.hdrOutputType};

        const DisplayConfiguration::Dpi estimatedDPI =
                getEstimatedDotsPerInchFromSize(hwcDisplayId, hwcMode);
+4 −1
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
#include <aidl/android/hardware/graphics/composer3/DisplayLuts.h>
#include <aidl/android/hardware/graphics/composer3/LutProperties.h>
#include <aidl/android/hardware/graphics/composer3/OutputType.h>
#include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>

namespace android {
@@ -112,12 +113,14 @@ public:
        float dpiY = -1.f;
        int32_t configGroup = -1;
        std::optional<hal::VrrConfig> vrrConfig;
        OutputType hdrOutputType;

        friend std::ostream& operator<<(std::ostream& os, const HWCDisplayMode& mode) {
            return os << "id=" << mode.hwcId << " res=" << mode.width << "x" << mode.height
                      << " vsyncPeriod=" << mode.vsyncPeriod << " dpi=" << mode.dpiX << "x"
                      << mode.dpiY << " group=" << mode.configGroup
                      << " vrrConfig=" << to_string(mode.vrrConfig).c_str();
                      << " vrrConfig=" << to_string(mode.vrrConfig).c_str()
                      << " hdrOutputType=" << toString(mode.hdrOutputType);
        }
    };

+5 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@

#include <aidl/android/hardware/graphics/common/DisplayDecorationSupport.h>
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
#include <aidl/android/hardware/graphics/composer3/OutputType.h>
#include <aidl/android/hardware/graphics/composer3/RenderIntent.h>

#undef NO_THREAD_SAFETY_ANALYSIS
@@ -3498,6 +3499,9 @@ std::pair<DisplayModes, DisplayModePtr> SurfaceFlinger::loadDisplayModes(
    DisplayModes newModes;
    for (const auto& hwcMode : hwcModes) {
        const auto id = nextModeId++;
        OutputType hdrOutputType = FlagManager::getInstance().connected_display_hdr()
                ? hwcMode.hdrOutputType
                : OutputType::INVALID;
        newModes.try_emplace(id,
                             DisplayMode::Builder(hwcMode.hwcId)
                                     .setId(id)
@@ -3508,6 +3512,7 @@ std::pair<DisplayModes, DisplayModePtr> SurfaceFlinger::loadDisplayModes(
                                     .setDpiX(hwcMode.dpiX)
                                     .setDpiY(hwcMode.dpiY)
                                     .setGroup(hwcMode.configGroup)
                                     .setHdrOutputType(hdrOutputType)
                                     .build());
    }

+1 −1
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ FLAG_MANAGER_ACONFIG_FLAG(flush_buffer_slots_to_uncache, "");
FLAG_MANAGER_ACONFIG_FLAG(force_compile_graphite_renderengine, "");
FLAG_MANAGER_ACONFIG_FLAG(true_hdr_screenshots, "debug.sf.true_hdr_screenshots");
FLAG_MANAGER_ACONFIG_FLAG(display_config_error_hal, "");
FLAG_MANAGER_ACONFIG_FLAG(connected_display_hdr, "");
FLAG_MANAGER_ACONFIG_FLAG(connected_display_hdr, "debug.sf.connected_display_hdr");
FLAG_MANAGER_ACONFIG_FLAG(deprecate_frame_tracker, "");
FLAG_MANAGER_ACONFIG_FLAG(skip_invisible_windows_in_input, "");
FLAG_MANAGER_ACONFIG_FLAG(begone_bright_hlg, "debug.sf.begone_bright_hlg");
Loading