blob: dbac21a59948ac390c546697e6f716ae97ef6110 [file] [log] [blame]
Naseer Ahmedb92e73f2016-03-12 02:03:48 -05001/*
Xu Yang84e61412018-12-06 14:52:16 +08002* 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,
97 sdm_id, true, DISPLAY_CLASS_BUILTIN),
98 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
Naseer Ahmed61f60952017-05-24 16:48:35 -0400125 return status;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500126}
127
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530128void HWCDisplayBuiltIn::ProcessBootAnimCompleted() {
Xu Yang340a3692018-07-10 16:50:52 +0800129 bool bootanim_exit = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500130
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500131 /* All other checks namely "init.svc.bootanim" or
132 * HWC_GEOMETRY_CHANGED fail in correctly identifying the
133 * exact bootup transition to homescreen
134 */
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400135 char property[PROPERTY_VALUE_MAX];
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500136 bool isEncrypted = false;
137 bool main_class_services_started = false;
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400138 property_get("ro.crypto.state", property, "unencrypted");
139 if (!strcmp(property, "encrypted")) {
140 property_get("ro.crypto.type", property, "block");
141 if (!strcmp(property, "block")) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500142 isEncrypted = true;
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400143 property_get("vold.decrypt", property, "");
144 if (!strcmp(property, "trigger_restart_framework")) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500145 main_class_services_started = true;
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400146 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500147 }
148 }
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400149
Xu Yang340a3692018-07-10 16:50:52 +0800150 property_get("service.bootanim.exit", property, "0");
151 if (!strcmp(property, "1")) {
152 bootanim_exit = true;
153 }
154
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500155 if ((!isEncrypted || (isEncrypted && main_class_services_started)) &&
Xu Yang340a3692018-07-10 16:50:52 +0800156 bootanim_exit) {
Xu Yang2a979af2018-05-07 17:10:49 +0800157 DLOGI("Applying default mode for display %d", sdm_id_);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500158 boot_animation_completed_ = true;
159 // Applying default mode after bootanimation is finished And
160 // If Data is Encrypted, it is ready for access.
Ch Ganesh Kumar5d43ff62017-10-13 19:01:47 +0530161 if (display_intf_) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500162 display_intf_->ApplyDefaultDisplayMode();
Ch Ganesh Kumar5d43ff62017-10-13 19:01:47 +0530163 RestoreColorTransform();
164 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500165 }
166}
167
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530168HWC2::Error HWCDisplayBuiltIn::Validate(uint32_t *out_num_types, uint32_t *out_num_requests) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500169 auto status = HWC2::Error::None;
170 DisplayError error = kErrorNone;
171
Ch Ganesh Kumar86c46512017-06-13 13:09:22 +0530172 if (default_mode_status_ && !boot_animation_completed_) {
173 ProcessBootAnimCompleted();
174 }
175
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500176 if (display_paused_) {
177 MarkLayersForGPUBypass();
178 return status;
179 }
180
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700181 if (color_tranform_failed_) {
182 // Must fall back to client composition
183 MarkLayersForClientComposition();
184 }
185
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500186 // Fill in the remaining blanks in the layers and add them to the SDM layerstack
187 BuildLayerStack();
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700188 // Checks and replaces layer stack for solid fill
189 SolidFillPrepare();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500190
Sushil Chauhan8008d602018-09-04 14:43:27 -0700191 // Apply current Color Mode and Render Intent.
Xu Yang84e61412018-12-06 14:52:16 +0800192 if (color_mode_->ApplyCurrentColorModeWithRenderIntent(
193 static_cast<bool>(layer_stack_.flags.hdr_present)) != HWC2::Error::None) {
Sushil Chauhan8008d602018-09-04 14:43:27 -0700194 // Fallback to GPU Composition, if Color Mode can't be applied.
195 MarkLayersForClientComposition();
196 }
197
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500198 bool pending_output_dump = dump_frame_count_ && dump_output_to_file_;
199
Sushil Chauhan06521582018-03-19 14:00:23 -0700200 if (readback_buffer_queued_ || pending_output_dump) {
201 CloseFd(&output_buffer_.release_fence_fd);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500202 // RHS values were set in FrameCaptureAsync() called from a binder thread. They are picked up
Sushil Chauhan06521582018-03-19 14:00:23 -0700203 // here in a subsequent draw round. Readback is not allowed for any secure use case.
204 readback_configured_ = !layer_stack_.flags.secure_present;
205 if (readback_configured_) {
Sushil Chauhanf42d8622018-09-30 23:20:37 -0700206 DisablePartialUpdateOneFrame();
Sushil Chauhan06521582018-03-19 14:00:23 -0700207 layer_stack_.output_buffer = &output_buffer_;
208 layer_stack_.flags.post_processed_output = post_processed_output_;
209 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500210 }
211
Ramakant Singh5db0dfb2017-08-23 12:34:57 +0530212 uint32_t num_updating_layers = GetUpdatingLayersCount();
213 bool one_updating_layer = (num_updating_layers == 1);
214 if (num_updating_layers != 0) {
215 ToggleCPUHint(one_updating_layer);
216 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500217
218 uint32_t refresh_rate = GetOptimalRefreshRate(one_updating_layer);
Anjaneya Prasad Musunuri4d65df72017-05-18 19:11:28 +0530219 bool final_rate = force_refresh_rate_ ? true : false;
220 error = display_intf_->SetRefreshRate(refresh_rate, final_rate);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500221 if (error == kErrorNone) {
222 // On success, set current refresh rate to new refresh rate
223 current_refresh_rate_ = refresh_rate;
224 }
225
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500226 if (layer_set_.empty()) {
Uday Kiran Pichika8d827732018-01-09 18:08:38 +0530227 // Avoid flush for Command mode panel.
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700228 flush_ = !IsDisplayCommandMode();
229 validated_ = true;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500230 return status;
231 }
232
233 status = PrepareLayerStack(out_num_types, out_num_requests);
Namit Solanki5b428dc2018-02-27 11:39:05 +0530234 pending_commit_ = true;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500235 return status;
236}
237
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530238HWC2::Error HWCDisplayBuiltIn::Present(int32_t *out_retire_fence) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500239 auto status = HWC2::Error::None;
240 if (display_paused_) {
Pullakavi Srinivas0a1dba62018-07-02 15:49:11 +0530241 DisplayError error = display_intf_->Flush(&layer_stack_);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700242 validated_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500243 if (error != kErrorNone) {
244 DLOGE("Flush failed. Error = %d", error);
245 }
246 } else {
247 status = HWCDisplay::CommitLayerStack();
248 if (status == HWC2::Error::None) {
249 HandleFrameOutput();
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700250 SolidFillCommit();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500251 status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
252 }
253 }
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700254
Sushil Chauhan06521582018-03-19 14:00:23 -0700255 CloseFd(&output_buffer_.acquire_fence_fd);
Namit Solanki5b428dc2018-02-27 11:39:05 +0530256 pending_commit_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500257 return status;
258}
259
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530260HWC2::Error HWCDisplayBuiltIn::GetColorModes(uint32_t *out_num_modes, ColorMode *out_modes) {
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700261 if (out_modes == nullptr) {
262 *out_num_modes = color_mode_->GetColorModeCount();
263 } else {
264 color_mode_->GetColorModes(out_num_modes, out_modes);
265 }
266
267 return HWC2::Error::None;
268}
269
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530270HWC2::Error HWCDisplayBuiltIn::GetRenderIntents(ColorMode mode, uint32_t *out_num_intents,
Naseer Ahmede7a77982018-06-04 10:56:04 -0400271 RenderIntent *out_intents) {
272 if (out_intents == nullptr) {
273 *out_num_intents = color_mode_->GetRenderIntentCount(mode);
274 } else {
275 color_mode_->GetRenderIntents(mode, out_num_intents, out_intents);
276 }
277 return HWC2::Error::None;
278}
279
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530280HWC2::Error HWCDisplayBuiltIn::SetColorMode(ColorMode mode) {
Naseer Ahmede7a77982018-06-04 10:56:04 -0400281 return SetColorModeWithRenderIntent(mode, RenderIntent::COLORIMETRIC);
282}
283
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530284HWC2::Error HWCDisplayBuiltIn::SetColorModeWithRenderIntent(ColorMode mode, RenderIntent intent) {
Sushil Chauhan8008d602018-09-04 14:43:27 -0700285 auto status = color_mode_->CacheColorModeWithRenderIntent(mode, intent);
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700286 if (status != HWC2::Error::None) {
Naseer Ahmede7a77982018-06-04 10:56:04 -0400287 DLOGE("failed for mode = %d intent = %d", mode, intent);
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700288 return status;
289 }
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700290 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700291 validated_ = false;
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700292 return status;
293}
294
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530295HWC2::Error HWCDisplayBuiltIn::SetColorModeById(int32_t color_mode_id) {
Naseer Ahmed6776dae2017-05-09 11:49:41 -0400296 auto status = color_mode_->SetColorModeById(color_mode_id);
297 if (status != HWC2::Error::None) {
298 DLOGE("failed for mode = %d", color_mode_id);
299 return status;
300 }
301
302 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700303 validated_ = false;
Naseer Ahmed6776dae2017-05-09 11:49:41 -0400304
305 return status;
306}
307
Xu Yang84e61412018-12-06 14:52:16 +0800308HWC2::Error HWCDisplayBuiltIn::SetColorModeFromClientApi(int32_t color_mode_id) {
309 DisplayError error = kErrorNone;
310 std::string mode_string;
311
312 error = display_intf_->GetColorModeName(color_mode_id, &mode_string);
313 if (error) {
314 DLOGE("Failed to get mode name for mode %d", color_mode_id);
315 return HWC2::Error::BadParameter;
316 }
317
318 auto status = color_mode_->SetColorModeFromClientApi(mode_string);
319 if (status != HWC2::Error::None) {
320 DLOGE("Failed to set mode = %d", color_mode_id);
321 return status;
322 }
323
324 return status;
325}
326
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530327HWC2::Error HWCDisplayBuiltIn::RestoreColorTransform() {
Ch Ganesh Kumar5d43ff62017-10-13 19:01:47 +0530328 auto status = color_mode_->RestoreColorTransform();
329 if (status != HWC2::Error::None) {
330 DLOGE("failed to RestoreColorTransform");
331 return status;
332 }
333
334 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
335
336 return status;
337}
338
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530339HWC2::Error HWCDisplayBuiltIn::SetColorTransform(const float *matrix,
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700340 android_color_transform_t hint) {
341 if (!matrix) {
342 return HWC2::Error::BadParameter;
343 }
344
345 auto status = color_mode_->SetColorTransform(matrix, hint);
346 if (status != HWC2::Error::None) {
347 DLOGE("failed for hint = %d", hint);
348 color_tranform_failed_ = true;
349 return status;
350 }
351
352 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
353 color_tranform_failed_ = false;
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700354 validated_ = false;
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700355
356 return status;
357}
358
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530359HWC2::Error HWCDisplayBuiltIn::SetReadbackBuffer(const native_handle_t *buffer,
Sushil Chauhan06521582018-03-19 14:00:23 -0700360 int32_t acquire_fence,
361 bool post_processed_output) {
362 const private_handle_t *handle = reinterpret_cast<const private_handle_t *>(buffer);
363 if (!handle || (handle->fd < 0)) {
364 return HWC2::Error::BadParameter;
365 }
366
367 // Configure the output buffer as Readback buffer
368 output_buffer_.width = UINT32(handle->width);
369 output_buffer_.height = UINT32(handle->height);
370 output_buffer_.unaligned_width = UINT32(handle->unaligned_width);
371 output_buffer_.unaligned_height = UINT32(handle->unaligned_height);
372 output_buffer_.format = HWCLayer::GetSDMFormat(handle->format, handle->flags);
373 output_buffer_.planes[0].fd = handle->fd;
374 output_buffer_.planes[0].stride = UINT32(handle->width);
375 output_buffer_.acquire_fence_fd = dup(acquire_fence);
376 output_buffer_.release_fence_fd = -1;
Sushil Chauhand0dc03d2018-09-19 07:08:40 -0700377 output_buffer_.handle_id = handle->id;
Sushil Chauhan06521582018-03-19 14:00:23 -0700378
379 post_processed_output_ = post_processed_output;
380 readback_buffer_queued_ = true;
381 readback_configured_ = false;
382 validated_ = false;
383
Sushil Chauhan06521582018-03-19 14:00:23 -0700384 return HWC2::Error::None;
385}
386
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530387HWC2::Error HWCDisplayBuiltIn::GetReadbackBufferFence(int32_t *release_fence) {
Sushil Chauhan06521582018-03-19 14:00:23 -0700388 auto status = HWC2::Error::None;
389
390 if (readback_configured_ && (output_buffer_.release_fence_fd >= 0)) {
391 *release_fence = output_buffer_.release_fence_fd;
392 } else {
393 status = HWC2::Error::Unsupported;
394 *release_fence = -1;
395 }
396
397 post_processed_output_ = false;
398 readback_buffer_queued_ = false;
399 readback_configured_ = false;
400 output_buffer_ = {};
401
402 return status;
403}
404
Yuchao Ma577f0f72018-07-09 11:20:00 +0800405HWC2::Error HWCDisplayBuiltIn::SetDisplayDppsAdROI(uint32_t h_start, uint32_t h_end,
406 uint32_t v_start, uint32_t v_end,
407 uint32_t factor_in, uint32_t factor_out) {
408 DisplayError error = kErrorNone;
409 DisplayDppsAd4RoiCfg dpps_ad4_roi_cfg = {};
410 uint32_t panel_width = 0, panel_height = 0;
411 constexpr uint16_t kMaxFactorVal = 0xffff;
412
413 if (h_start >= h_end || v_start >= v_end || factor_in > kMaxFactorVal ||
414 factor_out > kMaxFactorVal) {
415 DLOGE("Invalid roi region = [%u, %u, %u, %u, %u, %u]",
416 h_start, h_end, v_start, v_end, factor_in, factor_out);
417 return HWC2::Error::BadParameter;
418 }
419
420 GetPanelResolution(&panel_width, &panel_height);
421
422 if (h_start >= panel_width || h_end > panel_width ||
423 v_start >= panel_height || v_end > panel_height) {
424 DLOGE("Invalid roi region = [%u, %u, %u, %u], panel resolution = [%u, %u]",
425 h_start, h_end, v_start, v_end, panel_width, panel_height);
426 return HWC2::Error::BadParameter;
427 }
428
429 dpps_ad4_roi_cfg.h_start = h_start;
430 dpps_ad4_roi_cfg.h_end = h_end;
431 dpps_ad4_roi_cfg.v_start = v_start;
432 dpps_ad4_roi_cfg.v_end = v_end;
433 dpps_ad4_roi_cfg.factor_in = factor_in;
434 dpps_ad4_roi_cfg.factor_out = factor_out;
435
436 error = display_intf_->SetDisplayDppsAdROI(&dpps_ad4_roi_cfg);
437 if (error)
438 return HWC2::Error::BadConfig;
439
440 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
441
442 return HWC2::Error::None;
443}
444
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530445int HWCDisplayBuiltIn::Perform(uint32_t operation, ...) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500446 va_list args;
447 va_start(args, operation);
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700448 int val = 0;
Gopikrishnaiah Anandancc123062017-07-31 17:21:03 -0700449 LayerSolidFill *solid_fill_color;
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700450 LayerRect *rect = NULL;
451
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500452 switch (operation) {
453 case SET_METADATA_DYN_REFRESH_RATE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700454 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500455 SetMetaDataRefreshRateFlag(val);
456 break;
457 case SET_BINDER_DYN_REFRESH_RATE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700458 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500459 ForceRefreshRate(UINT32(val));
460 break;
461 case SET_DISPLAY_MODE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700462 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500463 SetDisplayMode(UINT32(val));
464 break;
465 case SET_QDCM_SOLID_FILL_INFO:
Gopikrishnaiah Anandancc123062017-07-31 17:21:03 -0700466 solid_fill_color = va_arg(args, LayerSolidFill*);
467 SetQDCMSolidFillInfo(true, *solid_fill_color);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500468 break;
469 case UNSET_QDCM_SOLID_FILL_INFO:
Gopikrishnaiah Anandancc123062017-07-31 17:21:03 -0700470 solid_fill_color = va_arg(args, LayerSolidFill*);
471 SetQDCMSolidFillInfo(false, *solid_fill_color);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500472 break;
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700473 case SET_QDCM_SOLID_FILL_RECT:
474 rect = va_arg(args, LayerRect*);
475 solid_fill_rect_ = *rect;
476 break;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500477 default:
478 DLOGW("Invalid operation %d", operation);
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700479 va_end(args);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500480 return -EINVAL;
481 }
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700482 va_end(args);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700483 validated_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500484
485 return 0;
486}
487
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530488DisplayError HWCDisplayBuiltIn::SetDisplayMode(uint32_t mode) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500489 DisplayError error = kErrorNone;
490
491 if (display_intf_) {
492 error = display_intf_->SetDisplayMode(mode);
Tharaga Balachandran04192a62018-08-29 16:23:25 -0400493 if (error == kErrorNone) {
494 DisplayConfigFixedInfo fixed_info = {};
495 display_intf_->GetConfig(&fixed_info);
496 is_cmd_mode_ = fixed_info.is_cmdmode;
497 partial_update_enabled_ = fixed_info.partial_update;
498 for (auto hwc_layer : layer_set_) {
499 hwc_layer->SetPartialUpdate(partial_update_enabled_);
500 }
501 client_target_->SetPartialUpdate(partial_update_enabled_);
502 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500503 }
504
505 return error;
506}
507
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530508void HWCDisplayBuiltIn::SetMetaDataRefreshRateFlag(bool enable) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500509 int disable_metadata_dynfps = 0;
510
Uday Kiran Pichika5e656b22018-05-15 18:48:24 +0530511 HWCDebugHandler::Get()->GetProperty(DISABLE_METADATA_DYNAMIC_FPS_PROP, &disable_metadata_dynfps);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500512 if (disable_metadata_dynfps) {
513 return;
514 }
515 use_metadata_refresh_rate_ = enable;
516}
517
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530518void HWCDisplayBuiltIn::SetQDCMSolidFillInfo(bool enable, const LayerSolidFill &color) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500519 solid_fill_enable_ = enable;
520 solid_fill_color_ = color;
521}
522
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530523void HWCDisplayBuiltIn::ToggleCPUHint(bool set) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500524 if (!cpu_hint_) {
525 return;
526 }
527
528 if (set) {
529 cpu_hint_->Set();
530 } else {
531 cpu_hint_->Reset();
532 }
533}
534
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530535int HWCDisplayBuiltIn::HandleSecureSession(const std::bitset<kSecureMax> &secure_sessions,
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700536 bool *power_on_pending) {
537 if (!power_on_pending) {
538 return -EINVAL;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500539 }
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700540
541 if (active_secure_sessions_[kSecureDisplay] != secure_sessions[kSecureDisplay]) {
542 SecureEvent secure_event =
543 secure_sessions.test(kSecureDisplay) ? kSecureDisplayStart : kSecureDisplayEnd;
Pullakavi Srinivas0a1dba62018-07-02 15:49:11 +0530544 DisplayError err = display_intf_->HandleSecureEvent(secure_event, &layer_stack_);
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700545 if (err != kErrorNone) {
546 DLOGE("Set secure event failed");
547 return err;
548 }
549
550 DLOGI("SecureDisplay state changed from %d to %d for display %d",
551 active_secure_sessions_.test(kSecureDisplay), secure_sessions.test(kSecureDisplay),
552 type_);
553 }
554 active_secure_sessions_ = secure_sessions;
555 *power_on_pending = false;
556 return 0;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500557}
558
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530559void HWCDisplayBuiltIn::ForceRefreshRate(uint32_t refresh_rate) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500560 if ((refresh_rate && (refresh_rate < min_refresh_rate_ || refresh_rate > max_refresh_rate_)) ||
561 force_refresh_rate_ == refresh_rate) {
562 // Cannot honor force refresh rate, as its beyond the range or new request is same
563 return;
564 }
565
566 force_refresh_rate_ = refresh_rate;
567
568 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
569
570 return;
571}
572
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530573uint32_t HWCDisplayBuiltIn::GetOptimalRefreshRate(bool one_updating_layer) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500574 if (force_refresh_rate_) {
575 return force_refresh_rate_;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500576 } else if (use_metadata_refresh_rate_ && one_updating_layer && metadata_refresh_rate_) {
577 return metadata_refresh_rate_;
578 }
579
580 return max_refresh_rate_;
581}
582
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530583DisplayError HWCDisplayBuiltIn::Refresh() {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500584 DisplayError error = kErrorNone;
585
586 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500587
588 return error;
589}
590
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530591void HWCDisplayBuiltIn::SetIdleTimeoutMs(uint32_t timeout_ms) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500592 display_intf_->SetIdleTimeoutMs(timeout_ms);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700593 validated_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500594}
595
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530596void HWCDisplayBuiltIn::HandleFrameOutput() {
Sushil Chauhan06521582018-03-19 14:00:23 -0700597 if (readback_buffer_queued_) {
598 validated_ = false;
599 }
600
Sushil Chauhan1d3b90c2018-12-11 16:52:35 -0800601 if (frame_capture_buffer_queued_) {
602 HandleFrameCapture();
603 } else if (dump_output_to_file_) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500604 HandleFrameDump();
605 }
606}
607
Sushil Chauhan1d3b90c2018-12-11 16:52:35 -0800608void HWCDisplayBuiltIn::HandleFrameCapture() {
609 if (readback_configured_ && (output_buffer_.release_fence_fd >= 0)) {
610 frame_capture_status_ = sync_wait(output_buffer_.release_fence_fd, 1000);
611 ::close(output_buffer_.release_fence_fd);
612 output_buffer_.release_fence_fd = -1;
613 }
614
615 frame_capture_buffer_queued_ = false;
616 readback_buffer_queued_ = false;
617 post_processed_output_ = false;
618 readback_configured_ = false;
619 output_buffer_ = {};
620}
621
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530622void HWCDisplayBuiltIn::HandleFrameDump() {
Sushil Chauhan06521582018-03-19 14:00:23 -0700623 if (!readback_configured_) {
624 dump_frame_count_ = 0;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500625 }
626
Sushil Chauhan06521582018-03-19 14:00:23 -0700627 if (dump_frame_count_ && output_buffer_.release_fence_fd >= 0) {
628 int ret = sync_wait(output_buffer_.release_fence_fd, 1000);
629 ::close(output_buffer_.release_fence_fd);
630 output_buffer_.release_fence_fd = -1;
631 if (ret < 0) {
632 DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno));
633 } else {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500634 DumpOutputBuffer(output_buffer_info_, output_buffer_base_, layer_stack_.retire_fence_fd);
Sushil Chauhan06521582018-03-19 14:00:23 -0700635 readback_buffer_queued_ = false;
Sushil Chauhan062a7a42018-04-25 22:27:52 -0700636 validated_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500637 }
638 }
639
640 if (0 == dump_frame_count_) {
641 dump_output_to_file_ = false;
642 // Unmap and Free buffer
643 if (munmap(output_buffer_base_, output_buffer_info_.alloc_buffer_info.size) != 0) {
644 DLOGE("unmap failed with err %d", errno);
645 }
646 if (buffer_allocator_->FreeBuffer(&output_buffer_info_) != 0) {
647 DLOGE("FreeBuffer failed");
648 }
649
Sushil Chauhan06521582018-03-19 14:00:23 -0700650 readback_buffer_queued_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500651 post_processed_output_ = false;
Sushil Chauhan06521582018-03-19 14:00:23 -0700652 readback_configured_ = false;
653
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500654 output_buffer_ = {};
655 output_buffer_info_ = {};
656 output_buffer_base_ = nullptr;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500657 }
658}
659
Sushil Chauhan267a6192018-06-06 18:41:47 -0700660HWC2::Error HWCDisplayBuiltIn::SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type,
661 int32_t format, bool post_processed) {
662 HWCDisplay::SetFrameDumpConfig(count, bit_mask_layer_type, format, post_processed);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500663 dump_output_to_file_ = bit_mask_layer_type & (1 << OUTPUT_LAYER_DUMP);
664 DLOGI("output_layer_dump_enable %d", dump_output_to_file_);
665
Sushil Chauhand0dc03d2018-09-19 07:08:40 -0700666 if (!count || !dump_output_to_file_ || (output_buffer_info_.alloc_buffer_info.fd >= 0)) {
Mathew Joseph Karimpanaldbd64f82017-10-06 10:13:38 +0530667 return HWC2::Error::None;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500668 }
669
670 // Allocate and map output buffer
Sushil Chauhan267a6192018-06-06 18:41:47 -0700671 if (post_processed) {
672 // To dump post-processed (DSPP) output, use Panel resolution.
673 GetPanelResolution(&output_buffer_info_.buffer_config.width,
674 &output_buffer_info_.buffer_config.height);
675 } else {
676 // To dump Layer Mixer output, use FrameBuffer resolution.
677 GetFrameBufferResolution(&output_buffer_info_.buffer_config.width,
678 &output_buffer_info_.buffer_config.height);
679 }
680
681 output_buffer_info_.buffer_config.format = HWCLayer::GetSDMFormat(format, 0);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500682 output_buffer_info_.buffer_config.buffer_count = 1;
683 if (buffer_allocator_->AllocateBuffer(&output_buffer_info_) != 0) {
684 DLOGE("Buffer allocation failed");
685 output_buffer_info_ = {};
Mathew Joseph Karimpanaldbd64f82017-10-06 10:13:38 +0530686 return HWC2::Error::NoResources;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500687 }
688
689 void *buffer = mmap(NULL, output_buffer_info_.alloc_buffer_info.size, PROT_READ | PROT_WRITE,
690 MAP_SHARED, output_buffer_info_.alloc_buffer_info.fd, 0);
691
692 if (buffer == MAP_FAILED) {
693 DLOGE("mmap failed with err %d", errno);
694 buffer_allocator_->FreeBuffer(&output_buffer_info_);
695 output_buffer_info_ = {};
Mathew Joseph Karimpanaldbd64f82017-10-06 10:13:38 +0530696 return HWC2::Error::NoResources;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500697 }
698
699 output_buffer_base_ = buffer;
Sushil Chauhan06521582018-03-19 14:00:23 -0700700 const native_handle_t *handle = static_cast<native_handle_t *>(output_buffer_info_.private_data);
Sushil Chauhan267a6192018-06-06 18:41:47 -0700701 SetReadbackBuffer(handle, -1, post_processed);
Sushil Chauhan06521582018-03-19 14:00:23 -0700702
Mathew Joseph Karimpanaldbd64f82017-10-06 10:13:38 +0530703 return HWC2::Error::None;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500704}
705
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530706int HWCDisplayBuiltIn::FrameCaptureAsync(const BufferInfo &output_buffer_info,
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500707 bool post_processed_output) {
708 // Note: This function is called in context of a binder thread and a lock is already held
709 if (output_buffer_info.alloc_buffer_info.fd < 0) {
710 DLOGE("Invalid fd %d", output_buffer_info.alloc_buffer_info.fd);
711 return -1;
712 }
713
714 auto panel_width = 0u;
715 auto panel_height = 0u;
716 auto fb_width = 0u;
717 auto fb_height = 0u;
718
719 GetPanelResolution(&panel_width, &panel_height);
720 GetFrameBufferResolution(&fb_width, &fb_height);
721
Ch Ganesh Kumar5c4988b2017-06-07 15:21:02 +0530722 if (post_processed_output && (output_buffer_info.buffer_config.width < panel_width ||
723 output_buffer_info.buffer_config.height < panel_height)) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500724 DLOGE("Buffer dimensions should not be less than panel resolution");
725 return -1;
Ch Ganesh Kumar5c4988b2017-06-07 15:21:02 +0530726 } else if (!post_processed_output && (output_buffer_info.buffer_config.width < fb_width ||
727 output_buffer_info.buffer_config.height < fb_height)) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500728 DLOGE("Buffer dimensions should not be less than FB resolution");
729 return -1;
730 }
731
Sushil Chauhan06521582018-03-19 14:00:23 -0700732 const native_handle_t *buffer = static_cast<native_handle_t *>(output_buffer_info.private_data);
733 SetReadbackBuffer(buffer, -1, post_processed_output);
Sushil Chauhan1d3b90c2018-12-11 16:52:35 -0800734 frame_capture_buffer_queued_ = true;
735 frame_capture_status_ = -EAGAIN;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500736
737 return 0;
738}
739
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530740DisplayError HWCDisplayBuiltIn::SetDetailEnhancerConfig
Alan Kwong2e136332016-08-16 07:50:16 -0400741 (const DisplayDetailEnhancerData &de_data) {
742 DisplayError error = kErrorNotSupported;
743
744 if (display_intf_) {
745 error = display_intf_->SetDetailEnhancerData(de_data);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700746 validated_ = false;
Alan Kwong2e136332016-08-16 07:50:16 -0400747 }
748 return error;
749}
750
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530751DisplayError HWCDisplayBuiltIn::ControlPartialUpdate(bool enable, uint32_t *pending) {
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700752 DisplayError error = kErrorNone;
753
754 if (display_intf_) {
755 error = display_intf_->ControlPartialUpdate(enable, pending);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700756 validated_ = false;
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700757 }
758
759 return error;
760}
761
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530762DisplayError HWCDisplayBuiltIn::DisablePartialUpdateOneFrame() {
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700763 DisplayError error = kErrorNone;
764
765 if (display_intf_) {
766 error = display_intf_->DisablePartialUpdateOneFrame();
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700767 validated_ = false;
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700768 }
769
770 return error;
771}
772
773
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530774DisplayError HWCDisplayBuiltIn::SetMixerResolution(uint32_t width, uint32_t height) {
Sushil Chauhan409e8442017-06-12 17:43:25 -0700775 DisplayError error = display_intf_->SetMixerResolution(width, height);
Saurabh Shaha307e8c2017-09-28 18:05:40 -0700776 validated_ = false;
Sushil Chauhan409e8442017-06-12 17:43:25 -0700777 return error;
Arun Kumar K.R8da7f502016-06-07 17:45:50 -0700778}
779
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530780DisplayError HWCDisplayBuiltIn::GetMixerResolution(uint32_t *width, uint32_t *height) {
Arun Kumar K.R8da7f502016-06-07 17:45:50 -0700781 return display_intf_->GetMixerResolution(width, height);
782}
783
Dileep Marchyaf3ce11f2018-04-30 23:35:46 +0530784HWC2::Error HWCDisplayBuiltIn::SetQSyncMode(QSyncMode qsync_mode) {
Sushil Chauhan380a59d2018-03-19 15:47:50 -0700785 auto err = display_intf_->SetQSyncMode(qsync_mode);
786 if (err != kErrorNone) {
787 return HWC2::Error::Unsupported;
788 }
789
790 return HWC2::Error::None;
791}
792
Ramkumar Radhakrishnan4faf8a62018-11-15 17:15:37 -0800793DisplayError HWCDisplayBuiltIn::ControlIdlePowerCollapse(bool enable, bool synchronous) {
Ramkumar Radhakrishnanf985d482018-07-23 18:10:41 -0700794 DisplayError error = kErrorNone;
795
796 if (display_intf_) {
797 error = display_intf_->ControlIdlePowerCollapse(enable, synchronous);
798 validated_ = false;
799 }
Ramkumar Radhakrishnan4faf8a62018-11-15 17:15:37 -0800800 return error;
Ramkumar Radhakrishnanf985d482018-07-23 18:10:41 -0700801}
802
Pullakavi Srinivas9189e602018-12-19 16:58:07 +0530803DisplayError HWCDisplayBuiltIn::SetDynamicDSIClock(uint64_t bitclk) {
804 {
805 SEQUENCE_WAIT_SCOPE_LOCK(HWCSession::locker_[type_]);
806 DisplayError error = display_intf_->SetDynamicDSIClock(bitclk);
807 if (error != kErrorNone) {
808 DLOGE(" failed: Clk: %llu Error: %d", bitclk, error);
809 return error;
810 }
811 }
812
813 callbacks_->Refresh(id_);
814 validated_ = false;
815
816 return kErrorNone;
817}
818
819DisplayError HWCDisplayBuiltIn::GetDynamicDSIClock(uint64_t *bitclk) {
820 SEQUENCE_WAIT_SCOPE_LOCK(HWCSession::locker_[type_]);
821 if (display_intf_) {
822 return display_intf_->GetDynamicDSIClock(bitclk);
823 }
824
825 return kErrorNotSupported;
826}
827
828DisplayError HWCDisplayBuiltIn::GetSupportedDSIClock(std::vector<uint64_t> *bitclk_rates) {
829 if (display_intf_) {
830 return display_intf_->GetSupportedDSIClock(bitclk_rates);
831 }
832
833 return kErrorNotSupported;
834}
835
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500836} // namespace sdm