Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [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_PLANE_H_ |
| 18 | #define ANDROID_DRM_PLANE_H_ |
| 19 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 20 | #include <xf86drmMode.h> |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 21 | |
Roman Stratiienko | e78235c | 2021-12-23 17:36:12 +0200 | [diff] [blame^] | 22 | #include <cstdint> |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 23 | #include <vector> |
| 24 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 25 | #include "DrmCrtc.h" |
| 26 | #include "DrmProperty.h" |
Matvii Zorin | 67a89d3 | 2021-01-31 14:45:05 +0200 | [diff] [blame] | 27 | #include "drmhwcomposer.h" |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 28 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 29 | namespace android { |
| 30 | |
Alexandru Gheorghe | 0f5abd7 | 2018-05-01 14:37:10 +0100 | [diff] [blame] | 31 | class DrmDevice; |
Roman Stratiienko | 24a7fc4 | 2021-12-23 16:25:20 +0200 | [diff] [blame] | 32 | struct DrmHwcLayer; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 33 | |
| 34 | class DrmPlane { |
| 35 | public: |
Alexandru Gheorghe | 0f5abd7 | 2018-05-01 14:37:10 +0100 | [diff] [blame] | 36 | DrmPlane(DrmDevice *drm, drmModePlanePtr p); |
Zach Reizner | ff30b52 | 2015-10-28 19:08:45 -0700 | [diff] [blame] | 37 | DrmPlane(const DrmPlane &) = delete; |
| 38 | DrmPlane &operator=(const DrmPlane &) = delete; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 39 | |
| 40 | int Init(); |
| 41 | |
| 42 | uint32_t id() const; |
| 43 | |
| 44 | bool GetCrtcSupported(const DrmCrtc &crtc) const; |
Matvii Zorin | 67a89d3 | 2021-01-31 14:45:05 +0200 | [diff] [blame] | 45 | bool IsValidForLayer(DrmHwcLayer *layer); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 46 | |
| 47 | uint32_t type() const; |
| 48 | |
Roman Kovalivskyi | 859b607 | 2020-03-26 05:03:39 +0200 | [diff] [blame] | 49 | bool IsFormatSupported(uint32_t format) const; |
Matvii Zorin | 8338c34 | 2020-09-08 16:12:51 +0300 | [diff] [blame] | 50 | bool HasNonRgbFormat() const; |
Roman Kovalivskyi | 859b607 | 2020-03-26 05:03:39 +0200 | [diff] [blame] | 51 | |
Roman Stratiienko | 0dbe639 | 2021-09-29 12:47:16 +0300 | [diff] [blame] | 52 | auto AtomicSetState(drmModeAtomicReq &pset, DrmHwcLayer &layer, uint32_t zpos, |
| 53 | uint32_t crtc_id) -> int; |
| 54 | auto AtomicDisablePlane(drmModeAtomicReq &pset) -> int; |
Alexandru Gheorghe | ea1c5e5 | 2018-09-17 10:48:54 +0100 | [diff] [blame] | 55 | const DrmProperty &zpos_property() const; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 56 | |
| 57 | private: |
Alexandru Gheorghe | 0f5abd7 | 2018-05-01 14:37:10 +0100 | [diff] [blame] | 58 | DrmDevice *drm_; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 59 | uint32_t id_; |
| 60 | |
Roman Stratiienko | 0b06388 | 2021-09-30 10:15:05 +0300 | [diff] [blame] | 61 | enum class Presence { kOptional, kMandatory }; |
| 62 | |
| 63 | auto GetPlaneProperty(const char *prop_name, DrmProperty &property, |
| 64 | Presence presence = Presence::kMandatory) -> bool; |
| 65 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 66 | uint32_t possible_crtc_mask_; |
| 67 | |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame] | 68 | uint32_t type_{}; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 69 | |
Roman Kovalivskyi | 859b607 | 2020-03-26 05:03:39 +0200 | [diff] [blame] | 70 | std::vector<uint32_t> formats_; |
| 71 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 72 | DrmProperty crtc_property_; |
| 73 | DrmProperty fb_property_; |
| 74 | DrmProperty crtc_x_property_; |
| 75 | DrmProperty crtc_y_property_; |
| 76 | DrmProperty crtc_w_property_; |
| 77 | DrmProperty crtc_h_property_; |
| 78 | DrmProperty src_x_property_; |
| 79 | DrmProperty src_y_property_; |
| 80 | DrmProperty src_w_property_; |
| 81 | DrmProperty src_h_property_; |
Alexandru Gheorghe | ea1c5e5 | 2018-09-17 10:48:54 +0100 | [diff] [blame] | 82 | DrmProperty zpos_property_; |
Sean Paul | 1c4c326 | 2015-07-14 15:51:52 -0400 | [diff] [blame] | 83 | DrmProperty rotation_property_; |
Sean Paul | d8aefb6 | 2015-10-15 15:17:31 -0400 | [diff] [blame] | 84 | DrmProperty alpha_property_; |
Lowry Li | 9b6cafd | 2018-08-28 17:58:21 +0800 | [diff] [blame] | 85 | DrmProperty blend_property_; |
Robert Foss | a09220c | 2016-09-30 10:27:23 -0400 | [diff] [blame] | 86 | DrmProperty in_fence_fd_property_; |
Matvii Zorin | 8338c34 | 2020-09-08 16:12:51 +0300 | [diff] [blame] | 87 | DrmProperty color_encoding_propery_; |
| 88 | DrmProperty color_range_property_; |
Roman Stratiienko | 4f1effa | 2021-09-29 12:47:26 +0300 | [diff] [blame] | 89 | |
Roman Stratiienko | 5063d53 | 2021-09-29 12:47:31 +0300 | [diff] [blame] | 90 | std::map<DrmHwcBlending, uint64_t> blending_enum_map_; |
Roman Stratiienko | 4f1effa | 2021-09-29 12:47:26 +0300 | [diff] [blame] | 91 | std::map<DrmHwcColorSpace, uint64_t> color_encoding_enum_map_; |
| 92 | std::map<DrmHwcSampleRange, uint64_t> color_range_enum_map_; |
Roman Stratiienko | 24a4c18 | 2021-09-29 12:59:54 +0300 | [diff] [blame] | 93 | std::map<DrmHwcTransform, uint64_t> transform_enum_map_; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 94 | }; |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 95 | } // namespace android |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 96 | |
| 97 | #endif // ANDROID_DRM_PLANE_H_ |