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();
310 cb_handle_t *cb = new cb_handle_t(fd, ashmem_size, usage,
319 int err = map_buffer(cb, &vaddr);
322 delete cb;
326 cb->setFd(fd);
338 cb->hostHandle = rcEnc->rcCreateColorBuffer(rcEnc, w, h, glFormat);
339 D("Created host ColorBuffer 0x%x\n", cb->hostHandle);
342 if (!cb->hostHandle) {
345 delete cb;
355 node->handle = cb;
364 *pHandle = cb;
376 const cb_handle_t *cb = (const cb_handle_t *)handle;
377 if (!cb_handle_t::validate((cb_handle_t*)cb)) {
382 if (cb->hostHandle != 0) {
384 D("Closing host ColorBuffer 0x%x\n", cb->hostHandle);
385 rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle);
391 if (cb->fd > 0) {
392 if (cb->ashmemSize > 0 && cb->ashmemBase) {
393 munmap((void *)cb->ashmemBase, cb->ashmemSize);
395 close(cb->fd);
402 while( n && n->handle != cb ) {
421 delete cb;
453 cb_handle_t *cb = (cb_handle_t *)buffer;
455 if (!fbdev || !cb_handle_t::validate(cb) || !cb->canBePosted()) {
463 uint32_t *postCountPtr = (uint32_t *)cb->ashmemBase;
471 rcEnc->rcFBPost(rcEnc, cb->hostHandle);
539 cb_handle_t *cb = (cb_handle_t *)handle;
540 if (!gr || !cb_handle_t::validate(cb)) {
541 ERR("gralloc_register_buffer(%p): invalid buffer", cb);
545 if (cb->hostHandle != 0) {
547 D("Opening host ColorBuffer 0x%x\n", cb->hostHandle);
548 rcEnc->rcOpenColorBuffer(rcEnc, cb->hostHandle);
555 if (cb->ashmemSize > 0 && cb->mappedPid != getpid()) {
557 int err = map_buffer(cb, &vaddr);
559 ERR("gralloc_register_buffer(%p): map failed: %s", cb, strerror(-err));
562 cb->mappedPid = getpid();
576 cb_handle_t *cb = (cb_handle_t *)handle;
577 if (!gr || !cb_handle_t::validate(cb)) {
578 ERR("gralloc_unregister_buffer(%p): invalid buffer", cb);
582 if (cb->hostHandle != 0) {
584 D("Closing host ColorBuffer 0x%x\n", cb->hostHandle);
585 rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle);
592 if (cb->ashmemSize > 0 && cb->mappedPid == getpid()) {
594 int err = munmap((void *)cb->ashmemBase, cb->ashmemSize);
596 ERR("gralloc_unregister_buffer(%p): unmap failed", cb);
599 cb->ashmemBase = 0;
600 cb->mappedPid = 0;
603 D("gralloc_unregister_buffer(%p) done\n", cb);
618 cb_handle_t *cb = (cb_handle_t *)handle;
619 if (!gr || !cb_handle_t::validate(cb)) {
625 if (cb->frameworkFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) {
641 bool sw_read_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_READ_MASK));
642 bool sw_write_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_WRITE_MASK));
650 ALOGE("gralloc_lock usage mismatch usage=0x%x cb->usage=0x%x\n", usage,
651 cb->usage);
661 if (cb->canBePosted() || sw_read || sw_write ||
664 if (cb->ashmemBasePid != getpid() || !cb->ashmemBase) {
668 if (cb->canBePosted()) {
669 postCount = *((int *)cb->ashmemBase);
670 cpu_addr = (void *)(cb->ashmemBase + sizeof(int));
673 cpu_addr = (void *)(cb->ashmemBase);
677 if (cb->hostHandle) {
684 int hostSyncStatus = rcEnc->rcColorBufferCacheFlush(rcEnc, cb->hostHandle,
708 cb->lockedLeft = l;
709 cb->lockedTop = t;
710 cb->lockedWidth = w;
711 cb->lockedHeight = h;
728 cb_handle_t *cb = (cb_handle_t *)handle;
729 if (!gr || !cb_handle_t::validate(cb)) {
737 if (cb->lockedWidth > 0 && cb->lockedHeight > 0 && cb->hostHandle) {
743 if (cb->canBePosted()) {
744 cpu_addr = (void *)(cb->ashmemBase + sizeof(int));
747 cpu_addr = (void *)(cb->ashmemBase);
750 if (cb->lockedWidth < cb->width || cb->lockedHeight < cb->height) {
751 int bpp = glUtilsPixelBitSize(cb->glFormat, cb->glType) >> 3;
752 char *tmpBuf = new char[cb->lockedWidth * cb->lockedHeight * bpp];
754 int dst_line_len = cb->lockedWidth * bpp;
755 int src_line_len = cb->width * bpp;
756 char *src = (char *)cpu_addr + cb->lockedTop*src_line_len + cb->lockedLeft*bpp;
758 for (int y=0; y<cb->lockedHeight; y++) {
764 rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle,
765 cb->lockedLeft, cb->lockedTop,
766 cb->lockedWidth, cb->lockedHeight,
767 cb->glFormat, cb->glType,
773 rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle, 0, 0,
774 cb->width, cb->height,
775 cb->glFormat, cb->glType,
780 cb->lockedWidth = cb->lockedHeight = 0;
800 cb_handle_t *cb = (cb_handle_t *)handle;
801 if (!gr || !cb_handle_t::validate(cb)) {
806 if (cb->frameworkFormat != HAL_PIXEL_FORMAT_YCbCr_420_888) {
809 cb->frameworkFormat);
817 bool sw_read_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_READ_MASK));
821 ALOGE("gralloc_lock_ycbcr usage mismatch usage:0x%x cb->usage:0x%x\n",
822 usage, cb->usage);
827 if (cb->ashmemBasePid != getpid() || !cb->ashmemBase) {
833 if (cb->canBePosted()) {
834 cpu_addr = (uint8_t *)(cb->ashmemBase + sizeof(int));
837 cpu_addr = (uint8_t *)(cb->ashmemBase);
847 switch (cb->format) {
849 yStride = cb->width;
850 cStride = cb->width;
852 vOffset = yStride * cb->height;
858 cb->format);
863 ycbcr->cb = cpu_addr + uOffset;
875 cb->lockedLeft = l;
876 cb->lockedTop = t;
877 cb->lockedWidth = w;
878 cb->lockedHeight = h;
880 DD("gralloc_lock_ycbcr success. usage: %x, ycbcr.y: %p, .cb: %p, .cr: %p, "
882 ycbcr->y, ycbcr->cb, ycbcr->cr, ycbcr->ystride, ycbcr->cstride,