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 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 17 | #include "DrmEncoder.h" |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 18 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 19 | #include <xf86drmMode.h> |
| 20 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame^] | 21 | #include <cstdint> |
| 22 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 23 | #include "DrmDevice.h" |
| 24 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 25 | namespace android { |
| 26 | |
| 27 | DrmEncoder::DrmEncoder(drmModeEncoderPtr e, DrmCrtc *current_crtc, |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame^] | 28 | std::vector<DrmCrtc *> possible_crtcs) |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 29 | : id_(e->encoder_id), |
| 30 | crtc_(current_crtc), |
Alexandru Gheorghe | ae4324c | 2018-03-21 12:06:20 +0000 | [diff] [blame] | 31 | display_(-1), |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame^] | 32 | possible_crtcs_(std::move(possible_crtcs)) { |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 33 | } |
| 34 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 35 | uint32_t DrmEncoder::id() const { |
| 36 | return id_; |
| 37 | } |
| 38 | |
| 39 | DrmCrtc *DrmEncoder::crtc() const { |
| 40 | return crtc_; |
| 41 | } |
| 42 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame^] | 43 | bool DrmEncoder::CanClone(DrmEncoder *encoder) { |
| 44 | return possible_clones_.find(encoder) != possible_clones_.end(); |
Alexandru Gheorghe | e8b668c | 2018-03-22 11:31:29 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void DrmEncoder::AddPossibleClone(DrmEncoder *possible_clone) { |
| 48 | possible_clones_.insert(possible_clone); |
| 49 | } |
| 50 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 51 | void DrmEncoder::set_crtc(DrmCrtc *crtc) { |
| 52 | crtc_ = crtc; |
Alexandru Gheorghe | ae4324c | 2018-03-21 12:06:20 +0000 | [diff] [blame] | 53 | display_ = crtc->display(); |
| 54 | } |
| 55 | |
| 56 | int DrmEncoder::display() const { |
| 57 | return display_; |
| 58 | } |
| 59 | |
| 60 | bool DrmEncoder::can_bind(int display) const { |
| 61 | return display_ == -1 || display_ == display; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 62 | } |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 63 | } // namespace android |