Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 1 | /* |
Jaesoo Lee | 712ee82 | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 2 | * Copyright (C) 2018 The Android Open Source Project |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 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 | */ |
Jiyong Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 16 | |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 17 | #include "SurfaceFlingerConfigs.h" |
Jiyong Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 18 | |
Jaesoo Lee | 712ee82 | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 19 | #include <android/hardware/configstore/1.1/types.h> |
linpeter | 5a12cd7 | 2018-11-22 20:41:52 +0800 | [diff] [blame^] | 20 | #include <android/hardware/configstore/1.2/types.h> |
Peiyong Lin | bfbaf84 | 2018-08-31 14:13:36 -0700 | [diff] [blame] | 21 | #include <android/hardware/graphics/common/1.1/types.h> |
Jaesoo Lee | 712ee82 | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 22 | #include <log/log.h> |
| 23 | |
Jiyong Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace configstore { |
Peiyong Lin | 2b3f826 | 2018-07-20 16:03:46 -0700 | [diff] [blame] | 27 | namespace V1_2 { |
Jiyong Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 28 | namespace implementation { |
| 29 | |
Peiyong Lin | bfbaf84 | 2018-08-31 14:13:36 -0700 | [diff] [blame] | 30 | using ::android::hardware::graphics::common::V1_1::PixelFormat; |
Valerie Hau | ec98306 | 2018-10-09 16:09:12 -0700 | [diff] [blame] | 31 | using ::android::hardware::graphics::common::V1_2::Dataspace; |
Peiyong Lin | bfbaf84 | 2018-08-31 14:13:36 -0700 | [diff] [blame] | 32 | |
Peiyong Lin | 2b3f826 | 2018-07-20 16:03:46 -0700 | [diff] [blame] | 33 | // ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs implementation. |
Jiyong Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 34 | Return<void> SurfaceFlingerConfigs::vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) { |
| 35 | #ifdef VSYNC_EVENT_PHASE_OFFSET_NS |
| 36 | _hidl_cb({true, VSYNC_EVENT_PHASE_OFFSET_NS}); |
Jiyong Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 37 | #else |
| 38 | _hidl_cb({false, 0}); |
| 39 | #endif |
| 40 | return Void(); |
| 41 | } |
| 42 | |
Fabien Sanglard | eebc925 | 2017-03-06 11:46:36 -0800 | [diff] [blame] | 43 | Return<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 Sanglard | eebc925 | 2017-03-06 11:46:36 -0800 | [diff] [blame] | 46 | #else |
| 47 | _hidl_cb({false, 0}); |
| 48 | #endif |
| 49 | return Void(); |
| 50 | } |
| 51 | |
Fabien Sanglard | cbece28 | 2017-03-13 13:03:04 -0700 | [diff] [blame] | 52 | Return<void> SurfaceFlingerConfigs::useContextPriority(useContextPriority_cb _hidl_cb) { |
| 53 | #ifdef USE_CONTEXT_PRIORITY |
| 54 | _hidl_cb({true, USE_CONTEXT_PRIORITY}); |
Fabien Sanglard | cbece28 | 2017-03-13 13:03:04 -0700 | [diff] [blame] | 55 | #else |
| 56 | _hidl_cb({false, false}); |
| 57 | #endif |
| 58 | return Void(); |
| 59 | } |
| 60 | |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 61 | Return<void> SurfaceFlingerConfigs::maxFrameBufferAcquiredBuffers( |
| 62 | maxFrameBufferAcquiredBuffers_cb _hidl_cb) { |
Fabien Sanglard | 3d9f5ad | 2017-03-10 15:37:07 -0800 | [diff] [blame] | 63 | #ifdef NUM_FRAMEBUFFER_SURFACE_BUFFERS |
| 64 | _hidl_cb({true, NUM_FRAMEBUFFER_SURFACE_BUFFERS}); |
Fabien Sanglard | 3d9f5ad | 2017-03-10 15:37:07 -0800 | [diff] [blame] | 65 | #else |
| 66 | _hidl_cb({false, 0}); |
| 67 | #endif |
| 68 | return Void(); |
| 69 | } |
| 70 | |
Courtney Goeltzenleuchter | 3670b44 | 2017-03-09 09:04:29 -0700 | [diff] [blame] | 71 | Return<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 Goeltzenleuchter | 3670b44 | 2017-03-09 09:04:29 -0700 | [diff] [blame] | 77 | return Void(); |
| 78 | } |
| 79 | |
Fabien Sanglard | bf4da3d | 2017-03-10 17:15:43 -0800 | [diff] [blame] | 80 | Return<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 Sanglard | bf4da3d | 2017-03-10 17:15:43 -0800 | [diff] [blame] | 86 | return Void(); |
| 87 | } |
| 88 | |
Courtney Goeltzenleuchter | 3670b44 | 2017-03-09 09:04:29 -0700 | [diff] [blame] | 89 | Return<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 Goeltzenleuchter | 3670b44 | 2017-03-09 09:04:29 -0700 | [diff] [blame] | 95 | return Void(); |
| 96 | } |
| 97 | |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 98 | Return<void> SurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs( |
| 99 | presentTimeOffsetFromVSyncNs_cb _hidl_cb) { |
Fabien Sanglard | 8d7e31e | 2017-03-14 13:16:30 -0700 | [diff] [blame] | 100 | #ifdef PRESENT_TIME_OFFSET_FROM_VSYNC_NS |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 101 | _hidl_cb({true, PRESENT_TIME_OFFSET_FROM_VSYNC_NS}); |
Fabien Sanglard | 8d7e31e | 2017-03-14 13:16:30 -0700 | [diff] [blame] | 102 | #else |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 103 | _hidl_cb({false, 0}); |
Fabien Sanglard | 8d7e31e | 2017-03-14 13:16:30 -0700 | [diff] [blame] | 104 | #endif |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 105 | return Void(); |
Fabien Sanglard | 8d7e31e | 2017-03-14 13:16:30 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Fabien Sanglard | 38295e7 | 2017-03-14 11:43:18 -0700 | [diff] [blame] | 108 | Return<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 Sanglard | 38295e7 | 2017-03-14 11:43:18 -0700 | [diff] [blame] | 114 | return Void(); |
| 115 | } |
Jiyong Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 116 | |
Fabien Sanglard | a33c7e4 | 2017-03-10 10:31:14 -0800 | [diff] [blame] | 117 | Return<void> SurfaceFlingerConfigs::maxVirtualDisplaySize(maxVirtualDisplaySize_cb _hidl_cb) { |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 118 | uint64_t maxSize = 0; |
Fabien Sanglard | a33c7e4 | 2017-03-10 10:31:14 -0800 | [diff] [blame] | 119 | #ifdef MAX_VIRTUAL_DISPLAY_DIMENSION |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 120 | maxSize = MAX_VIRTUAL_DISPLAY_DIMENSION; |
| 121 | _hidl_cb({true, maxSize}); |
Fabien Sanglard | a33c7e4 | 2017-03-10 10:31:14 -0800 | [diff] [blame] | 122 | #else |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 123 | _hidl_cb({false, maxSize}); |
Fabien Sanglard | a33c7e4 | 2017-03-10 10:31:14 -0800 | [diff] [blame] | 124 | #endif |
Jaesoo Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 125 | return Void(); |
Fabien Sanglard | a33c7e4 | 2017-03-10 10:31:14 -0800 | [diff] [blame] | 126 | } |
| 127 | |
Steven Thomas | cb4172a | 2017-03-13 17:42:18 -0700 | [diff] [blame] | 128 | Return<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 Thomas | cb4172a | 2017-03-13 17:42:18 -0700 | [diff] [blame] | 136 | return Void(); |
| 137 | } |
| 138 | |
Chia-I Wu | 1224640 | 2017-04-11 15:17:24 -0700 | [diff] [blame] | 139 | Return<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 Lin | 2b3f826 | 2018-07-20 16:03:46 -0700 | [diff] [blame] | 149 | // ::android::hardware::configstore::V1_1::ISurfaceFlingerConfigs implementation. |
Jaesoo Lee | 712ee82 | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 150 | |
| 151 | #ifdef PRIMARY_DISPLAY_ORIENTATION |
| 152 | static_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 | |
| 157 | Return<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 Lin | 2b3f826 | 2018-07-20 16:03:46 -0700 | [diff] [blame] | 197 | // ::android::hardware::configstore::V1_2::ISurfaceFlingerConfigs implementation. |
| 198 | Return<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 Lee | 812e85e | 2017-04-28 18:29:40 +0900 | [diff] [blame] | 206 | |
Peiyong Lin | d45f469 | 2018-10-28 15:21:12 -0700 | [diff] [blame] | 207 | #ifdef DEFAULT_COMPOSITION_DATA_SPACE |
| 208 | static_assert(DEFAULT_COMPOSITION_DATA_SPACE != 0, |
| 209 | "Default composition data space must not be UNKNOWN"); |
| 210 | #endif |
| 211 | |
| 212 | #ifdef WCG_COMPOSITION_DATA_SPACE |
| 213 | static_assert(WCG_COMPOSITION_DATA_SPACE != 0, |
| 214 | "Wide color gamut composition data space must not be UNKNOWN"); |
Peiyong Lin | bfbaf84 | 2018-08-31 14:13:36 -0700 | [diff] [blame] | 215 | #endif |
| 216 | |
| 217 | Return<void> SurfaceFlingerConfigs::getCompositionPreference(getCompositionPreference_cb _hidl_cb) { |
Peiyong Lin | d45f469 | 2018-10-28 15:21:12 -0700 | [diff] [blame] | 218 | Dataspace defaultDataspace = Dataspace::V0_SRGB; |
| 219 | PixelFormat defaultPixelFormat = PixelFormat::RGBA_8888; |
Peiyong Lin | bfbaf84 | 2018-08-31 14:13:36 -0700 | [diff] [blame] | 220 | |
Peiyong Lin | d45f469 | 2018-10-28 15:21:12 -0700 | [diff] [blame] | 221 | #ifdef DEFAULT_COMPOSITION_DATA_SPACE |
| 222 | defaultDataspace = static_cast<Dataspace>(DEFAULT_COMPOSITION_DATA_SPACE); |
Peiyong Lin | bfbaf84 | 2018-08-31 14:13:36 -0700 | [diff] [blame] | 223 | #endif |
| 224 | |
Peiyong Lin | d45f469 | 2018-10-28 15:21:12 -0700 | [diff] [blame] | 225 | #ifdef DEFAULT_COMPOSITION_PIXEL_FORMAT |
| 226 | defaultPixelFormat = static_cast<PixelFormat>(DEFAULT_COMPOSITION_PIXEL_FORMAT); |
Peiyong Lin | bfbaf84 | 2018-08-31 14:13:36 -0700 | [diff] [blame] | 227 | #endif |
Peiyong Lin | d45f469 | 2018-10-28 15:21:12 -0700 | [diff] [blame] | 228 | |
| 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 Lin | bfbaf84 | 2018-08-31 14:13:36 -0700 | [diff] [blame] | 242 | return Void(); |
| 243 | } |
| 244 | |
linpeter | 5a12cd7 | 2018-11-22 20:41:52 +0800 | [diff] [blame^] | 245 | Return<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 Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 324 | } // namespace implementation |
Peiyong Lin | 2b3f826 | 2018-07-20 16:03:46 -0700 | [diff] [blame] | 325 | } // namespace V1_2 |
Jiyong Park | 200825e | 2017-01-14 19:40:33 +0900 | [diff] [blame] | 326 | } // namespace configstore |
| 327 | } // namespace hardware |
| 328 | } // namespace android |