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 | |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 20 | #include <hardware/hardware.h> |
| 21 | #include <hardware/hwcomposer.h> |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 22 | |
Zach Reizner | fd6dc33 | 2015-10-13 21:12:48 -0700 | [diff] [blame] | 23 | #include <sstream> |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 24 | #include <vector> |
| 25 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 26 | #include "drm/DrmCrtc.h" |
| 27 | #include "drm/DrmPlane.h" |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 28 | #include "drmhwcomposer.h" |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | |
Sean Paul | 4c4646e | 2016-05-10 04:19:24 -0400 | [diff] [blame] | 32 | class Importer; |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 33 | |
Roman Stratiienko | 5d1f557 | 2021-12-17 15:09:28 +0200 | [diff] [blame] | 34 | constexpr size_t kUndefinedSourceLayer = UINT16_MAX; |
| 35 | |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 36 | class DrmCompositionPlane { |
| 37 | public: |
| 38 | DrmCompositionPlane() = default; |
| 39 | DrmCompositionPlane(DrmCompositionPlane &&rhs) = default; |
| 40 | DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default; |
Roman Stratiienko | 67cebf5 | 2021-12-17 13:31:27 +0200 | [diff] [blame] | 41 | DrmCompositionPlane(DrmPlane *plane, size_t source_layer) |
Roman Stratiienko | 5d1f557 | 2021-12-17 15:09:28 +0200 | [diff] [blame] | 42 | : plane_(plane), source_layer_(source_layer) { |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | DrmPlane *plane() const { |
| 46 | return plane_; |
| 47 | } |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 48 | |
Roman Stratiienko | 5d1f557 | 2021-12-17 15:09:28 +0200 | [diff] [blame] | 49 | size_t source_layer() const { |
| 50 | return source_layer_; |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | private: |
Roman Stratiienko | e78235c | 2021-12-23 17:36:12 +0200 | [diff] [blame] | 54 | DrmPlane *plane_ = nullptr; |
Roman Stratiienko | 5d1f557 | 2021-12-17 15:09:28 +0200 | [diff] [blame] | 55 | size_t source_layer_ = kUndefinedSourceLayer; |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 56 | }; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 57 | |
| 58 | class DrmDisplayComposition { |
| 59 | public: |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 60 | DrmDisplayComposition(const DrmDisplayComposition &) = delete; |
Roman Stratiienko | 753d107 | 2021-12-30 18:05:27 +0200 | [diff] [blame] | 61 | explicit DrmDisplayComposition(DrmCrtc *crtc); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 62 | ~DrmDisplayComposition() = default; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 63 | |
Roman Stratiienko | 36a7f28 | 2021-10-05 18:17:53 +0300 | [diff] [blame] | 64 | int SetLayers(DrmHwcLayer *layers, size_t num_layers); |
Sean Paul | 4f4ef69 | 2016-05-03 16:40:59 -0700 | [diff] [blame] | 65 | int AddPlaneComposition(DrmCompositionPlane plane); |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 66 | |
Rob Herring | af0d975 | 2018-05-04 16:34:19 -0500 | [diff] [blame] | 67 | int Plan(std::vector<DrmPlane *> *primary_planes, |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 68 | std::vector<DrmPlane *> *overlay_planes); |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 69 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 70 | std::vector<DrmHwcLayer> &layers() { |
| 71 | return layers_; |
| 72 | } |
| 73 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 74 | std::vector<DrmCompositionPlane> &composition_planes() { |
| 75 | return composition_planes_; |
| 76 | } |
| 77 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 78 | DrmCrtc *crtc() const { |
| 79 | return crtc_; |
| 80 | } |
| 81 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 82 | private: |
Roman Stratiienko | e78235c | 2021-12-23 17:36:12 +0200 | [diff] [blame] | 83 | DrmCrtc *crtc_ = nullptr; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 84 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 85 | std::vector<DrmHwcLayer> layers_; |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 86 | std::vector<DrmCompositionPlane> composition_planes_; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 87 | }; |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 88 | } // namespace android |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 89 | |
| 90 | #endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_ |