sdm: hwc2: Add support for TWM entry and exit.

- Implement SET_STAND_BY_MODE binder support. SKGHAL
  use this api to inform HWC about TWM entry/exit.
- Move to null display to drop all incoming calls
  from surfaceflinger on TWM entry.
- Move to normal display on TWM exit.
- Add scope_lock for SET_STAND_BY_MODE API.

Bug: 79541227
CRs-Fixed: 2200577
Change-Id: I26ef3b1af53856f68f76b116988cc2a28c06b6ac
This commit is contained in:
Rajavenu Kyatham 2018-02-14 00:44:31 +05:30 committed by Alain Vongsouvanh
parent 679188367b
commit 85a0f2823c
8 changed files with 79 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014, 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2013-2014, 2016, 2018 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -316,6 +316,22 @@ int getPanelBrightness() {
return panel_brightness;
}
int setStandByMode(int mode) {
status_t err = (status_t) FAILED_TRANSACTION;
sp<IQService> binder = getBinder();
Parcel inParcel, outParcel;
if(binder != NULL) {
inParcel.writeInt32(mode);
err = binder->dispatch(IQService::SET_STAND_BY_MODE,
&inParcel, &outParcel);
if(err) {
ALOGE("%s() failed with err %d", __FUNCTION__, err);
}
}
return err;
}
}// namespace
// ----------------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 - 2016 The Linux Foundation. All rights reserved.
* Copyright (c) 2013 - 2016, 2018 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -158,6 +158,7 @@ int setPanelBrightness(int level);
// Retrieves the current panel brightness value
int getPanelBrightness();
int setStandByMode(int mode);
}; //namespace
#endif

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2012-2014, 2016 The Linux Foundation. All rights reserved.
* Copyright (C) 2012-2014, 2016, 2018 The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are
* retained for attribution purposes only.
@ -75,6 +75,7 @@ public:
SET_LAYER_MIXER_RESOLUTION = 33, // Enables client to set layer mixer resolution.
SET_COLOR_MODE = 34, // Overrides the QDCM mode on the display
GET_HDR_CAPABILITIES = 35, // Get HDR capabilities for legacy HWC interface
SET_STAND_BY_MODE = 36, //Set stand by mode for MDP3 hardware.
COMMAND_LIST_END = 400,
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
@ -148,6 +148,9 @@ class HWCDisplay : public DisplayEventHandler {
virtual int SetState(bool connected) {
return kErrorNotSupported;
}
virtual DisplayError SetStandByMode(bool enable) {
return kErrorNotSupported;
}
int SetPanelBrightness(int level);
int GetPanelBrightness(int *level);
int ToggleScreenUpdates(bool enable);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -594,4 +594,28 @@ DisplayError HWCDisplayPrimary::GetMixerResolution(uint32_t *width, uint32_t *he
return display_intf_->GetMixerResolution(width, height);
}
DisplayError HWCDisplayPrimary::SetStandByMode(bool enable) {
if (enable) {
if (!display_null_.IsActive()) {
stored_display_intf_ = display_intf_;
display_intf_ = &display_null_;
display_null_.SetActive(true);
DLOGD("Null display is connected successfully");
} else {
DLOGD("Null display is already connected.");
}
} else {
if (display_null_.IsActive()) {
display_intf_ = stored_display_intf_;
validated_.reset();
display_null_.SetActive(false);
DLOGD("Display is connected successfully");
} else {
DLOGD("Display is already connected.");
}
}
return kErrorNone;
}
} // namespace sdm

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2016, 2018 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -34,6 +34,7 @@
#include "cpuhint.h"
#include "hwc_display.h"
#include "display_null.h"
namespace sdm {
@ -67,6 +68,7 @@ class HWCDisplayPrimary : public HWCDisplay {
virtual int GetFrameCaptureStatus() { return frame_capture_status_; }
virtual DisplayError SetDetailEnhancerConfig(const DisplayDetailEnhancerData &de_data);
virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending);
virtual DisplayError SetStandByMode(bool enable);
private:
HWCDisplayPrimary(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
@ -102,6 +104,11 @@ class HWCDisplayPrimary : public HWCDisplay {
BufferInfo output_buffer_info_ = {};
void *output_buffer_base_ = nullptr;
int default_mode_status_ = 0;
//Null display
DisplayNull display_null_;
DisplayInterface *stored_display_intf_ = NULL;
};
} // namespace sdm

View File

@ -1015,6 +1015,10 @@ android::status_t HWCSession::notifyCallback(uint32_t command, const android::Pa
status = SetColorModeOverride(input_parcel);
break;
case qService::IQService::SET_STAND_BY_MODE:
status = SetStandByMode(input_parcel);
break;
default:
DLOGW("QService command = %d is not supported", command);
return -EINVAL;
@ -1501,6 +1505,21 @@ android::status_t HWCSession::GetVisibleDisplayRect(const android::Parcel *input
return android::NO_ERROR;
}
android::status_t HWCSession::SetStandByMode(const android::Parcel *input_parcel) {
SCOPE_LOCK(locker_);
bool enable = (input_parcel->readInt32() > 0);
if (!hwc_display_[HWC_DISPLAY_PRIMARY]) {
DLOGI("Primary display is not initialized");
return -EINVAL;
}
hwc_display_[HWC_DISPLAY_PRIMARY]->SetStandByMode(enable);
return android::NO_ERROR;
}
void HWCSession::Refresh(hwc2_display_t display) {
SCOPE_LOCK(callbacks_lock_);
HWC2::Error err = callbacks_.Refresh(display);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
@ -218,6 +218,7 @@ class HWCSession : hwc2_device_t, HWCUEventListener, IDisplayConfig, public qCli
android::Parcel *output_parcel);
android::status_t SetMixerResolution(const android::Parcel *input_parcel);
android::status_t SetColorModeOverride(const android::Parcel *input_parcel);
android::status_t SetStandByMode(const android::Parcel *input_parcel);
void Refresh(hwc2_display_t display);
void HotPlug(hwc2_display_t display, HWC2::Connection state);