1 /* 2 * Copyright (c) 2014 - 2016, 2018 - 2019 The Linux Foundation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer in the documentation and/or other materials provided 12 * with the distribution. 13 * * Neither the name of The Linux Foundation nor the names of its 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 /*! @file core_interface.h 31 @brief Interface file for core of the display subsystem. 32 33 @details Display core is primarily used for loading and unloading different display device 34 components viz primary, external and virtual. Display core is a statically linked library which 35 runs in caller's process context. 36 */ 37 #ifndef __CORE_INTERFACE_H__ 38 #define __CORE_INTERFACE_H__ 39 40 #include <stdint.h> 41 #include <map> 42 #include <vector> 43 44 #include "display_interface.h" 45 #include "sdm_types.h" 46 #include "buffer_allocator.h" 47 #include "buffer_sync_handler.h" 48 #include "socket_handler.h" 49 50 /*! @brief Display manager interface version. 51 52 @details Display manager interfaces are version tagged to maintain backward compatibility. This 53 version is supplied as a default argument during display core initialization. 54 55 Client may use an older version of interfaces and link to a higher version of display manager 56 library, but vice versa is not allowed. 57 58 A 32-bit client must use 32-bit display core library and a 64-bit client must use 64-bit display 59 core library. 60 61 Display manager interfaces follow default data structures alignment. Client must not override the 62 default padding rules while using these interfaces. 63 64 @warning It is assumed that client upgrades or downgrades display core interface all at once 65 and recompile all binaries which use these interfaces. Mix and match of these interfaces can 66 lead to unpredictable behaviour. 67 68 @sa CoreInterface::CreateCore 69 */ 70 #define SDM_REVISION_MAJOR (1) 71 #define SDM_REVISION_MINOR (0) 72 73 #define SDM_VERSION_TAG ((uint32_t) ((SDM_REVISION_MAJOR << 24) | (SDM_REVISION_MINOR << 16) | \ 74 (sizeof(SDMCompatibility) << 8) | sizeof(int *))) 75 76 namespace sdm { 77 78 /*! @brief This enum represents max bandwidth limit mode. 79 80 @sa DisplayInterface::SetMaxBandwidthMode 81 */ 82 enum HWBwModes { 83 kBwVFEOff, //!< Camera/video front end off. No change in device bandwidth limit. 84 kBwVFEOn, //!< Camera/video front end is on. Bandwidth limit reduced. 85 kBwModeMax, //!< Limiter for maximum available bandwidth modes. 86 }; 87 88 /*! @brief Information on hardware for the first display 89 90 @details This structure returns the display type of the first display on the device 91 (internal display or HDMI etc) and whether it is currently connected. 92 */ 93 struct HWDisplayInterfaceInfo { 94 DisplayType type = kDisplayTypeMax; 95 bool is_connected = false; 96 }; 97 98 /*! @brief Information about a single display/monitor/screen 99 100 @details This structure returns the display configuration and status of a single display. A 101 list of this structure type 'HWDisplaysInfo' is used to return information on all available 102 displays. See \link HWDisplaysInfo \endlink 103 */ 104 struct HWDisplayInfo { 105 int32_t display_id = -1; //!< ID of this display (Display ID). 106 DisplayType display_type = kDisplayTypeMax; //!< Type of display: BuiltIn/Pluggable/Virtual 107 bool is_connected = false; //!< Connection status of the display. 108 bool is_primary = false; //!< True only if this is the main display of the 109 //!< device. 110 bool is_wb_ubwc_supported = true; //!< check hardware wb ubwc support 111 }; 112 113 /*! @brief Information on all displays as a map with display_id as key. 114 115 @details This map returns the display configuration and status of all displays. 116 */ 117 typedef std::map<int32_t, HWDisplayInfo> HWDisplaysInfo; 118 119 /*! @brief Display core interface. 120 121 @details This class defines display core interfaces. It contains methods which client shall use 122 to create/destroy different display devices. This interface is created during display core 123 CreateCore() and remains valid until DestroyCore(). 124 125 @sa CoreInterface::CreateCore 126 @sa CoreInterface::DestroyCore 127 */ 128 class CoreInterface { 129 public: 130 /*! @brief Method to create and get handle to display core interface. 131 132 @details This method is the entry point into the display core. Client can create and operate on 133 different display devices only through a valid interface handle obtained using this method. An 134 object of display core is created and handle to this object is returned via output parameter. 135 This interface shall be called only once. 136 137 @param[in] buffer_allocator \link BufferAllocator \endlink 138 @param[in] buffer_sync_handler \link BufferSyncHandler \endlink 139 @param[in] socket_handler \link SocketHandler \endlink 140 @param[out] interface \link CoreInterface \endlink 141 @param[in] version \link SDM_VERSION_TAG \endlink. Client must not override this argument. 142 143 @return \link DisplayError \endlink 144 145 @sa DestroyCore 146 */ 147 static DisplayError CreateCore(BufferAllocator *buffer_allocator, 148 BufferSyncHandler *buffer_sync_handler, 149 SocketHandler *socket_handler, CoreInterface **interface, 150 uint32_t version = SDM_VERSION_TAG); 151 152 /*! @brief Method to release handle to display core interface. 153 154 @details The object of corresponding display core is destroyed when this method is invoked. 155 Client must explicitly destroy all created display device objects associated with this handle 156 before invoking this method. 157 158 @param[in] interface \link CoreInterface \endlink 159 160 @return \link DisplayError \endlink 161 162 @sa CreateCore 163 */ 164 static DisplayError DestroyCore(); 165 166 /*! @brief Method to create a display device for a given type. 167 168 @details Client shall use this method to create each of the connected display type. A handle to 169 interface associated with this object is returned via output parameter which can be used to 170 interact further with the display device. 171 172 @param[in] type \link DisplayType \endlink 173 @param[in] event_handler \link DisplayEventHandler \endlink 174 @param[out] interface \link DisplayInterface \endlink 175 176 @return \link DisplayError \endlink 177 178 @sa DestroyDisplay 179 */ 180 virtual DisplayError CreateDisplay(DisplayType type, DisplayEventHandler *event_handler, 181 DisplayInterface **interface) = 0; 182 183 /*! @brief Method to create a display device for a given display ID. 184 185 @details Client shall use this method to create a DisplayInterface to a discovered display 186 identified by its display ID. A handle to the DisplayInterface is returned via the 'interface' 187 output parameter which can be used to interact further with the display device. Displays and 188 their IDs must be discovered using GetDisplaysStatus(). 189 190 @param[in] display_id A display ID got from \link GetDisplaysStatus() \endlink 191 @param[in] event_handler \link DisplayEventHandler \endlink 192 @param[out] interface \link DisplayInterface \endlink 193 194 @return \link DisplayError \endlink 195 196 @sa DestroyDisplay 197 */ 198 virtual DisplayError CreateDisplay(int32_t display_id, DisplayEventHandler *event_handler, 199 DisplayInterface **interface) = 0; 200 201 /*! @brief Method to destroy a display device. 202 203 @details Client shall use this method to destroy each of the created display device objects. 204 205 @param[in] interface \link DisplayInterface \endlink 206 207 @return \link DisplayError \endlink 208 209 @sa CreateDisplay 210 */ 211 virtual DisplayError DestroyDisplay(DisplayInterface *interface) = 0; 212 213 /*! @brief Method to update the bandwidth limit as per given mode. 214 215 @param[in] mode indicate the mode or use case 216 217 @return \link DisplayError \endlink 218 */ 219 virtual DisplayError SetMaxBandwidthMode(HWBwModes mode) = 0; 220 221 /*! @brief Method to get characteristics of the first display. 222 223 @details Client shall use this method to determine if the first display is HDMI, and whether 224 it is currently connected. 225 226 @param[in] hw_disp_info structure that this method will fill up with info. 227 228 @return \link DisplayError \endlink 229 */ 230 virtual DisplayError GetFirstDisplayInterfaceType(HWDisplayInterfaceInfo *hw_disp_info) = 0; 231 232 /*! @brief Method to get an up-to-date list of all available displays. 233 234 @details Client shall use this method to get the updated list of all available displays and 235 their properties, usually in response to a hot-plug event. Client must use one of the returned 236 HWDisplayInfo::display_ids when using CreateDisplay(int32_t display_id, ...) to create the 237 DisplayInterface to the display. 238 239 @param[out] hw_displays_info \link HWDisplaysInfo \endlink which is a map of \link HWDisplayInfo 240 \endlink structures with display_id as the key. 241 242 @return \link DisplayError \endlink 243 */ 244 virtual DisplayError GetDisplaysStatus(HWDisplaysInfo *hw_displays_info) = 0; 245 246 /*! @brief Method to get the maximum supported number of concurrent displays of a particular type. 247 248 @details Client shall use this method to get the maximum number of DisplayInterface instances 249 that can be created for a particular \link DisplayType \endlink display. For the maximum 250 number of concurrent DisplayInterfaces supported of all types, call with type kDisplayTypeMax. 251 252 @param[in] type Type of display: BuiltIn/Pluggable/Virtual/kDisplayTypeMax 253 key. 254 255 @param[out] max_displays Maximum number of DisplayInterface instances possible. 256 257 @return \link DisplayError \endlink 258 */ 259 virtual DisplayError GetMaxDisplaysSupported(DisplayType type, int32_t *max_displays) = 0; 260 261 /*! @brief Method which returns true if the given format is supported by rotator otherwise false 262 263 @param[in] \link LayerBufferFormat \endlink 264 265 @return returns true if the given format is supported by rotator otherwise false 266 */ 267 virtual bool IsRotatorSupportedFormat(LayerBufferFormat format) = 0; 268 269 protected: ~CoreInterface()270 virtual ~CoreInterface() { } 271 }; 272 273 } // namespace sdm 274 275 #endif // __CORE_INTERFACE_H__ 276 277