blob: b78d15e2f255abe015b579d4bb30fa6690ca3a29 [file] [log] [blame]
Jaesoo Lee812e85e2017-04-28 18:29:40 +09001/*
Jaesoo Lee712ee822017-04-28 18:29:40 +09002 * Copyright (C) 2018 The Android Open Source Project
Jaesoo Lee812e85e2017-04-28 18:29:40 +09003 *
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 */
Jiyong Park200825e2017-01-14 19:40:33 +090016
Jaesoo Lee812e85e2017-04-28 18:29:40 +090017#include "SurfaceFlingerConfigs.h"
Jiyong Park200825e2017-01-14 19:40:33 +090018
Jaesoo Lee712ee822017-04-28 18:29:40 +090019#include <android/hardware/configstore/1.1/types.h>
Peiyong Linbfbaf842018-08-31 14:13:36 -070020#include <android/hardware/graphics/common/1.1/types.h>
Jaesoo Lee712ee822017-04-28 18:29:40 +090021#include <log/log.h>
22
Jiyong Park200825e2017-01-14 19:40:33 +090023namespace android {
24namespace hardware {
25namespace configstore {
Peiyong Lin2b3f8262018-07-20 16:03:46 -070026namespace V1_2 {
Jiyong Park200825e2017-01-14 19:40:33 +090027namespace implementation {
28
Peiyong Linbfbaf842018-08-31 14:13:36 -070029using ::android::hardware::graphics::common::V1_1::PixelFormat;
Valerie Hauec983062018-10-09 16:09:12 -070030using ::android::hardware::graphics::common::V1_2::Dataspace;
Peiyong Linbfbaf842018-08-31 14:13:36 -070031
Peiyong Lin2b3f8262018-07-20 16:03:46 -070032// ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs implementation.
Jiyong Park200825e2017-01-14 19:40:33 +090033Return<void> SurfaceFlingerConfigs::vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
34#ifdef VSYNC_EVENT_PHASE_OFFSET_NS
35 _hidl_cb({true, VSYNC_EVENT_PHASE_OFFSET_NS});
Jiyong Park200825e2017-01-14 19:40:33 +090036#else
37 _hidl_cb({false, 0});
38#endif
39 return Void();
40}
41
Fabien Sanglardeebc9252017-03-06 11:46:36 -080042Return<void> SurfaceFlingerConfigs::vsyncSfEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
43#ifdef SF_VSYNC_EVENT_PHASE_OFFSET_NS
44 _hidl_cb({true, SF_VSYNC_EVENT_PHASE_OFFSET_NS});
Fabien Sanglardeebc9252017-03-06 11:46:36 -080045#else
46 _hidl_cb({false, 0});
47#endif
48 return Void();
49}
50
Fabien Sanglardcbece282017-03-13 13:03:04 -070051Return<void> SurfaceFlingerConfigs::useContextPriority(useContextPriority_cb _hidl_cb) {
52#ifdef USE_CONTEXT_PRIORITY
53 _hidl_cb({true, USE_CONTEXT_PRIORITY});
Fabien Sanglardcbece282017-03-13 13:03:04 -070054#else
55 _hidl_cb({false, false});
56#endif
57 return Void();
58}
59
Jaesoo Lee812e85e2017-04-28 18:29:40 +090060Return<void> SurfaceFlingerConfigs::maxFrameBufferAcquiredBuffers(
61 maxFrameBufferAcquiredBuffers_cb _hidl_cb) {
Fabien Sanglard3d9f5ad2017-03-10 15:37:07 -080062#ifdef NUM_FRAMEBUFFER_SURFACE_BUFFERS
63 _hidl_cb({true, NUM_FRAMEBUFFER_SURFACE_BUFFERS});
Fabien Sanglard3d9f5ad2017-03-10 15:37:07 -080064#else
65 _hidl_cb({false, 0});
66#endif
67 return Void();
68}
69
Courtney Goeltzenleuchter3670b442017-03-09 09:04:29 -070070Return<void> SurfaceFlingerConfigs::hasWideColorDisplay(hasWideColorDisplay_cb _hidl_cb) {
71 bool value = false;
72#ifdef HAS_WIDE_COLOR_DISPLAY
73 value = true;
74#endif
75 _hidl_cb({true, value});
Courtney Goeltzenleuchter3670b442017-03-09 09:04:29 -070076 return Void();
77}
78
Fabien Sanglardbf4da3d2017-03-10 17:15:43 -080079Return<void> SurfaceFlingerConfigs::hasSyncFramework(hasSyncFramework_cb _hidl_cb) {
80 bool value = true;
81#ifdef RUNNING_WITHOUT_SYNC_FRAMEWORK
82 value = false;
83#endif
84 _hidl_cb({true, value});
Fabien Sanglardbf4da3d2017-03-10 17:15:43 -080085 return Void();
86}
87
Courtney Goeltzenleuchter3670b442017-03-09 09:04:29 -070088Return<void> SurfaceFlingerConfigs::hasHDRDisplay(hasHDRDisplay_cb _hidl_cb) {
89 bool value = false;
90#ifdef HAS_HDR_DISPLAY
91 value = true;
92#endif
93 _hidl_cb({true, value});
Courtney Goeltzenleuchter3670b442017-03-09 09:04:29 -070094 return Void();
95}
96
Jaesoo Lee812e85e2017-04-28 18:29:40 +090097Return<void> SurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs(
98 presentTimeOffsetFromVSyncNs_cb _hidl_cb) {
Fabien Sanglard8d7e31e2017-03-14 13:16:30 -070099#ifdef PRESENT_TIME_OFFSET_FROM_VSYNC_NS
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900100 _hidl_cb({true, PRESENT_TIME_OFFSET_FROM_VSYNC_NS});
Fabien Sanglard8d7e31e2017-03-14 13:16:30 -0700101#else
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900102 _hidl_cb({false, 0});
Fabien Sanglard8d7e31e2017-03-14 13:16:30 -0700103#endif
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900104 return Void();
Fabien Sanglard8d7e31e2017-03-14 13:16:30 -0700105}
106
Fabien Sanglard38295e72017-03-14 11:43:18 -0700107Return<void> SurfaceFlingerConfigs::useHwcForRGBtoYUV(useHwcForRGBtoYUV_cb _hidl_cb) {
108 bool value = false;
109#ifdef FORCE_HWC_COPY_FOR_VIRTUAL_DISPLAYS
110 value = true;
111#endif
112 _hidl_cb({true, value});
Fabien Sanglard38295e72017-03-14 11:43:18 -0700113 return Void();
114}
Jiyong Park200825e2017-01-14 19:40:33 +0900115
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800116Return<void> SurfaceFlingerConfigs::maxVirtualDisplaySize(maxVirtualDisplaySize_cb _hidl_cb) {
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900117 uint64_t maxSize = 0;
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800118#ifdef MAX_VIRTUAL_DISPLAY_DIMENSION
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900119 maxSize = MAX_VIRTUAL_DISPLAY_DIMENSION;
120 _hidl_cb({true, maxSize});
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800121#else
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900122 _hidl_cb({false, maxSize});
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800123#endif
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900124 return Void();
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800125}
126
Steven Thomascb4172a2017-03-13 17:42:18 -0700127Return<void> SurfaceFlingerConfigs::useVrFlinger(useVrFlinger_cb _hidl_cb) {
128 bool value = false;
129 bool specified = false;
130#ifdef USE_VR_FLINGER
131 value = true;
132 specified = true;
133#endif
134 _hidl_cb({specified, value});
Steven Thomascb4172a2017-03-13 17:42:18 -0700135 return Void();
136}
137
Chia-I Wu12246402017-04-11 15:17:24 -0700138Return<void> SurfaceFlingerConfigs::startGraphicsAllocatorService(
139 startGraphicsAllocatorService_cb _hidl_cb) {
140 bool value = false;
141#ifdef START_GRAPHICS_ALLOCATOR_SERVICE
142 value = true;
143#endif
144 _hidl_cb({true, value});
145 return Void();
146}
147
Peiyong Lin2b3f8262018-07-20 16:03:46 -0700148// ::android::hardware::configstore::V1_1::ISurfaceFlingerConfigs implementation.
Jaesoo Lee712ee822017-04-28 18:29:40 +0900149
150#ifdef PRIMARY_DISPLAY_ORIENTATION
151static_assert(PRIMARY_DISPLAY_ORIENTATION == 0 || PRIMARY_DISPLAY_ORIENTATION == 90 ||
152 PRIMARY_DISPLAY_ORIENTATION == 180 || PRIMARY_DISPLAY_ORIENTATION == 270,
153 "Primary display orientation must be 0/90/180/270");
154#endif
155
156Return<void> SurfaceFlingerConfigs::primaryDisplayOrientation(
157 primaryDisplayOrientation_cb _hidl_cb) {
158 using ::android::hardware::configstore::V1_1::DisplayOrientation;
159
160 bool specified = false;
161 DisplayOrientation value = DisplayOrientation::ORIENTATION_0;
162
163 int orientation = 0;
164#ifdef PRIMARY_DISPLAY_ORIENTATION
165 specified = true;
166 orientation = PRIMARY_DISPLAY_ORIENTATION;
167#endif
168
169 switch (orientation) {
170 case 0: {
171 value = DisplayOrientation::ORIENTATION_0;
172 break;
173 }
174 case 90: {
175 value = DisplayOrientation::ORIENTATION_90;
176 break;
177 }
178 case 180: {
179 value = DisplayOrientation::ORIENTATION_180;
180 break;
181 }
182 case 270: {
183 value = DisplayOrientation::ORIENTATION_270;
184 break;
185 }
186 default: {
187 // statically checked above -> memory corruption
188 LOG_ALWAYS_FATAL("Invalid orientation %d", orientation);
189 }
190 }
191
192 _hidl_cb({specified, value});
193 return Void();
194}
195
Peiyong Lin2b3f8262018-07-20 16:03:46 -0700196// ::android::hardware::configstore::V1_2::ISurfaceFlingerConfigs implementation.
197Return<void> SurfaceFlingerConfigs::useColorManagement(useColorManagement_cb _hidl_cb) {
198#if defined(USE_COLOR_MANAGEMENT) || defined(HAS_WIDE_COLOR_DISPLAY) || defined(HAS_HDR_DISPLAY)
199 _hidl_cb({true, true});
200#else
201 _hidl_cb({true, false});
202#endif
203 return Void();
204}
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900205
Peiyong Linbfbaf842018-08-31 14:13:36 -0700206#ifdef COMPOSITION_DATA_SPACE
207static_assert(COMPOSITION_DATA_SPACE != 0, "Expected composition data space must not be UNKNOWN");
208#endif
209
210Return<void> SurfaceFlingerConfigs::getCompositionPreference(getCompositionPreference_cb _hidl_cb) {
211 Dataspace dataSpace = Dataspace::V0_SRGB;
212 PixelFormat pixelFormat = PixelFormat::RGBA_8888;
213
214#ifdef COMPOSITION_DATA_SPACE
215 dataSpace = static_cast<Dataspace>(COMPOSITION_DATA_SPACE);
216#endif
217
218#ifdef COMPOSITION_PIXEL_FORMAT
219 pixelFormat = static_cast<PixelFormat>(COMPOSITION_PIXEL_FORMAT);
220#endif
221 _hidl_cb(dataSpace, pixelFormat);
222 return Void();
223}
224
Jiyong Park200825e2017-01-14 19:40:33 +0900225} // namespace implementation
Peiyong Lin2b3f8262018-07-20 16:03:46 -0700226} // namespace V1_2
Jiyong Park200825e2017-01-14 19:40:33 +0900227} // namespace configstore
228} // namespace hardware
229} // namespace android