blob: 06af71d7932a1a4e462a812793a87e955108b1ba [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
Puneet Kumar1c5e5562015-07-30 03:35:38 +000020#include "compositor.h"
Sean Paulb386f1b2015-05-13 06:33:23 -070021#include "drm_hwcomposer.h"
Sean Paul98e73c82015-06-24 14:38:49 -070022#include "drmdisplaycomposition.h"
Sean Paulb386f1b2015-05-13 06:33:23 -070023#include "drmplane.h"
24#include "importer.h"
25
26#include <deque>
27#include <map>
28#include <vector>
29
30#include <hardware/hardware.h>
31#include <hardware/hwcomposer.h>
32
33namespace android {
34
Puneet Kumar1c5e5562015-07-30 03:35:38 +000035class DrmComposition : public Composition {
Sean Paulb386f1b2015-05-13 06:33:23 -070036 public:
Sean Paul98e73c82015-06-24 14:38:49 -070037 DrmComposition(DrmResources *drm, Importer *importer);
Sean Paulb386f1b2015-05-13 06:33:23 -070038 ~DrmComposition();
39
Puneet Kumar1c5e5562015-07-30 03:35:38 +000040 virtual int Init();
Sean Paulb386f1b2015-05-13 06:33:23 -070041
Puneet Kumar1c5e5562015-07-30 03:35:38 +000042 virtual unsigned GetRemainingLayers(int display, unsigned num_needed) const;
43 virtual int AddLayer(int display, hwc_layer_1_t *layer, hwc_drm_bo_t *bo);
Sean Pauldb7a17d2015-06-24 18:46:05 -070044 int AddDpmsMode(int display, uint32_t dpms_mode);
Sean Paulb386f1b2015-05-13 06:33:23 -070045
Sean Paul2e46fbd2015-07-09 17:22:22 -040046 int DisableUnusedPlanes();
47
Sean Paul98e73c82015-06-24 14:38:49 -070048 std::unique_ptr<DrmDisplayComposition> TakeDisplayComposition(int display);
Sean Paul2e46fbd2015-07-09 17:22:22 -040049 DrmDisplayComposition *GetDisplayComposition(int display);
Sean Paulb386f1b2015-05-13 06:33:23 -070050
51 private:
Sean Paul98e73c82015-06-24 14:38:49 -070052 DrmComposition(const DrmComposition &) = delete;
53
Sean Paulb386f1b2015-05-13 06:33:23 -070054 DrmResources *drm_;
55 Importer *importer_;
56
Sean Paulb386f1b2015-05-13 06:33:23 -070057 std::vector<DrmPlane *> primary_planes_;
Sean Paul9099aa52015-07-09 17:51:50 -040058 std::vector<DrmPlane *> overlay_planes_;
Sean Paul98e73c82015-06-24 14:38:49 -070059
60 /*
61 * This _must_ be read-only after it's passed to QueueComposition. Otherwise
62 * locking is required to maintain consistency across the compositor threads.
63 */
64 std::map<int, std::unique_ptr<DrmDisplayComposition>> composition_map_;
Sean Paulb386f1b2015-05-13 06:33:23 -070065};
Sean Paul98e73c82015-06-24 14:38:49 -070066
Sean Paulb386f1b2015-05-13 06:33:23 -070067}
68
69#endif // ANDROID_DRM_COMPOSITION_H_