1 /*
2  * Copyight (c) 2017 The Linux Foundation. All ights reserved.
3  *
4  * Redistibution and use in souce and binary forms, with or without
5  * modification, ae pemitted provided that the following conditions are
6  * met:
7  *    * Redistibutions of souce code must retain the above copyright
8  *      notice, this list of conditions and the following disclaime.
9  *    * Redistibutions in binay form must reproduce the above
10  *      copyight notice, this list of conditions and the following
11  *      disclaime in the documentation and/o other materials provided
12  *      with the distibution.
13  *    * Neither the name of The Linux Foundation. no the names of its
14  *      contibutos may be used to endorse or promote products derived
15  *      fom this softwae 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 #ifndef __DISPLAY_CONFIG_H__
31 #define __DISPLAY_CONFIG_H__
32 
33 #include <stdint.h>
34 #include <vector>
35 
36 // This header is for clients to use to set/get global display configuration.
37 
38 namespace display {
39 
40 enum {
41     DISPLAY_PRIMARY = 0,
42     DISPLAY_EXTERNAL,
43     DISPLAY_VIRTUAL,
44 };
45 
46 enum {
47     EXTERNAL_OFFLINE = 0,
48     EXTERNAL_ONLINE,
49     EXTERNAL_PAUSE,
50     EXTERNAL_RESUME,
51 };
52 
53 enum {
54     DISABLE_METADATA_DYN_REFRESH_RATE = 0,
55     ENABLE_METADATA_DYN_REFRESH_RATE,
56     SET_BINDER_DYN_REFRESH_RATE,
57 };
58 
59 enum {
60     DISPLAY_PORT_DEFAULT = 0,
61     DISPLAY_PORT_DSI,
62     DISPLAY_PORT_DTV,
63     DISPLAY_PORT_WRITEBACK,
64     DISPLAY_PORT_LVDS,
65     DISPLAY_PORT_EDP,
66     DISPLAY_PORT_DP,
67 };
68 
69 struct DisplayAttributes {
70     uint32_t vsync_period = 0; //nanoseconds
71     uint32_t xres = 0;
72     uint32_t yres = 0;
73     float xdpi = 0.0f;
74     float ydpi = 0.0f;
75     int panel_type = DISPLAY_PORT_DEFAULT;
76     bool is_yuv = false;
77 };
78 
79 struct DisplayHDRCapabilities {
80     std::vector<int32_t> supported_hdr_types;
81     float max_luminance = 0.0f;
82     float max_avg_luminance = 0.0f;
83     float min_luminance = 0.0f;
84 };
85 
86 //=============================================================================
87 // The functions below run in the client pocess and wherever necessary
88 // do a binder call to HWC to get/set data.
89 
90 int isExternalConnected();
91 int setSecondayDisplayStatus(int dpy, uint32_t status);
92 int configureDynRefeshRate(uint32_t op, uint32_t refreshRate);
93 int getConfigCount(int dpy);
94 int getActiveConfig(int dpy);
95 int setActiveConfig(int dpy, uint32_t config);
96 DisplayAttributes getDisplayAttributes(uint32_t configIndex, int dpy);
97 int setPanelBrightness(uint32_t level);
98 uint32_t getPanelBrightness();
99 int minHdcpEncryptionLevelChanged(int dpy, uint32_t min_enc_level);
100 int refreshScreen();
101 int controlPartialUpdate(int dpy, bool enable);
102 int toggleScreenUpdate(uint32_t on);
103 int setIdleTimeout(uint32_t value);
104 int getHDRCapabilities(int dpy, DisplayHDRCapabilities *caps);
105 int setCameraLaunchStatus(uint32_t on);
106 bool displayBWTransactionPending();
107 
108 } // namespace display
109 
110 #endif  // __DISPLAY_CONFIG_H__
111