1 /*
2 * Copyright (c) 2018-2019, 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 "hwc_display_dummy.h"
31 #include "utils/debug.h"
32 
33 #define __CLASS__ "HWCDisplayDummy"
34 
35 namespace sdm {
36 
Create(CoreInterface * core_intf,BufferAllocator * buffer_allocator,HWCCallbacks * callbacks,HWCDisplayEventHandler * event_handler,qService::QService * qservice,hwc2_display_t id,int32_t sdm_id,HWCDisplay ** hwc_display)37 int HWCDisplayDummy::Create(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
38                             HWCCallbacks *callbacks, HWCDisplayEventHandler *event_handler,
39                             qService::QService *qservice, hwc2_display_t id, int32_t sdm_id,
40                             HWCDisplay **hwc_display) {
41   HWCDisplay *hwc_display_dummy = new HWCDisplayDummy(core_intf, buffer_allocator, callbacks,
42                                       event_handler, qservice, id, sdm_id);
43   *hwc_display = hwc_display_dummy;
44   return kErrorNone;
45 }
46 
Destroy(HWCDisplay * hwc_display)47 void HWCDisplayDummy::Destroy(HWCDisplay *hwc_display) {
48   delete hwc_display;
49 }
50 
Validate(uint32_t * out_num_types,uint32_t * out_num_requests)51 HWC2::Error HWCDisplayDummy::Validate(uint32_t *out_num_types, uint32_t *out_num_requests) {
52   return HWC2::Error::None;
53 }
54 
Present(int32_t * out_retire_fence)55 HWC2::Error HWCDisplayDummy::Present(int32_t *out_retire_fence) {
56   for (auto hwc_layer : layer_set_) {
57     hwc_layer->PushBackReleaseFence(-1);
58   }
59   return HWC2::Error::None;
60 }
61 
HWCDisplayDummy(CoreInterface * core_intf,BufferAllocator * buffer_allocator,HWCCallbacks * callbacks,HWCDisplayEventHandler * event_handler,qService::QService * qservice,hwc2_display_t id,int32_t sdm_id)62 HWCDisplayDummy::HWCDisplayDummy(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
63                                  HWCCallbacks *callbacks, HWCDisplayEventHandler *event_handler,
64                                  qService::QService *qservice, hwc2_display_t id,
65                                  int32_t sdm_id) :HWCDisplay(core_intf, buffer_allocator,
66                                  callbacks, event_handler, qservice, kBuiltIn, id, sdm_id, true,
67                                  DISPLAY_CLASS_BUILTIN) {
68   DisplayConfigVariableInfo config;
69   config.x_pixels = 720;
70   config.y_pixels = 1280;
71   config.x_dpi = 200.0f;
72   config.y_dpi = 200.0f;
73   config.fps = 60;
74   config.vsync_period_ns = 16600000;
75   display_null_.SetFrameBufferConfig(config);
76   num_configs_ = 1;
77   display_intf_ = &display_null_;
78 }
79 
GetActiveConfig(hwc2_config_t * out_config)80 HWC2::Error HWCDisplayDummy::GetActiveConfig(hwc2_config_t *out_config) {
81   *out_config = 0;
82   return HWC2::Error::None;
83 }
84 
85 }  // namespace sdm
86