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 &edid_property() const; 66 const DrmProperty &writeback_pixel_formats() const; 67 const DrmProperty &writeback_fb_id() const; 68 const DrmProperty &writeback_out_fence() const; 69 const DrmProperty &max_luminance() const; 70 const DrmProperty &max_avg_luminance() const; 71 const DrmProperty &min_luminance() const; 72 const DrmProperty &hdr_formats() const; 73 const DrmProperty &lp_mode() const; 74 const DrmProperty &brightness_cap() const; 75 const DrmProperty &brightness_level() const; 76 const DrmProperty &hbm_mode() const; 77 const DrmProperty &dimming_on() const; 78 const DrmProperty &lhbm_on() const; 79 const DrmProperty &sync_rr_switch() const; 80 properties()81 const std::vector<DrmProperty *> &properties() const { 82 return properties_; 83 } 84 possible_encoders()85 const std::vector<DrmEncoder *> &possible_encoders() const { 86 return possible_encoders_; 87 } 88 DrmEncoder *encoder() const; 89 void set_encoder(DrmEncoder *encoder); 90 91 drmModeConnection state() const; 92 93 uint32_t mm_width() const; 94 uint32_t mm_height() const; 95 get_preferred_mode_id()96 uint32_t get_preferred_mode_id() const { 97 return preferred_mode_id_; 98 } 99 100 private: 101 DrmDevice *drm_; 102 103 uint32_t id_; 104 DrmEncoder *encoder_; 105 int display_; 106 107 uint32_t type_; 108 uint32_t type_id_; 109 drmModeConnection state_; 110 111 uint32_t mm_width_; 112 uint32_t mm_height_; 113 114 DrmMode active_mode_; 115 std::vector<DrmMode> modes_; 116 117 DrmProperty dpms_property_; 118 DrmProperty crtc_id_property_; 119 DrmProperty edid_property_; 120 DrmProperty writeback_pixel_formats_; 121 DrmProperty writeback_fb_id_; 122 DrmProperty writeback_out_fence_; 123 DrmProperty max_luminance_; 124 DrmProperty max_avg_luminance_; 125 DrmProperty min_luminance_; 126 DrmProperty hdr_formats_; 127 DrmProperty lp_mode_; 128 DrmProperty brightness_cap_; 129 DrmProperty brightness_level_; 130 DrmProperty hbm_mode_; 131 DrmProperty dimming_on_; 132 DrmProperty lhbm_on_; 133 DrmProperty sync_rr_switch_; 134 std::vector<DrmProperty *> properties_; 135 136 std::vector<DrmEncoder *> possible_encoders_; 137 138 uint32_t preferred_mode_id_; 139 }; 140 } // namespace android 141 142 #endif // ANDROID_DRM_PLANE_H_ 143