Lines Matching refs:cb

128         cb_handle_old_t* cb = static_cast<cb_handle_old_t*>(p);  in from()  local
129 return cb->isValid() ? cb : NULL; in from()
144 int32_t* getOpenCountPtr(const cb_handle_old_t* cb) { in getOpenCountPtr() argument
145 return ((int32_t*)cb->getBufferPtr()) + 1; in getOpenCountPtr()
148 uint32_t getAshmemColorOffset(cb_handle_old_t* cb) { in getAshmemColorOffset() argument
150 if (cb->canBePosted()) res = GOLDFISH_OFFSET_UNIT; in getAshmemColorOffset()
393 static void get_ashmem_region(ExtendedRCEncoderContext *rcEnc, cb_handle_old_t *cb) { in get_ashmem_region() argument
398 get_mem_region(cb->getBufferPtr()); in get_ashmem_region()
407 static bool put_ashmem_region(ExtendedRCEncoderContext *rcEnc, cb_handle_old_t *cb) { in put_ashmem_region() argument
412 const bool should_unmap = put_mem_region(rcEnc, cb->getBufferPtr()); in put_ashmem_region()
418 put_gralloc_region(rcEnc, cb->bufferSize); in put_ashmem_region()
423 static int map_buffer(cb_handle_old_t *cb, void **vaddr) in map_buffer() argument
425 if (cb->bufferFd < 0) { in map_buffer()
429 void *addr = mmap(0, cb->bufferSize, PROT_READ | PROT_WRITE, in map_buffer()
430 MAP_SHARED, cb->bufferFd, 0); in map_buffer()
436 cb->setBufferPtr(addr); in map_buffer()
437 cb->ashmemBasePid = getpid(); in map_buffer()
439 cb, addr, cb->bufferSize); in map_buffer()
477 static void updateHostColorBuffer(cb_handle_old_t* cb, in updateHostColorBuffer() argument
485 int bpp = glUtilsPixelBitSize(cb->glFormat, cb->glType) >> 3; in updateHostColorBuffer()
486 int left = doLocked ? cb->lockedLeft : 0; in updateHostColorBuffer()
487 int top = doLocked ? cb->lockedTop : 0; in updateHostColorBuffer()
488 int width = doLocked ? cb->lockedWidth : cb->width; in updateHostColorBuffer()
489 int height = doLocked ? cb->lockedHeight : cb->height; in updateHostColorBuffer()
495 cb->format != HAL_PIXEL_FORMAT_YV12 && in updateHostColorBuffer()
496 cb->format != HAL_PIXEL_FORMAT_YCbCr_420_888; in updateHostColorBuffer()
505 cb->width, in updateHostColorBuffer()
516 switch (cb->format) { in updateHostColorBuffer()
537 rcEnc->rcUpdateColorBufferDMA(rcEnc, cb->hostHandle, in updateHostColorBuffer()
539 cb->glFormat, cb->glType, in updateHostColorBuffer()
543 switch (cb->format) { in updateHostColorBuffer()
562 rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle, in updateHostColorBuffer()
564 cb->glFormat, cb->glType, to_send); in updateHostColorBuffer()
842 cb_handle_old_t *cb = new cb_handle_old_t(fd, ashmem_size, usage, in gralloc_alloc() local
851 int err = map_buffer(cb, &vaddr); in gralloc_alloc()
854 delete cb; in gralloc_alloc()
875cb->hostHandle = rcEnc->rcCreateColorBufferDMA(rcEnc, w, h, allocFormat, selectedEmuFrameworkForma… in gralloc_alloc()
877 cb->hostHandle = rcEnc->rcCreateColorBuffer(rcEnc, w, h, allocFormat); in gralloc_alloc()
882 if (!cb->hostHandle) { in gralloc_alloc()
885 delete cb; in gralloc_alloc()
891 cb->setRefcountPipeFd(refcountPipeFd); in gralloc_alloc()
892 qemu_pipe_write(refcountPipeFd, &cb->hostHandle, 4); in gralloc_alloc()
894 D("Created host ColorBuffer 0x%x\n", cb->hostHandle); in gralloc_alloc()
897 if (isHidlGralloc) { *getOpenCountPtr(cb) = 0; } in gralloc_alloc()
904 grdev->allocated.insert(cb); in gralloc_alloc()
907 *pHandle = cb; in gralloc_alloc()
909 __FUNCTION__, cb->ashmemBase, cb->ashmemSize, cb); in gralloc_alloc()
933 const cb_handle_old_t *cb = cb_handle_old_t::from(handle); in gralloc_free() local
934 if (!cb) { in gralloc_free()
940 __FUNCTION__, handle, cb->getBufferPtr(), cb->bufferSize); in gralloc_free()
942 if (cb->hostHandle && !cb->hasRefcountPipe()) { in gralloc_free()
946 if (isHidlGralloc && cb->getBufferPtr()) { in gralloc_free()
947 openCountPtr = getOpenCountPtr(cb); in gralloc_free()
951 D("Closing host ColorBuffer 0x%x\n", cb->hostHandle); in gralloc_free()
953 rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle); in gralloc_free()
964 if (cb->bufferFd > 0) { in gralloc_free()
965 if (cb->bufferSize > 0 && cb->getBufferPtr()) { in gralloc_free()
966 D("%s: unmapped %p", __FUNCTION__, cb->getBufferPtr()); in gralloc_free()
967 munmap(cb->getBufferPtr(), cb->bufferSize); in gralloc_free()
968 put_gralloc_region(rcEnc, cb->bufferSize); in gralloc_free()
970 close(cb->bufferFd); in gralloc_free()
973 if(qemu_pipe_valid(cb->hostHandleRefCountFd)) { in gralloc_free()
974 qemu_pipe_close(cb->hostHandleRefCountFd); in gralloc_free()
981 grdev->allocated.erase(cb); in gralloc_free()
984 delete cb; in gralloc_free()
1023 cb_handle_old_t *cb = cb_handle_old_t::from_unconst(handle); in gralloc_register_buffer() local
1024 if (!cb) { in gralloc_register_buffer()
1025 ERR("gralloc_register_buffer(%p): invalid buffer", cb); in gralloc_register_buffer()
1030 handle, cb->width, cb->height, cb->format); in gralloc_register_buffer()
1032 if (cb->hostHandle != 0 && !cb->hasRefcountPipe()) { in gralloc_register_buffer()
1033 D("Opening host ColorBuffer 0x%x\n", cb->hostHandle); in gralloc_register_buffer()
1035 rcEnc->rcOpenColorBuffer2(rcEnc, cb->hostHandle); in gralloc_register_buffer()
1043 if (cb->bufferSize > 0 && cb->mappedPid != getpid()) { in gralloc_register_buffer()
1045 int err = map_buffer(cb, &vaddr); in gralloc_register_buffer()
1047 ERR("gralloc_register_buffer(%p): map failed: %s", cb, strerror(-err)); in gralloc_register_buffer()
1050 cb->mappedPid = getpid(); in gralloc_register_buffer()
1053 int32_t* openCountPtr = getOpenCountPtr(cb); in gralloc_register_buffer()
1058 if (cb->bufferSize > 0) { in gralloc_register_buffer()
1059 get_ashmem_region(rcEnc, cb); in gralloc_register_buffer()
1079 cb_handle_old_t *cb = cb_handle_old_t::from_unconst(handle); in gralloc_unregister_buffer() local
1080 if (!cb) { in gralloc_unregister_buffer()
1081 ERR("gralloc_unregister_buffer(%p): invalid buffer", cb); in gralloc_unregister_buffer()
1086 if (cb->hostHandle && !cb->hasRefcountPipe()) { in gralloc_unregister_buffer()
1087 D("Closing host ColorBuffer 0x%x\n", cb->hostHandle); in gralloc_unregister_buffer()
1089 rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle); in gralloc_unregister_buffer()
1094 if (cb->bufferSize > 0 && cb->mappedPid == getpid()) { in gralloc_unregister_buffer()
1095 int32_t* openCountPtr = getOpenCountPtr(cb); in gralloc_unregister_buffer()
1098 rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle); in gralloc_unregister_buffer()
1110 if (cb->bufferSize > 0 && cb->mappedPid == getpid()) { in gralloc_unregister_buffer()
1111 const bool should_unmap = put_ashmem_region(rcEnc, cb); in gralloc_unregister_buffer()
1114 int err = munmap(cb->getBufferPtr(), cb->bufferSize); in gralloc_unregister_buffer()
1116 ERR("gralloc_unregister_buffer(%p): unmap failed", cb); in gralloc_unregister_buffer()
1119 cb->bufferSize = 0; in gralloc_unregister_buffer()
1120 cb->mappedPid = 0; in gralloc_unregister_buffer()
1125 D("gralloc_unregister_buffer(%p) done\n", cb); in gralloc_unregister_buffer()
1143 cb_handle_old_t *cb = cb_handle_old_t::from_unconst(handle); in gralloc_lock() local
1144 if (!cb) { in gralloc_lock()
1171 bool sw_read_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_READ_MASK)); in gralloc_lock()
1178 sw_read_allowed = sw_read_allowed || (cb->usage & GRALLOC_USAGE_HW_VIDEO_ENCODER); in gralloc_lock()
1181 bool sw_write_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_WRITE_MASK)); in gralloc_lock()
1190 cb->usage); in gralloc_lock()
1201 if (cb->canBePosted() || sw_read || sw_write || in gralloc_lock()
1204 if (cb->ashmemBasePid != getpid() || !cb->getBufferPtr()) { in gralloc_lock()
1208 cpu_addr = (void *)((char*)cb->getBufferPtr() + getAshmemColorOffset(cb)); in gralloc_lock()
1211 if (cb->hostHandle) { in gralloc_lock()
1219 int hostSyncStatus = rcEnc->rcColorBufferCacheFlush(rcEnc, cb->hostHandle, in gralloc_lock()
1233 cb->width, cb->height, cb->ashmemBase, cb->ashmemSize); in gralloc_lock()
1236 if (cb->format == HAL_PIXEL_FORMAT_YV12 || in gralloc_lock()
1237 cb->format == HAL_PIXEL_FORMAT_YCbCr_420_888) { in gralloc_lock()
1240 if (cb->format == HAL_PIXEL_FORMAT_YV12) { in gralloc_lock()
1241 get_yv12_offsets(cb->width, cb->height, NULL, NULL, in gralloc_lock()
1244 get_yuv420p_offsets(cb->width, cb->height, NULL, NULL, in gralloc_lock()
1248 rcEnc->rcReadColorBufferYUV(rcEnc, cb->hostHandle, in gralloc_lock()
1249 0, 0, cb->width, cb->height, in gralloc_lock()
1253 tmpBuf = new char[cb->width * cb->height * 3]; in gralloc_lock()
1254 rcEnc->rcReadColorBuffer(rcEnc, cb->hostHandle, in gralloc_lock()
1255 … 0, 0, cb->width, cb->height, cb->glFormat, cb->glType, tmpBuf); in gralloc_lock()
1256 if (cb->format == HAL_PIXEL_FORMAT_YV12) { in gralloc_lock()
1258 … rgb888_to_yv12((char*)cpu_addr, tmpBuf, cb->width, cb->height, l, t, l+w-1, t+h-1); in gralloc_lock()
1259 } else if (cb->format == HAL_PIXEL_FORMAT_YCbCr_420_888) { in gralloc_lock()
1261 … rgb888_to_yuv420p((char*)cpu_addr, tmpBuf, cb->width, cb->height, l, t, l+w-1, t+h-1); in gralloc_lock()
1266 rcEnc->rcReadColorBuffer(rcEnc, cb->hostHandle, in gralloc_lock()
1267 0, 0, cb->width, cb->height, cb->glFormat, cb->glType, rgb_addr); in gralloc_lock()
1272 gralloc_dmaregion_register_ashmem(rcEnc, cb->bufferSize); in gralloc_lock()
1288 cb->lockedLeft = l; in gralloc_lock()
1289 cb->lockedTop = t; in gralloc_lock()
1290 cb->lockedWidth = w; in gralloc_lock()
1291 cb->lockedHeight = h; in gralloc_lock()
1295 vaddr, vaddr ? *vaddr : 0, usage, cpu_addr, cb->ashmemBase); in gralloc_lock()
1312 cb_handle_old_t *cb = cb_handle_old_t::from_unconst(handle); in gralloc_unlock() local
1313 if (!cb) { in gralloc_unlock()
1322 if (cb->hostHandle) { in gralloc_unlock()
1328 char *cpu_addr = (char*)cb->getBufferPtr() + getAshmemColorOffset(cb); in gralloc_unlock()
1330 if (cb->lockedWidth < cb->width || cb->lockedHeight < cb->height) { in gralloc_unlock()
1331 updateHostColorBuffer(cb, true, cpu_addr); in gralloc_unlock()
1334 updateHostColorBuffer(cb, false, cpu_addr); in gralloc_unlock()
1341 cb->lockedWidth = cb->lockedHeight = 0; in gralloc_unlock()
1367 cb_handle_old_t *cb = cb_handle_old_t::from_unconst(handle); in gralloc_lock_ycbcr() local
1368 if (!cb) { in gralloc_lock_ycbcr()
1373 if (cb->format != HAL_PIXEL_FORMAT_YV12 && in gralloc_lock_ycbcr()
1374 cb->format != HAL_PIXEL_FORMAT_YCbCr_420_888) { in gralloc_lock_ycbcr()
1378 cb->format); in gralloc_lock_ycbcr()
1382 usage |= (cb->usage & GRALLOC_USAGE_HW_CAMERA_MASK); in gralloc_lock_ycbcr()
1401 switch (cb->format) { in gralloc_lock_ycbcr()
1403 yStride = cb->width; in gralloc_lock_ycbcr()
1404 cStride = cb->width; in gralloc_lock_ycbcr()
1406 vOffset = yStride * cb->height; in gralloc_lock_ycbcr()
1413 yStride = (cb->width + (align -1)) & ~(align-1); in gralloc_lock_ycbcr()
1416 cSize = cStride * cb->height/2; in gralloc_lock_ycbcr()
1417 vOffset = yStride * cb->height; in gralloc_lock_ycbcr()
1422 yStride = cb->width; in gralloc_lock_ycbcr()
1425 uOffset = cb->height * yStride; in gralloc_lock_ycbcr()
1426 vOffset = uOffset + cStride * cb->height / 2; in gralloc_lock_ycbcr()
1431 cb->format); in gralloc_lock_ycbcr()
1436 ycbcr->cb = cpu_addr + uOffset; in gralloc_lock_ycbcr()
1447 ycbcr->y, ycbcr->cb, ycbcr->cr, ycbcr->ystride, ycbcr->cstride, in gralloc_lock_ycbcr()
1448 ycbcr->chroma_step, cb->ashmemBase); in gralloc_lock_ycbcr()