2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_DRM_PLATFORM_H_
18 #define ANDROID_DRM_PLATFORM_H_
20 #include <hardware/hardware.h>
21 #include <hardware/hwcomposer.h>
27 #include "compositor/DrmDisplayComposition.h"
28 #include "drmhwcomposer.h"
36 // Removes and returns the next available plane from planes
37 static DrmPlane *PopPlane(std::vector<DrmPlane *> *planes) {
40 DrmPlane *plane = planes->front();
41 planes->erase(planes->begin());
45 // Inserts the given layer:plane in the composition at the back
46 static int Emplace(std::vector<DrmCompositionPlane> *composition,
47 std::vector<DrmPlane *> *planes,
48 std::pair<size_t, DrmHwcLayer *> layer) {
49 DrmPlane *plane = PopPlane(planes);
50 std::vector<DrmPlane *> unused_planes;
53 ret = plane->IsValidForLayer(layer.second) ? 0 : -EINVAL;
56 if (!plane->zpos_property().is_immutable())
57 unused_planes.push_back(plane);
58 plane = PopPlane(planes);
62 composition->emplace_back(plane, layer.first);
63 planes->insert(planes->begin(), unused_planes.begin(),
70 int ProvisionPlanesInternal(std::vector<DrmCompositionPlane> *composition,
71 std::map<size_t, DrmHwcLayer *> &layers,
72 std::vector<DrmPlane *> *planes);
75 // Creates a planner instance
76 static std::unique_ptr<Planner> CreateInstance(DrmDevice *drm);
78 // Takes a stack of layers and provisions hardware planes for them. If the
79 // entire stack can't fit in hardware, FIXME
81 // @layers: a map of index:layer of layers to composite
82 // @primary_planes: a vector of primary planes available for this frame
83 // @overlay_planes: a vector of overlay planes available for this frame
85 // Returns: A tuple with the status of the operation (0 for success) and
86 // a vector of the resulting plan (ie: layer->plane mapping).
87 std::tuple<int, std::vector<DrmCompositionPlane>> ProvisionPlanes(
88 std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
89 std::vector<DrmPlane *> *primary_planes,
90 std::vector<DrmPlane *> *overlay_planes);
93 std::vector<DrmPlane *> GetUsablePlanes(
94 DrmCrtc *crtc, std::vector<DrmPlane *> *primary_planes,
95 std::vector<DrmPlane *> *overlay_planes);
97 } // namespace android