diff --git a/composer/display_null.cpp b/composer/display_null.cpp index e0697d5cd..4a7e205f0 100644 --- a/composer/display_null.cpp +++ b/composer/display_null.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. +* Copyright (c) 2017-2021, 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 @@ -118,7 +118,9 @@ DisplayError DisplayNull::Prepare(LayerStack *layer_stack) { } for (auto layer : layer_stack->layers) { - layer->composition = kCompositionGPU; + if (layer->composition != kCompositionGPUTarget) { + layer->composition = kCompositionGPU; + } } return kErrorNone; } diff --git a/composer/display_null.h b/composer/display_null.h index ba2cfb4ec..34a44ae7b 100644 --- a/composer/display_null.h +++ b/composer/display_null.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. +* Copyright (c) 2017-2019, 2021, 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 @@ -123,6 +123,12 @@ class DisplayNull : public DisplayInterface { MAKE_NO_OP(SetDisplayElapseTime(uint64_t)) MAKE_NO_OP(ClearLUTs()) + void SetActive(bool active) { active_ = active; } + bool IsActive() { return active_; } + + private: + bool active_ = false; + protected: DisplayConfigVariableInfo default_variable_config_ = {}; DisplayConfigFixedInfo default_fixed_config_ = {}; @@ -150,11 +156,7 @@ class DisplayNullExternal : public DisplayNull { virtual DisplayError GetFrameBufferConfig(DisplayConfigVariableInfo *variable_info); virtual DisplayError GetDisplayIdentificationData(uint8_t *out_port, uint32_t *out_data_size, uint8_t *out_data); - void SetActive(bool active) { active_ = active; } - bool IsActive() { return active_; } - private: - bool active_ = false; DisplayState state_ = kStateOff; DisplayConfigVariableInfo fb_config_ = {}; }; diff --git a/composer/hwc_display.h b/composer/hwc_display.h index a758b25fa..cebbc8d64 100644 --- a/composer/hwc_display.h +++ b/composer/hwc_display.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright 2015 The Android Open Source Project @@ -248,6 +248,9 @@ class HWCDisplay : public DisplayEventHandler { virtual int SetState(bool connected) { return kErrorNotSupported; } + virtual DisplayError SetStandByMode(bool enable) { + return kErrorNotSupported; + } virtual DisplayError Flush() { return kErrorNotSupported; } diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp index 69395da6c..22f6f275d 100644 --- a/composer/hwc_display_builtin.cpp +++ b/composer/hwc_display_builtin.cpp @@ -1239,6 +1239,29 @@ DisplayError HWCDisplayBuiltIn::GetSupportedDSIClock(std::vector *bitc return kErrorNotSupported; } +DisplayError HWCDisplayBuiltIn::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_ = false; + display_null_.SetActive(false); + DLOGD("Display is connected successfully"); + } else { + DLOGD("Display is already connected."); + } + } + return kErrorNone; +} + HWC2::Error HWCDisplayBuiltIn::UpdateDisplayId(hwc2_display_t id) { id_ = id; return HWC2::Error::None; diff --git a/composer/hwc_display_builtin.h b/composer/hwc_display_builtin.h index 8629c2488..aab416fdc 100644 --- a/composer/hwc_display_builtin.h +++ b/composer/hwc_display_builtin.h @@ -40,6 +40,7 @@ #include "cpuhint.h" #include "hwc_display.h" #include "hwc_layers.h" +#include "display_null.h" #include "gl_layer_stitch.h" @@ -112,6 +113,7 @@ class HWCDisplayBuiltIn : public HWCDisplay, public SyncTask *bitclk_rates); + virtual DisplayError SetStandByMode(bool enable); virtual HWC2::Error UpdateDisplayId(hwc2_display_t id); virtual HWC2::Error SetPendingRefresh(); virtual HWC2::Error SetPanelBrightness(float brightness); @@ -233,6 +235,10 @@ class HWCDisplayBuiltIn : public HWCDisplay, public SyncTaskreadInt32() > 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; +} + int HWCSession::CreatePrimaryDisplay() { int status = -EINVAL; HWDisplaysInfo hw_displays_info = {}; diff --git a/composer/hwc_session.h b/composer/hwc_session.h index 5044e5d91..1314a12fe 100644 --- a/composer/hwc_session.h +++ b/composer/hwc_session.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright 2015 The Android Open Source Project @@ -478,6 +478,7 @@ class HWCSession : hwc2_device_t, HWCUEventListener, public qClient::BnQClient, android::status_t SetColorModeById(const android::Parcel *input_parcel); android::status_t SetColorModeFromClient(const android::Parcel *input_parcel); android::status_t getComposerStatus(); + android::status_t SetStandByMode(const android::Parcel *input_parcel); android::status_t SetQSyncMode(const android::Parcel *input_parcel); android::status_t SetIdlePC(const android::Parcel *input_parcel); android::status_t RefreshScreen(const android::Parcel *input_parcel); diff --git a/libqdutils/display_config.cpp b/libqdutils/display_config.cpp index 8f27200d6..0157a536c 100644 --- a/libqdutils/display_config.cpp +++ b/libqdutils/display_config.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2014, 2016, 2018-2020, The Linux Foundation. All rights reserved. +* Copyright (c) 2013-2014, 2016, 2018-2021, 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 @@ -393,3 +393,19 @@ extern "C" int waitForComposerInit() { return !status; } + +extern "C" int setStandByMode(int mode) { + status_t err = (status_t) FAILED_TRANSACTION; + sp 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; +} diff --git a/libqdutils/display_config.h b/libqdutils/display_config.h index 21aea6068..81f22d751 100644 --- a/libqdutils/display_config.h +++ b/libqdutils/display_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 - 2016, 2018 - 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2013 - 2016, 2018 - 2021, 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 @@ -170,6 +170,9 @@ int getSupportedBitClk(int dpy, std::vector& bit_rates); // Sets the specified min and max luminance values. int setPanelLuminanceAttributes(int dpy, float min_lum, float max_lum); +// Sets display standy mode +extern "C" int setStandByMode(int mode); + }; //namespace diff --git a/libqservice/IQService.h b/libqservice/IQService.h index 920f27c54..473de12bf 100644 --- a/libqservice/IQService.h +++ b/libqservice/IQService.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 The Android Open Source Project - * Copyright (C) 2012-2014, 2016-2019 The Linux Foundation. All rights reserved. + * Copyright (C) 2012-2014, 2016-2019, 2021, The Linux Foundation. All rights reserved. * * Not a Contribution, Apache license notifications and license are * retained for attribution purposes only. @@ -79,6 +79,7 @@ class IQService : public android::IInterface SET_PANEL_LUMINANCE = 47, // Set Panel Luminance attributes. SET_BRIGHTNESS_SCALE = 48, // Set brightness scale ratio SET_COLOR_SAMPLING_ENABLED = 49, // Toggle the collection of display color stats + SET_STAND_BY_MODE = 50, // Set stand by mode for MDP hardware COMMAND_LIST_END = 400, };