blob: d78207b2528b981303400257809d1fbd85ddf1a7 [file] [log] [blame]
Naseer Ahmedb92e73f2016-03-12 02:03:48 -05001/*
Naseer Ahmed61f60952017-05-24 16:48:35 -04002* Copyright (c) 2014 - 2017, 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>
34#include <stdarg.h>
35#include <sys/mman.h>
36
Arun Kumar K.R29cd6582016-05-10 19:12:45 -070037#include <map>
38#include <string>
39#include <vector>
40
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050041#include "hwc_display_primary.h"
42#include "hwc_debugger.h"
43
44#define __CLASS__ "HWCDisplayPrimary"
45
46namespace sdm {
47
48int HWCDisplayPrimary::Create(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
49 HWCCallbacks *callbacks, qService::QService *qservice,
50 HWCDisplay **hwc_display) {
51 int status = 0;
52 uint32_t primary_width = 0;
53 uint32_t primary_height = 0;
54
55 HWCDisplay *hwc_display_primary =
56 new HWCDisplayPrimary(core_intf, buffer_allocator, callbacks, qservice);
57 status = hwc_display_primary->Init();
58 if (status) {
59 delete hwc_display_primary;
60 return status;
61 }
62
Arun Kumar K.R8da7f502016-06-07 17:45:50 -070063 hwc_display_primary->GetMixerResolution(&primary_width, &primary_height);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050064 int width = 0, height = 0;
65 HWCDebugHandler::Get()->GetProperty("sdm.fb_size_width", &width);
66 HWCDebugHandler::Get()->GetProperty("sdm.fb_size_height", &height);
67 if (width > 0 && height > 0) {
68 primary_width = UINT32(width);
69 primary_height = UINT32(height);
70 }
71
72 status = hwc_display_primary->SetFrameBufferResolution(primary_width, primary_height);
73 if (status) {
74 Destroy(hwc_display_primary);
75 return status;
76 }
77
78 *hwc_display = hwc_display_primary;
79
80 return status;
81}
82
83void HWCDisplayPrimary::Destroy(HWCDisplay *hwc_display) {
84 hwc_display->Deinit();
85 delete hwc_display;
86}
87
88HWCDisplayPrimary::HWCDisplayPrimary(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
89 HWCCallbacks *callbacks, qService::QService *qservice)
90 : HWCDisplay(core_intf, callbacks, kPrimary, HWC_DISPLAY_PRIMARY, true, qservice,
Naseer Ahmedd1830402017-03-01 18:38:12 -050091 DISPLAY_CLASS_PRIMARY, buffer_allocator),
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050092 buffer_allocator_(buffer_allocator),
93 cpu_hint_(NULL) {
94}
95
96int HWCDisplayPrimary::Init() {
97 cpu_hint_ = new CPUHint();
98 if (cpu_hint_->Init(static_cast<HWCDebugHandler *>(HWCDebugHandler::Get())) != kErrorNone) {
99 delete cpu_hint_;
100 cpu_hint_ = NULL;
101 }
102
103 use_metadata_refresh_rate_ = true;
104 int disable_metadata_dynfps = 0;
105 HWCDebugHandler::Get()->GetProperty("persist.metadata_dynfps.disable", &disable_metadata_dynfps);
106 if (disable_metadata_dynfps) {
107 use_metadata_refresh_rate_ = false;
108 }
109
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700110 int status = HWCDisplay::Init();
111 if (status) {
112 return status;
113 }
114 color_mode_ = new HWCColorMode(display_intf_);
Naseer Ahmed61f60952017-05-24 16:48:35 -0400115 color_mode_->Init();
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700116
Naseer Ahmed61f60952017-05-24 16:48:35 -0400117 return status;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500118}
119
120void HWCDisplayPrimary::ProcessBootAnimCompleted() {
121 uint32_t numBootUpLayers = 0;
122 // TODO(user): Remove this hack
123
124 numBootUpLayers = static_cast<uint32_t>(Debug::GetBootAnimLayerCount());
125
126 if (numBootUpLayers == 0) {
127 numBootUpLayers = 2;
128 }
129 /* All other checks namely "init.svc.bootanim" or
130 * HWC_GEOMETRY_CHANGED fail in correctly identifying the
131 * exact bootup transition to homescreen
132 */
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400133 char property[PROPERTY_VALUE_MAX];
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500134 bool isEncrypted = false;
135 bool main_class_services_started = false;
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400136 property_get("ro.crypto.state", property, "unencrypted");
137 if (!strcmp(property, "encrypted")) {
138 property_get("ro.crypto.type", property, "block");
139 if (!strcmp(property, "block")) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500140 isEncrypted = true;
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400141 property_get("vold.decrypt", property, "");
142 if (!strcmp(property, "trigger_restart_framework")) {
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500143 main_class_services_started = true;
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400144 }
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500145 }
146 }
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400147
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500148 if ((!isEncrypted || (isEncrypted && main_class_services_started)) &&
149 (layer_set_.size() > numBootUpLayers)) {
Naseer Ahmedac442ae2016-06-23 18:58:03 -0400150 DLOGI("Applying default mode");
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500151 boot_animation_completed_ = true;
152 // Applying default mode after bootanimation is finished And
153 // If Data is Encrypted, it is ready for access.
154 if (display_intf_)
155 display_intf_->ApplyDefaultDisplayMode();
156 }
157}
158
159HWC2::Error HWCDisplayPrimary::Validate(uint32_t *out_num_types, uint32_t *out_num_requests) {
160 auto status = HWC2::Error::None;
161 DisplayError error = kErrorNone;
162
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500163 if (display_paused_) {
164 MarkLayersForGPUBypass();
165 return status;
166 }
167
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700168 if (color_tranform_failed_) {
169 // Must fall back to client composition
170 MarkLayersForClientComposition();
171 }
172
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500173 // Fill in the remaining blanks in the layers and add them to the SDM layerstack
174 BuildLayerStack();
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700175 // Checks and replaces layer stack for solid fill
176 SolidFillPrepare();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500177
178 bool pending_output_dump = dump_frame_count_ && dump_output_to_file_;
179
180 if (frame_capture_buffer_queued_ || pending_output_dump) {
181 // RHS values were set in FrameCaptureAsync() called from a binder thread. They are picked up
182 // here in a subsequent draw round.
183 layer_stack_.output_buffer = &output_buffer_;
184 layer_stack_.flags.post_processed_output = post_processed_output_;
185 }
186
187 bool one_updating_layer = SingleLayerUpdating();
188 ToggleCPUHint(one_updating_layer);
189
190 uint32_t refresh_rate = GetOptimalRefreshRate(one_updating_layer);
191 if (current_refresh_rate_ != refresh_rate) {
192 error = display_intf_->SetRefreshRate(refresh_rate);
193 }
194
195 if (error == kErrorNone) {
196 // On success, set current refresh rate to new refresh rate
197 current_refresh_rate_ = refresh_rate;
198 }
199
200 if (handle_idle_timeout_) {
201 handle_idle_timeout_ = false;
202 }
203
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500204 if (layer_set_.empty()) {
205 flush_ = true;
206 return status;
207 }
208
209 status = PrepareLayerStack(out_num_types, out_num_requests);
210 return status;
211}
212
213HWC2::Error HWCDisplayPrimary::Present(int32_t *out_retire_fence) {
214 auto status = HWC2::Error::None;
215 if (display_paused_) {
216 // TODO(user): From old HWC implementation
217 // If we do not handle the frame set retireFenceFd to outbufAcquireFenceFd
218 // Revisit this when validating display_paused
219 DisplayError error = display_intf_->Flush();
220 if (error != kErrorNone) {
221 DLOGE("Flush failed. Error = %d", error);
222 }
223 } else {
224 status = HWCDisplay::CommitLayerStack();
225 if (status == HWC2::Error::None) {
226 HandleFrameOutput();
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700227 SolidFillCommit();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500228 status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
229 }
230 }
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700231
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500232 CloseAcquireFds();
233 return status;
234}
235
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700236HWC2::Error HWCDisplayPrimary::GetColorModes(uint32_t *out_num_modes,
Naseer Ahmedeae28122016-06-27 15:47:05 -0400237 android_color_mode_t *out_modes) {
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700238 if (out_modes == nullptr) {
239 *out_num_modes = color_mode_->GetColorModeCount();
240 } else {
241 color_mode_->GetColorModes(out_num_modes, out_modes);
242 }
243
244 return HWC2::Error::None;
245}
246
Naseer Ahmedeae28122016-06-27 15:47:05 -0400247HWC2::Error HWCDisplayPrimary::SetColorMode(android_color_mode_t mode) {
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700248 auto status = color_mode_->SetColorMode(mode);
249 if (status != HWC2::Error::None) {
250 DLOGE("failed for mode = %d", mode);
251 return status;
252 }
253
254 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
255
256 return status;
257}
258
Naseer Ahmed6776dae2017-05-09 11:49:41 -0400259HWC2::Error HWCDisplayPrimary::SetColorModeById(int32_t color_mode_id) {
260 auto status = color_mode_->SetColorModeById(color_mode_id);
261 if (status != HWC2::Error::None) {
262 DLOGE("failed for mode = %d", color_mode_id);
263 return status;
264 }
265
266 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
267
268 return status;
269}
270
Arun Kumar K.R29cd6582016-05-10 19:12:45 -0700271HWC2::Error HWCDisplayPrimary::SetColorTransform(const float *matrix,
272 android_color_transform_t hint) {
273 if (!matrix) {
274 return HWC2::Error::BadParameter;
275 }
276
277 auto status = color_mode_->SetColorTransform(matrix, hint);
278 if (status != HWC2::Error::None) {
279 DLOGE("failed for hint = %d", hint);
280 color_tranform_failed_ = true;
281 return status;
282 }
283
284 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
285 color_tranform_failed_ = false;
286
287 return status;
288}
289
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500290int HWCDisplayPrimary::Perform(uint32_t operation, ...) {
291 va_list args;
292 va_start(args, operation);
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700293 int val = 0;
294 LayerRect *rect = NULL;
295
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500296 switch (operation) {
297 case SET_METADATA_DYN_REFRESH_RATE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700298 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500299 SetMetaDataRefreshRateFlag(val);
300 break;
301 case SET_BINDER_DYN_REFRESH_RATE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700302 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500303 ForceRefreshRate(UINT32(val));
304 break;
305 case SET_DISPLAY_MODE:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700306 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500307 SetDisplayMode(UINT32(val));
308 break;
309 case SET_QDCM_SOLID_FILL_INFO:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700310 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500311 SetQDCMSolidFillInfo(true, UINT32(val));
312 break;
313 case UNSET_QDCM_SOLID_FILL_INFO:
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700314 val = va_arg(args, int32_t);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500315 SetQDCMSolidFillInfo(false, UINT32(val));
316 break;
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700317 case SET_QDCM_SOLID_FILL_RECT:
318 rect = va_arg(args, LayerRect*);
319 solid_fill_rect_ = *rect;
320 break;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500321 default:
322 DLOGW("Invalid operation %d", operation);
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700323 va_end(args);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500324 return -EINVAL;
325 }
Arun Kumar K.R536c7d62016-06-14 18:47:39 -0700326 va_end(args);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500327
328 return 0;
329}
330
331DisplayError HWCDisplayPrimary::SetDisplayMode(uint32_t mode) {
332 DisplayError error = kErrorNone;
333
334 if (display_intf_) {
335 error = display_intf_->SetDisplayMode(mode);
336 }
337
338 return error;
339}
340
341void HWCDisplayPrimary::SetMetaDataRefreshRateFlag(bool enable) {
342 int disable_metadata_dynfps = 0;
343
344 HWCDebugHandler::Get()->GetProperty("persist.metadata_dynfps.disable", &disable_metadata_dynfps);
345 if (disable_metadata_dynfps) {
346 return;
347 }
348 use_metadata_refresh_rate_ = enable;
349}
350
351void HWCDisplayPrimary::SetQDCMSolidFillInfo(bool enable, uint32_t color) {
352 solid_fill_enable_ = enable;
353 solid_fill_color_ = color;
354}
355
356void HWCDisplayPrimary::ToggleCPUHint(bool set) {
357 if (!cpu_hint_) {
358 return;
359 }
360
361 if (set) {
362 cpu_hint_->Set();
363 } else {
364 cpu_hint_->Reset();
365 }
366}
367
368void HWCDisplayPrimary::SetSecureDisplay(bool secure_display_active) {
369 if (secure_display_active_ != secure_display_active) {
370 // Skip Prepare and call Flush for null commit
371 DLOGI("SecureDisplay state changed from %d to %d Needs Flush!!", secure_display_active_,
372 secure_display_active);
373 secure_display_active_ = secure_display_active;
374 skip_prepare_ = true;
375 }
376 return;
377}
378
379void HWCDisplayPrimary::ForceRefreshRate(uint32_t refresh_rate) {
380 if ((refresh_rate && (refresh_rate < min_refresh_rate_ || refresh_rate > max_refresh_rate_)) ||
381 force_refresh_rate_ == refresh_rate) {
382 // Cannot honor force refresh rate, as its beyond the range or new request is same
383 return;
384 }
385
386 force_refresh_rate_ = refresh_rate;
387
388 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
389
390 return;
391}
392
393uint32_t HWCDisplayPrimary::GetOptimalRefreshRate(bool one_updating_layer) {
394 if (force_refresh_rate_) {
395 return force_refresh_rate_;
396 } else if (handle_idle_timeout_) {
397 return min_refresh_rate_;
398 } else if (use_metadata_refresh_rate_ && one_updating_layer && metadata_refresh_rate_) {
399 return metadata_refresh_rate_;
400 }
401
402 return max_refresh_rate_;
403}
404
405DisplayError HWCDisplayPrimary::Refresh() {
406 DisplayError error = kErrorNone;
407
408 callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
409 handle_idle_timeout_ = true;
410
411 return error;
412}
413
414void HWCDisplayPrimary::SetIdleTimeoutMs(uint32_t timeout_ms) {
415 display_intf_->SetIdleTimeoutMs(timeout_ms);
416}
417
418static void SetLayerBuffer(const BufferInfo &output_buffer_info, LayerBuffer *output_buffer) {
Ramkumar Radhakrishnanb27735f2016-08-26 22:37:23 -0700419 const BufferConfig& buffer_config = output_buffer_info.buffer_config;
420 const AllocatedBufferInfo &alloc_buffer_info = output_buffer_info.alloc_buffer_info;
421
422 output_buffer->width = alloc_buffer_info.aligned_width;
423 output_buffer->height = alloc_buffer_info.aligned_height;
424 output_buffer->unaligned_width = buffer_config.width;
425 output_buffer->unaligned_height = buffer_config.height;
426 output_buffer->format = buffer_config.format;
427 output_buffer->planes[0].fd = alloc_buffer_info.fd;
428 output_buffer->planes[0].stride = alloc_buffer_info.stride;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500429}
430
431void HWCDisplayPrimary::HandleFrameOutput() {
432 if (frame_capture_buffer_queued_) {
433 HandleFrameCapture();
434 } else if (dump_output_to_file_) {
435 HandleFrameDump();
436 }
437}
438
439void HWCDisplayPrimary::HandleFrameCapture() {
440 if (output_buffer_.release_fence_fd >= 0) {
441 frame_capture_status_ = sync_wait(output_buffer_.release_fence_fd, 1000);
442 ::close(output_buffer_.release_fence_fd);
443 output_buffer_.release_fence_fd = -1;
444 }
445
446 frame_capture_buffer_queued_ = false;
447 post_processed_output_ = false;
448 output_buffer_ = {};
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500449}
450
451void HWCDisplayPrimary::HandleFrameDump() {
452 if (dump_frame_count_ && output_buffer_.release_fence_fd >= 0) {
453 int ret = sync_wait(output_buffer_.release_fence_fd, 1000);
454 ::close(output_buffer_.release_fence_fd);
455 output_buffer_.release_fence_fd = -1;
456 if (ret < 0) {
457 DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno));
458 } else {
459 DumpOutputBuffer(output_buffer_info_, output_buffer_base_, layer_stack_.retire_fence_fd);
460 }
461 }
462
463 if (0 == dump_frame_count_) {
464 dump_output_to_file_ = false;
465 // Unmap and Free buffer
466 if (munmap(output_buffer_base_, output_buffer_info_.alloc_buffer_info.size) != 0) {
467 DLOGE("unmap failed with err %d", errno);
468 }
469 if (buffer_allocator_->FreeBuffer(&output_buffer_info_) != 0) {
470 DLOGE("FreeBuffer failed");
471 }
472
473 post_processed_output_ = false;
474 output_buffer_ = {};
475 output_buffer_info_ = {};
476 output_buffer_base_ = nullptr;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500477 }
478}
479
480void HWCDisplayPrimary::SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type) {
481 HWCDisplay::SetFrameDumpConfig(count, bit_mask_layer_type);
482 dump_output_to_file_ = bit_mask_layer_type & (1 << OUTPUT_LAYER_DUMP);
483 DLOGI("output_layer_dump_enable %d", dump_output_to_file_);
484
485 if (!count || !dump_output_to_file_) {
486 return;
487 }
488
489 // Allocate and map output buffer
490 output_buffer_info_ = {};
491 // Since we dump DSPP output use Panel resolution.
492 GetPanelResolution(&output_buffer_info_.buffer_config.width,
493 &output_buffer_info_.buffer_config.height);
494 output_buffer_info_.buffer_config.format = kFormatRGB888;
495 output_buffer_info_.buffer_config.buffer_count = 1;
496 if (buffer_allocator_->AllocateBuffer(&output_buffer_info_) != 0) {
497 DLOGE("Buffer allocation failed");
498 output_buffer_info_ = {};
499 return;
500 }
501
502 void *buffer = mmap(NULL, output_buffer_info_.alloc_buffer_info.size, PROT_READ | PROT_WRITE,
503 MAP_SHARED, output_buffer_info_.alloc_buffer_info.fd, 0);
504
505 if (buffer == MAP_FAILED) {
506 DLOGE("mmap failed with err %d", errno);
507 buffer_allocator_->FreeBuffer(&output_buffer_info_);
508 output_buffer_info_ = {};
509 return;
510 }
511
512 output_buffer_base_ = buffer;
513 post_processed_output_ = true;
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700514 DisablePartialUpdateOneFrame();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500515}
516
517int HWCDisplayPrimary::FrameCaptureAsync(const BufferInfo &output_buffer_info,
518 bool post_processed_output) {
519 // Note: This function is called in context of a binder thread and a lock is already held
520 if (output_buffer_info.alloc_buffer_info.fd < 0) {
521 DLOGE("Invalid fd %d", output_buffer_info.alloc_buffer_info.fd);
522 return -1;
523 }
524
525 auto panel_width = 0u;
526 auto panel_height = 0u;
527 auto fb_width = 0u;
528 auto fb_height = 0u;
529
530 GetPanelResolution(&panel_width, &panel_height);
531 GetFrameBufferResolution(&fb_width, &fb_height);
532
533 if (post_processed_output && (output_buffer_info_.buffer_config.width < panel_width ||
534 output_buffer_info_.buffer_config.height < panel_height)) {
535 DLOGE("Buffer dimensions should not be less than panel resolution");
536 return -1;
537 } else if (!post_processed_output && (output_buffer_info_.buffer_config.width < fb_width ||
538 output_buffer_info_.buffer_config.height < fb_height)) {
539 DLOGE("Buffer dimensions should not be less than FB resolution");
540 return -1;
541 }
542
543 SetLayerBuffer(output_buffer_info, &output_buffer_);
544 post_processed_output_ = post_processed_output;
545 frame_capture_buffer_queued_ = true;
546 // Status is only cleared on a new call to dump and remains valid otherwise
547 frame_capture_status_ = -EAGAIN;
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700548 DisablePartialUpdateOneFrame();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500549
550 return 0;
551}
552
Alan Kwong2e136332016-08-16 07:50:16 -0400553DisplayError HWCDisplayPrimary::SetDetailEnhancerConfig
554 (const DisplayDetailEnhancerData &de_data) {
555 DisplayError error = kErrorNotSupported;
556
557 if (display_intf_) {
558 error = display_intf_->SetDetailEnhancerData(de_data);
559 }
560 return error;
561}
562
Arun Kumar K.R17bbd042016-06-07 17:38:02 -0700563DisplayError HWCDisplayPrimary::ControlPartialUpdate(bool enable, uint32_t *pending) {
564 DisplayError error = kErrorNone;
565
566 if (display_intf_) {
567 error = display_intf_->ControlPartialUpdate(enable, pending);
568 }
569
570 return error;
571}
572
573DisplayError HWCDisplayPrimary::DisablePartialUpdateOneFrame() {
574 DisplayError error = kErrorNone;
575
576 if (display_intf_) {
577 error = display_intf_->DisablePartialUpdateOneFrame();
578 }
579
580 return error;
581}
582
583
Arun Kumar K.R8da7f502016-06-07 17:45:50 -0700584DisplayError HWCDisplayPrimary::SetMixerResolution(uint32_t width, uint32_t height) {
585 return display_intf_->SetMixerResolution(width, height);
586}
587
588DisplayError HWCDisplayPrimary::GetMixerResolution(uint32_t *width, uint32_t *height) {
589 return display_intf_->GetMixerResolution(width, height);
590}
591
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500592} // namespace sdm