1 /* 2 * Copyright (c) 2014 - 2016, 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 42 #include "display_interface.h" 43 #include "sdm_types.h" 44 #include "buffer_allocator.h" 45 #include "buffer_sync_handler.h" 46 47 /*! @brief Display manager interface version. 48 49 @details Display manager interfaces are version tagged to maintain backward compatibility. This 50 version is supplied as a default argument during display core initialization. 51 52 Client may use an older version of interfaces and link to a higher version of display manager 53 library, but vice versa is not allowed. 54 55 A 32-bit client must use 32-bit display core library and a 64-bit client must use 64-bit display 56 core library. 57 58 Display manager interfaces follow default data structures alignment. Client must not override the 59 default padding rules while using these interfaces. 60 61 @warning It is assumed that client upgrades or downgrades display core interface all at once 62 and recompile all binaries which use these interfaces. Mix and match of these interfaces can 63 lead to unpredictable behaviour. 64 65 @sa CoreInterface::CreateCore 66 */ 67 #define SDM_REVISION_MAJOR (1) 68 #define SDM_REVISION_MINOR (0) 69 70 #define SDM_VERSION_TAG ((uint32_t) ((SDM_REVISION_MAJOR << 24) | (SDM_REVISION_MINOR << 16) | \ 71 (sizeof(SDMCompatibility) << 8) | sizeof(int *))) 72 73 namespace sdm { 74 75 /*! @brief Forward declaration for debug handler. 76 */ 77 class DebugHandler; 78 79 /*! @brief This enum represents max bandwidth limit mode. 80 81 @sa DisplayInterface::SetMaxBandwidthMode 82 */ 83 enum HWBwModes { 84 kBwDefault, //!< Default state. No change in device bandwidth limit. 85 kBwCamera, //!< Camera is on. Bandwidth limit should be reduced accordingly. 86 kBwVFlip, //!< VFlip is required. Reduce bandwidth limit accordingly. 87 kBwHFlip, //!< HFlip is required. Reduce bandwidth limit accordingly. 88 kBwModeMax, //!< Limiter for maximum available bandwidth modes. 89 }; 90 91 92 /*! @brief Information on hardware for the first display 93 94 @details This structure returns the display type of the first display on the device 95 (internal display or HDMI etc) and whether it is currently connected, 96 97 */ 98 struct HWDisplayInterfaceInfo { 99 DisplayType type; 100 bool is_connected; 101 }; 102 103 /*! @brief Display core interface. 104 105 @details This class defines display core interfaces. It contains methods which client shall use 106 to create/destroy different display devices. This interface is created during display core 107 CreateCore() and remains valid until DestroyCore(). 108 109 @sa CoreInterface::CreateCore 110 @sa CoreInterface::DestroyCore 111 */ 112 class CoreInterface { 113 public: 114 /*! @brief Method to create and get handle to display core interface. 115 116 @details This method is the entry point into the display core. Client can create and operate on 117 different display devices only through a valid interface handle obtained using this method. An 118 object of display core is created and handle to this object is returned via output parameter. 119 This interface shall be called only once. 120 121 @param[in] debug_handler \link DebugHandler \endlink 122 @param[in] buffer_allocator \link BufferAllocator \endlink 123 @param[in] buffer_sync_handler \link BufferSyncHandler \endlink 124 @param[out] interface \link CoreInterface \endlink 125 @param[in] version \link SDM_VERSION_TAG \endlink. Client must not override this argument. 126 127 @return \link DisplayError \endlink 128 129 @sa DestroyCore 130 */ 131 static DisplayError CreateCore(DebugHandler *debug_handler, BufferAllocator *buffer_allocator, 132 BufferSyncHandler *buffer_sync_handler, CoreInterface **interface, 133 uint32_t version = SDM_VERSION_TAG); 134 135 /*! @brief Method to release handle to display core interface. 136 137 @details The object of corresponding display core is destroyed when this method is invoked. 138 Client must explicitly destroy all created display device objects associated with this handle 139 before invoking this method. 140 141 @param[in] interface \link CoreInterface \endlink 142 143 @return \link DisplayError \endlink 144 145 @sa CreateCore 146 */ 147 static DisplayError DestroyCore(); 148 149 /*! @brief Method to create a display device for a given type. 150 151 @details Client shall use this method to create each of the connected display type. A handle to 152 interface associated with this object is returned via output parameter which can be used to 153 interact further with the display device. 154 155 @param[in] type \link DisplayType \endlink 156 @param[in] event_handler \link DisplayEventHandler \endlink 157 @param[out] interface \link DisplayInterface \endlink 158 159 @return \link DisplayError \endlink 160 161 @sa DestroyDisplay 162 */ 163 virtual DisplayError CreateDisplay(DisplayType type, DisplayEventHandler *event_handler, 164 DisplayInterface **interface) = 0; 165 166 /*! @brief Method to destroy a display device. 167 168 @details Client shall use this method to destroy each of the created display device objects. 169 170 @param[in] interface \link DisplayInterface \endlink 171 172 @return \link DisplayError \endlink 173 174 @sa CreateDisplay 175 */ 176 virtual DisplayError DestroyDisplay(DisplayInterface *interface) = 0; 177 178 /*! @brief Method to update the bandwidth limit as per given mode. 179 180 @param[in] mode indicate the mode or use case 181 182 @return \link DisplayError \endlink 183 184 */ 185 virtual DisplayError SetMaxBandwidthMode(HWBwModes mode) = 0; 186 187 /*! @brief Method to get characteristics of the first display. 188 189 @details Client shall use this method to determine if the first display is HDMI, and whether 190 it is currently connected. 191 192 @param[in] hw_disp_info structure that this method will fill up with info. 193 194 @return \link DisplayError \endlink 195 196 */ 197 virtual DisplayError GetFirstDisplayInterfaceType(HWDisplayInterfaceInfo *hw_disp_info) = 0; 198 199 200 protected: 201 virtual ~CoreInterface() { } 202 }; 203 204 } // namespace sdm 205 206 #endif // __CORE_INTERFACE_H__ 207 208