display: Add support to set color mode by ID
Add a binder API to set color mode by mode ID which is present in
the calibration data XML. This is only used for debugging.
CRs-Fixed: 2044628
Change-Id: I5f71e1e7e2e170d36b64003204620b0bf3e95ba0
diff --git a/sdm/include/core/display_interface.h b/sdm/include/core/display_interface.h
index ce59850..f4054bb 100644
--- a/sdm/include/core/display_interface.h
+++ b/sdm/include/core/display_interface.h
@@ -539,6 +539,13 @@
*/
virtual DisplayError SetColorMode(const std::string &color_mode) = 0;
+ /*! @brief Method to set the color mode by ID. This method is used for debugging only.
+
+ @param[in] mode_name Mode ID which needs to be set
+
+ @return \link DisplayError \endlink
+ */
+ virtual DisplayError SetColorModeById(int32_t color_mode_id) = 0;
/*! @brief Method to set the color transform
@param[in] length Mode name which needs to be set
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index d30e0f3..c268183 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -804,6 +804,10 @@
return error;
}
+DisplayError DisplayBase::SetColorModeById(int32_t color_mode_id) {
+ return color_mgr_->ColorMgrSetMode(color_mode_id);
+}
+
DisplayError DisplayBase::SetColorModeInternal(const std::string &color_mode) {
DLOGV_IF(kTagQDCM, "Color Mode = %s", color_mode.c_str());
diff --git a/sdm/libs/core/display_base.h b/sdm/libs/core/display_base.h
index f75c518..4023229 100644
--- a/sdm/libs/core/display_base.h
+++ b/sdm/libs/core/display_base.h
@@ -96,6 +96,7 @@
virtual DisplayError GetColorModes(uint32_t *mode_count, std::vector<std::string> *color_modes);
virtual DisplayError GetColorModeAttr(const std::string &color_mode, AttrVal *attr);
virtual DisplayError SetColorMode(const std::string &color_mode);
+ virtual DisplayError SetColorModeById(int32_t color_mode_id);
virtual DisplayError SetColorTransform(const uint32_t length, const double *color_transform);
virtual DisplayError GetDefaultColorMode(std::string *color_mode);
virtual DisplayError ApplyDefaultDisplayMode(void);
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 158d485..ae0d745 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -119,6 +119,15 @@
return status;
}
+HWC2::Error HWCColorMode::SetColorModeById(int32_t color_mode_id) {
+ DLOGI("Applying mode: %d", color_mode_id);
+ DisplayError error = display_intf_->SetColorModeById(color_mode_id);
+ if (error != kErrorNone) {
+ return HWC2::Error::BadParameter;
+ }
+ return HWC2::Error::None;
+}
+
HWC2::Error HWCColorMode::SetColorTransform(const float *matrix, android_color_transform_t hint) {
if (!matrix) {
return HWC2::Error::BadParameter;
diff --git a/sdm/libs/hwc2/hwc_display.h b/sdm/libs/hwc2/hwc_display.h
index 188a4bd..276bee8 100644
--- a/sdm/libs/hwc2/hwc_display.h
+++ b/sdm/libs/hwc2/hwc_display.h
@@ -59,6 +59,7 @@
uint32_t GetColorModeCount();
HWC2::Error GetColorModes(uint32_t *out_num_modes, android_color_mode_t *out_modes);
HWC2::Error SetColorMode(android_color_mode_t mode);
+ HWC2::Error SetColorModeById(int32_t color_mode_id);
HWC2::Error SetColorTransform(const float *matrix, android_color_transform_t hint);
private:
@@ -155,6 +156,9 @@
virtual HWC2::Error SetColorMode(android_color_mode_t mode) {
return HWC2::Error::Unsupported;
}
+ virtual HWC2::Error SetColorModeById(int32_t color_mode_id) {
+ return HWC2::Error::Unsupported;
+ }
virtual HWC2::Error SetColorTransform(const float *matrix, android_color_transform_t hint) {
return HWC2::Error::Unsupported;
}
diff --git a/sdm/libs/hwc2/hwc_display_primary.cpp b/sdm/libs/hwc2/hwc_display_primary.cpp
index a27dca1..f3404a3 100644
--- a/sdm/libs/hwc2/hwc_display_primary.cpp
+++ b/sdm/libs/hwc2/hwc_display_primary.cpp
@@ -255,6 +255,18 @@
return status;
}
+HWC2::Error HWCDisplayPrimary::SetColorModeById(int32_t color_mode_id) {
+ auto status = color_mode_->SetColorModeById(color_mode_id);
+ if (status != HWC2::Error::None) {
+ DLOGE("failed for mode = %d", color_mode_id);
+ return status;
+ }
+
+ callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
+
+ return status;
+}
+
HWC2::Error HWCDisplayPrimary::SetColorTransform(const float *matrix,
android_color_transform_t hint) {
if (!matrix) {
diff --git a/sdm/libs/hwc2/hwc_display_primary.h b/sdm/libs/hwc2/hwc_display_primary.h
index 43673ed..b98de2b 100644
--- a/sdm/libs/hwc2/hwc_display_primary.h
+++ b/sdm/libs/hwc2/hwc_display_primary.h
@@ -57,6 +57,7 @@
virtual HWC2::Error Present(int32_t *out_retire_fence);
virtual HWC2::Error GetColorModes(uint32_t *out_num_modes, android_color_mode_t *out_modes);
virtual HWC2::Error SetColorMode(android_color_mode_t mode);
+ virtual HWC2::Error SetColorModeById(int32_t color_mode_id);
virtual HWC2::Error SetColorTransform(const float *matrix, android_color_transform_t hint);
virtual int Perform(uint32_t operation, ...);
virtual void SetSecureDisplay(bool secure_display_active);
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 255cb48..2bf7d4d 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -872,6 +872,10 @@
status = SetColorModeOverride(input_parcel);
break;
+ case qService::IQService::SET_COLOR_MODE_BY_ID:
+ status = SetColorModeById(input_parcel);
+ break;
+
default:
DLOGW("QService command = %d is not supported", command);
return -EINVAL;
@@ -1245,6 +1249,16 @@
return 0;
}
+android::status_t HWCSession::SetColorModeById(const android::Parcel *input_parcel) {
+ auto display = static_cast<hwc2_display_t >(input_parcel->readInt32());
+ auto mode = input_parcel->readInt32();
+ auto device = static_cast<hwc2_device_t *>(this);
+ auto err = CallDisplayFunction(device, display, &HWCDisplay::SetColorModeById, mode);
+ if (err != HWC2_ERROR_NONE)
+ return -EINVAL;
+ return 0;
+}
+
void HWCSession::DynamicDebug(const android::Parcel *input_parcel) {
int type = input_parcel->readInt32();
bool enable = (input_parcel->readInt32() > 0);
diff --git a/sdm/libs/hwc2/hwc_session.h b/sdm/libs/hwc2/hwc_session.h
index 500a763..87d41d7 100644
--- a/sdm/libs/hwc2/hwc_session.h
+++ b/sdm/libs/hwc2/hwc_session.h
@@ -170,6 +170,8 @@
android::status_t SetColorModeOverride(const android::Parcel *input_parcel);
+ android::status_t SetColorModeById(const android::Parcel *input_parcel);
+
static Locker locker_;
CoreInterface *core_intf_ = NULL;
HWCDisplay *hwc_display_[HWC_NUM_DISPLAY_TYPES] = {NULL};