summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2012-06-21 11:17:08 -0500
committerDaniel Levin <dendy@ti.com>2012-11-26 20:03:35 +0200
commit85855ca02333f8cc9a6a3b821ed35a06a8fec232 (patch)
treed519afff4f5a2b231e178ac1f5189f668941d5ae /camera
parentc143e22be6a85a75d247fea47c4aba577fb0002d (diff)
downloadhardware_ti_omap4-85855ca02333f8cc9a6a3b821ed35a06a8fec232.zip
hardware_ti_omap4-85855ca02333f8cc9a6a3b821ed35a06a8fec232.tar.gz
hardware_ti_omap4-85855ca02333f8cc9a6a3b821ed35a06a8fec232.tar.bz2
CameraHal: Add support for setting multiple tap in/outs
- Adding support for setting multiple tap in and tap out points that the application can set at any time. Applications need to provide name of tap-in and tap-outs with their shot config for us to find the tap-in or tap-out point from the vector we are keeping. - Patch for releasing tap in/outs to follow Depends on frameworks/av change Ia21c4a26: http://review.omapzoom.org/#/c/28899/ Change-Id: I6fa91de68c7bf71525596ee5e1a5ebb2a7b3b5da Signed-off-by: Tyler Luu <tluu@ti.com> Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>
Diffstat (limited to 'camera')
-rw-r--r--camera/BufferSourceAdapter.cpp33
-rw-r--r--camera/CameraHal.cpp165
-rw-r--r--camera/inc/CameraHal.h8
3 files changed, 122 insertions, 84 deletions
diff --git a/camera/BufferSourceAdapter.cpp b/camera/BufferSourceAdapter.cpp
index 214d4ed..b4317e4 100644
--- a/camera/BufferSourceAdapter.cpp
+++ b/camera/BufferSourceAdapter.cpp
@@ -195,12 +195,33 @@ int BufferSourceAdapter::setPreviewWindow(preview_stream_ops_t *source)
return BAD_VALUE;
}
- if ( source == mBufferSource ) {
- return ALREADY_EXISTS;
- }
+ if (mBufferSource) {
+ char id1[OP_STR_SIZE], id2[OP_STR_SIZE];
+ status_t ret;
- // Destroy the existing source, if it exists
- destroy();
+ ret = extendedOps()->get_id(mBufferSource, id1, sizeof(id1));
+ if (ret != 0) {
+ CAMHAL_LOGE("Surface::getId returned error %d", ret);
+ return ret;
+ }
+
+ ret = extendedOps()->get_id(source, id2, sizeof(id2));
+ if (ret != 0) {
+ CAMHAL_LOGE("Surface::getId returned error %d", ret);
+ return ret;
+ }
+ if ((0 >= strlen(id1)) || (0 >= strlen(id2))) {
+ CAMHAL_LOGE("Cannot set ST without name: id1:\"%s\" id2:\"%s\"",
+ id1, id2);
+ return NOT_ENOUGH_DATA;
+ }
+ if (0 == strcmp(id1, id2)) {
+ return ALREADY_EXISTS;
+ }
+
+ // client has to unset mBufferSource before being able to set a new one
+ return BAD_VALUE;
+ }
// Move to new source obj
mBufferSource = source;
@@ -354,7 +375,7 @@ CameraBuffer* BufferSourceAdapter::allocateBufferList(int width, int dummyHeight
return NULL;
}
- CAMHAL_LOGDB("Number of buffers set to ANativeWindow %d", numBufs);
+ CAMHAL_LOGDB("Number of buffers set to BufferSourceAdapter %d", numBufs);
// Set the number of buffers needed for this buffer source
err = mBufferSource->set_buffer_count(mBufferSource, numBufs);
if (err != 0) {
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp
index 3b8ee85..5a36a97 100644
--- a/camera/CameraHal.cpp
+++ b/camera/CameraHal.cpp
@@ -83,6 +83,10 @@ static int dummy_get_buffer_format(preview_stream_ops_t*, int*) {
static int dummy_set_metadata(preview_stream_ops_t*, const camera_memory_t*) {
return INVALID_OPERATION;
}
+
+static int dummy_get_id(preview_stream_ops_t*, char *data, unsigned int dataSize) {
+ return INVALID_OPERATION;
+}
#endif
#ifdef OMAP_ENHANCEMENT
@@ -92,6 +96,7 @@ static preview_stream_extended_ops_t dummyPreviewStreamExtendedOps = {
dummy_get_buffer_dimension,
dummy_get_buffer_format,
dummy_set_metadata,
+ dummy_get_id,
#endif
};
#endif
@@ -2113,117 +2118,103 @@ void CameraHal::setExtendedPreviewStreamOps(preview_stream_extended_ops_t *ops)
status_t CameraHal::setBufferSource(struct preview_stream_ops *tapin, struct preview_stream_ops *tapout)
{
status_t ret = NO_ERROR;
+ int index = -1;
LOG_FUNCTION_NAME;
- // If either a tapin or tapout was previously set
- // we need to clean up and clear capturing
- if ((!tapout && mBufferSourceAdapter_Out.get()) ||
- (!tapin && mBufferSourceAdapter_In.get())) {
- signalEndImageCapture();
- }
-
- // Set tapout point
- // destroy current buffer tapout if NULL tapout is passed
- if (!tapout) {
- if (mBufferSourceAdapter_Out.get() != NULL) {
- CAMHAL_LOGD("NULL tapout passed, destroying buffer tapout adapter");
- mBufferSourceAdapter_Out.clear();
- mBufferSourceAdapter_Out = 0;
- }
- ret = NO_ERROR;
- } else if (mBufferSourceAdapter_Out.get() == NULL) {
- mBufferSourceAdapter_Out = new BufferSourceAdapter();
- mBufferSourceAdapter_Out->setExtendedOps(mExtendedPreviewStreamOps);
- if(!mBufferSourceAdapter_Out.get()) {
- CAMHAL_LOGEA("Couldn't create DisplayAdapter");
- ret = NO_MEMORY;
- goto exit;
+ // Set tapout point
+ // destroy current buffer tapout if NULL tapout is passed
+ // 1. Check name of tap-out
+ // 2. If not already set, then create a new one
+ // 3. Allocate buffers. If user is re-setting the surface, free buffers first and re-allocate
+ // in case dimensions have changed
+
+ android::AutoMutex lock(mLock);
+
+ for (unsigned int i = 0; i < mOutAdapters.size(); i++) {
+ android::sp<DisplayAdapter> out;
+ out = mOutAdapters.itemAt(i);
+ ret = out->setPreviewWindow(tapout);
+ if (ret == ALREADY_EXISTS) {
+ index = i;
+ ret = NO_ERROR;
}
+ }
- ret = mBufferSourceAdapter_Out->initialize();
- if (ret != NO_ERROR)
- {
- mBufferSourceAdapter_Out.clear();
- mBufferSourceAdapter_Out = 0;
+ if (index < 0 && tapout) {
+ android::sp<DisplayAdapter> out = new BufferSourceAdapter();
+
+ ret = out->initialize();
+ if (ret != NO_ERROR) {
+ out.clear();
CAMHAL_LOGEA("DisplayAdapter initialize failed");
goto exit;
}
+ // BufferSourceAdapter will be handler of the extended OPS
+ out->setExtendedOps(mExtendedPreviewStreamOps);
+
// CameraAdapter will be the frame provider for BufferSourceAdapter
- mBufferSourceAdapter_Out->setFrameProvider(mCameraAdapter);
+ out->setFrameProvider(mCameraAdapter);
// BufferSourceAdapter will use ErrorHandler to send errors back to
// the application
- mBufferSourceAdapter_Out->setErrorHandler(mAppCallbackNotifier.get());
+ out->setErrorHandler(mAppCallbackNotifier.get());
// Update the display adapter with the new window that is passed from CameraService
- ret = mBufferSourceAdapter_Out->setPreviewWindow(tapout);
+ ret = out->setPreviewWindow(tapout);
if(ret != NO_ERROR) {
CAMHAL_LOGEB("DisplayAdapter setPreviewWindow returned error %d", ret);
goto exit;
}
- } else {
- // Update the display adapter with the new window that is passed from CameraService
- freeImageBufs();
- ret = mBufferSourceAdapter_Out->setPreviewWindow(tapout);
- if (ret == ALREADY_EXISTS) {
- // ALREADY_EXISTS should be treated as a noop in this case
- ret = NO_ERROR;
- }
- }
- if (ret != NO_ERROR) {
- CAMHAL_LOGE("Error while trying to set tapout point");
- goto exit;
+ mOutAdapters.add(out);
}
- // 1. Set tapin point
- if (!tapin) {
- if (mBufferSourceAdapter_In.get() != NULL) {
- CAMHAL_LOGD("NULL tapin passed, destroying buffer tapin adapter");
- mBufferSourceAdapter_In.clear();
- mBufferSourceAdapter_In = 0;
- }
- ret = NO_ERROR;
- } else if (mBufferSourceAdapter_In.get() == NULL) {
- mBufferSourceAdapter_In = new BufferSourceAdapter();
- mBufferSourceAdapter_In->setExtendedOps(mExtendedPreviewStreamOps);
- if(!mBufferSourceAdapter_In.get()) {
- CAMHAL_LOGEA("Couldn't create DisplayAdapter");
- ret = NO_MEMORY;
- goto exit;
+ // 1. Set tapin point
+ // 1. Check name of tap-out
+ // 2. If not already set, then create a new one
+ // 3. Allocate buffers. If user is re-setting the surface, free buffers first and re-allocate
+ // in case dimensions have changed
+ index = -1;
+ if (!tapin) goto exit;
+ for (unsigned int i = 0; i < mInAdapters.size(); i++) {
+ android::sp<DisplayAdapter> in;
+ in = mInAdapters.itemAt(i);
+ ret = in->setPreviewWindow(tapin);
+ if (ret == ALREADY_EXISTS) {
+ index = i;
+ ret = NO_ERROR;
}
+ }
+ if (index < 0 && tapin) {
+ android::sp<DisplayAdapter> in = new BufferSourceAdapter();
- ret = mBufferSourceAdapter_In->initialize();
- if (ret != NO_ERROR)
- {
- mBufferSourceAdapter_In.clear();
- mBufferSourceAdapter_In = 0;
+ ret = in->initialize();
+ if (ret != NO_ERROR) {
+ in.clear();
CAMHAL_LOGEA("DisplayAdapter initialize failed");
goto exit;
}
- // We need to set a frame provider so camera adapter can return the frame back to us
- mBufferSourceAdapter_In->setFrameProvider(mCameraAdapter);
+ // BufferSourceAdapter will be handler of the extended OPS
+ in->setExtendedOps(mExtendedPreviewStreamOps);
+
+ // CameraAdapter will be the frame provider for BufferSourceAdapter
+ in->setFrameProvider(mCameraAdapter);
// BufferSourceAdapter will use ErrorHandler to send errors back to
// the application
- mBufferSourceAdapter_In->setErrorHandler(mAppCallbackNotifier.get());
+ in->setErrorHandler(mAppCallbackNotifier.get());
// Update the display adapter with the new window that is passed from CameraService
- ret = mBufferSourceAdapter_In->setPreviewWindow(tapin);
+ ret = in->setPreviewWindow(tapin);
if(ret != NO_ERROR) {
CAMHAL_LOGEB("DisplayAdapter setPreviewWindow returned error %d", ret);
goto exit;
}
- } else {
- // Update the display adapter with the new window that is passed from CameraService
- ret = mBufferSourceAdapter_In->setPreviewWindow(tapin);
- if (ret == ALREADY_EXISTS) {
- // ALREADY_EXISTS should be treated as a noop in this case
- ret = NO_ERROR;
- }
+
+ mInAdapters.add(in);
}
exit:
@@ -3027,10 +3018,21 @@ status_t CameraHal::__takePicture(const char *params)
valStr = shotParams.get(android::ShotParameters::KEY_CURRENT_TAP_OUT);
if (valStr != NULL) {
- if(!mBufferSourceAdapter_Out->match(valStr)) {
+ int index = -1;
+ for (unsigned int i = 0; i < mOutAdapters.size(); i++) {
+ if(mOutAdapters.itemAt(i)->match(valStr)) {
+ index = i;
+ break;
+ }
+ }
+ if (index < 0) {
CAMHAL_LOGE("Invalid tap out surface passed to camerahal");
return BAD_VALUE;
}
+ CAMHAL_LOGD("Found matching out adapter at %d", index);
+ mBufferSourceAdapter_Out = mOutAdapters.itemAt(index);
+ } else {
+ mBufferSourceAdapter_Out.clear();
}
mCameraAdapter->setParameters(mParameters);
@@ -3322,10 +3324,19 @@ status_t CameraHal::reprocess(const char *params)
valStr = shotParams.get(android::ShotParameters::KEY_CURRENT_TAP_IN);
if (valStr != NULL) {
- if(!mBufferSourceAdapter_In->match(valStr)) {
+ int index = -1;
+ for (unsigned int i = 0; i < mInAdapters.size(); i++) {
+ if(mInAdapters.itemAt(i)->match(valStr)) {
+ index = i;
+ break;
+ }
+ }
+ if (index < 0) {
CAMHAL_LOGE("Invalid tap in surface passed to camerahal");
return BAD_VALUE;
}
+ CAMHAL_LOGD("Found matching in adapter at %d", index);
+ mBufferSourceAdapter_In = mInAdapters.itemAt(index);
} else {
CAMHAL_LOGE("No tap in surface sent with shot config!");
return BAD_VALUE;
@@ -4286,6 +4297,8 @@ void CameraHal::deinitialize()
mBufferSourceAdapter_Out.clear();
mBufferSourceAdapter_In.clear();
+ mOutAdapters.clear();
+ mInAdapters.clear();
LOG_FUNCTION_NAME_EXIT;
diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h
index 1b5466d..4a4316c 100644
--- a/camera/inc/CameraHal.h
+++ b/camera/inc/CameraHal.h
@@ -1375,8 +1375,12 @@ public:
android::sp<AppCallbackNotifier> mAppCallbackNotifier;
android::sp<DisplayAdapter> mDisplayAdapter;
android::sp<MemoryManager> mMemoryManager;
- // TODO(XXX): May need to keep this as a vector in the future
- // when we can have multiple tap-in/tap-out points
+
+ android::Vector< android::sp<DisplayAdapter> > mOutAdapters;
+ android::Vector< android::sp<DisplayAdapter> > mInAdapters;
+
+ // TODO(XXX): Even though we support user setting multiple BufferSourceAdapters now
+ // only one tap in surface and one tap out surface is supported at a time.
android::sp<DisplayAdapter> mBufferSourceAdapter_In;
android::sp<DisplayAdapter> mBufferSourceAdapter_Out;