summaryrefslogtreecommitdiff
path: root/sdm/libs/hwc2/hwc_session.cpp
diff options
context:
space:
mode:
authorVenkat Thogaru <vthogaru@codeaurora.org>2020-01-27 15:49:58 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2020-04-08 22:19:53 -0700
commit137baa01e3adbc386a9ed752dfc74e58e0fd2e6c (patch)
tree9bf3c799a17b2b66e040b8cb2aac7933adeb5254 /sdm/libs/hwc2/hwc_session.cpp
parenta60e7287bc6a1ef95205b74e31b8f5ca940cc73b (diff)
sdm: Implement SetDisplayBrightness, GetDisplayBrightness.
Change-Id: Ica0f0bbb2955ad26fa113728ee152a21e6014b6c CRs-Fixed: 2454377
Diffstat (limited to 'sdm/libs/hwc2/hwc_session.cpp')
-rw-r--r--sdm/libs/hwc2/hwc_session.cpp46
1 files changed, 28 insertions, 18 deletions
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 86637055..d1653ee5 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -1310,7 +1310,7 @@ hwc2_function_pointer_t HWCSession::GetFunction(struct hwc2_device *device,
case HWC2::FunctionDescriptor::GetDisplayBrightnessSupport:
return AsFP<HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT>(HWCSession::GetDisplayBrightnessSupport);
case HWC2::FunctionDescriptor::SetDisplayBrightness:
- return AsFP<HWC2_PFN_SET_DISPLAY_BRIGHTNESS>(SetDisplayBrightness);
+ return AsFP<HWC2_PFN_SET_DISPLAY_BRIGHTNESS>(HWCSession::SetDisplayBrightness);
default:
DLOGD("Unknown/Unimplemented function descriptor: %d (%s)", int_descriptor,
to_string(descriptor).c_str());
@@ -1580,9 +1580,14 @@ android::status_t HWCSession::notifyCallback(uint32_t command, const android::Pa
DLOGE("QService command = %d: output_parcel needed.", command);
break;
}
- int level = 0;
- status = GetPanelBrightness(&level);
- output_parcel->writeInt32(level);
+ float brightness = -1.0f;
+ uint32_t display = input_parcel->readUint32();
+ status = getDisplayBrightness(display, &brightness);
+ if (brightness == -1.0f) {
+ output_parcel->writeInt32(0);
+ } else {
+ output_parcel->writeInt32(INT32(brightness*254 + 1));
+ }
}
break;
@@ -1591,8 +1596,13 @@ android::status_t HWCSession::notifyCallback(uint32_t command, const android::Pa
DLOGE("QService command = %d: input_parcel and output_parcel needed.", command);
break;
}
- uint32_t level = UINT32(input_parcel->readInt32());
- status = setPanelBrightness(level);
+ int level = input_parcel->readInt32();
+ hwc2_device_t *device = static_cast<hwc2_device_t *>(this);
+ if (level == 0) {
+ status = SetDisplayBrightness(device, HWC_DISPLAY_PRIMARY, -1.0f);
+ } else {
+ status = SetDisplayBrightness(device, HWC_DISPLAY_PRIMARY, (level - 1)/254.0f);
+ }
output_parcel->writeInt32(status);
}
break;
@@ -2119,7 +2129,7 @@ android::status_t HWCSession::QdcmCMDDispatch(uint32_t display_id,
android::status_t HWCSession::QdcmCMDHandler(const android::Parcel *input_parcel,
android::Parcel *output_parcel) {
int ret = 0;
- int32_t *brightness_value = NULL;
+ float *brightness = NULL;
uint32_t display_id(0);
PPPendingParams pending_action;
PPDisplayAPIPayload resp_payload, req_payload;
@@ -2192,12 +2202,13 @@ android::status_t HWCSession::QdcmCMDHandler(const android::Parcel *input_parcel
usleep(kSolidFillDelay);
break;
case kSetPanelBrightness:
- brightness_value = reinterpret_cast<int32_t *>(resp_payload.payload);
- if (brightness_value == NULL) {
- DLOGE("Brightness value is Null");
- ret = -EINVAL;
+ ret = -EINVAL;
+ brightness = reinterpret_cast<float *>(resp_payload.payload);
+ if (brightness == NULL) {
+ DLOGE("Brightness payload is Null");
} else {
- ret = hwc_display_[display_id]->SetPanelBrightness(*brightness_value);
+ ret = INT(SetDisplayBrightness(static_cast<hwc2_device_t *>(this),
+ static_cast<hwc2_display_t>(display_id), *brightness));
}
break;
case kEnableFrameCapture:
@@ -3294,10 +3305,6 @@ int32_t HWCSession::GetDisplayCapabilities(hwc2_device_t *device, hwc2_display_t
}
}
-int32_t HWCSession::SetDisplayBrightness(hwc2_device_t *device, hwc2_display_t display,
- float brightness) {
- return INT32(HWC2::Error::None);
-}
int32_t HWCSession::GetDisplayBrightnessSupport(hwc2_device_t *device, hwc2_display_t display,
bool *outSupport) {
@@ -3315,12 +3322,15 @@ int32_t HWCSession::GetDisplayBrightnessSupport(hwc2_device_t *device, hwc2_disp
DLOGE("Expected valid hwc_display");
return HWC2_ERROR_BAD_PARAMETER;
}
- // This function isn't actually used in the framework
- // The capability is used instead
*outSupport = (hwc_display->GetDisplayClass() == DISPLAY_CLASS_BUILTIN);
return HWC2_ERROR_NONE;
}
+int32_t HWCSession::SetDisplayBrightness(hwc2_device_t *device, hwc2_display_t display,
+ float brightness) {
+ return CallDisplayFunction(device, display, &HWCDisplay::SetPanelBrightness, brightness);
+}
+
android::status_t HWCSession::SetQSyncMode(const android::Parcel *input_parcel) {
auto mode = input_parcel->readInt32();
auto device = static_cast<hwc2_device_t *>(this);