/* * Copyright (c) Hisilicon Technologies Co., Ltd.. 2018-2019. All rights reserved. * Description: Gralloc * Author: Hisilicon * Created: 2019.11.07 */ #include #include #include #include "gralloc_internal_priv.h" #include "gralloc1_public_interface.h" #include "gralloc_framebuffer.h" #include "gralloc_debug.h" #define MAX_STR_LEN 8 static int gralloc_module_device_open(const hw_module_t *module, const char *name, hw_device_t **device) { int ret = 0; gralloc_debug_update_config(); if (!strncmp(name, GRALLOC_HARDWARE_MODULE_ID, MAX_STR_LEN)) { ret = gralloc_device_open(module, device); } else if (!strncmp(name, GRALLOC_HARDWARE_FB0, MAX_STR_LEN)) { ret = framebuffer_device_open(module, device); } return ret; } static struct hw_module_methods_t g_gralloc_module_methods = { gralloc_module_device_open }; private_module_t::private_module_t() { base.common.tag = HARDWARE_MODULE_TAG; base.common.version_major = GRALLOC_MODULE_API_VERSION_1_0; base.common.version_minor = 0; base.common.id = GRALLOC_HARDWARE_MODULE_ID; base.common.name = "Graphics Memory Allocator Module"; base.common.author = "KTP_GPU"; base.common.methods = &g_gralloc_module_methods; base.common.dso = nullptr; base.registerBuffer = nullptr; base.unregisterBuffer = nullptr; base.lock = nullptr; base.unlock = nullptr; base.perform = nullptr; base.lock_ycbcr = nullptr; base.lockAsync = nullptr; base.unlockAsync = nullptr; base.lockAsync_ycbcr = nullptr; base.getTransportSize = nullptr; base.validateBufferSize = nullptr; base.reserved_proc[0] = nullptr; if (memset_s(&base.common.reserved, sizeof(base.common.reserved), 0, sizeof(base.common.reserved)) != EOK) { GRALLOC_ERROR_INFO(); } for (int i = 0; i < NUM_FB_DEVICES; i++) { framebuffer[i] = nullptr; numBuffers[i] = 0; bufferMask[i] = 0; xdpi[i] = 0.0f; ydpi[i] = 0.0f; fps[i] = 0.0f; swapInterval[i] = 1; if (memset_s(&vinfo, sizeof(vinfo), 0, sizeof(vinfo)) != EOK) { GRALLOC_ERROR_INFO(); } if (memset_s(&finfo, sizeof(finfo), 0, sizeof(finfo)) != EOK) { GRALLOC_ERROR_INFO(); } } client = -1; pthread_mutex_init(&(lock), nullptr); }; struct private_module_t HAL_MODULE_INFO_SYM;