2010-08-06 00:24:35 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
2015-01-29 04:54:13 +01:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <malloc.h>
|
2017-09-06 05:16:25 +02:00
|
|
|
#include <string.h>
|
2010-08-06 00:24:35 +02:00
|
|
|
|
|
|
|
#include <cutils/atomic.h>
|
2017-04-11 17:56:09 +02:00
|
|
|
#include <log/log.h>
|
2010-08-06 00:24:35 +02:00
|
|
|
|
2017-04-11 17:56:09 +02:00
|
|
|
#include <hardware/hardware.h>
|
2010-08-06 00:24:35 +02:00
|
|
|
#include <hardware/hwcomposer.h>
|
|
|
|
|
|
|
|
#include <EGL/egl.h>
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
struct hwc_context_t {
|
2012-06-06 08:41:37 +02:00
|
|
|
hwc_composer_device_1_t device;
|
2010-08-06 00:24:35 +02:00
|
|
|
/* our private state goes below here */
|
|
|
|
};
|
|
|
|
|
|
|
|
static int hwc_device_open(const struct hw_module_t* module, const char* name,
|
|
|
|
struct hw_device_t** device);
|
|
|
|
|
|
|
|
static struct hw_module_methods_t hwc_module_methods = {
|
2016-07-01 01:43:40 +02:00
|
|
|
.open = hwc_device_open
|
2010-08-06 00:24:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
hwc_module_t HAL_MODULE_INFO_SYM = {
|
2016-07-01 01:43:40 +02:00
|
|
|
.common = {
|
|
|
|
.tag = HARDWARE_MODULE_TAG,
|
|
|
|
.version_major = 1,
|
|
|
|
.version_minor = 0,
|
|
|
|
.id = HWC_HARDWARE_MODULE_ID,
|
|
|
|
.name = "Sample hwcomposer module",
|
|
|
|
.author = "The Android Open Source Project",
|
|
|
|
.methods = &hwc_module_methods,
|
2010-08-06 00:24:35 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2017-11-15 01:05:46 +01:00
|
|
|
#if 0
|
2012-06-06 08:41:37 +02:00
|
|
|
static void dump_layer(hwc_layer_1_t const* l) {
|
2011-12-20 17:25:12 +01:00
|
|
|
ALOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}",
|
2010-08-12 01:15:42 +02:00
|
|
|
l->compositionType, l->flags, l->handle, l->transform, l->blending,
|
|
|
|
l->sourceCrop.left,
|
|
|
|
l->sourceCrop.top,
|
|
|
|
l->sourceCrop.right,
|
|
|
|
l->sourceCrop.bottom,
|
|
|
|
l->displayFrame.left,
|
|
|
|
l->displayFrame.top,
|
|
|
|
l->displayFrame.right,
|
|
|
|
l->displayFrame.bottom);
|
|
|
|
}
|
2017-11-15 01:05:46 +01:00
|
|
|
#endif
|
2010-08-12 01:15:42 +02:00
|
|
|
|
2016-07-01 01:43:40 +02:00
|
|
|
static int hwc_prepare(hwc_composer_device_1_t * /*dev*/,
|
|
|
|
size_t /*numDisplays*/, hwc_display_contents_1_t** displays) {
|
2012-07-31 23:29:00 +02:00
|
|
|
if (displays && (displays[0]->flags & HWC_GEOMETRY_CHANGED)) {
|
|
|
|
for (size_t i=0 ; i<displays[0]->numHwLayers ; i++) {
|
2010-08-12 01:15:42 +02:00
|
|
|
//dump_layer(&list->hwLayers[i]);
|
2012-07-31 23:29:00 +02:00
|
|
|
displays[0]->hwLayers[i].compositionType = HWC_FRAMEBUFFER;
|
2010-08-06 00:24:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-01 01:43:40 +02:00
|
|
|
static int hwc_set(hwc_composer_device_1_t * /*dev*/,
|
|
|
|
size_t /*numDisplays*/, hwc_display_contents_1_t** displays)
|
2010-08-06 00:24:35 +02:00
|
|
|
{
|
2010-08-12 01:15:42 +02:00
|
|
|
//for (size_t i=0 ; i<list->numHwLayers ; i++) {
|
|
|
|
// dump_layer(&list->hwLayers[i]);
|
|
|
|
//}
|
|
|
|
|
2016-07-01 01:43:40 +02:00
|
|
|
EGLBoolean success = eglSwapBuffers((EGLDisplay)displays[0]->dpy,
|
2012-07-31 23:29:00 +02:00
|
|
|
(EGLSurface)displays[0]->sur);
|
2016-07-01 01:43:40 +02:00
|
|
|
if (!success) {
|
2010-08-06 00:24:35 +02:00
|
|
|
return HWC_EGL_ERROR;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hwc_device_close(struct hw_device_t *dev)
|
|
|
|
{
|
|
|
|
struct hwc_context_t* ctx = (struct hwc_context_t*)dev;
|
|
|
|
if (ctx) {
|
|
|
|
free(ctx);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
static int hwc_device_open(const struct hw_module_t* module, const char* name,
|
|
|
|
struct hw_device_t** device)
|
|
|
|
{
|
|
|
|
int status = -EINVAL;
|
|
|
|
if (!strcmp(name, HWC_HARDWARE_COMPOSER)) {
|
|
|
|
struct hwc_context_t *dev;
|
|
|
|
dev = (hwc_context_t*)malloc(sizeof(*dev));
|
|
|
|
|
|
|
|
/* initialize our state here */
|
|
|
|
memset(dev, 0, sizeof(*dev));
|
|
|
|
|
|
|
|
/* initialize the procs */
|
|
|
|
dev->device.common.tag = HARDWARE_DEVICE_TAG;
|
2012-06-06 08:41:37 +02:00
|
|
|
dev->device.common.version = HWC_DEVICE_API_VERSION_1_0;
|
2010-08-06 00:24:35 +02:00
|
|
|
dev->device.common.module = const_cast<hw_module_t*>(module);
|
|
|
|
dev->device.common.close = hwc_device_close;
|
|
|
|
|
|
|
|
dev->device.prepare = hwc_prepare;
|
|
|
|
dev->device.set = hwc_set;
|
|
|
|
|
|
|
|
*device = &dev->device.common;
|
|
|
|
status = 0;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|