• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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() {
30   return ::android::base::GetProperty("ro.product.board", "") == "cutf";
31 }
32 
IsCuttlefishFoldable()33 bool IsCuttlefishFoldable() {
34   return IsCuttlefish() &&
35          ::android::base::GetProperty("ro.product.name", "").find("foldable") !=
36              std::string::npos;
37 }
38 
39 
IsInNoOpCompositionMode()40 bool IsInNoOpCompositionMode() {
41   const std::string mode = ::android::base::GetProperty("ro.vendor.hwcomposer.mode", "");
42   DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.mode is %s", __FUNCTION__, mode.c_str());
43   return mode == "noop";
44 }
45 
IsInClientCompositionMode()46 bool IsInClientCompositionMode() {
47   const std::string mode = ::android::base::GetProperty("ro.vendor.hwcomposer.mode", "");
48   DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.mode is %s", __FUNCTION__, mode.c_str());
49   return mode == "client";
50 }
51 
IsInGem5DisplayFinderMode()52 bool IsInGem5DisplayFinderMode() {
53   const std::string mode =
54     ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
55   DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s",
56             __FUNCTION__, mode.c_str());
57   return mode == "gem5";
58 }
59 
IsInNoOpDisplayFinderMode()60 bool IsInNoOpDisplayFinderMode() {
61   const std::string mode =
62     ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
63   DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s",
64             __FUNCTION__, mode.c_str());
65   return mode == "noop";
66 }
67 
IsInDrmDisplayFinderMode()68 bool IsInDrmDisplayFinderMode() {
69   const std::string mode =
70     ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
71   DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s",
72             __FUNCTION__, mode.c_str());
73   return mode == "drm";
74 }
75 
toString(HWC3::Error error)76 std::string toString(HWC3::Error error) {
77   switch (error) {
78     case HWC3::Error::None:
79       return "None";
80     case HWC3::Error::BadConfig:
81       return "BadConfig";
82     case HWC3::Error::BadDisplay:
83       return "BadDisplay";
84     case HWC3::Error::BadLayer:
85       return "BadLayer";
86     case HWC3::Error::BadParameter:
87       return "BadParameter";
88     case HWC3::Error::NoResources:
89       return "NoResources";
90     case HWC3::Error::NotValidated:
91       return "NotValidated";
92     case HWC3::Error::Unsupported:
93       return "Unsupported";
94     case HWC3::Error::SeamlessNotAllowed:
95       return "SeamlessNotAllowed";
96   }
97 }
98 
99 }  // namespace aidl::android::hardware::graphics::composer3::impl
100