1 /*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (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.0
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 "Common.h"
18
19 #include <android-base/properties.h>
20
21 namespace aidl::android::hardware::graphics::composer3::impl {
22
IsAutoDevice()23 bool IsAutoDevice() {
24 // gcar_emu_x86_64, sdk_car_md_x86_64, cf_x86_64_auto, cf_x86_64_only_auto_md
25 const std::string product_name = ::android::base::GetProperty("ro.product.name", "");
26 return product_name.find("car_") || product_name.find("_auto");
27 }
28
IsCuttlefish()29 bool IsCuttlefish() { return ::android::base::GetProperty("ro.product.board", "") == "cutf"; }
30
IsCuttlefishFoldable()31 bool IsCuttlefishFoldable() {
32 return IsCuttlefish() && ::android::base::GetProperty("ro.product.name", "").find("foldable") !=
33 std::string::npos;
34 }
35
IsInNoOpCompositionMode()36 bool IsInNoOpCompositionMode() {
37 const std::string mode = ::android::base::GetProperty("ro.vendor.hwcomposer.mode", "");
38 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.mode is %s", __FUNCTION__, mode.c_str());
39 return mode == "noop";
40 }
41
IsInClientCompositionMode()42 bool IsInClientCompositionMode() {
43 const std::string mode = ::android::base::GetProperty("ro.vendor.hwcomposer.mode", "");
44 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.mode is %s", __FUNCTION__, mode.c_str());
45 return mode == "client";
46 }
47
IsInGem5DisplayFinderMode()48 bool IsInGem5DisplayFinderMode() {
49 const std::string mode =
50 ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
51 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s", __FUNCTION__,
52 mode.c_str());
53 return mode == "gem5";
54 }
55
IsInNoOpDisplayFinderMode()56 bool IsInNoOpDisplayFinderMode() {
57 const std::string mode =
58 ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
59 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s", __FUNCTION__,
60 mode.c_str());
61 return mode == "noop";
62 }
63
IsInDrmDisplayFinderMode()64 bool IsInDrmDisplayFinderMode() {
65 const std::string mode =
66 ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
67 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s", __FUNCTION__,
68 mode.c_str());
69 return mode == "drm";
70 }
71
toString(HWC3::Error error)72 std::string toString(HWC3::Error error) {
73 switch (error) {
74 case HWC3::Error::None:
75 return "None";
76 case HWC3::Error::BadConfig:
77 return "BadConfig";
78 case HWC3::Error::BadDisplay:
79 return "BadDisplay";
80 case HWC3::Error::BadLayer:
81 return "BadLayer";
82 case HWC3::Error::BadParameter:
83 return "BadParameter";
84 case HWC3::Error::NoResources:
85 return "NoResources";
86 case HWC3::Error::NotValidated:
87 return "NotValidated";
88 case HWC3::Error::Unsupported:
89 return "Unsupported";
90 case HWC3::Error::SeamlessNotAllowed:
91 return "SeamlessNotAllowed";
92 }
93 }
94
95 } // namespace aidl::android::hardware::graphics::composer3::impl
96