blob: eae8cde5482f6621d19dc4c5d2d6a4c6300cfd16 [file] [log] [blame]
Sean Paulb386f1b2015-05-13 06:33:23 -07001/*
2 * Copyright (C) 2015 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#ifndef ANDROID_DRM_COMPOSITION_H_
18#define ANDROID_DRM_COMPOSITION_H_
19
Zach Reizner7642c922015-10-29 10:11:16 -070020#include "drmhwcomposer.h"
Sean Paul98e73c82015-06-24 14:38:49 -070021#include "drmdisplaycomposition.h"
Sean Paulb386f1b2015-05-13 06:33:23 -070022#include "drmplane.h"
Sean Paul63769962016-04-21 16:25:06 -040023#include "platform.h"
Sean Paulb386f1b2015-05-13 06:33:23 -070024
Sean Paulb386f1b2015-05-13 06:33:23 -070025#include <map>
26#include <vector>
27
28#include <hardware/hardware.h>
29#include <hardware/hwcomposer.h>
30
31namespace android {
32
Zach Reizner92f8e632015-10-12 17:47:13 -070033class DrmDisplayCompositor;
34
Zach Reizner09807052015-08-13 14:53:41 -070035struct DrmCompositionDisplayLayersMap {
36 int display;
Zach Reizner5757e822015-10-16 19:06:31 -070037 bool geometry_changed = true;
Zach Reizner4a253652015-09-10 18:30:54 -070038 std::vector<DrmHwcLayer> layers;
39
40 DrmCompositionDisplayLayersMap() = default;
41 DrmCompositionDisplayLayersMap(DrmCompositionDisplayLayersMap &&rhs) =
42 default;
Zach Reizner09807052015-08-13 14:53:41 -070043};
44
Zach Reizner459a5a92015-07-31 15:12:49 -070045class DrmComposition {
Sean Paulb386f1b2015-05-13 06:33:23 -070046 public:
Sean Paulaa18d912016-05-12 14:28:05 -040047 DrmComposition(DrmResources *drm, Importer *importer, Planner *planner);
Sean Paulb386f1b2015-05-13 06:33:23 -070048
Sean Paulbdc67bf2015-09-21 10:04:02 -040049 int Init(uint64_t frame_no);
Sean Paulb386f1b2015-05-13 06:33:23 -070050
Zach Reizner4a253652015-09-10 18:30:54 -070051 int SetLayers(size_t num_displays, DrmCompositionDisplayLayersMap *maps);
Zach Reizner09807052015-08-13 14:53:41 -070052 int SetDpmsMode(int display, uint32_t dpms_mode);
Sean Paul57355412015-09-19 09:14:34 -040053 int SetDisplayMode(int display, const DrmMode &display_mode);
Sean Paul2e46fbd2015-07-09 17:22:22 -040054
Sean Paul98e73c82015-06-24 14:38:49 -070055 std::unique_ptr<DrmDisplayComposition> TakeDisplayComposition(int display);
Sean Paul2e46fbd2015-07-09 17:22:22 -040056 DrmDisplayComposition *GetDisplayComposition(int display);
Zach Reizner92f8e632015-10-12 17:47:13 -070057
58 int Plan(std::map<int, DrmDisplayCompositor> &compositor_map);
Zach Reizner09807052015-08-13 14:53:41 -070059 int DisableUnusedPlanes();
Sean Paulb386f1b2015-05-13 06:33:23 -070060
61 private:
Sean Paul98e73c82015-06-24 14:38:49 -070062 DrmComposition(const DrmComposition &) = delete;
63
Sean Paulb386f1b2015-05-13 06:33:23 -070064 DrmResources *drm_;
65 Importer *importer_;
Sean Paulaa18d912016-05-12 14:28:05 -040066 Planner *planner_;
Sean Paulb386f1b2015-05-13 06:33:23 -070067
Sean Paulb386f1b2015-05-13 06:33:23 -070068 std::vector<DrmPlane *> primary_planes_;
Sean Paul9099aa52015-07-09 17:51:50 -040069 std::vector<DrmPlane *> overlay_planes_;
Sean Paul98e73c82015-06-24 14:38:49 -070070
71 /*
72 * This _must_ be read-only after it's passed to QueueComposition. Otherwise
73 * locking is required to maintain consistency across the compositor threads.
74 */
75 std::map<int, std::unique_ptr<DrmDisplayComposition>> composition_map_;
Sean Paulb386f1b2015-05-13 06:33:23 -070076};
Sean Paulb386f1b2015-05-13 06:33:23 -070077}
78
79#endif // ANDROID_DRM_COMPOSITION_H_