1 /*
2  * Copyright (C) 2012 The Android Open Source Project
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 
17 #ifndef ANDROID_EXYNOS_HWC_H_
18 #define ANDROID_EXYNOS_HWC_H_
19 #include <hardware/hwcomposer2.h>
20 #include <cutils/atomic.h>
21 #include "ExynosMPPType.h"
22 #include "ExynosHWCModule.h"
23 #include "ExynosDevice.h"
24 
25 //#define DISABLE_FENCE
26 
27 #define HWC_FPS_TH      5   /* valid range 1 to 60 */
28 #define VSYNC_INTERVAL (1000000000.0 / 60)
29 
30 enum {
31     HWC_CTL_MAX_OVLY_CNT = 100,
32     HWC_CTL_VIDEO_OVLY_CNT = 101,
33     HWC_CTL_DYNAMIC_RECOMP = 102,
34     HWC_CTL_SKIP_STATIC = 103,
35     /* HWC_CTL_DMA_BW_BAL = 104, */
36     HWC_CTL_SECURE_DMA = 105,
37     HWC_CTL_WINDOW_UPDATE = 106,
38     HWC_CTL_FORCE_PANIC = 107,
39     HWC_CTL_FORCE_GPU = 108,
40     HWC_CTL_SKIP_M2M_PROCESSING = 109,
41     HWC_CTL_DISPLAY_MODE = 110,
42     HWC_CTL_SKIP_RESOURCE_ASSIGN = 111,
43     HWC_CTL_SKIP_VALIDATE = 112,
44     HWC_CTL_DUMP_MID_BUF = 200,
45     HWC_CTL_CAPTURE_READBACK = 201,
46     HWC_CTL_ENABLE_COMPOSITION_CROP = 300,
47     HWC_CTL_ENABLE_EXYNOSCOMPOSITION_OPT = 301,
48     HWC_CTL_ENABLE_CLIENTCOMPOSITION_OPT = 302,
49     HWC_CTL_USE_MAX_G2D_SRC = 303,
50     HWC_CTL_ENABLE_HANDLE_LOW_FPS = 304,
51     HWC_CTL_ENABLE_EARLY_START_MPP = 305,
52     HWC_CTL_DDI_RESOLUTION_CHANGE = 306,
53     HWC_CTL_ENABLE_FENCE_TRACER = 307,
54     HWC_CTL_DO_FENCE_FILE_DUMP = 308,
55     HWC_CTL_SYS_FENCE_LOGGING = 309,
56 };
57 
58 class ExynosDevice;
59 
60 hwc2_function_pointer_t exynos_getFunction(struct hwc2_device* device, int32_t descriptor);
61 void exynos_getCapabilities(struct hwc2_device* device, uint32_t* outcount, int32_t* outcapabilities);
62 void exynos_dump(hwc2_device_t* device, uint32_t* outSize, char* outBuffer);
63 int32_t exynos_acceptDisplayChanges(hwc2_device_t* device, hwc2_display_t display);
64 int32_t exynos_createLayer(hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t* outLayer);
65 int32_t exynos_createVirtualDisplay(hwc2_device_t* device, uint32_t width, uint32_t height,
66         int32_t* format, hwc2_display_t* outDisplay);
67 int32_t exynos_destroyLayer(hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer);
68 int32_t exynos_destroyVirtualDisplay(hwc2_device_t* device, hwc2_display_t display);
69 int32_t exynos_getActiveConfig(hwc2_device_t *device, hwc2_display_t display, hwc2_config_t* outConfig);
70 int32_t exynos_getChangedCompositionTypes(hwc2_device_t *device, hwc2_display_t display,
71         uint32_t* outNumElements, hwc2_layer_t* outLayers, int32_t* outTypes);
72 int32_t exynos_getClientTargetSupport(hwc2_device_t *device, hwc2_display_t display, uint32_t width,
73         uint32_t height, int32_t format, int32_t dataSpace);
74 int32_t exynos_getColorModes(hwc2_device_t *device, hwc2_display_t display, uint32_t* outNumModes,
75         int32_t* outModes);
76 int32_t exynos_getDisplayAttribute(hwc2_device_t *device, hwc2_display_t display, hwc2_config_t config,
77         int32_t attribute, int32_t *outValue);
78 int32_t exynos_getDisplayConfigs(hwc2_device_t *device, hwc2_display_t display, uint32_t* outNumConfigs,
79         hwc2_config_t* outConfigs);
80 int32_t exynos_getDisplayName(hwc2_device_t *device, hwc2_display_t display, uint32_t* outSize, char* outName);
81 int32_t exynos_getDisplayRequests(hwc2_device_t *device, hwc2_display_t display, int32_t* outDisplayRequests,
82         uint32_t* outNumElements, hwc2_layer_t* outLayers, int32_t* outLayerRequests);
83 int32_t exynos_getDisplayType(hwc2_device_t *device, hwc2_display_t display, int32_t* outType);
84 int32_t exynos_getDozeSupport(hwc2_device_t *device, hwc2_display_t display, int32_t* outSupport);
85 int32_t exynos_getHdrCapabilities(hwc2_device_t *device, hwc2_display_t display, uint32_t* outNumTypes,
86         int32_t* outTypes, float* outMaxLuminance, float* outMaxAverageLuminance,
87         float* outMinLuminance);
88 int32_t exynos_getMaxVirtualDisplayCount(hwc2_device_t* device);
89 int32_t exynos_getReleaseFences(hwc2_device_t *device, hwc2_display_t display, uint32_t* outNumElements,
90         hwc2_layer_t* outLayers, int32_t* outFences);
91 int32_t exynos_presentDisplay(hwc2_device_t *device, hwc2_display_t display, int32_t* outRetireFence);
92 int32_t exynos_registerCallback(hwc2_device_t* device, int32_t descriptor,
93         hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer);
94 int32_t exynos_setActiveConfig(hwc2_device_t *device, hwc2_display_t display, hwc2_config_t config);
95 int32_t exynos_setClientTarget(hwc2_device_t *device, hwc2_display_t display, buffer_handle_t target,
96         int32_t acquireFence, int32_t dataspace, hwc_region_t damage);
97 int32_t exynos_setColorMode(hwc2_device_t *device, hwc2_display_t display, int32_t mode);
98 int32_t exynos_setColorTransform(hwc2_device_t *device, hwc2_display_t display, const float* matrix, int32_t hint);
99 int32_t exynos_setCursorPosition(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer,
100         int32_t x, int32_t y);
101 int32_t exynos_setLayerBlendMode(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, int32_t mode);
102 int32_t exynos_setLayerBuffer(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer,
103         buffer_handle_t buffer, int32_t acquireFence);
104 int32_t exynos_setLayerColor(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, hwc_color_t color);
105 int32_t exynos_setLayerCompositionType(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, int32_t type);
106 int32_t exynos_setLayerDataspace(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, int32_t dataspace);
107 int32_t exynos_setLayerDisplayFrame(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer,
108         hwc_rect_t frame);
109 int32_t exynos_setLayerPlaneAlpha(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, float alpha);
110 int32_t exynos_setLayerSidebandStream(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer,
111         const native_handle_t* stream);
112 int32_t exynos_setLayerSourceCrop(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, hwc_frect_t crop);
113 int32_t exynos_setLayerSurfaceDamage(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, hwc_region_t damage);
114 int32_t exynos_setLayerTransform(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, int32_t transform);
115 int32_t exynos_setLayerVisibleRegion(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, hwc_region_t visible);
116 int32_t exynos_setLayerZOrder(hwc2_device_t *device, hwc2_display_t display, hwc2_layer_t layer, uint32_t z);
117 int32_t exynos_setOutputBuffer(hwc2_device_t *device, hwc2_display_t display, buffer_handle_t buffer, int32_t releaseFence);
118 int32_t exynos_setPowerMode(hwc2_device_t *device, hwc2_display_t display, int32_t mode);
119 int32_t exynos_setVsyncEnabled(hwc2_device_t *device, hwc2_display_t display, int32_t enabled);
120 int32_t exynos_validateDisplay(hwc2_device_t *device, hwc2_display_t display,
121         uint32_t* outNumTypes, uint32_t* outNumRequests);
122 int32_t exynos_setLayerPerFrameMetadata(hwc2_device_t* device, hwc2_display_t display,
123         hwc2_layer_t layer, uint32_t numElements,
124         const int32_t* /*hw2_per_frame_metadata_key_t*/ keys,
125         const float* metadata);
126 int32_t exynos_getPerFrameMetadataKeys(hwc2_device_t* device, hwc2_display_t display,
127         uint32_t* outNumKeys, int32_t* /*hwc2_per_frame_metadata_key_t*/ outKeys);
128 int32_t exynos_getRenderIntents(hwc2_device_t* device, hwc2_display_t display, int32_t mode,
129         uint32_t* outNumIntents, int32_t* /*android_render_intent_v1_1_t*/ outIntents);
130 int32_t exynos_setColorModeWithRenderIntent(hwc2_device_t* device, hwc2_display_t display,
131         int32_t /*android_color_mode_t*/ mode,
132         int32_t /*android_render_intent_v1_1_t */ intent);
133 int32_t exynos_getReadbackBufferAttributes(hwc2_device_t *dev, hwc2_display_t display,
134         int32_t* /*android_pixel_format_t*/ outFormat,
135         int32_t* /*android_dataspace_t*/ outDataspace);
136 int32_t exynos_setReadbackBuffer(hwc2_device_t *dev, hwc2_display_t display,
137         buffer_handle_t buffer, int32_t releaseFence);
138 int32_t exynos_getReadbackBufferFence(hwc2_device_t *dev, hwc2_display_t display,
139         int32_t* outFence);
140 
141 int32_t exynos_getDisplayIdentificationData(hwc2_device_t* device, hwc2_display_t display, uint8_t* outPort,
142         uint32_t* outDataSize, uint8_t* outData);
143 int32_t exynos_getDisplayCapabilities(hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumCapabilities,
144         uint32_t* outCapabilities);
145 int32_t exynos_setLayerColorTransform(hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
146         const float* matrix);
147 int32_t exynos_getDisplayedContentSamplingAttributes(hwc2_device_t* device, hwc2_display_t display,
148         int32_t* /* andrmid_pixel_format_t */ format,
149         int32_t* /* android_dataspace_t */ dataspace,
150         uint8_t* /* mask of android_component_t */ supported_components);
151 int32_t exynos_setDisplayedContentSamplingEnabled(hwc2_device_t* device, hwc2_display_t display,
152         int32_t /*hwc2_displayed_content_sampling_t*/ enabled,
153         uint8_t /* mask of android_component_t */ component_mask,
154         uint64_t max_frames);
155 int32_t exynos_getDisplayedContentSample(hwc2_device_t* device, hwc2_display_t display,
156         uint64_t max_frames, uint64_t timestamp,
157         uint64_t* frame_count, int32_t samples_size[4], uint64_t* samples[4]);
158 int32_t exynos_setLayerPerFrameMetadataBlobs(hwc2_device_t* device, hwc2_display_t display,
159         hwc2_layer_t layer, uint32_t numElements, const int32_t* keys, const uint32_t* sizes,
160         const uint8_t* metadata);
161 int32_t exynos_getDisplayBrightnessSupport(hwc2_device_t* device, hwc2_display_t display, bool* outSupport);
162 int32_t exynos_setDisplayBrightness(hwc2_device_t* device, hwc2_display_t display, float brightness);
163 
164 int32_t exynos_GetDisplayConnectionType(hwc2_device_t* device, hwc2_display_t display,
165         uint32_t* /*hwc2_display_connection_type_t*/ outType);
166 int32_t exynos_GetDisplayVsyncPeriod(hwc2_device_t* device, hwc2_display_t display,
167         hwc2_vsync_period_t* outVsyncPeriod);
168 int32_t exynos_SetActiveConfigWithConstraints(hwc2_device_t* device, hwc2_display_t display,
169         hwc2_config_t config, hwc_vsync_period_change_constraints_t* vsyncPeriodChangeConstraints,
170         hwc_vsync_period_change_timeline_t* outTimeline);
171 int32_t exynos_SetAutoLowLatencyMode(hwc2_device_t* device, hwc2_display_t display, bool on);
172 int32_t exynos_GetSupportedContentTypes(hwc2_device_t* device, hwc2_display_t display,
173         uint32_t* outNumSupportedContentTypes, uint32_t* outSupportedContentTypes);
174 int32_t exynos_SetContentType(hwc2_device_t* device, hwc2_display_t display,
175         int32_t /* hwc2_content_type_t */ contentType);
176 int32_t exynos_GetClientTargetProperty(hwc2_device_t* device, hwc2_display_t display,
177         hwc_client_target_property_t* outClientTargetProperty);
178 int32_t exynos_SetLayerGenericMetadata(hwc2_device_t* device, hwc2_display_t display,
179         hwc2_layer_t layer, uint32_t keyLength, const char* key,
180         bool mandatory, uint32_t valueLength, const uint8_t* value);
181 void exynos_GetLayerGenericMetadataKey(hwc2_device_t* device, uint32_t keyIndex,
182         uint32_t* outKeyLength, char* outKey, bool* outMandatory);
183 
184 enum {
185     NO_DRM = 0,
186     NORMAL_DRM,
187     SECURE_DRM,
188 };
189 
190 struct exynos_hwc2_device_t {
191     hwc2_device_t base;
192 	ExynosDevice *device;
193 };
194 #endif
195