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 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <cutils/properties.h> |
| 31 | #include <sync/sync.h> |
| 32 | #include <utils/constants.h> |
| 33 | #include <utils/debug.h> |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 34 | #include <utils/utils.h> |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 35 | #include <stdarg.h> |
| 36 | #include <sys/mman.h> |
| 37 | |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 38 | #include <map> |
| 39 | #include <string> |
| 40 | #include <vector> |
| 41 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 42 | #include "hwc_display_builtin.h" |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 43 | #include "hwc_debugger.h" |
Pullakavi Srinivas | 9189e60 | 2018-12-19 16:58:07 +0530 | [diff] [blame] | 44 | #include "hwc_session.h" |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 45 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 46 | #define __CLASS__ "HWCDisplayBuiltIn" |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 47 | |
| 48 | namespace sdm { |
| 49 | |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 50 | static void SetRect(LayerRect &src_rect, GLRect *target) { |
| 51 | target->left = src_rect.left; |
| 52 | target->top = src_rect.top; |
| 53 | target->right = src_rect.right; |
| 54 | target->bottom = src_rect.bottom; |
| 55 | } |
| 56 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 57 | int HWCDisplayBuiltIn::Create(CoreInterface *core_intf, BufferAllocator *buffer_allocator, |
Varun Arora | 7c8ee54 | 2018-05-01 20:58:16 -0700 | [diff] [blame] | 58 | HWCCallbacks *callbacks, HWCDisplayEventHandler *event_handler, |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 59 | qService::QService *qservice, hwc2_display_t id, int32_t sdm_id, |
| 60 | HWCDisplay **hwc_display) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 61 | int status = 0; |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 62 | uint32_t builtin_width = 0; |
| 63 | uint32_t builtin_height = 0; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 64 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 65 | HWCDisplay *hwc_display_builtin = |
| 66 | new HWCDisplayBuiltIn(core_intf, buffer_allocator, callbacks, event_handler, qservice, id, |
| 67 | sdm_id); |
| 68 | status = hwc_display_builtin->Init(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 69 | if (status) { |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 70 | delete hwc_display_builtin; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 71 | return status; |
| 72 | } |
| 73 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 74 | hwc_display_builtin->GetMixerResolution(&builtin_width, &builtin_height); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 75 | int width = 0, height = 0; |
Uday Kiran Pichika | 5e656b2 | 2018-05-15 18:48:24 +0530 | [diff] [blame] | 76 | HWCDebugHandler::Get()->GetProperty(FB_WIDTH_PROP, &width); |
| 77 | HWCDebugHandler::Get()->GetProperty(FB_HEIGHT_PROP, &height); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 78 | if (width > 0 && height > 0) { |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 79 | builtin_width = UINT32(width); |
| 80 | builtin_height = UINT32(height); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 81 | } |
| 82 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 83 | status = hwc_display_builtin->SetFrameBufferResolution(builtin_width, builtin_height); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 84 | if (status) { |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 85 | Destroy(hwc_display_builtin); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 86 | return status; |
| 87 | } |
| 88 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 89 | *hwc_display = hwc_display_builtin; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 90 | |
| 91 | return status; |
| 92 | } |
| 93 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 94 | void HWCDisplayBuiltIn::Destroy(HWCDisplay *hwc_display) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 95 | hwc_display->Deinit(); |
| 96 | delete hwc_display; |
| 97 | } |
| 98 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 99 | HWCDisplayBuiltIn::HWCDisplayBuiltIn(CoreInterface *core_intf, BufferAllocator *buffer_allocator, |
Varun Arora | 7c8ee54 | 2018-05-01 20:58:16 -0700 | [diff] [blame] | 100 | HWCCallbacks *callbacks, HWCDisplayEventHandler *event_handler, |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 101 | qService::QService *qservice, hwc2_display_t id, |
| 102 | int32_t sdm_id) |
| 103 | : HWCDisplay(core_intf, buffer_allocator, callbacks, event_handler, qservice, kBuiltIn, id, |
Gousemoodhin Nadaf | 087c310 | 2019-01-07 19:34:56 +0530 | [diff] [blame] | 104 | sdm_id, DISPLAY_CLASS_BUILTIN), |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 105 | buffer_allocator_(buffer_allocator), |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 106 | cpu_hint_(NULL), layer_stitch_task_(*this) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 107 | } |
| 108 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 109 | int HWCDisplayBuiltIn::Init() { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 110 | cpu_hint_ = new CPUHint(); |
| 111 | if (cpu_hint_->Init(static_cast<HWCDebugHandler *>(HWCDebugHandler::Get())) != kErrorNone) { |
| 112 | delete cpu_hint_; |
| 113 | cpu_hint_ = NULL; |
| 114 | } |
| 115 | |
| 116 | use_metadata_refresh_rate_ = true; |
| 117 | int disable_metadata_dynfps = 0; |
Uday Kiran Pichika | 5e656b2 | 2018-05-15 18:48:24 +0530 | [diff] [blame] | 118 | HWCDebugHandler::Get()->GetProperty(DISABLE_METADATA_DYNAMIC_FPS_PROP, &disable_metadata_dynfps); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 119 | if (disable_metadata_dynfps) { |
| 120 | use_metadata_refresh_rate_ = false; |
| 121 | } |
| 122 | |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 123 | int status = HWCDisplay::Init(); |
| 124 | if (status) { |
| 125 | return status; |
| 126 | } |
| 127 | color_mode_ = new HWCColorMode(display_intf_); |
Naseer Ahmed | 61f6095 | 2017-05-24 16:48:35 -0400 | [diff] [blame] | 128 | color_mode_->Init(); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 129 | |
Padmanabhan Komanduru | 866bf6a | 2019-03-19 14:30:48 +0530 | [diff] [blame] | 130 | int optimize_refresh = 0; |
| 131 | HWCDebugHandler::Get()->GetProperty(ENABLE_OPTIMIZE_REFRESH, &optimize_refresh); |
| 132 | enable_optimize_refresh_ = (optimize_refresh == 1); |
| 133 | if (enable_optimize_refresh_) { |
Padmanabhan Komanduru | e74cf4f | 2019-04-25 17:38:43 -0700 | [diff] [blame] | 134 | DLOGI("Drop redundant drawcycles %d", id_); |
| 135 | } |
| 136 | |
Mathew Joseph Karimpanal | b1c1586 | 2019-07-04 11:14:24 +0530 | [diff] [blame] | 137 | is_primary_ = display_intf_->IsPrimaryDisplay(); |
| 138 | |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 139 | if (!InitLayerStitch()) { |
| 140 | DLOGW("Failed to initialize Layer Stitch context"); |
| 141 | } |
| 142 | |
Naseer Ahmed | 61f6095 | 2017-05-24 16:48:35 -0400 | [diff] [blame] | 143 | return status; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 144 | } |
| 145 | |
Lakshmi Narayana Kalavala | 25fe12c | 2019-12-11 20:44:55 -0800 | [diff] [blame^] | 146 | std::string HWCDisplayBuiltIn::Dump() { |
| 147 | return HWCDisplay::Dump() + histogram.Dump(); |
| 148 | } |
| 149 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 150 | HWC2::Error HWCDisplayBuiltIn::Validate(uint32_t *out_num_types, uint32_t *out_num_requests) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 151 | auto status = HWC2::Error::None; |
| 152 | DisplayError error = kErrorNone; |
| 153 | |
Gurpreet Singh Dhami | a427688 | 2019-04-12 10:30:58 -0700 | [diff] [blame] | 154 | DTRACE_SCOPED(); |
| 155 | |
Mathew Joseph Karimpanal | b1c1586 | 2019-07-04 11:14:24 +0530 | [diff] [blame] | 156 | if (display_paused_ || (!is_primary_ && active_secure_sessions_[kSecureDisplay])) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 157 | MarkLayersForGPUBypass(); |
| 158 | return status; |
| 159 | } |
| 160 | |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 161 | if (color_tranform_failed_) { |
| 162 | // Must fall back to client composition |
| 163 | MarkLayersForClientComposition(); |
| 164 | } |
| 165 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 166 | // Fill in the remaining blanks in the layers and add them to the SDM layerstack |
| 167 | BuildLayerStack(); |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 168 | |
| 169 | // Add stitch layer to layer stack. |
| 170 | AppendStitchLayer(); |
| 171 | |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 172 | // Checks and replaces layer stack for solid fill |
| 173 | SolidFillPrepare(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 174 | |
Sushil Chauhan | 8008d60 | 2018-09-04 14:43:27 -0700 | [diff] [blame] | 175 | // Apply current Color Mode and Render Intent. |
Xu Yang | 84e6141 | 2018-12-06 14:52:16 +0800 | [diff] [blame] | 176 | if (color_mode_->ApplyCurrentColorModeWithRenderIntent( |
| 177 | static_cast<bool>(layer_stack_.flags.hdr_present)) != HWC2::Error::None) { |
Sushil Chauhan | 8008d60 | 2018-09-04 14:43:27 -0700 | [diff] [blame] | 178 | // Fallback to GPU Composition, if Color Mode can't be applied. |
| 179 | MarkLayersForClientComposition(); |
| 180 | } |
| 181 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 182 | bool pending_output_dump = dump_frame_count_ && dump_output_to_file_; |
| 183 | |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 184 | if (readback_buffer_queued_ || pending_output_dump) { |
| 185 | CloseFd(&output_buffer_.release_fence_fd); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 186 | // RHS values were set in FrameCaptureAsync() called from a binder thread. They are picked up |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 187 | // here in a subsequent draw round. Readback is not allowed for any secure use case. |
| 188 | readback_configured_ = !layer_stack_.flags.secure_present; |
| 189 | if (readback_configured_) { |
Sushil Chauhan | f42d862 | 2018-09-30 23:20:37 -0700 | [diff] [blame] | 190 | DisablePartialUpdateOneFrame(); |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 191 | layer_stack_.output_buffer = &output_buffer_; |
| 192 | layer_stack_.flags.post_processed_output = post_processed_output_; |
| 193 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 194 | } |
| 195 | |
Ramakant Singh | 5db0dfb | 2017-08-23 12:34:57 +0530 | [diff] [blame] | 196 | uint32_t num_updating_layers = GetUpdatingLayersCount(); |
| 197 | bool one_updating_layer = (num_updating_layers == 1); |
| 198 | if (num_updating_layers != 0) { |
| 199 | ToggleCPUHint(one_updating_layer); |
| 200 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 201 | |
| 202 | uint32_t refresh_rate = GetOptimalRefreshRate(one_updating_layer); |
Pullakavi Srinivas | 4619db9 | 2019-04-20 15:07:59 +0530 | [diff] [blame] | 203 | error = display_intf_->SetRefreshRate(refresh_rate, force_refresh_rate_); |
| 204 | |
| 205 | // Get the refresh rate set. |
| 206 | display_intf_->GetRefreshRate(&refresh_rate); |
| 207 | bool vsync_source = (callbacks_->GetVsyncSource() == id_); |
| 208 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 209 | if (error == kErrorNone) { |
Pullakavi Srinivas | 4619db9 | 2019-04-20 15:07:59 +0530 | [diff] [blame] | 210 | if (vsync_source && (current_refresh_rate_ < refresh_rate)) { |
| 211 | DTRACE_BEGIN("HWC2::Vsync::Enable"); |
| 212 | // Display is ramping up from idle. |
| 213 | // Client realizes need for resync upon change in config. |
| 214 | // Since we know config has changed, triggering vsync proactively |
| 215 | // can help in reducing pipeline delays to enable events. |
| 216 | SetVsyncEnabled(HWC2::Vsync::Enable); |
| 217 | DTRACE_END(); |
| 218 | } |
| 219 | // On success, set current refresh rate to new refresh rate. |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 220 | current_refresh_rate_ = refresh_rate; |
| 221 | } |
| 222 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 223 | if (layer_set_.empty()) { |
Uday Kiran Pichika | 8d82773 | 2018-01-09 18:08:38 +0530 | [diff] [blame] | 224 | // Avoid flush for Command mode panel. |
Pullakavi Srinivas | 2d55f3a | 2019-07-16 14:49:06 +0530 | [diff] [blame] | 225 | flush_ = !client_connected_; |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 226 | validated_ = true; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 227 | return status; |
| 228 | } |
| 229 | |
| 230 | status = PrepareLayerStack(out_num_types, out_num_requests); |
Namit Solanki | 5b428dc | 2018-02-27 11:39:05 +0530 | [diff] [blame] | 231 | pending_commit_ = true; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 232 | return status; |
| 233 | } |
| 234 | |
Padmanabhan Komanduru | e74cf4f | 2019-04-25 17:38:43 -0700 | [diff] [blame] | 235 | HWC2::Error HWCDisplayBuiltIn::CommitLayerStack() { |
| 236 | skip_commit_ = CanSkipCommit(); |
| 237 | return HWCDisplay::CommitLayerStack(); |
| 238 | } |
| 239 | |
| 240 | bool HWCDisplayBuiltIn::CanSkipCommit() { |
| 241 | if (layer_stack_invalid_) { |
| 242 | return false; |
| 243 | } |
| 244 | |
| 245 | // Reject repeated drawcycle requests if it satisfies all conditions. |
| 246 | // 1. None of the layerstack attributes changed. |
| 247 | // 2. No new buffer latched. |
| 248 | // 3. No refresh request triggered by HWC. |
| 249 | // 4. This display is not source of vsync. |
| 250 | bool buffers_latched = false; |
| 251 | for (auto &hwc_layer : layer_set_) { |
| 252 | buffers_latched |= hwc_layer->BufferLatched(); |
| 253 | hwc_layer->ResetBufferFlip(); |
| 254 | } |
| 255 | |
Padmanabhan Komanduru | f5e6c5d | 2019-04-04 13:56:31 +0530 | [diff] [blame] | 256 | bool vsync_source = (callbacks_->GetVsyncSource() == id_); |
Padmanabhan Komanduru | 866bf6a | 2019-03-19 14:30:48 +0530 | [diff] [blame] | 257 | bool skip_commit = enable_optimize_refresh_ && !pending_commit_ && !buffers_latched && |
Padmanabhan Komanduru | f5e6c5d | 2019-04-04 13:56:31 +0530 | [diff] [blame] | 258 | !pending_refresh_ && !vsync_source; |
Padmanabhan Komanduru | e74cf4f | 2019-04-25 17:38:43 -0700 | [diff] [blame] | 259 | pending_refresh_ = false; |
| 260 | |
| 261 | return skip_commit; |
| 262 | } |
| 263 | |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 264 | HWC2::Error HWCDisplayBuiltIn::CommitStitchLayers() { |
| 265 | if (!validated_ || skip_commit_) { |
| 266 | return HWC2::Error::None; |
| 267 | } |
| 268 | |
| 269 | if (disable_layer_stitch_) { |
| 270 | return HWC2::Error::None; |
| 271 | } |
| 272 | |
| 273 | for (auto &layer : layer_stack_.layers) { |
| 274 | LayerComposition &composition = layer->composition; |
| 275 | if (composition != kCompositionStitch) { |
| 276 | continue; |
| 277 | } |
| 278 | |
| 279 | LayerStitchStitchContext ctx = {}; |
| 280 | // Stitch target doesn't have an input fence. |
| 281 | // Render all layers at specified destination. |
| 282 | LayerBuffer &input_buffer = layer->input_buffer; |
| 283 | ctx.src_hnd = reinterpret_cast<const private_handle_t *>(input_buffer.buffer_id); |
| 284 | Layer *stitch_layer = stitch_target_->GetSDMLayer(); |
| 285 | LayerBuffer &output_buffer = stitch_layer->input_buffer; |
| 286 | ctx.dst_hnd = reinterpret_cast<const private_handle_t *>(output_buffer.buffer_id); |
| 287 | SetRect(layer->stitch_dst_rect, &ctx.dst_rect); |
| 288 | ctx.src_acquire_fence_fd = input_buffer.acquire_fence_fd; |
| 289 | |
| 290 | layer_stitch_task_.PerformTask(LayerStitchTaskCode::kCodeStitch, &ctx); |
| 291 | |
| 292 | // Merge with current fence and close previous one. |
| 293 | int acquire_fence = sync_merge(__CLASS__, output_buffer.acquire_fence_fd, ctx.release_fence_fd); |
| 294 | CloseFd(&output_buffer.acquire_fence_fd); |
| 295 | CloseFd(&ctx.release_fence_fd); |
| 296 | |
| 297 | output_buffer.acquire_fence_fd = acquire_fence; |
| 298 | } |
| 299 | |
| 300 | return HWC2::Error::None; |
| 301 | } |
| 302 | |
Padmanabhan Komanduru | 6693fcb | 2019-11-22 21:06:52 +0530 | [diff] [blame] | 303 | void HWCDisplayBuiltIn::CacheAvrStatus() { |
| 304 | QSyncMode qsync_mode = kQSyncModeNone; |
| 305 | |
| 306 | DisplayError error = display_intf_->GetQSyncMode(&qsync_mode); |
| 307 | if (error != kErrorNone) { |
| 308 | return; |
| 309 | } |
| 310 | |
| 311 | bool qsync_enabled = (qsync_mode != kQSyncModeNone); |
| 312 | if (qsync_enabled_ != qsync_enabled) { |
| 313 | qsync_reconfigured_ = true; |
| 314 | qsync_enabled_ = qsync_enabled; |
| 315 | } else { |
| 316 | qsync_reconfigured_ = false; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | bool HWCDisplayBuiltIn::IsQsyncCallbackNeeded(bool *qsync_enabled, int32_t *refresh_rate, |
| 321 | int32_t *qsync_refresh_rate) { |
| 322 | if (!qsync_reconfigured_) { |
| 323 | return false; |
| 324 | } |
| 325 | |
| 326 | bool vsync_source = (callbacks_->GetVsyncSource() == id_); |
| 327 | // Qsync callback not needed if this display is not the source of vsync |
| 328 | if (!vsync_source) { |
| 329 | return false; |
| 330 | } |
| 331 | |
| 332 | *qsync_enabled = qsync_enabled_; |
| 333 | uint32_t current_rate = 0; |
| 334 | display_intf_->GetRefreshRate(¤t_rate); |
| 335 | *refresh_rate = INT32(current_rate); |
| 336 | *qsync_refresh_rate = min_refresh_rate_; |
| 337 | |
| 338 | return true; |
| 339 | } |
| 340 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 341 | HWC2::Error HWCDisplayBuiltIn::Present(int32_t *out_retire_fence) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 342 | auto status = HWC2::Error::None; |
Gurpreet Singh Dhami | a427688 | 2019-04-12 10:30:58 -0700 | [diff] [blame] | 343 | |
| 344 | DTRACE_SCOPED(); |
Mathew Joseph Karimpanal | b1c1586 | 2019-07-04 11:14:24 +0530 | [diff] [blame] | 345 | |
| 346 | if (!is_primary_ && active_secure_sessions_[kSecureDisplay]) { |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 347 | return status; |
Mathew Joseph Karimpanal | b1c1586 | 2019-07-04 11:14:24 +0530 | [diff] [blame] | 348 | } else if (display_paused_) { |
Pullakavi Srinivas | 0a1dba6 | 2018-07-02 15:49:11 +0530 | [diff] [blame] | 349 | DisplayError error = display_intf_->Flush(&layer_stack_); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 350 | validated_ = false; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 351 | if (error != kErrorNone) { |
| 352 | DLOGE("Flush failed. Error = %d", error); |
| 353 | } |
| 354 | } else { |
Padmanabhan Komanduru | 6693fcb | 2019-11-22 21:06:52 +0530 | [diff] [blame] | 355 | CacheAvrStatus(); |
| 356 | |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 357 | status = CommitStitchLayers(); |
| 358 | if (status != HWC2::Error::None) { |
| 359 | DLOGE("Stitch failed: %d", status); |
| 360 | return status; |
| 361 | } |
| 362 | |
Padmanabhan Komanduru | e74cf4f | 2019-04-25 17:38:43 -0700 | [diff] [blame] | 363 | status = CommitLayerStack(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 364 | if (status == HWC2::Error::None) { |
| 365 | HandleFrameOutput(); |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 366 | SolidFillCommit(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 367 | status = HWCDisplay::PostCommitLayerStack(out_retire_fence); |
| 368 | } |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 369 | |
| 370 | if (stitch_target_) { |
| 371 | // Close Stitch buffer acquire fence. |
| 372 | Layer *stitch_layer = stitch_target_->GetSDMLayer(); |
| 373 | LayerBuffer &output_buffer = stitch_layer->input_buffer; |
| 374 | CloseFd(&output_buffer.acquire_fence_fd); |
| 375 | CloseFd(&output_buffer.release_fence_fd); |
| 376 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 377 | } |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 378 | |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 379 | CloseFd(&output_buffer_.acquire_fence_fd); |
Namit Solanki | 5b428dc | 2018-02-27 11:39:05 +0530 | [diff] [blame] | 380 | pending_commit_ = false; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 381 | return status; |
| 382 | } |
| 383 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 384 | HWC2::Error HWCDisplayBuiltIn::GetColorModes(uint32_t *out_num_modes, ColorMode *out_modes) { |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 385 | if (out_modes == nullptr) { |
| 386 | *out_num_modes = color_mode_->GetColorModeCount(); |
| 387 | } else { |
| 388 | color_mode_->GetColorModes(out_num_modes, out_modes); |
| 389 | } |
| 390 | |
| 391 | return HWC2::Error::None; |
| 392 | } |
| 393 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 394 | HWC2::Error HWCDisplayBuiltIn::GetRenderIntents(ColorMode mode, uint32_t *out_num_intents, |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 395 | RenderIntent *out_intents) { |
| 396 | if (out_intents == nullptr) { |
| 397 | *out_num_intents = color_mode_->GetRenderIntentCount(mode); |
| 398 | } else { |
| 399 | color_mode_->GetRenderIntents(mode, out_num_intents, out_intents); |
| 400 | } |
| 401 | return HWC2::Error::None; |
| 402 | } |
| 403 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 404 | HWC2::Error HWCDisplayBuiltIn::SetColorMode(ColorMode mode) { |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 405 | return SetColorModeWithRenderIntent(mode, RenderIntent::COLORIMETRIC); |
| 406 | } |
| 407 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 408 | HWC2::Error HWCDisplayBuiltIn::SetColorModeWithRenderIntent(ColorMode mode, RenderIntent intent) { |
Sushil Chauhan | 8008d60 | 2018-09-04 14:43:27 -0700 | [diff] [blame] | 409 | auto status = color_mode_->CacheColorModeWithRenderIntent(mode, intent); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 410 | if (status != HWC2::Error::None) { |
Naseer Ahmed | e7a7798 | 2018-06-04 10:56:04 -0400 | [diff] [blame] | 411 | DLOGE("failed for mode = %d intent = %d", mode, intent); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 412 | return status; |
| 413 | } |
Ramkumar Radhakrishnan | 44c6436 | 2018-12-12 13:03:59 -0800 | [diff] [blame] | 414 | callbacks_->Refresh(id_); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 415 | validated_ = false; |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 416 | return status; |
| 417 | } |
| 418 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 419 | HWC2::Error HWCDisplayBuiltIn::SetColorModeById(int32_t color_mode_id) { |
Naseer Ahmed | 6776dae | 2017-05-09 11:49:41 -0400 | [diff] [blame] | 420 | auto status = color_mode_->SetColorModeById(color_mode_id); |
| 421 | if (status != HWC2::Error::None) { |
| 422 | DLOGE("failed for mode = %d", color_mode_id); |
| 423 | return status; |
| 424 | } |
| 425 | |
Ramkumar Radhakrishnan | 44c6436 | 2018-12-12 13:03:59 -0800 | [diff] [blame] | 426 | callbacks_->Refresh(id_); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 427 | validated_ = false; |
Naseer Ahmed | 6776dae | 2017-05-09 11:49:41 -0400 | [diff] [blame] | 428 | |
| 429 | return status; |
| 430 | } |
| 431 | |
Xu Yang | 84e6141 | 2018-12-06 14:52:16 +0800 | [diff] [blame] | 432 | HWC2::Error HWCDisplayBuiltIn::SetColorModeFromClientApi(int32_t color_mode_id) { |
| 433 | DisplayError error = kErrorNone; |
| 434 | std::string mode_string; |
| 435 | |
| 436 | error = display_intf_->GetColorModeName(color_mode_id, &mode_string); |
| 437 | if (error) { |
| 438 | DLOGE("Failed to get mode name for mode %d", color_mode_id); |
| 439 | return HWC2::Error::BadParameter; |
| 440 | } |
| 441 | |
| 442 | auto status = color_mode_->SetColorModeFromClientApi(mode_string); |
| 443 | if (status != HWC2::Error::None) { |
| 444 | DLOGE("Failed to set mode = %d", color_mode_id); |
| 445 | return status; |
| 446 | } |
| 447 | |
| 448 | return status; |
| 449 | } |
| 450 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 451 | HWC2::Error HWCDisplayBuiltIn::RestoreColorTransform() { |
Ch Ganesh Kumar | 5d43ff6 | 2017-10-13 19:01:47 +0530 | [diff] [blame] | 452 | auto status = color_mode_->RestoreColorTransform(); |
| 453 | if (status != HWC2::Error::None) { |
| 454 | DLOGE("failed to RestoreColorTransform"); |
| 455 | return status; |
| 456 | } |
| 457 | |
Ramkumar Radhakrishnan | 44c6436 | 2018-12-12 13:03:59 -0800 | [diff] [blame] | 458 | callbacks_->Refresh(id_); |
Ch Ganesh Kumar | 5d43ff6 | 2017-10-13 19:01:47 +0530 | [diff] [blame] | 459 | |
| 460 | return status; |
| 461 | } |
| 462 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 463 | HWC2::Error HWCDisplayBuiltIn::SetColorTransform(const float *matrix, |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 464 | android_color_transform_t hint) { |
| 465 | if (!matrix) { |
| 466 | return HWC2::Error::BadParameter; |
| 467 | } |
| 468 | |
| 469 | auto status = color_mode_->SetColorTransform(matrix, hint); |
| 470 | if (status != HWC2::Error::None) { |
| 471 | DLOGE("failed for hint = %d", hint); |
| 472 | color_tranform_failed_ = true; |
| 473 | return status; |
| 474 | } |
| 475 | |
Ramkumar Radhakrishnan | 44c6436 | 2018-12-12 13:03:59 -0800 | [diff] [blame] | 476 | callbacks_->Refresh(id_); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 477 | color_tranform_failed_ = false; |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 478 | validated_ = false; |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 479 | |
| 480 | return status; |
| 481 | } |
| 482 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 483 | HWC2::Error HWCDisplayBuiltIn::SetReadbackBuffer(const native_handle_t *buffer, |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 484 | int32_t acquire_fence, bool post_processed_output, |
| 485 | CWBClient client) { |
| 486 | if (cwb_client_ != client && cwb_client_ != kCWBClientNone) { |
| 487 | DLOGE("CWB is in use with client = %d", cwb_client_); |
| 488 | return HWC2::Error::NoResources; |
| 489 | } |
| 490 | |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 491 | const private_handle_t *handle = reinterpret_cast<const private_handle_t *>(buffer); |
| 492 | if (!handle || (handle->fd < 0)) { |
| 493 | return HWC2::Error::BadParameter; |
| 494 | } |
| 495 | |
| 496 | // Configure the output buffer as Readback buffer |
| 497 | output_buffer_.width = UINT32(handle->width); |
| 498 | output_buffer_.height = UINT32(handle->height); |
| 499 | output_buffer_.unaligned_width = UINT32(handle->unaligned_width); |
| 500 | output_buffer_.unaligned_height = UINT32(handle->unaligned_height); |
| 501 | output_buffer_.format = HWCLayer::GetSDMFormat(handle->format, handle->flags); |
| 502 | output_buffer_.planes[0].fd = handle->fd; |
| 503 | output_buffer_.planes[0].stride = UINT32(handle->width); |
| 504 | output_buffer_.acquire_fence_fd = dup(acquire_fence); |
| 505 | output_buffer_.release_fence_fd = -1; |
Sushil Chauhan | d0dc03d | 2018-09-19 07:08:40 -0700 | [diff] [blame] | 506 | output_buffer_.handle_id = handle->id; |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 507 | |
| 508 | post_processed_output_ = post_processed_output; |
| 509 | readback_buffer_queued_ = true; |
| 510 | readback_configured_ = false; |
| 511 | validated_ = false; |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 512 | cwb_client_ = client; |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 513 | |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 514 | return HWC2::Error::None; |
| 515 | } |
| 516 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 517 | HWC2::Error HWCDisplayBuiltIn::GetReadbackBufferFence(int32_t *release_fence) { |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 518 | auto status = HWC2::Error::None; |
| 519 | |
| 520 | if (readback_configured_ && (output_buffer_.release_fence_fd >= 0)) { |
| 521 | *release_fence = output_buffer_.release_fence_fd; |
| 522 | } else { |
| 523 | status = HWC2::Error::Unsupported; |
| 524 | *release_fence = -1; |
| 525 | } |
| 526 | |
| 527 | post_processed_output_ = false; |
| 528 | readback_buffer_queued_ = false; |
| 529 | readback_configured_ = false; |
| 530 | output_buffer_ = {}; |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 531 | cwb_client_ = kCWBClientNone; |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 532 | |
| 533 | return status; |
| 534 | } |
| 535 | |
Gurpreet Singh Dhami | 1207e46 | 2018-12-27 20:02:02 -0500 | [diff] [blame] | 536 | DisplayError HWCDisplayBuiltIn::TeardownConcurrentWriteback(void) { |
| 537 | DisplayError error = kErrorNotSupported; |
| 538 | |
| 539 | if (output_buffer_.release_fence_fd >= 0) { |
| 540 | int32_t release_fence_fd = dup(output_buffer_.release_fence_fd); |
| 541 | int ret = sync_wait(output_buffer_.release_fence_fd, 1000); |
| 542 | if (ret < 0) { |
| 543 | DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno)); |
| 544 | } |
| 545 | |
| 546 | ::close(release_fence_fd); |
| 547 | if (ret) |
| 548 | return kErrorResources; |
| 549 | } |
| 550 | |
| 551 | if (display_intf_) { |
| 552 | error = display_intf_->TeardownConcurrentWriteback(); |
| 553 | } |
| 554 | |
| 555 | return error; |
| 556 | } |
| 557 | |
Yuchao Ma | 577f0f7 | 2018-07-09 11:20:00 +0800 | [diff] [blame] | 558 | HWC2::Error HWCDisplayBuiltIn::SetDisplayDppsAdROI(uint32_t h_start, uint32_t h_end, |
| 559 | uint32_t v_start, uint32_t v_end, |
| 560 | uint32_t factor_in, uint32_t factor_out) { |
| 561 | DisplayError error = kErrorNone; |
| 562 | DisplayDppsAd4RoiCfg dpps_ad4_roi_cfg = {}; |
| 563 | uint32_t panel_width = 0, panel_height = 0; |
| 564 | constexpr uint16_t kMaxFactorVal = 0xffff; |
| 565 | |
| 566 | if (h_start >= h_end || v_start >= v_end || factor_in > kMaxFactorVal || |
| 567 | factor_out > kMaxFactorVal) { |
| 568 | DLOGE("Invalid roi region = [%u, %u, %u, %u, %u, %u]", |
| 569 | h_start, h_end, v_start, v_end, factor_in, factor_out); |
| 570 | return HWC2::Error::BadParameter; |
| 571 | } |
| 572 | |
| 573 | GetPanelResolution(&panel_width, &panel_height); |
| 574 | |
| 575 | if (h_start >= panel_width || h_end > panel_width || |
| 576 | v_start >= panel_height || v_end > panel_height) { |
| 577 | DLOGE("Invalid roi region = [%u, %u, %u, %u], panel resolution = [%u, %u]", |
| 578 | h_start, h_end, v_start, v_end, panel_width, panel_height); |
| 579 | return HWC2::Error::BadParameter; |
| 580 | } |
| 581 | |
| 582 | dpps_ad4_roi_cfg.h_start = h_start; |
| 583 | dpps_ad4_roi_cfg.h_end = h_end; |
| 584 | dpps_ad4_roi_cfg.v_start = v_start; |
| 585 | dpps_ad4_roi_cfg.v_end = v_end; |
| 586 | dpps_ad4_roi_cfg.factor_in = factor_in; |
| 587 | dpps_ad4_roi_cfg.factor_out = factor_out; |
| 588 | |
| 589 | error = display_intf_->SetDisplayDppsAdROI(&dpps_ad4_roi_cfg); |
| 590 | if (error) |
| 591 | return HWC2::Error::BadConfig; |
| 592 | |
Ramkumar Radhakrishnan | 44c6436 | 2018-12-12 13:03:59 -0800 | [diff] [blame] | 593 | callbacks_->Refresh(id_); |
Yuchao Ma | 577f0f7 | 2018-07-09 11:20:00 +0800 | [diff] [blame] | 594 | |
| 595 | return HWC2::Error::None; |
| 596 | } |
| 597 | |
Xu Yang | 9dacc87 | 2018-12-25 11:04:28 +0800 | [diff] [blame] | 598 | HWC2::Error HWCDisplayBuiltIn::SetFrameTriggerMode(uint32_t mode) { |
| 599 | DisplayError error = kErrorNone; |
| 600 | FrameTriggerMode trigger_mode = kFrameTriggerDefault; |
| 601 | |
| 602 | if (mode >= kFrameTriggerMax) { |
| 603 | DLOGE("Invalid input mode %d", mode); |
| 604 | return HWC2::Error::BadParameter; |
| 605 | } |
| 606 | |
| 607 | trigger_mode = static_cast<FrameTriggerMode>(mode); |
| 608 | error = display_intf_->SetFrameTriggerMode(trigger_mode); |
| 609 | if (error) |
| 610 | return HWC2::Error::BadConfig; |
| 611 | |
| 612 | callbacks_->Refresh(HWC_DISPLAY_PRIMARY); |
| 613 | validated_ = false; |
| 614 | |
| 615 | return HWC2::Error::None; |
| 616 | } |
| 617 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 618 | int HWCDisplayBuiltIn::Perform(uint32_t operation, ...) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 619 | va_list args; |
| 620 | va_start(args, operation); |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 621 | int val = 0; |
Gopikrishnaiah Anandan | cc12306 | 2017-07-31 17:21:03 -0700 | [diff] [blame] | 622 | LayerSolidFill *solid_fill_color; |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 623 | LayerRect *rect = NULL; |
| 624 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 625 | switch (operation) { |
| 626 | case SET_METADATA_DYN_REFRESH_RATE: |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 627 | val = va_arg(args, int32_t); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 628 | SetMetaDataRefreshRateFlag(val); |
| 629 | break; |
| 630 | case SET_BINDER_DYN_REFRESH_RATE: |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 631 | val = va_arg(args, int32_t); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 632 | ForceRefreshRate(UINT32(val)); |
| 633 | break; |
| 634 | case SET_DISPLAY_MODE: |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 635 | val = va_arg(args, int32_t); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 636 | SetDisplayMode(UINT32(val)); |
| 637 | break; |
| 638 | case SET_QDCM_SOLID_FILL_INFO: |
Gopikrishnaiah Anandan | cc12306 | 2017-07-31 17:21:03 -0700 | [diff] [blame] | 639 | solid_fill_color = va_arg(args, LayerSolidFill*); |
| 640 | SetQDCMSolidFillInfo(true, *solid_fill_color); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 641 | break; |
| 642 | case UNSET_QDCM_SOLID_FILL_INFO: |
Gopikrishnaiah Anandan | cc12306 | 2017-07-31 17:21:03 -0700 | [diff] [blame] | 643 | solid_fill_color = va_arg(args, LayerSolidFill*); |
| 644 | SetQDCMSolidFillInfo(false, *solid_fill_color); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 645 | break; |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 646 | case SET_QDCM_SOLID_FILL_RECT: |
| 647 | rect = va_arg(args, LayerRect*); |
| 648 | solid_fill_rect_ = *rect; |
| 649 | break; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 650 | default: |
| 651 | DLOGW("Invalid operation %d", operation); |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 652 | va_end(args); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 653 | return -EINVAL; |
| 654 | } |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 655 | va_end(args); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 656 | validated_ = false; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 657 | |
| 658 | return 0; |
| 659 | } |
| 660 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 661 | DisplayError HWCDisplayBuiltIn::SetDisplayMode(uint32_t mode) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 662 | DisplayError error = kErrorNone; |
| 663 | |
| 664 | if (display_intf_) { |
| 665 | error = display_intf_->SetDisplayMode(mode); |
Tharaga Balachandran | 04192a6 | 2018-08-29 16:23:25 -0400 | [diff] [blame] | 666 | if (error == kErrorNone) { |
| 667 | DisplayConfigFixedInfo fixed_info = {}; |
| 668 | display_intf_->GetConfig(&fixed_info); |
| 669 | is_cmd_mode_ = fixed_info.is_cmdmode; |
| 670 | partial_update_enabled_ = fixed_info.partial_update; |
| 671 | for (auto hwc_layer : layer_set_) { |
| 672 | hwc_layer->SetPartialUpdate(partial_update_enabled_); |
| 673 | } |
| 674 | client_target_->SetPartialUpdate(partial_update_enabled_); |
| 675 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | return error; |
| 679 | } |
| 680 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 681 | void HWCDisplayBuiltIn::SetMetaDataRefreshRateFlag(bool enable) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 682 | int disable_metadata_dynfps = 0; |
| 683 | |
Uday Kiran Pichika | 5e656b2 | 2018-05-15 18:48:24 +0530 | [diff] [blame] | 684 | HWCDebugHandler::Get()->GetProperty(DISABLE_METADATA_DYNAMIC_FPS_PROP, &disable_metadata_dynfps); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 685 | if (disable_metadata_dynfps) { |
| 686 | return; |
| 687 | } |
| 688 | use_metadata_refresh_rate_ = enable; |
| 689 | } |
| 690 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 691 | void HWCDisplayBuiltIn::SetQDCMSolidFillInfo(bool enable, const LayerSolidFill &color) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 692 | solid_fill_enable_ = enable; |
| 693 | solid_fill_color_ = color; |
| 694 | } |
| 695 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 696 | void HWCDisplayBuiltIn::ToggleCPUHint(bool set) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 697 | if (!cpu_hint_) { |
| 698 | return; |
| 699 | } |
| 700 | |
| 701 | if (set) { |
| 702 | cpu_hint_->Set(); |
| 703 | } else { |
| 704 | cpu_hint_->Reset(); |
| 705 | } |
| 706 | } |
| 707 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 708 | int HWCDisplayBuiltIn::HandleSecureSession(const std::bitset<kSecureMax> &secure_sessions, |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 709 | bool *power_on_pending) { |
| 710 | if (!power_on_pending) { |
| 711 | return -EINVAL; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 712 | } |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 713 | |
Mathew Joseph Karimpanal | b1c1586 | 2019-07-04 11:14:24 +0530 | [diff] [blame] | 714 | if (!is_primary_) { |
| 715 | return HWCDisplay::HandleSecureSession(secure_sessions, power_on_pending); |
| 716 | } |
| 717 | |
Ramkumar Radhakrishnan | 44c6436 | 2018-12-12 13:03:59 -0800 | [diff] [blame] | 718 | if (current_power_mode_ != HWC2::PowerMode::On) { |
| 719 | return 0; |
| 720 | } |
| 721 | |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 722 | if (active_secure_sessions_[kSecureDisplay] != secure_sessions[kSecureDisplay]) { |
| 723 | SecureEvent secure_event = |
| 724 | secure_sessions.test(kSecureDisplay) ? kSecureDisplayStart : kSecureDisplayEnd; |
Pullakavi Srinivas | 0a1dba6 | 2018-07-02 15:49:11 +0530 | [diff] [blame] | 725 | DisplayError err = display_intf_->HandleSecureEvent(secure_event, &layer_stack_); |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 726 | if (err != kErrorNone) { |
| 727 | DLOGE("Set secure event failed"); |
| 728 | return err; |
| 729 | } |
| 730 | |
Mathew Joseph Karimpanal | b1c1586 | 2019-07-04 11:14:24 +0530 | [diff] [blame] | 731 | DLOGI("SecureDisplay state changed from %d to %d for display %d-%d", |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 732 | active_secure_sessions_.test(kSecureDisplay), secure_sessions.test(kSecureDisplay), |
Mathew Joseph Karimpanal | b1c1586 | 2019-07-04 11:14:24 +0530 | [diff] [blame] | 733 | id_, type_); |
Ramkumar Radhakrishnan | a38b760 | 2018-03-15 14:49:52 -0700 | [diff] [blame] | 734 | } |
| 735 | active_secure_sessions_ = secure_sessions; |
| 736 | *power_on_pending = false; |
| 737 | return 0; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 738 | } |
| 739 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 740 | void HWCDisplayBuiltIn::ForceRefreshRate(uint32_t refresh_rate) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 741 | if ((refresh_rate && (refresh_rate < min_refresh_rate_ || refresh_rate > max_refresh_rate_)) || |
| 742 | force_refresh_rate_ == refresh_rate) { |
| 743 | // Cannot honor force refresh rate, as its beyond the range or new request is same |
| 744 | return; |
| 745 | } |
| 746 | |
| 747 | force_refresh_rate_ = refresh_rate; |
| 748 | |
Ramkumar Radhakrishnan | 44c6436 | 2018-12-12 13:03:59 -0800 | [diff] [blame] | 749 | callbacks_->Refresh(id_); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 750 | |
| 751 | return; |
| 752 | } |
| 753 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 754 | uint32_t HWCDisplayBuiltIn::GetOptimalRefreshRate(bool one_updating_layer) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 755 | if (force_refresh_rate_) { |
| 756 | return force_refresh_rate_; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 757 | } else if (use_metadata_refresh_rate_ && one_updating_layer && metadata_refresh_rate_) { |
| 758 | return metadata_refresh_rate_; |
| 759 | } |
| 760 | |
| 761 | return max_refresh_rate_; |
| 762 | } |
| 763 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 764 | void HWCDisplayBuiltIn::SetIdleTimeoutMs(uint32_t timeout_ms) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 765 | display_intf_->SetIdleTimeoutMs(timeout_ms); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 766 | validated_ = false; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 767 | } |
| 768 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 769 | void HWCDisplayBuiltIn::HandleFrameOutput() { |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 770 | if (readback_buffer_queued_) { |
| 771 | validated_ = false; |
| 772 | } |
| 773 | |
Sushil Chauhan | 1d3b90c | 2018-12-11 16:52:35 -0800 | [diff] [blame] | 774 | if (frame_capture_buffer_queued_) { |
| 775 | HandleFrameCapture(); |
| 776 | } else if (dump_output_to_file_) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 777 | HandleFrameDump(); |
| 778 | } |
| 779 | } |
| 780 | |
Sushil Chauhan | 1d3b90c | 2018-12-11 16:52:35 -0800 | [diff] [blame] | 781 | void HWCDisplayBuiltIn::HandleFrameCapture() { |
| 782 | if (readback_configured_ && (output_buffer_.release_fence_fd >= 0)) { |
| 783 | frame_capture_status_ = sync_wait(output_buffer_.release_fence_fd, 1000); |
| 784 | ::close(output_buffer_.release_fence_fd); |
| 785 | output_buffer_.release_fence_fd = -1; |
| 786 | } |
| 787 | |
| 788 | frame_capture_buffer_queued_ = false; |
| 789 | readback_buffer_queued_ = false; |
| 790 | post_processed_output_ = false; |
| 791 | readback_configured_ = false; |
| 792 | output_buffer_ = {}; |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 793 | cwb_client_ = kCWBClientNone; |
Sushil Chauhan | 1d3b90c | 2018-12-11 16:52:35 -0800 | [diff] [blame] | 794 | } |
| 795 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 796 | void HWCDisplayBuiltIn::HandleFrameDump() { |
Ramkumar Radhakrishnan | 68331fc | 2019-06-19 11:24:12 -0700 | [diff] [blame] | 797 | if (dump_frame_count_) { |
| 798 | int ret = 0; |
| 799 | if (output_buffer_.release_fence_fd >= 0) { |
| 800 | ret = sync_wait(output_buffer_.release_fence_fd, 1000); |
| 801 | if (ret < 0) { |
| 802 | DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno)); |
| 803 | } |
| 804 | ::close(output_buffer_.release_fence_fd); |
| 805 | output_buffer_.release_fence_fd = -1; |
| 806 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 807 | |
Ramkumar Radhakrishnan | 68331fc | 2019-06-19 11:24:12 -0700 | [diff] [blame] | 808 | if (!ret) { |
| 809 | DumpOutputBuffer(output_buffer_info_, output_buffer_base_, layer_stack_.retire_fence_fd); |
| 810 | validated_ = false; |
| 811 | } |
| 812 | |
| 813 | if (0 == (dump_frame_count_ - 1)) { |
| 814 | dump_output_to_file_ = false; |
| 815 | // Unmap and Free buffer |
| 816 | if (munmap(output_buffer_base_, output_buffer_info_.alloc_buffer_info.size) != 0) { |
| 817 | DLOGE("unmap failed with err %d", errno); |
| 818 | } |
| 819 | if (buffer_allocator_->FreeBuffer(&output_buffer_info_) != 0) { |
| 820 | DLOGE("FreeBuffer failed"); |
| 821 | } |
| 822 | |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 823 | readback_buffer_queued_ = false; |
Ramkumar Radhakrishnan | 68331fc | 2019-06-19 11:24:12 -0700 | [diff] [blame] | 824 | post_processed_output_ = false; |
| 825 | readback_configured_ = false; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 826 | |
Ramkumar Radhakrishnan | 68331fc | 2019-06-19 11:24:12 -0700 | [diff] [blame] | 827 | output_buffer_ = {}; |
| 828 | output_buffer_info_ = {}; |
| 829 | output_buffer_base_ = nullptr; |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 830 | cwb_client_ = kCWBClientNone; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 831 | } |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 832 | } |
| 833 | } |
| 834 | |
Sushil Chauhan | 267a619 | 2018-06-06 18:41:47 -0700 | [diff] [blame] | 835 | HWC2::Error HWCDisplayBuiltIn::SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type, |
| 836 | int32_t format, bool post_processed) { |
| 837 | HWCDisplay::SetFrameDumpConfig(count, bit_mask_layer_type, format, post_processed); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 838 | dump_output_to_file_ = bit_mask_layer_type & (1 << OUTPUT_LAYER_DUMP); |
| 839 | DLOGI("output_layer_dump_enable %d", dump_output_to_file_); |
| 840 | |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 841 | if (dump_output_to_file_) { |
| 842 | if (cwb_client_ != kCWBClientNone) { |
| 843 | DLOGE("CWB is in use with client = %d", cwb_client_); |
| 844 | dump_output_to_file_ = false; |
| 845 | return HWC2::Error::NoResources; |
| 846 | } |
| 847 | } |
| 848 | |
Sushil Chauhan | d0dc03d | 2018-09-19 07:08:40 -0700 | [diff] [blame] | 849 | if (!count || !dump_output_to_file_ || (output_buffer_info_.alloc_buffer_info.fd >= 0)) { |
Mathew Joseph Karimpanal | dbd64f8 | 2017-10-06 10:13:38 +0530 | [diff] [blame] | 850 | return HWC2::Error::None; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | // Allocate and map output buffer |
Sushil Chauhan | 267a619 | 2018-06-06 18:41:47 -0700 | [diff] [blame] | 854 | if (post_processed) { |
| 855 | // To dump post-processed (DSPP) output, use Panel resolution. |
| 856 | GetPanelResolution(&output_buffer_info_.buffer_config.width, |
| 857 | &output_buffer_info_.buffer_config.height); |
| 858 | } else { |
| 859 | // To dump Layer Mixer output, use FrameBuffer resolution. |
| 860 | GetFrameBufferResolution(&output_buffer_info_.buffer_config.width, |
| 861 | &output_buffer_info_.buffer_config.height); |
| 862 | } |
| 863 | |
| 864 | output_buffer_info_.buffer_config.format = HWCLayer::GetSDMFormat(format, 0); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 865 | output_buffer_info_.buffer_config.buffer_count = 1; |
| 866 | if (buffer_allocator_->AllocateBuffer(&output_buffer_info_) != 0) { |
| 867 | DLOGE("Buffer allocation failed"); |
| 868 | output_buffer_info_ = {}; |
Mathew Joseph Karimpanal | dbd64f8 | 2017-10-06 10:13:38 +0530 | [diff] [blame] | 869 | return HWC2::Error::NoResources; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | void *buffer = mmap(NULL, output_buffer_info_.alloc_buffer_info.size, PROT_READ | PROT_WRITE, |
| 873 | MAP_SHARED, output_buffer_info_.alloc_buffer_info.fd, 0); |
| 874 | |
| 875 | if (buffer == MAP_FAILED) { |
| 876 | DLOGE("mmap failed with err %d", errno); |
| 877 | buffer_allocator_->FreeBuffer(&output_buffer_info_); |
| 878 | output_buffer_info_ = {}; |
Mathew Joseph Karimpanal | dbd64f8 | 2017-10-06 10:13:38 +0530 | [diff] [blame] | 879 | return HWC2::Error::NoResources; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | output_buffer_base_ = buffer; |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 883 | const native_handle_t *handle = static_cast<native_handle_t *>(output_buffer_info_.private_data); |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 884 | SetReadbackBuffer(handle, -1, post_processed, kCWBClientFrameDump); |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 885 | |
Mathew Joseph Karimpanal | dbd64f8 | 2017-10-06 10:13:38 +0530 | [diff] [blame] | 886 | return HWC2::Error::None; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 887 | } |
| 888 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 889 | int HWCDisplayBuiltIn::FrameCaptureAsync(const BufferInfo &output_buffer_info, |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 890 | bool post_processed_output) { |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 891 | if (cwb_client_ != kCWBClientNone) { |
| 892 | DLOGE("CWB is in use with client = %d", cwb_client_); |
| 893 | return -1; |
| 894 | } |
| 895 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 896 | // Note: This function is called in context of a binder thread and a lock is already held |
| 897 | if (output_buffer_info.alloc_buffer_info.fd < 0) { |
| 898 | DLOGE("Invalid fd %d", output_buffer_info.alloc_buffer_info.fd); |
| 899 | return -1; |
| 900 | } |
| 901 | |
| 902 | auto panel_width = 0u; |
| 903 | auto panel_height = 0u; |
| 904 | auto fb_width = 0u; |
| 905 | auto fb_height = 0u; |
| 906 | |
| 907 | GetPanelResolution(&panel_width, &panel_height); |
| 908 | GetFrameBufferResolution(&fb_width, &fb_height); |
| 909 | |
Ch Ganesh Kumar | 5c4988b | 2017-06-07 15:21:02 +0530 | [diff] [blame] | 910 | if (post_processed_output && (output_buffer_info.buffer_config.width < panel_width || |
| 911 | output_buffer_info.buffer_config.height < panel_height)) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 912 | DLOGE("Buffer dimensions should not be less than panel resolution"); |
| 913 | return -1; |
Ch Ganesh Kumar | 5c4988b | 2017-06-07 15:21:02 +0530 | [diff] [blame] | 914 | } else if (!post_processed_output && (output_buffer_info.buffer_config.width < fb_width || |
| 915 | output_buffer_info.buffer_config.height < fb_height)) { |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 916 | DLOGE("Buffer dimensions should not be less than FB resolution"); |
| 917 | return -1; |
| 918 | } |
| 919 | |
Sushil Chauhan | 0652158 | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 920 | const native_handle_t *buffer = static_cast<native_handle_t *>(output_buffer_info.private_data); |
Dileep Marchya | cb2a3a9 | 2019-06-21 17:30:50 +0530 | [diff] [blame] | 921 | SetReadbackBuffer(buffer, -1, post_processed_output, kCWBClientColor); |
Sushil Chauhan | 1d3b90c | 2018-12-11 16:52:35 -0800 | [diff] [blame] | 922 | frame_capture_buffer_queued_ = true; |
| 923 | frame_capture_status_ = -EAGAIN; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 924 | |
| 925 | return 0; |
| 926 | } |
| 927 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 928 | DisplayError HWCDisplayBuiltIn::SetDetailEnhancerConfig |
Alan Kwong | 2e13633 | 2016-08-16 07:50:16 -0400 | [diff] [blame] | 929 | (const DisplayDetailEnhancerData &de_data) { |
| 930 | DisplayError error = kErrorNotSupported; |
| 931 | |
| 932 | if (display_intf_) { |
| 933 | error = display_intf_->SetDetailEnhancerData(de_data); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 934 | validated_ = false; |
Alan Kwong | 2e13633 | 2016-08-16 07:50:16 -0400 | [diff] [blame] | 935 | } |
| 936 | return error; |
| 937 | } |
| 938 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 939 | DisplayError HWCDisplayBuiltIn::ControlPartialUpdate(bool enable, uint32_t *pending) { |
Arun Kumar K.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 940 | DisplayError error = kErrorNone; |
| 941 | |
| 942 | if (display_intf_) { |
| 943 | error = display_intf_->ControlPartialUpdate(enable, pending); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 944 | validated_ = false; |
Arun Kumar K.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | return error; |
| 948 | } |
| 949 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 950 | DisplayError HWCDisplayBuiltIn::DisablePartialUpdateOneFrame() { |
Arun Kumar K.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 951 | DisplayError error = kErrorNone; |
| 952 | |
| 953 | if (display_intf_) { |
| 954 | error = display_intf_->DisablePartialUpdateOneFrame(); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 955 | validated_ = false; |
Arun Kumar K.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | return error; |
| 959 | } |
| 960 | |
Lakshmi Narayana Kalavala | 25fe12c | 2019-12-11 20:44:55 -0800 | [diff] [blame^] | 961 | HWC2::Error HWCDisplayBuiltIn::SetDisplayedContentSamplingEnabledVndService(bool enabled) { |
| 962 | std::unique_lock<decltype(sampling_mutex)> lk(sampling_mutex); |
| 963 | vndservice_sampling_vote = enabled; |
| 964 | if (api_sampling_vote || vndservice_sampling_vote) { |
| 965 | histogram.start(); |
| 966 | } else { |
| 967 | histogram.stop(); |
| 968 | } |
| 969 | return HWC2::Error::None; |
| 970 | } |
| 971 | |
| 972 | HWC2::Error HWCDisplayBuiltIn::SetDisplayedContentSamplingEnabled(int32_t enabled, |
| 973 | uint8_t component_mask, |
| 974 | uint64_t max_frames) { |
| 975 | if ((enabled != HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE) && |
| 976 | (enabled != HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE)) |
| 977 | return HWC2::Error::BadParameter; |
| 978 | |
| 979 | std::unique_lock<decltype(sampling_mutex)> lk(sampling_mutex); |
| 980 | if (enabled == HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE) { |
| 981 | api_sampling_vote = true; |
| 982 | } else { |
| 983 | api_sampling_vote = false; |
| 984 | } |
| 985 | |
| 986 | auto start = api_sampling_vote || vndservice_sampling_vote; |
| 987 | if (start && max_frames == 0) { |
| 988 | histogram.start(); |
| 989 | } else if (start) { |
| 990 | histogram.start(max_frames); |
| 991 | } else { |
| 992 | histogram.stop(); |
| 993 | } |
| 994 | return HWC2::Error::None; |
| 995 | } |
| 996 | |
| 997 | HWC2::Error HWCDisplayBuiltIn::GetDisplayedContentSamplingAttributes( |
| 998 | int32_t *format, int32_t *dataspace, uint8_t *supported_components) { |
| 999 | return histogram.getAttributes(format, dataspace, supported_components); |
| 1000 | } |
| 1001 | |
| 1002 | HWC2::Error HWCDisplayBuiltIn::GetDisplayedContentSample( |
| 1003 | uint64_t max_frames, uint64_t timestamp, uint64_t *numFrames, |
| 1004 | int32_t samples_size[NUM_HISTOGRAM_COLOR_COMPONENTS], |
| 1005 | uint64_t *samples[NUM_HISTOGRAM_COLOR_COMPONENTS]) { |
| 1006 | histogram.collect(max_frames, timestamp, samples_size, samples, numFrames); |
| 1007 | return HWC2::Error::None; |
| 1008 | } |
Arun Kumar K.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 1009 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 1010 | DisplayError HWCDisplayBuiltIn::SetMixerResolution(uint32_t width, uint32_t height) { |
Sushil Chauhan | 409e844 | 2017-06-12 17:43:25 -0700 | [diff] [blame] | 1011 | DisplayError error = display_intf_->SetMixerResolution(width, height); |
Ramkumar Radhakrishnan | f7f5216 | 2019-06-06 19:40:04 -0700 | [diff] [blame] | 1012 | callbacks_->Refresh(id_); |
Saurabh Shah | a307e8c | 2017-09-28 18:05:40 -0700 | [diff] [blame] | 1013 | validated_ = false; |
Sushil Chauhan | 409e844 | 2017-06-12 17:43:25 -0700 | [diff] [blame] | 1014 | return error; |
Arun Kumar K.R | 8da7f50 | 2016-06-07 17:45:50 -0700 | [diff] [blame] | 1015 | } |
| 1016 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 1017 | DisplayError HWCDisplayBuiltIn::GetMixerResolution(uint32_t *width, uint32_t *height) { |
Arun Kumar K.R | 8da7f50 | 2016-06-07 17:45:50 -0700 | [diff] [blame] | 1018 | return display_intf_->GetMixerResolution(width, height); |
| 1019 | } |
| 1020 | |
Dileep Marchya | f3ce11f | 2018-04-30 23:35:46 +0530 | [diff] [blame] | 1021 | HWC2::Error HWCDisplayBuiltIn::SetQSyncMode(QSyncMode qsync_mode) { |
Pullakavi Srinivas | 2457414 | 2019-08-14 12:18:12 +0530 | [diff] [blame] | 1022 | // Client needs to ensure that config change and qsync mode change |
| 1023 | // are not triggered in the same drawcycle. |
| 1024 | if (pending_config_) { |
| 1025 | DLOGE("Failed to set qsync mode. Pending active config transition"); |
| 1026 | return HWC2::Error::Unsupported; |
| 1027 | } |
| 1028 | |
Sushil Chauhan | 380a59d | 2018-03-19 15:47:50 -0700 | [diff] [blame] | 1029 | auto err = display_intf_->SetQSyncMode(qsync_mode); |
| 1030 | if (err != kErrorNone) { |
| 1031 | return HWC2::Error::Unsupported; |
| 1032 | } |
| 1033 | |
Sushil Chauhan | ec4eb57 | 2019-02-07 13:29:42 -0800 | [diff] [blame] | 1034 | validated_ = false; |
Sushil Chauhan | 380a59d | 2018-03-19 15:47:50 -0700 | [diff] [blame] | 1035 | return HWC2::Error::None; |
| 1036 | } |
| 1037 | |
Ramkumar Radhakrishnan | 4faf8a6 | 2018-11-15 17:15:37 -0800 | [diff] [blame] | 1038 | DisplayError HWCDisplayBuiltIn::ControlIdlePowerCollapse(bool enable, bool synchronous) { |
Ramkumar Radhakrishnan | f985d48 | 2018-07-23 18:10:41 -0700 | [diff] [blame] | 1039 | DisplayError error = kErrorNone; |
| 1040 | |
| 1041 | if (display_intf_) { |
| 1042 | error = display_intf_->ControlIdlePowerCollapse(enable, synchronous); |
| 1043 | validated_ = false; |
| 1044 | } |
Ramkumar Radhakrishnan | 4faf8a6 | 2018-11-15 17:15:37 -0800 | [diff] [blame] | 1045 | return error; |
Ramkumar Radhakrishnan | f985d48 | 2018-07-23 18:10:41 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
Pullakavi Srinivas | 9189e60 | 2018-12-19 16:58:07 +0530 | [diff] [blame] | 1048 | DisplayError HWCDisplayBuiltIn::SetDynamicDSIClock(uint64_t bitclk) { |
Dileep Marchya | afa45bc | 2019-06-21 17:05:31 +0530 | [diff] [blame] | 1049 | DisablePartialUpdateOneFrame(); |
| 1050 | DisplayError error = display_intf_->SetDynamicDSIClock(bitclk); |
| 1051 | if (error != kErrorNone) { |
| 1052 | DLOGE(" failed: Clk: %llu Error: %d", bitclk, error); |
| 1053 | return error; |
Pullakavi Srinivas | 9189e60 | 2018-12-19 16:58:07 +0530 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | callbacks_->Refresh(id_); |
| 1057 | validated_ = false; |
| 1058 | |
| 1059 | return kErrorNone; |
| 1060 | } |
| 1061 | |
| 1062 | DisplayError HWCDisplayBuiltIn::GetDynamicDSIClock(uint64_t *bitclk) { |
Pullakavi Srinivas | 9189e60 | 2018-12-19 16:58:07 +0530 | [diff] [blame] | 1063 | if (display_intf_) { |
| 1064 | return display_intf_->GetDynamicDSIClock(bitclk); |
| 1065 | } |
| 1066 | |
| 1067 | return kErrorNotSupported; |
| 1068 | } |
| 1069 | |
| 1070 | DisplayError HWCDisplayBuiltIn::GetSupportedDSIClock(std::vector<uint64_t> *bitclk_rates) { |
| 1071 | if (display_intf_) { |
| 1072 | return display_intf_->GetSupportedDSIClock(bitclk_rates); |
| 1073 | } |
| 1074 | |
| 1075 | return kErrorNotSupported; |
| 1076 | } |
| 1077 | |
Padmanabhan Komanduru | e74cf4f | 2019-04-25 17:38:43 -0700 | [diff] [blame] | 1078 | HWC2::Error HWCDisplayBuiltIn::UpdateDisplayId(hwc2_display_t id) { |
| 1079 | id_ = id; |
| 1080 | return HWC2::Error::None; |
| 1081 | } |
| 1082 | |
| 1083 | HWC2::Error HWCDisplayBuiltIn::SetPendingRefresh() { |
| 1084 | pending_refresh_ = true; |
| 1085 | return HWC2::Error::None; |
| 1086 | } |
| 1087 | |
Varun Arora | 75c05f0 | 2019-05-14 14:53:37 -0700 | [diff] [blame] | 1088 | HWC2::Error HWCDisplayBuiltIn::SetPanelBrightness(float brightness) { |
| 1089 | DisplayError ret = display_intf_->SetPanelBrightness(brightness); |
| 1090 | if (ret != kErrorNone) { |
| 1091 | return HWC2::Error::NoResources; |
| 1092 | } |
| 1093 | |
| 1094 | return HWC2::Error::None; |
| 1095 | } |
| 1096 | |
| 1097 | HWC2::Error HWCDisplayBuiltIn::GetPanelBrightness(float *brightness) { |
| 1098 | DisplayError ret = display_intf_->GetPanelBrightness(brightness); |
| 1099 | if (ret != kErrorNone) { |
| 1100 | return HWC2::Error::NoResources; |
| 1101 | } |
| 1102 | |
| 1103 | return HWC2::Error::None; |
| 1104 | } |
Xu Yang | 45d0abf | 2019-07-05 11:34:06 +0800 | [diff] [blame] | 1105 | |
Yuchao Ma | ada1c40 | 2019-11-12 14:47:11 +0800 | [diff] [blame] | 1106 | HWC2::Error HWCDisplayBuiltIn::GetPanelMaxBrightness(uint32_t *max_brightness_level) { |
| 1107 | DisplayError ret = display_intf_->GetPanelMaxBrightness(max_brightness_level); |
| 1108 | if (ret != kErrorNone) { |
| 1109 | return HWC2::Error::NoResources; |
| 1110 | } |
| 1111 | |
| 1112 | return HWC2::Error::None; |
| 1113 | } |
| 1114 | |
Xu Yang | 45d0abf | 2019-07-05 11:34:06 +0800 | [diff] [blame] | 1115 | HWC2::Error HWCDisplayBuiltIn::SetBLScale(uint32_t level) { |
| 1116 | DisplayError ret = display_intf_->SetBLScale(level); |
| 1117 | if (ret != kErrorNone) { |
| 1118 | return HWC2::Error::NoResources; |
| 1119 | } |
Srinivas Pullakavi | 3c4337f | 2019-07-03 11:24:31 +0530 | [diff] [blame] | 1120 | return HWC2::Error::None; |
| 1121 | } |
Xu Yang | 45d0abf | 2019-07-05 11:34:06 +0800 | [diff] [blame] | 1122 | |
Srinivas Pullakavi | 3c4337f | 2019-07-03 11:24:31 +0530 | [diff] [blame] | 1123 | HWC2::Error HWCDisplayBuiltIn::UpdatePowerMode(HWC2::PowerMode mode) { |
| 1124 | current_power_mode_ = mode; |
| 1125 | validated_ = false; |
Xu Yang | 45d0abf | 2019-07-05 11:34:06 +0800 | [diff] [blame] | 1126 | return HWC2::Error::None; |
| 1127 | } |
| 1128 | |
Padmanabhan Komanduru | 9a91e9f | 2019-09-12 12:33:19 +0530 | [diff] [blame] | 1129 | HWC2::Error HWCDisplayBuiltIn::SetClientTarget(buffer_handle_t target, int32_t acquire_fence, |
| 1130 | int32_t dataspace, hwc_region_t damage) { |
| 1131 | HWC2::Error error = HWCDisplay::SetClientTarget(target, acquire_fence, dataspace, damage); |
| 1132 | if (error != HWC2::Error::None) { |
| 1133 | return error; |
| 1134 | } |
| 1135 | |
| 1136 | Layer *sdm_layer = client_target_->GetSDMLayer(); |
Padmanabhan Komanduru | a4bf606 | 2019-10-13 09:04:49 +0530 | [diff] [blame] | 1137 | uint32_t fb_width = 0, fb_height = 0; |
| 1138 | |
| 1139 | GetFrameBufferResolution(&fb_width, &fb_height); |
| 1140 | |
| 1141 | if (fb_width != sdm_layer->input_buffer.unaligned_width || |
| 1142 | fb_height != sdm_layer->input_buffer.unaligned_height) { |
| 1143 | if (SetFrameBufferConfig(sdm_layer->input_buffer.unaligned_width, |
| 1144 | sdm_layer->input_buffer.unaligned_height)) { |
| 1145 | return HWC2::Error::BadParameter; |
| 1146 | } |
| 1147 | } |
Padmanabhan Komanduru | 9a91e9f | 2019-09-12 12:33:19 +0530 | [diff] [blame] | 1148 | |
| 1149 | return HWC2::Error::None; |
| 1150 | } |
Sushil Chauhan | 1566a13 | 2019-10-02 11:59:28 -0700 | [diff] [blame] | 1151 | |
| 1152 | bool HWCDisplayBuiltIn::IsSmartPanelConfig(uint32_t config_id) { |
| 1153 | if (config_id < hwc_config_map_.size()) { |
| 1154 | uint32_t index = hwc_config_map_.at(config_id); |
| 1155 | return variable_config_map_.at(index).smart_panel; |
| 1156 | } |
| 1157 | |
| 1158 | return false; |
| 1159 | } |
| 1160 | |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 1161 | int HWCDisplayBuiltIn::Deinit() { |
| 1162 | // Destory color convert instance. This destroys thread and underlying GL resources. |
| 1163 | if (gl_layer_stitch_) { |
| 1164 | layer_stitch_task_.PerformTask(LayerStitchTaskCode::kCodeDestroyInstance, nullptr); |
| 1165 | } |
| 1166 | |
Lakshmi Narayana Kalavala | 25fe12c | 2019-12-11 20:44:55 -0800 | [diff] [blame^] | 1167 | histogram.stop(); |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 1168 | return HWCDisplay::Deinit(); |
| 1169 | } |
| 1170 | |
| 1171 | void HWCDisplayBuiltIn::OnTask(const LayerStitchTaskCode &task_code, |
| 1172 | SyncTask<LayerStitchTaskCode>::TaskContext *task_context) { |
| 1173 | switch (task_code) { |
| 1174 | case LayerStitchTaskCode::kCodeGetInstance: { |
| 1175 | gl_layer_stitch_ = GLLayerStitch::GetInstance(false /* Non-secure */); |
| 1176 | } |
| 1177 | break; |
| 1178 | case LayerStitchTaskCode::kCodeStitch: { |
| 1179 | DTRACE_SCOPED(); |
| 1180 | LayerStitchStitchContext* ctx = reinterpret_cast<LayerStitchStitchContext*>(task_context); |
| 1181 | gl_layer_stitch_->Blit(ctx->src_hnd, ctx->dst_hnd, ctx->src_rect, ctx->dst_rect, |
| 1182 | ctx->src_acquire_fence_fd, ctx->dst_acquire_fence_fd, |
| 1183 | &(ctx->release_fence_fd)); |
| 1184 | } |
| 1185 | break; |
| 1186 | case LayerStitchTaskCode::kCodeDestroyInstance: { |
| 1187 | if (gl_layer_stitch_) { |
| 1188 | GLLayerStitch::Destroy(gl_layer_stitch_); |
| 1189 | } |
| 1190 | } |
| 1191 | break; |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | bool HWCDisplayBuiltIn::InitLayerStitch() { |
| 1196 | if (!is_primary_) { |
| 1197 | // Disable on all non-primary builtins. |
| 1198 | DLOGI("Non-primary builtin."); |
Pullakavi Srinivas | 94793b4 | 2019-11-27 20:03:50 +0530 | [diff] [blame] | 1199 | disable_layer_stitch_ = true; |
Pullakavi Srinivas | 1ae4acb | 2019-11-18 19:33:45 +0530 | [diff] [blame] | 1200 | return true; |
| 1201 | } |
| 1202 | |
| 1203 | // Disable by default. |
| 1204 | int value = 1; |
| 1205 | Debug::Get()->GetProperty(DISABLE_LAYER_STITCH, &value); |
| 1206 | disable_layer_stitch_ = (value == 1); |
| 1207 | |
| 1208 | if (disable_layer_stitch_) { |
| 1209 | DLOGI("Layer Stitch Disabled !!!"); |
| 1210 | return true; |
| 1211 | } |
| 1212 | |
| 1213 | // Initialize stitch context. This will be non-secure. |
| 1214 | layer_stitch_task_.PerformTask(LayerStitchTaskCode::kCodeGetInstance, nullptr); |
| 1215 | if (gl_layer_stitch_ == nullptr) { |
| 1216 | DLOGE("Failed to get LayerStitch Instance"); |
| 1217 | return false; |
| 1218 | } |
| 1219 | |
| 1220 | if (!AllocateStitchBuffer()) { |
| 1221 | return true; |
| 1222 | } |
| 1223 | |
| 1224 | stitch_target_ = new HWCLayer(id_, static_cast<HWCBufferAllocator *>(buffer_allocator_)); |
| 1225 | |
| 1226 | // Populate buffer params and pvt handle. |
| 1227 | InitStitchTarget(); |
| 1228 | |
| 1229 | DLOGI("Created LayerStitch instance: %p", gl_layer_stitch_); |
| 1230 | |
| 1231 | return true; |
| 1232 | } |
| 1233 | |
| 1234 | bool HWCDisplayBuiltIn::AllocateStitchBuffer() { |
| 1235 | // Buffer dimensions: FB width * (1.5 * height) |
| 1236 | |
| 1237 | DisplayError error = display_intf_->GetFrameBufferConfig(&fb_config_); |
| 1238 | if (error != kErrorNone) { |
| 1239 | DLOGE("Get frame buffer config failed. Error = %d", error); |
| 1240 | return false; |
| 1241 | } |
| 1242 | |
| 1243 | BufferConfig &config = buffer_info_.buffer_config; |
| 1244 | config.width = fb_config_.x_pixels; |
| 1245 | config.height = fb_config_.y_pixels * kBufferHeightFactor; |
| 1246 | |
| 1247 | // By default UBWC is enabled and below property is global enable/disable for all |
| 1248 | // buffers allocated through gralloc , including framebuffer targets. |
| 1249 | int ubwc_disabled = 0; |
| 1250 | HWCDebugHandler::Get()->GetProperty(DISABLE_UBWC_PROP, &ubwc_disabled); |
| 1251 | config.format = ubwc_disabled ? kFormatRGBA8888 : kFormatRGBA8888Ubwc; |
| 1252 | |
| 1253 | config.gfx_client = true; |
| 1254 | |
| 1255 | // Populate default params. |
| 1256 | config.secure = false; |
| 1257 | config.cache = false; |
| 1258 | config.secure_camera = false; |
| 1259 | |
| 1260 | error = buffer_allocator_->AllocateBuffer(&buffer_info_); |
| 1261 | |
| 1262 | if (error != kErrorNone) { |
| 1263 | DLOGE("Failed to allocate buffer. Error: %d", error); |
| 1264 | return false; |
| 1265 | } |
| 1266 | |
| 1267 | return true; |
| 1268 | } |
| 1269 | |
| 1270 | void HWCDisplayBuiltIn::InitStitchTarget() { |
| 1271 | LayerBuffer buffer = {}; |
| 1272 | buffer.planes[0].fd = buffer_info_.alloc_buffer_info.fd; |
| 1273 | buffer.planes[0].offset = 0; |
| 1274 | buffer.planes[0].stride = buffer_info_.alloc_buffer_info.stride; |
| 1275 | buffer.size = buffer_info_.alloc_buffer_info.size; |
| 1276 | buffer.handle_id = buffer_info_.alloc_buffer_info.id; |
| 1277 | buffer.width = buffer_info_.alloc_buffer_info.aligned_width; |
| 1278 | buffer.height = buffer_info_.alloc_buffer_info.aligned_height; |
| 1279 | buffer.unaligned_width = fb_config_.x_pixels; |
| 1280 | buffer.unaligned_height = fb_config_.y_pixels; |
| 1281 | buffer.format = buffer_info_.alloc_buffer_info.format; |
| 1282 | |
| 1283 | Layer *sdm_stitch_target = stitch_target_->GetSDMLayer(); |
| 1284 | sdm_stitch_target->composition = kCompositionStitchTarget; |
| 1285 | sdm_stitch_target->input_buffer = buffer; |
| 1286 | sdm_stitch_target->input_buffer.buffer_id = reinterpret_cast<uint64_t>(buffer_info_.private_data); |
| 1287 | } |
| 1288 | |
| 1289 | void HWCDisplayBuiltIn::AppendStitchLayer() { |
| 1290 | if (disable_layer_stitch_) { |
| 1291 | return; |
| 1292 | } |
| 1293 | |
| 1294 | // Append stitch target buffer to layer stack. |
| 1295 | Layer *sdm_stitch_target = stitch_target_->GetSDMLayer(); |
| 1296 | sdm_stitch_target->composition = kCompositionStitchTarget; |
| 1297 | layer_stack_.layers.push_back(sdm_stitch_target); |
| 1298 | } |
| 1299 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 1300 | } // namespace sdm |