Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 29 | namespace android { |
| 30 | |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 31 | enum DrmCompositionType { |
| 32 | DRM_COMPOSITION_TYPE_EMPTY, |
| 33 | DRM_COMPOSITION_TYPE_FRAME, |
Sean Paul | db7a17d | 2015-06-24 18:46:05 -0700 | [diff] [blame] | 34 | DRM_COMPOSITION_TYPE_DPMS, |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 37 | typedef 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; |
| 46 | typedef std::vector<DrmCompositionLayer_t> DrmCompositionLayerVector_t; |
| 47 | |
| 48 | class DrmDisplayComposition { |
| 49 | public: |
| 50 | DrmDisplayComposition(); |
| 51 | ~DrmDisplayComposition(); |
| 52 | |
| 53 | int Init(DrmResources *drm, Importer *importer); |
| 54 | |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 55 | DrmCompositionType type() const; |
| 56 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 57 | int AddLayer(hwc_layer_1_t *layer, hwc_drm_bo_t *bo, DrmCrtc *crtc, |
| 58 | DrmPlane *plane); |
Sean Paul | 2e46fbd | 2015-07-09 17:22:22 -0400 | [diff] [blame^] | 59 | int AddPlaneDisable(DrmPlane *plane); |
Sean Paul | db7a17d | 2015-06-24 18:46:05 -0700 | [diff] [blame] | 60 | int AddDpmsMode(uint32_t dpms_mode); |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 61 | |
| 62 | int FinishComposition(); |
| 63 | |
| 64 | DrmCompositionLayerVector_t *GetCompositionLayers(); |
Sean Paul | db7a17d | 2015-06-24 18:46:05 -0700 | [diff] [blame] | 65 | uint32_t dpms_mode() const; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 66 | |
| 67 | private: |
| 68 | DrmDisplayComposition(const DrmDisplayComposition &) = delete; |
| 69 | |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 70 | bool validate_composition_type(DrmCompositionType desired); |
| 71 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 72 | DrmResources *drm_; |
| 73 | Importer *importer_; |
| 74 | |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 75 | DrmCompositionType type_; |
| 76 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 77 | int timeline_fd_; |
| 78 | int timeline_; |
| 79 | |
| 80 | DrmCompositionLayerVector_t layers_; |
Sean Paul | db7a17d | 2015-06-24 18:46:05 -0700 | [diff] [blame] | 81 | uint32_t dpms_mode_; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 82 | }; |
| 83 | } |
| 84 | |
| 85 | #endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_ |