summaryrefslogtreecommitdiffstats
path: root/camera/ANativeWindowDisplayAdapter.cpp
diff options
context:
space:
mode:
authorAndriy Chepurnyy <x0155536@ti.com>2012-10-26 14:02:25 +0300
committerDaniel Levin <dendy@ti.com>2012-11-26 20:17:15 +0200
commit5be19d85932b7efd58885bf4ca1934f52beb32c0 (patch)
tree671d0e83fb4de8278ac1eadc0d578cf97b5aee7c /camera/ANativeWindowDisplayAdapter.cpp
parente54099214a3a1c340f4785c9e4d46265cecbfb49 (diff)
downloadhardware_ti_omap4-5be19d85932b7efd58885bf4ca1934f52beb32c0.zip
hardware_ti_omap4-5be19d85932b7efd58885bf4ca1934f52beb32c0.tar.gz
hardware_ti_omap4-5be19d85932b7efd58885bf4ca1934f52beb32c0.tar.bz2
CameraHAL: Make graphic buffer locking conditional
This mechanism is added to support components where locking mechanism is handled on DOMX layer. As example is using ducati decoder with buffers allocated via ANativeWindowDisplayAdapter. Change-Id: I33ae0f0766473a6d8e85699c31dcad9345b4df70 Signed-off-by: Andriy Chepurnyy <x0155536@ti.com>
Diffstat (limited to 'camera/ANativeWindowDisplayAdapter.cpp')
-rw-r--r--camera/ANativeWindowDisplayAdapter.cpp62
1 files changed, 38 insertions, 24 deletions
diff --git a/camera/ANativeWindowDisplayAdapter.cpp b/camera/ANativeWindowDisplayAdapter.cpp
index fce9c50..396e6d4 100644
--- a/camera/ANativeWindowDisplayAdapter.cpp
+++ b/camera/ANativeWindowDisplayAdapter.cpp
@@ -75,7 +75,8 @@ OMX_COLOR_FORMATTYPE toOMXPixFormat(const char* parameters_format)
ANativeWindowDisplayAdapter::ANativeWindowDisplayAdapter():mDisplayThread(NULL),
mDisplayState(ANativeWindowDisplayAdapter::DISPLAY_INIT),
mDisplayEnabled(false),
- mBufferCount(0)
+ mBufferCount(0),
+ mUseExternalBufferLocking(false)
@@ -579,6 +580,9 @@ CameraBuffer* ANativeWindowDisplayAdapter::allocateBufferList(int width, int hei
mapper.lock(*handle, CAMHAL_GRALLOC_USAGE, bounds, y_uv);
mBuffers[i].mapped = y_uv[0];
mFrameProvider->addFramePointers(&mBuffers[i], y_uv);
+ if (mUseExternalBufferLocking) {
+ mapper.unlock(*handle);
+ }
}
// return the rest of the buffers back to ANativeWindow
@@ -781,8 +785,10 @@ status_t ANativeWindowDisplayAdapter::returnBuffersToWindow()
continue;
}
- // unlock buffer before giving it up
- mapper.unlock(*handle);
+ if (!mUseExternalBufferLocking) {
+ // unlock buffer before giving it up
+ mapper.unlock(*handle);
+ }
ret = mANativeWindow->cancel_buffer(mANativeWindow, handle);
if ( NO_INIT == ret ) {
@@ -1070,8 +1076,10 @@ status_t ANativeWindowDisplayAdapter::PostFrame(ANativeWindowDisplayAdapter::Dis
{
buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque;
- // unlock buffer before sending to display
- mapper.unlock(*handle);
+ if (!mUseExternalBufferLocking) {
+ // unlock buffer before sending to display
+ mapper.unlock(*handle);
+ }
ret = mANativeWindow->enqueue_buffer(mANativeWindow, handle);
}
if ( NO_ERROR != ret ) {
@@ -1090,9 +1098,10 @@ status_t ANativeWindowDisplayAdapter::PostFrame(ANativeWindowDisplayAdapter::Dis
else
{
buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque;
-
- // unlock buffer before giving it up
- mapper.unlock(*handle);
+ if (!mUseExternalBufferLocking) {
+ // unlock buffer before giving it up
+ mapper.unlock(*handle);
+ }
// cancel buffer and dequeue another one
ret = mANativeWindow->cancel_buffer(mANativeWindow, handle);
@@ -1162,23 +1171,24 @@ bool ANativeWindowDisplayAdapter::handleFrameReturn()
if (i == mBufferCount) {
CAMHAL_LOGEB("Failed to find handle %p", buf);
}
-
- // lock buffer before sending to FrameProvider for filling
- bounds.left = 0;
- bounds.top = 0;
- bounds.right = mFrameWidth;
- bounds.bottom = mFrameHeight;
-
- int lock_try_count = 0;
- while (mapper.lock(*(buffer_handle_t *) mBuffers[i].opaque, CAMHAL_GRALLOC_USAGE, bounds, y_uv) < 0){
- if (++lock_try_count > LOCK_BUFFER_TRIES){
- if ( NULL != mErrorNotifier.get() ){
- mErrorNotifier->errorNotify(CAMERA_ERROR_UNKNOWN);
+ if (!mUseExternalBufferLocking) {
+ // lock buffer before sending to FrameProvider for filling
+ bounds.left = 0;
+ bounds.top = 0;
+ bounds.right = mFrameWidth;
+ bounds.bottom = mFrameHeight;
+
+ int lock_try_count = 0;
+ while (mapper.lock(*(buffer_handle_t *) mBuffers[i].opaque, CAMHAL_GRALLOC_USAGE, bounds, y_uv) < 0){
+ if (++lock_try_count > LOCK_BUFFER_TRIES){
+ if ( NULL != mErrorNotifier.get() ){
+ mErrorNotifier->errorNotify(CAMERA_ERROR_UNKNOWN);
+ }
+ return false;
+ }
+ CAMHAL_LOGEA("Gralloc Lock FrameReturn Error: Sleeping 15ms");
+ usleep(15000);
}
- return false;
- }
- CAMHAL_LOGEA("Gralloc Lock FrameReturn Error: Sleeping 15ms");
- usleep(15000);
}
{
@@ -1242,6 +1252,10 @@ void ANativeWindowDisplayAdapter::frameCallback(CameraFrame* caFrame)
PostFrame(df);
}
+void ANativeWindowDisplayAdapter::setExternalLocking(bool extBuffLocking)
+{
+ mUseExternalBufferLocking = extBuffLocking;
+}
/*--------------------ANativeWindowDisplayAdapter Class ENDS here-----------------------------*/