blob: 69bf6d95641915e1eecadf5f449cf7c1605da250 [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
Sean Paulb386f1b2015-05-13 06:33:23 -070020#include "drm_hwcomposer.h"
Sean Paul98e73c82015-06-24 14:38:49 -070021#include "drmdisplaycomposition.h"
Sean Paulb386f1b2015-05-13 06:33:23 -070022#include "drmplane.h"
23#include "importer.h"
24
25#include <deque>
26#include <map>
27#include <vector>
28
29#include <hardware/hardware.h>
30#include <hardware/hwcomposer.h>
31
32namespace android {
33
Zach Reizner459a5a92015-07-31 15:12:49 -070034class DrmComposition {
Sean Paulb386f1b2015-05-13 06:33:23 -070035 public:
Sean Paul98e73c82015-06-24 14:38:49 -070036 DrmComposition(DrmResources *drm, Importer *importer);
Sean Paulb386f1b2015-05-13 06:33:23 -070037 ~DrmComposition();
38
Zach Reizner459a5a92015-07-31 15:12:49 -070039 int Init();
Sean Paulb386f1b2015-05-13 06:33:23 -070040
Zach Reizner459a5a92015-07-31 15:12:49 -070041 unsigned GetRemainingLayers(int display, unsigned num_needed) const;
42 int AddLayer(int display, hwc_layer_1_t *layer, hwc_drm_bo_t *bo);
Sean Pauldb7a17d2015-06-24 18:46:05 -070043 int AddDpmsMode(int display, uint32_t dpms_mode);
Sean Paulb386f1b2015-05-13 06:33:23 -070044
Sean Paul2e46fbd2015-07-09 17:22:22 -040045 int DisableUnusedPlanes();
46
Sean Paul98e73c82015-06-24 14:38:49 -070047 std::unique_ptr<DrmDisplayComposition> TakeDisplayComposition(int display);
Sean Paul2e46fbd2015-07-09 17:22:22 -040048 DrmDisplayComposition *GetDisplayComposition(int display);
Sean Paulb386f1b2015-05-13 06:33:23 -070049
50 private:
Sean Paul98e73c82015-06-24 14:38:49 -070051 DrmComposition(const DrmComposition &) = delete;
52
Sean Paulb386f1b2015-05-13 06:33:23 -070053 DrmResources *drm_;
54 Importer *importer_;
55
Sean Paulb386f1b2015-05-13 06:33:23 -070056 std::vector<DrmPlane *> primary_planes_;
Sean Paul9099aa52015-07-09 17:51:50 -040057 std::vector<DrmPlane *> overlay_planes_;
Sean Paul98e73c82015-06-24 14:38:49 -070058
59 /*
60 * This _must_ be read-only after it's passed to QueueComposition. Otherwise
61 * locking is required to maintain consistency across the compositor threads.
62 */
63 std::map<int, std::unique_ptr<DrmDisplayComposition>> composition_map_;
Sean Paulb386f1b2015-05-13 06:33:23 -070064};
Sean Paul98e73c82015-06-24 14:38:49 -070065
Sean Paulb386f1b2015-05-13 06:33:23 -070066}
67
68#endif // ANDROID_DRM_COMPOSITION_H_