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; |
Sean Paul | aa18d91 | 2016-05-12 14:28:05 -0400 | [diff] [blame] | 33 | class Planner; |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 34 | |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 35 | class DrmCompositionPlane { |
| 36 | public: |
| 37 | DrmCompositionPlane() = default; |
| 38 | DrmCompositionPlane(DrmCompositionPlane &&rhs) = default; |
| 39 | DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default; |
Roman Stratiienko | 67cebf5 | 2021-12-17 13:31:27 +0200 | [diff] [blame^] | 40 | DrmCompositionPlane(DrmPlane *plane) : plane_(plane) { |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 41 | } |
Roman Stratiienko | 67cebf5 | 2021-12-17 13:31:27 +0200 | [diff] [blame^] | 42 | DrmCompositionPlane(DrmPlane *plane, size_t source_layer) |
| 43 | : plane_(plane), source_layers_(1, source_layer) { |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | DrmPlane *plane() const { |
| 47 | return plane_; |
| 48 | } |
| 49 | void set_plane(DrmPlane *plane) { |
| 50 | plane_ = plane; |
| 51 | } |
| 52 | |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 53 | std::vector<size_t> &source_layers() { |
| 54 | return source_layers_; |
| 55 | } |
| 56 | |
| 57 | const std::vector<size_t> &source_layers() const { |
| 58 | return source_layers_; |
| 59 | } |
| 60 | |
| 61 | private: |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 62 | DrmPlane *plane_ = NULL; |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 63 | std::vector<size_t> source_layers_; |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 64 | }; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 65 | |
| 66 | class DrmDisplayComposition { |
| 67 | public: |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 68 | DrmDisplayComposition(const DrmDisplayComposition &) = delete; |
Matvii Zorin | 704ea0e | 2021-01-08 12:55:45 +0200 | [diff] [blame] | 69 | DrmDisplayComposition(DrmCrtc *crtc, Planner *planner); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 70 | ~DrmDisplayComposition() = default; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 71 | |
Roman Stratiienko | 36a7f28 | 2021-10-05 18:17:53 +0300 | [diff] [blame] | 72 | int SetLayers(DrmHwcLayer *layers, size_t num_layers); |
Sean Paul | 4f4ef69 | 2016-05-03 16:40:59 -0700 | [diff] [blame] | 73 | int AddPlaneComposition(DrmCompositionPlane plane); |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 74 | |
Rob Herring | af0d975 | 2018-05-04 16:34:19 -0500 | [diff] [blame] | 75 | int Plan(std::vector<DrmPlane *> *primary_planes, |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 76 | std::vector<DrmPlane *> *overlay_planes); |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 77 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 78 | std::vector<DrmHwcLayer> &layers() { |
| 79 | return layers_; |
| 80 | } |
| 81 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 82 | std::vector<DrmCompositionPlane> &composition_planes() { |
| 83 | return composition_planes_; |
| 84 | } |
| 85 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 86 | DrmCrtc *crtc() const { |
| 87 | return crtc_; |
| 88 | } |
| 89 | |
Sean Paul | aa18d91 | 2016-05-12 14:28:05 -0400 | [diff] [blame] | 90 | Planner *planner() const { |
| 91 | return planner_; |
| 92 | } |
| 93 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 94 | private: |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 95 | DrmCrtc *crtc_ = NULL; |
Sean Paul | aa18d91 | 2016-05-12 14:28:05 -0400 | [diff] [blame] | 96 | Planner *planner_ = NULL; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 97 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 98 | std::vector<DrmHwcLayer> layers_; |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 99 | std::vector<DrmCompositionPlane> composition_planes_; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 100 | }; |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 101 | } // namespace android |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 102 | |
| 103 | #endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_ |