drm_hwcomposer: Implement getHdrCapabilities and getColorModes
Retrieve color and HDR information from the EDID.
Change-Id: I1aac27644d5c4fd5d5f295ca32b69ed69e94e0c6
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
diff --git a/utils/EdidWrapper.h b/utils/EdidWrapper.h
index 867d1a0..30124d7 100644
--- a/utils/EdidWrapper.h
+++ b/utils/EdidWrapper.h
@@ -16,8 +16,6 @@
#pragma once
-#define LOG_TAG "drmhwc"
-
#if HAS_LIBDISPLAY_INFO
extern "C" {
#include <libdisplay-info/info.h>
@@ -26,8 +24,8 @@
#include <ui/GraphicTypes.h>
+#include "compositor/DisplayInfo.h"
#include "drm/DrmUnique.h"
-#include "utils/log.h"
namespace android {
@@ -47,6 +45,9 @@
const float * /*min_luminance*/) {
GetSupportedHdrTypes(types);
};
+ virtual void GetColorModes(std::vector<Colormode> &color_modes) {
+ color_modes.clear();
+ };
};
#if HAS_LIBDISPLAY_INFO
@@ -67,6 +68,8 @@
const float *max_average_luminance,
const float *min_luminance) override;
+ void GetColorModes(std::vector<Colormode> &color_modes) override;
+
private:
LibdisplayEdidWrapper(di_info *info) : info_(std::move(info)) {
}
diff --git a/utils/LibdisplayEdidWrapper.cpp b/utils/LibdisplayEdidWrapper.cpp
index 5a17b93..d2d2a1c 100644
--- a/utils/LibdisplayEdidWrapper.cpp
+++ b/utils/LibdisplayEdidWrapper.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "drmhwc"
#if HAS_LIBDISPLAY_INFO
+
#include "utils/EdidWrapper.h"
#include "utils/log.h"
@@ -63,5 +64,36 @@
min_luminance = &hdr_static_meta->desired_content_min_luminance;
}
+void LibdisplayEdidWrapper::GetColorModes(std::vector<Colormode> &color_modes) {
+ color_modes.clear();
+ color_modes.emplace_back(Colormode::kNative);
+
+ const auto *hdr_static_meta = di_info_get_hdr_static_metadata(info_);
+ const auto *colorimetries = di_info_get_supported_signal_colorimetry(info_);
+
+ /* Rec. ITU-R BT.2020 constant luminance YCbCr */
+ /* Rec. ITU-R BT.2020 non-constant luminance YCbCr */
+ if (colorimetries->bt2020_cycc || colorimetries->bt2020_ycc)
+ color_modes.emplace_back(Colormode::kBt2020);
+
+ /* Rec. ITU-R BT.2020 RGB */
+ if (colorimetries->bt2020_rgb)
+ color_modes.emplace_back(Colormode::kDisplayBt2020);
+
+ /* SMPTE ST 2113 RGB: P3D65 and P3DCI */
+ if (colorimetries->st2113_rgb) {
+ color_modes.emplace_back(Colormode::kDciP3);
+ color_modes.emplace_back(Colormode::kDisplayP3);
+ }
+
+ /* Rec. ITU-R BT.2100 ICtCp HDR (with PQ and/or HLG) */
+ if (colorimetries->ictcp) {
+ if (hdr_static_meta->pq)
+ color_modes.emplace_back(Colormode::kBt2100Pq);
+ if (hdr_static_meta->hlg)
+ color_modes.emplace_back(Colormode::kBt2100Hlg);
+ }
+}
+
} // namespace android
#endif