blob: c26a3cc1ef6c3a50396d9d8390114cb79377b40a [file] [log] [blame]
Sean Paul6a55e9f2015-04-30 15:31:06 -04001/*
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
Roman Stratiienkobde95662022-12-10 20:27:58 +020017#pragma once
Sean Paul6a55e9f2015-04-30 15:31:06 -040018
Sean Paul6a55e9f2015-04-30 15:31:06 -040019#include <xf86drmMode.h>
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030020
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020021#include <cstdint>
Sean Paul6a55e9f2015-04-30 15:31:06 -040022#include <vector>
23
Roman Stratiienko13cc3662020-08-29 21:35:39 +030024#include "DrmCrtc.h"
25#include "DrmProperty.h"
Roman Stratiienko4b2cc482022-02-21 14:53:58 +020026#include "compositor/LayerData.h"
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030027
Sean Paul6a55e9f2015-04-30 15:31:06 -040028namespace android {
29
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010030class DrmDevice;
Roman Stratiienko4b2cc482022-02-21 14:53:58 +020031struct LayerData;
Sean Paul6a55e9f2015-04-30 15:31:06 -040032
Roman Stratiienkocad8e0c2022-01-31 16:40:16 +020033class DrmPlane : public PipelineBindable<DrmPlane> {
Sean Paul6a55e9f2015-04-30 15:31:06 -040034 public:
Zach Reiznerff30b522015-10-28 19:08:45 -070035 DrmPlane(const DrmPlane &) = delete;
36 DrmPlane &operator=(const DrmPlane &) = delete;
Sean Paul6a55e9f2015-04-30 15:31:06 -040037
Roman Stratiienkob671fab2022-01-29 00:50:22 +020038 static auto CreateInstance(DrmDevice &dev, uint32_t plane_id)
39 -> std::unique_ptr<DrmPlane>;
Sean Paul6a55e9f2015-04-30 15:31:06 -040040
Roman Stratiienkob671fab2022-01-29 00:50:22 +020041 bool IsCrtcSupported(const DrmCrtc &crtc) const;
Roman Stratiienko4b2cc482022-02-21 14:53:58 +020042 bool IsValidForLayer(LayerData *layer);
Sean Paul6a55e9f2015-04-30 15:31:06 -040043
Roman Stratiienkob671fab2022-01-29 00:50:22 +020044 auto GetType() const {
45 return type_;
46 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040047
Roman Kovalivskyi859b6072020-03-26 05:03:39 +020048 bool IsFormatSupported(uint32_t format) const;
Matvii Zorin8338c342020-09-08 16:12:51 +030049 bool HasNonRgbFormat() const;
Roman Kovalivskyi859b6072020-03-26 05:03:39 +020050
Roman Stratiienko4b2cc482022-02-21 14:53:58 +020051 auto AtomicSetState(drmModeAtomicReq &pset, LayerData &layer, uint32_t zpos,
Roman Stratiienko0dbe6392021-09-29 12:47:16 +030052 uint32_t crtc_id) -> int;
53 auto AtomicDisablePlane(drmModeAtomicReq &pset) -> int;
Roman Stratiienkob671fab2022-01-29 00:50:22 +020054 auto &GetZPosProperty() const {
55 return zpos_property_;
56 }
57
58 auto GetId() const {
59 return plane_->plane_id;
60 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040061
62 private:
Roman Stratiienkob671fab2022-01-29 00:50:22 +020063 DrmPlane(DrmDevice &dev, DrmModePlaneUnique plane)
64 : drm_(&dev), plane_(std::move(plane)){};
65 DrmDevice *const drm_;
66 DrmModePlaneUnique plane_;
Sean Paul6a55e9f2015-04-30 15:31:06 -040067
Roman Stratiienko0b063882021-09-30 10:15:05 +030068 enum class Presence { kOptional, kMandatory };
69
Roman Stratiienkob671fab2022-01-29 00:50:22 +020070 auto Init() -> int;
Roman Stratiienko0b063882021-09-30 10:15:05 +030071 auto GetPlaneProperty(const char *prop_name, DrmProperty &property,
72 Presence presence = Presence::kMandatory) -> bool;
73
Roman Stratiienkob3b5c1e2021-02-15 13:44:19 +020074 uint32_t type_{};
Sean Paul6a55e9f2015-04-30 15:31:06 -040075
Roman Kovalivskyi859b6072020-03-26 05:03:39 +020076 std::vector<uint32_t> formats_;
77
Sean Paul6a55e9f2015-04-30 15:31:06 -040078 DrmProperty crtc_property_;
79 DrmProperty fb_property_;
80 DrmProperty crtc_x_property_;
81 DrmProperty crtc_y_property_;
82 DrmProperty crtc_w_property_;
83 DrmProperty crtc_h_property_;
84 DrmProperty src_x_property_;
85 DrmProperty src_y_property_;
86 DrmProperty src_w_property_;
87 DrmProperty src_h_property_;
Alexandru Gheorgheea1c5e52018-09-17 10:48:54 +010088 DrmProperty zpos_property_;
Sean Paul1c4c3262015-07-14 15:51:52 -040089 DrmProperty rotation_property_;
Sean Pauld8aefb62015-10-15 15:17:31 -040090 DrmProperty alpha_property_;
Lowry Li9b6cafd2018-08-28 17:58:21 +080091 DrmProperty blend_property_;
Robert Fossa09220c2016-09-30 10:27:23 -040092 DrmProperty in_fence_fd_property_;
Matvii Zorin8338c342020-09-08 16:12:51 +030093 DrmProperty color_encoding_propery_;
94 DrmProperty color_range_property_;
Roman Stratiienko4f1effa2021-09-29 12:47:26 +030095
Roman Stratiienko4b2cc482022-02-21 14:53:58 +020096 std::map<BufferBlendMode, uint64_t> blending_enum_map_;
97 std::map<BufferColorSpace, uint64_t> color_encoding_enum_map_;
98 std::map<BufferSampleRange, uint64_t> color_range_enum_map_;
99 std::map<LayerTransform, uint64_t> transform_enum_map_;
Sean Paul6a55e9f2015-04-30 15:31:06 -0400100};
Sean Paulf72cccd2018-08-27 13:59:08 -0400101} // namespace android