blob: 966bd4e188f40b1cc7e99574669afd1bfd085d22 [file] [log] [blame]
Roman Stratiienko9362cef2022-02-02 09:53:50 +02001/*
2 * Copyright (C) 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#define LOG_TAG "hwc-composition-drm-kms-plan"
18
19#include "DrmKmsPlan.h"
20
21#include "drm/DrmDevice.h"
22#include "drm/DrmPlane.h"
23#include "utils/log.h"
24
25namespace android {
26auto DrmKmsPlan::CreateDrmKmsPlan(DrmDisplayPipeline &pipe,
27 std::vector<DrmHwcLayer> composition)
28 -> std::unique_ptr<DrmKmsPlan> {
29 auto plan = std::make_unique<DrmKmsPlan>();
30
31 auto avail_planes = pipe.GetUsablePlanes();
32
33 int z_pos = 0;
34 for (auto &dhl : composition) {
35 std::shared_ptr<BindingOwner<DrmPlane>> plane;
36
37 /* Skip unsupported planes */
38 do {
39 if (avail_planes.empty()) {
40 return {};
41 }
42
43 plane = *avail_planes.begin();
44 avail_planes.erase(avail_planes.begin());
45 } while (!plane->Get()->IsValidForLayer(&dhl));
46
47 LayerToPlaneJoining joining = {
48 .layer = std::move(dhl),
49 .plane = plane,
50 .z_pos = z_pos++,
51 };
52
53 plan->plan.emplace_back(std::move(joining));
54 }
55
56 return plan;
57}
58
59} // namespace android