blob: 377e467864c95830265c0c7ee3a5e0573829ff8f [file] [log] [blame]
Sundong Ahne64a2282019-02-22 11:52:42 +09001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.1
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "SurfaceFlingerConfigs.h"
18
19#include <android/hardware/configstore/1.1/types.h>
20#include <log/log.h>
21
22namespace android {
23namespace hardware {
24namespace configstore {
25namespace V1_1 {
26namespace implementation {
27
28// ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs implementation.
29Return<void> SurfaceFlingerConfigs::vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
30#ifdef VSYNC_EVENT_PHASE_OFFSET_NS
31 _hidl_cb({true, VSYNC_EVENT_PHASE_OFFSET_NS});
32#else
33 _hidl_cb({false, 0});
34#endif
35 return Void();
36}
37
38Return<void> SurfaceFlingerConfigs::vsyncSfEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
39#ifdef SF_VSYNC_EVENT_PHASE_OFFSET_NS
40 _hidl_cb({true, SF_VSYNC_EVENT_PHASE_OFFSET_NS});
41#else
42 _hidl_cb({false, 0});
43#endif
44 return Void();
45}
46
47Return<void> SurfaceFlingerConfigs::useContextPriority(useContextPriority_cb _hidl_cb) {
48#ifdef USE_CONTEXT_PRIORITY
49 _hidl_cb({true, USE_CONTEXT_PRIORITY});
50#else
51 _hidl_cb({false, false});
52#endif
53 return Void();
54}
55
56Return<void> SurfaceFlingerConfigs::maxFrameBufferAcquiredBuffers(
57 maxFrameBufferAcquiredBuffers_cb _hidl_cb) {
58#ifdef NUM_FRAMEBUFFER_SURFACE_BUFFERS
59 _hidl_cb({true, NUM_FRAMEBUFFER_SURFACE_BUFFERS});
60#else
61 _hidl_cb({false, 0});
62#endif
63 return Void();
64}
65
66Return<void> SurfaceFlingerConfigs::hasWideColorDisplay(hasWideColorDisplay_cb _hidl_cb) {
67 bool value = false;
68#ifdef HAS_WIDE_COLOR_DISPLAY
69 value = true;
70#endif
71 _hidl_cb({true, value});
72 return Void();
73}
74
75Return<void> SurfaceFlingerConfigs::hasSyncFramework(hasSyncFramework_cb _hidl_cb) {
76 bool value = true;
77#ifdef RUNNING_WITHOUT_SYNC_FRAMEWORK
78 value = false;
79#endif
80 _hidl_cb({true, value});
81 return Void();
82}
83
84Return<void> SurfaceFlingerConfigs::hasHDRDisplay(hasHDRDisplay_cb _hidl_cb) {
85 bool value = false;
86#ifdef HAS_HDR_DISPLAY
87 value = true;
88#endif
89 _hidl_cb({true, value});
90 return Void();
91}
92
93Return<void> SurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs(
94 presentTimeOffsetFromVSyncNs_cb _hidl_cb) {
95#ifdef PRESENT_TIME_OFFSET_FROM_VSYNC_NS
96 _hidl_cb({true, PRESENT_TIME_OFFSET_FROM_VSYNC_NS});
97#else
98 _hidl_cb({false, 0});
99#endif
100 return Void();
101}
102
103Return<void> SurfaceFlingerConfigs::useHwcForRGBtoYUV(useHwcForRGBtoYUV_cb _hidl_cb) {
104 bool value = false;
105#ifdef FORCE_HWC_COPY_FOR_VIRTUAL_DISPLAYS
106 value = true;
107#endif
108 _hidl_cb({true, value});
109 return Void();
110}
111
112Return<void> SurfaceFlingerConfigs::maxVirtualDisplaySize(maxVirtualDisplaySize_cb _hidl_cb) {
113 uint64_t maxSize = 0;
114#ifdef MAX_VIRTUAL_DISPLAY_DIMENSION
115 maxSize = MAX_VIRTUAL_DISPLAY_DIMENSION;
116 _hidl_cb({true, maxSize});
117#else
118 _hidl_cb({false, maxSize});
119#endif
120 return Void();
121}
122
123Return<void> SurfaceFlingerConfigs::useVrFlinger(useVrFlinger_cb _hidl_cb) {
124 bool value = false;
125 bool specified = false;
126#ifdef USE_VR_FLINGER
127 value = true;
128 specified = true;
129#endif
130 _hidl_cb({specified, value});
131 return Void();
132}
133
134Return<void> SurfaceFlingerConfigs::startGraphicsAllocatorService(
135 startGraphicsAllocatorService_cb _hidl_cb) {
136 bool value = false;
137#ifdef START_GRAPHICS_ALLOCATOR_SERVICE
138 value = true;
139#endif
140 _hidl_cb({true, value});
141 return Void();
142}
143
144// ::android::hardware::configstore::V1_1::ISurfaceFlingerConfigs implementation.
145
146#ifdef PRIMARY_DISPLAY_ORIENTATION
147static_assert(PRIMARY_DISPLAY_ORIENTATION == 0 || PRIMARY_DISPLAY_ORIENTATION == 90 ||
148 PRIMARY_DISPLAY_ORIENTATION == 180 || PRIMARY_DISPLAY_ORIENTATION == 270,
149 "Primary display orientation must be 0/90/180/270");
150#endif
151
152Return<void> SurfaceFlingerConfigs::primaryDisplayOrientation(
153 primaryDisplayOrientation_cb _hidl_cb) {
154 using ::android::hardware::configstore::V1_1::DisplayOrientation;
155
156 bool specified = false;
157 DisplayOrientation value = DisplayOrientation::ORIENTATION_0;
158
159 int orientation = 0;
160#ifdef PRIMARY_DISPLAY_ORIENTATION
161 specified = true;
162 orientation = PRIMARY_DISPLAY_ORIENTATION;
163#endif
164
165 switch (orientation) {
166 case 0: {
167 value = DisplayOrientation::ORIENTATION_0;
168 break;
169 }
170 case 90: {
171 value = DisplayOrientation::ORIENTATION_90;
172 break;
173 }
174 case 180: {
175 value = DisplayOrientation::ORIENTATION_180;
176 break;
177 }
178 case 270: {
179 value = DisplayOrientation::ORIENTATION_270;
180 break;
181 }
182 default: {
183 // statically checked above -> memory corruption
184 LOG_ALWAYS_FATAL("Invalid orientation %d", orientation);
185 }
186 }
187
188 _hidl_cb({specified, value});
189 return Void();
190}
191
192} // namespace implementation
193} // namespace V1_1
194} // namespace configstore
195} // namespace hardware
196} // namespace android