drm_hwcomposer: Add support for color transform matrix
1. Add and wire-up CRTC CTM property support.
2. Add custom Android property to select behavior for cases
where DRM can't handle color transform matrix.
The "vendor.hwc.drm.ctm" property can be set to:
- DRM_OR_GPU (default) - Use GPU if CTM is not supported by DRM.
- DRM_OR_IGNORE - Ignore CTM if DRM doesn't support it.
The last option is useful for Android 13 and later where default
color transformation matrix is not an identity matrix.
At the moment I do not have any devices with CTM support, therefore
I can test only DRM_OR_IGNORE option.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/drm/ResourceManager.cpp b/drm/ResourceManager.cpp
index dd26c17..577d86c 100644
--- a/drm/ResourceManager.cpp
+++ b/drm/ResourceManager.cpp
@@ -72,9 +72,21 @@
}
}
- char scale_with_gpu[PROPERTY_VALUE_MAX];
- property_get("vendor.hwc.drm.scale_with_gpu", scale_with_gpu, "0");
- scale_with_gpu_ = bool(strncmp(scale_with_gpu, "0", 1));
+ char proptext[PROPERTY_VALUE_MAX];
+ property_get("vendor.hwc.drm.scale_with_gpu", proptext, "0");
+ scale_with_gpu_ = bool(strncmp(proptext, "0", 1));
+
+ constexpr char kDrmOrGpu[] = "DRM_OR_GPU";
+ constexpr char kDrmOrIgnore[] = "DRM_OR_IGNORE";
+ property_get("vendor.hwc.drm.ctm", proptext, kDrmOrGpu);
+ if (strncmp(proptext, kDrmOrGpu, sizeof(kDrmOrGpu)) == 0) {
+ ctm_handling_ = CtmHandling::kDrmOrGpu;
+ } else if (strncmp(proptext, kDrmOrIgnore, sizeof(kDrmOrIgnore)) == 0) {
+ ctm_handling_ = CtmHandling::kDrmOrIgnore;
+ } else {
+ ALOGE("Invalid value for vendor.hwc.drm.ctm: %s", proptext);
+ ctm_handling_ = CtmHandling::kDrmOrGpu;
+ }
if (BufferInfoGetter::GetInstance() == nullptr) {
ALOGE("Failed to initialize BufferInfoGetter");