drm_hwcomposer: Connect ComposerClient with HwcDisplay
Implements the HWC3 frontend by calling the HWC2 interfaces already
exposed through DrmHwc, HwcDisplay, HwcLayer, and so on.
Convert between hwc2 types and hwc3 types in ComposerClient.
The following changes from !238 were used as a basis for this change,
and squashed together:
(drm_hwcomposer: Connect ComposerClient with HwcDisplay)
(drm_hwcomposer: Implement HWC3 frontend by calling down to HWC2)
The projects [1, 2] were used as a reference for the implementation.
[1]: https://android.googlesource.com/platform/hardware/google/graphics/common/+/refs/heads/main/hwc3/
[2]: https://android.googlesource.com/device/generic/goldfish-opengl/+/refs/heads/master/system/hwc3/
Co-authored-by: Normunds Rieksts <normunds.rieksts@arm.com>
Co-authored-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I98c10175d5c5f01aec1e192863238e16aa1537ec
Signed-off-by: Drew Davenport <ddavenport@chromium.org>
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc3/Utils.cpp b/hwc3/Utils.cpp
new file mode 100644
index 0000000..adbd2fb
--- /dev/null
+++ b/hwc3/Utils.cpp
@@ -0,0 +1,58 @@
+
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "drmhwc"
+#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
+
+#include "Utils.h"
+
+#include <hardware/hwcomposer2.h>
+
+#include "utils/log.h"
+
+namespace aidl::android::hardware::graphics::composer3 {
+
+hwc3::Error Hwc2toHwc3Error(HWC2::Error error) {
+ switch (error) {
+ case HWC2::Error::None:
+ return hwc3::Error::kNone;
+ case HWC2::Error::BadConfig:
+ return hwc3::Error::kBadConfig;
+ case HWC2::Error::BadDisplay:
+ return hwc3::Error::kBadDisplay;
+ case HWC2::Error::BadLayer:
+ return hwc3::Error::kBadLayer;
+ case HWC2::Error::BadParameter:
+ return hwc3::Error::kBadParameter;
+ case HWC2::Error::NoResources:
+ return hwc3::Error::kNoResources;
+ case HWC2::Error::NotValidated:
+ return hwc3::Error::kNotValidated;
+ case HWC2::Error::Unsupported:
+ return hwc3::Error::kUnsupported;
+ case HWC2::Error::SeamlessNotAllowed:
+ return hwc3::Error::kSeamlessNotAllowed;
+ case HWC2::Error::SeamlessNotPossible:
+ return hwc3::Error::kSeamlessNotPossible;
+ default:
+ ALOGE("Unknown HWC2 error. Could not translate to HWC3 error: %d",
+ static_cast<int32_t>(error));
+ return hwc3::Error::kUnsupported;
+ }
+}
+
+}; // namespace aidl::android::hardware::graphics::composer3
\ No newline at end of file