From 70139de6a2b6f02ad3e5d5bca4917ad35276b8b9 Mon Sep 17 00:00:00 2001 From: Prabhanjan Kandula Date: Sat, 17 Mar 2012 00:57:49 +0530 Subject: [PATCH] libgralloc: fix the calculation of fb virtual y resolution calculate the yresolution virtual according to the hole introduced by 4k alignment of frame buffer. CRs-fixed: 325134 (cherry picked from commit 464443a5d3b216e06e644d0e41c234490c3c46c2) Change-Id: Id7a93e11e2f3c1d52a26ec3669a9d710c369bf41 --- libgralloc/framebuffer.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp index 283a8ac..64e3c23 100644 --- a/libgralloc/framebuffer.cpp +++ b/libgralloc/framebuffer.cpp @@ -655,20 +655,22 @@ int mapFrameBufferLocked(struct private_module_t* module) if (numberOfBuffers > NUM_FRAMEBUFFERS_MAX) numberOfBuffers = NUM_FRAMEBUFFERS_MAX; - LOGE("We support %d buffers", numberOfBuffers); + LOGV("We support %d buffers", numberOfBuffers); - info.yres_virtual = info.yres * numberOfBuffers; + //consider the included hole by 4k alignment + uint32_t line_length = (info.xres * info.bits_per_pixel / 8); + info.yres_virtual = (size * numberOfBuffers) / line_length; uint32_t flags = PAGE_FLIP; if (ioctl(fd, FBIOPUT_VSCREENINFO, &info) == -1) { - info.yres_virtual = info.yres; + info.yres_virtual = size / line_length; flags &= ~PAGE_FLIP; LOGW("FBIOPUT_VSCREENINFO failed, page flipping not supported"); } - if (info.yres_virtual < info.yres * 2) { + if (info.yres_virtual < ((size * 2) / line_length) ) { // we need at least 2 for page-flipping - info.yres_virtual = info.yres; + info.yres_virtual = size / line_length; flags &= ~PAGE_FLIP; LOGW("page flipping not supported (yres_virtual=%d, requested=%d)", info.yres_virtual, info.yres*2);