From 49008be4a3a4b34967505443ba5f0dcb62008880 Mon Sep 17 00:00:00 2001 From: Omprakash Dhyade Date: Sun, 18 Sep 2011 17:35:45 -0700 Subject: [PATCH] hardware/msm7k: libgralloc-qsd8k: Remove wait in fb_post and lockBuffer implementation Since fb_post and dequeueBuffer may be called from different threads, it might happen that both wait for available buffer causig both threads to go in sleep. To solve this problem we add lockBuffer implementation and remove waits from fb_post and dequeueBuffer. This will also be consistent with native window implementation. Change-Id: Id5e6e2feac5153156fabd9266b0c1cd5a5681514 --- libgralloc-qsd8k/framebuffer.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/libgralloc-qsd8k/framebuffer.cpp b/libgralloc-qsd8k/framebuffer.cpp index 60e1e55..29c1c8a 100644 --- a/libgralloc-qsd8k/framebuffer.cpp +++ b/libgralloc-qsd8k/framebuffer.cpp @@ -609,26 +609,11 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) pthread_cond_signal(&(m->qpost)); pthread_mutex_unlock(&(m->qlock)); - // LCDC: after new buffer grabbed by MDP can unlock previous - // (current) buffer - if (m->currentBuffer) { - if (m->swapInterval != 0) { - pthread_mutex_lock(&(m->avail[futureIdx].lock)); - //while (! m->avail[futureIdx].is_avail) { - while (m->avail[futureIdx].state != AVL) { - pthread_cond_wait(&(m->avail[futureIdx].cond), - &(m->avail[futureIdx].lock)); - //m->avail[futureIdx].is_avail = true; - } - pthread_mutex_unlock(&(m->avail[futureIdx].lock)); - } + if (m->currentBuffer) m->base.unlock(&m->base, m->currentBuffer); - } + m->currentBuffer = buffer; m->currentIdx = nxtIdx; - if (m->avail[futureIdx].state != AVL) { - LOGE_IF(m->swapInterval != 0, "[%d] != AVL!", futureIdx); - } } else { if (m->currentBuffer) m->base.unlock(&m->base, m->currentBuffer); @@ -679,7 +664,7 @@ static int fb_compositionComplete(struct framebuffer_device_t* dev) return 0; } -static int fb_dequeueBuffer(struct framebuffer_device_t* dev, int index) +static int fb_lockBuffer(struct framebuffer_device_t* dev, int index) { private_module_t* m = reinterpret_cast( dev->common.module); @@ -1010,7 +995,7 @@ int fb_device_open(hw_module_t const* module, const char* name, dev->device.post = fb_post; dev->device.setUpdateRect = 0; dev->device.compositionComplete = fb_compositionComplete; - dev->device.dequeueBuffer = fb_dequeueBuffer; + dev->device.lockBuffer = fb_lockBuffer; #if defined(HDMI_DUAL_DISPLAY) dev->device.orientationChanged = fb_orientationChanged; dev->device.videoOverlayStarted = fb_videoOverlayStarted;