summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2012-03-26 16:59:27 -0500
committerDaniel Levin <dendy@ti.com>2012-07-25 08:55:45 -0500
commit78f1a95ab2745b74c10d861dd9b91012ea7bfc93 (patch)
treeb9e8e0382cb324d5aa5e2127f7ec17bd114d61f3
parent464208344e2c84e886bb9bb0ca1cf940b893030d (diff)
downloadhardware_ti_omap4-78f1a95ab2745b74c10d861dd9b91012ea7bfc93.zip
hardware_ti_omap4-78f1a95ab2745b74c10d861dd9b91012ea7bfc93.tar.gz
hardware_ti_omap4-78f1a95ab2745b74c10d861dd9b91012ea7bfc93.tar.bz2
camera: implementation for new takePicture
takePicture now takes in a ShotParameters structure Change-Id: I2362d330b94e800ad800e039c22595f818935b45 Signed-off-by: Tyler Luu <tluu@ti.com> Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>
-rw-r--r--camera/CameraHal.cpp45
-rw-r--r--camera/CameraHal_Module.cpp9
-rw-r--r--camera/inc/CameraHal.h3
-rw-r--r--test/CameraHal/camera_test.h2
-rw-r--r--test/CameraHal/camera_test_menu.cpp20
-rw-r--r--test/CameraHal/camera_test_script.cpp21
6 files changed, 83 insertions, 17 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp
index b63656a..722f553 100644
--- a/camera/CameraHal.cpp
+++ b/camera/CameraHal.cpp
@@ -2539,12 +2539,12 @@ status_t CameraHal::stopImageBracketing()
@todo Define error codes if unable to switch to image capture
*/
-status_t CameraHal::takePicture( )
+status_t CameraHal::takePicture(const char *params)
{
status_t ret = NO_ERROR;
CameraFrame frame;
CameraAdapter::BuffersDescriptor desc;
- int burst;
+ int burst = -1;
const char *valstr = NULL;
unsigned int bufferCount = 1;
unsigned int rawBufferCount = 1;
@@ -2588,6 +2588,39 @@ status_t CameraHal::takePicture( )
return INVALID_OPERATION;
}
+ // check if camera application is using shots parameters
+ // api. parameters set here override anything set using setParameters
+ // TODO(XXX): Just going to use legacy TI parameters for now. Need
+ // add new APIs in CameraHal to utilize ShotParameters later, so
+ // we don't have to parse through the whole set of parameters
+ // in camera adapter
+ if (strlen(params) > 0) {
+ ShotParameters shotParams;
+ const char* valStr;
+ int valNum;
+
+ String8 shotParams8(params);
+
+ shotParams.unflatten(shotParams8);
+ mParameters.remove(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE);
+ mParameters.remove(TICameraParameters::KEY_EXP_BRACKETING_RANGE);
+
+ valStr = shotParams.get(ShotParameters::KEY_EXP_GAIN_PAIRS);
+ if (valStr!= NULL) {
+ mParameters.set(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE, valStr);
+ }
+
+ valNum = shotParams.getInt(ShotParameters::KEY_BURST);
+ if (valNum >= 0) {
+ mParameters.set(TICameraParameters::KEY_BURST, valNum);
+ burst = valNum;
+ }
+ mCameraAdapter->setParameters(mParameters);
+ } else {
+ // TODO(XXX): Should probably reset burst and bracketing params
+ // when we remove legacy TI parameters implementation
+ }
+
// if we are already in the middle of a capture...then we just need
// setParameters and start image capture to queue more shots
if ((mCameraAdapter->getState() == CameraAdapter::CAPTURE_STATE &&
@@ -2604,11 +2637,11 @@ status_t CameraHal::takePicture( )
if ( !mBracketingRunning )
{
-
- if ( NO_ERROR == ret )
- {
+ // if application didn't set burst through ShotParameters
+ // then query from TICameraParameters
+ if ((burst == -1) && (NO_ERROR == ret)) {
burst = mParameters.getInt(TICameraParameters::KEY_BURST);
- }
+ }
//Allocate all buffers only in burst capture case
if ( burst > 0 ) {
diff --git a/camera/CameraHal_Module.cpp b/camera/CameraHal_Module.cpp
index 69a47f3..8984eae 100644
--- a/camera/CameraHal_Module.cpp
+++ b/camera/CameraHal_Module.cpp
@@ -307,10 +307,17 @@ int camera_cancel_auto_focus(struct camera_device * device)
return rv;
}
+#ifdef OMAP_ENHANCEMENT
+int camera_take_picture(struct camera_device * device, const char *params)
+#else
int camera_take_picture(struct camera_device * device)
+#endif
{
int rv = -EINVAL;
ti_camera_device_t* ti_dev = NULL;
+#ifndef OMAP_ENHANCEMENT
+ const char* params = NULL;
+#endif
LOGV("%s", __FUNCTION__);
@@ -319,7 +326,7 @@ int camera_take_picture(struct camera_device * device)
ti_dev = (ti_camera_device_t*) device;
- rv = gCameraHals[ti_dev->cameraid]->takePicture();
+ rv = gCameraHals[ti_dev->cameraid]->takePicture(params);
return rv;
}
diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h
index 34d7023..ee62dcb 100644
--- a/camera/inc/CameraHal.h
+++ b/camera/inc/CameraHal.h
@@ -36,6 +36,7 @@
#include "binder/MemoryHeapBase.h"
#include <utils/threads.h>
#include <camera/CameraParameters.h>
+#include <camera/ShotParameters.h>
#include <hardware/camera.h>
#include "MessageQueue.h"
#include "Semaphore.h"
@@ -1126,7 +1127,7 @@ public:
/**
* Take a picture.
*/
- int takePicture();
+ int takePicture(const char* params);
/**
* Cancel a picture that was started with takePicture. Calling this
diff --git a/test/CameraHal/camera_test.h b/test/CameraHal/camera_test.h
index c73e1ea..6b98228 100644
--- a/test/CameraHal/camera_test.h
+++ b/test/CameraHal/camera_test.h
@@ -9,7 +9,7 @@
#define KEY_CAMERA "camera-index"
#define KEY_SATURATION "saturation"
#define KEY_BRIGHTNESS "brightness"
-#define KEY_BURST "burst-capture"
+#define KEY_TI_BURST "burst-capture"
#define KEY_EXPOSURE "exposure"
#define KEY_CONTRAST "contrast"
#define KEY_SHARPNESS "sharpness"
diff --git a/test/CameraHal/camera_test_menu.cpp b/test/CameraHal/camera_test_menu.cpp
index 2b01bea..e08ce4a 100644
--- a/test/CameraHal/camera_test_menu.cpp
+++ b/test/CameraHal/camera_test_menu.cpp
@@ -22,6 +22,7 @@
#include <binder/IServiceManager.h>
#include <cutils/properties.h>
#include <camera/CameraParameters.h>
+#include <camera/ShotParameters.h>
#include <system/audio.h>
#include <system/camera.h>
@@ -42,6 +43,7 @@ sp<SurfaceComposerClient> client;
sp<SurfaceControl> surfaceControl;
sp<Surface> previewSurface;
CameraParameters params;
+CameraParameters shotParams;
float compensation = 0.0;
double latitude = 0.0;
double longitude = 0.0;
@@ -2491,7 +2493,7 @@ int functional_menu() {
} else {
burst += BURST_INC;
}
- params.set(KEY_BURST, burst);
+ params.set(KEY_TI_BURST, burst);
if ( hardwareActive )
camera->setParameters(params.flatten());
@@ -2789,11 +2791,16 @@ int functional_menu() {
break;
case 'p':
+ {
+ int msgType = CAMERA_MSG_COMPRESSED_IMAGE |
+ CAMERA_MSG_RAW_IMAGE |
+ CAMERA_MSG_RAW_BURST;
+
if(strcmp(modevalues[capture_mode], "video-mode") == 0) {
if(strcmp(videosnapshotstr, "true") == 0) {
gettimeofday(&picture_start, 0);
if ( hardwareActive ) {
- camera->takePicture(CAMERA_MSG_COMPRESSED_IMAGE|CAMERA_MSG_RAW_IMAGE);
+ camera->takePicture(msgType, shotParams.flatten());
}
} else {
printf("Video Snapshot is not supported\n");
@@ -2803,10 +2810,15 @@ int functional_menu() {
gettimeofday(&picture_start, 0);
if (hardwareActive) {
- camera->takePicture(CAMERA_MSG_POSTVIEW_FRAME | CAMERA_MSG_RAW_IMAGE_NOTIFY | CAMERA_MSG_COMPRESSED_IMAGE | CAMERA_MSG_SHUTTER);
+ msgType = CAMERA_MSG_POSTVIEW_FRAME |
+ CAMERA_MSG_RAW_IMAGE_NOTIFY |
+ CAMERA_MSG_COMPRESSED_IMAGE |
+ CAMERA_MSG_SHUTTER |
+ CAMERA_MSG_RAW_BURST;
+ camera->takePicture(msgType, shotParams.flatten());
}
-
break;
+ }
case '&':
printf("Enabling Preview Callback");
diff --git a/test/CameraHal/camera_test_script.cpp b/test/CameraHal/camera_test_script.cpp
index 5af33f2..17c5496 100644
--- a/test/CameraHal/camera_test_script.cpp
+++ b/test/CameraHal/camera_test_script.cpp
@@ -22,6 +22,7 @@
#include <binder/IServiceManager.h>
#include <cutils/properties.h>
#include <camera/CameraParameters.h>
+#include <camera/ShotParameters.h>
#include <sys/wait.h>
@@ -739,7 +740,7 @@ int execute_functional_script(char *script) {
case '#':
- params.set(KEY_BURST, atoi(cmd + 1));
+ params.set(KEY_TI_BURST, atoi(cmd + 1));
if ( hardwareActive )
camera->setParameters(params.flatten());
@@ -1050,11 +1051,17 @@ int execute_functional_script(char *script) {
break;
case 'p':
+ {
+ int msgType = CAMERA_MSG_COMPRESSED_IMAGE |
+ CAMERA_MSG_RAW_IMAGE |
+ CAMERA_MSG_RAW_BURST;
+ ShotParameters shotParams;
+
if(strcmp(modevalues[capture_mode], "video-mode") == 0) {
if(strcmp(videosnapshotstr, "true") == 0) {
gettimeofday(&picture_start, 0);
if ( hardwareActive ) {
- ret = camera->takePicture(CAMERA_MSG_COMPRESSED_IMAGE|CAMERA_MSG_RAW_IMAGE);
+ ret = camera->takePicture(msgType, shotParams.flatten());
if ( ret != NO_ERROR ) {
printf("Error returned while taking a picture");
}
@@ -1064,16 +1071,22 @@ int execute_functional_script(char *script) {
return -1;
}
}
+
gettimeofday(&picture_start, 0);
if (hardwareActive) {
- ret = camera->takePicture(CAMERA_MSG_POSTVIEW_FRAME | CAMERA_MSG_RAW_IMAGE_NOTIFY | CAMERA_MSG_COMPRESSED_IMAGE | CAMERA_MSG_SHUTTER);
+ msgType = CAMERA_MSG_POSTVIEW_FRAME |
+ CAMERA_MSG_RAW_IMAGE_NOTIFY |
+ CAMERA_MSG_COMPRESSED_IMAGE |
+ CAMERA_MSG_SHUTTER |
+ CAMERA_MSG_RAW_BURST;
+ ret = camera->takePicture(msgType, shotParams.flatten());
}
if ( ret != NO_ERROR )
printf("Error returned while taking a picture");
break;
-
+ }
case 'd':
dly = atoi(cmd + 1);
sleep(dly);