summaryrefslogtreecommitdiff
path: root/hwc2/common/base/HwcModule.cpp (plain)
blob: 9b3a34b7f35c1517b1fb2b94d1869e32a86d7a17
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
50namespace android {
51namespace amlogic {
52
53static int hwc2_device_close(struct hw_device_t *dev)
54{
55 CTRACE();
56 Hwcomposer::releaseInstance();
57 return 0;
58}
59
60int32_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
75int32_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
84void 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
92uint32_t getMaxVirtualDisplayCount(
93 hwc2_device_t* device) {
94 GET_HWC();
95
96 uint32_t ret = hwc->getMaxVirtualDisplayCount();
97
98 return ret;
99}
100
101int32_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
113int32_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
122int32_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
132int32_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
142int32_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
152int32_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
164int32_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
175int32_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
185int32_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
195int32_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
205int32_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
215int32_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
230int32_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
240int32_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
250int32_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
263int32_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
274int32_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
284int32_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
295int32_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
306int32_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
316int32_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
326int32_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
336int32_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
346int32_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
356int32_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
366int32_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
376int32_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
387int32_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
409int32_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
419int32_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
429int32_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
439int32_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
449int32_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
459int32_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
469int32_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
479int32_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
489int32_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
499int32_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
509int32_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
519hwc2_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_COLOR_MODES:
548 return reinterpret_cast<hwc2_function_pointer_t>(getColorModes);
549 case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE:
550 return reinterpret_cast<hwc2_function_pointer_t>(getDisplayAttribute);
551 case HWC2_FUNCTION_GET_DISPLAY_CONFIGS:
552 return reinterpret_cast<hwc2_function_pointer_t>(getDisplayConfigs);
553 case HWC2_FUNCTION_GET_DISPLAY_NAME:
554 return reinterpret_cast<hwc2_function_pointer_t>(getDisplayName);
555 case HWC2_FUNCTION_GET_DISPLAY_REQUESTS:
556 return reinterpret_cast<hwc2_function_pointer_t>(getDisplayRequests);
557 case HWC2_FUNCTION_GET_DISPLAY_TYPE:
558 return reinterpret_cast<hwc2_function_pointer_t>(getDisplayType);
559 case HWC2_FUNCTION_GET_DOZE_SUPPORT:
560 return reinterpret_cast<hwc2_function_pointer_t>(getDozeSupport);
561 case HWC2_FUNCTION_GET_HDR_CAPABILITIES:
562 return reinterpret_cast<hwc2_function_pointer_t>(getHdrCapabilities);
563 case HWC2_FUNCTION_GET_RELEASE_FENCES:
564 return reinterpret_cast<hwc2_function_pointer_t>(getReleaseFences);
565 case HWC2_FUNCTION_PRESENT_DISPLAY:
566 return reinterpret_cast<hwc2_function_pointer_t>(presentDisplay);
567 case HWC2_FUNCTION_SET_ACTIVE_CONFIG:
568 return reinterpret_cast<hwc2_function_pointer_t>(setActiveConfig);
569 case HWC2_FUNCTION_SET_CLIENT_TARGET:
570 return reinterpret_cast<hwc2_function_pointer_t>(setClientTarget);
571 case HWC2_FUNCTION_SET_COLOR_MODE:
572 return reinterpret_cast<hwc2_function_pointer_t>(setColorMode);
573 case HWC2_FUNCTION_SET_COLOR_TRANSFORM:
574 return reinterpret_cast<hwc2_function_pointer_t>(setColorTransform);
575 case HWC2_FUNCTION_SET_OUTPUT_BUFFER:
576 return reinterpret_cast<hwc2_function_pointer_t>(setOutputBuffer);
577 case HWC2_FUNCTION_SET_POWER_MODE:
578 return reinterpret_cast<hwc2_function_pointer_t>(setPowerMode);
579 case HWC2_FUNCTION_SET_VSYNC_ENABLED:
580 return reinterpret_cast<hwc2_function_pointer_t>(setVsyncEnabled);
581 case HWC2_FUNCTION_VALIDATE_DISPLAY:
582 return reinterpret_cast<hwc2_function_pointer_t>(validateDisplay);
583
584 // Layer functions
585 case HWC2_FUNCTION_SET_CURSOR_POSITION:
586 return reinterpret_cast<hwc2_function_pointer_t>(setCursorPosition);
587 case HWC2_FUNCTION_SET_LAYER_BUFFER:
588 return reinterpret_cast<hwc2_function_pointer_t>(setLayerBuffer);
589 case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE:
590 return reinterpret_cast<hwc2_function_pointer_t>(setLayerSurfaceDamage);
591
592 // Layer state functions
593 case HWC2_FUNCTION_SET_LAYER_BLEND_MODE:
594 return reinterpret_cast<hwc2_function_pointer_t>(setLayerBlendMode);
595 case HWC2_FUNCTION_SET_LAYER_COLOR:
596 return reinterpret_cast<hwc2_function_pointer_t>(setLayerColor);
597 case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE:
598 return reinterpret_cast<hwc2_function_pointer_t>(setLayerCompositionType);
599 case HWC2_FUNCTION_SET_LAYER_DATASPACE:
600 return reinterpret_cast<hwc2_function_pointer_t>(setLayerDataspace);
601 case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME:
602 return reinterpret_cast<hwc2_function_pointer_t>(setLayerDisplayFrame);
603 case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA:
604 return reinterpret_cast<hwc2_function_pointer_t>(setLayerPlaneAlpha);
605 case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM:
606 return reinterpret_cast<hwc2_function_pointer_t>(setLayerSidebandStream);
607 case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP:
608 return reinterpret_cast<hwc2_function_pointer_t>(setLayerSourceCrop);
609 case HWC2_FUNCTION_SET_LAYER_TRANSFORM:
610 return reinterpret_cast<hwc2_function_pointer_t>(setLayerTransform);
611 case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION:
612 return reinterpret_cast<hwc2_function_pointer_t>(setLayerVisibleRegion);
613 case HWC2_FUNCTION_SET_LAYER_Z_ORDER:
614 return reinterpret_cast<hwc2_function_pointer_t>(setLayerZOrder);
615 default:
616 ETRACE("getFunction: Unknown function descriptor: %d", descriptor);
617 return NULL;
618 }
619}
620
621void hwc2_getCapabilities(struct hwc2_device* device,
622 uint32_t* outCount,
623 int32_t* /*hwc2_capability_t*/ outCapabilities) {
624 GET_HWC_RETURN_VOID_IF_NULL();
625 if (NULL == outCapabilities) {
626 *outCount = 1;
627 } else {
628 *outCount = 1;
629 outCapabilities[0] = HWC2_CAPABILITY_SIDEBAND_STREAM;
630 }
631}
632
633//------------------------------------------------------------------------------
634
635static int hwc2_device_open(const struct hw_module_t* module,
636 const char* name,
637 struct hw_device_t** device)
638{
639 if (!name) {
640 ETRACE("invalid name.");
641 return -EINVAL;
642 }
643
644 ATRACE("open device %s", name);
645
646 if (strcmp(name, HWC_HARDWARE_COMPOSER) != 0) {
647 ETRACE("try to open unknown HWComposer %s", name);
648 return -EINVAL;
649 }
650
651 private_module_t *gralloc_module = NULL;
652 if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
653 (const struct hw_module_t **)&gralloc_module)) {
654 ETRACE("failed to get gralloc hw module");
655 return -EINVAL;
656 }
657
658 Hwcomposer& hwc = Hwcomposer::getInstance();
659 // initialize our state here
660 if (hwc.initialize(gralloc_module) == false) {
661 ETRACE("failed to intialize HWComposer");
662 Hwcomposer::releaseInstance();
663 return -EINVAL;
664 }
665
666 // initialize the procs
667 hwc.hwc2_device_t::common.tag = HARDWARE_DEVICE_TAG;
668 hwc.hwc2_device_t::common.module =
669 const_cast<hw_module_t*>(module);
670 hwc.hwc2_device_t::common.close = hwc2_device_close;
671
672 hwc.hwc2_device_t::getFunction = hwc2_getFunction;
673 hwc.hwc2_device_t::getCapabilities = hwc2_getCapabilities;
674 hwc.hwc2_device_t::common.version = HWC_DEVICE_API_VERSION_2_0;
675 *device = &hwc.hwc2_device_t::common;
676
677 return 0;
678}
679
680} // namespace amlogic
681} // namespace android
682
683typedef struct hwc_module {
684 /**
685 * Common methods of the hardware composer module. This *must* be the first member of
686 * hwc_module as users of this structure will cast a hw_module_t to
687 * hwc_module pointer in contexts where it's known the hw_module_t references a
688 * hwc_module.
689 */
690 struct hw_module_t common;
691} hwc_module_t;
692
693static struct hw_module_methods_t hwc2_module_methods = {
694 .open = android::amlogic::hwc2_device_open
695};
696
697hwc_module_t HAL_MODULE_INFO_SYM = {
698 .common = {
699 .tag = HARDWARE_MODULE_TAG,
700 .version_major = 2,
701 .version_minor = 0,
702 .id = HWC_HARDWARE_MODULE_ID,
703 .name = "AML Hardware Composer",
704 .author = "aml",
705 .methods = &hwc2_module_methods,
706 .dso = NULL,
707 .reserved = {0},
708 }
709};
710