FramebufferNativeWindow::FramebufferNativeWindow()
: BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false)
{
hw_module_t const* module;
if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
int stride;
int err;
int i;
err = framebuffer_open(module, &fbDev);
LOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
err = gralloc_open(module, &grDev);
LOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err));
// bail out if we can't initialize the modules
if (!fbDev || !grDev)
hw_get_module 是所有 hareware module 的 loading interface
hardware/libhardware/hardware.c
hw_get_module 其實就是依照 property set 的 module path, name ,要 dlopen 去 load 這個 so 近來。
在用 dlsym 取出 so 的 HAL_MODULE_INFO_SYM_AS_STR 這個 function 的 位址.
在這裡就是 .. GRALLOC_HARDWAE_MODULE_ID.
./hardware/libhardware/include/hardware/gralloc.h:36:#define GRALLOC_HARDWARE_MODULE_ID "gralloc"
hw_get_module 會到3 個位置去找:
/* Loop through the configuration variants looking for a module */
for (i=0 ; i< HAL_VARIANT_KEYS_COUNT+1 ; i++) {
if (i < HAL_VARIANT_KEYS_COUNT) {
if (property_get(variant_keys[i], prop, NULL) == 0) {
continue;
}
snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH1, id, prop);
if (access(path, R_OK) == 0) break;
snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH2, id, prop);
if (access(path, R_OK) == 0) break;
} else {
snprintf(path, sizeof(path), "%s/%s.default.so",
HAL_LIBRARY_PATH1, id);
if (access(path, R_OK) == 0) break;
}
}
其中 .../hardware/libhardware/hardware.c:31:#define HAL_LIBRARY_PATH1 "/system/lib/hw"
./hardware/libhardware/hardware.c:32:#define HAL_LIBRARY_PATH2 "/vendor/lib/hw"
的確在 ..
/system/lib/hw/有
gralloc.imx5x.so
取出的 function 叫 HMI..
gralloc 的 hmi interface 定義是:
static struct hw_module_methods_t gralloc_module_methods = {
open: gralloc_device_open
};
struct private_module_t HAL_MODULE_INFO_SYM = {
base: {
common: {
tag: HARDWARE_MODULE_TAG,
version_major: 1,
version_minor: 0,
id: GRALLOC_HARDWARE_MODULE_ID,
name: "Graphics Memory Allocator Module",
author: "The Android Open Source Project",
methods: &gralloc_module_methods
},
registerBuffer: gralloc_register_buffer,
unregisterBuffer: gralloc_unregister_buffer,
lock: gralloc_lock,
unlock: gralloc_unlock,
},
framebuffer: 0,
flags: 0,
numBuffers: 0,
bufferMask: 0,
lock: PTHREAD_MUTEX_INITIALIZER,
currentBuffer: 0,
pmem_master: -1,
pmem_master_base: 0,
master_phys: 0
};
沒有留言:
張貼留言