display: Remove framebuffer HAL usage

This patch removes the usage of the framebuffer HAL which is
deprecated in JB MR1 onwards. The code is left for compatibility
such as conformance tests but it is unused for normal display
usage.

Change-Id: If98133bdaa759cdc41d4503ff695b225ee43cb6f

Conflicts:

	libhwcomposer/hwc_utils.cpp
diff --git a/libgralloc/fb_priv.h b/libgralloc/fb_priv.h
index b096304..01af2e1 100644
--- a/libgralloc/fb_priv.h
+++ b/libgralloc/fb_priv.h
@@ -52,13 +52,6 @@
     float fps;
     uint32_t swapInterval;
     uint32_t currentOffset;
-    bool fbPostDone;
-    pthread_mutex_t fbPostLock;
-    //Condition to inform HWC that fb_post called
-    pthread_cond_t fbPostCond;
-    bool fbPanDone;
-    pthread_mutex_t fbPanLock;
-    pthread_cond_t fbPanCond;
 };
 
 
diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp
index cc16a5f..0335f5e 100644
--- a/libgralloc/framebuffer.cpp
+++ b/libgralloc/framebuffer.cpp
@@ -54,7 +54,6 @@
 
 enum {
     PAGE_FLIP = 0x00000001,
-    LOCKED    = 0x00000002
 };
 
 struct fb_context_t {
@@ -88,8 +87,8 @@
     private_module_t* m =
         reinterpret_cast<private_module_t*>(dev->common.module);
     struct mdp_display_commit prim_commit;
+    prim_commit.wait_for_finish = 1;
     memset(&prim_commit, 0, sizeof(struct mdp_display_commit));
-    prim_commit.flags = MDP_DISPLAY_COMMIT_OVERLAY;
     if (ioctl(m->framebuffer->fd, MSMFB_DISPLAY_COMMIT, &prim_commit) == -1) {
         ALOGE("%s: MSMFB_DISPLAY_COMMIT for primary failed, str: %s",
                 __FUNCTION__, strerror(errno));
@@ -326,12 +325,6 @@
     module->framebuffer->base = intptr_t(vaddr);
     memset(vaddr, 0, fbSize);
     module->currentOffset = 0;
-    module->fbPostDone = false;
-    pthread_mutex_init(&(module->fbPostLock), NULL);
-    pthread_cond_init(&(module->fbPostCond), NULL);
-    module->fbPanDone = false;
-    pthread_mutex_init(&(module->fbPanLock), NULL);
-    pthread_cond_init(&(module->fbPanCond), NULL);
     return 0;
 }
 
diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp
index 292012b..8b9a6c5 100644
--- a/libgralloc/gpu.cpp
+++ b/libgralloc/gpu.cpp
@@ -52,77 +52,6 @@
 
 }
 
-int gpu_context_t::gralloc_alloc_framebuffer_locked(size_t size, int usage,
-                                                    buffer_handle_t* pHandle)
-{
-    private_module_t* m = reinterpret_cast<private_module_t*>(common.module);
-
-    // we don't support framebuffer allocations with graphics heap flags
-    if (usage & GRALLOC_HEAP_MASK) {
-        return -EINVAL;
-    }
-
-    if (m->framebuffer == NULL) {
-        ALOGE("%s: Invalid framebuffer", __FUNCTION__);
-        return -EINVAL;
-    }
-
-    const uint32_t bufferMask = m->bufferMask;
-    const uint32_t numBuffers = m->numBuffers;
-    size_t bufferSize = m->finfo.line_length * m->info.yres;
-
-    //adreno needs FB size to be page aligned
-    bufferSize = roundUpToPageSize(bufferSize);
-
-    if (numBuffers == 1) {
-        // If we have only one buffer, we never use page-flipping. Instead,
-        // we return a regular buffer which will be memcpy'ed to the main
-        // screen when post is called.
-        int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D;
-        return gralloc_alloc_buffer(bufferSize, newUsage, pHandle, BUFFER_TYPE_UI,
-                                    m->fbFormat, m->info.xres, m->info.yres);
-    }
-
-    if (bufferMask >= ((1LU<<numBuffers)-1)) {
-        // We ran out of buffers.
-        return -ENOMEM;
-    }
-
-    // create a "fake" handle for it
-    intptr_t vaddr = intptr_t(m->framebuffer->base);
-    private_handle_t* hnd = new private_handle_t(
-                                dup(m->framebuffer->fd), bufferSize,
-                                private_handle_t::PRIV_FLAGS_USES_ION |
-                                private_handle_t::PRIV_FLAGS_FRAMEBUFFER,
-                                BUFFER_TYPE_UI, m->fbFormat, m->info.xres,
-                                m->info.yres);
-
-    // find a free slot
-    for (uint32_t i=0 ; i<numBuffers ; i++) {
-        if ((bufferMask & (1LU<<i)) == 0) {
-            m->bufferMask |= (1LU<<i);
-            break;
-        }
-        vaddr += bufferSize;
-    }
-
-    hnd->base = vaddr;
-    hnd->offset = vaddr - intptr_t(m->framebuffer->base);
-    *pHandle = hnd;
-    return 0;
-}
-
-
-int gpu_context_t::gralloc_alloc_framebuffer(size_t size, int usage,
-                                             buffer_handle_t* pHandle)
-{
-    private_module_t* m = reinterpret_cast<private_module_t*>(common.module);
-    pthread_mutex_lock(&m->lock);
-    int err = gralloc_alloc_framebuffer_locked(size, usage, pHandle);
-    pthread_mutex_unlock(&m->lock);
-    return err;
-}
-
 int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage,
                                         buffer_handle_t* pHandle, int bufferType,
                                         int format, int width, int height)
@@ -267,26 +196,20 @@
 
 int gpu_context_t::free_impl(private_handle_t const* hnd) {
     private_module_t* m = reinterpret_cast<private_module_t*>(common.module);
-    if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) {
-        // free this buffer
-        const size_t bufferSize = m->finfo.line_length * m->info.yres;
-        int index = (hnd->base - m->framebuffer->base) / bufferSize;
-        m->bufferMask &= ~(1<<index);
-    } else {
-        terminateBuffer(&m->base, const_cast<private_handle_t*>(hnd));
-        IMemAlloc* memalloc = mAllocCtrl->getAllocator(hnd->flags);
-        int err = memalloc->free_buffer((void*)hnd->base, (size_t) hnd->size,
-                                        hnd->offset, hnd->fd);
-        if(err)
-            return err;
-        // free the metadata space
-        unsigned long size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
-        err = memalloc->free_buffer((void*)hnd->base_metadata,
-                                    (size_t) size, hnd->offset_metadata,
-                                    hnd->fd_metadata);
-        if (err)
-            return err;
-    }
+
+    terminateBuffer(&m->base, const_cast<private_handle_t*>(hnd));
+    IMemAlloc* memalloc = mAllocCtrl->getAllocator(hnd->flags);
+    int err = memalloc->free_buffer((void*)hnd->base, (size_t) hnd->size,
+                                    hnd->offset, hnd->fd);
+    if(err)
+        return err;
+    // free the metadata space
+    unsigned long size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
+    err = memalloc->free_buffer((void*)hnd->base_metadata,
+                                (size_t) size, hnd->offset_metadata,
+                                hnd->fd_metadata);
+    if (err)
+        return err;
 
     delete hnd;
     return 0;
diff --git a/libgralloc/gpu.h b/libgralloc/gpu.h
index 2986984..6826ffe 100644
--- a/libgralloc/gpu.h
+++ b/libgralloc/gpu.h
@@ -27,7 +27,7 @@
 #include <cutils/ashmem.h>
 
 #include "gralloc_priv.h"
-#include <fb_priv.h>
+#include "fb_priv.h"
 
 namespace gralloc {
 class IAllocController;
@@ -36,12 +36,6 @@
     gpu_context_t(const private_module_t* module,
                   IAllocController* alloc_ctrl);
 
-    int gralloc_alloc_framebuffer_locked(size_t size, int usage,
-                                         buffer_handle_t* pHandle);
-
-    int gralloc_alloc_framebuffer(size_t size, int usage,
-                                  buffer_handle_t* pHandle);
-
     int gralloc_alloc_buffer(size_t size, int usage,
                              buffer_handle_t* pHandle,
                              int bufferType, int format,