blob: 7395b4a11f7dcb43f5a007065f4210fa858e1daf
1 | /* |
2 | // Copyright (c) 2014 Intel Corporation |
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 | // This file is modified by Amlogic, Inc. 2017.01.17. |
17 | */ |
18 | |
19 | #ifndef IDISPLAY_DEVICE_H |
20 | #define IDISPLAY_DEVICE_H |
21 | |
22 | #include <utils/KeyedVector.h> |
23 | #include <Dump.h> |
24 | #include <hardware/hwcomposer2.h> |
25 | #include <Hwcomposer.h> |
26 | #include <HwcLayer.h> |
27 | |
28 | namespace android { |
29 | namespace amlogic { |
30 | |
31 | enum { |
32 | LAYER_MAX_NUM_SECURE_PROTECTED = 5, |
33 | LAYER_MAX_NUM_CHANGE_REQUEST = 8, |
34 | LAYER_MAX_NUM_CHANGE_TYPE = 16, |
35 | LAYER_MAX_NUM_SUPPORT = LAYER_MAX_NUM_CHANGE_TYPE, |
36 | }; |
37 | |
38 | enum { |
39 | HWC2_NO_LAYER = 0, |
40 | HWC2_ONE_LAYER = 1, |
41 | HWC2_TWO_LAYERS = 2, |
42 | HWC2_THREE_LAYERS = 3, |
43 | HWC2_MAX_LAYERS = HWC2_THREE_LAYERS, |
44 | }; |
45 | |
46 | |
47 | // display device interface |
48 | class IDisplayDevice { |
49 | public: |
50 | // display device type |
51 | enum { |
52 | DEVICE_PRIMARY = HWC_DISPLAY_PRIMARY, |
53 | DEVICE_EXTERNAL = HWC_DISPLAY_EXTERNAL, |
54 | DEVICE_VIRTUAL = HWC_DISPLAY_VIRTUAL, |
55 | DEVICE_COUNT, |
56 | }; |
57 | enum { |
58 | DEVICE_DISCONNECTED = 0, |
59 | DEVICE_CONNECTED, |
60 | }; |
61 | enum { |
62 | DEVICE_DISPLAY_OFF = 0, |
63 | DEVICE_DISPLAY_ON, |
64 | DEVICE_DISPLAY_STANDBY, |
65 | }; |
66 | public: |
67 | IDisplayDevice() {} |
68 | virtual ~IDisplayDevice() {} |
69 | public: |
70 | virtual int32_t acceptDisplayChanges() = 0; |
71 | virtual bool createLayer(hwc2_layer_t* outLayer) = 0; |
72 | virtual bool destroyLayer(hwc2_layer_t layer) = 0; |
73 | virtual int32_t getActiveConfig(hwc2_config_t* outConfig) = 0; |
74 | virtual int32_t getChangedCompositionTypes(uint32_t* outNumElements, hwc2_layer_t* outLayers, |
75 | int32_t* /*hwc2_composition_t*/ outTypes) = 0; |
76 | virtual int32_t getClientTargetSupport(uint32_t width, |
77 | uint32_t height, int32_t /*android_pixel_format_t*/ format, |
78 | int32_t /*android_dataspace_t*/ dataspace) = 0; |
79 | virtual int32_t getColorModes(uint32_t* outNumModes, |
80 | int32_t* /*android_color_mode_t*/ outModes) = 0; |
81 | virtual int32_t getDisplayAttribute(hwc2_config_t config, |
82 | int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue) = 0; |
83 | virtual int32_t getDisplayConfigs(uint32_t* outNumConfigs, hwc2_config_t* outConfigs) = 0; |
84 | virtual int32_t getDisplayName(uint32_t* outSize,char* outName) = 0; |
85 | virtual int32_t getDisplayRequests(int32_t* /*hwc2_display_request_t*/ outDisplayRequests, |
86 | uint32_t* outNumElements, hwc2_layer_t* outLayers, int32_t* /*hwc2_layer_request_t*/ outLayerRequests) = 0; |
87 | virtual int32_t getDisplayType(int32_t* /*hwc2_display_type_t*/ outType) = 0; |
88 | virtual int32_t getDozeSupport(int32_t* outSupport) = 0; |
89 | virtual int32_t getHdrCapabilities(uint32_t* outNumTypes, |
90 | int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance, |
91 | float* outMaxAverageLuminance, float* outMinLuminance) = 0; |
92 | virtual int32_t getReleaseFences(uint32_t* outNumElements, hwc2_layer_t* outLayers, int32_t* outFences) = 0; |
93 | virtual int32_t presentDisplay(int32_t* outRetireFence) = 0; |
94 | virtual int32_t setActiveConfig(hwc2_config_t config) = 0; |
95 | virtual int32_t setClientTarget(buffer_handle_t target, |
96 | int32_t acquireFence, int32_t /*android_dataspace_t*/ dataspace, hwc_region_t damage) = 0; |
97 | virtual int32_t setColorMode(int32_t /*android_color_mode_t*/ mode) = 0; |
98 | virtual int32_t setColorTransform(const float* matrix, int32_t /*android_color_transform_t*/ hint) = 0; |
99 | // virtual int32_t setOutputBuffer(buffer_handle_t buffer, int32_t releaseFence) = 0; |
100 | virtual int32_t setPowerMode(int32_t /*hwc2_power_mode_t*/ mode) = 0; |
101 | virtual bool vsyncControl(bool enabled) = 0; |
102 | virtual int32_t validateDisplay(uint32_t* outNumTypes, uint32_t* outNumRequests) = 0; |
103 | virtual int32_t setCursorPosition(hwc2_layer_t layerId, int32_t x, int32_t y) = 0; |
104 | |
105 | // Virtual display. |
106 | virtual int32_t createVirtualDisplay(uint32_t width, uint32_t height, int32_t* format, hwc2_display_t* outDisplay) = 0; |
107 | virtual int32_t destroyVirtualDisplay(hwc2_display_t display) = 0; |
108 | virtual int32_t setOutputBuffer(buffer_handle_t buffer, int32_t releaseFence) = 0; |
109 | |
110 | // Other Display methods |
111 | virtual hwc2_display_t getId() const = 0; |
112 | virtual bool isConnected() const = 0; |
113 | |
114 | // device related operations |
115 | virtual bool initCheck() const = 0; |
116 | virtual bool initialize() = 0; |
117 | virtual void deinitialize() = 0; |
118 | virtual const char* getName() const = 0; |
119 | virtual int getDisplayId() const = 0; |
120 | |
121 | virtual HwcLayer* getLayerById(hwc2_layer_t layerId) = 0; |
122 | |
123 | virtual bool updateDisplayConfigs() = 0; |
124 | |
125 | //events |
126 | virtual void onVsync(int64_t timestamp) = 0; |
127 | |
128 | virtual void dump(Dump& d) = 0; |
129 | |
130 | }; |
131 | |
132 | } |
133 | } |
134 | |
135 | #endif /* IDISPLAY_DEVICE_H */ |
136 |