blob: f2027ee28231884d34cd5dfc0bdd4914c5dbbc23 [file] [log] [blame]
Jason Macnakda49cb72022-10-07 11:06:41 -07001/*
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 "DrmPlane.h"
18
19namespace aidl::android::hardware::graphics::composer3::impl {
20
21std::unique_ptr<DrmPlane> DrmPlane::create(::android::base::borrowed_fd drmFd, uint32_t planeId) {
22 std::unique_ptr<DrmPlane> plane(new DrmPlane(planeId));
23
24 DEBUG_LOG("%s: Loading properties for DRM plane:%" PRIu32, __FUNCTION__, planeId);
25 if (!LoadDrmProperties(drmFd, planeId, DRM_MODE_OBJECT_PLANE, GetPropertiesMap(),
26 plane.get())) {
27 ALOGE("%s: Failed to load plane properties.", __FUNCTION__);
28 return nullptr;
29 }
30
31 drmModePlanePtr drmPlane = drmModeGetPlane(drmFd.get(), planeId);
32 plane->mPossibleCrtcsMask = drmPlane->possible_crtcs;
33 drmModeFreePlane(drmPlane);
34
35 return plane;
36}
37
38bool DrmPlane::isPrimary() const { return mType.getValue() == DRM_PLANE_TYPE_PRIMARY; }
39
40bool DrmPlane::isOverlay() const { return mType.getValue() == DRM_PLANE_TYPE_OVERLAY; }
41
42bool DrmPlane::isCompatibleWith(const DrmCrtc& crtc) {
43 return ((0x1 << crtc.mIndexInResourcesArray) & mPossibleCrtcsMask);
44}
45
46} // namespace aidl::android::hardware::graphics::composer3::impl