• 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 #include <mutex>
29 
30 namespace android {
31 
32 class DrmDevice;
33 
34 class DrmConnector {
35  public:
36   DrmConnector(DrmDevice *drm, drmModeConnectorPtr c,
37                DrmEncoder *current_encoder,
38                std::vector<DrmEncoder *> &possible_encoders);
39   DrmConnector(const DrmProperty &) = delete;
40   DrmConnector &operator=(const DrmProperty &) = delete;
41 
42   int Init();
43 
44   uint32_t id() const;
45 
46   int display() const;
47   void set_display(int display);
48 
49   bool internal() const;
50   bool external() const;
51   bool writeback() const;
52   bool valid_type() const;
53 
54   std::string name() const;
55 
56   int UpdateModes(bool is_vrr_mode = false);
57   int UpdateEdidProperty();
58   int UpdateLuminanceAndHdrProperties();
59 
modes()60   const std::vector<DrmMode> &modes() const {
61     return modes_;
62   }
modesLock()63   std::recursive_mutex &modesLock() {
64     return modes_lock_;
65   }
66   const DrmMode &active_mode() const;
67   void set_active_mode(const DrmMode &mode);
68 
69   int ResetLpMode();
70   const DrmMode &lp_mode() const;
71 
72   const DrmProperty &dpms_property() const;
73   const DrmProperty &crtc_id_property() const;
74   const DrmProperty &edid_property() const;
75   const DrmProperty &writeback_pixel_formats() const;
76   const DrmProperty &writeback_fb_id() const;
77   const DrmProperty &writeback_out_fence() const;
78   const DrmProperty &max_luminance() const;
79   const DrmProperty &max_avg_luminance() const;
80   const DrmProperty &min_luminance() const;
81   const DrmProperty &hdr_formats() const;
82   const DrmProperty &orientation() const;
83   const DrmProperty &brightness_cap() const;
84   const DrmProperty &brightness_level() const;
85   const DrmProperty &hbm_mode() const;
86   const DrmProperty &dimming_on() const;
87   const DrmProperty &lhbm_on() const;
88   const DrmProperty &mipi_sync() const;
89   const DrmProperty &panel_idle_support() const;
90   const DrmProperty &rr_switch_duration() const;
91   const DrmProperty &operation_rate() const;
92   const DrmProperty &refresh_on_lp() const;
93   const DrmProperty &content_protection() const;
94 
properties()95   const std::vector<DrmProperty *> &properties() const {
96       return properties_;
97   }
98 
possible_encoders()99   const std::vector<DrmEncoder *> &possible_encoders() const {
100     return possible_encoders_;
101   }
102   DrmEncoder *encoder() const;
103   void set_encoder(DrmEncoder *encoder);
104 
105   drmModeConnection state() const;
106 
107   uint32_t mm_width() const;
108   uint32_t mm_height() const;
109 
get_preferred_mode_id()110   uint32_t get_preferred_mode_id() const {
111     return preferred_mode_id_;
112   }
113 
114  private:
115   DrmDevice *drm_;
116 
117   uint32_t id_;
118   DrmEncoder *encoder_;
119   int display_;
120 
121   uint32_t type_;
122   uint32_t type_id_;
123   drmModeConnection state_;
124 
125   uint32_t mm_width_;
126   uint32_t mm_height_;
127 
128   DrmMode active_mode_;
129   std::vector<DrmMode> modes_;
130   std::recursive_mutex modes_lock_;
131   DrmMode lp_mode_;
132 
133   DrmProperty dpms_property_;
134   DrmProperty crtc_id_property_;
135   DrmProperty edid_property_;
136   DrmProperty writeback_pixel_formats_;
137   DrmProperty writeback_fb_id_;
138   DrmProperty writeback_out_fence_;
139   DrmProperty max_luminance_;
140   DrmProperty max_avg_luminance_;
141   DrmProperty min_luminance_;
142   DrmProperty hdr_formats_;
143   DrmProperty orientation_;
144   DrmProperty lp_mode_property_;
145   DrmProperty brightness_cap_;
146   DrmProperty brightness_level_;
147   DrmProperty hbm_mode_;
148   DrmProperty dimming_on_;
149   DrmProperty lhbm_on_;
150   DrmProperty mipi_sync_;
151   DrmProperty panel_idle_support_;
152   DrmProperty rr_switch_duration_;
153   DrmProperty operation_rate_;
154   DrmProperty refresh_on_lp_;
155   DrmProperty content_protection_;
156   std::vector<DrmProperty *> properties_;
157 
158   std::vector<DrmEncoder *> possible_encoders_;
159 
160   uint32_t preferred_mode_id_;
161 
162   int UpdateLpMode();
163 };
164 }  // namespace android
165 
166 #endif  // ANDROID_DRM_PLANE_H_
167