ANDROID: Set min bpc on modeset
When HDR10 is the desired output type for the display mode, request a minimum
bpc of 8 from the connector. This ensures the quality of the HDR content and
allows the caller to retry with SDR if there is insufficient bandwidth.
Bug: 374183675
Test: Presubmit
Change-Id: I897e0b42e0065a61ecfe28c280094b6c375d8a72
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
diff --git a/drm/DrmAtomicStateManager.cpp b/drm/DrmAtomicStateManager.cpp
index 9ce9a93..405c311 100644
--- a/drm/DrmAtomicStateManager.cpp
+++ b/drm/DrmAtomicStateManager.cpp
@@ -165,6 +165,23 @@
return -EINVAL;
}
+ if (args.min_bpc && connector->GetMinBpcProperty()) {
+ int err;
+ uint64_t range_min, range_max = 0;
+ std::tie(err, range_min) = connector->GetMinBpcProperty().RangeMin();
+ if (err)
+ return err;
+ std::tie(err, range_max) = connector->GetMinBpcProperty().RangeMax();
+ if (err)
+ return err;
+
+ // Adjust requested min bpc to be within the property range
+ int32_t min_bpc_val = std::max(args.min_bpc.value(), static_cast<int32_t>(range_min));
+ min_bpc_val = std::min(min_bpc_val, static_cast<int32_t>(range_max));
+ if (!connector->GetMinBpcProperty().AtomicSet(*pset, min_bpc_val))
+ return -EINVAL;
+ }
+
auto unused_planes = new_frame_state.used_planes;
if (args.composition) {