Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 1 | /* |
Gousemoodhin Nadaf | 087c310 | 2019-01-07 19:34:56 +0530 | [diff] [blame] | 2 | * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 3 | * Not a Contribution. |
| 4 | * |
| 5 | * Copyright 2015 The Android Open Source Project |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | #ifndef __HWC_DISPLAY_H__ |
| 21 | #define __HWC_DISPLAY_H__ |
| 22 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 23 | #include <QService.h> |
Gousemoodhin Nadaf | 0e56687 | 2019-05-13 16:14:54 +0530 | [diff] [blame] | 24 | #include <android/hardware/graphics/common/1.2/types.h> |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 25 | #include <core/core_interface.h> |
| 26 | #include <hardware/hwcomposer.h> |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 27 | #include <private/color_params.h> |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 28 | #include <qdMetaData.h> |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 29 | #include <sys/stat.h> |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 30 | #include <map> |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 31 | #include <queue> |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 32 | #include <set> |
Naseer Ahmed | 2a3c7d9 | 2016-05-17 18:38:54 -0400 | [diff] [blame] | 33 | #include <string> |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 34 | #include <utility> |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 35 | #include <vector> |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 36 | #include <bitset> |
Mahesh Aia | f3a1f99 | 2019-01-16 13:07:42 -0800 | [diff] [blame] | 37 | #include <algorithm> |
Naseer Ahmed | 4275221 | 2017-01-27 17:32:21 -0500 | [diff] [blame] | 38 | #include "hwc_buffer_allocator.h" |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 39 | #include "hwc_callbacks.h" |
| 40 | #include "hwc_layers.h" |
Varun Arora | 465c1f7 | 2018-02-08 16:18:50 -0800 | [diff] [blame] | 41 | #include "display_null.h" |
Varun Arora | 7c8ee54 | 2018-05-01 20:58:16 -0700 | [diff] [blame] | 42 | #include "hwc_display_event_handler.h" |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 43 | |
Gousemoodhin Nadaf | 0e56687 | 2019-05-13 16:14:54 +0530 | [diff] [blame] | 44 | using android::hardware::graphics::common::V1_2::ColorMode; |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 45 | using android::hardware::graphics::common::V1_1::Dataspace; |
| 46 | using android::hardware::graphics::common::V1_1::RenderIntent; |
| 47 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 48 | namespace sdm { |
| 49 | |
Arun Kumar K.R | 51be3d1 | 2017-03-31 19:54:38 -0700 | [diff] [blame] | 50 | class HWCToneMapper; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 51 | |
Xu Yang | 47f4409 | 2019-02-13 14:09:53 +0800 | [diff] [blame] | 52 | /* max customer extended render intent */ |
| 53 | #define MAX_EXTENDED_RENDER_INTENT 0x1ff |
| 54 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 55 | // Subclasses set this to their type. This has to be different from DisplayType. |
| 56 | // This is to avoid RTTI and dynamic_cast |
| 57 | enum DisplayClass { |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 58 | DISPLAY_CLASS_BUILTIN, |
| 59 | DISPLAY_CLASS_PLUGGABLE, |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 60 | DISPLAY_CLASS_VIRTUAL, |
| 61 | DISPLAY_CLASS_NULL |
| 62 | }; |
| 63 | |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 64 | enum SecureSessionType { |
| 65 | kSecureDisplay, |
| 66 | kSecureCamera, |
| 67 | kSecureMax, |
| 68 | }; |
| 69 | |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame^] | 70 | // CWB client currently using the block |
| 71 | enum CWBClient { |
| 72 | kCWBClientNone, // No client connected |
| 73 | kCWBClientFrameDump, // Dump to file |
| 74 | kCWBClientColor, // Internal client i.e. Color Manager |
| 75 | kCWBClientExternal, // External client calling through private APIs |
| 76 | kCWBClientComposer, // Client to HWC i.e. SurfaceFlinger |
| 77 | }; |
| 78 | |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 79 | class HWCColorMode { |
| 80 | public: |
| 81 | explicit HWCColorMode(DisplayInterface *display_intf); |
| 82 | ~HWCColorMode() {} |
| 83 | HWC2::Error Init(); |
| 84 | HWC2::Error DeInit(); |
Naseer Ahmed | 913502b | 2017-04-18 16:05:05 -0400 | [diff] [blame] | 85 | void Dump(std::ostringstream* os); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 86 | uint32_t GetColorModeCount(); |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 87 | uint32_t GetRenderIntentCount(ColorMode mode); |
| 88 | HWC2::Error GetColorModes(uint32_t *out_num_modes, ColorMode *out_modes); |
| 89 | HWC2::Error GetRenderIntents(ColorMode mode, uint32_t *out_num_intents, RenderIntent *out_modes); |
| 90 | HWC2::Error SetColorModeWithRenderIntent(ColorMode mode, RenderIntent intent); |
Naseer Ahmed | 6776dae | 2017-05-09 11:49:41 -0400 | [diff] [blame] | 91 | HWC2::Error SetColorModeById(int32_t color_mode_id); |
Xu Yang | 84e6141 | 2018-12-06 14:52:16 +0800 | [diff] [blame] | 92 | HWC2::Error SetColorModeFromClientApi(std::string mode_string); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 93 | HWC2::Error SetColorTransform(const float *matrix, android_color_transform_t hint); |
Ch Ganesh Kumar | 5d43ff6 | 2017-10-13 19:01:47 +0530 | [diff] [blame] | 94 | HWC2::Error RestoreColorTransform(); |
Gousemoodhin Nadaf | 839f29d | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 95 | ColorMode GetCurrentColorMode() { return current_color_mode_; } |
Xu Yang | 84e6141 | 2018-12-06 14:52:16 +0800 | [diff] [blame] | 96 | HWC2::Error ApplyCurrentColorModeWithRenderIntent(bool hdr_present); |
Sushil Chauhan | 8008d60 | 2018-09-04 14:43:27 -0700 | [diff] [blame] | 97 | HWC2::Error CacheColorModeWithRenderIntent(ColorMode mode, RenderIntent intent); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 98 | |
| 99 | private: |
| 100 | static const uint32_t kColorTransformMatrixCount = 16; |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 101 | void PopulateColorModes(); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 102 | template <class T> |
| 103 | void CopyColorTransformMatrix(const T *input_matrix, double *output_matrix) { |
| 104 | for (uint32_t i = 0; i < kColorTransformMatrixCount; i++) { |
| 105 | output_matrix[i] = static_cast<double>(input_matrix[i]); |
| 106 | } |
| 107 | } |
Qing Huang | 3f21afb | 2017-04-19 15:11:49 +0800 | [diff] [blame] | 108 | HWC2::Error ApplyDefaultColorMode(); |
Sushil Chauhan | 8008d60 | 2018-09-04 14:43:27 -0700 | [diff] [blame] | 109 | HWC2::Error ValidateColorModeWithRenderIntent(ColorMode mode, RenderIntent intent); |
Xu Yang | 84e6141 | 2018-12-06 14:52:16 +0800 | [diff] [blame] | 110 | HWC2::Error SetPreferredColorModeInternal(const std::string &mode_string, bool from_client, |
| 111 | ColorMode *color_mode, DynamicRangeType *dynamic_range); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 112 | |
| 113 | DisplayInterface *display_intf_ = NULL; |
Sushil Chauhan | 7cd110d | 2018-08-24 17:17:55 -0700 | [diff] [blame] | 114 | bool apply_mode_ = false; |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 115 | ColorMode current_color_mode_ = ColorMode::NATIVE; |
| 116 | RenderIntent current_render_intent_ = RenderIntent::COLORIMETRIC; |
Xu Yang | 84e6141 | 2018-12-06 14:52:16 +0800 | [diff] [blame] | 117 | DynamicRangeType curr_dynamic_range_ = kSdrType; |
| 118 | typedef std::map<DynamicRangeType, std::string> DynamicRangeMap; |
| 119 | typedef std::map<RenderIntent, DynamicRangeMap> RenderIntentMap; |
| 120 | // Initialize supported mode/render intent/dynamic range combination |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 121 | std::map<ColorMode, RenderIntentMap> color_mode_map_ = {}; |
Naseer Ahmed | 7dcd137 | 2017-05-19 18:06:51 -0400 | [diff] [blame] | 122 | double color_matrix_[kColorTransformMatrixCount] = { 1.0, 0.0, 0.0, 0.0, \ |
| 123 | 0.0, 1.0, 0.0, 0.0, \ |
| 124 | 0.0, 0.0, 1.0, 0.0, \ |
| 125 | 0.0, 0.0, 0.0, 1.0 }; |
Xu Yang | 84e6141 | 2018-12-06 14:52:16 +0800 | [diff] [blame] | 126 | std::map<ColorMode, DynamicRangeMap> preferred_mode_ = {}; |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 127 | }; |
| 128 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 129 | class HWCDisplay : public DisplayEventHandler { |
| 130 | public: |
Dileep Marchya | 6860b2b | 2017-04-07 15:56:47 +0530 | [diff] [blame] | 131 | enum DisplayStatus { |
| 132 | kDisplayStatusInvalid = -1, |
| 133 | kDisplayStatusOffline, |
| 134 | kDisplayStatusOnline, |
| 135 | kDisplayStatusPause, |
| 136 | kDisplayStatusResume, |
| 137 | }; |
| 138 | |
Sushil Chauhan | e3a9fd0 | 2017-10-12 18:00:05 -0700 | [diff] [blame] | 139 | enum DisplayValidateState { |
| 140 | kNormalValidate, |
| 141 | kInternalValidate, |
| 142 | kSkipValidate, |
| 143 | }; |
| 144 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 145 | virtual ~HWCDisplay() {} |
| 146 | virtual int Init(); |
| 147 | virtual int Deinit(); |
| 148 | |
| 149 | // Framebuffer configurations |
| 150 | virtual void SetIdleTimeoutMs(uint32_t timeout_ms); |
Sushil Chauhan | 267a619 | 2018-06-06 18:41:47 -0700 | [diff] [blame] | 151 | virtual HWC2::Error SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type, |
| 152 | int32_t format, bool post_processed); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 153 | virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages); |
Arun Kumar K.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 154 | virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending) { |
| 155 | return kErrorNotSupported; |
| 156 | } |
Varun Arora | f027a22 | 2018-11-14 17:38:16 -0800 | [diff] [blame] | 157 | virtual HWC2::PowerMode GetCurrentPowerMode(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 158 | virtual int SetFrameBufferResolution(uint32_t x_pixels, uint32_t y_pixels); |
| 159 | virtual void GetFrameBufferResolution(uint32_t *x_pixels, uint32_t *y_pixels); |
Dileep Marchya | 6860b2b | 2017-04-07 15:56:47 +0530 | [diff] [blame] | 160 | virtual int SetDisplayStatus(DisplayStatus display_status); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 161 | virtual int OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level); |
| 162 | virtual int Perform(uint32_t operation, ...); |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 163 | virtual int HandleSecureSession(const std::bitset<kSecureMax> &secure_sessions, |
| 164 | bool *power_on_pending); |
| 165 | virtual int GetActiveSecureSession(std::bitset<kSecureMax> *secure_sessions); |
Arun Kumar K.R | 8da7f50 | 2016-06-07 17:45:50 -0700 | [diff] [blame] | 166 | virtual DisplayError SetMixerResolution(uint32_t width, uint32_t height); |
| 167 | virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height); |
| 168 | virtual void GetPanelResolution(uint32_t *width, uint32_t *height); |
Saurabh Shah | 9c224a3 | 2017-11-09 12:17:44 -0800 | [diff] [blame] | 169 | virtual std::string Dump(); |
Gurpreet Singh Dhami | 1207e46 | 2018-12-27 20:02:02 -0500 | [diff] [blame] | 170 | virtual DisplayError TeardownConcurrentWriteback(void) { |
| 171 | return kErrorNotSupported; |
| 172 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 173 | |
| 174 | // Captures frame output in the buffer specified by output_buffer_info. The API is |
| 175 | // non-blocking and the client is expected to check operation status later on. |
| 176 | // Returns -1 if the input is invalid. |
| 177 | virtual int FrameCaptureAsync(const BufferInfo &output_buffer_info, bool post_processed) { |
| 178 | return -1; |
| 179 | } |
Sushil Chauhan | 1d3b90c | 2018-12-11 16:52:35 -0800 | [diff] [blame] | 180 | // Returns the status of frame capture operation requested with FrameCaptureAsync(). |
| 181 | // -EAGAIN : No status obtain yet, call API again after another frame. |
| 182 | // < 0 : Operation happened but failed. |
| 183 | // 0 : Success. |
| 184 | virtual int GetFrameCaptureStatus() { return -EAGAIN; } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 185 | |
Alan Kwong | 2e13633 | 2016-08-16 07:50:16 -0400 | [diff] [blame] | 186 | virtual DisplayError SetDetailEnhancerConfig(const DisplayDetailEnhancerData &de_data) { |
| 187 | return kErrorNotSupported; |
| 188 | } |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 189 | virtual HWC2::Error SetReadbackBuffer(const native_handle_t *buffer, int32_t acquire_fence, |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame^] | 190 | bool post_processed_output, CWBClient client) { |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 191 | return HWC2::Error::Unsupported; |
| 192 | } |
| 193 | virtual HWC2::Error GetReadbackBufferFence(int32_t *release_fence) { |
| 194 | return HWC2::Error::Unsupported; |
| 195 | } |
Alan Kwong | 2e13633 | 2016-08-16 07:50:16 -0400 | [diff] [blame] | 196 | |
Yuchao Ma | 577f0f7 | 2018-07-09 11:20:00 +0800 | [diff] [blame] | 197 | virtual HWC2::Error SetDisplayDppsAdROI(uint32_t h_start, uint32_t h_end, |
| 198 | uint32_t v_start, uint32_t v_end, |
| 199 | uint32_t factor_in, uint32_t factor_out) { |
| 200 | return HWC2::Error::Unsupported; |
| 201 | } |
Xu Yang | 9dacc87 | 2018-12-25 11:04:28 +0800 | [diff] [blame] | 202 | virtual HWC2::Error SetFrameTriggerMode(uint32_t mode) { |
| 203 | return HWC2::Error::Unsupported; |
| 204 | } |
Yuchao Ma | 577f0f7 | 2018-07-09 11:20:00 +0800 | [diff] [blame] | 205 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 206 | // Display Configurations |
Mahesh Aia | f3a1f99 | 2019-01-16 13:07:42 -0800 | [diff] [blame] | 207 | static uint32_t GetThrottlingRefreshRate() { return HWCDisplay::throttling_refresh_rate_; } |
| 208 | static void SetThrottlingRefreshRate(uint32_t newRefreshRate) |
| 209 | { HWCDisplay::throttling_refresh_rate_ = newRefreshRate; } |
Dileep Marchya | 6860b2b | 2017-04-07 15:56:47 +0530 | [diff] [blame] | 210 | virtual int SetActiveDisplayConfig(uint32_t config); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 211 | virtual int GetActiveDisplayConfig(uint32_t *config); |
| 212 | virtual int GetDisplayConfigCount(uint32_t *count); |
Arun Kumar K.R | 8da7f50 | 2016-06-07 17:45:50 -0700 | [diff] [blame] | 213 | virtual int GetDisplayAttributesForConfig(int config, |
| 214 | DisplayConfigVariableInfo *display_attributes); |
Dileep Marchya | d16da3e | 2017-05-20 01:56:21 +0530 | [diff] [blame] | 215 | virtual int SetState(bool connected) { |
| 216 | return kErrorNotSupported; |
| 217 | } |
Rajavenu Kyatham | 0987b0e | 2018-02-14 18:59:26 +0530 | [diff] [blame] | 218 | virtual DisplayError Flush() { |
| 219 | return kErrorNotSupported; |
| 220 | } |
| 221 | |
Mahesh Aia | f3a1f99 | 2019-01-16 13:07:42 -0800 | [diff] [blame] | 222 | uint32_t GetMaxRefreshRate() { return max_refresh_rate_; } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 223 | int ToggleScreenUpdates(bool enable); |
| 224 | int ColorSVCRequestRoute(const PPDisplayAPIPayload &in_payload, PPDisplayAPIPayload *out_payload, |
| 225 | PPPendingParams *pending_action); |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 226 | void SolidFillPrepare(); |
| 227 | void SolidFillCommit(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 228 | DisplayClass GetDisplayClass(); |
| 229 | int GetVisibleDisplayRect(hwc_rect_t *rect); |
| 230 | void BuildLayerStack(void); |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 231 | void BuildSolidFillStack(void); |
Varun Arora | 2c23e58 | 2017-10-10 15:07:13 -0700 | [diff] [blame] | 232 | HWCLayer *GetHWCLayer(hwc2_layer_t layer_id); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 233 | void ResetValidation() { validated_ = false; } |
Sushil Chauhan | 409e844 | 2017-06-12 17:43:25 -0700 | [diff] [blame] | 234 | uint32_t GetGeometryChanges() { return geometry_changes_; } |
Sushil Chauhan | e3a9fd0 | 2017-10-12 18:00:05 -0700 | [diff] [blame] | 235 | bool CanSkipValidate(); |
Sushil Chauhan | e3a9fd0 | 2017-10-12 18:00:05 -0700 | [diff] [blame] | 236 | bool IsSkipValidateState() { return (validate_state_ == kSkipValidate); } |
| 237 | bool IsInternalValidateState() { return (validated_ && (validate_state_ == kInternalValidate)); } |
| 238 | void SetValidationState(DisplayValidateState state) { validate_state_ = state; } |
Sushil Chauhan | fea3e90 | 2018-07-31 15:34:48 -0700 | [diff] [blame] | 239 | ColorMode GetCurrentColorMode() { |
| 240 | return (color_mode_ ? color_mode_->GetCurrentColorMode() : ColorMode::SRGB); |
| 241 | } |
Sushil Chauhan | 181d950 | 2018-12-13 16:40:58 -0800 | [diff] [blame] | 242 | bool HWCClientNeedsValidate() { |
| 243 | return (has_client_composition_ || layer_stack_.flags.single_buffered_layer_present); |
| 244 | } |
Sushil Chauhan | 9c07ad0 | 2019-02-28 12:07:35 -0800 | [diff] [blame] | 245 | virtual void SetFastPathComposition(bool enable) { fast_path_composition_ = enable; } |
Xu Yang | 84e6141 | 2018-12-06 14:52:16 +0800 | [diff] [blame] | 246 | virtual HWC2::Error SetColorModeFromClientApi(int32_t color_mode_id) { |
| 247 | return HWC2::Error::Unsupported; |
| 248 | } |
Mathew Joseph Karimpanal | abe3b3d | 2018-11-27 17:25:40 +0530 | [diff] [blame] | 249 | bool IsFirstCommitDone() { return !first_cycle_; } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 250 | |
| 251 | // HWC2 APIs |
| 252 | virtual HWC2::Error AcceptDisplayChanges(void); |
| 253 | virtual HWC2::Error GetActiveConfig(hwc2_config_t *out_config); |
| 254 | virtual HWC2::Error SetActiveConfig(hwc2_config_t config); |
Archit Srivastava | a59c4ff | 2019-05-20 10:54:22 +0530 | [diff] [blame] | 255 | virtual HWC2::Error SetPanelLuminanceAttributes(float min_lum, float max_lum) { |
| 256 | return HWC2::Error::Unsupported; |
| 257 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 258 | virtual HWC2::Error SetClientTarget(buffer_handle_t target, int32_t acquire_fence, |
Naseer Ahmed | a20c4c0 | 2016-06-03 17:48:28 -0400 | [diff] [blame] | 259 | int32_t dataspace, hwc_region_t damage); |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 260 | virtual HWC2::Error SetColorMode(ColorMode mode) { return HWC2::Error::Unsupported; } |
| 261 | virtual HWC2::Error SetColorModeWithRenderIntent(ColorMode mode, RenderIntent intent) { |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 262 | return HWC2::Error::Unsupported; |
| 263 | } |
Naseer Ahmed | 6776dae | 2017-05-09 11:49:41 -0400 | [diff] [blame] | 264 | virtual HWC2::Error SetColorModeById(int32_t color_mode_id) { |
| 265 | return HWC2::Error::Unsupported; |
| 266 | } |
Ch Ganesh Kumar | 5d43ff6 | 2017-10-13 19:01:47 +0530 | [diff] [blame] | 267 | virtual HWC2::Error RestoreColorTransform() { |
| 268 | return HWC2::Error::Unsupported; |
| 269 | } |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 270 | virtual HWC2::Error SetColorTransform(const float *matrix, android_color_transform_t hint) { |
| 271 | return HWC2::Error::Unsupported; |
| 272 | } |
Naseer Ahmed | eae2812 | 2016-06-27 15:47:05 -0400 | [diff] [blame] | 273 | virtual HWC2::Error HandleColorModeTransform(android_color_mode_t mode, |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 274 | android_color_transform_t hint, |
| 275 | const double *matrix) { |
| 276 | return HWC2::Error::Unsupported; |
| 277 | } |
Pullakavi Srinivas | 9189e60 | 2018-12-19 16:58:07 +0530 | [diff] [blame] | 278 | virtual DisplayError SetDynamicDSIClock(uint64_t bitclk) { |
| 279 | return kErrorNotSupported; |
| 280 | } |
| 281 | virtual DisplayError GetDynamicDSIClock(uint64_t *bitclk) { |
| 282 | return kErrorNotSupported; |
| 283 | } |
| 284 | virtual DisplayError GetSupportedDSIClock(std::vector<uint64_t> *bitclk) { |
| 285 | return kErrorNotSupported; |
| 286 | } |
Padmanabhan Komanduru | e74cf4f | 2019-04-25 17:38:43 -0700 | [diff] [blame] | 287 | virtual HWC2::Error UpdateDisplayId(hwc2_display_t id) { |
| 288 | return HWC2::Error::Unsupported; |
| 289 | } |
| 290 | virtual HWC2::Error SetPendingRefresh() { |
| 291 | return HWC2::Error::Unsupported; |
| 292 | } |
Varun Arora | 75c05f0 | 2019-05-14 14:53:37 -0700 | [diff] [blame] | 293 | virtual HWC2::Error SetPanelBrightness(float brightness) { |
| 294 | return HWC2::Error::Unsupported; |
| 295 | } |
| 296 | virtual HWC2::Error GetPanelBrightness(float *brightness) { |
| 297 | return HWC2::Error::Unsupported; |
| 298 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 299 | virtual HWC2::Error GetDisplayConfigs(uint32_t *out_num_configs, hwc2_config_t *out_configs); |
| 300 | virtual HWC2::Error GetDisplayAttribute(hwc2_config_t config, HWC2::Attribute attribute, |
| 301 | int32_t *out_value); |
| 302 | virtual HWC2::Error GetClientTargetSupport(uint32_t width, uint32_t height, int32_t format, |
| 303 | int32_t dataspace); |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 304 | virtual HWC2::Error GetColorModes(uint32_t *outNumModes, ColorMode *outModes); |
| 305 | virtual HWC2::Error GetRenderIntents(ColorMode mode, uint32_t *out_num_intents, |
| 306 | RenderIntent *out_intents); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 307 | virtual HWC2::Error GetChangedCompositionTypes(uint32_t *out_num_elements, |
| 308 | hwc2_layer_t *out_layers, int32_t *out_types); |
| 309 | virtual HWC2::Error GetDisplayRequests(int32_t *out_display_requests, uint32_t *out_num_elements, |
| 310 | hwc2_layer_t *out_layers, int32_t *out_layer_requests); |
| 311 | virtual HWC2::Error GetDisplayName(uint32_t *out_size, char *out_name); |
| 312 | virtual HWC2::Error GetDisplayType(int32_t *out_type); |
| 313 | virtual HWC2::Error SetCursorPosition(hwc2_layer_t layer, int x, int y); |
| 314 | virtual HWC2::Error SetVsyncEnabled(HWC2::Vsync enabled); |
Varun Arora | 78580b8 | 2018-09-10 13:59:57 -0700 | [diff] [blame] | 315 | virtual HWC2::Error SetPowerMode(HWC2::PowerMode mode, bool teardown); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 316 | virtual HWC2::Error CreateLayer(hwc2_layer_t *out_layer_id); |
| 317 | virtual HWC2::Error DestroyLayer(hwc2_layer_t layer_id); |
| 318 | virtual HWC2::Error SetLayerZOrder(hwc2_layer_t layer_id, uint32_t z); |
| 319 | virtual HWC2::Error Validate(uint32_t *out_num_types, uint32_t *out_num_requests) = 0; |
| 320 | virtual HWC2::Error GetReleaseFences(uint32_t *out_num_elements, hwc2_layer_t *out_layers, |
| 321 | int32_t *out_fences); |
| 322 | virtual HWC2::Error Present(int32_t *out_retire_fence) = 0; |
Arun Kumar K.R | f28957a | 2017-01-10 17:36:52 -0800 | [diff] [blame] | 323 | virtual HWC2::Error GetHdrCapabilities(uint32_t *out_num_types, int32_t* out_types, |
| 324 | float* out_max_luminance, |
| 325 | float* out_max_average_luminance, |
| 326 | float* out_min_luminance); |
Naseer Ahmed | a6782e4 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 327 | virtual HWC2::Error GetPerFrameMetadataKeys(uint32_t *out_num_keys, |
| 328 | PerFrameMetadataKey *out_keys); |
Naseer Ahmed | a699e79 | 2017-11-09 15:08:31 -0500 | [diff] [blame] | 329 | virtual HWC2::Error SetDisplayAnimating(bool animating) { |
| 330 | animating_ = animating; |
Ramkumar Radhakrishnan | ae338ae | 2017-11-27 21:27:25 -0800 | [diff] [blame] | 331 | validated_ = false; |
Naseer Ahmed | a699e79 | 2017-11-09 15:08:31 -0500 | [diff] [blame] | 332 | return HWC2::Error::None; |
| 333 | } |
Sushil Chauhan | e3a9fd0 | 2017-10-12 18:00:05 -0700 | [diff] [blame] | 334 | virtual HWC2::Error GetValidateDisplayOutput(uint32_t *out_num_types, uint32_t *out_num_requests); |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 335 | virtual bool IsDisplayCommandMode(); |
Sushil Chauhan | 380a59d | 2018-03-19 15:47:50 -0700 | [diff] [blame] | 336 | virtual HWC2::Error SetQSyncMode(QSyncMode qsync_mode) { |
| 337 | return HWC2::Error::Unsupported; |
| 338 | } |
Ramkumar Radhakrishnan | 4faf8a6 | 2018-11-15 17:15:37 -0800 | [diff] [blame] | 339 | virtual DisplayError ControlIdlePowerCollapse(bool enable, bool synchronous) { |
| 340 | return kErrorNone; |
Ramkumar Radhakrishnan | f985d48 | 2018-07-23 18:10:41 -0700 | [diff] [blame] | 341 | } |
Varun Arora | 6ba9eda | 2019-02-07 17:59:32 -0800 | [diff] [blame] | 342 | virtual HWC2::Error GetDisplayIdentificationData(uint8_t *out_port, uint32_t *out_data_size, |
| 343 | uint8_t *out_data); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 344 | |
| 345 | protected: |
Mahesh Aia | f3a1f99 | 2019-01-16 13:07:42 -0800 | [diff] [blame] | 346 | static uint32_t throttling_refresh_rate_; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 347 | // Maximum number of layers supported by display manager. |
| 348 | static const uint32_t kMaxLayerCount = 32; |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 349 | HWCDisplay(CoreInterface *core_intf, BufferAllocator *buffer_allocator, HWCCallbacks *callbacks, |
| 350 | HWCDisplayEventHandler *event_handler, qService::QService *qservice, DisplayType type, |
Gousemoodhin Nadaf | 087c310 | 2019-01-07 19:34:56 +0530 | [diff] [blame] | 351 | hwc2_display_t id, int32_t sdm_id, DisplayClass display_class); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 352 | |
| 353 | // DisplayEventHandler methods |
| 354 | virtual DisplayError VSync(const DisplayEventVSync &vsync); |
| 355 | virtual DisplayError Refresh(); |
| 356 | virtual DisplayError CECMessage(char *message); |
Sushil Chauhan | 409e844 | 2017-06-12 17:43:25 -0700 | [diff] [blame] | 357 | virtual DisplayError HandleEvent(DisplayEvent event); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 358 | virtual void DumpOutputBuffer(const BufferInfo &buffer_info, void *base, int fence); |
| 359 | virtual HWC2::Error PrepareLayerStack(uint32_t *out_num_types, uint32_t *out_num_requests); |
| 360 | virtual HWC2::Error CommitLayerStack(void); |
| 361 | virtual HWC2::Error PostCommitLayerStack(int32_t *out_retire_fence); |
Arun Kumar K.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 362 | virtual DisplayError DisablePartialUpdateOneFrame() { |
| 363 | return kErrorNotSupported; |
| 364 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 365 | const char *GetDisplayString(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 366 | void MarkLayersForGPUBypass(void); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 367 | void MarkLayersForClientComposition(void); |
Pullakavi Srinivas | 9189e60 | 2018-12-19 16:58:07 +0530 | [diff] [blame] | 368 | void UpdateConfigs(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 369 | virtual void ApplyScanAdjustment(hwc_rect_t *display_frame); |
Ramakant Singh | 5db0dfb | 2017-08-23 12:34:57 +0530 | [diff] [blame] | 370 | uint32_t GetUpdatingLayersCount(void); |
Sushil Chauhan | 9735cf8 | 2018-07-10 12:06:01 -0700 | [diff] [blame] | 371 | bool IsLayerUpdating(HWCLayer *layer); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 372 | uint32_t SanitizeRefreshRate(uint32_t req_refresh_rate); |
Sushil Chauhan | 409e844 | 2017-06-12 17:43:25 -0700 | [diff] [blame] | 373 | virtual void GetUnderScanConfig() { } |
Arun Kumar K.R | 5b82155 | 2018-12-07 08:00:15 +0530 | [diff] [blame] | 374 | int32_t SetClientTargetDataSpace(int32_t dataspace); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 375 | |
| 376 | enum { |
| 377 | INPUT_LAYER_DUMP, |
| 378 | OUTPUT_LAYER_DUMP, |
| 379 | }; |
| 380 | |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 381 | bool validated_ = false; |
Saurabh Shah | dccc0f4 | 2018-01-15 15:59:56 -0800 | [diff] [blame] | 382 | bool layer_stack_invalid_ = true; |
Naseer Ahmed | 72dea24 | 2016-05-03 19:13:07 -0400 | [diff] [blame] | 383 | CoreInterface *core_intf_ = nullptr; |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 384 | HWCBufferAllocator *buffer_allocator_ = NULL; |
Naseer Ahmed | 72dea24 | 2016-05-03 19:13:07 -0400 | [diff] [blame] | 385 | HWCCallbacks *callbacks_ = nullptr; |
Varun Arora | 7c8ee54 | 2018-05-01 20:58:16 -0700 | [diff] [blame] | 386 | HWCDisplayEventHandler *event_handler_ = nullptr; |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 387 | DisplayType type_ = kDisplayTypeMax; |
| 388 | hwc2_display_t id_ = UINT64_MAX; |
| 389 | int32_t sdm_id_ = -1; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 390 | DisplayInterface *display_intf_ = NULL; |
| 391 | LayerStack layer_stack_; |
Naseer Ahmed | 72dea24 | 2016-05-03 19:13:07 -0400 | [diff] [blame] | 392 | HWCLayer *client_target_ = nullptr; // Also known as framebuffer target |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 393 | std::map<hwc2_layer_t, HWCLayer *> layer_map_; // Look up by Id - TODO |
| 394 | std::multiset<HWCLayer *, SortLayersByZ> layer_set_; // Maintain a set sorted by Z |
| 395 | std::map<hwc2_layer_t, HWC2::Composition> layer_changes_; |
| 396 | std::map<hwc2_layer_t, HWC2::LayerRequest> layer_requests_; |
| 397 | bool flush_on_error_ = false; |
| 398 | bool flush_ = false; |
| 399 | uint32_t dump_frame_count_ = 0; |
| 400 | uint32_t dump_frame_index_ = 0; |
| 401 | bool dump_input_layers_ = false; |
Varun Arora | f027a22 | 2018-11-14 17:38:16 -0800 | [diff] [blame] | 402 | HWC2::PowerMode current_power_mode_ = HWC2::PowerMode::Off; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 403 | bool swap_interval_zero_ = false; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 404 | bool display_paused_ = false; |
| 405 | uint32_t min_refresh_rate_ = 0; |
| 406 | uint32_t max_refresh_rate_ = 0; |
| 407 | uint32_t current_refresh_rate_ = 0; |
| 408 | bool use_metadata_refresh_rate_ = false; |
| 409 | uint32_t metadata_refresh_rate_ = 0; |
| 410 | uint32_t force_refresh_rate_ = 0; |
| 411 | bool boot_animation_completed_ = false; |
| 412 | bool shutdown_pending_ = false; |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 413 | std::bitset<kSecureMax> active_secure_sessions_ = 0; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 414 | bool solid_fill_enable_ = false; |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 415 | Layer *solid_fill_layer_ = NULL; |
| 416 | LayerRect solid_fill_rect_ = {}; |
Gopikrishnaiah Anandan | cc12306 | 2017-07-31 17:21:03 -0700 | [diff] [blame] | 417 | LayerSolidFill solid_fill_color_ = {}; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 418 | LayerRect display_rect_; |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 419 | bool color_tranform_failed_ = false; |
| 420 | HWCColorMode *color_mode_ = NULL; |
Arun Kumar K.R | 51be3d1 | 2017-03-31 19:54:38 -0700 | [diff] [blame] | 421 | HWCToneMapper *tone_mapper_ = nullptr; |
Rajavenu Kyatham | 40fc538 | 2017-07-12 18:36:55 +0530 | [diff] [blame] | 422 | uint32_t num_configs_ = 0; |
Arun Kumar K.R | 2be0bf8 | 2017-05-24 15:14:41 +0530 | [diff] [blame] | 423 | int disable_hdr_handling_ = 0; // disables HDR handling. |
Namit Solanki | 5b428dc | 2018-02-27 11:39:05 +0530 | [diff] [blame] | 424 | bool pending_commit_ = false; |
Tharaga Balachandran | 04192a6 | 2018-08-29 16:23:25 -0400 | [diff] [blame] | 425 | bool is_cmd_mode_ = false; |
| 426 | bool partial_update_enabled_ = false; |
Sushil Chauhan | 7bd2066 | 2018-08-20 17:51:32 -0700 | [diff] [blame] | 427 | bool fast_path_composition_ = false; |
Padmanabhan Komanduru | e74cf4f | 2019-04-25 17:38:43 -0700 | [diff] [blame] | 428 | bool skip_commit_ = false; |
Pullakavi Srinivas | 9189e60 | 2018-12-19 16:58:07 +0530 | [diff] [blame] | 429 | std::map<uint32_t, DisplayConfigVariableInfo> variable_config_map_; |
| 430 | std::vector<uint32_t> hwc_config_map_; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 431 | |
| 432 | private: |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 433 | void DumpInputBuffers(void); |
Sushil Chauhan | 36c059a | 2018-06-28 11:39:01 -0700 | [diff] [blame] | 434 | bool CanSkipSdmPrepare(uint32_t *num_types, uint32_t *num_requests); |
Pullakavi Srinivas | 3dbb0d9 | 2018-03-07 15:15:14 +0530 | [diff] [blame] | 435 | void UpdateRefreshRate(); |
Rajavenu Kyatham | af26f40 | 2019-02-13 15:04:03 +0530 | [diff] [blame] | 436 | void WaitOnPreviousFence(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 437 | qService::QService *qservice_ = NULL; |
| 438 | DisplayClass display_class_; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 439 | uint32_t geometry_changes_ = GeometryChanges::kNone; |
Naseer Ahmed | a699e79 | 2017-11-09 15:08:31 -0500 | [diff] [blame] | 440 | bool animating_ = false; |
Varun Arora | 465c1f7 | 2018-02-08 16:18:50 -0800 | [diff] [blame] | 441 | int null_display_mode_ = 0; |
Sushil Chauhan | e3a9fd0 | 2017-10-12 18:00:05 -0700 | [diff] [blame] | 442 | bool has_client_composition_ = false; |
| 443 | DisplayValidateState validate_state_ = kNormalValidate; |
Sushil Chauhan | 7bd2066 | 2018-08-20 17:51:32 -0700 | [diff] [blame] | 444 | bool fast_path_enabled_ = true; |
Mathew Joseph Karimpanal | abe3b3d | 2018-11-27 17:25:40 +0530 | [diff] [blame] | 445 | bool first_cycle_ = true; // false if a display commit has succeeded on the device. |
Rajavenu Kyatham | 9d50958 | 2019-02-13 15:29:55 +0530 | [diff] [blame] | 446 | int fbt_release_fence_ = -1; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 447 | }; |
| 448 | |
| 449 | inline int HWCDisplay::Perform(uint32_t operation, ...) { |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | } // namespace sdm |
| 454 | |
| 455 | #endif // __HWC_DISPLAY_H__ |