1 /* 2 * Copyright (c) 2013 - 2016, 2018 - 2021, 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 /* 31 * Changes from Qualcomm Innovation Center are provided under the following license: 32 * 33 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 34 * 35 * Redistribution and use in source and binary forms, with or without 36 * modification, are permitted (subject to the limitations in the 37 * disclaimer below) provided that the following conditions are met: 38 * 39 * * Redistributions of source code must retain the above copyright 40 * notice, this list of conditions and the following disclaimer. 41 * 42 * * Redistributions in binary form must reproduce the above 43 * copyright notice, this list of conditions and the following 44 * disclaimer in the documentation and/or other materials provided 45 * with the distribution. 46 * 47 * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its 48 * contributors may be used to endorse or promote products derived 49 * from this software without specific prior written permission. 50 * 51 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE 52 * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 53 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 54 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 55 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 56 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 57 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 59 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 60 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 61 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 62 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 63 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 64 */ 65 66 #ifndef _DISPLAY_CONFIG_H 67 #define _DISPLAY_CONFIG_H 68 69 #include <vector> 70 71 #include <gralloc_priv.h> 72 #include <qdMetaData.h> 73 #include <hardware/hwcomposer.h> 74 75 // This header is for clients to use to set/get global display configuration. 76 // Only primary and external displays are supported here. 77 78 namespace qdutils { 79 80 81 /* TODO: Have all the common enums that need be exposed to clients and which 82 * are also needed in hwc defined here. Remove such definitions we have in 83 * hwc_utils.h 84 */ 85 86 // Use this enum to specify the dpy parameters where needed 87 enum { 88 // DO NOT CHANGE THE LEGACY DEFINES 89 DISPLAY_PRIMARY = 0, // = HWC_DISPLAY_PRIMARY 90 DISPLAY_EXTERNAL = 1, // = HWC_DISPLAY_EXTERNAL 91 DISPLAY_VIRTUAL = 2, // = HWC_DISPLAY_VIRTUAL 92 93 // Additional displays only for vendor client (e.g. pp) reference 94 DISPLAY_BUILTIN_2 = 3, 95 DISPLAY_EXTERNAL_2 = 4, 96 }; 97 98 // External Display states - used in setSecondaryDisplayStatus() 99 // To be consistent with the same defined in hwc_utils.h 100 enum { 101 EXTERNAL_OFFLINE = 0, 102 EXTERNAL_ONLINE, 103 EXTERNAL_PAUSE, 104 EXTERNAL_RESUME, 105 }; 106 107 enum { 108 DISABLE_METADATA_DYN_REFRESH_RATE = 0, 109 ENABLE_METADATA_DYN_REFRESH_RATE, 110 SET_BINDER_DYN_REFRESH_RATE, 111 }; 112 113 enum { 114 DEFAULT_MODE = 0, 115 VIDEO_MODE, 116 COMMAND_MODE, 117 }; 118 119 enum { 120 DISPLAY_PORT_DEFAULT = 0, 121 DISPLAY_PORT_DSI, 122 DISPLAY_PORT_DTV, 123 DISPLAY_PORT_WRITEBACK, 124 DISPLAY_PORT_LVDS, 125 DISPLAY_PORT_EDP, 126 DISPLAY_PORT_DP, 127 }; 128 129 // Display Attributes that are available to clients of this library 130 // Not to be confused with a similar struct in hwc_utils (in the hwc namespace) 131 typedef struct DisplayAttributes { 132 uint32_t vsync_period = 0; //nanoseconds 133 uint32_t xres = 0; 134 uint32_t yres = 0; 135 float xdpi = 0.0f; 136 float ydpi = 0.0f; 137 int panel_type = DISPLAY_PORT_DEFAULT; 138 bool is_yuv = false; 139 } DisplayAttributes_t; 140 141 //============================================================================= 142 // The functions below run in the client process and wherever necessary 143 // do a binder call to HWC to get/set data. 144 145 // Check if external display is connected. Useful to check before making 146 // calls for external displays 147 // Returns 1 if connected, 0 if disconnected, negative values on errors 148 int isExternalConnected(void); 149 150 // Get display vsync period which is in nanoseconds 151 // i.e vsync_period = 1000000000l / fps 152 // Returns 0 on success, negative values on errors 153 int getDisplayAttributes(int dpy, DisplayAttributes_t& dpyattr); 154 155 // get the active visible region for the display 156 // Returns 0 on success, negative values on errors 157 int getDisplayVisibleRegion(int dpy, hwc_rect_t &rect); 158 159 // set the view frame information in hwc context from surfaceflinger 160 int setViewFrame(int dpy, int l, int t, int r, int b); 161 162 // Set the secondary display status(pause/resume/offline etc.,) 163 int setSecondaryDisplayStatus(int dpy, uint32_t status); 164 165 // Enable/Disable/Set refresh rate dynamically 166 int configureDynRefreshRate(uint32_t op, uint32_t refreshRate); 167 168 // Returns the number of configs supported for the display on success. 169 // Returns -1 on error. 170 // Only primary display supported for now, value of dpy ignored. 171 int getConfigCount(int dpy); 172 173 // Returns the index of config that is current set for the display on success. 174 // Returns -1 on error. 175 // Only primary display supported for now, value of dpy ignored. 176 int getActiveConfig(int dpy); 177 178 // Sets the config for the display on success and returns 0. 179 // Returns -1 on error. 180 // Only primary display supported for now, value of dpy ignored 181 int setActiveConfig(int configIndex, int dpy); 182 183 // Returns the attributes for the specified config for the display on success. 184 // Returns xres and yres as 0 on error. 185 // Only primary display supported for now, value of dpy ignored 186 DisplayAttributes getDisplayAttributes(int configIndex, int dpy); 187 188 // Set the primary display mode to command or video mode 189 int setDisplayMode(int mode); 190 191 // Sets the panel brightness of the primary display 192 int setPanelBrightness(int level); 193 194 // Retrieves the current panel brightness value 195 int getPanelBrightness(); 196 197 // Sets the specified bit clk value. 198 int setDsiClk(int dpy, uint64_t bitClk); 199 200 // Retrieves the current bit clk value. 201 uint64_t getDsiClk(int dpy); 202 203 // Get supported bit clk values. 204 int getSupportedBitClk(int dpy, std::vector<uint64_t>& bit_rates); 205 206 // Sets the specified min and max luminance values. 207 int setPanelLuminanceAttributes(int dpy, float min_lum, float max_lum); 208 209 // Informs HWC about TWM entry/exit based on which NULL Display is connected 210 // or disconnected. 211 // mode -> 0 for exit sequence, 1 for entry sequence. 212 // is_twm -> 213 // 0 for regular ambient mode 214 // 1 for TWM with framework shutdown mode (If display is in ON state, then 215 // this would put display in DOZE state). 216 // Using 0 for mode value and 1 for is_twm is not valid, it may lead to 217 // state inconsistency between Android Framework and HAL. 218 int setStandByMode(int mode, int is_twm); 219 220 // Get Panel Resolution 221 extern "C" int getPanelResolution(int *width, int *height); 222 223 extern "C" int delayFirstCommit(void); 224 225 }; //namespace 226 227 228 extern "C" int waitForComposerInit(); 229 #endif 230