该文件中的几个主要函数是gralloc_module_t结构函数指针的具体实现。
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
};
1、int gralloc_register_buffer(gralloc_module_t const* module,
buffer_handle_t handle)
1)建立一个新的private_handle_t对象
2)如果不是本进程对象,赋初值
2、int gralloc_unregister_buffer(gralloc_module_t const* module,
buffer_handle_t handle)
1)validate判断handle是否合法
2)call gralloc_unmap(module, handle)
3、static int gralloc_unmap(gralloc_module_t const* module,
buffer_handle_t handle)
1)获取base和size
2)PMEM_HACK because pmem cannot mmap at an offset
3)munmap(base, size)
4、int gralloc_lock(gralloc_module_t const* module,
buffer_handle_t handle, int usage,
int l, int t, int w, int h,
void** vaddr)
1)validate检查
2)如果已经被lock-->error
3)用android_atomic_cmpxchg将new_value写入lockState
4)如果需要map-->gralloc_map(module, handle, vaddr)
5)*vaddr = (void*)hnd->base
5、static int gralloc_map(gralloc_module_t const* module,
buffer_handle_t handle,
void** vaddr)
1)PMEM_HACK
2)void* mappedAddress = mmap(0, size,
PROT_READ|PROT_WRITE, MAP_SHARED, hnd->fd, 0);
3)hnd->base = intptr_t(mappedAddress) + hnd->offset
4)*vaddr = (void*)hnd->base
6、int gralloc_unlock(gralloc_module_t const* module,
buffer_handle_t handle)
1)将lockState跟新至unlock态
7、int terminateBuffer(gralloc_module_t const* module,
private_handle_t* hnd)
1)if locked -->error
2)if mapped -->unmap
3)本文件没有调用
8、MSM7K添加的一个函数
int gralloc_perform(struct gralloc_module_t const* module,
int operation, ... )
1)参数不定,通过va宏获取,估计为operation,fd,size,offset,base,handle
2)根据参数配置private_handle_t* hnd
3)Only for Video and Camera
阅读(898) | 评论(0) | 转发(0) |