blob: 53c9dc45c9dcdf794e169fbc91f15040875458ec [file] [log] [blame]
Naseer Ahmedb92e73f2016-03-12 02:03:48 -05001/*
Gousemoodhin Nadaf087c3102019-01-07 19:34:56 +05302* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
Naseer Ahmedb92e73f2016-03-12 02:03:48 -05003*
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 Chauhan06521582018-03-19 14:00:23 -070034#include <utils/utils.h>
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050035#include <stdarg.h>
36#include <sys/mman.h>
37
Arun Kumar K.R29cd6582016-05-10 19:12:45 -070038#include <map>
39#include <string>
40#include <vector>
41
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053042#include "hwc_display_builtin.h"
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050043#include "hwc_debugger.h"
Pullakavi Srinivas9189e602018-12-19 16:58:07 +053044#include "hwc_session.h"
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050045
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053046#define __CLASS__ "HWCDisplayBuiltIn"
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050047
48namespace sdm {
49
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053050int HWCDisplayBuiltIn::Create(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
Varun Arora7c8ee542018-05-01 20:58:16 -070051 HWCCallbacks *callbacks, HWCDisplayEventHandler *event_handler,
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053052 qService::QService *qservice, hwc2_display_t id, int32_t sdm_id,
53 HWCDisplay **hwc_display) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050054 int status = 0;
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053055 uint32_t builtin_width = 0;
56 uint32_t builtin_height = 0;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050057
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053058 HWCDisplay *hwc_display_builtin =
59 new HWCDisplayBuiltIn(core_intf, buffer_allocator, callbacks, event_handler, qservice, id,
60 sdm_id);
61 status = hwc_display_builtin->Init();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050062 if (status) {
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053063 delete hwc_display_builtin;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050064 return status;
65 }
66
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053067 hwc_display_builtin->GetMixerResolution(&builtin_width, &builtin_height);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050068 int width = 0, height = 0;
Uday Kiran Pichika5e656b22018-05-15 18:48:24 +053069 HWCDebugHandler::Get()->GetProperty(FB_WIDTH_PROP, &width);
70 HWCDebugHandler::Get()->GetProperty(FB_HEIGHT_PROP, &height);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050071 if (width > 0 && height > 0) {
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053072 builtin_width = UINT32(width);
73 builtin_height = UINT32(height);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050074 }
75
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053076 status = hwc_display_builtin->SetFrameBufferResolution(builtin_width, builtin_height);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050077 if (status) {
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053078 Destroy(hwc_display_builtin);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050079 return status;
80 }
81
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053082 *hwc_display = hwc_display_builtin;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050083
84 return status;
85}
86
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053087void HWCDisplayBuiltIn::Destroy(HWCDisplay *hwc_display) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050088 hwc_display->Deinit();
89 delete hwc_display;
90}
91
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053092HWCDisplayBuiltIn::HWCDisplayBuiltIn(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
Varun Arora7c8ee542018-05-01 20:58:16 -070093 HWCCallbacks *callbacks, HWCDisplayEventHandler *event_handler,
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053094 qService::QService *qservice, hwc2_display_t id,
95 int32_t sdm_id)
96 : HWCDisplay(core_intf, buffer_allocator, callbacks, event_handler, qservice, kBuiltIn, id,
Gousemoodhin Nadaf087c3102019-01-07 19:34:56 +053097 sdm_id, DISPLAY_CLASS_BUILTIN),
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +053098 buffer_allocator_(buffer_allocator),
99 cpu_hint_(NULL) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500100}
101
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530102int HWCDisplayBuiltIn::Init() {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500103 cpu_hint_ = new CPUHint();
104 if (cpu_hint_->Init(static_cast<HWCDebugHandler *>(HWCDebugHandler::Get())) != kErrorNone) {
105 delete cpu_hint_;
106 cpu_hint_ = NULL;
107 }
108
109 use_metadata_refresh_rate_ = true;
110 int disable_metadata_dynfps = 0;
Uday Kiran Pichika5e656b22018-05-15 18:48:24 +0530111 HWCDebugHandler::Get()->GetProperty(DISABLE_METADATA_DYNAMIC_FPS_PROP, &disable_metadata_dynfps);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500112 if (disable_metadata_dynfps) {
113 use_metadata_refresh_rate_ = false;
114 }
115
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700116 int status = HWCDisplay::Init();
117 if (status) {
118 return status;
119 }
120 color_mode_ = new HWCColorMode(display_intf_);
Naseer Ahmed61f60952017-05-24 16:48:35 -0400121 color_mode_->Init();
Uday Kiran Pichika5e656b22018-05-15 18:48:24 +0530122 HWCDebugHandler::Get()->GetProperty(ENABLE_DEFAULT_COLOR_MODE,
Ch Ganesh Kumar86c46512017-06-13 13:09:22 +0530123 &default_mode_status_);
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700124
Padmanabhan Komandurue74cf4f2019-04-25 17:38:43 -0700125 int drop_refresh = 0;
126 HWCDebugHandler::Get()->GetProperty(ENABLE_DROP_REFRESH, &drop_refresh);
127 enable_drop_refresh_ = (drop_refresh == 1);
128 if (enable_drop_refresh_) {
129 DLOGI("Drop redundant drawcycles %d", id_);
130 }
131
Naseer Ahmed61f60952017-05-24 16:48:35 -0400132 return status;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500133}
134
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530135HWC2::Error HWCDisplayBuiltIn::Validate(uint32_t *out_num_types, uint32_t *out_num_requests) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500136 auto status = HWC2::Error::None;
137 DisplayError error = kErrorNone;
138
Gurpreet Singh Dhamia4276882019-04-12 10:30:58 -0700139 DTRACE_SCOPED();
140
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500141 if (display_paused_) {
142 MarkLayersForGPUBypass();
143 return status;
144 }
145
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700146 if (color_tranform_failed_) {
147 // Must fall back to client composition
148 MarkLayersForClientComposition();
149 }
150
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500151 // Fill in the remaining blanks in the layers and add them to the SDM layerstack
152 BuildLayerStack();
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700153 // Checks and replaces layer stack for solid fill
154 SolidFillPrepare();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500155
Sushil Chauhan8008d602018-09-04 14:43:27 -0700156 // Apply current Color Mode and Render Intent.
Xu Yang84e61412018-12-06 14:52:16 +0800157 if (color_mode_->ApplyCurrentColorModeWithRenderIntent(
158 static_cast<bool>(layer_stack_.flags.hdr_present)) != HWC2::Error::None) {
Sushil Chauhan8008d602018-09-04 14:43:27 -0700159 // Fallback to GPU Composition, if Color Mode can't be applied.
160 MarkLayersForClientComposition();
161 }
162
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500163 bool pending_output_dump = dump_frame_count_ && dump_output_to_file_;
164
Sushil Chauhan06521582018-03-19 14:00:23 -0700165 if (readback_buffer_queued_ || pending_output_dump) {
166 CloseFd(&output_buffer_.release_fence_fd);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500167 // RHS values were set in FrameCaptureAsync() called from a binder thread. They are picked up
Sushil Chauhan06521582018-03-19 14:00:23 -0700168 // here in a subsequent draw round. Readback is not allowed for any secure use case.
169 readback_configured_ = !layer_stack_.flags.secure_present;
170 if (readback_configured_) {
Sushil Chauhanf42d8622018-09-30 23:20:37 -0700171 DisablePartialUpdateOneFrame();
Sushil Chauhan06521582018-03-19 14:00:23 -0700172 layer_stack_.output_buffer = &output_buffer_;
173 layer_stack_.flags.post_processed_output = post_processed_output_;
174 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500175 }
176
Ramakant Singh5db0dfb2017-08-23 12:34:57 +0530177 uint32_t num_updating_layers = GetUpdatingLayersCount();
178 bool one_updating_layer = (num_updating_layers == 1);
179 if (num_updating_layers != 0) {
180 ToggleCPUHint(one_updating_layer);
181 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500182
183 uint32_t refresh_rate = GetOptimalRefreshRate(one_updating_layer);
Anjaneya Prasad Musunuri4d65df72017-05-18 19:11:28 +0530184 bool final_rate = force_refresh_rate_ ? true : false;
185 error = display_intf_->SetRefreshRate(refresh_rate, final_rate);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500186 if (error == kErrorNone) {
187 // On success, set current refresh rate to new refresh rate
188 current_refresh_rate_ = refresh_rate;
189 }
190
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500191 if (layer_set_.empty()) {
Uday Kiran Pichika8d827732018-01-09 18:08:38 +0530192 // Avoid flush for Command mode panel.
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700193 flush_ = !IsDisplayCommandMode();
194 validated_ = true;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500195 return status;
196 }
197
198 status = PrepareLayerStack(out_num_types, out_num_requests);
Namit Solanki5b428dc2018-02-27 11:39:05 +0530199 pending_commit_ = true;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500200 return status;
201}
202
Padmanabhan Komandurue74cf4f2019-04-25 17:38:43 -0700203HWC2::Error HWCDisplayBuiltIn::CommitLayerStack() {
204 skip_commit_ = CanSkipCommit();
205 return HWCDisplay::CommitLayerStack();
206}
207
208bool HWCDisplayBuiltIn::CanSkipCommit() {
209 if (layer_stack_invalid_) {
210 return false;
211 }
212
213 // Reject repeated drawcycle requests if it satisfies all conditions.
214 // 1. None of the layerstack attributes changed.
215 // 2. No new buffer latched.
216 // 3. No refresh request triggered by HWC.
217 // 4. This display is not source of vsync.
218 bool buffers_latched = false;
219 for (auto &hwc_layer : layer_set_) {
220 buffers_latched |= hwc_layer->BufferLatched();
221 hwc_layer->ResetBufferFlip();
222 }
223
224 bool skip_commit = enable_drop_refresh_ && !pending_commit_ && !buffers_latched &&
225 !pending_refresh_ && !vsync_source_;
226 pending_refresh_ = false;
227
228 return skip_commit;
229}
230
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530231HWC2::Error HWCDisplayBuiltIn::Present(int32_t *out_retire_fence) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500232 auto status = HWC2::Error::None;
Gurpreet Singh Dhamia4276882019-04-12 10:30:58 -0700233
234 DTRACE_SCOPED();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500235 if (display_paused_) {
Pullakavi Srinivas0a1dba62018-07-02 15:49:11 +0530236 DisplayError error = display_intf_->Flush(&layer_stack_);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700237 validated_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500238 if (error != kErrorNone) {
239 DLOGE("Flush failed. Error = %d", error);
240 }
241 } else {
Padmanabhan Komandurue74cf4f2019-04-25 17:38:43 -0700242 status = CommitLayerStack();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500243 if (status == HWC2::Error::None) {
244 HandleFrameOutput();
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700245 SolidFillCommit();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500246 status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
247 }
248 }
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700249
Sushil Chauhan06521582018-03-19 14:00:23 -0700250 CloseFd(&output_buffer_.acquire_fence_fd);
Namit Solanki5b428dc2018-02-27 11:39:05 +0530251 pending_commit_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500252 return status;
253}
254
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530255HWC2::Error HWCDisplayBuiltIn::GetColorModes(uint32_t *out_num_modes, ColorMode *out_modes) {
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700256 if (out_modes == nullptr) {
257 *out_num_modes = color_mode_->GetColorModeCount();
258 } else {
259 color_mode_->GetColorModes(out_num_modes, out_modes);
260 }
261
262 return HWC2::Error::None;
263}
264
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530265HWC2::Error HWCDisplayBuiltIn::GetRenderIntents(ColorMode mode, uint32_t *out_num_intents,
Naseer Ahmede7a77982018-06-04 10:56:04 -0400266 RenderIntent *out_intents) {
267 if (out_intents == nullptr) {
268 *out_num_intents = color_mode_->GetRenderIntentCount(mode);
269 } else {
270 color_mode_->GetRenderIntents(mode, out_num_intents, out_intents);
271 }
272 return HWC2::Error::None;
273}
274
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530275HWC2::Error HWCDisplayBuiltIn::SetColorMode(ColorMode mode) {
Naseer Ahmede7a77982018-06-04 10:56:04 -0400276 return SetColorModeWithRenderIntent(mode, RenderIntent::COLORIMETRIC);
277}
278
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530279HWC2::Error HWCDisplayBuiltIn::SetColorModeWithRenderIntent(ColorMode mode, RenderIntent intent) {
Sushil Chauhan8008d602018-09-04 14:43:27 -0700280 auto status = color_mode_->CacheColorModeWithRenderIntent(mode, intent);
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700281 if (status != HWC2::Error::None) {
Naseer Ahmede7a77982018-06-04 10:56:04 -0400282 DLOGE("failed for mode = %d intent = %d", mode, intent);
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700283 return status;
284 }
Ramkumar Radhakrishnan44c64362018-12-12 13:03:59 -0800285 callbacks_->Refresh(id_);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700286 validated_ = false;
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700287 return status;
288}
289
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530290HWC2::Error HWCDisplayBuiltIn::SetColorModeById(int32_t color_mode_id) {
Naseer Ahmed6776dae2017-05-09 11:49:41 -0400291 auto status = color_mode_->SetColorModeById(color_mode_id);
292 if (status != HWC2::Error::None) {
293 DLOGE("failed for mode = %d", color_mode_id);
294 return status;
295 }
296
Ramkumar Radhakrishnan44c64362018-12-12 13:03:59 -0800297 callbacks_->Refresh(id_);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700298 validated_ = false;
Naseer Ahmed6776dae2017-05-09 11:49:41 -0400299
300 return status;
301}
302
Xu Yang84e61412018-12-06 14:52:16 +0800303HWC2::Error HWCDisplayBuiltIn::SetColorModeFromClientApi(int32_t color_mode_id) {
304 DisplayError error = kErrorNone;
305 std::string mode_string;
306
307 error = display_intf_->GetColorModeName(color_mode_id, &mode_string);
308 if (error) {
309 DLOGE("Failed to get mode name for mode %d", color_mode_id);
310 return HWC2::Error::BadParameter;
311 }
312
313 auto status = color_mode_->SetColorModeFromClientApi(mode_string);
314 if (status != HWC2::Error::None) {
315 DLOGE("Failed to set mode = %d", color_mode_id);
316 return status;
317 }
318
319 return status;
320}
321
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530322HWC2::Error HWCDisplayBuiltIn::RestoreColorTransform() {
Ch Ganesh Kumar5d43ff62017-10-13 19:01:47 +0530323 auto status = color_mode_->RestoreColorTransform();
324 if (status != HWC2::Error::None) {
325 DLOGE("failed to RestoreColorTransform");
326 return status;
327 }
328
Ramkumar Radhakrishnan44c64362018-12-12 13:03:59 -0800329 callbacks_->Refresh(id_);
Ch Ganesh Kumar5d43ff62017-10-13 19:01:47 +0530330
331 return status;
332}
333
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530334HWC2::Error HWCDisplayBuiltIn::SetColorTransform(const float *matrix,
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700335 android_color_transform_t hint) {
336 if (!matrix) {
337 return HWC2::Error::BadParameter;
338 }
339
340 auto status = color_mode_->SetColorTransform(matrix, hint);
341 if (status != HWC2::Error::None) {
342 DLOGE("failed for hint = %d", hint);
343 color_tranform_failed_ = true;
344 return status;
345 }
346
Ramkumar Radhakrishnan44c64362018-12-12 13:03:59 -0800347 callbacks_->Refresh(id_);
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700348 color_tranform_failed_ = false;
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700349 validated_ = false;
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700350
351 return status;
352}
353
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530354HWC2::Error HWCDisplayBuiltIn::SetReadbackBuffer(const native_handle_t *buffer,
Sushil Chauhan06521582018-03-19 14:00:23 -0700355 int32_t acquire_fence,
356 bool post_processed_output) {
357 const private_handle_t *handle = reinterpret_cast<const private_handle_t *>(buffer);
358 if (!handle || (handle->fd < 0)) {
359 return HWC2::Error::BadParameter;
360 }
361
362 // Configure the output buffer as Readback buffer
363 output_buffer_.width = UINT32(handle->width);
364 output_buffer_.height = UINT32(handle->height);
365 output_buffer_.unaligned_width = UINT32(handle->unaligned_width);
366 output_buffer_.unaligned_height = UINT32(handle->unaligned_height);
367 output_buffer_.format = HWCLayer::GetSDMFormat(handle->format, handle->flags);
368 output_buffer_.planes[0].fd = handle->fd;
369 output_buffer_.planes[0].stride = UINT32(handle->width);
370 output_buffer_.acquire_fence_fd = dup(acquire_fence);
371 output_buffer_.release_fence_fd = -1;
Sushil Chauhand0dc03d2018-09-19 07:08:40 -0700372 output_buffer_.handle_id = handle->id;
Sushil Chauhan06521582018-03-19 14:00:23 -0700373
374 post_processed_output_ = post_processed_output;
375 readback_buffer_queued_ = true;
376 readback_configured_ = false;
377 validated_ = false;
378
Sushil Chauhan06521582018-03-19 14:00:23 -0700379 return HWC2::Error::None;
380}
381
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530382HWC2::Error HWCDisplayBuiltIn::GetReadbackBufferFence(int32_t *release_fence) {
Sushil Chauhan06521582018-03-19 14:00:23 -0700383 auto status = HWC2::Error::None;
384
385 if (readback_configured_ && (output_buffer_.release_fence_fd >= 0)) {
386 *release_fence = output_buffer_.release_fence_fd;
387 } else {
388 status = HWC2::Error::Unsupported;
389 *release_fence = -1;
390 }
391
392 post_processed_output_ = false;
393 readback_buffer_queued_ = false;
394 readback_configured_ = false;
395 output_buffer_ = {};
396
397 return status;
398}
399
Gurpreet Singh Dhami1207e462018-12-27 20:02:02 -0500400DisplayError HWCDisplayBuiltIn::TeardownConcurrentWriteback(void) {
401 DisplayError error = kErrorNotSupported;
402
403 if (output_buffer_.release_fence_fd >= 0) {
404 int32_t release_fence_fd = dup(output_buffer_.release_fence_fd);
405 int ret = sync_wait(output_buffer_.release_fence_fd, 1000);
406 if (ret < 0) {
407 DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno));
408 }
409
410 ::close(release_fence_fd);
411 if (ret)
412 return kErrorResources;
413 }
414
415 if (display_intf_) {
416 error = display_intf_->TeardownConcurrentWriteback();
417 }
418
419 return error;
420}
421
Yuchao Ma577f0f72018-07-09 11:20:00 +0800422HWC2::Error HWCDisplayBuiltIn::SetDisplayDppsAdROI(uint32_t h_start, uint32_t h_end,
423 uint32_t v_start, uint32_t v_end,
424 uint32_t factor_in, uint32_t factor_out) {
425 DisplayError error = kErrorNone;
426 DisplayDppsAd4RoiCfg dpps_ad4_roi_cfg = {};
427 uint32_t panel_width = 0, panel_height = 0;
428 constexpr uint16_t kMaxFactorVal = 0xffff;
429
430 if (h_start >= h_end || v_start >= v_end || factor_in > kMaxFactorVal ||
431 factor_out > kMaxFactorVal) {
432 DLOGE("Invalid roi region = [%u, %u, %u, %u, %u, %u]",
433 h_start, h_end, v_start, v_end, factor_in, factor_out);
434 return HWC2::Error::BadParameter;
435 }
436
437 GetPanelResolution(&panel_width, &panel_height);
438
439 if (h_start >= panel_width || h_end > panel_width ||
440 v_start >= panel_height || v_end > panel_height) {
441 DLOGE("Invalid roi region = [%u, %u, %u, %u], panel resolution = [%u, %u]",
442 h_start, h_end, v_start, v_end, panel_width, panel_height);
443 return HWC2::Error::BadParameter;
444 }
445
446 dpps_ad4_roi_cfg.h_start = h_start;
447 dpps_ad4_roi_cfg.h_end = h_end;
448 dpps_ad4_roi_cfg.v_start = v_start;
449 dpps_ad4_roi_cfg.v_end = v_end;
450 dpps_ad4_roi_cfg.factor_in = factor_in;
451 dpps_ad4_roi_cfg.factor_out = factor_out;
452
453 error = display_intf_->SetDisplayDppsAdROI(&dpps_ad4_roi_cfg);
454 if (error)
455 return HWC2::Error::BadConfig;
456
Ramkumar Radhakrishnan44c64362018-12-12 13:03:59 -0800457 callbacks_->Refresh(id_);
Yuchao Ma577f0f72018-07-09 11:20:00 +0800458
459 return HWC2::Error::None;
460}
461
Xu Yang9dacc872018-12-25 11:04:28 +0800462HWC2::Error HWCDisplayBuiltIn::SetFrameTriggerMode(uint32_t mode) {
463 DisplayError error = kErrorNone;
464 FrameTriggerMode trigger_mode = kFrameTriggerDefault;
465
466 if (mode >= kFrameTriggerMax) {
467 DLOGE("Invalid input mode %d", mode);
468 return HWC2::Error::BadParameter;
469 }
470
471 trigger_mode = static_cast<FrameTriggerMode>(mode);
472 error = display_intf_->SetFrameTriggerMode(trigger_mode);
473 if (error)
474 return HWC2::Error::BadConfig;
475
476 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
477 validated_ = false;
478
479 return HWC2::Error::None;
480}
481
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530482int HWCDisplayBuiltIn::Perform(uint32_t operation, ...) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500483 va_list args;
484 va_start(args, operation);
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700485 int val = 0;
Gopikrishnaiah Anandancc123062017-07-31 17:21:03 -0700486 LayerSolidFill *solid_fill_color;
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700487 LayerRect *rect = NULL;
488
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500489 switch (operation) {
490 case SET_METADATA_DYN_REFRESH_RATE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700491 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500492 SetMetaDataRefreshRateFlag(val);
493 break;
494 case SET_BINDER_DYN_REFRESH_RATE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700495 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500496 ForceRefreshRate(UINT32(val));
497 break;
498 case SET_DISPLAY_MODE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700499 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500500 SetDisplayMode(UINT32(val));
501 break;
502 case SET_QDCM_SOLID_FILL_INFO:
Gopikrishnaiah Anandancc123062017-07-31 17:21:03 -0700503 solid_fill_color = va_arg(args, LayerSolidFill*);
504 SetQDCMSolidFillInfo(true, *solid_fill_color);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500505 break;
506 case UNSET_QDCM_SOLID_FILL_INFO:
Gopikrishnaiah Anandancc123062017-07-31 17:21:03 -0700507 solid_fill_color = va_arg(args, LayerSolidFill*);
508 SetQDCMSolidFillInfo(false, *solid_fill_color);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500509 break;
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700510 case SET_QDCM_SOLID_FILL_RECT:
511 rect = va_arg(args, LayerRect*);
512 solid_fill_rect_ = *rect;
513 break;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500514 default:
515 DLOGW("Invalid operation %d", operation);
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700516 va_end(args);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500517 return -EINVAL;
518 }
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700519 va_end(args);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700520 validated_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500521
522 return 0;
523}
524
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530525DisplayError HWCDisplayBuiltIn::SetDisplayMode(uint32_t mode) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500526 DisplayError error = kErrorNone;
527
528 if (display_intf_) {
529 error = display_intf_->SetDisplayMode(mode);
Tharaga Balachandran04192a62018-08-29 16:23:25 -0400530 if (error == kErrorNone) {
531 DisplayConfigFixedInfo fixed_info = {};
532 display_intf_->GetConfig(&fixed_info);
533 is_cmd_mode_ = fixed_info.is_cmdmode;
534 partial_update_enabled_ = fixed_info.partial_update;
535 for (auto hwc_layer : layer_set_) {
536 hwc_layer->SetPartialUpdate(partial_update_enabled_);
537 }
538 client_target_->SetPartialUpdate(partial_update_enabled_);
539 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500540 }
541
542 return error;
543}
544
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530545void HWCDisplayBuiltIn::SetMetaDataRefreshRateFlag(bool enable) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500546 int disable_metadata_dynfps = 0;
547
Uday Kiran Pichika5e656b22018-05-15 18:48:24 +0530548 HWCDebugHandler::Get()->GetProperty(DISABLE_METADATA_DYNAMIC_FPS_PROP, &disable_metadata_dynfps);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500549 if (disable_metadata_dynfps) {
550 return;
551 }
552 use_metadata_refresh_rate_ = enable;
553}
554
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530555void HWCDisplayBuiltIn::SetQDCMSolidFillInfo(bool enable, const LayerSolidFill &color) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500556 solid_fill_enable_ = enable;
557 solid_fill_color_ = color;
558}
559
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530560void HWCDisplayBuiltIn::ToggleCPUHint(bool set) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500561 if (!cpu_hint_) {
562 return;
563 }
564
565 if (set) {
566 cpu_hint_->Set();
567 } else {
568 cpu_hint_->Reset();
569 }
570}
571
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530572int HWCDisplayBuiltIn::HandleSecureSession(const std::bitset<kSecureMax> &secure_sessions,
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700573 bool *power_on_pending) {
574 if (!power_on_pending) {
575 return -EINVAL;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500576 }
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700577
Ramkumar Radhakrishnan44c64362018-12-12 13:03:59 -0800578 if (current_power_mode_ != HWC2::PowerMode::On) {
579 return 0;
580 }
581
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700582 if (active_secure_sessions_[kSecureDisplay] != secure_sessions[kSecureDisplay]) {
583 SecureEvent secure_event =
584 secure_sessions.test(kSecureDisplay) ? kSecureDisplayStart : kSecureDisplayEnd;
Pullakavi Srinivas0a1dba62018-07-02 15:49:11 +0530585 DisplayError err = display_intf_->HandleSecureEvent(secure_event, &layer_stack_);
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700586 if (err != kErrorNone) {
587 DLOGE("Set secure event failed");
588 return err;
589 }
590
591 DLOGI("SecureDisplay state changed from %d to %d for display %d",
592 active_secure_sessions_.test(kSecureDisplay), secure_sessions.test(kSecureDisplay),
593 type_);
594 }
595 active_secure_sessions_ = secure_sessions;
596 *power_on_pending = false;
597 return 0;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500598}
599
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530600void HWCDisplayBuiltIn::ForceRefreshRate(uint32_t refresh_rate) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500601 if ((refresh_rate && (refresh_rate < min_refresh_rate_ || refresh_rate > max_refresh_rate_)) ||
602 force_refresh_rate_ == refresh_rate) {
603 // Cannot honor force refresh rate, as its beyond the range or new request is same
604 return;
605 }
606
607 force_refresh_rate_ = refresh_rate;
608
Ramkumar Radhakrishnan44c64362018-12-12 13:03:59 -0800609 callbacks_->Refresh(id_);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500610
611 return;
612}
613
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530614uint32_t HWCDisplayBuiltIn::GetOptimalRefreshRate(bool one_updating_layer) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500615 if (force_refresh_rate_) {
616 return force_refresh_rate_;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500617 } else if (use_metadata_refresh_rate_ && one_updating_layer && metadata_refresh_rate_) {
618 return metadata_refresh_rate_;
619 }
620
621 return max_refresh_rate_;
622}
623
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530624DisplayError HWCDisplayBuiltIn::Refresh() {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500625 DisplayError error = kErrorNone;
626
Ramkumar Radhakrishnan44c64362018-12-12 13:03:59 -0800627 callbacks_->Refresh(id_);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500628
629 return error;
630}
631
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530632void HWCDisplayBuiltIn::SetIdleTimeoutMs(uint32_t timeout_ms) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500633 display_intf_->SetIdleTimeoutMs(timeout_ms);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700634 validated_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500635}
636
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530637void HWCDisplayBuiltIn::HandleFrameOutput() {
Sushil Chauhan06521582018-03-19 14:00:23 -0700638 if (readback_buffer_queued_) {
639 validated_ = false;
640 }
641
Sushil Chauhan1d3b90c2018-12-11 16:52:35 -0800642 if (frame_capture_buffer_queued_) {
643 HandleFrameCapture();
644 } else if (dump_output_to_file_) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500645 HandleFrameDump();
646 }
647}
648
Sushil Chauhan1d3b90c2018-12-11 16:52:35 -0800649void HWCDisplayBuiltIn::HandleFrameCapture() {
650 if (readback_configured_ && (output_buffer_.release_fence_fd >= 0)) {
651 frame_capture_status_ = sync_wait(output_buffer_.release_fence_fd, 1000);
652 ::close(output_buffer_.release_fence_fd);
653 output_buffer_.release_fence_fd = -1;
654 }
655
656 frame_capture_buffer_queued_ = false;
657 readback_buffer_queued_ = false;
658 post_processed_output_ = false;
659 readback_configured_ = false;
660 output_buffer_ = {};
661}
662
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530663void HWCDisplayBuiltIn::HandleFrameDump() {
Sushil Chauhan06521582018-03-19 14:00:23 -0700664 if (!readback_configured_) {
665 dump_frame_count_ = 0;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500666 }
667
Sushil Chauhan06521582018-03-19 14:00:23 -0700668 if (dump_frame_count_ && output_buffer_.release_fence_fd >= 0) {
669 int ret = sync_wait(output_buffer_.release_fence_fd, 1000);
670 ::close(output_buffer_.release_fence_fd);
671 output_buffer_.release_fence_fd = -1;
672 if (ret < 0) {
673 DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno));
674 } else {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500675 DumpOutputBuffer(output_buffer_info_, output_buffer_base_, layer_stack_.retire_fence_fd);
Sushil Chauhan06521582018-03-19 14:00:23 -0700676 readback_buffer_queued_ = false;
Sushil Chauhan062a7a42018-04-25 22:27:52 -0700677 validated_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500678 }
679 }
680
681 if (0 == dump_frame_count_) {
682 dump_output_to_file_ = false;
683 // Unmap and Free buffer
684 if (munmap(output_buffer_base_, output_buffer_info_.alloc_buffer_info.size) != 0) {
685 DLOGE("unmap failed with err %d", errno);
686 }
687 if (buffer_allocator_->FreeBuffer(&output_buffer_info_) != 0) {
688 DLOGE("FreeBuffer failed");
689 }
690
Sushil Chauhan06521582018-03-19 14:00:23 -0700691 readback_buffer_queued_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500692 post_processed_output_ = false;
Sushil Chauhan06521582018-03-19 14:00:23 -0700693 readback_configured_ = false;
694
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500695 output_buffer_ = {};
696 output_buffer_info_ = {};
697 output_buffer_base_ = nullptr;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500698 }
699}
700
Sushil Chauhan267a6192018-06-06 18:41:47 -0700701HWC2::Error HWCDisplayBuiltIn::SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type,
702 int32_t format, bool post_processed) {
703 HWCDisplay::SetFrameDumpConfig(count, bit_mask_layer_type, format, post_processed);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500704 dump_output_to_file_ = bit_mask_layer_type & (1 << OUTPUT_LAYER_DUMP);
705 DLOGI("output_layer_dump_enable %d", dump_output_to_file_);
706
Sushil Chauhand0dc03d2018-09-19 07:08:40 -0700707 if (!count || !dump_output_to_file_ || (output_buffer_info_.alloc_buffer_info.fd >= 0)) {
Mathew Joseph Karimpanaldbd64f82017-10-06 10:13:38 +0530708 return HWC2::Error::None;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500709 }
710
711 // Allocate and map output buffer
Sushil Chauhan267a6192018-06-06 18:41:47 -0700712 if (post_processed) {
713 // To dump post-processed (DSPP) output, use Panel resolution.
714 GetPanelResolution(&output_buffer_info_.buffer_config.width,
715 &output_buffer_info_.buffer_config.height);
716 } else {
717 // To dump Layer Mixer output, use FrameBuffer resolution.
718 GetFrameBufferResolution(&output_buffer_info_.buffer_config.width,
719 &output_buffer_info_.buffer_config.height);
720 }
721
722 output_buffer_info_.buffer_config.format = HWCLayer::GetSDMFormat(format, 0);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500723 output_buffer_info_.buffer_config.buffer_count = 1;
724 if (buffer_allocator_->AllocateBuffer(&output_buffer_info_) != 0) {
725 DLOGE("Buffer allocation failed");
726 output_buffer_info_ = {};
Mathew Joseph Karimpanaldbd64f82017-10-06 10:13:38 +0530727 return HWC2::Error::NoResources;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500728 }
729
730 void *buffer = mmap(NULL, output_buffer_info_.alloc_buffer_info.size, PROT_READ | PROT_WRITE,
731 MAP_SHARED, output_buffer_info_.alloc_buffer_info.fd, 0);
732
733 if (buffer == MAP_FAILED) {
734 DLOGE("mmap failed with err %d", errno);
735 buffer_allocator_->FreeBuffer(&output_buffer_info_);
736 output_buffer_info_ = {};
Mathew Joseph Karimpanaldbd64f82017-10-06 10:13:38 +0530737 return HWC2::Error::NoResources;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500738 }
739
740 output_buffer_base_ = buffer;
Sushil Chauhan06521582018-03-19 14:00:23 -0700741 const native_handle_t *handle = static_cast<native_handle_t *>(output_buffer_info_.private_data);
Sushil Chauhan267a6192018-06-06 18:41:47 -0700742 SetReadbackBuffer(handle, -1, post_processed);
Sushil Chauhan06521582018-03-19 14:00:23 -0700743
Mathew Joseph Karimpanaldbd64f82017-10-06 10:13:38 +0530744 return HWC2::Error::None;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500745}
746
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530747int HWCDisplayBuiltIn::FrameCaptureAsync(const BufferInfo &output_buffer_info,
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500748 bool post_processed_output) {
749 // Note: This function is called in context of a binder thread and a lock is already held
750 if (output_buffer_info.alloc_buffer_info.fd < 0) {
751 DLOGE("Invalid fd %d", output_buffer_info.alloc_buffer_info.fd);
752 return -1;
753 }
754
755 auto panel_width = 0u;
756 auto panel_height = 0u;
757 auto fb_width = 0u;
758 auto fb_height = 0u;
759
760 GetPanelResolution(&panel_width, &panel_height);
761 GetFrameBufferResolution(&fb_width, &fb_height);
762
Ch Ganesh Kumar5c4988b2017-06-07 15:21:02 +0530763 if (post_processed_output && (output_buffer_info.buffer_config.width < panel_width ||
764 output_buffer_info.buffer_config.height < panel_height)) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500765 DLOGE("Buffer dimensions should not be less than panel resolution");
766 return -1;
Ch Ganesh Kumar5c4988b2017-06-07 15:21:02 +0530767 } else if (!post_processed_output && (output_buffer_info.buffer_config.width < fb_width ||
768 output_buffer_info.buffer_config.height < fb_height)) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500769 DLOGE("Buffer dimensions should not be less than FB resolution");
770 return -1;
771 }
772
Sushil Chauhan06521582018-03-19 14:00:23 -0700773 const native_handle_t *buffer = static_cast<native_handle_t *>(output_buffer_info.private_data);
774 SetReadbackBuffer(buffer, -1, post_processed_output);
Sushil Chauhan1d3b90c2018-12-11 16:52:35 -0800775 frame_capture_buffer_queued_ = true;
776 frame_capture_status_ = -EAGAIN;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500777
778 return 0;
779}
780
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530781DisplayError HWCDisplayBuiltIn::SetDetailEnhancerConfig
Alan Kwong2e136332016-08-16 07:50:16 -0400782 (const DisplayDetailEnhancerData &de_data) {
783 DisplayError error = kErrorNotSupported;
784
785 if (display_intf_) {
786 error = display_intf_->SetDetailEnhancerData(de_data);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700787 validated_ = false;
Alan Kwong2e136332016-08-16 07:50:16 -0400788 }
789 return error;
790}
791
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530792DisplayError HWCDisplayBuiltIn::ControlPartialUpdate(bool enable, uint32_t *pending) {
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700793 DisplayError error = kErrorNone;
794
795 if (display_intf_) {
796 error = display_intf_->ControlPartialUpdate(enable, pending);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700797 validated_ = false;
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700798 }
799
800 return error;
801}
802
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530803DisplayError HWCDisplayBuiltIn::DisablePartialUpdateOneFrame() {
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700804 DisplayError error = kErrorNone;
805
806 if (display_intf_) {
807 error = display_intf_->DisablePartialUpdateOneFrame();
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700808 validated_ = false;
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700809 }
810
811 return error;
812}
813
814
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530815DisplayError HWCDisplayBuiltIn::SetMixerResolution(uint32_t width, uint32_t height) {
Sushil Chauhan409e8442017-06-12 17:43:25 -0700816 DisplayError error = display_intf_->SetMixerResolution(width, height);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700817 validated_ = false;
Sushil Chauhan409e8442017-06-12 17:43:25 -0700818 return error;
Arun Kumar K.R8da7f502016-06-07 17:45:50 -0700819}
820
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530821DisplayError HWCDisplayBuiltIn::GetMixerResolution(uint32_t *width, uint32_t *height) {
Arun Kumar K.R8da7f502016-06-07 17:45:50 -0700822 return display_intf_->GetMixerResolution(width, height);
823}
824
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530825HWC2::Error HWCDisplayBuiltIn::SetQSyncMode(QSyncMode qsync_mode) {
Sushil Chauhan380a59d2018-03-19 15:47:50 -0700826 auto err = display_intf_->SetQSyncMode(qsync_mode);
827 if (err != kErrorNone) {
828 return HWC2::Error::Unsupported;
829 }
830
Sushil Chauhanec4eb572019-02-07 13:29:42 -0800831 validated_ = false;
Sushil Chauhan380a59d2018-03-19 15:47:50 -0700832 return HWC2::Error::None;
833}
834
Ramkumar Radhakrishnan4faf8a62018-11-15 17:15:37 -0800835DisplayError HWCDisplayBuiltIn::ControlIdlePowerCollapse(bool enable, bool synchronous) {
Ramkumar Radhakrishnanf985d482018-07-23 18:10:41 -0700836 DisplayError error = kErrorNone;
837
838 if (display_intf_) {
839 error = display_intf_->ControlIdlePowerCollapse(enable, synchronous);
840 validated_ = false;
841 }
Ramkumar Radhakrishnan4faf8a62018-11-15 17:15:37 -0800842 return error;
Ramkumar Radhakrishnanf985d482018-07-23 18:10:41 -0700843}
844
Pullakavi Srinivas9189e602018-12-19 16:58:07 +0530845DisplayError HWCDisplayBuiltIn::SetDynamicDSIClock(uint64_t bitclk) {
846 {
847 SEQUENCE_WAIT_SCOPE_LOCK(HWCSession::locker_[type_]);
848 DisplayError error = display_intf_->SetDynamicDSIClock(bitclk);
849 if (error != kErrorNone) {
850 DLOGE(" failed: Clk: %llu Error: %d", bitclk, error);
851 return error;
852 }
853 }
854
855 callbacks_->Refresh(id_);
856 validated_ = false;
857
858 return kErrorNone;
859}
860
861DisplayError HWCDisplayBuiltIn::GetDynamicDSIClock(uint64_t *bitclk) {
862 SEQUENCE_WAIT_SCOPE_LOCK(HWCSession::locker_[type_]);
863 if (display_intf_) {
864 return display_intf_->GetDynamicDSIClock(bitclk);
865 }
866
867 return kErrorNotSupported;
868}
869
870DisplayError HWCDisplayBuiltIn::GetSupportedDSIClock(std::vector<uint64_t> *bitclk_rates) {
871 if (display_intf_) {
872 return display_intf_->GetSupportedDSIClock(bitclk_rates);
873 }
874
875 return kErrorNotSupported;
876}
877
Padmanabhan Komandurue74cf4f2019-04-25 17:38:43 -0700878HWC2::Error HWCDisplayBuiltIn::UpdateDisplayId(hwc2_display_t id) {
879 id_ = id;
880 return HWC2::Error::None;
881}
882
883HWC2::Error HWCDisplayBuiltIn::SetPendingRefresh() {
884 pending_refresh_ = true;
885 return HWC2::Error::None;
886}
887
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500888} // namespace sdm