blob: 89e664cc46a8a4cd6eee9d5291c249e55d6218a4 [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 Paulf72cccd2018-08-27 13:59:08 -040022#include <set>
23#include <vector>
Sean Paul6a55e9f2015-04-30 15:31:06 -040024
Roman Stratiienko13cc3662020-08-29 21:35:39 +030025#include "DrmCrtc.h"
Roman Stratiienkocad8e0c2022-01-31 16:40:16 +020026#include "DrmDisplayPipeline.h"
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030027
Sean Paul6a55e9f2015-04-30 15:31:06 -040028namespace android {
29
Roman Stratiienkocad8e0c2022-01-31 16:40:16 +020030class DrmEncoder : public PipelineBindable<DrmEncoder> {
Sean Paul6a55e9f2015-04-30 15:31:06 -040031 public:
Roman Stratiienko027987b2022-01-30 21:06:35 +020032 static auto CreateInstance(DrmDevice &dev, uint32_t encoder_id,
33 uint32_t index) -> std::unique_ptr<DrmEncoder>;
34
Zach Reiznerff30b522015-10-28 19:08:45 -070035 DrmEncoder(const DrmEncoder &) = delete;
36 DrmEncoder &operator=(const DrmEncoder &) = delete;
Sean Paul6a55e9f2015-04-30 15:31:06 -040037
Roman Stratiienko027987b2022-01-30 21:06:35 +020038 auto GetId() const {
39 return enc_->encoder_id;
40 };
Sean Paul6a55e9f2015-04-30 15:31:06 -040041
Roman Stratiienko027987b2022-01-30 21:06:35 +020042 auto GetIndexInResArray() const {
43 return index_in_res_array_;
Zach Reiznerff30b522015-10-28 19:08:45 -070044 }
Roman Stratiienko027987b2022-01-30 21:06:35 +020045
46 auto CanClone(DrmEncoder &encoder) {
47 return (enc_->possible_clones & (1 << encoder.GetIndexInResArray())) != 0;
48 }
49
50 auto SupportsCrtc(DrmCrtc &crtc) {
51 return (enc_->possible_crtcs & (1 << crtc.GetIndexInResArray())) != 0;
52 }
53
54 auto GetCurrentCrtcId() {
55 return enc_->crtc_id;
56 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040057
58 private:
Roman Stratiienko027987b2022-01-30 21:06:35 +020059 DrmEncoder(DrmModeEncoderUnique enc, uint32_t index)
60 : enc_(std::move(enc)), index_in_res_array_(index){};
Sean Paul6a55e9f2015-04-30 15:31:06 -040061
Roman Stratiienko027987b2022-01-30 21:06:35 +020062 DrmModeEncoderUnique enc_;
63
64 const uint32_t index_in_res_array_;
Sean Paul6a55e9f2015-04-30 15:31:06 -040065};
Sean Paulf72cccd2018-08-27 13:59:08 -040066} // namespace android