Home | History | Annotate | Download | only in gralloc

Lines Matching defs:hnd

72 	private_handle_t *hnd = (private_handle_t *)handle;
96 hnd->pid = getpid();
98 if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
104 else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP)
107 hnd->ump_mem_handle = (int)ump_handle_create_from_secure_id(hnd->ump_id);
109 if (UMP_INVALID_MEMORY_HANDLE != (ump_handle)hnd->ump_mem_handle)
111 hnd->base = ump_mapped_pointer_get((ump_handle)hnd->ump_mem_handle);
113 if (0 != hnd->base)
115 hnd->writeOwner = 0;
116 hnd->lockState &= ~(private_handle_t::LOCK_STATE_UNREGISTERED);
122 AERR("Failed to map UMP handle 0x%x", hnd->ump_mem_handle);
125 ump_reference_release((ump_handle)hnd->ump_mem_handle);
129 AERR("Failed to create UMP handle 0x%x", hnd->ump_mem_handle);
133 AERR("Gralloc does not support UMP. Unable to register UMP memory for handle 0x%p", hnd);
136 else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
140 size_t size = hnd->size;
150 AERR("Could not get gralloc module for handle: 0x%p", hnd);
166 AERR("Could not open ion device for handle: 0x%p", hnd);
172 mappedAddress = (unsigned char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_fd, 0);
176 AERR("mmap( share_fd:%d ) failed with %s", hnd->share_fd, strerror(errno));
181 hnd->base = mappedAddress + hnd->offset;
182 hnd->lockState &= ~(private_handle_t::LOCK_STATE_UNREGISTERED);
189 AERR("registering non-UMP buffer not supported. flags = %d", hnd->flags);
197 static void unmap_buffer(private_handle_t *hnd)
199 if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP)
202 ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle);
203 ump_reference_release((ump_handle)hnd->ump_mem_handle);
204 hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE;
206 AERR("Can't unregister UMP buffer for handle 0x%p. Not supported", hnd);
209 else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
212 void *base = (void *)hnd->base;
213 size_t size = hnd->size;
221 AERR("Can't unregister DMA_BUF buffer for hnd %p. Not supported", hnd);
227 AERR("Unregistering unknown buffer is not supported. Flags = %d", hnd->flags);
230 hnd->base = 0;
231 hnd->lockState = 0;
232 hnd->writeOwner = 0;
245 private_handle_t *hnd = (private_handle_t *)handle;
247 AERR_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState);
249 if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
253 else if (hnd->pid == getpid()) // never unmap buffers that were not registered in this process
257 hnd->lockState &= ~(private_handle_t::LOCK_STATE_MAPPED);
260 if (!(hnd->lockState & private_handle_t::LOCK_STATE_WRITE))
262 unmap_buffer(hnd);
265 hnd->lockState |= private_handle_t::LOCK_STATE_UNREGISTERED;
271 AERR("Trying to unregister buffer 0x%p from process %d that was not created in current process: %d", hnd, hnd->pid, getpid());
285 private_handle_t *hnd = (private_handle_t *)handle;
289 if (hnd->lockState & private_handle_t::LOCK_STATE_UNREGISTERED)
291 AERR("Locking on an unregistered buffer 0x%p, returning error", hnd);
296 if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP || hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
298 hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
301 hnd->lockState |= private_handle_t::LOCK_STATE_WRITE;
307 *vaddr = (void *)hnd->base;
328 private_handle_t *hnd = (private_handle_t *)handle;
330 if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP && hnd->writeOwner)
333 ump_cpu_msync_now((ump_handle)hnd->ump_mem_handle, UMP_MSYNC_CLEAN_AND_INVALIDATE, (void *)hnd->base, hnd->size);
335 AERR("Buffer 0x%p is UMP type but it is not supported", hnd);
338 else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION && hnd->writeOwner)
352 hnd->lockState &= ~(private_handle_t::LOCK_STATE_WRITE);
355 if (hnd->lockState & private_handle_t::LOCK_STATE_UNREGISTERED)
357 unmap_buffer(hnd);