summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kovalivskyi <roman.kovalivskyi@globallogic.com>2019-12-11 19:09:51 +0200
committerRoman Kovalivskyi <roman.kovalivskyi@globallogic.com>2019-12-16 17:54:03 +0200
commit12b91a35816c97c640f235fc0ac46e81402270a8 (patch)
tree44bc9be3e73bb271025d36080fc9927135760737
parentbb37569e6647c92bcdee7a4be42bb5fb003ce0b7 (diff)
drm_hwcomposer: Add simplistic SetColorTransform implementation
VTS tests for SET_COLOR_TRANSFORM fails for now since SetColorTransform is marked as unsupported function. this commit tries to address this issue. We can't make complete implementation of those features for our platform for now, so we'd just save arguments for future use and force client composition if any color transformation is requested. This is perfectly acceptable way to pass VTS testcase for SET_COLOR_TRANSFORM. Commit da5839cf9258 ("drm_hwcomposer: Add support for GetColorModes & SetCursorPosition") implements GetColorModes and SetCursorPosition simply by adding fields that store this values for future uses. Therefore we assume that it is okay to use this approach to at least support interface part. Please note that if transform hint is identity then no transformation should be applied. If hint is arbitrary matrix then given matrix should be applier after composition, though for now we'd just force client composition instead. This behavior is required by HAL interface as stated in hardware/interfaces/graphics/composer/2.1/IComposerClient.hal, line 738 from repository https://android.googlesource.com/platform/hardware/interfaces, tag android-10.0.0_r14 Please note that color transform matrix argument is an array that has 16 elements by contract, as it is 4x4 matrix. This is why MATRIX_SIZE has such value. Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
-rw-r--r--drmhwctwo.cpp27
-rw-r--r--include/drmhwctwo.h5
2 files changed, 28 insertions, 4 deletions
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index a1f8232..fa25d6b 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -231,8 +231,16 @@ DrmHwcTwo::HwcDisplay::HwcDisplay(ResourceManager *resource_manager,
drm_(drm),
importer_(importer),
handle_(handle),
- type_(type) {
+ type_(type),
+ color_transform_hint_(HAL_COLOR_TRANSFORM_IDENTITY) {
supported(__func__);
+
+ // clang-format off
+ color_transform_matrix_ = {1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0};
+ // clang-format on
}
void DrmHwcTwo::HwcDisplay::ClearDisplay() {
@@ -791,8 +799,18 @@ HWC2::Error DrmHwcTwo::HwcDisplay::SetColorMode(int32_t mode) {
HWC2::Error DrmHwcTwo::HwcDisplay::SetColorTransform(const float *matrix,
int32_t hint) {
supported(__func__);
- // TODO: Force client composition if we get this
- return unsupported(__func__, matrix, hint);
+ if (hint < HAL_COLOR_TRANSFORM_IDENTITY ||
+ hint > HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA)
+ return HWC2::Error::BadParameter;
+
+ if (!matrix && hint == HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX)
+ return HWC2::Error::BadParameter;
+
+ color_transform_hint_ = static_cast<android_color_transform_t>(hint);
+ if (color_transform_hint_ == HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX)
+ std::copy(matrix, matrix + MATRIX_SIZE, color_transform_matrix_.begin());
+
+ return HWC2::Error::None;
}
HWC2::Error DrmHwcTwo::HwcDisplay::SetOutputBuffer(buffer_handle_t buffer,
@@ -865,7 +883,8 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
uint32_t pixops = (df.right - df.left) * (df.bottom - df.top);
if (gpu_block || avail_planes == 0 ||
!HardwareSupportsLayerType(l.second->sf_type()) ||
- !importer_->CanImportBuffer(l.second->buffer())) {
+ !importer_->CanImportBuffer(l.second->buffer()) ||
+ color_transform_hint_ != HAL_COLOR_TRANSFORM_IDENTITY) {
gpu_block = true;
gpu_pixops += pixops;
++*num_types;
diff --git a/include/drmhwctwo.h b/include/drmhwctwo.h
index 361bce9..4a10fef 100644
--- a/include/drmhwctwo.h
+++ b/include/drmhwctwo.h
@@ -22,6 +22,7 @@
#include <hardware/hwcomposer2.h>
+#include <array>
#include <map>
namespace android {
@@ -202,6 +203,8 @@ class DrmHwcTwo : public hwc2_device_t {
void AddFenceToPresentFence(int fd);
bool HardwareSupportsLayerType(HWC2::Composition comp_type);
+ constexpr static size_t MATRIX_SIZE = 16;
+
ResourceManager *resource_manager_;
DrmDevice *drm_;
DrmDisplayCompositor compositor_;
@@ -221,6 +224,8 @@ class DrmHwcTwo : public hwc2_device_t {
HwcLayer client_layer_;
UniqueFd present_fence_;
int32_t color_mode_;
+ std::array<float, MATRIX_SIZE> color_transform_matrix_;
+ android_color_transform_t color_transform_hint_;
uint32_t frame_no_ = 0;
/* Statistics */