blob: 5af17131b2c5bc365f6b4716603c795e8b16b18f
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 | #include <hardware/hardware.h> |
20 | #include <string.h> |
21 | #include <stdio.h> |
22 | #include <fcntl.h> |
23 | #include <errno.h> |
24 | #include <HwcTrace.h> |
25 | #include <Hwcomposer.h> |
26 | |
27 | #define GET_HWC_RETURN_X_IF_NULL(X) \ |
28 | CTRACE(); \ |
29 | Hwcomposer *hwc = static_cast<Hwcomposer*>(device); \ |
30 | do {\ |
31 | if (!hwc) { \ |
32 | ETRACE("invalid HWC device."); \ |
33 | return X; \ |
34 | } \ |
35 | } while (0) |
36 | |
37 | #define GET_HWC() \ |
38 | CTRACE(); \ |
39 | Hwcomposer *hwc = static_cast<Hwcomposer*>(device); \ |
40 | do {\ |
41 | if (!hwc) { \ |
42 | ETRACE("invalid HWC device."); \ |
43 | } \ |
44 | } while (0) |
45 | |
46 | #define GET_HWC_RETURN_ERROR_IF_NULL() GET_HWC_RETURN_X_IF_NULL(-EINVAL) |
47 | #define GET_HWC_RETURN_VOID_IF_NULL() GET_HWC_RETURN_X_IF_NULL() |
48 | #define GET_HWC_RETURN_NULL_IF_NULL() GET_HWC_RETURN_X_IF_NULL(NULL) |
49 | |
50 | namespace android { |
51 | namespace amlogic { |
52 | |
53 | static int hwc2_device_close(struct hw_device_t *dev) |
54 | { |
55 | CTRACE(); |
56 | Hwcomposer::releaseInstance(); |
57 | return 0; |
58 | } |
59 | |
60 | int32_t createVirtualDisplay( |
61 | hwc2_device_t* device, uint32_t width, |
62 | uint32_t height, int32_t* format, |
63 | hwc2_display_t* outDisplay) { |
64 | GET_HWC(); |
65 | |
66 | if (width > 1920 && height > 1080) { |
67 | return HWC2_ERROR_UNSUPPORTED; |
68 | } |
69 | |
70 | int32_t ret = hwc->createVirtualDisplay(width, height, format, outDisplay); |
71 | |
72 | return ret; |
73 | } |
74 | |
75 | int32_t destroyVirtualDisplay( |
76 | hwc2_device_t* device, hwc2_display_t display) { |
77 | GET_HWC(); |
78 | |
79 | int32_t ret = hwc->destroyVirtualDisplay(display); |
80 | |
81 | return ret; |
82 | } |
83 | |
84 | void dump(hwc2_device_t* device, |
85 | uint32_t* outSize, |
86 | char* outBuffer) { |
87 | GET_HWC_RETURN_VOID_IF_NULL(); |
88 | |
89 | hwc->dump(outSize, outBuffer); |
90 | } |
91 | |
92 | uint32_t getMaxVirtualDisplayCount( |
93 | hwc2_device_t* device) { |
94 | GET_HWC(); |
95 | |
96 | uint32_t ret = hwc->getMaxVirtualDisplayCount(); |
97 | |
98 | return ret; |
99 | } |
100 | |
101 | int32_t registerCallback( |
102 | hwc2_device_t* device, |
103 | hwc2_callback_descriptor_t descriptor, |
104 | hwc2_callback_data_t callbackData, |
105 | hwc2_function_pointer_t pointer) { |
106 | GET_HWC(); |
107 | |
108 | int32_t ret = hwc->registerCallback(descriptor, callbackData, pointer); |
109 | |
110 | return ret; |
111 | } |
112 | |
113 | int32_t acceptDisplayChanges( |
114 | hwc2_device_t* device, hwc2_display_t display) { |
115 | GET_HWC(); |
116 | |
117 | int32_t ret = hwc->acceptDisplayChanges(display); |
118 | |
119 | return ret; |
120 | } |
121 | |
122 | int32_t createLayer( |
123 | hwc2_device_t* device, hwc2_display_t display, |
124 | hwc2_layer_t* outLayer) { |
125 | GET_HWC(); |
126 | |
127 | int32_t ret = hwc->createLayer(display, outLayer); |
128 | |
129 | return ret; |
130 | } |
131 | |
132 | int32_t destroyLayer( |
133 | hwc2_device_t* device, hwc2_display_t display, |
134 | hwc2_layer_t layer) { |
135 | GET_HWC(); |
136 | |
137 | int32_t ret = hwc->destroyLayer(display, layer); |
138 | |
139 | return ret; |
140 | } |
141 | |
142 | int32_t getActiveConfig( |
143 | hwc2_device_t* device, hwc2_display_t display, |
144 | hwc2_config_t* outConfig) { |
145 | GET_HWC(); |
146 | |
147 | int32_t ret = hwc->getActiveConfig(display, outConfig); |
148 | |
149 | return ret; |
150 | } |
151 | |
152 | int32_t getChangedCompositionTypes( |
153 | hwc2_device_t* device, hwc2_display_t display, |
154 | uint32_t* outNumElements, hwc2_layer_t* outLayers, |
155 | int32_t* outTypes) { |
156 | GET_HWC(); |
157 | |
158 | int32_t ret = hwc->getChangedCompositionTypes(display, outNumElements, |
159 | outLayers, outTypes); |
160 | |
161 | return ret; |
162 | } |
163 | |
164 | int32_t getClientTargetSupport( |
165 | hwc2_device_t* device, hwc2_display_t display, uint32_t width, |
166 | uint32_t height, android_pixel_format_t format, |
167 | android_dataspace_t dataspace) { |
168 | GET_HWC(); |
169 | |
170 | int32_t ret = hwc->getClientTargetSupport(display, width, height, format, dataspace); |
171 | |
172 | return ret; |
173 | } |
174 | |
175 | int32_t getColorModes( |
176 | hwc2_device_t* device, hwc2_display_t display, |
177 | uint32_t* outNumModes, int32_t* /*android_color_mode_t*/ outModes) { |
178 | GET_HWC(); |
179 | |
180 | int32_t ret = hwc->getColorModes(display, outNumModes, outModes); |
181 | |
182 | return ret; |
183 | } |
184 | |
185 | int32_t getDisplayAttribute( |
186 | hwc2_device_t* device, hwc2_display_t display, |
187 | hwc2_config_t config, hwc2_attribute_t attribute, int32_t* outValue) { |
188 | GET_HWC(); |
189 | |
190 | int32_t ret = hwc->getDisplayAttribute(display, config, attribute, outValue); |
191 | |
192 | return ret; |
193 | } |
194 | |
195 | int32_t getDisplayConfigs( |
196 | hwc2_device_t* device, hwc2_display_t display, |
197 | uint32_t* outNumConfigs, hwc2_config_t* outConfigs) { |
198 | GET_HWC(); |
199 | |
200 | int32_t ret = hwc->getDisplayConfigs(display, outNumConfigs, outConfigs); |
201 | |
202 | return ret; |
203 | } |
204 | |
205 | int32_t getDisplayName( |
206 | hwc2_device_t* device, hwc2_display_t display, |
207 | uint32_t* outSize, char* outName) { |
208 | GET_HWC(); |
209 | |
210 | int32_t ret = hwc->getDisplayName(display, outSize, outName); |
211 | |
212 | return ret; |
213 | } |
214 | |
215 | int32_t getDisplayRequests( |
216 | hwc2_device_t* device, |
217 | hwc2_display_t display, |
218 | int32_t* outDisplayRequests, |
219 | uint32_t* outNumElements, |
220 | hwc2_layer_t* outLayers, |
221 | int32_t* outLayerRequests) { |
222 | GET_HWC(); |
223 | |
224 | int32_t ret = hwc->getDisplayRequests(display, outDisplayRequests, |
225 | outNumElements, outLayers, outLayerRequests); |
226 | |
227 | return ret; |
228 | } |
229 | |
230 | int32_t getDisplayType( |
231 | hwc2_device_t* device, hwc2_display_t display, |
232 | int32_t* outType) { |
233 | GET_HWC(); |
234 | |
235 | int32_t ret = hwc->getDisplayType(display, outType); |
236 | |
237 | return ret; |
238 | } |
239 | |
240 | int32_t getDozeSupport( |
241 | hwc2_device_t* device, hwc2_display_t display, |
242 | int32_t* outSupport) { |
243 | GET_HWC(); |
244 | |
245 | int32_t ret = hwc->getDozeSupport(display, outSupport); |
246 | |
247 | return ret; |
248 | } |
249 | |
250 | int32_t getHdrCapabilities( |
251 | hwc2_device_t* device, hwc2_display_t display, |
252 | uint32_t* outNumTypes, int32_t* /*android_hdr_t*/ outTypes, |
253 | float* outMaxLuminance, float* outMaxAverageLuminance, |
254 | float* outMinLuminance) { |
255 | GET_HWC(); |
256 | |
257 | int32_t ret = hwc->getHdrCapabilities(display, outNumTypes, outTypes, |
258 | outMaxLuminance, outMaxAverageLuminance, outMinLuminance); |
259 | |
260 | return ret; |
261 | } |
262 | |
263 | int32_t getReleaseFences( |
264 | hwc2_device_t* device, hwc2_display_t display, |
265 | uint32_t* outNumElements, hwc2_layer_t* outLayers, |
266 | int32_t* outFences) { |
267 | GET_HWC(); |
268 | |
269 | int32_t ret = hwc->getReleaseFences(display, outNumElements, outLayers, outFences); |
270 | |
271 | return ret; |
272 | } |
273 | |
274 | int32_t presentDisplay( |
275 | hwc2_device_t* device, hwc2_display_t display, |
276 | int32_t* outRetireFence) { |
277 | GET_HWC(); |
278 | |
279 | int32_t ret = hwc->presentDisplay(display, outRetireFence); |
280 | |
281 | return ret; |
282 | } |
283 | |
284 | int32_t setActiveConfig( |
285 | hwc2_device_t* device, |
286 | hwc2_display_t display, |
287 | hwc2_config_t config) { |
288 | GET_HWC(); |
289 | |
290 | int32_t ret = hwc->setActiveConfig(display, config); |
291 | |
292 | return ret; |
293 | } |
294 | |
295 | int32_t setClientTarget( |
296 | hwc2_device_t* device, hwc2_display_t display, |
297 | buffer_handle_t target, int32_t acquireFence, |
298 | android_dataspace_t dataspace, hwc_region_t damage) { |
299 | GET_HWC(); |
300 | |
301 | int32_t ret = hwc->setClientTarget(display, target, acquireFence, dataspace, damage); |
302 | |
303 | return ret; |
304 | } |
305 | |
306 | int32_t setColorMode( |
307 | hwc2_device_t* device, hwc2_display_t display, |
308 | int32_t /*android_color_mode_t*/ mode) { |
309 | GET_HWC(); |
310 | |
311 | int32_t ret = hwc->setColorMode(display, mode); |
312 | |
313 | return ret; |
314 | } |
315 | |
316 | int32_t setColorTransform( |
317 | hwc2_device_t* device, hwc2_display_t display, |
318 | const float* matrix, int32_t /*android_color_transform_t*/ hint) { |
319 | GET_HWC(); |
320 | |
321 | int32_t ret = hwc->setColorTransform(display, matrix, hint); |
322 | |
323 | return ret; |
324 | } |
325 | |
326 | int32_t setOutputBuffer( |
327 | hwc2_device_t* device, hwc2_display_t display, |
328 | buffer_handle_t buffer, int32_t releaseFence) { |
329 | GET_HWC(); |
330 | |
331 | int32_t ret = hwc->setOutputBuffer(display, buffer, releaseFence); |
332 | |
333 | return ret; |
334 | } |
335 | |
336 | int32_t setPowerMode( |
337 | hwc2_device_t* device, hwc2_display_t display, |
338 | hwc2_power_mode_t mode) { |
339 | GET_HWC(); |
340 | |
341 | int32_t ret = hwc->setPowerMode(display, mode); |
342 | |
343 | return ret; |
344 | } |
345 | |
346 | int32_t setVsyncEnabled( |
347 | hwc2_device_t* device, hwc2_display_t display, |
348 | hwc2_vsync_t enabled) { |
349 | GET_HWC(); |
350 | |
351 | int32_t ret = hwc->setVsyncEnabled(display, enabled); |
352 | |
353 | return ret; |
354 | } |
355 | |
356 | int32_t validateDisplay( |
357 | hwc2_device_t* device, hwc2_display_t display, |
358 | uint32_t* outNumTypes, uint32_t* outNumRequests) { |
359 | GET_HWC(); |
360 | |
361 | int32_t ret = hwc->validateDisplay(display, outNumTypes, outNumRequests); |
362 | |
363 | return ret; |
364 | } |
365 | |
366 | int32_t setCursorPosition( |
367 | hwc2_device_t* device, hwc2_display_t display, |
368 | hwc2_layer_t layer, int32_t x, int32_t y) { |
369 | GET_HWC(); |
370 | |
371 | int32_t ret = hwc->setCursorPosition(display, layer, x, y); |
372 | |
373 | return ret; |
374 | } |
375 | |
376 | int32_t setLayerBuffer( |
377 | hwc2_device_t* device, hwc2_display_t display, |
378 | hwc2_layer_t layer, buffer_handle_t buffer, |
379 | int32_t acquireFence) { |
380 | GET_HWC(); |
381 | |
382 | int32_t ret = hwc->setLayerBuffer(display, layer, buffer, acquireFence); |
383 | |
384 | return ret; |
385 | } |
386 | |
387 | int32_t setLayerSurfaceDamage( |
388 | hwc2_device_t* device, hwc2_display_t display, |
389 | hwc2_layer_t layer, hwc_region_t damage) { |
390 | GET_HWC(); |
391 | |
392 | int32_t ret = hwc->setLayerSurfaceDamage(display, layer, damage); |
393 | |
394 | return ret; |
395 | } |
396 | |
397 | /* |
398 | * Layer State Functions |
399 | * |
400 | * These functions modify the state of a given layer. They do not take effect |
401 | * until the display configuration is successfully validated with |
402 | * validateDisplay and the display contents are presented with presentDisplay. |
403 | * |
404 | * All of these functions take as their first three parameters a device pointer, |
405 | * a display handle for the display which contains the layer, and a layer |
406 | * handle, so these parameters are omitted from the described parameter lists. |
407 | */ |
408 | |
409 | int32_t setLayerBlendMode( |
410 | hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer, |
411 | hwc2_blend_mode_t mode) { |
412 | GET_HWC(); |
413 | |
414 | int32_t ret = hwc->setLayerBlendMode(display, layer, mode); |
415 | |
416 | return ret; |
417 | } |
418 | |
419 | int32_t setLayerColor( |
420 | hwc2_device_t* device, hwc2_display_t display, |
421 | hwc2_layer_t layer, hwc_color_t color) { |
422 | GET_HWC(); |
423 | |
424 | int32_t ret = hwc->setLayerColor(display, layer, color); |
425 | |
426 | return ret; |
427 | } |
428 | |
429 | int32_t setLayerCompositionType( |
430 | hwc2_device_t* device, hwc2_display_t display, |
431 | hwc2_layer_t layer, hwc2_composition_t type) { |
432 | GET_HWC(); |
433 | |
434 | int32_t ret = hwc->setLayerCompositionType(display, layer, type); |
435 | |
436 | return ret; |
437 | } |
438 | |
439 | int32_t setLayerDataspace( |
440 | hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer, |
441 | int32_t /*android_dataspace_t*/ dataspace) { |
442 | GET_HWC(); |
443 | |
444 | int32_t ret = hwc->setLayerDataspace(display, layer, dataspace); |
445 | |
446 | return ret; |
447 | } |
448 | |
449 | int32_t setLayerDisplayFrame( |
450 | hwc2_device_t* device, hwc2_display_t display, |
451 | hwc2_layer_t layer, hwc_rect_t frame) { |
452 | GET_HWC(); |
453 | |
454 | int32_t ret = hwc->setLayerDisplayFrame(display, layer, frame); |
455 | |
456 | return ret; |
457 | } |
458 | |
459 | int32_t setLayerPlaneAlpha( |
460 | hwc2_device_t* device, hwc2_display_t display, |
461 | hwc2_layer_t layer, float alpha) { |
462 | GET_HWC(); |
463 | |
464 | int32_t ret = hwc->setLayerPlaneAlpha(display, layer, alpha); |
465 | |
466 | return ret; |
467 | } |
468 | |
469 | int32_t setLayerSidebandStream( |
470 | hwc2_device_t* device, hwc2_display_t display, |
471 | hwc2_layer_t layer, const native_handle_t* stream) { |
472 | GET_HWC(); |
473 | |
474 | int32_t ret = hwc->setLayerSidebandStream(display, layer, stream); |
475 | |
476 | return ret; |
477 | } |
478 | |
479 | int32_t setLayerSourceCrop( |
480 | hwc2_device_t* device, hwc2_display_t display, |
481 | hwc2_layer_t layer, hwc_frect_t crop) { |
482 | GET_HWC(); |
483 | |
484 | int32_t ret = hwc->setLayerSourceCrop(display, layer, crop); |
485 | |
486 | return ret; |
487 | } |
488 | |
489 | int32_t setLayerTransform( |
490 | hwc2_device_t* device, hwc2_display_t display, |
491 | hwc2_layer_t layer, hwc_transform_t transform) { |
492 | GET_HWC(); |
493 | |
494 | int32_t ret = hwc->setLayerTransform(display, layer, transform); |
495 | |
496 | return ret; |
497 | } |
498 | |
499 | int32_t setLayerVisibleRegion( |
500 | hwc2_device_t* device, hwc2_display_t display, |
501 | hwc2_layer_t layer, hwc_region_t visible) { |
502 | GET_HWC(); |
503 | |
504 | int32_t ret = hwc->setLayerVisibleRegion(display, layer, visible); |
505 | |
506 | return ret; |
507 | } |
508 | |
509 | int32_t setLayerZOrder( |
510 | hwc2_device_t* device, hwc2_display_t display, |
511 | hwc2_layer_t layer, uint32_t z) { |
512 | GET_HWC(); |
513 | |
514 | int32_t ret = hwc->setLayerZOrder(display, layer, z); |
515 | |
516 | return ret; |
517 | } |
518 | |
519 | hwc2_function_pointer_t hwc2_getFunction(struct hwc2_device* device, |
520 | int32_t /*hwc2_function_descriptor_t*/ descriptor) { |
521 | GET_HWC_RETURN_NULL_IF_NULL(); |
522 | |
523 | switch (descriptor) { |
524 | // Device functions |
525 | case HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY: |
526 | return reinterpret_cast<hwc2_function_pointer_t>(createVirtualDisplay); |
527 | case HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY: |
528 | return reinterpret_cast<hwc2_function_pointer_t>(destroyVirtualDisplay); |
529 | case HWC2_FUNCTION_DUMP: |
530 | return reinterpret_cast<hwc2_function_pointer_t>(dump); |
531 | case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT: |
532 | return reinterpret_cast<hwc2_function_pointer_t>(getMaxVirtualDisplayCount); |
533 | case HWC2_FUNCTION_REGISTER_CALLBACK: |
534 | return reinterpret_cast<hwc2_function_pointer_t>(registerCallback); |
535 | |
536 | // Display functions |
537 | case HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES: |
538 | return reinterpret_cast<hwc2_function_pointer_t>(acceptDisplayChanges); |
539 | case HWC2_FUNCTION_CREATE_LAYER: |
540 | return reinterpret_cast<hwc2_function_pointer_t>(createLayer); |
541 | case HWC2_FUNCTION_DESTROY_LAYER: |
542 | return reinterpret_cast<hwc2_function_pointer_t>(destroyLayer); |
543 | case HWC2_FUNCTION_GET_ACTIVE_CONFIG: |
544 | return reinterpret_cast<hwc2_function_pointer_t>(getActiveConfig); |
545 | case HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES: |
546 | return reinterpret_cast<hwc2_function_pointer_t>(getChangedCompositionTypes); |
547 | case HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT: |
548 | return reinterpret_cast<hwc2_function_pointer_t>(getClientTargetSupport); |
549 | case HWC2_FUNCTION_GET_COLOR_MODES: |
550 | return reinterpret_cast<hwc2_function_pointer_t>(getColorModes); |
551 | case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE: |
552 | return reinterpret_cast<hwc2_function_pointer_t>(getDisplayAttribute); |
553 | case HWC2_FUNCTION_GET_DISPLAY_CONFIGS: |
554 | return reinterpret_cast<hwc2_function_pointer_t>(getDisplayConfigs); |
555 | case HWC2_FUNCTION_GET_DISPLAY_NAME: |
556 | return reinterpret_cast<hwc2_function_pointer_t>(getDisplayName); |
557 | case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: |
558 | return reinterpret_cast<hwc2_function_pointer_t>(getDisplayRequests); |
559 | case HWC2_FUNCTION_GET_DISPLAY_TYPE: |
560 | return reinterpret_cast<hwc2_function_pointer_t>(getDisplayType); |
561 | case HWC2_FUNCTION_GET_DOZE_SUPPORT: |
562 | return reinterpret_cast<hwc2_function_pointer_t>(getDozeSupport); |
563 | case HWC2_FUNCTION_GET_HDR_CAPABILITIES: |
564 | return reinterpret_cast<hwc2_function_pointer_t>(getHdrCapabilities); |
565 | case HWC2_FUNCTION_GET_RELEASE_FENCES: |
566 | return reinterpret_cast<hwc2_function_pointer_t>(getReleaseFences); |
567 | case HWC2_FUNCTION_PRESENT_DISPLAY: |
568 | return reinterpret_cast<hwc2_function_pointer_t>(presentDisplay); |
569 | case HWC2_FUNCTION_SET_ACTIVE_CONFIG: |
570 | return reinterpret_cast<hwc2_function_pointer_t>(setActiveConfig); |
571 | case HWC2_FUNCTION_SET_CLIENT_TARGET: |
572 | return reinterpret_cast<hwc2_function_pointer_t>(setClientTarget); |
573 | case HWC2_FUNCTION_SET_COLOR_MODE: |
574 | return reinterpret_cast<hwc2_function_pointer_t>(setColorMode); |
575 | case HWC2_FUNCTION_SET_COLOR_TRANSFORM: |
576 | return reinterpret_cast<hwc2_function_pointer_t>(setColorTransform); |
577 | case HWC2_FUNCTION_SET_OUTPUT_BUFFER: |
578 | return reinterpret_cast<hwc2_function_pointer_t>(setOutputBuffer); |
579 | case HWC2_FUNCTION_SET_POWER_MODE: |
580 | return reinterpret_cast<hwc2_function_pointer_t>(setPowerMode); |
581 | case HWC2_FUNCTION_SET_VSYNC_ENABLED: |
582 | return reinterpret_cast<hwc2_function_pointer_t>(setVsyncEnabled); |
583 | case HWC2_FUNCTION_VALIDATE_DISPLAY: |
584 | return reinterpret_cast<hwc2_function_pointer_t>(validateDisplay); |
585 | |
586 | // Layer functions |
587 | case HWC2_FUNCTION_SET_CURSOR_POSITION: |
588 | return reinterpret_cast<hwc2_function_pointer_t>(setCursorPosition); |
589 | case HWC2_FUNCTION_SET_LAYER_BUFFER: |
590 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerBuffer); |
591 | case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE: |
592 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerSurfaceDamage); |
593 | |
594 | // Layer state functions |
595 | case HWC2_FUNCTION_SET_LAYER_BLEND_MODE: |
596 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerBlendMode); |
597 | case HWC2_FUNCTION_SET_LAYER_COLOR: |
598 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerColor); |
599 | case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE: |
600 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerCompositionType); |
601 | case HWC2_FUNCTION_SET_LAYER_DATASPACE: |
602 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerDataspace); |
603 | case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME: |
604 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerDisplayFrame); |
605 | case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA: |
606 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerPlaneAlpha); |
607 | case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM: |
608 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerSidebandStream); |
609 | case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP: |
610 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerSourceCrop); |
611 | case HWC2_FUNCTION_SET_LAYER_TRANSFORM: |
612 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerTransform); |
613 | case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION: |
614 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerVisibleRegion); |
615 | case HWC2_FUNCTION_SET_LAYER_Z_ORDER: |
616 | return reinterpret_cast<hwc2_function_pointer_t>(setLayerZOrder); |
617 | default: |
618 | ETRACE("getFunction: Unknown function descriptor: %d", descriptor); |
619 | return NULL; |
620 | } |
621 | } |
622 | |
623 | void hwc2_getCapabilities(struct hwc2_device* device, |
624 | uint32_t* outCount, |
625 | int32_t* /*hwc2_capability_t*/ outCapabilities) { |
626 | GET_HWC_RETURN_VOID_IF_NULL(); |
627 | if (NULL == outCapabilities) { |
628 | *outCount = 1; |
629 | } else { |
630 | *outCount = 1; |
631 | outCapabilities[0] = HWC2_CAPABILITY_SIDEBAND_STREAM; |
632 | } |
633 | } |
634 | |
635 | //------------------------------------------------------------------------------ |
636 | |
637 | static int hwc2_device_open(const struct hw_module_t* module, |
638 | const char* name, |
639 | struct hw_device_t** device) |
640 | { |
641 | if (!name) { |
642 | ETRACE("invalid name."); |
643 | return -EINVAL; |
644 | } |
645 | |
646 | ATRACE("open device %s", name); |
647 | |
648 | if (strcmp(name, HWC_HARDWARE_COMPOSER) != 0) { |
649 | ETRACE("try to open unknown HWComposer %s", name); |
650 | return -EINVAL; |
651 | } |
652 | |
653 | private_module_t *gralloc_module = NULL; |
654 | if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, |
655 | (const struct hw_module_t **)&gralloc_module)) { |
656 | ETRACE("failed to get gralloc hw module"); |
657 | return -EINVAL; |
658 | } |
659 | |
660 | Hwcomposer& hwc = Hwcomposer::getInstance(); |
661 | // initialize our state here |
662 | if (hwc.initialize(gralloc_module) == false) { |
663 | ETRACE("failed to intialize HWComposer"); |
664 | Hwcomposer::releaseInstance(); |
665 | return -EINVAL; |
666 | } |
667 | |
668 | // initialize the procs |
669 | hwc.hwc2_device_t::common.tag = HARDWARE_DEVICE_TAG; |
670 | hwc.hwc2_device_t::common.module = |
671 | const_cast<hw_module_t*>(module); |
672 | hwc.hwc2_device_t::common.close = hwc2_device_close; |
673 | |
674 | hwc.hwc2_device_t::getFunction = hwc2_getFunction; |
675 | hwc.hwc2_device_t::getCapabilities = hwc2_getCapabilities; |
676 | hwc.hwc2_device_t::common.version = HWC_DEVICE_API_VERSION_2_0; |
677 | *device = &hwc.hwc2_device_t::common; |
678 | |
679 | return 0; |
680 | } |
681 | |
682 | } // namespace amlogic |
683 | } // namespace android |
684 | |
685 | typedef struct hwc_module { |
686 | /** |
687 | * Common methods of the hardware composer module. This *must* be the first member of |
688 | * hwc_module as users of this structure will cast a hw_module_t to |
689 | * hwc_module pointer in contexts where it's known the hw_module_t references a |
690 | * hwc_module. |
691 | */ |
692 | struct hw_module_t common; |
693 | } hwc_module_t; |
694 | |
695 | static struct hw_module_methods_t hwc2_module_methods = { |
696 | .open = android::amlogic::hwc2_device_open |
697 | }; |
698 | |
699 | hwc_module_t HAL_MODULE_INFO_SYM = { |
700 | .common = { |
701 | .tag = HARDWARE_MODULE_TAG, |
702 | .version_major = 2, |
703 | .version_minor = 0, |
704 | .id = HWC_HARDWARE_MODULE_ID, |
705 | .name = "AML Hardware Composer", |
706 | .author = "aml", |
707 | .methods = &hwc2_module_methods, |
708 | .dso = NULL, |
709 | .reserved = {0}, |
710 | } |
711 | }; |
712 |