xref: /aosp_15_r20/external/drm_hwcomposer/hwc3/Utils.cpp (revision 0a9764fe0a15e71ebbeb85e87e10990c23aab47f)
1 
2 /*
3  * Copyright (C) 2024 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #define LOG_TAG "drmhwc"
19 #define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
20 
21 #include "Utils.h"
22 
23 #include <hardware/hwcomposer2.h>
24 
25 #include "utils/log.h"
26 
27 namespace aidl::android::hardware::graphics::composer3 {
28 
Hwc2toHwc3Error(HWC2::Error error)29 hwc3::Error Hwc2toHwc3Error(HWC2::Error error) {
30   switch (error) {
31     case HWC2::Error::None:
32       return hwc3::Error::kNone;
33     case HWC2::Error::BadConfig:
34       return hwc3::Error::kBadConfig;
35     case HWC2::Error::BadDisplay:
36       return hwc3::Error::kBadDisplay;
37     case HWC2::Error::BadLayer:
38       return hwc3::Error::kBadLayer;
39     case HWC2::Error::BadParameter:
40       return hwc3::Error::kBadParameter;
41     case HWC2::Error::NoResources:
42       return hwc3::Error::kNoResources;
43     case HWC2::Error::NotValidated:
44       return hwc3::Error::kNotValidated;
45     case HWC2::Error::Unsupported:
46       return hwc3::Error::kUnsupported;
47     case HWC2::Error::SeamlessNotAllowed:
48       return hwc3::Error::kSeamlessNotAllowed;
49     case HWC2::Error::SeamlessNotPossible:
50       return hwc3::Error::kSeamlessNotPossible;
51     default:
52       ALOGE("Unknown HWC2 error. Could not translate to HWC3 error: %d",
53             static_cast<int32_t>(error));
54       return hwc3::Error::kUnsupported;
55   }
56 }
57 
58 };  // namespace aidl::android::hardware::graphics::composer3