int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd) { DEBUG_ENTER(); /* * If the buffer has been mapped during a lock operation, it's time * to un-map it. It's an error to be here with a locked buffer. */ LOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[terminate] handle %p still locked (state=%08x)", hnd, hnd->lockState); if (hnd->lockState & private_handle_t::LOCK_STATE_MAPPED) { // this buffer was mapped, unmap it now if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_PMEM) { if (hnd->pid != getpid()) { // ... unless it's a "master" pmem buffer, that is a buffer // mapped in the process it's been allocated. // (see gralloc_alloc_buffer()) gralloc_unmap(module, hnd); } } else { gralloc_unmap(module, hnd); } } DEBUG_LEAVE(); return 0; }
static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) { ALOGE("unregistering invalid buffer, returning error"); return -EINVAL; } private_handle_t* hnd = (private_handle_t*)handle; #ifdef USE_PARTIAL_FLUSH if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) if (!release_rect((int)hnd->ump_id)) ALOGE("secureID: 0x%x, release error", (int)hnd->ump_id); #endif ALOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState); /* never unmap buffers that were created in this process */ if (hnd->pid != getpid()) { pthread_mutex_lock(&s_map_lock); if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) { ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); hnd->base = 0; ump_reference_release((ump_handle)hnd->ump_mem_handle); hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE; hnd->lockState = 0; hnd->writeOwner = 0; } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_IOCTL) { if(hnd->base != 0) gralloc_unmap(module, handle); pthread_mutex_unlock(&s_map_lock); if (0 < gMemfd) { close(gMemfd); gMemfd = 0; } return 0; } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) { ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); ump_reference_release((ump_handle)hnd->ump_mem_handle); if (hnd->base) gralloc_unmap(module, handle); hnd->base = 0; hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE; hnd->lockState = 0; hnd->writeOwner = 0; } else { ALOGE("unregistering non-UMP buffer not supported"); } pthread_mutex_unlock(&s_map_lock); } return 0; }
int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle) { DEBUG_ENTER(); if (private_handle_t::validate(handle) < 0) return -EINVAL; /* * If the buffer has been mapped during a lock operation, it's time * to un-map it. It's an error to be here with a locked buffer. * NOTE: the framebuffer is handled differently and is never unmapped. */ private_handle_t* hnd = (private_handle_t*)handle; LOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState); // never unmap buffers that were created in this process if (hnd->pid != getpid()) { if (hnd->lockState & private_handle_t::LOCK_STATE_MAPPED) { gralloc_unmap(module, handle); } hnd->base = 0; hnd->lockState = 0; hnd->writeOwner = 0; } DEBUG_LEAVE(); return 0; }
static int terminateBuffer(gralloc_module_t const* module, struct hwmem_gralloc_buf_handle_t* hnd) { /* * If the buffer has been mapped during a lock operation, it's time * to un-map it. It's an error to be here with a locked buffer. */ ALOGE_IF(hnd->lockState & LOCK_STATE_READ_MASK, "[terminate] handle %p still locked (state=%08x)", hnd, hnd->lockState); if (hnd->lockState & LOCK_STATE_MAPPED) { // this buffer was mapped, unmap it now if ((hnd->flags & PRIV_FLAGS_USES_PMEM) && (hnd->pid == getpid())) { // ... unless it's a "master" pmem buffer, that is a buffer // mapped in the process it's been allocated. // (see gralloc_alloc_buffer()) } else { gralloc_unmap(module, hnd); } } return 0; }
int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd) { if (hnd->base) { // this buffer was mapped, unmap it now gralloc_unmap(module, hnd); } return 0; }
int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; private_handle_t* hnd = (private_handle_t*)handle; if (hnd->base) gralloc_unmap(module, handle); return 0; }
int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd) { if (hnd->base) { // this buffer was mapped, unmap it now if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_PMEM) { if (hnd->pid != getpid()) { // ... unless it's a "master" pmem buffer, that is a buffer // mapped in the process it's been allocated. // (see gralloc_alloc_buffer()) gralloc_unmap(module, hnd); } } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_GPU) { // XXX: for now do nothing here } else { gralloc_unmap(module, hnd); } } return 0; }
int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; // never unmap buffers that were created in this process private_handle_t* hnd = (private_handle_t*)handle; if (hnd->pid != getpid()) { if (hnd->base) { gralloc_unmap(module, handle); } } return 0; }
int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; private_handle_t* hnd = (private_handle_t*)handle; ALOGV("%s: base %p %d %d %d %d\n", __func__, hnd->base, hnd->size, hnd->width, hnd->height, hnd->stride); gralloc_unmap(module, handle); if (hnd->handle) ion_free(getIonFd(module), hnd->handle); if (hnd->handle1) ion_free(getIonFd(module), hnd->handle1); if (hnd->handle2) ion_free(getIonFd(module), hnd->handle2); return 0; }
int gralloc_unregister_buffer_pmem(gralloc_module_t const* module, struct hwmem_gralloc_buf_handle_t* hnd) { /* * If the buffer has been mapped during a lock operation, it's time * to un-map it. It's an error to be here with a locked buffer. * NOTE: the framebuffer is handled differently and is never unmapped. */ ALOGE_IF(hnd->lockState & LOCK_STATE_READ_MASK, "[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState); // never unmap buffers that were created in this process if (hnd->pid != getpid()) { if (hnd->lockState & LOCK_STATE_MAPPED) { gralloc_unmap(module, hnd); } hnd->base_addr = 0; hnd->lockState = 0; hnd->writeOwner = 0; } return 0; }
int grallocUnmap(gralloc_module_t const* module, private_handle_t *hnd) { return gralloc_unmap(module, hnd); }