diff options
Diffstat (limited to 'services/camera')
6 files changed, 108 insertions, 7 deletions
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp index 0f1e650..bddcb8c 100644 --- a/services/camera/libcameraservice/Camera2Client.cpp +++ b/services/camera/libcameraservice/Camera2Client.cpp @@ -1430,11 +1430,13 @@ void Camera2Client::notifyAutoFocus(uint8_t newState, int triggerId) { } } if (sendMovingMessage) { +#ifndef OMAP_ICS_CAMERA SharedCameraClient::Lock l(mSharedCameraClient); if (l.mCameraClient != 0) { l.mCameraClient->notifyCallback(CAMERA_MSG_FOCUS_MOVE, afInMotion ? 1 : 0, 0); } +#endif } if (sendCompletedMessage) { SharedCameraClient::Lock l(mSharedCameraClient); diff --git a/services/camera/libcameraservice/CameraClient.cpp b/services/camera/libcameraservice/CameraClient.cpp index b930c02..1cdb938 100644 --- a/services/camera/libcameraservice/CameraClient.cpp +++ b/services/camera/libcameraservice/CameraClient.cpp @@ -83,8 +83,14 @@ status_t CameraClient::initialize(camera_module_t *module) { (void *)mCameraId); // Enable zoom, error, focus, and metadata messages by default - enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS | - CAMERA_MSG_PREVIEW_METADATA | CAMERA_MSG_FOCUS_MOVE); + enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS +#ifndef QCOM_HARDWARE + | CAMERA_MSG_PREVIEW_METADATA +#endif +#ifndef OMAP_ICS_CAMERA + | CAMERA_MSG_FOCUS_MOVE +#endif + ); LOG1("CameraClient::initialize X (pid %d, id %d)", callingPid, mCameraId); return OK; @@ -244,9 +250,14 @@ void CameraClient::disconnect() { // Release the held ANativeWindow resources. if (mPreviewWindow != 0) { +#ifdef QCOM_HARDWARE + mHardware->setPreviewWindow(0); +#endif disconnectWindow(mPreviewWindow); mPreviewWindow = 0; +#ifndef QCOM_HARDWARE mHardware->setPreviewWindow(mPreviewWindow); +#endif } mHardware.clear(); @@ -285,6 +296,10 @@ status_t CameraClient::setPreviewWindow(const sp<IBinder>& binder, native_window_set_buffers_transform(window.get(), mOrientation); result = mHardware->setPreviewWindow(window); } +#ifdef QCOM_HARDWARE + } else { + result = mHardware->setPreviewWindow(window); +#endif } if (result == NO_ERROR) { @@ -344,6 +359,9 @@ void CameraClient::setPreviewCallbackFlag(int callback_flag) { // start preview mode status_t CameraClient::startPreview() { LOG1("startPreview (pid %d)", getCallingPid()); +#ifdef QCOM_HARDWARE + enableMsgType(CAMERA_MSG_PREVIEW_METADATA); +#endif return startCameraMode(CAMERA_PREVIEW_MODE); } @@ -393,6 +411,11 @@ status_t CameraClient::startPreviewMode() { native_window_set_buffers_transform(mPreviewWindow.get(), mOrientation); } + +#if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) + disableMsgType(CAMERA_MSG_COMPRESSED_BURST_IMAGE); +#endif + mHardware->setPreviewWindow(mPreviewWindow); result = mHardware->startPreview(); @@ -429,9 +452,22 @@ status_t CameraClient::startRecordingMode() { // stop preview mode void CameraClient::stopPreview() { LOG1("stopPreview (pid %d)", getCallingPid()); +#ifdef QCOM_HARDWARE + disableMsgType(CAMERA_MSG_PREVIEW_METADATA); +#endif Mutex::Autolock lock(mLock); if (checkPidAndHardware() != NO_ERROR) return; +#ifdef OMAP_ENHANCEMENT + // According to framework documentation, preview needs + // to be started for image capture. This will make sure + // that image capture related messages get disabled if + // not done already in their respective handlers. + // If these messages come when in the midddle of + // stopping preview we will deadlock the system in + // lockIfMessageWanted(). + disableMsgType(CAMERA_MSG_POSTVIEW_FRAME); +#endif disableMsgType(CAMERA_MSG_PREVIEW_FRAME); mHardware->stopPreview(); @@ -527,8 +563,18 @@ status_t CameraClient::takePicture(int msgType) { CAMERA_MSG_POSTVIEW_FRAME | CAMERA_MSG_RAW_IMAGE | CAMERA_MSG_RAW_IMAGE_NOTIFY | +#if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) + CAMERA_MSG_RAW_BURST | +#endif CAMERA_MSG_COMPRESSED_IMAGE); +#if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) + picMsgType |= CAMERA_MSG_COMPRESSED_BURST_IMAGE; +#endif + +#ifdef QCOM_HARDWARE + disableMsgType(CAMERA_MSG_PREVIEW_METADATA); +#endif enableMsgType(picMsgType); return mHardware->takePicture(); @@ -687,6 +733,12 @@ void CameraClient::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2, void* user) { LOG2("notifyCallback(%d)", msgType); + // Ignore CAF_RESTART callbacks from Samsung's camera driver + if (msgType == CAMERA_MSG_FOCUS && ext1 == 4) { + LOG2("Ignore CAF_RESTART callback"); + return; + } + Mutex* lock = getClientLockFromCookie(user); if (lock == NULL) return; Mutex::Autolock alock(*lock); @@ -740,6 +792,11 @@ void CameraClient::dataCallback(int32_t msgType, case CAMERA_MSG_COMPRESSED_IMAGE: client->handleCompressedPicture(dataPtr); break; +#if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) + case CAMERA_MSG_COMPRESSED_BURST_IMAGE: + client->handleCompressedBurstPicture(dataPtr); + break; +#endif default: client->handleGenericData(msgType, dataPtr, metadata); break; @@ -869,6 +926,20 @@ void CameraClient::handleCompressedPicture(const sp<IMemory>& mem) { } } +#if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) +// burst picture callback - compressed picture ready +void CameraClient::handleCompressedBurstPicture(const sp<IMemory>& mem) { + // Don't disable this message type yet. In this mode takePicture() will + // get called only once. When burst finishes this message will get automatically + // disabled in the respective call for restarting the preview. + + sp<ICameraClient> c = mCameraClient; + mLock.unlock(); + if (c != 0) { + c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL); + } +} +#endif void CameraClient::handleGenericNotify(int32_t msgType, int32_t ext1, int32_t ext2) { diff --git a/services/camera/libcameraservice/CameraClient.h b/services/camera/libcameraservice/CameraClient.h index 2f31c4e..9b10706 100644 --- a/services/camera/libcameraservice/CameraClient.h +++ b/services/camera/libcameraservice/CameraClient.h @@ -97,6 +97,9 @@ private: void handlePostview(const sp<IMemory>& mem); void handleRawPicture(const sp<IMemory>& mem); void handleCompressedPicture(const sp<IMemory>& mem); +#if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) + void handleCompressedBurstPicture(const sp<IMemory>& mem); +#endif void handleGenericNotify(int32_t msgType, int32_t ext1, int32_t ext2); void handleGenericData(int32_t msgType, const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata); diff --git a/services/camera/libcameraservice/CameraHardwareInterface.h b/services/camera/libcameraservice/CameraHardwareInterface.h index 05ac9fa..d67996e 100644 --- a/services/camera/libcameraservice/CameraHardwareInterface.h +++ b/services/camera/libcameraservice/CameraHardwareInterface.h @@ -113,6 +113,12 @@ public: ALOGV("%s(%s) buf %p", __FUNCTION__, mName.string(), buf.get()); if (mDevice->ops->set_preview_window) { +#ifdef QCOM_HARDWARE + ALOGV("%s buf %p mPreviewWindow %p", __FUNCTION__, buf.get(), mPreviewWindow.get()); + if (mPreviewWindow.get() && (buf.get() != mPreviewWindow.get())) { + mDevice->ops->set_preview_window(mDevice, 0); + } +#endif mPreviewWindow = buf; mHalPreviewWindow.user = this; ALOGV("%s &mHalPreviewWindow %p mHalPreviewWindow.user %p", __FUNCTION__, @@ -456,13 +462,17 @@ private: ALOGV("%s", __FUNCTION__); CameraHardwareInterface *__this = static_cast<CameraHardwareInterface *>(user); - sp<CameraHeapMemory> mem(static_cast<CameraHeapMemory *>(data->handle)); - if (index >= mem->mNumBufs) { + if (data != NULL) { + sp<CameraHeapMemory> mem(static_cast<CameraHeapMemory *>(data->handle)); + if (index >= mem->mNumBufs) { ALOGE("%s: invalid buffer index %d, max allowed is %d", __FUNCTION__, index, mem->mNumBufs); return; + } + __this->mDataCb(msg_type, mem->mBuffers[index], metadata, __this->mCbUser); + } else { + __this->mDataCb(msg_type, NULL, metadata, __this->mCbUser); } - __this->mDataCb(msg_type, mem->mBuffers[index], metadata, __this->mCbUser); } static void __data_cb_timestamp(nsecs_t timestamp, int32_t msg_type, diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 124d24d..d8365eb 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -37,6 +37,7 @@ #include <utils/Log.h> #include <utils/String16.h> +#include <system/camera.h> #include "CameraService.h" #include "CameraClient.h" #include "Camera2Client.h" @@ -358,8 +359,18 @@ void CameraService::loadSound() { LOG1("CameraService::loadSound ref=%d", mSoundRef); if (mSoundRef++) return; - mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg"); - mSoundPlayer[SOUND_RECORDING] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg"); + char value[PROPERTY_VALUE_MAX]; + property_get("persist.camera.shutter.disable", value, "0"); + int disableSound = atoi(value); + + if(!disableSound) { + mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg"); + mSoundPlayer[SOUND_RECORDING] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg"); + } + else { + mSoundPlayer[SOUND_SHUTTER] = NULL; + mSoundPlayer[SOUND_RECORDING] = NULL; + } } void CameraService::releaseSound() { diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 4dab340..7844047 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -23,7 +23,11 @@ #include <hardware/camera.h> /* This needs to be increased if we can have more cameras */ +#ifdef OMAP_ENHANCEMENT +#define MAX_CAMERAS 3 +#else #define MAX_CAMERAS 2 +#endif namespace android { |