1 /*
2 * Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *     * Redistributions of source code must retain the above copyright
8 *       notice, this list of conditions and the following disclaimer.
9 *     * Redistributions in binary form must reproduce the above
10 *       copyright notice, this list of conditions and the following
11 *       disclaimer in the documentation and/or other materials provided
12 *       with the distribution.
13 *     * Neither the name of The Linux Foundation nor the names of its
14 *       contributors may be used to endorse or promote products derived
15 *       from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 
30 #include <cutils/properties.h>
31 #include <sync/sync.h>
32 #include <utils/constants.h>
33 #include <utils/debug.h>
34 #include <stdarg.h>
35 #include <sys/mman.h>
36 
37 #include <map>
38 #include <string>
39 #include <vector>
40 
41 #include "hwc_display_primary.h"
42 #include "hwc_debugger.h"
43 
44 #define __CLASS__ "HWCDisplayPrimary"
45 
46 namespace sdm {
47 
Create(CoreInterface * core_intf,BufferAllocator * buffer_allocator,HWCCallbacks * callbacks,qService::QService * qservice,HWCDisplay ** hwc_display)48 int 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 
63   hwc_display_primary->GetMixerResolution(&primary_width, &primary_height);
64   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 
Destroy(HWCDisplay * hwc_display)83 void HWCDisplayPrimary::Destroy(HWCDisplay *hwc_display) {
84   hwc_display->Deinit();
85   delete hwc_display;
86 }
87 
HWCDisplayPrimary(CoreInterface * core_intf,BufferAllocator * buffer_allocator,HWCCallbacks * callbacks,qService::QService * qservice)88 HWCDisplayPrimary::HWCDisplayPrimary(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
89                                      HWCCallbacks *callbacks, qService::QService *qservice)
90     : HWCDisplay(core_intf, callbacks, kPrimary, HWC_DISPLAY_PRIMARY, true, qservice,
91                  DISPLAY_CLASS_PRIMARY, buffer_allocator),
92       buffer_allocator_(buffer_allocator),
93       cpu_hint_(NULL) {
94 }
95 
Init()96 int 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 
110   int status = HWCDisplay::Init();
111   if (status) {
112     return status;
113   }
114   color_mode_ = new HWCColorMode(display_intf_);
115   color_mode_->Init();
116   HWCDebugHandler::Get()->GetProperty("vendor.display.enable_default_color_mode",
117                                       &default_mode_status_);
118 
119   return status;
120 }
121 
ProcessBootAnimCompleted()122 void HWCDisplayPrimary::ProcessBootAnimCompleted() {
123   uint32_t numBootUpLayers = 0;
124   // TODO(user): Remove this hack
125 
126   numBootUpLayers = static_cast<uint32_t>(Debug::GetBootAnimLayerCount());
127 
128   if (numBootUpLayers == 0) {
129     numBootUpLayers = 2;
130   }
131   /* All other checks namely "init.svc.bootanim" or
132   * HWC_GEOMETRY_CHANGED fail in correctly identifying the
133   * exact bootup transition to homescreen
134   */
135   char property[PROPERTY_VALUE_MAX];
136   bool isEncrypted = false;
137   bool main_class_services_started = false;
138   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")) {
142       isEncrypted = true;
143       property_get("vold.decrypt", property, "");
144       if (!strcmp(property, "trigger_restart_framework")) {
145         main_class_services_started = true;
146       }
147     }
148   }
149 
150   if ((!isEncrypted || (isEncrypted && main_class_services_started)) &&
151       (layer_set_.size() > numBootUpLayers)) {
152     DLOGI("Applying default mode");
153     boot_animation_completed_ = true;
154     // Applying default mode after bootanimation is finished And
155     // If Data is Encrypted, it is ready for access.
156     if (display_intf_)
157       display_intf_->ApplyDefaultDisplayMode();
158   }
159 }
160 
Validate(uint32_t * out_num_types,uint32_t * out_num_requests)161 HWC2::Error HWCDisplayPrimary::Validate(uint32_t *out_num_types, uint32_t *out_num_requests) {
162   auto status = HWC2::Error::None;
163   DisplayError error = kErrorNone;
164 
165   if (default_mode_status_ && !boot_animation_completed_) {
166     ProcessBootAnimCompleted();
167   }
168 
169   if (display_paused_) {
170     MarkLayersForGPUBypass();
171     return status;
172   }
173 
174   if (color_tranform_failed_) {
175     // Must fall back to client composition
176     MarkLayersForClientComposition();
177   }
178 
179   // Fill in the remaining blanks in the layers and add them to the SDM layerstack
180   BuildLayerStack();
181   // Checks and replaces layer stack for solid fill
182   SolidFillPrepare();
183 
184   bool pending_output_dump = dump_frame_count_ && dump_output_to_file_;
185 
186   if (frame_capture_buffer_queued_ || pending_output_dump) {
187     // RHS values were set in FrameCaptureAsync() called from a binder thread. They are picked up
188     // here in a subsequent draw round.
189     layer_stack_.output_buffer = &output_buffer_;
190     layer_stack_.flags.post_processed_output = post_processed_output_;
191   }
192 
193   bool one_updating_layer = SingleLayerUpdating();
194   ToggleCPUHint(one_updating_layer);
195 
196   uint32_t refresh_rate = GetOptimalRefreshRate(one_updating_layer);
197   if (current_refresh_rate_ != refresh_rate) {
198     error = display_intf_->SetRefreshRate(refresh_rate);
199   }
200 
201   if (error == kErrorNone) {
202     // On success, set current refresh rate to new refresh rate
203     current_refresh_rate_ = refresh_rate;
204   }
205 
206   if (handle_idle_timeout_) {
207     handle_idle_timeout_ = false;
208   }
209 
210   if (layer_set_.empty()) {
211     flush_ = true;
212     return status;
213   }
214 
215   status = PrepareLayerStack(out_num_types, out_num_requests);
216   return status;
217 }
218 
Present(int32_t * out_retire_fence)219 HWC2::Error HWCDisplayPrimary::Present(int32_t *out_retire_fence) {
220   auto status = HWC2::Error::None;
221   if (display_paused_) {
222     // TODO(user): From old HWC implementation
223     // If we do not handle the frame set retireFenceFd to outbufAcquireFenceFd
224     // Revisit this when validating display_paused
225     DisplayError error = display_intf_->Flush();
226     validated_.reset();
227     if (error != kErrorNone) {
228       DLOGE("Flush failed. Error = %d", error);
229     }
230   } else {
231     status = HWCDisplay::CommitLayerStack();
232     if (status == HWC2::Error::None) {
233       HandleFrameOutput();
234       SolidFillCommit();
235       status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
236     }
237   }
238 
239   CloseAcquireFds();
240   return status;
241 }
242 
GetColorModes(uint32_t * out_num_modes,android_color_mode_t * out_modes)243 HWC2::Error HWCDisplayPrimary::GetColorModes(uint32_t *out_num_modes,
244                                              android_color_mode_t *out_modes) {
245   if (out_modes == nullptr) {
246     *out_num_modes = color_mode_->GetColorModeCount();
247   } else {
248     color_mode_->GetColorModes(out_num_modes, out_modes);
249   }
250 
251   return HWC2::Error::None;
252 }
253 
SetColorMode(android_color_mode_t mode)254 HWC2::Error HWCDisplayPrimary::SetColorMode(android_color_mode_t mode) {
255   auto status = color_mode_->SetColorMode(mode);
256   if (status != HWC2::Error::None) {
257     DLOGE("failed for mode = %d", mode);
258     return status;
259   }
260 
261   callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
262   validated_.reset();
263 
264   return status;
265 }
266 
SetColorTransform(const float * matrix,android_color_transform_t hint)267 HWC2::Error HWCDisplayPrimary::SetColorTransform(const float *matrix,
268                                                  android_color_transform_t hint) {
269   if (!matrix) {
270     return HWC2::Error::BadParameter;
271   }
272 
273   auto status = color_mode_->SetColorTransform(matrix, hint);
274   if (status != HWC2::Error::None) {
275     DLOGE("failed for hint = %d", hint);
276     color_tranform_failed_ = true;
277     return status;
278   }
279 
280   callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
281   color_tranform_failed_ = false;
282   validated_.reset();
283 
284   return status;
285 }
286 
Perform(uint32_t operation,...)287 int HWCDisplayPrimary::Perform(uint32_t operation, ...) {
288   va_list args;
289   va_start(args, operation);
290   int val = 0;
291   LayerRect *rect = NULL;
292 
293   switch (operation) {
294     case SET_METADATA_DYN_REFRESH_RATE:
295       val = va_arg(args, int32_t);
296       SetMetaDataRefreshRateFlag(val);
297       break;
298     case SET_BINDER_DYN_REFRESH_RATE:
299       val = va_arg(args, int32_t);
300       ForceRefreshRate(UINT32(val));
301       break;
302     case SET_DISPLAY_MODE:
303       val = va_arg(args, int32_t);
304       SetDisplayMode(UINT32(val));
305       break;
306     case SET_QDCM_SOLID_FILL_INFO:
307       val = va_arg(args, int32_t);
308       SetQDCMSolidFillInfo(true, UINT32(val));
309       break;
310     case UNSET_QDCM_SOLID_FILL_INFO:
311       val = va_arg(args, int32_t);
312       SetQDCMSolidFillInfo(false, UINT32(val));
313       break;
314     case SET_QDCM_SOLID_FILL_RECT:
315       rect = va_arg(args, LayerRect*);
316       solid_fill_rect_ = *rect;
317       break;
318     default:
319       DLOGW("Invalid operation %d", operation);
320       va_end(args);
321       return -EINVAL;
322   }
323   va_end(args);
324   validated_.reset();
325 
326   return 0;
327 }
328 
SetDisplayMode(uint32_t mode)329 DisplayError HWCDisplayPrimary::SetDisplayMode(uint32_t mode) {
330   DisplayError error = kErrorNone;
331 
332   if (display_intf_) {
333     error = display_intf_->SetDisplayMode(mode);
334   }
335 
336   return error;
337 }
338 
SetMetaDataRefreshRateFlag(bool enable)339 void HWCDisplayPrimary::SetMetaDataRefreshRateFlag(bool enable) {
340   int disable_metadata_dynfps = 0;
341 
342   HWCDebugHandler::Get()->GetProperty("persist.metadata_dynfps.disable", &disable_metadata_dynfps);
343   if (disable_metadata_dynfps) {
344     return;
345   }
346   use_metadata_refresh_rate_ = enable;
347 }
348 
SetQDCMSolidFillInfo(bool enable,uint32_t color)349 void HWCDisplayPrimary::SetQDCMSolidFillInfo(bool enable, uint32_t color) {
350   solid_fill_enable_ = enable;
351   solid_fill_color_ = color;
352 }
353 
ToggleCPUHint(bool set)354 void HWCDisplayPrimary::ToggleCPUHint(bool set) {
355   if (!cpu_hint_) {
356     return;
357   }
358 
359   if (set) {
360     cpu_hint_->Set();
361   } else {
362     cpu_hint_->Reset();
363   }
364 }
365 
SetSecureDisplay(bool secure_display_active)366 void HWCDisplayPrimary::SetSecureDisplay(bool secure_display_active) {
367   if (secure_display_active_ != secure_display_active) {
368     // Skip Prepare and call Flush for null commit
369     DLOGI("SecureDisplay state changed from %d to %d Needs Flush!!", secure_display_active_,
370           secure_display_active);
371     secure_display_active_ = secure_display_active;
372     skip_prepare_ = true;
373   }
374   return;
375 }
376 
ForceRefreshRate(uint32_t refresh_rate)377 void HWCDisplayPrimary::ForceRefreshRate(uint32_t refresh_rate) {
378   if ((refresh_rate && (refresh_rate < min_refresh_rate_ || refresh_rate > max_refresh_rate_)) ||
379       force_refresh_rate_ == refresh_rate) {
380     // Cannot honor force refresh rate, as its beyond the range or new request is same
381     return;
382   }
383 
384   force_refresh_rate_ = refresh_rate;
385 
386   callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
387 
388   return;
389 }
390 
GetOptimalRefreshRate(bool one_updating_layer)391 uint32_t HWCDisplayPrimary::GetOptimalRefreshRate(bool one_updating_layer) {
392   if (force_refresh_rate_) {
393     return force_refresh_rate_;
394   } else if (handle_idle_timeout_) {
395     return min_refresh_rate_;
396   } else if (use_metadata_refresh_rate_ && one_updating_layer && metadata_refresh_rate_) {
397     return metadata_refresh_rate_;
398   }
399 
400   return max_refresh_rate_;
401 }
402 
Refresh()403 DisplayError HWCDisplayPrimary::Refresh() {
404   DisplayError error = kErrorNone;
405 
406   callbacks_->Refresh(HWC_DISPLAY_PRIMARY);
407   handle_idle_timeout_ = true;
408 
409   return error;
410 }
411 
SetIdleTimeoutMs(uint32_t timeout_ms)412 void HWCDisplayPrimary::SetIdleTimeoutMs(uint32_t timeout_ms) {
413   display_intf_->SetIdleTimeoutMs(timeout_ms);
414   validated_.reset();
415 }
416 
SetLayerBuffer(const BufferInfo & output_buffer_info,LayerBuffer * output_buffer)417 static void SetLayerBuffer(const BufferInfo &output_buffer_info, LayerBuffer *output_buffer) {
418   const BufferConfig& buffer_config = output_buffer_info.buffer_config;
419   const AllocatedBufferInfo &alloc_buffer_info = output_buffer_info.alloc_buffer_info;
420 
421   output_buffer->width = alloc_buffer_info.aligned_width;
422   output_buffer->height = alloc_buffer_info.aligned_height;
423   output_buffer->unaligned_width = buffer_config.width;
424   output_buffer->unaligned_height = buffer_config.height;
425   output_buffer->format = buffer_config.format;
426   output_buffer->planes[0].fd = alloc_buffer_info.fd;
427   output_buffer->planes[0].stride = alloc_buffer_info.stride;
428 }
429 
HandleFrameOutput()430 void HWCDisplayPrimary::HandleFrameOutput() {
431   if (frame_capture_buffer_queued_) {
432     HandleFrameCapture();
433   } else if (dump_output_to_file_) {
434     HandleFrameDump();
435   }
436 }
437 
HandleFrameCapture()438 void HWCDisplayPrimary::HandleFrameCapture() {
439   if (output_buffer_.release_fence_fd >= 0) {
440     frame_capture_status_ = sync_wait(output_buffer_.release_fence_fd, 1000);
441     ::close(output_buffer_.release_fence_fd);
442     output_buffer_.release_fence_fd = -1;
443   }
444 
445   frame_capture_buffer_queued_ = false;
446   post_processed_output_ = false;
447   output_buffer_ = {};
448 }
449 
HandleFrameDump()450 void HWCDisplayPrimary::HandleFrameDump() {
451   if (dump_frame_count_ && output_buffer_.release_fence_fd >= 0) {
452     int ret = sync_wait(output_buffer_.release_fence_fd, 1000);
453     ::close(output_buffer_.release_fence_fd);
454     output_buffer_.release_fence_fd = -1;
455     if (ret < 0) {
456       DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno));
457     } else {
458       DumpOutputBuffer(output_buffer_info_, output_buffer_base_, layer_stack_.retire_fence_fd);
459     }
460   }
461 
462   if (0 == dump_frame_count_) {
463     dump_output_to_file_ = false;
464     // Unmap and Free buffer
465     if (munmap(output_buffer_base_, output_buffer_info_.alloc_buffer_info.size) != 0) {
466       DLOGE("unmap failed with err %d", errno);
467     }
468     if (buffer_allocator_->FreeBuffer(&output_buffer_info_) != 0) {
469       DLOGE("FreeBuffer failed");
470     }
471 
472     post_processed_output_ = false;
473     output_buffer_ = {};
474     output_buffer_info_ = {};
475     output_buffer_base_ = nullptr;
476   }
477 }
478 
SetFrameDumpConfig(uint32_t count,uint32_t bit_mask_layer_type)479 void HWCDisplayPrimary::SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type) {
480   HWCDisplay::SetFrameDumpConfig(count, bit_mask_layer_type);
481   dump_output_to_file_ = bit_mask_layer_type & (1 << OUTPUT_LAYER_DUMP);
482   DLOGI("output_layer_dump_enable %d", dump_output_to_file_);
483 
484   if (!count || !dump_output_to_file_) {
485     return;
486   }
487 
488   // Allocate and map output buffer
489   output_buffer_info_ = {};
490   // Since we dump DSPP output use Panel resolution.
491   GetPanelResolution(&output_buffer_info_.buffer_config.width,
492                      &output_buffer_info_.buffer_config.height);
493   output_buffer_info_.buffer_config.format = kFormatRGB888;
494   output_buffer_info_.buffer_config.buffer_count = 1;
495   if (buffer_allocator_->AllocateBuffer(&output_buffer_info_) != 0) {
496     DLOGE("Buffer allocation failed");
497     output_buffer_info_ = {};
498     return;
499   }
500 
501   void *buffer = mmap(NULL, output_buffer_info_.alloc_buffer_info.size, PROT_READ | PROT_WRITE,
502                       MAP_SHARED, output_buffer_info_.alloc_buffer_info.fd, 0);
503 
504   if (buffer == MAP_FAILED) {
505     DLOGE("mmap failed with err %d", errno);
506     buffer_allocator_->FreeBuffer(&output_buffer_info_);
507     output_buffer_info_ = {};
508     return;
509   }
510 
511   output_buffer_base_ = buffer;
512   post_processed_output_ = true;
513   DisablePartialUpdateOneFrame();
514   validated_.reset();
515 }
516 
FrameCaptureAsync(const BufferInfo & output_buffer_info,bool post_processed_output)517 int 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;
548   DisablePartialUpdateOneFrame();
549 
550   return 0;
551 }
552 
SetDetailEnhancerConfig(const DisplayDetailEnhancerData & de_data)553 DisplayError HWCDisplayPrimary::SetDetailEnhancerConfig
554                                    (const DisplayDetailEnhancerData &de_data) {
555   DisplayError error = kErrorNotSupported;
556 
557   if (display_intf_) {
558     error = display_intf_->SetDetailEnhancerData(de_data);
559     validated_.reset();
560   }
561   return error;
562 }
563 
ControlPartialUpdate(bool enable,uint32_t * pending)564 DisplayError HWCDisplayPrimary::ControlPartialUpdate(bool enable, uint32_t *pending) {
565   DisplayError error = kErrorNone;
566 
567   if (display_intf_) {
568     error = display_intf_->ControlPartialUpdate(enable, pending);
569     validated_.reset();
570   }
571 
572   return error;
573 }
574 
DisablePartialUpdateOneFrame()575 DisplayError HWCDisplayPrimary::DisablePartialUpdateOneFrame() {
576   DisplayError error = kErrorNone;
577 
578   if (display_intf_) {
579     error = display_intf_->DisablePartialUpdateOneFrame();
580     validated_.reset();
581   }
582 
583   return error;
584 }
585 
586 
SetMixerResolution(uint32_t width,uint32_t height)587 DisplayError HWCDisplayPrimary::SetMixerResolution(uint32_t width, uint32_t height) {
588   DisplayError error = display_intf_->SetMixerResolution(width, height);
589   validated_.reset();
590   return error;
591 }
592 
GetMixerResolution(uint32_t * width,uint32_t * height)593 DisplayError HWCDisplayPrimary::GetMixerResolution(uint32_t *width, uint32_t *height) {
594   return display_intf_->GetMixerResolution(width, height);
595 }
596 
SetStandByMode(bool enable)597 DisplayError HWCDisplayPrimary::SetStandByMode(bool enable) {
598   if (enable) {
599     if (!display_null_.IsActive()) {
600       stored_display_intf_ = display_intf_;
601       display_intf_ = &display_null_;
602       display_null_.SetActive(true);
603       DLOGD("Null display is connected successfully");
604     } else {
605       DLOGD("Null display is already connected.");
606     }
607   } else {
608     if (display_null_.IsActive()) {
609       display_intf_ = stored_display_intf_;
610       validated_.reset();
611       display_null_.SetActive(false);
612       DLOGD("Display is connected successfully");
613     } else {
614       DLOGD("Display is already connected.");
615     }
616   }
617 
618   return kErrorNone;
619 }
620 
621 }  // namespace sdm
622