• 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_CONNECTOR_H_
18 #define ANDROID_DRM_CONNECTOR_H_
19 
20 #include "drmencoder.h"
21 #include "drmmode.h"
22 #include "drmproperty.h"
23 
24 #include <stdint.h>
25 #include <xf86drmMode.h>
26 #include <string>
27 #include <vector>
28 
29 namespace android {
30 
31 class DrmDevice;
32 
33 class DrmConnector {
34  public:
35   DrmConnector(DrmDevice *drm, drmModeConnectorPtr c,
36                DrmEncoder *current_encoder,
37                std::vector<DrmEncoder *> &possible_encoders);
38   DrmConnector(const DrmProperty &) = delete;
39   DrmConnector &operator=(const DrmProperty &) = delete;
40 
41   int Init();
42 
43   uint32_t id() const;
44 
45   int display() const;
46   void set_display(int display);
47 
48   bool internal() const;
49   bool external() const;
50   bool writeback() const;
51   bool valid_type() const;
52 
53   std::string name() const;
54 
55   int UpdateModes();
56 
modes()57   const std::vector<DrmMode> &modes() const {
58     return modes_;
59   }
60   const DrmMode &active_mode() const;
61   void set_active_mode(const DrmMode &mode);
62 
63   const DrmProperty &dpms_property() const;
64   const DrmProperty &crtc_id_property() const;
65   const DrmProperty &writeback_pixel_formats() const;
66   const DrmProperty &writeback_fb_id() const;
67   const DrmProperty &writeback_out_fence() const;
68 
possible_encoders()69   const std::vector<DrmEncoder *> &possible_encoders() const {
70     return possible_encoders_;
71   }
72   DrmEncoder *encoder() const;
73   void set_encoder(DrmEncoder *encoder);
74 
75   drmModeConnection state() const;
76 
77   uint32_t mm_width() const;
78   uint32_t mm_height() const;
79 
get_preferred_mode_id()80   uint32_t get_preferred_mode_id() const {
81     return preferred_mode_id_;
82   }
83 
84  private:
85   DrmDevice *drm_;
86 
87   uint32_t id_;
88   DrmEncoder *encoder_;
89   int display_;
90 
91   uint32_t type_;
92   uint32_t type_id_;
93   drmModeConnection state_;
94 
95   uint32_t mm_width_;
96   uint32_t mm_height_;
97 
98   DrmMode active_mode_;
99   std::vector<DrmMode> modes_;
100 
101   DrmProperty dpms_property_;
102   DrmProperty crtc_id_property_;
103   DrmProperty writeback_pixel_formats_;
104   DrmProperty writeback_fb_id_;
105   DrmProperty writeback_out_fence_;
106 
107   std::vector<DrmEncoder *> possible_encoders_;
108 
109   uint32_t preferred_mode_id_;
110 };
111 }  // namespace android
112 
113 #endif  // ANDROID_DRM_PLANE_H_
114