CameraService: Add compatibility for OMAP ICS blobs

Workaround the conflict created by usage of the 0x800 enum
in JB (focus move) vs its OMAP usage in ICS (burst jpeg)

Originally:
CameraService: Adds support for burst compressed images

Signed-off-by: Emilian Peev <epeev@mm-sol.com>

Moved the changes under OMAP_ENHANCEMENT

Signed-off-by: Solaiyappan Saravanan <saravanan.s@ti.com>
Change-Id: I1f17675b2854793de83c2b7cdecafc039c46f355

CameraService: Adds support for burst compressed images

Depends on:
  - http://review.omapzoom.org/#/c/24537/
  - http://review.omapzoom.org/#/c/24538/

Change-Id: I1f17675b2854793de83c2b7cdecafc039c46f355
Signed-off-by: Solaiyappan Saravanan <saravanan.s@ti.com>
Signed-off-by: Emilian Peev <epeev@mm-sol.com>
Signed-off-by: Daniel Levin <dendy@ti.com>

Add CAMERA_MSG_RAW_BURST handling to CameraService

Change-Id: Id958836e726e9908f60311d5bfc6d26eb8298cea
Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>

CameraService: Disable capture message types before stopping preview

If we try to stopPreview in the middle of capture, these
callbacks might occur. In this case, stopPreview will already be
holding mLock while the message handler will try to grab mLock.
Deadlock occurs if the stopPreview and message callback dependencies
are in the same thread.

Issue reproduced with Image Capture/Home Key scenario.

Port from GB: Issue is still reproducible (although extremely
              rarely) in ICS.

Signed-off-by: Emilian Peev <epeev@mm-sol.com>
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Signed-off-by: Daniel Levin <dendy@ti.com>
Change-Id: I222d00f8bd69c11302a35610095efe0ddc49f876
diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp
index bd6805d..757a54c 100644
--- a/services/camera/libcameraservice/api1/CameraClient.cpp
+++ b/services/camera/libcameraservice/api1/CameraClient.cpp
@@ -89,7 +89,11 @@
 
     // 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);
+                  CAMERA_MSG_PREVIEW_METADATA 
+#ifndef OMAP_ICS_CAMERA
+                  | CAMERA_MSG_FOCUS_MOVE
+#endif
+                 );
 
     LOG1("CameraClient::initialize X (pid %d, id %d)", callingPid, mCameraId);
     return OK;
@@ -400,6 +404,11 @@
         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();
 
@@ -439,6 +448,16 @@
     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();
@@ -534,8 +553,15 @@
                            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
+
     enableMsgType(picMsgType);
 
     return mHardware->takePicture();
@@ -747,6 +773,11 @@
         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;
@@ -876,6 +907,20 @@
     }
 }
 
+#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/api1/CameraClient.h b/services/camera/libcameraservice/api1/CameraClient.h
index 4b89564..f460763 100644
--- a/services/camera/libcameraservice/api1/CameraClient.h
+++ b/services/camera/libcameraservice/api1/CameraClient.h
@@ -105,6 +105,9 @@
     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);