blob: 7202c7c3f4c80255024ca83e747f1a670a19e79a [file] [log] [blame]
Sean Paul98e73c82015-06-24 14:38:49 -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_DISPLAY_COMPOSITION_H_
18#define ANDROID_DRM_DISPLAY_COMPOSITION_H_
19
20#include "drm_hwcomposer.h"
21#include "drmplane.h"
22#include "importer.h"
23
24#include <vector>
25
26#include <hardware/hardware.h>
27#include <hardware/hwcomposer.h>
28
29namespace android {
30
Sean Paulacb2a442015-06-24 18:43:01 -070031enum DrmCompositionType {
32 DRM_COMPOSITION_TYPE_EMPTY,
33 DRM_COMPOSITION_TYPE_FRAME,
Sean Pauldb7a17d2015-06-24 18:46:05 -070034 DRM_COMPOSITION_TYPE_DPMS,
Sean Paulacb2a442015-06-24 18:43:01 -070035};
36
Sean Paul98e73c82015-06-24 14:38:49 -070037typedef struct DrmCompositionLayer {
38 DrmCompositionLayer();
39 ~DrmCompositionLayer();
40
41 hwc_layer_1_t layer;
42 hwc_drm_bo_t bo;
43 DrmCrtc *crtc;
44 DrmPlane *plane;
45} DrmCompositionLayer_t;
46typedef std::vector<DrmCompositionLayer_t> DrmCompositionLayerVector_t;
47
48class DrmDisplayComposition {
49 public:
50 DrmDisplayComposition();
51 ~DrmDisplayComposition();
52
53 int Init(DrmResources *drm, Importer *importer);
54
Sean Paulacb2a442015-06-24 18:43:01 -070055 DrmCompositionType type() const;
56
Sean Paul98e73c82015-06-24 14:38:49 -070057 int AddLayer(hwc_layer_1_t *layer, hwc_drm_bo_t *bo, DrmCrtc *crtc,
58 DrmPlane *plane);
Zach Reizner713a6782015-07-31 15:12:44 -070059 // Like the AddLayer that accepts a hwc_drm_bo_t, but uses Importer to import
60 // the layer->handle itself.
61 int AddLayer(hwc_layer_1_t *layer, DrmCrtc *crtc, DrmPlane *plane);
Sean Paul2e46fbd2015-07-09 17:22:22 -040062 int AddPlaneDisable(DrmPlane *plane);
Sean Pauldb7a17d2015-06-24 18:46:05 -070063 int AddDpmsMode(uint32_t dpms_mode);
Sean Paul98e73c82015-06-24 14:38:49 -070064
65 int FinishComposition();
66
67 DrmCompositionLayerVector_t *GetCompositionLayers();
Sean Pauldb7a17d2015-06-24 18:46:05 -070068 uint32_t dpms_mode() const;
Sean Paul98e73c82015-06-24 14:38:49 -070069
Zach Reizner46ddd452015-07-30 08:10:14 -070070 Importer *importer() const;
71
Sean Paul98e73c82015-06-24 14:38:49 -070072 private:
73 DrmDisplayComposition(const DrmDisplayComposition &) = delete;
74
Sean Paulacb2a442015-06-24 18:43:01 -070075 bool validate_composition_type(DrmCompositionType desired);
76
Sean Paul98e73c82015-06-24 14:38:49 -070077 DrmResources *drm_;
78 Importer *importer_;
79
Sean Paulacb2a442015-06-24 18:43:01 -070080 DrmCompositionType type_;
81
Sean Paul98e73c82015-06-24 14:38:49 -070082 int timeline_fd_;
83 int timeline_;
Zach Reiznerece04892015-07-17 14:13:28 -070084 int timeline_current_;
Sean Paul98e73c82015-06-24 14:38:49 -070085
86 DrmCompositionLayerVector_t layers_;
Sean Pauldb7a17d2015-06-24 18:46:05 -070087 uint32_t dpms_mode_;
Sean Paul98e73c82015-06-24 14:38:49 -070088};
89}
90
91#endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_