• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 #include <xf86drmMode.h>
21 
22 #include <cstdint>
23 #include <set>
24 #include <vector>
25 
26 #include "DrmCrtc.h"
27 #include "DrmDisplayPipeline.h"
28 
29 namespace android {
30 
31 class DrmEncoder : public PipelineBindable<DrmEncoder> {
32  public:
33   static auto CreateInstance(DrmDevice &dev, uint32_t encoder_id,
34                              uint32_t index) -> std::unique_ptr<DrmEncoder>;
35 
36   DrmEncoder(const DrmEncoder &) = delete;
37   DrmEncoder &operator=(const DrmEncoder &) = delete;
38 
GetId()39   auto GetId() const {
40     return enc_->encoder_id;
41   };
42 
GetIndexInResArray()43   auto GetIndexInResArray() const {
44     return index_in_res_array_;
45   }
46 
CanClone(DrmEncoder & encoder)47   auto CanClone(DrmEncoder &encoder) {
48     return (enc_->possible_clones & (1 << encoder.GetIndexInResArray())) != 0;
49   }
50 
SupportsCrtc(DrmCrtc & crtc)51   auto SupportsCrtc(DrmCrtc &crtc) {
52     return (enc_->possible_crtcs & (1 << crtc.GetIndexInResArray())) != 0;
53   }
54 
GetCurrentCrtcId()55   auto GetCurrentCrtcId() {
56     return enc_->crtc_id;
57   }
58 
59  private:
DrmEncoder(DrmModeEncoderUnique enc,uint32_t index)60   DrmEncoder(DrmModeEncoderUnique enc, uint32_t index)
61       : enc_(std::move(enc)), index_in_res_array_(index){};
62 
63   DrmModeEncoderUnique enc_;
64 
65   const uint32_t index_in_res_array_;
66 };
67 }  // namespace android
68 
69 #endif  // ANDROID_DRM_ENCODER_H_
70