blob: 714442bd2288fb136a722754e358b1c893cd293f [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>
linpeter5a12cd72018-11-22 20:41:52 +080020#include <android/hardware/configstore/1.2/types.h>
Peiyong Linbfbaf842018-08-31 14:13:36 -070021#include <android/hardware/graphics/common/1.1/types.h>
Jaesoo Lee712ee822017-04-28 18:29:40 +090022#include <log/log.h>
23
Jiyong Park200825e2017-01-14 19:40:33 +090024namespace android {
25namespace hardware {
26namespace configstore {
Peiyong Lin2b3f8262018-07-20 16:03:46 -070027namespace V1_2 {
Jiyong Park200825e2017-01-14 19:40:33 +090028namespace implementation {
29
Valerie Hauec983062018-10-09 16:09:12 -070030using ::android::hardware::graphics::common::V1_2::Dataspace;
Kevin DuBois97e1a932019-01-22 10:22:37 -080031using ::android::hardware::graphics::common::V1_2::PixelFormat;
Peiyong Linbfbaf842018-08-31 14:13:36 -070032
Peiyong Lin2b3f8262018-07-20 16:03:46 -070033// ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs implementation.
Jiyong Park200825e2017-01-14 19:40:33 +090034Return<void> SurfaceFlingerConfigs::vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
35#ifdef VSYNC_EVENT_PHASE_OFFSET_NS
36 _hidl_cb({true, VSYNC_EVENT_PHASE_OFFSET_NS});
Jiyong Park200825e2017-01-14 19:40:33 +090037#else
38 _hidl_cb({false, 0});
39#endif
40 return Void();
41}
42
Fabien Sanglardeebc9252017-03-06 11:46:36 -080043Return<void> SurfaceFlingerConfigs::vsyncSfEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
44#ifdef SF_VSYNC_EVENT_PHASE_OFFSET_NS
45 _hidl_cb({true, SF_VSYNC_EVENT_PHASE_OFFSET_NS});
Fabien Sanglardeebc9252017-03-06 11:46:36 -080046#else
47 _hidl_cb({false, 0});
48#endif
49 return Void();
50}
51
Fabien Sanglardcbece282017-03-13 13:03:04 -070052Return<void> SurfaceFlingerConfigs::useContextPriority(useContextPriority_cb _hidl_cb) {
53#ifdef USE_CONTEXT_PRIORITY
54 _hidl_cb({true, USE_CONTEXT_PRIORITY});
Fabien Sanglardcbece282017-03-13 13:03:04 -070055#else
56 _hidl_cb({false, false});
57#endif
58 return Void();
59}
60
Jaesoo Lee812e85e2017-04-28 18:29:40 +090061Return<void> SurfaceFlingerConfigs::maxFrameBufferAcquiredBuffers(
62 maxFrameBufferAcquiredBuffers_cb _hidl_cb) {
Fabien Sanglard3d9f5ad2017-03-10 15:37:07 -080063#ifdef NUM_FRAMEBUFFER_SURFACE_BUFFERS
64 _hidl_cb({true, NUM_FRAMEBUFFER_SURFACE_BUFFERS});
Fabien Sanglard3d9f5ad2017-03-10 15:37:07 -080065#else
66 _hidl_cb({false, 0});
67#endif
68 return Void();
69}
70
Courtney Goeltzenleuchter3670b442017-03-09 09:04:29 -070071Return<void> SurfaceFlingerConfigs::hasWideColorDisplay(hasWideColorDisplay_cb _hidl_cb) {
72 bool value = false;
73#ifdef HAS_WIDE_COLOR_DISPLAY
74 value = true;
75#endif
76 _hidl_cb({true, value});
Courtney Goeltzenleuchter3670b442017-03-09 09:04:29 -070077 return Void();
78}
79
Fabien Sanglardbf4da3d2017-03-10 17:15:43 -080080Return<void> SurfaceFlingerConfigs::hasSyncFramework(hasSyncFramework_cb _hidl_cb) {
81 bool value = true;
82#ifdef RUNNING_WITHOUT_SYNC_FRAMEWORK
83 value = false;
84#endif
85 _hidl_cb({true, value});
Fabien Sanglardbf4da3d2017-03-10 17:15:43 -080086 return Void();
87}
88
Courtney Goeltzenleuchter3670b442017-03-09 09:04:29 -070089Return<void> SurfaceFlingerConfigs::hasHDRDisplay(hasHDRDisplay_cb _hidl_cb) {
90 bool value = false;
91#ifdef HAS_HDR_DISPLAY
92 value = true;
93#endif
94 _hidl_cb({true, value});
Courtney Goeltzenleuchter3670b442017-03-09 09:04:29 -070095 return Void();
96}
97
Jaesoo Lee812e85e2017-04-28 18:29:40 +090098Return<void> SurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs(
99 presentTimeOffsetFromVSyncNs_cb _hidl_cb) {
Fabien Sanglard8d7e31e2017-03-14 13:16:30 -0700100#ifdef PRESENT_TIME_OFFSET_FROM_VSYNC_NS
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900101 _hidl_cb({true, PRESENT_TIME_OFFSET_FROM_VSYNC_NS});
Fabien Sanglard8d7e31e2017-03-14 13:16:30 -0700102#else
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900103 _hidl_cb({false, 0});
Fabien Sanglard8d7e31e2017-03-14 13:16:30 -0700104#endif
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900105 return Void();
Fabien Sanglard8d7e31e2017-03-14 13:16:30 -0700106}
107
Fabien Sanglard38295e72017-03-14 11:43:18 -0700108Return<void> SurfaceFlingerConfigs::useHwcForRGBtoYUV(useHwcForRGBtoYUV_cb _hidl_cb) {
109 bool value = false;
110#ifdef FORCE_HWC_COPY_FOR_VIRTUAL_DISPLAYS
111 value = true;
112#endif
113 _hidl_cb({true, value});
Fabien Sanglard38295e72017-03-14 11:43:18 -0700114 return Void();
115}
Jiyong Park200825e2017-01-14 19:40:33 +0900116
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800117Return<void> SurfaceFlingerConfigs::maxVirtualDisplaySize(maxVirtualDisplaySize_cb _hidl_cb) {
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900118 uint64_t maxSize = 0;
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800119#ifdef MAX_VIRTUAL_DISPLAY_DIMENSION
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900120 maxSize = MAX_VIRTUAL_DISPLAY_DIMENSION;
121 _hidl_cb({true, maxSize});
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800122#else
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900123 _hidl_cb({false, maxSize});
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800124#endif
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900125 return Void();
Fabien Sanglarda33c7e42017-03-10 10:31:14 -0800126}
127
Steven Thomascb4172a2017-03-13 17:42:18 -0700128Return<void> SurfaceFlingerConfigs::useVrFlinger(useVrFlinger_cb _hidl_cb) {
129 bool value = false;
130 bool specified = false;
131#ifdef USE_VR_FLINGER
132 value = true;
133 specified = true;
134#endif
135 _hidl_cb({specified, value});
Steven Thomascb4172a2017-03-13 17:42:18 -0700136 return Void();
137}
138
Chia-I Wu12246402017-04-11 15:17:24 -0700139Return<void> SurfaceFlingerConfigs::startGraphicsAllocatorService(
140 startGraphicsAllocatorService_cb _hidl_cb) {
141 bool value = false;
142#ifdef START_GRAPHICS_ALLOCATOR_SERVICE
143 value = true;
144#endif
145 _hidl_cb({true, value});
146 return Void();
147}
148
Peiyong Lin2b3f8262018-07-20 16:03:46 -0700149// ::android::hardware::configstore::V1_1::ISurfaceFlingerConfigs implementation.
Jaesoo Lee712ee822017-04-28 18:29:40 +0900150
151#ifdef PRIMARY_DISPLAY_ORIENTATION
152static_assert(PRIMARY_DISPLAY_ORIENTATION == 0 || PRIMARY_DISPLAY_ORIENTATION == 90 ||
153 PRIMARY_DISPLAY_ORIENTATION == 180 || PRIMARY_DISPLAY_ORIENTATION == 270,
154 "Primary display orientation must be 0/90/180/270");
155#endif
156
157Return<void> SurfaceFlingerConfigs::primaryDisplayOrientation(
158 primaryDisplayOrientation_cb _hidl_cb) {
159 using ::android::hardware::configstore::V1_1::DisplayOrientation;
160
161 bool specified = false;
162 DisplayOrientation value = DisplayOrientation::ORIENTATION_0;
163
164 int orientation = 0;
165#ifdef PRIMARY_DISPLAY_ORIENTATION
166 specified = true;
167 orientation = PRIMARY_DISPLAY_ORIENTATION;
168#endif
169
170 switch (orientation) {
171 case 0: {
172 value = DisplayOrientation::ORIENTATION_0;
173 break;
174 }
175 case 90: {
176 value = DisplayOrientation::ORIENTATION_90;
177 break;
178 }
179 case 180: {
180 value = DisplayOrientation::ORIENTATION_180;
181 break;
182 }
183 case 270: {
184 value = DisplayOrientation::ORIENTATION_270;
185 break;
186 }
187 default: {
188 // statically checked above -> memory corruption
189 LOG_ALWAYS_FATAL("Invalid orientation %d", orientation);
190 }
191 }
192
193 _hidl_cb({specified, value});
194 return Void();
195}
196
Peiyong Lin2b3f8262018-07-20 16:03:46 -0700197// ::android::hardware::configstore::V1_2::ISurfaceFlingerConfigs implementation.
198Return<void> SurfaceFlingerConfigs::useColorManagement(useColorManagement_cb _hidl_cb) {
199#if defined(USE_COLOR_MANAGEMENT) || defined(HAS_WIDE_COLOR_DISPLAY) || defined(HAS_HDR_DISPLAY)
200 _hidl_cb({true, true});
201#else
202 _hidl_cb({true, false});
203#endif
204 return Void();
205}
Jaesoo Lee812e85e2017-04-28 18:29:40 +0900206
Peiyong Lind45f4692018-10-28 15:21:12 -0700207#ifdef DEFAULT_COMPOSITION_DATA_SPACE
208static_assert(DEFAULT_COMPOSITION_DATA_SPACE != 0,
209 "Default composition data space must not be UNKNOWN");
210#endif
211
212#ifdef WCG_COMPOSITION_DATA_SPACE
213static_assert(WCG_COMPOSITION_DATA_SPACE != 0,
214 "Wide color gamut composition data space must not be UNKNOWN");
Peiyong Linbfbaf842018-08-31 14:13:36 -0700215#endif
216
217Return<void> SurfaceFlingerConfigs::getCompositionPreference(getCompositionPreference_cb _hidl_cb) {
Peiyong Lind45f4692018-10-28 15:21:12 -0700218 Dataspace defaultDataspace = Dataspace::V0_SRGB;
219 PixelFormat defaultPixelFormat = PixelFormat::RGBA_8888;
Peiyong Linbfbaf842018-08-31 14:13:36 -0700220
Peiyong Lind45f4692018-10-28 15:21:12 -0700221#ifdef DEFAULT_COMPOSITION_DATA_SPACE
222 defaultDataspace = static_cast<Dataspace>(DEFAULT_COMPOSITION_DATA_SPACE);
Peiyong Linbfbaf842018-08-31 14:13:36 -0700223#endif
224
Peiyong Lind45f4692018-10-28 15:21:12 -0700225#ifdef DEFAULT_COMPOSITION_PIXEL_FORMAT
226 defaultPixelFormat = static_cast<PixelFormat>(DEFAULT_COMPOSITION_PIXEL_FORMAT);
Peiyong Linbfbaf842018-08-31 14:13:36 -0700227#endif
Peiyong Lind45f4692018-10-28 15:21:12 -0700228
229 Dataspace wideColorGamutDataspace = Dataspace::V0_SRGB;
230 PixelFormat wideColorGamutPixelFormat = PixelFormat::RGBA_8888;
231
232#ifdef WCG_COMPOSITION_DATA_SPACE
233 wideColorGamutDataspace = static_cast<Dataspace>(WCG_COMPOSITION_DATA_SPACE);
234#endif
235
236#ifdef WCG_COMPOSITION_PIXEL_FORMAT
237 wideColorGamutPixelFormat = static_cast<PixelFormat>(WCG_COMPOSITION_PIXEL_FORMAT);
238#endif
239
240 _hidl_cb(defaultDataspace, defaultPixelFormat, wideColorGamutDataspace,
241 wideColorGamutPixelFormat);
Peiyong Linbfbaf842018-08-31 14:13:36 -0700242 return Void();
243}
244
linpeter5a12cd72018-11-22 20:41:52 +0800245Return<void> SurfaceFlingerConfigs::getDisplayNativePrimaries(getDisplayNativePrimaries_cb _hidl_cb) {
246 DisplayPrimaries primaries;
247 // The default XYZ is sRGB gamut in CIE1931 color space
248#ifdef TARGET_DISPLAY_PRIMARY_RED_X
249 primaries.red.X = TARGET_DISPLAY_PRIMARY_RED_X;
250#else
251 primaries.red.X = 0.4123;
252#endif
253
254#ifdef TARGET_DISPLAY_PRIMARY_RED_Y
255 primaries.red.Y = TARGET_DISPLAY_PRIMARY_RED_Y;
256#else
257 primaries.red.Y = 0.2126;
258#endif
259
260#ifdef TARGET_DISPLAY_PRIMARY_RED_Z
261 primaries.red.Z = TARGET_DISPLAY_PRIMARY_RED_Z;
262#else
263 primaries.red.Z = 0.0193;
264#endif
265
266#ifdef TARGET_DISPLAY_PRIMARY_GREEN_X
267 primaries.green.X = TARGET_DISPLAY_PRIMARY_GREEN_X;
268#else
269 primaries.green.X = 0.3576;
270#endif
271
272#ifdef TARGET_DISPLAY_PRIMARY_GREEN_Y
273 primaries.green.Y = TARGET_DISPLAY_PRIMARY_GREEN_Y;
274#else
275 primaries.green.Y = 0.7152;
276#endif
277
278#ifdef TARGET_DISPLAY_PRIMARY_GREEN_Z
279 primaries.green.Z = TARGET_DISPLAY_PRIMARY_GREEN_Z;
280#else
281 primaries.green.Z = 0.1192;
282#endif
283
284#ifdef TARGET_DISPLAY_PRIMARY_BLUE_X
285 primaries.blue.X = TARGET_DISPLAY_PRIMARY_BLUE_X;
286#else
287 primaries.blue.X = 0.1805;
288#endif
289
290#ifdef TARGET_DISPLAY_PRIMARY_BLUE_Y
291 primaries.blue.Y = TARGET_DISPLAY_PRIMARY_BLUE_Y;
292#else
293 primaries.blue.Y = 0.0722;
294#endif
295
296#ifdef TARGET_DISPLAY_PRIMARY_BLUE_Z
297 primaries.blue.Z = TARGET_DISPLAY_PRIMARY_BLUE_Z;
298#else
299 primaries.blue.Z = 0.9506;
300#endif
301
302#ifdef TARGET_DISPLAY_PRIMARY_WHITE_X
303 primaries.white.X = TARGET_DISPLAY_PRIMARY_WHITE_X;
304#else
305 primaries.white.X = 0.9505;
306#endif
307
308#ifdef TARGET_DISPLAY_PRIMARY_WHITE_Y
309 primaries.white.Y = TARGET_DISPLAY_PRIMARY_WHITE_Y;
310#else
311 primaries.white.Y = 1.0000;
312#endif
313
314#ifdef TARGET_DISPLAY_PRIMARY_WHITE_Z
315 primaries.white.Z = TARGET_DISPLAY_PRIMARY_WHITE_Z;
316#else
317 primaries.white.Z = 1.0891;
318#endif
319
320 _hidl_cb(primaries);
321 return Void();
322}
323
Jiyong Park200825e2017-01-14 19:40:33 +0900324} // namespace implementation
Peiyong Lin2b3f8262018-07-20 16:03:46 -0700325} // namespace V1_2
Jiyong Park200825e2017-01-14 19:40:33 +0900326} // namespace configstore
327} // namespace hardware
328} // namespace android