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 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
17 
18 #include <hardware/hardware.h>
19 #include <utils/Errors.h>
20 #include <utils/Trace.h>
21 #include <log/log.h>
22 #include <sys/stat.h>
23 
24 #include "ExynosHWC.h"
25 #include "ExynosHWCModule.h"
26 #include "ExynosHWCService.h"
27 #include "ExynosDisplay.h"
28 #include "ExynosLayer.h"
29 #include "ExynosExternalDisplayModule.h"
30 #include "ExynosDeviceModule.h"
31 
32 class ExynosHWCService;
33 
34 using namespace android;
35 using namespace SOC_VERSION;
36 
hwcApiVersion(const hwc_composer_device_1_t * hwc)37 uint32_t hwcApiVersion(const hwc_composer_device_1_t* hwc) {
38     uint32_t hwcVersion = hwc->common.version;
39     return hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK;
40 }
41 
hwcHeaderVersion(const hwc_composer_device_1_t * hwc)42 uint32_t hwcHeaderVersion(const hwc_composer_device_1_t* hwc) {
43     uint32_t hwcVersion = hwc->common.version;
44     return hwcVersion & HARDWARE_API_VERSION_2_HEADER_MASK;
45 }
46 
hwcHasApiVersion(const hwc_composer_device_1_t * hwc,uint32_t version)47 bool hwcHasApiVersion(const hwc_composer_device_1_t* hwc, uint32_t version)
48 {
49     return (hwcApiVersion(hwc) >= (version & HARDWARE_API_VERSION_2_MAJ_MIN_MASK));
50 }
51 
52 /**************************************************************************************
53  * HWC 2.x APIs
54  * ************************************************************************************/
55 ExynosDevice *g_exynosDevice = NULL;
56 
57 hwc2_function_pointer_t exynos_function_pointer[] =
58 {
59     NULL,                               //HWC2_FUNCTION_INVAILD
60     reinterpret_cast<hwc2_function_pointer_t>(exynos_acceptDisplayChanges),        //HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES
61     reinterpret_cast<hwc2_function_pointer_t>(exynos_createLayer),                 //HWC2_FUNCTION_CREATE_LAYER
62     reinterpret_cast<hwc2_function_pointer_t>(exynos_createVirtualDisplay),        //HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY
63     reinterpret_cast<hwc2_function_pointer_t>(exynos_destroyLayer),                //HWC2_FUNCTION_DESTROY_LAYER
64     reinterpret_cast<hwc2_function_pointer_t>(exynos_destroyVirtualDisplay),       //HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY
65     reinterpret_cast<hwc2_function_pointer_t>(exynos_dump),                        //HWC2_FUNCTION_DUMP
66     reinterpret_cast<hwc2_function_pointer_t>(exynos_getActiveConfig),             //HWC2_FUNCTION_GET_ACTIVE_CONFIG
67     reinterpret_cast<hwc2_function_pointer_t>(exynos_getChangedCompositionTypes),  //HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES
68     reinterpret_cast<hwc2_function_pointer_t>(exynos_getClientTargetSupport),      //HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT
69     reinterpret_cast<hwc2_function_pointer_t>(exynos_getColorModes),               //HWC2_FUNCTION_GET_COLOR_MODES
70     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDisplayAttribute),         //HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE
71     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDisplayConfigs),           //HWC2_FUNCTION_GET_DISPLAY_CONFIGS
72     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDisplayName),              //HWC2_FUNCTION_GET_DISPLAY_NAME
73     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDisplayRequests),          //HWC2_FUNCTION_GET_DISPLAY_REQUESTS
74     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDisplayType),              //HWC2_FUNCTION_GET_DISPLAY_TYPE
75     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDozeSupport),              //HWC2_FUNCTION_GET_DOZE_SUPPORT
76     reinterpret_cast<hwc2_function_pointer_t>(exynos_getHdrCapabilities),          //HWC2_FUNCTION_GET_HDR_CAPABILITIES
77     reinterpret_cast<hwc2_function_pointer_t>(exynos_getMaxVirtualDisplayCount),   //HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT
78     reinterpret_cast<hwc2_function_pointer_t>(exynos_getReleaseFences),            //HWC2_FUNCTION_GET_RELEASE_FENCES
79     reinterpret_cast<hwc2_function_pointer_t>(exynos_presentDisplay),              //HWC2_FUNCTION_PRESENT_DISPLAY
80     reinterpret_cast<hwc2_function_pointer_t>(exynos_registerCallback),            //HWC2_FUNCTION_REGISTER_CALLBACK
81     reinterpret_cast<hwc2_function_pointer_t>(exynos_setActiveConfig),             //HWC2_FUNCTION_SET_ACTIVE_CONFIG
82     reinterpret_cast<hwc2_function_pointer_t>(exynos_setClientTarget),             //HWC2_FUNCTION_SET_CLIENT_TARGET
83     reinterpret_cast<hwc2_function_pointer_t>(exynos_setColorMode),                //HWC2_FUNCTION_SET_COLOR_MODE
84     reinterpret_cast<hwc2_function_pointer_t>(exynos_setColorTransform),           //HWC2_FUNCTION_SET_COLOR_TRANSFORM
85     reinterpret_cast<hwc2_function_pointer_t>(exynos_setCursorPosition),           //HWC2_FUNCTION_SET_CURSOR_POSITION
86     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerBlendMode),           //HWC2_FUNCTION_SET_LAYER_BLEND_MODE
87     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerBuffer),              //HWC2_FUNCTION_SET_LAYER_BUFFER
88     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerColor),               //HWC2_FUNCTION_SET_LAYER_COLOR
89     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerCompositionType),     //HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE
90     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerDataspace),           //HWC2_FUNCTION_SET_LAYER_DATASPACE
91     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerDisplayFrame),        //HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME
92     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerPlaneAlpha),          //HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA
93     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerSidebandStream),      //HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM
94     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerSourceCrop),          //HWC2_FUNCTION_SET_LAYER_SOURCE_CROP
95     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerSurfaceDamage),       //HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE
96     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerTransform),           //HWC2_FUNCTION_SET_LAYER_TRANSFORM
97     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerVisibleRegion),       //HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION
98     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerZOrder),              //HWC2_FUNCTION_SET_LAYER_Z_ORDER
99     reinterpret_cast<hwc2_function_pointer_t>(exynos_setOutputBuffer),             //HWC2_FUNCTION_SET_OUTPUT_BUFFER
100     reinterpret_cast<hwc2_function_pointer_t>(exynos_setPowerMode),                //HWC2_FUNCTION_SET_POWER_MODE
101     reinterpret_cast<hwc2_function_pointer_t>(exynos_setVsyncEnabled),             //HWC2_FUNCTION_SET_VSYNC_ENABLED
102     reinterpret_cast<hwc2_function_pointer_t>(exynos_validateDisplay),             //HWC2_FUNCTION_VALIDATE_DISPLAY
103     reinterpret_cast<hwc2_function_pointer_t>(NULL),                               //HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR
104     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerPerFrameMetadata),    //HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA
105     reinterpret_cast<hwc2_function_pointer_t>(exynos_getPerFrameMetadataKeys),     //HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS
106     reinterpret_cast<hwc2_function_pointer_t>(exynos_setReadbackBuffer),           //HWC2_FUNCTION_SET_READBACK_BUFFER
107     reinterpret_cast<hwc2_function_pointer_t>(exynos_getReadbackBufferAttributes), //HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES
108     reinterpret_cast<hwc2_function_pointer_t>(exynos_getReadbackBufferFence),      //HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE
109 #ifdef HWC_SUPPORT_RENDER_INTENT
110     reinterpret_cast<hwc2_function_pointer_t>(exynos_getRenderIntents),            //HWC2_FUNCTION_GET_RENDER_INTENTS
111     reinterpret_cast<hwc2_function_pointer_t>(exynos_setColorModeWithRenderIntent),//HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT
112 #else
113     reinterpret_cast<hwc2_function_pointer_t>(NULL),                               //HWC2_FUNCTION_GET_RENDER_INTENTS
114     reinterpret_cast<hwc2_function_pointer_t>(NULL),                               //HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT
115 #endif
116     reinterpret_cast<hwc2_function_pointer_t>(NULL),                               //HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX
117 
118     // composer 2.3
119     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDisplayIdentificationData),//HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA
120     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDisplayCapabilities),      //HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES
121     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerColorTransform),      //HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM
122     reinterpret_cast<hwc2_function_pointer_t>(NULL),                               //HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES
123     reinterpret_cast<hwc2_function_pointer_t>(NULL),                               //HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED
124     reinterpret_cast<hwc2_function_pointer_t>(NULL),                               //HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE
125     reinterpret_cast<hwc2_function_pointer_t>(exynos_setLayerPerFrameMetadataBlobs), //HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS
126     reinterpret_cast<hwc2_function_pointer_t>(exynos_getDisplayBrightnessSupport),   //HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT
127     reinterpret_cast<hwc2_function_pointer_t>(exynos_setDisplayBrightness),          //HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS
128 
129     // composer 2.4
130     reinterpret_cast<hwc2_function_pointer_t>(exynos_GetDisplayConnectionType),      //HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE
131     reinterpret_cast<hwc2_function_pointer_t>(exynos_GetDisplayVsyncPeriod),         //HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD
132     reinterpret_cast<hwc2_function_pointer_t>(exynos_SetActiveConfigWithConstraints),//HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS
133     reinterpret_cast<hwc2_function_pointer_t>(exynos_SetAutoLowLatencyMode),         //HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE
134     reinterpret_cast<hwc2_function_pointer_t>(exynos_GetSupportedContentTypes),      //HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES
135     reinterpret_cast<hwc2_function_pointer_t>(exynos_SetContentType),                //HWC2_FUNCTION_SET_CONTENT_TYPE
136     reinterpret_cast<hwc2_function_pointer_t>(exynos_GetClientTargetProperty),       //HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY
137     reinterpret_cast<hwc2_function_pointer_t>(exynos_SetLayerGenericMetadata),       //HWC2_FUNCTION_SET_LAYER_GENERIC_METADATA
138     reinterpret_cast<hwc2_function_pointer_t>(exynos_GetLayerGenericMetadataKey),    //HWC2_FUNCTION_GET_LAYER_GENERIC_METADATA_KEY
139 };
140 
checkDevice(hwc2_device_t * dev)141 inline ExynosDevice* checkDevice(hwc2_device_t *dev)
142 {
143     struct exynos_hwc2_device_t *pdev = (struct exynos_hwc2_device_t *)dev;
144     ExynosDevice *exynosDevice = pdev->device;
145     if ((g_exynosDevice == NULL) || (exynosDevice != g_exynosDevice)) {
146         ALOGE("device pointer is not valid (%p, %p)", exynosDevice, g_exynosDevice);
147         return NULL;
148     }
149 
150     return exynosDevice;
151 }
152 
checkDisplay(ExynosDevice * exynosDevice,hwc2_display_t display)153 inline ExynosDisplay* checkDisplay(ExynosDevice *exynosDevice, hwc2_display_t display)
154 {
155     ExynosDisplay *exynosDisplay = exynosDevice->getDisplay((uint32_t)display);
156     if (exynosDisplay == NULL) {
157         ALOGE("exynosDisplay is NULL");
158         return NULL;
159     }
160 
161     return exynosDisplay;
162 }
163 
checkLayer(ExynosDisplay * exynosDisplay,hwc2_layer_t layer)164 inline ExynosLayer* checkLayer(ExynosDisplay *exynosDisplay, hwc2_layer_t layer)
165 {
166     ExynosLayer *exynosLayer = exynosDisplay->checkLayer(layer);
167     if (exynosLayer == NULL) {
168         ALOGE("exynosLayer is NULL");
169         return NULL;
170     }
171 
172     return exynosLayer;
173 }
174 
exynos_getFunction(struct hwc2_device * dev,int32_t descriptor)175 hwc2_function_pointer_t exynos_getFunction(struct hwc2_device *dev,
176         int32_t descriptor)
177 {
178     if (descriptor <= HWC2_FUNCTION_INVALID || descriptor > HWC2_FUNCTION_GET_LAYER_GENERIC_METADATA_KEY)
179         return NULL;
180 
181     ExynosDevice *exynosDevice = checkDevice(dev);
182     if (!exynosDevice)
183         return NULL;
184 
185     return exynos_function_pointer[descriptor];
186 }
187 
exynos_getCapabilities(struct hwc2_device * dev,uint32_t * outCount,int32_t * outCapabilities)188 void exynos_getCapabilities(struct hwc2_device *dev, uint32_t *outCount, int32_t *outCapabilities)
189 {
190     ExynosDevice *exynosDevice = checkDevice(dev);
191 
192     if (!exynosDevice)
193         *outCapabilities = 0;
194     else
195         return exynosDevice->getCapabilities(outCount, outCapabilities);
196 }
197 
exynos_dump(hwc2_device_t * dev,uint32_t * outSize,char * outBuffer)198 void exynos_dump(hwc2_device_t *dev, uint32_t *outSize, char *outBuffer)
199 {
200     ExynosDevice *exynosDevice = checkDevice(dev);
201 
202     if (exynosDevice)
203         return exynosDevice->dump(outSize, outBuffer);
204 }
205 
exynos_acceptDisplayChanges(hwc2_device_t * dev,hwc2_display_t display)206 int32_t exynos_acceptDisplayChanges(hwc2_device_t *dev, hwc2_display_t display)
207 {
208     ExynosDevice *exynosDevice = checkDevice(dev);
209 
210     if (exynosDevice) {
211         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, (uint32_t)display);
212         if (exynosDisplay) {
213             int32_t ret = exynosDisplay->acceptDisplayChanges();
214             exynosDisplay->mHWCRenderingState = RENDERING_STATE_ACCEPTED_CHANGE;
215             return ret;
216         }
217     }
218 
219     return HWC2_ERROR_BAD_DISPLAY;
220 }
221 
exynos_createLayer(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t * outLayer)222 int32_t exynos_createLayer(hwc2_device_t *dev,
223         hwc2_display_t display, hwc2_layer_t *outLayer)
224 {
225     ExynosDevice *exynosDevice = checkDevice(dev);
226 
227     if (exynosDevice) {
228         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
229         if (exynosDisplay)
230             return exynosDisplay->createLayer(outLayer);
231     }
232 
233     return HWC2_ERROR_BAD_DISPLAY;
234 }
235 
exynos_createVirtualDisplay(hwc2_device_t * dev,uint32_t width,uint32_t height,int32_t * format,hwc2_display_t * outDisplay)236 int32_t exynos_createVirtualDisplay(hwc2_device_t *dev, uint32_t width, uint32_t height,
237         int32_t *format, hwc2_display_t *outDisplay)
238 {
239     if (format == nullptr)
240         return HWC2_ERROR_BAD_PARAMETER;
241 
242     ExynosDevice *exynosDevice = checkDevice(dev);
243     *outDisplay = getDisplayId(HWC_DISPLAY_VIRTUAL, 0);
244 
245     if (exynosDevice) {
246         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, *outDisplay);
247         if (exynosDisplay)
248             return exynosDevice->createVirtualDisplay(width, height, format, exynosDisplay);
249     }
250 
251     return HWC2_ERROR_BAD_PARAMETER;
252 }
253 
exynos_destroyLayer(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer)254 int32_t exynos_destroyLayer(hwc2_device_t *dev, hwc2_display_t display,
255         hwc2_layer_t layer)
256 {
257     ExynosDevice *exynosDevice = checkDevice(dev);
258 
259     if (exynosDevice) {
260         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
261         if (exynosDisplay) {
262             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
263             if (exynosLayer)
264                 return exynosDisplay->destroyLayer((hwc2_layer_t)exynosLayer);
265             else
266                 return HWC2_ERROR_BAD_LAYER;
267         }
268     }
269 
270     return HWC2_ERROR_BAD_DISPLAY;
271 }
272 
exynos_destroyVirtualDisplay(hwc2_device_t * dev,hwc2_display_t display)273 int32_t exynos_destroyVirtualDisplay(hwc2_device_t* dev, hwc2_display_t display)
274 {
275     ExynosDevice *exynosDevice = checkDevice(dev);
276 
277     if (exynosDevice) {
278         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
279         if (exynosDisplay) {
280             exynosDisplay->destroyLayers();
281             return exynosDevice->destroyVirtualDisplay(exynosDisplay);
282         }
283     }
284 
285     return HWC2_ERROR_BAD_DISPLAY;
286 }
287 
exynos_getActiveConfig(hwc2_device_t * dev,hwc2_display_t display,hwc2_config_t * outConfig)288 int32_t exynos_getActiveConfig(hwc2_device_t *dev, hwc2_display_t display,
289         hwc2_config_t* outConfig)
290 {
291     ExynosDevice *exynosDevice = checkDevice(dev);
292 
293     if (exynosDevice) {
294         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
295         if (exynosDisplay)
296             return exynosDisplay->getActiveConfig(outConfig);
297     }
298 
299     return HWC2_ERROR_BAD_DISPLAY;
300 }
301 
exynos_getChangedCompositionTypes(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outNumElements,hwc2_layer_t * outLayers,int32_t * outTypes)302 int32_t exynos_getChangedCompositionTypes(hwc2_device_t *dev, hwc2_display_t display,
303         uint32_t* outNumElements, hwc2_layer_t* outLayers,
304         int32_t* /*hwc2_composition_t*/ outTypes)
305 {
306     ExynosDevice *exynosDevice = checkDevice(dev);
307 
308     if (exynosDevice) {
309         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
310         if (exynosDisplay)
311             return exynosDisplay->getChangedCompositionTypes(outNumElements, outLayers, outTypes);
312     }
313 
314     return HWC2_ERROR_BAD_DISPLAY;
315 }
316 
exynos_getClientTargetSupport(hwc2_device_t * dev,hwc2_display_t display,uint32_t width,uint32_t height,int32_t format,int32_t dataSpace)317 int32_t exynos_getClientTargetSupport(hwc2_device_t *dev, hwc2_display_t display, uint32_t width,
318         uint32_t height, int32_t format, int32_t dataSpace)
319 {
320     ExynosDevice *exynosDevice = checkDevice(dev);
321 
322     if (exynosDevice) {
323         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
324         if (exynosDisplay)
325             return exynosDisplay->getClientTargetSupport(width, height, format, dataSpace);
326     }
327 
328     return HWC2_ERROR_BAD_DISPLAY;
329 }
330 
exynos_getColorModes(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outNumModes,int32_t * outModes)331 int32_t exynos_getColorModes(hwc2_device_t *dev, hwc2_display_t display, uint32_t* outNumModes,
332         int32_t* outModes)
333 {
334     ExynosDevice *exynosDevice = checkDevice(dev);
335 
336     if (exynosDevice) {
337         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
338         if (exynosDisplay)
339             return exynosDisplay->getColorModes(outNumModes, outModes);
340     }
341 
342     return HWC2_ERROR_BAD_DISPLAY;
343 }
344 
exynos_getRenderIntents(hwc2_device_t * dev,hwc2_display_t display,int32_t mode,uint32_t * outNumIntents,int32_t * outIntents)345 int32_t exynos_getRenderIntents(hwc2_device_t* dev, hwc2_display_t display, int32_t mode,
346                 uint32_t* outNumIntents, int32_t* /*android_render_intent_v1_1_t*/ outIntents)
347 {
348     if (mode < 0)
349         return HWC2_ERROR_BAD_PARAMETER;
350 
351     ExynosDevice *exynosDevice = checkDevice(dev);
352     ALOGD("%s:: mode(%d)", __func__, mode);
353 
354     if (exynosDevice) {
355         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
356         if (exynosDisplay)
357             return exynosDisplay->getRenderIntents(mode, outNumIntents, outIntents);
358     }
359 
360     return HWC2_ERROR_BAD_DISPLAY;
361 }
362 
exynos_setColorModeWithRenderIntent(hwc2_device_t * dev,hwc2_display_t display,int32_t mode,int32_t intent)363 int32_t exynos_setColorModeWithRenderIntent(hwc2_device_t* dev, hwc2_display_t display,
364         int32_t /*android_color_mode_t*/ mode,
365         int32_t /*android_render_intent_v1_1_t */ intent)
366 {
367     if ((mode < 0) || (intent < 0))
368         return HWC2_ERROR_BAD_PARAMETER;
369 
370     ExynosDevice *exynosDevice = checkDevice(dev);
371     ALOGD("%s:: mode(%d), intent(%d)", __func__, mode, intent);
372 
373     if (exynosDevice) {
374         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
375         if (exynosDisplay)
376             return exynosDisplay->setColorModeWithRenderIntent(mode, intent);
377     }
378 
379     return HWC2_ERROR_BAD_DISPLAY;
380 }
381 
exynos_getDisplayAttribute(hwc2_device_t * dev,hwc2_display_t display,hwc2_config_t config,int32_t attribute,int32_t * outValue)382 int32_t exynos_getDisplayAttribute(hwc2_device_t *dev, hwc2_display_t display,
383         hwc2_config_t config, int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue)
384 {
385     ExynosDevice *exynosDevice = checkDevice(dev);
386 
387     if (exynosDevice) {
388         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
389         if (exynosDisplay)
390             return exynosDisplay->getDisplayAttribute(config, attribute, outValue);
391     }
392 
393     return HWC2_ERROR_BAD_DISPLAY;
394 }
395 
exynos_getDisplayConfigs(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outNumConfigs,hwc2_config_t * outConfigs)396 int32_t exynos_getDisplayConfigs(hwc2_device_t *dev, hwc2_display_t display,
397         uint32_t* outNumConfigs, hwc2_config_t* outConfigs)
398 {
399     ExynosDevice *exynosDevice = checkDevice(dev);
400 
401     if (exynosDevice) {
402         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
403         if (exynosDisplay)
404             return exynosDisplay->getDisplayConfigs(outNumConfigs, outConfigs);
405     }
406 
407     return HWC2_ERROR_BAD_DISPLAY;
408 }
409 
exynos_getDisplayName(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outSize,char * outName)410 int32_t exynos_getDisplayName(hwc2_device_t *dev, hwc2_display_t display,
411         uint32_t* outSize, char* outName)
412 {
413     ExynosDevice *exynosDevice = checkDevice(dev);
414 
415     if (exynosDevice) {
416         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
417         if (exynosDisplay)
418             return exynosDisplay->getDisplayName(outSize, outName);
419     }
420 
421     return HWC2_ERROR_BAD_DISPLAY;
422 }
423 
exynos_getDisplayRequests(hwc2_device_t * dev,hwc2_display_t display,int32_t * outDisplayRequests,uint32_t * outNumElements,hwc2_layer_t * outLayers,int32_t * outLayerRequests)424 int32_t exynos_getDisplayRequests(hwc2_device_t *dev, hwc2_display_t display,
425         int32_t* /*hwc2_display_request_t*/ outDisplayRequests,
426         uint32_t* outNumElements, hwc2_layer_t* outLayers,
427         int32_t* /*hwc2_layer_request_t*/ outLayerRequests)
428 {
429     ExynosDevice *exynosDevice = checkDevice(dev);
430 
431     if (exynosDevice) {
432         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
433         if (exynosDisplay)
434             return exynosDisplay->getDisplayRequests(outDisplayRequests, outNumElements, outLayers, outLayerRequests);
435     }
436 
437     return HWC2_ERROR_BAD_DISPLAY;
438 }
439 
exynos_getDisplayType(hwc2_device_t * dev,hwc2_display_t display,int32_t * outType)440 int32_t exynos_getDisplayType(hwc2_device_t *dev, hwc2_display_t display,
441         int32_t* /*hwc2_display_type_t*/ outType)
442 {
443     ExynosDevice *exynosDevice = checkDevice(dev);
444 
445     if (exynosDevice) {
446         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
447         if (exynosDisplay)
448             return exynosDisplay->getDisplayType(outType);
449     }
450 
451     return HWC2_ERROR_BAD_DISPLAY;
452 }
453 
exynos_getDozeSupport(hwc2_device_t * dev,hwc2_display_t display,int32_t * outSupport)454 int32_t exynos_getDozeSupport(hwc2_device_t *dev, hwc2_display_t display,
455         int32_t* outSupport)
456 {
457     ExynosDevice *exynosDevice = checkDevice(dev);
458 
459     if (exynosDevice) {
460         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
461         if (exynosDisplay)
462             return exynosDisplay->getDozeSupport(outSupport);
463     }
464 
465     return HWC2_ERROR_BAD_DISPLAY;
466 }
467 
exynos_getHdrCapabilities(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outNumTypes,int32_t * outTypes,float * outMaxLuminance,float * outMaxAverageLuminance,float * outMinLuminance)468 int32_t exynos_getHdrCapabilities(hwc2_device_t *dev, hwc2_display_t display,
469         uint32_t* outNumTypes,
470         int32_t* outTypes, float* outMaxLuminance,
471         float* outMaxAverageLuminance, float* outMinLuminance)
472 {
473     ExynosDevice *exynosDevice = checkDevice(dev);
474 
475     if (exynosDevice) {
476         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
477         if (exynosDisplay) {
478             return exynosDisplay->getHdrCapabilities(outNumTypes, outTypes, outMaxLuminance,
479                     outMaxAverageLuminance, outMinLuminance);
480             return 0;
481         }
482     }
483 
484     return HWC2_ERROR_BAD_DISPLAY;
485 }
486 
exynos_getMaxVirtualDisplayCount(hwc2_device_t * dev)487 int32_t exynos_getMaxVirtualDisplayCount(hwc2_device_t* dev)
488 {
489     ExynosDevice *exynosDevice = checkDevice(dev);
490 
491     if (exynosDevice)
492         return exynosDevice->getMaxVirtualDisplayCount();
493     else
494         return HWC2_ERROR_BAD_PARAMETER;
495 }
496 
exynos_getReleaseFences(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outNumElements,hwc2_layer_t * outLayers,int32_t * outFences)497 int32_t exynos_getReleaseFences(hwc2_device_t *dev, hwc2_display_t display,
498         uint32_t* outNumElements, hwc2_layer_t* outLayers, int32_t* outFences)
499 {
500     ExynosDevice *exynosDevice = checkDevice(dev);
501 
502     if (exynosDevice) {
503         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
504         if (exynosDisplay)
505             return exynosDisplay->getReleaseFences(outNumElements, outLayers, outFences);
506     }
507 
508     return HWC2_ERROR_BAD_DISPLAY;
509 }
510 
exynos_presentDisplay(hwc2_device_t * dev,hwc2_display_t display,int32_t * outRetireFence)511 int32_t exynos_presentDisplay(hwc2_device_t *dev, hwc2_display_t display,
512         int32_t* outRetireFence)
513 {
514     ExynosDevice *exynosDevice = checkDevice(dev);
515 
516     if (exynosDevice) {
517         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
518         if (exynosDisplay == NULL)
519             return HWC2_ERROR_BAD_DISPLAY;
520 
521         if (exynosDisplay->mHWCRenderingState == RENDERING_STATE_VALIDATED) {
522             ALOGI("%s:: acceptDisplayChanges was not called",
523                     exynosDisplay->mDisplayName.string());
524             if (exynosDisplay->acceptDisplayChanges() != HWC2_ERROR_NONE) {
525                 ALOGE("%s:: acceptDisplayChanges is failed",
526                         exynosDisplay->mDisplayName.string());
527             }
528         }
529         int32_t ret = exynosDisplay->presentDisplay(outRetireFence);
530         exynosDisplay->mHWCRenderingState = RENDERING_STATE_PRESENTED;
531         return ret;
532     }
533 
534     return HWC2_ERROR_BAD_DISPLAY;
535 }
536 
exynos_registerCallback(hwc2_device_t * dev,int32_t descriptor,hwc2_callback_data_t callbackData,hwc2_function_pointer_t pointer)537 int32_t exynos_registerCallback(hwc2_device_t* dev,
538         int32_t /*hwc2_callback_descriptor_t*/ descriptor,
539         hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer)
540 {
541     int32_t ret = 0;
542     struct exynos_hwc2_device_t *pdev = (struct exynos_hwc2_device_t *)dev;
543     ExynosDevice *exynosDevice = pdev->device;
544     if (exynosDevice == NULL)
545     {
546         ALOGE("%s:: descriptor(%d), exynosDevice(%p), pointer(%p)",
547                 __func__, descriptor, exynosDevice, pointer);
548         return HWC2_ERROR_BAD_PARAMETER;
549     }
550 
551     switch (descriptor) {
552         case HWC2_CALLBACK_INVALID:
553         case HWC2_CALLBACK_HOTPLUG:
554         case HWC2_CALLBACK_REFRESH:
555         case HWC2_CALLBACK_VSYNC:
556         case HWC2_CALLBACK_VSYNC_2_4:
557         case HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED:
558             ret = exynosDevice->registerCallback(descriptor, callbackData, pointer);
559             return ret;
560         default:
561             return HWC2_ERROR_BAD_PARAMETER;
562     }
563 
564     return HWC2_ERROR_NONE;
565 }
566 
exynos_setActiveConfig(hwc2_device_t * dev,hwc2_display_t display,hwc2_config_t config)567 int32_t exynos_setActiveConfig(hwc2_device_t *dev, hwc2_display_t display,
568         hwc2_config_t config)
569 {
570     HDEBUGLOGD(eDebugDisplayConfig, "%s, %d",__func__, config);
571 
572     ExynosDevice *exynosDevice = checkDevice(dev);
573 
574     if (exynosDevice) {
575         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
576         if (exynosDisplay)
577             return exynosDisplay->setActiveConfig(config);
578     }
579 
580     return HWC2_ERROR_BAD_DISPLAY;
581 }
582 
exynos_setClientTarget(hwc2_device_t * dev,hwc2_display_t display,buffer_handle_t target,int32_t acquireFence,int32_t dataspace,hwc_region_t __unused damage)583 int32_t exynos_setClientTarget(hwc2_device_t *dev, hwc2_display_t display,
584         buffer_handle_t target, int32_t acquireFence,
585         int32_t /*android_dataspace_t*/ dataspace, hwc_region_t __unused damage)
586 {
587     ExynosDevice *exynosDevice = checkDevice(dev);
588 
589     if (exynosDevice) {
590         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
591         if (exynosDisplay)
592             return exynosDisplay->setClientTarget(target, acquireFence, dataspace);
593     }
594 
595     return HWC2_ERROR_BAD_DISPLAY;
596 }
597 
exynos_setColorMode(hwc2_device_t * dev,hwc2_display_t display,int32_t mode)598 int32_t exynos_setColorMode(hwc2_device_t *dev, hwc2_display_t display, int32_t mode)
599 {
600     if (mode < 0)
601         return HWC2_ERROR_BAD_PARAMETER;
602 
603     ExynosDevice *exynosDevice = checkDevice(dev);
604 
605     if (exynosDevice) {
606         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
607         if (exynosDisplay)
608             return exynosDisplay->setColorMode(mode);
609     }
610 
611     return HWC2_ERROR_BAD_DISPLAY;
612 }
613 
exynos_setColorTransform(hwc2_device_t * dev,hwc2_display_t display,const float * matrix,int32_t hint)614 int32_t exynos_setColorTransform(hwc2_device_t *dev, hwc2_display_t display,
615         const float* matrix, int32_t hint)
616 {
617     if (matrix == nullptr)
618         return HWC2_ERROR_BAD_PARAMETER;
619 
620     ExynosDevice *exynosDevice = checkDevice(dev);
621 
622     if (exynosDevice) {
623         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
624         if (exynosDisplay)
625             return exynosDisplay->setColorTransform(matrix, hint);
626     }
627 
628     return HWC2_ERROR_BAD_DISPLAY;
629 }
630 
exynos_setCursorPosition(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,int32_t x,int32_t y)631 int32_t exynos_setCursorPosition(hwc2_device_t *dev, hwc2_display_t display,
632         hwc2_layer_t layer, int32_t x, int32_t y)
633 {
634     ExynosDevice *exynosDevice = checkDevice(dev);
635 
636     if (exynosDevice) {
637         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
638         if (exynosDisplay) {
639             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
640             if (exynosLayer)
641                 return exynosLayer->setCursorPosition(x, y);
642         }
643     }
644 
645     return HWC2_ERROR_BAD_LAYER;
646 }
647 
exynos_setLayerBlendMode(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,int32_t mode)648 int32_t exynos_setLayerBlendMode(hwc2_device_t *dev, hwc2_display_t display,
649         hwc2_layer_t layer, int32_t /*hwc2_blend_mode_t*/ mode)
650 {
651     ExynosDevice *exynosDevice = checkDevice(dev);
652 
653     if (exynosDevice) {
654         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
655         if (exynosDisplay) {
656             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
657             if (exynosLayer)
658                 return exynosLayer->setLayerBlendMode(mode);
659         }
660     }
661 
662     return HWC2_ERROR_BAD_LAYER;
663 }
664 
exynos_setLayerBuffer(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,buffer_handle_t buffer,int32_t acquireFence)665 int32_t exynos_setLayerBuffer(hwc2_device_t *dev, hwc2_display_t display,
666         hwc2_layer_t layer, buffer_handle_t buffer, int32_t acquireFence)
667 {
668     ExynosDevice *exynosDevice = checkDevice(dev);
669 
670     if (exynosDevice) {
671         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
672         if (exynosDisplay) {
673             Mutex::Autolock lock(exynosDisplay->mDisplayMutex);
674             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
675             if (exynosLayer)
676                 return exynosLayer->setLayerBuffer(buffer, acquireFence);
677         }
678     }
679 
680     return HWC2_ERROR_BAD_LAYER;
681 }
682 
exynos_setLayerColor(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,hwc_color_t color)683 int32_t exynos_setLayerColor(hwc2_device_t *dev, hwc2_display_t display,
684         hwc2_layer_t layer, hwc_color_t color)
685 {
686     ExynosDevice *exynosDevice = checkDevice(dev);
687 
688     if (exynosDevice) {
689         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
690         if (exynosDisplay) {
691             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
692             if (exynosLayer)
693                 return exynosLayer->setLayerColor(color);
694         }
695     }
696 
697     return HWC2_ERROR_BAD_LAYER;
698 }
699 
exynos_setLayerCompositionType(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,int32_t type)700 int32_t exynos_setLayerCompositionType(hwc2_device_t *dev, hwc2_display_t display,
701         hwc2_layer_t layer, int32_t /*hwc2_composition_t*/ type)
702 {
703     ExynosDevice *exynosDevice = checkDevice(dev);
704 
705     if (exynosDevice) {
706         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
707         if (exynosDisplay) {
708             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
709             if (exynosLayer)
710                 return exynosLayer->setLayerCompositionType(type);
711         }
712     }
713 
714     return HWC2_ERROR_BAD_LAYER;
715 }
716 
exynos_setLayerDataspace(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,int32_t dataspace)717 int32_t exynos_setLayerDataspace(hwc2_device_t *dev, hwc2_display_t display, hwc2_layer_t layer, int32_t dataspace)
718 {
719     ExynosDevice *exynosDevice = checkDevice(dev);
720 
721     if (exynosDevice) {
722         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
723         if (exynosDisplay) {
724             Mutex::Autolock lock(exynosDisplay->mDisplayMutex);
725             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
726             if (exynosLayer)
727                 return exynosLayer->setLayerDataspace(dataspace);
728         }
729     }
730 
731     return HWC2_ERROR_BAD_LAYER;
732 }
733 
exynos_setLayerDisplayFrame(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,hwc_rect_t frame)734 int32_t exynos_setLayerDisplayFrame(hwc2_device_t *dev, hwc2_display_t display,
735         hwc2_layer_t layer, hwc_rect_t frame)
736 {
737     ExynosDevice *exynosDevice = checkDevice(dev);
738 
739     if (exynosDevice) {
740         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
741         if (exynosDisplay) {
742             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
743             if (exynosLayer)
744                 return exynosLayer->setLayerDisplayFrame(frame);
745         }
746     }
747 
748     return HWC2_ERROR_BAD_LAYER;
749 }
750 
exynos_setLayerPlaneAlpha(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,float alpha)751 int32_t exynos_setLayerPlaneAlpha(hwc2_device_t *dev, hwc2_display_t display,
752         hwc2_layer_t layer, float alpha)
753 {
754     ExynosDevice *exynosDevice = checkDevice(dev);
755 
756     if (exynosDevice) {
757         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
758         if (exynosDisplay) {
759             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
760             if (exynosLayer)
761                 return exynosLayer->setLayerPlaneAlpha(alpha);
762         }
763     }
764 
765     return HWC2_ERROR_BAD_LAYER;
766 }
767 
exynos_setLayerSidebandStream(hwc2_device_t __unused * dev,hwc2_display_t __unused display,hwc2_layer_t __unused layer,const native_handle_t * __unused stream)768 int32_t exynos_setLayerSidebandStream(hwc2_device_t __unused *dev, hwc2_display_t __unused display,
769         hwc2_layer_t __unused layer, const native_handle_t* __unused stream)
770 {
771     ALOGE("%s:: unsuported api", __func__);
772     return HWC2_ERROR_NONE;
773 }
774 
exynos_setLayerSourceCrop(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,hwc_frect_t crop)775 int32_t exynos_setLayerSourceCrop(hwc2_device_t *dev, hwc2_display_t display,
776         hwc2_layer_t layer, hwc_frect_t crop)
777 {
778     ExynosDevice *exynosDevice = checkDevice(dev);
779 
780     if (exynosDevice) {
781         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
782         if (exynosDisplay) {
783             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
784             if (exynosLayer)
785                 return exynosLayer->setLayerSourceCrop(crop);
786         }
787     }
788 
789     return HWC2_ERROR_BAD_LAYER;
790 }
791 
exynos_setLayerSurfaceDamage(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,hwc_region_t damage)792 int32_t exynos_setLayerSurfaceDamage(hwc2_device_t *dev, hwc2_display_t display,
793         hwc2_layer_t layer, hwc_region_t damage)
794 {
795     ExynosDevice *exynosDevice = checkDevice(dev);
796 
797     if (exynosDevice) {
798         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
799         if (exynosDisplay) {
800             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
801             if (exynosLayer)
802                 return exynosLayer->setLayerSurfaceDamage(damage);
803         }
804     }
805 
806     return HWC2_ERROR_BAD_LAYER;
807 }
808 
exynos_setLayerTransform(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,int32_t transform)809 int32_t exynos_setLayerTransform(hwc2_device_t *dev, hwc2_display_t display,
810         hwc2_layer_t layer, int32_t /*hwc_transform_t*/ transform)
811 {
812     ExynosDevice *exynosDevice = checkDevice(dev);
813 
814     if (exynosDevice) {
815         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
816         if (exynosDisplay) {
817             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
818             if (exynosLayer)
819                 return exynosLayer->setLayerTransform(transform);
820         }
821     }
822 
823     return HWC2_ERROR_BAD_LAYER;
824 }
825 
exynos_setLayerVisibleRegion(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,hwc_region_t visible)826 int32_t exynos_setLayerVisibleRegion(hwc2_device_t *dev, hwc2_display_t display,
827         hwc2_layer_t layer, hwc_region_t visible)
828 {
829     ExynosDevice *exynosDevice = checkDevice(dev);
830 
831     if (exynosDevice) {
832         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
833         if (exynosDisplay) {
834             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
835             if (exynosLayer)
836                 return exynosLayer->setLayerVisibleRegion(visible);
837         }
838     }
839 
840     return HWC2_ERROR_BAD_LAYER;
841 }
842 
exynos_setLayerZOrder(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,uint32_t z)843 int32_t exynos_setLayerZOrder(hwc2_device_t *dev, hwc2_display_t display,
844         hwc2_layer_t layer, uint32_t z)
845 {
846     ExynosDevice *exynosDevice = checkDevice(dev);
847 
848     if (exynosDevice) {
849         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
850         if (exynosDisplay) {
851             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
852             if (exynosLayer)
853                 return exynosLayer->setLayerZOrder(z);
854         }
855     }
856 
857     return HWC2_ERROR_BAD_LAYER;
858 }
859 
exynos_setOutputBuffer(hwc2_device_t * dev,hwc2_display_t display,buffer_handle_t buffer,int32_t releaseFence)860 int32_t exynos_setOutputBuffer(hwc2_device_t *dev, hwc2_display_t display,
861         buffer_handle_t buffer, int32_t releaseFence)
862 {
863     ExynosDevice *exynosDevice = checkDevice(dev);
864 
865     if (exynosDevice) {
866         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
867         if (exynosDisplay)
868             return exynosDisplay->setOutputBuffer(buffer, releaseFence);
869     }
870 
871     return HWC2_ERROR_BAD_DISPLAY;
872 }
873 
exynos_setPowerMode(hwc2_device_t * dev,hwc2_display_t display,int32_t mode)874 int32_t exynos_setPowerMode(hwc2_device_t *dev, hwc2_display_t display,
875         int32_t /*hwc2_power_mode_t*/ mode)
876 {
877     if (mode < 0)
878         return HWC2_ERROR_BAD_PARAMETER;
879 
880     ExynosDevice *exynosDevice = checkDevice(dev);
881 
882     if (exynosDevice) {
883         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
884         if (exynosDisplay) {
885             return exynosDisplay->setPowerMode(mode);
886         }
887     }
888 
889     return HWC2_ERROR_BAD_DISPLAY;
890 }
891 
exynos_setVsyncEnabled(hwc2_device_t * dev,hwc2_display_t display,int32_t enabled)892 int32_t exynos_setVsyncEnabled(hwc2_device_t *dev, hwc2_display_t display,
893         int32_t /*hwc2_vsync_t*/ enabled)
894 {
895     ExynosDevice *exynosDevice = checkDevice(dev);
896 
897     if (exynosDevice) {
898         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
899         if (exynosDisplay)
900             return exynosDisplay->setVsyncEnabled(enabled);
901     }
902 
903     return HWC2_ERROR_BAD_DISPLAY;
904 }
905 
exynos_validateDisplay(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outNumTypes,uint32_t * outNumRequests)906 int32_t exynos_validateDisplay(hwc2_device_t *dev, hwc2_display_t display,
907         uint32_t* outNumTypes, uint32_t* outNumRequests)
908 {
909     ExynosDevice *exynosDevice = checkDevice(dev);
910 
911     if (exynosDevice) {
912         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
913         if (exynosDisplay == NULL)
914             return HWC2_ERROR_BAD_DISPLAY;
915         int32_t ret = exynosDisplay->validateDisplay(outNumTypes, outNumRequests);
916         exynosDisplay->mHWCRenderingState = RENDERING_STATE_VALIDATED;
917         return ret;
918     }
919 
920     return HWC2_ERROR_BAD_DISPLAY;
921 }
922 
exynos_setLayerPerFrameMetadata(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,uint32_t numElements,const int32_t * keys,const float * metadata)923 int32_t exynos_setLayerPerFrameMetadata(hwc2_device_t *dev, hwc2_display_t display,
924         hwc2_layer_t layer, uint32_t numElements,
925         const int32_t* /*hw2_per_frame_metadata_key_t*/ keys,
926         const float* metadata) {
927     if ((keys == nullptr) || (metadata == nullptr))
928         return HWC2_ERROR_BAD_PARAMETER;
929 
930     ExynosDevice *exynosDevice = checkDevice(dev);
931     if (exynosDevice) {
932         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
933         if (exynosDisplay) {
934             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
935             if (exynosLayer == NULL) {
936                 ALOGE("%s:: invalid layer", __func__);
937                 return HWC2_ERROR_BAD_PARAMETER;
938             }
939             return exynosLayer->setLayerPerFrameMetadata(numElements, keys, metadata);
940         }
941     }
942     return HWC2_ERROR_BAD_DISPLAY;
943 }
944 
exynos_getPerFrameMetadataKeys(hwc2_device_t * dev,hwc2_display_t __unused display,uint32_t * outNumKeys,int32_t * outKeys)945 int32_t exynos_getPerFrameMetadataKeys(hwc2_device_t* dev, hwc2_display_t __unused display,
946         uint32_t* outNumKeys, int32_t* /*hwc2_per_frame_metadata_key_t*/ outKeys) {
947 
948     ExynosDevice *exynosDevice = checkDevice(dev);
949     if (exynosDevice == NULL)
950         return HWC2_ERROR_BAD_DISPLAY;
951 
952     ExynosResourceManager *resourceManager = exynosDevice->mResourceManager;
953 
954     uint32_t numKeys = 0;
955 
956     if (resourceManager->hasHDR10PlusMPP())
957         numKeys = HWC2_HDR10_PLUS_SEI;
958     else
959         numKeys = HWC2_MAX_FRAME_AVERAGE_LIGHT_LEVEL;
960 
961     if (outKeys == NULL) {
962         *outNumKeys = numKeys + 1;
963         return NO_ERROR;
964     } else {
965         if (*outNumKeys != (numKeys + 1)) {
966             ALOGE("%s:: invalid outNumKeys(%d)", __func__, *outNumKeys);
967             return -1;
968         }
969         for (uint32_t i = 0; i < (*outNumKeys) ; i++) {
970             outKeys[i] = i;
971         }
972     }
973     return NO_ERROR;
974 }
975 
exynos_getReadbackBufferAttributes(hwc2_device_t * dev,hwc2_display_t display,int32_t * outFormat,int32_t * outDataspace)976 int32_t exynos_getReadbackBufferAttributes(hwc2_device_t *dev, hwc2_display_t display,
977         int32_t* /*android_pixel_format_t*/ outFormat,
978         int32_t* /*android_dataspace_t*/ outDataspace) {
979     ExynosDevice *exynosDevice = checkDevice(dev);
980 
981     if (exynosDevice) {
982         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
983         if (exynosDisplay)
984             return exynosDisplay->getReadbackBufferAttributes(outFormat, outDataspace);
985     }
986 
987     return HWC2_ERROR_BAD_DISPLAY;
988 }
989 
exynos_getDisplayIdentificationData(hwc2_device_t * dev,hwc2_display_t display,uint8_t * outPort,uint32_t * outDataSize,uint8_t * outData)990 int32_t exynos_getDisplayIdentificationData(hwc2_device_t* dev, hwc2_display_t display, uint8_t* outPort,
991         uint32_t* outDataSize, uint8_t* outData)
992 {
993     ExynosDevice *exynosDevice = checkDevice(dev);
994 
995     if (exynosDevice) {
996         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
997 
998         if (exynosDisplay) {
999             return exynosDisplay->getDisplayIdentificationData(outPort, outDataSize, outData);
1000         }
1001     }
1002 
1003     return HWC2_ERROR_BAD_DISPLAY;
1004 }
1005 
exynos_setReadbackBuffer(hwc2_device_t * dev,hwc2_display_t display,buffer_handle_t buffer,int32_t releaseFence)1006 int32_t exynos_setReadbackBuffer(hwc2_device_t *dev, hwc2_display_t display,
1007         buffer_handle_t buffer, int32_t releaseFence) {
1008     ExynosDevice *exynosDevice = checkDevice(dev);
1009 
1010     if (exynosDevice) {
1011         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1012         if (exynosDisplay)
1013             return exynosDisplay->setReadbackBuffer(buffer, releaseFence);
1014     }
1015 
1016     return HWC2_ERROR_BAD_DISPLAY;
1017 }
1018 
exynos_getDisplayCapabilities(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outNumCapabilities,uint32_t * outCapabilities)1019 int32_t exynos_getDisplayCapabilities(hwc2_device_t* dev, hwc2_display_t display, uint32_t* outNumCapabilities,
1020         uint32_t* outCapabilities)
1021 {
1022     ExynosDevice *exynosDevice = checkDevice(dev);
1023 
1024     if (exynosDevice) {
1025         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1026         if (exynosDisplay) {
1027             return exynosDisplay->getDisplayCapabilities(outNumCapabilities, outCapabilities);
1028         }
1029     }
1030 
1031     return HWC2_ERROR_BAD_DISPLAY;
1032 }
1033 
exynos_setLayerColorTransform(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,const float * matrix)1034 int32_t exynos_setLayerColorTransform(hwc2_device_t* dev,
1035         hwc2_display_t display, hwc2_layer_t layer, const float* matrix)
1036 {
1037     if (matrix == nullptr)
1038         return HWC2_ERROR_BAD_PARAMETER;
1039 
1040     ExynosDevice *exynosDevice = checkDevice(dev);
1041 
1042     if (exynosDevice) {
1043         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1044         if (exynosDisplay) {
1045             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
1046             if (exynosLayer)
1047                 return exynosLayer->setLayerColorTransform(matrix);
1048         }
1049     }
1050 
1051     return HWC2_ERROR_BAD_DISPLAY;
1052 }
1053 
exynos_getReadbackBufferFence(hwc2_device_t * dev,hwc2_display_t display,int32_t * outFence)1054 int32_t exynos_getReadbackBufferFence(hwc2_device_t *dev, hwc2_display_t display,
1055         int32_t* outFence) {
1056     ExynosDevice *exynosDevice = checkDevice(dev);
1057 
1058     if (exynosDevice) {
1059         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1060         if (exynosDisplay)
1061             return exynosDisplay->getReadbackBufferFence(outFence);
1062     }
1063 
1064     return HWC2_ERROR_BAD_DISPLAY;
1065 }
1066 
exynos_setLayerPerFrameMetadataBlobs(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,uint32_t numElements,const int32_t * keys,const uint32_t * sizes,const uint8_t * metadata)1067 int32_t exynos_setLayerPerFrameMetadataBlobs(hwc2_device_t* dev, hwc2_display_t display,
1068         hwc2_layer_t layer, uint32_t numElements, const int32_t* keys, const uint32_t* sizes,
1069         const uint8_t* metadata)
1070 {
1071     if ((keys == nullptr) || (sizes == nullptr) || (metadata == nullptr))
1072         return HWC2_ERROR_BAD_PARAMETER;
1073 
1074     ExynosDevice *exynosDevice = checkDevice(dev);
1075 
1076     if (exynosDevice) {
1077         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1078         if (exynosDisplay) {
1079             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
1080             if (exynosLayer)
1081                 return exynosLayer->setLayerPerFrameMetadataBlobs(numElements, keys, sizes, metadata);
1082         }
1083     }
1084 
1085     return HWC2_ERROR_BAD_DISPLAY;
1086 }
1087 
exynos_getDisplayBrightnessSupport(hwc2_device_t * dev,hwc2_display_t display,bool * outSupport)1088 int32_t exynos_getDisplayBrightnessSupport(hwc2_device_t* dev, hwc2_display_t display, bool* outSupport)
1089 {
1090     ExynosDevice *exynosDevice = checkDevice(dev);
1091 
1092     if (exynosDevice) {
1093         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1094         if (exynosDisplay) {
1095             return exynosDisplay->getDisplayBrightnessSupport(outSupport);
1096         }
1097     }
1098 
1099     return HWC2_ERROR_BAD_DISPLAY;
1100 }
1101 
exynos_setDisplayBrightness(hwc2_device_t * dev,hwc2_display_t display,float brightness)1102 int32_t exynos_setDisplayBrightness(hwc2_device_t* dev, hwc2_display_t display, float brightness)
1103 {
1104     ExynosDevice *exynosDevice = checkDevice(dev);
1105 
1106     if (exynosDevice) {
1107         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1108         if (exynosDisplay) {
1109             return exynosDisplay->setDisplayBrightness(brightness);
1110         }
1111     }
1112 
1113     return HWC2_ERROR_BAD_DISPLAY;
1114 }
1115 
exynos_GetDisplayConnectionType(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outType)1116 int32_t exynos_GetDisplayConnectionType(hwc2_device_t* dev, hwc2_display_t display,
1117         uint32_t* /*hwc2_display_connection_type_t*/ outType)
1118 {
1119     ExynosDevice *exynosDevice = checkDevice(dev);
1120 
1121     if (exynosDevice) {
1122         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1123         if (exynosDisplay) {
1124             return exynosDisplay->getDisplayConnectionType(outType);
1125         }
1126     }
1127 
1128     return HWC2_ERROR_BAD_DISPLAY;
1129 }
1130 
exynos_GetDisplayVsyncPeriod(hwc2_device_t * dev,hwc2_display_t display,hwc2_vsync_period_t * outVsyncPeriod)1131 int32_t exynos_GetDisplayVsyncPeriod(hwc2_device_t* dev, hwc2_display_t display,
1132         hwc2_vsync_period_t* outVsyncPeriod)
1133 {
1134     ExynosDevice *exynosDevice = checkDevice(dev);
1135 
1136     if (exynosDevice) {
1137         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1138         if (exynosDisplay) {
1139             return exynosDisplay->getDisplayVsyncPeriod(outVsyncPeriod);
1140         }
1141     }
1142 
1143     return HWC2_ERROR_BAD_DISPLAY;
1144 }
1145 
exynos_SetActiveConfigWithConstraints(hwc2_device_t * dev,hwc2_display_t display,hwc2_config_t config,hwc_vsync_period_change_constraints_t * vsyncPeriodChangeConstraints,hwc_vsync_period_change_timeline_t * outTimeline)1146 int32_t exynos_SetActiveConfigWithConstraints(hwc2_device_t* dev, hwc2_display_t display,
1147         hwc2_config_t config, hwc_vsync_period_change_constraints_t* vsyncPeriodChangeConstraints,
1148         hwc_vsync_period_change_timeline_t* outTimeline)
1149 {
1150     HDEBUGLOGD(eDebugDisplayConfig, "%s, %d", __func__, config);
1151     ExynosDevice *exynosDevice = checkDevice(dev);
1152 
1153     if (exynosDevice) {
1154         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1155         if (exynosDisplay) {
1156             return exynosDisplay->setActiveConfigWithConstraints(config, vsyncPeriodChangeConstraints, outTimeline);
1157         }
1158     }
1159 
1160     return HWC2_ERROR_BAD_DISPLAY;
1161 }
1162 
exynos_SetAutoLowLatencyMode(hwc2_device_t * dev,hwc2_display_t display,bool on)1163 int32_t exynos_SetAutoLowLatencyMode(hwc2_device_t* dev, hwc2_display_t display, bool on)
1164 {
1165     ExynosDevice *exynosDevice = checkDevice(dev);
1166 
1167     if (exynosDevice) {
1168         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1169         if (exynosDisplay) {
1170             return exynosDisplay->setAutoLowLatencyMode(on);
1171         }
1172     }
1173 
1174     return HWC2_ERROR_BAD_DISPLAY;
1175 }
1176 
exynos_GetSupportedContentTypes(hwc2_device_t * dev,hwc2_display_t display,uint32_t * outNumSupportedContentTypes,uint32_t * outSupportedContentTypes)1177 int32_t exynos_GetSupportedContentTypes(hwc2_device_t* dev, hwc2_display_t display,
1178         uint32_t* outNumSupportedContentTypes, uint32_t* outSupportedContentTypes)
1179 {
1180     ExynosDevice *exynosDevice = checkDevice(dev);
1181 
1182     if (exynosDevice) {
1183         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1184         if (exynosDisplay) {
1185             return exynosDisplay->getSupportedContentTypes(outNumSupportedContentTypes, outSupportedContentTypes);
1186         }
1187     }
1188 
1189     return HWC2_ERROR_BAD_DISPLAY;
1190 }
1191 
exynos_SetContentType(hwc2_device_t * dev,hwc2_display_t display,int32_t contentType)1192 int32_t exynos_SetContentType(hwc2_device_t* dev, hwc2_display_t display,
1193         int32_t /* hwc2_content_type_t */ contentType)
1194 {
1195     ExynosDevice *exynosDevice = checkDevice(dev);
1196 
1197     if (exynosDevice) {
1198         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1199         if (exynosDisplay) {
1200             return exynosDisplay->setContentType(contentType);
1201         }
1202     }
1203 
1204     return HWC2_ERROR_BAD_DISPLAY;
1205 }
1206 
exynos_GetClientTargetProperty(hwc2_device_t * dev,hwc2_display_t display,hwc_client_target_property_t * outClientTargetProperty)1207 int32_t exynos_GetClientTargetProperty(hwc2_device_t* dev, hwc2_display_t display,
1208         hwc_client_target_property_t* outClientTargetProperty)
1209 {
1210     ExynosDevice *exynosDevice = checkDevice(dev);
1211 
1212     if (exynosDevice) {
1213         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1214         if (exynosDisplay) {
1215             /* TODO */
1216             return exynosDisplay->getClientTargetProperty(outClientTargetProperty);
1217         }
1218     }
1219 
1220     return HWC2_ERROR_BAD_DISPLAY;
1221 }
1222 
exynos_SetLayerGenericMetadata(hwc2_device_t * dev,hwc2_display_t display,hwc2_layer_t layer,uint32_t keyLength,const char * key,bool mandatory,uint32_t valueLength,const uint8_t * value)1223 int32_t exynos_SetLayerGenericMetadata(hwc2_device_t* dev, hwc2_display_t display,
1224         hwc2_layer_t layer, uint32_t keyLength, const char* key,
1225         bool mandatory, uint32_t valueLength, const uint8_t* value)
1226 {
1227     ExynosDevice *exynosDevice = checkDevice(dev);
1228 
1229     if (exynosDevice) {
1230         ExynosDisplay *exynosDisplay = checkDisplay(exynosDevice, display);
1231         if (exynosDisplay) {
1232             ExynosLayer *exynosLayer = checkLayer(exynosDisplay, layer);
1233             if (exynosLayer == nullptr)
1234                 return HWC2_ERROR_BAD_LAYER;
1235 
1236             return exynosLayer->setLayerGenericMetadata(layer,
1237                     keyLength, key, mandatory, valueLength, value);
1238         }
1239     }
1240 
1241     return HWC2_ERROR_BAD_DISPLAY;
1242 }
1243 
exynos_GetLayerGenericMetadataKey(hwc2_device_t * dev,uint32_t keyIndex,uint32_t * outKeyLength,char * outKey,bool * outMandatory)1244 void exynos_GetLayerGenericMetadataKey(hwc2_device_t* dev, uint32_t keyIndex,
1245         uint32_t* outKeyLength, char* outKey, bool* outMandatory)
1246 {
1247     ExynosDevice *exynosDevice = checkDevice(dev);
1248 
1249     if (exynosDevice) {
1250         return exynosDevice->getLayerGenericMetadataKey(keyIndex, outKeyLength, outKey, outMandatory);
1251     }
1252 
1253     return;
1254 }
1255 
1256 /* ************************************************************************************/
1257 
exynos_boot_finished(ExynosHWCCtx * dev)1258 void exynos_boot_finished(ExynosHWCCtx *dev)
1259 {
1260     ALOGI("%s +", __func__);
1261     int sw_fd;
1262 
1263     if (dev == NULL) {
1264         ALOGE("%s:: dev is NULL", __func__);
1265         return;
1266     }
1267 
1268     char cablestate_name[MAX_DEV_NAME + 1];
1269     cablestate_name[MAX_DEV_NAME] = '\0';
1270     sprintf(cablestate_name, DP_CABLE_STATE_NAME, DP_LINK_NAME);
1271     sw_fd = open(cablestate_name, O_RDONLY);
1272 
1273     if (sw_fd >= 0) {
1274         char val;
1275         if (read(sw_fd, &val, 1) == 1 && val == '1') {
1276             ALOGI("%s : try to reconnect displayport", __func__);
1277             ExynosExternalDisplayModule *display = (ExynosExternalDisplayModule*)dev->device->getDisplay(getDisplayId(HWC_DISPLAY_EXTERNAL, 0));
1278             if (display != nullptr)
1279                 display->handleHotplugEvent();
1280         }
1281         hwcFdClose(sw_fd);
1282     }
1283     ALOGI("%s -", __func__);
1284 }
1285 
exynos_close(hw_device_t * device)1286 int exynos_close(hw_device_t* device)
1287 {
1288     if (device == NULL)
1289     {
1290         ALOGE("%s:: device is null", __func__);
1291         return -EINVAL;
1292     }
1293 
1294     /* For HWC2.x version */
1295     struct exynos_hwc2_device_t *dev = (struct exynos_hwc2_device_t *)device;
1296     if (dev != NULL) {
1297         if (dev->device != NULL)
1298             delete dev->device;
1299         delete dev;
1300     }
1301 
1302     return NO_ERROR;
1303 }
1304 
exynos_open(const struct hw_module_t * module,const char * name,struct hw_device_t ** device)1305 int exynos_open(const struct hw_module_t *module, const char *name,
1306         struct hw_device_t **device)
1307 {
1308     if (strcmp(name, HWC_HARDWARE_COMPOSER)) {
1309         return -EINVAL;
1310     }
1311 
1312     void *ptrDev = NULL;
1313 
1314     ALOGD("HWC module_api_version(%d), hal_api_version(%d)",
1315             module->module_api_version, module->hal_api_version);
1316     /* For HWC2.x version */
1317     struct exynos_hwc2_device_t *dev;
1318     dev = (struct exynos_hwc2_device_t *)malloc(sizeof(*dev));
1319     memset(dev, 0, sizeof(*dev));
1320 
1321     dev->device = new ExynosDeviceModule;
1322     g_exynosDevice = dev->device;
1323 
1324     dev->base.common.tag = HARDWARE_DEVICE_TAG;
1325     dev->base.common.version = HWC_DEVICE_API_VERSION_2_0;
1326     dev->base.common.module = const_cast<hw_module_t *>(module);
1327     dev->base.common.close = exynos_close;
1328 
1329     dev->base.getCapabilities = exynos_getCapabilities;
1330     dev->base.getFunction = exynos_getFunction;
1331     *device = &dev->base.common;
1332     ptrDev = dev;
1333 
1334     ALOGD("Start HWCService");
1335 #ifdef USES_HWC_SERVICES
1336     ExynosHWCCtx *hwcCtx = (ExynosHWCCtx*)ptrDev;
1337     android::ExynosHWCService   *HWCService;
1338     HWCService = android::ExynosHWCService::getExynosHWCService();
1339     HWCService->setExynosHWCCtx(hwcCtx);
1340     HWCService->setBootFinishedCallback(exynos_boot_finished);
1341 #endif
1342 
1343     return NO_ERROR;
1344 }
1345 
1346 static struct hw_module_methods_t exynos_hwc_module_methods = {
1347     .open = exynos_open,
1348 };
1349 
1350 hwc_module_t HAL_MODULE_INFO_SYM = {
1351     .common = {
1352         .tag = HARDWARE_MODULE_TAG,
1353         .module_api_version = 2,
1354         .hal_api_version = 0,
1355         .id = HWC_HARDWARE_MODULE_ID,
1356         .name = "Samsung exynos hwcomposer module",
1357         .author = "Samsung LSI",
1358         .methods = &exynos_hwc_module_methods,
1359         .dso = 0,
1360         .reserved = {0},
1361     }
1362 };
1363