Home | History | Annotate | Download | only in gralloc

Lines Matching refs:cb

90 static int map_buffer(cb_handle_t *cb, void **vaddr)
92 if (cb->fd < 0 || cb->ashmemSize <= 0) {
96 void *addr = mmap(0, cb->ashmemSize, PROT_READ | PROT_WRITE,
97 MAP_SHARED, cb->fd, 0);
102 cb->ashmemBase = intptr_t(addr);
103 cb->ashmemBasePid = getpid();
300 cb_handle_t *cb = new cb_handle_t(fd, ashmem_size, usage,
309 int err = map_buffer(cb, &vaddr);
312 delete cb;
316 cb->setFd(fd);
328 cb->hostHandle = rcEnc->rcCreateColorBuffer(rcEnc, w, h, glFormat);
329 D("Created host ColorBuffer 0x%x\n", cb->hostHandle);
332 if (!cb->hostHandle) {
335 delete cb;
345 node->handle = cb;
354 *pHandle = cb;
366 const cb_handle_t *cb = (const cb_handle_t *)handle;
367 if (!cb_handle_t::validate((cb_handle_t*)cb)) {
372 if (cb->hostHandle != 0) {
374 D("Closing host ColorBuffer 0x%x\n", cb->hostHandle);
375 rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle);
381 if (cb->fd > 0) {
382 if (cb->ashmemSize > 0 && cb->ashmemBase) {
383 munmap((void *)cb->ashmemBase, cb->ashmemSize);
385 close(cb->fd);
392 while( n && n->handle != cb ) {
411 delete cb;
443 cb_handle_t *cb = (cb_handle_t *)buffer;
445 if (!fbdev || !cb_handle_t::validate(cb) || !cb->canBePosted()) {
453 uint32_t *postCountPtr = (uint32_t *)cb->ashmemBase;
461 rcEnc->rcFBPost(rcEnc, cb->hostHandle);
529 cb_handle_t *cb = (cb_handle_t *)handle;
530 if (!gr || !cb_handle_t::validate(cb)) {
531 ERR("gralloc_register_buffer(%p): invalid buffer", cb);
535 if (cb->hostHandle != 0) {
537 D("Opening host ColorBuffer 0x%x\n", cb->hostHandle);
538 rcEnc->rcOpenColorBuffer(rcEnc, cb->hostHandle);
545 if (cb->ashmemSize > 0 && cb->mappedPid != getpid()) {
547 int err = map_buffer(cb, &vaddr);
549 ERR("gralloc_register_buffer(%p): map failed: %s", cb, strerror(-err));
552 cb->mappedPid = getpid();
566 cb_handle_t *cb = (cb_handle_t *)handle;
567 cb)) {
568 ERR("gralloc_unregister_buffer(%p): invalid buffer", cb);
572 if (cb->hostHandle != 0) {
574 D("Closing host ColorBuffer 0x%x\n", cb->hostHandle);
575 rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle);
582 if (cb->ashmemSize > 0 && cb->mappedPid == getpid()) {
584 int err = munmap((void *)cb->ashmemBase, cb->ashmemSize);
586 ERR("gralloc_unregister_buffer(%p): unmap failed", cb);
589 cb->ashmemBase = 0;
590 cb->mappedPid = 0;
593 D("gralloc_unregister_buffer(%p) done\n", cb);
608 cb_handle_t *cb = (cb_handle_t *)handle;
609 if (!gr || !cb_handle_t::validate(cb)) {
615 if (cb->frameworkFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) {
631 bool sw_read_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_READ_MASK));
632 bool sw_write_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_WRITE_MASK));
640 ALOGE("gralloc_lock usage mismatch usage=0x%x cb->usage=0x%x\n", usage,
641 cb->usage);
651 if (cb->canBePosted() || sw_read || sw_write ||
654 if (cb->ashmemBasePid != getpid() || !cb->ashmemBase) {
658 if (cb->canBePosted()) {
659 postCount = *((int *)cb->ashmemBase);
660 cpu_addr = (void *)(cb->ashmemBase + sizeof(int));
663 cpu_addr = (void *)(cb->ashmemBase);
667 if (cb->hostHandle) {
674 int hostSyncStatus = rcEnc->rcColorBufferCacheFlush(rcEnc, cb->hostHandle,
698 cb->lockedLeft = l;
699 cb->lockedTop = t;
700 cb->lockedWidth = w;
701 cb->lockedHeight = h;
718 cb_handle_t *cb = (cb_handle_t *)handle;
719 if (!gr || !cb_handle_t::validate(cb)) {
727 if (cb->lockedWidth > 0 && cb->lockedHeight > 0 && cb->hostHandle) {
733 if (cb->canBePosted()) {
734 cpu_addr = (void *)(cb->ashmemBase + sizeof(int));
737 cpu_addr = (void *)(cb->ashmemBase);
740 if (cb->lockedWidth < cb->width || cb->lockedHeight < cb->height) {
741 int bpp = glUtilsPixelBitSize(cb->glFormat, cb->glType) >> 3;
742 char *tmpBuf = new char[cb->lockedWidth * cb->lockedHeight * bpp];
744 int dst_line_len = cb->lockedWidth * bpp;
745 int src_line_len = cb->width * bpp;
746 char *src = (char *)cpu_addr + cb->lockedTop*src_line_len + cb->lockedLeft*bpp;
748 for (int y=0; y<cb->lockedHeight; y++) {
754 rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle,
755 cb->lockedLeft, cb->lockedTop,
756 cb->lockedWidth, cb->lockedHeight,
757 cb->glFormat, cb->glType,
763 rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle, 0, 0,
764 cb->width, cb->height,
765 cb->glFormat, cb->glType,
770 cb->lockedWidth = cb->lockedHeight = 0;
790 cb_handle_t *cb = (cb_handle_t *)handle;
791 if (!gr || !cb_handle_t::validate(cb)) {
796 if (cb->frameworkFormat != HAL_PIXEL_FORMAT_YCbCr_420_888) {
799 cb->frameworkFormat);
807 bool sw_read_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_READ_MASK));
811 ALOGE("gralloc_lock_ycbcr usage mismatch usage:0x%x cb->usage:0x%x\n",
812 usage, cb->usage);
817 if (cb->ashmemBasePid != getpid() || !cb->ashmemBase) {
823 if (cb->canBePosted()) {
824 cpu_addr = (uint8_t *)(cb->ashmemBase + sizeof(int));
827 cpu_addr = (uint8_t *)(cb->ashmemBase);
837 switch (cb->format) {
839 yStride = cb->width;
840 cStride = cb->width;
842 vOffset = yStride * cb->height;
848 cb->format);
853 ycbcr->cb = cpu_addr + uOffset;
865 cb->lockedLeft = l;
866 cb->lockedTop = t;
867 cb->lockedWidth = w;
868 cb->lockedHeight = h;
870 DD("gralloc_lock_ycbcr success. usage: %x, ycbcr.y: %p, .cb: %p, .cr: %p, "
872 ycbcr->y, ycbcr->cb, ycbcr->cr, ycbcr->ystride, ycbcr->cstride,