blob: 76da993e714db1e9e2003098aea1707c44a79ad2 [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
Zach Reiznerb44fd102015-08-07 16:00:01 -070026#include <hardware/gralloc.h>
Sean Paul98e73c82015-06-24 14:38:49 -070027#include <hardware/hardware.h>
28#include <hardware/hwcomposer.h>
29
30namespace android {
31
Sean Paulacb2a442015-06-24 18:43:01 -070032enum DrmCompositionType {
33 DRM_COMPOSITION_TYPE_EMPTY,
34 DRM_COMPOSITION_TYPE_FRAME,
Sean Pauldb7a17d2015-06-24 18:46:05 -070035 DRM_COMPOSITION_TYPE_DPMS,
Sean Paulacb2a442015-06-24 18:43:01 -070036};
37
Sean Paul98e73c82015-06-24 14:38:49 -070038typedef struct DrmCompositionLayer {
39 DrmCompositionLayer();
40 ~DrmCompositionLayer();
41
42 hwc_layer_1_t layer;
43 hwc_drm_bo_t bo;
44 DrmCrtc *crtc;
45 DrmPlane *plane;
Zach Reiznerb44fd102015-08-07 16:00:01 -070046 native_handle_t *handle;
Sean Paul98e73c82015-06-24 14:38:49 -070047} DrmCompositionLayer_t;
48typedef std::vector<DrmCompositionLayer_t> DrmCompositionLayerVector_t;
49
50class DrmDisplayComposition {
51 public:
52 DrmDisplayComposition();
53 ~DrmDisplayComposition();
54
55 int Init(DrmResources *drm, Importer *importer);
56
Sean Paulacb2a442015-06-24 18:43:01 -070057 DrmCompositionType type() const;
58
Sean Paul98e73c82015-06-24 14:38:49 -070059 int AddLayer(hwc_layer_1_t *layer, hwc_drm_bo_t *bo, DrmCrtc *crtc,
60 DrmPlane *plane);
Zach Reizner713a6782015-07-31 15:12:44 -070061 // Like the AddLayer that accepts a hwc_drm_bo_t, but uses Importer to import
62 // the layer->handle itself.
63 int AddLayer(hwc_layer_1_t *layer, DrmCrtc *crtc, DrmPlane *plane);
Sean Paul2e46fbd2015-07-09 17:22:22 -040064 int AddPlaneDisable(DrmPlane *plane);
Sean Pauldb7a17d2015-06-24 18:46:05 -070065 int AddDpmsMode(uint32_t dpms_mode);
Sean Paul98e73c82015-06-24 14:38:49 -070066
Zach Reiznerb44fd102015-08-07 16:00:01 -070067 void RemoveNoPlaneLayers();
Sean Paul98e73c82015-06-24 14:38:49 -070068 int FinishComposition();
69
70 DrmCompositionLayerVector_t *GetCompositionLayers();
Sean Pauldb7a17d2015-06-24 18:46:05 -070071 uint32_t dpms_mode() const;
Sean Paul98e73c82015-06-24 14:38:49 -070072
Zach Reizner46ddd452015-07-30 08:10:14 -070073 Importer *importer() const;
74
Sean Paul98e73c82015-06-24 14:38:49 -070075 private:
76 DrmDisplayComposition(const DrmDisplayComposition &) = delete;
77
Sean Paulacb2a442015-06-24 18:43:01 -070078 bool validate_composition_type(DrmCompositionType desired);
79
Sean Paul98e73c82015-06-24 14:38:49 -070080 DrmResources *drm_;
81 Importer *importer_;
Zach Reiznerb44fd102015-08-07 16:00:01 -070082 const gralloc_module_t *gralloc_;
Sean Paul98e73c82015-06-24 14:38:49 -070083
Sean Paulacb2a442015-06-24 18:43:01 -070084 DrmCompositionType type_;
85
Sean Paul98e73c82015-06-24 14:38:49 -070086 int timeline_fd_;
87 int timeline_;
Zach Reiznerece04892015-07-17 14:13:28 -070088 int timeline_current_;
Sean Paul98e73c82015-06-24 14:38:49 -070089
90 DrmCompositionLayerVector_t layers_;
Sean Pauldb7a17d2015-06-24 18:46:05 -070091 uint32_t dpms_mode_;
Sean Paul98e73c82015-06-24 14:38:49 -070092};
93}
94
95#endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_