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_ENCODER_H_ |
| 18 | #define ANDROID_DRM_ENCODER_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 | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 23 | #include <set> |
| 24 | #include <vector> |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 25 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 26 | #include "DrmCrtc.h" |
Roman Stratiienko | cad8e0c | 2022-01-31 16:40:16 +0200 | [diff] [blame^] | 27 | #include "DrmDisplayPipeline.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 | |
Roman Stratiienko | cad8e0c | 2022-01-31 16:40:16 +0200 | [diff] [blame^] | 31 | class DrmEncoder : public PipelineBindable<DrmEncoder> { |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 32 | public: |
Roman Stratiienko | 027987b | 2022-01-30 21:06:35 +0200 | [diff] [blame] | 33 | static auto CreateInstance(DrmDevice &dev, uint32_t encoder_id, |
| 34 | uint32_t index) -> std::unique_ptr<DrmEncoder>; |
| 35 | |
Zach Reizner | ff30b52 | 2015-10-28 19:08:45 -0700 | [diff] [blame] | 36 | DrmEncoder(const DrmEncoder &) = delete; |
| 37 | DrmEncoder &operator=(const DrmEncoder &) = delete; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 38 | |
Roman Stratiienko | 027987b | 2022-01-30 21:06:35 +0200 | [diff] [blame] | 39 | auto GetId() const { |
| 40 | return enc_->encoder_id; |
| 41 | }; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 42 | |
Roman Stratiienko | 027987b | 2022-01-30 21:06:35 +0200 | [diff] [blame] | 43 | auto GetIndexInResArray() const { |
| 44 | return index_in_res_array_; |
Zach Reizner | ff30b52 | 2015-10-28 19:08:45 -0700 | [diff] [blame] | 45 | } |
Roman Stratiienko | 027987b | 2022-01-30 21:06:35 +0200 | [diff] [blame] | 46 | |
| 47 | auto CanClone(DrmEncoder &encoder) { |
| 48 | return (enc_->possible_clones & (1 << encoder.GetIndexInResArray())) != 0; |
| 49 | } |
| 50 | |
| 51 | auto SupportsCrtc(DrmCrtc &crtc) { |
| 52 | return (enc_->possible_crtcs & (1 << crtc.GetIndexInResArray())) != 0; |
| 53 | } |
| 54 | |
| 55 | auto GetCurrentCrtcId() { |
| 56 | return enc_->crtc_id; |
| 57 | } |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 58 | |
| 59 | private: |
Roman Stratiienko | 027987b | 2022-01-30 21:06:35 +0200 | [diff] [blame] | 60 | DrmEncoder(DrmModeEncoderUnique enc, uint32_t index) |
| 61 | : enc_(std::move(enc)), index_in_res_array_(index){}; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 62 | |
Roman Stratiienko | 027987b | 2022-01-30 21:06:35 +0200 | [diff] [blame] | 63 | DrmModeEncoderUnique enc_; |
| 64 | |
| 65 | const uint32_t index_in_res_array_; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 66 | }; |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 67 | } // namespace android |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 68 | |
| 69 | #endif // ANDROID_DRM_ENCODER_H_ |