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 | |
Zach Reizner | b44fd10 | 2015-08-07 16:00:01 -0700 | [diff] [blame^] | 26 | #include <hardware/gralloc.h> |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 27 | #include <hardware/hardware.h> |
| 28 | #include <hardware/hwcomposer.h> |
| 29 | |
| 30 | namespace android { |
| 31 | |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 32 | enum DrmCompositionType { |
| 33 | DRM_COMPOSITION_TYPE_EMPTY, |
| 34 | DRM_COMPOSITION_TYPE_FRAME, |
Sean Paul | db7a17d | 2015-06-24 18:46:05 -0700 | [diff] [blame] | 35 | DRM_COMPOSITION_TYPE_DPMS, |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 38 | typedef 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 Reizner | b44fd10 | 2015-08-07 16:00:01 -0700 | [diff] [blame^] | 46 | native_handle_t *handle; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 47 | } DrmCompositionLayer_t; |
| 48 | typedef std::vector<DrmCompositionLayer_t> DrmCompositionLayerVector_t; |
| 49 | |
| 50 | class DrmDisplayComposition { |
| 51 | public: |
| 52 | DrmDisplayComposition(); |
| 53 | ~DrmDisplayComposition(); |
| 54 | |
| 55 | int Init(DrmResources *drm, Importer *importer); |
| 56 | |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 57 | DrmCompositionType type() const; |
| 58 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 59 | int AddLayer(hwc_layer_1_t *layer, hwc_drm_bo_t *bo, DrmCrtc *crtc, |
| 60 | DrmPlane *plane); |
Zach Reizner | 713a678 | 2015-07-31 15:12:44 -0700 | [diff] [blame] | 61 | // 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 Paul | 2e46fbd | 2015-07-09 17:22:22 -0400 | [diff] [blame] | 64 | int AddPlaneDisable(DrmPlane *plane); |
Sean Paul | db7a17d | 2015-06-24 18:46:05 -0700 | [diff] [blame] | 65 | int AddDpmsMode(uint32_t dpms_mode); |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 66 | |
Zach Reizner | b44fd10 | 2015-08-07 16:00:01 -0700 | [diff] [blame^] | 67 | void RemoveNoPlaneLayers(); |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 68 | int FinishComposition(); |
| 69 | |
| 70 | DrmCompositionLayerVector_t *GetCompositionLayers(); |
Sean Paul | db7a17d | 2015-06-24 18:46:05 -0700 | [diff] [blame] | 71 | uint32_t dpms_mode() const; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 72 | |
Zach Reizner | 46ddd45 | 2015-07-30 08:10:14 -0700 | [diff] [blame] | 73 | Importer *importer() const; |
| 74 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 75 | private: |
| 76 | DrmDisplayComposition(const DrmDisplayComposition &) = delete; |
| 77 | |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 78 | bool validate_composition_type(DrmCompositionType desired); |
| 79 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 80 | DrmResources *drm_; |
| 81 | Importer *importer_; |
Zach Reizner | b44fd10 | 2015-08-07 16:00:01 -0700 | [diff] [blame^] | 82 | const gralloc_module_t *gralloc_; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 83 | |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 84 | DrmCompositionType type_; |
| 85 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 86 | int timeline_fd_; |
| 87 | int timeline_; |
Zach Reizner | ece0489 | 2015-07-17 14:13:28 -0700 | [diff] [blame] | 88 | int timeline_current_; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 89 | |
| 90 | DrmCompositionLayerVector_t layers_; |
Sean Paul | db7a17d | 2015-06-24 18:46:05 -0700 | [diff] [blame] | 91 | uint32_t dpms_mode_; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 92 | }; |
| 93 | } |
| 94 | |
| 95 | #endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_ |