am 25487b34: am 44a0023d: hwc: refactor prepare: separate gathering layer statistics and cloning decision

* commit '25487b340cdb1cf93882d874858615872c2035de':
  hwc: refactor prepare: separate gathering layer statistics and cloning decision
diff --git a/camera/ANativeWindowDisplayAdapter.cpp b/camera/ANativeWindowDisplayAdapter.cpp
index 3f13b52..e6a4c87 100644
--- a/camera/ANativeWindowDisplayAdapter.cpp
+++ b/camera/ANativeWindowDisplayAdapter.cpp
@@ -177,8 +177,8 @@
     mFailedDQs = 0;
 
     mPaused = false;
-    mXOff = 0;
-    mYOff = 0;
+    mXOff = -1;
+    mYOff = -1;
     mFirstInit = false;
 
     mFD = -1;
@@ -269,6 +269,10 @@
         return BAD_VALUE;
     }
 
+    if ( window == mANativeWindow ) {
+        return ALREADY_EXISTS;
+    }
+
     ///Destroy the existing window object, if it exists
     destroy();
 
@@ -454,8 +458,8 @@
         mDisplayEnabled = false;
 
         ///Reset the offset values
-        mXOff = 0;
-        mYOff = 0;
+        mXOff = -1;
+        mYOff = -1;
 
         ///Reset the frame width and height values
         mFrameWidth =0;
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp
index bfdd671..18f48f3 100644
--- a/camera/AppCallbackNotifier.cpp
+++ b/camera/AppCallbackNotifier.cpp
@@ -38,12 +38,24 @@
                                         CameraFrame::FrameType type,
                                         void* cookie1,
                                         void* cookie2,
-                                        void* cookie3)
+                                        void* cookie3,
+                                        bool canceled)
 {
-    if (cookie1) {
+    if (cookie1 && !canceled) {
         AppCallbackNotifier* cb = (AppCallbackNotifier*) cookie1;
         cb->EncoderDoneCb(main_jpeg, thumb_jpeg, type, cookie2, cookie3);
     }
+
+    if (main_jpeg) {
+        free(main_jpeg);
+    }
+
+    if (thumb_jpeg) {
+       if (((Encoder_libjpeg::params *) thumb_jpeg)->dst) {
+           free(((Encoder_libjpeg::params *) thumb_jpeg)->dst);
+       }
+       free(thumb_jpeg);
+    }
 }
 
 /*--------------------NotificationHandler Class STARTS here-----------------------------*/
@@ -129,30 +141,17 @@
 
  exit:
 
-    if (main_jpeg) {
-        free(main_jpeg);
-    }
-
-    if (thumb_jpeg) {
-       if (((Encoder_libjpeg::params *) thumb_jpeg)->dst) {
-           free(((Encoder_libjpeg::params *) thumb_jpeg)->dst);
-       }
-       free(thumb_jpeg);
-    }
-
-    if (encoded_mem) {
-        encoded_mem->release(encoded_mem);
-    }
-
     if (picture) {
         picture->release(picture);
     }
 
-    if (cookie2) {
-        delete (ExifElementsTable*) cookie2;
-    }
-
     if (mNotifierState == AppCallbackNotifier::NOTIFIER_STARTED) {
+        if (encoded_mem) {
+            encoded_mem->release(encoded_mem);
+        }
+        if (cookie2) {
+            delete (ExifElementsTable*) cookie2;
+        }
         encoder = gEncoderQueue.valueFor(src);
         if (encoder.get()) {
             gEncoderQueue.removeItem(src);
@@ -285,7 +284,8 @@
         CAMHAL_LOGDA("Notification Thread received message from Camera HAL");
         shouldLive = processMessage();
         if(!shouldLive) {
-                CAMHAL_LOGDA("Notification Thread exiting.");
+          CAMHAL_LOGDA("Notification Thread exiting.");
+          return shouldLive;
         }
     }
 
@@ -1664,7 +1664,7 @@
 
 status_t AppCallbackNotifier::disableMsgType(int32_t msgType)
 {
-    if(!mCameraHal->msgTypeEnabled(CAMERA_MSG_PREVIEW_FRAME | CAMERA_MSG_POSTVIEW_FRAME)) {
+    if( msgType & (CAMERA_MSG_PREVIEW_FRAME | CAMERA_MSG_POSTVIEW_FRAME) ) {
         mFrameProvider->disableFrameNotification(CameraFrame::PREVIEW_FRAME_SYNC);
     }
 
@@ -1732,9 +1732,20 @@
 
     while(!gEncoderQueue.isEmpty()) {
         sp<Encoder_libjpeg> encoder = gEncoderQueue.valueAt(0);
+        camera_memory_t* encoded_mem = NULL;
+        ExifElementsTable* exif = NULL;
+
         if(encoder.get()) {
             encoder->cancel();
-            encoder->join();
+
+            encoder->getCookies(NULL, (void**) &encoded_mem, (void**) &exif);
+            if (encoded_mem) {
+                encoded_mem->release(encoded_mem);
+            }
+            if (exif) {
+                delete exif;
+            }
+
             encoder.clear();
         }
         gEncoderQueue.removeItemsAt(0);
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp
index c7ba87f..c64b7e2 100644
--- a/camera/CameraHal.cpp
+++ b/camera/CameraHal.cpp
@@ -1713,12 +1713,15 @@
             // Start the preview since the window is now available
             ret = startPreview();
         }
-    }else
-    {
-        /* If mDisplayAdpater is already created. No need to do anything.
-         * We get a surface handle directly now, so we can reconfigure surface
-         * itself in DisplayAdapter if dimensions have changed
-         */
+    } else {
+        // Update the display adapter with the new window that is passed from CameraService
+        ret = mDisplayAdapter->setPreviewWindow(window);
+        if ( (NO_ERROR == ret) && previewEnabled() ) {
+            restartPreview();
+        } else if (ret == ALREADY_EXISTS) {
+            // ALREADY_EXISTS should be treated as a noop in this case
+            ret = NO_ERROR;
+        }
     }
     LOG_FUNCTION_NAME_EXIT;
 
diff --git a/camera/CameraHalUtilClasses.cpp b/camera/CameraHalUtilClasses.cpp
index 3074bc4..073c2b8 100644
--- a/camera/CameraHalUtilClasses.cpp
+++ b/camera/CameraHalUtilClasses.cpp
@@ -1,362 +1,362 @@
-/*

- * Copyright (C) Texas Instruments - http://www.ti.com/

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-/**

-* @file CameraHalUtilClasses.cpp

-*

-* This file maps the CameraHardwareInterface to the Camera interfaces on OMAP4 (mainly OMX).

-*

-*/

-

-#define LOG_TAG "CameraHAL"

-

-

-#include "CameraHal.h"

-

-namespace android {

-

-/*--------------------FrameProvider Class STARTS here-----------------------------*/

-

-int FrameProvider::enableFrameNotification(int32_t frameTypes)

-{

-    LOG_FUNCTION_NAME;

-    status_t ret = NO_ERROR;

-

-    ///Enable the frame notification to CameraAdapter (which implements FrameNotifier interface)

-    mFrameNotifier->enableMsgType(frameTypes<<MessageNotifier::FRAME_BIT_FIELD_POSITION

-                                    , mFrameCallback

-                                    , NULL

-                                    , mCookie

-                                    );

-

-    LOG_FUNCTION_NAME_EXIT;

-    return ret;

-}

-

-int FrameProvider::disableFrameNotification(int32_t frameTypes)

-{

-    LOG_FUNCTION_NAME;

-    status_t ret = NO_ERROR;

-

-    mFrameNotifier->disableMsgType(frameTypes<<MessageNotifier::FRAME_BIT_FIELD_POSITION

-                                    , mCookie

-                                    );

-

-    LOG_FUNCTION_NAME_EXIT;

-    return ret;

-}

-

-int FrameProvider::returnFrame(void *frameBuf, CameraFrame::FrameType frameType)

-{

-    status_t ret = NO_ERROR;

-

-    mFrameNotifier->returnFrame(frameBuf, frameType);

-

-    return ret;

-}

-

-void FrameProvider::addFramePointers(void *frameBuf, void *buf)

-{

-  mFrameNotifier->addFramePointers(frameBuf, buf);

-  return;

-}

-

-void FrameProvider::removeFramePointers()

-{

-  mFrameNotifier->removeFramePointers();

-  return;

-}

-

-/*--------------------FrameProvider Class ENDS here-----------------------------*/

-

-/*--------------------EventProvider Class STARTS here-----------------------------*/

-

-int EventProvider::enableEventNotification(int32_t frameTypes)

-{

-    LOG_FUNCTION_NAME;

-    status_t ret = NO_ERROR;

-

-    ///Enable the frame notification to CameraAdapter (which implements FrameNotifier interface)

-    mEventNotifier->enableMsgType(frameTypes<<MessageNotifier::EVENT_BIT_FIELD_POSITION

-                                    , NULL

-                                    , mEventCallback

-                                    , mCookie

-                                    );

-

-    LOG_FUNCTION_NAME_EXIT;

-    return ret;

-}

-

-int EventProvider::disableEventNotification(int32_t frameTypes)

-{

-    LOG_FUNCTION_NAME;

-    status_t ret = NO_ERROR;

-

-    mEventNotifier->disableMsgType(frameTypes<<MessageNotifier::FRAME_BIT_FIELD_POSITION

-                                    , mCookie

-                                    );

-

-    LOG_FUNCTION_NAME_EXIT;

-    return ret;

-}

-

-/*--------------------EventProvider Class ENDS here-----------------------------*/

-

-/*--------------------CameraArea Class STARTS here-----------------------------*/

-

-status_t CameraArea::transfrom(size_t width,

-                               size_t height,

-                               size_t &top,

-                               size_t &left,

-                               size_t &areaWidth,

-                               size_t &areaHeight)

-{

-    status_t ret = NO_ERROR;

-    size_t hRange, vRange;

-    double hScale, vScale;

-

-    LOG_FUNCTION_NAME

-

-    hRange = CameraArea::RIGHT - CameraArea::LEFT;

-    vRange = CameraArea::BOTTOM - CameraArea::TOP;

-    hScale = ( double ) width / ( double ) hRange;

-    vScale = ( double ) height / ( double ) vRange;

-

-    top = ( mTop + vRange / 2 ) * vScale;

-    left = ( mLeft + hRange / 2 ) * hScale;

-    areaHeight = ( mBottom + vRange / 2 ) * vScale;

-    areaHeight -= top;

-    areaWidth = ( mRight + hRange / 2) * hScale;

-    areaWidth -= left;

-

-    LOG_FUNCTION_NAME_EXIT

-

-    return ret;

-}

-

-status_t CameraArea::checkArea(ssize_t top,

-                               ssize_t left,

-                               ssize_t bottom,

-                               ssize_t right,

-                               ssize_t weight)

-{

-

-    //Handles the invalid regin corner case.

-    if ( ( 0 == top ) && ( 0 == left ) && ( 0 == bottom ) && ( 0 == right ) && ( 0 == weight ) ) {

-        return NO_ERROR;

-    }

-

-    if ( ( CameraArea::WEIGHT_MIN > weight ) ||  ( CameraArea::WEIGHT_MAX < weight ) ) {

-        CAMHAL_LOGEB("Camera area weight is invalid %d", weight);

-        return -EINVAL;

-    }

-

-    if ( ( CameraArea::TOP > top ) || ( CameraArea::BOTTOM < top ) ) {

-        CAMHAL_LOGEB("Camera area top coordinate is invalid %d", top );

-        return -EINVAL;

-    }

-

-    if ( ( CameraArea::TOP > bottom ) || ( CameraArea::BOTTOM < bottom ) ) {

-        CAMHAL_LOGEB("Camera area bottom coordinate is invalid %d", bottom );

-        return -EINVAL;

-    }

-

-    if ( ( CameraArea::LEFT > left ) || ( CameraArea::RIGHT < left ) ) {

-        CAMHAL_LOGEB("Camera area left coordinate is invalid %d", left );

-        return -EINVAL;

-    }

-

-    if ( ( CameraArea::LEFT > right ) || ( CameraArea::RIGHT < right ) ) {

-        CAMHAL_LOGEB("Camera area right coordinate is invalid %d", right );

-        return -EINVAL;

-    }

-

-    if ( left >= right ) {

-        CAMHAL_LOGEA("Camera area left larger than right");

-        return -EINVAL;

-    }

-

-    if ( top >= bottom ) {

-        CAMHAL_LOGEA("Camera area top larger than bottom");

-        return -EINVAL;

-    }

-

-    return NO_ERROR;

-}

-

-status_t CameraArea::parseAreas(const char *area,

-                                size_t areaLength,

-                                Vector< sp<CameraArea> > &areas)

-{

-    status_t ret = NO_ERROR;

-    char *ctx;

-    char *pArea = NULL;

-    char *pStart = NULL;

-    char *pEnd = NULL;

-    const char *startToken = "(";

-    const char endToken = ')';

-    const char sep = ',';

-    ssize_t top, left, bottom, right, weight;

-    char *tmpBuffer = NULL;

-    sp<CameraArea> currentArea;

-

-    LOG_FUNCTION_NAME

-

-    if ( ( NULL == area ) ||

-         ( 0 >= areaLength ) )

-        {

-        return -EINVAL;

-        }

-

-    tmpBuffer = ( char * ) malloc(areaLength);

-    if ( NULL == tmpBuffer )

-        {

-        return -ENOMEM;

-        }

-

-    memcpy(tmpBuffer, area, areaLength);

-

-    pArea = strtok_r(tmpBuffer, startToken, &ctx);

-

-    do

-        {

-

-        pStart = pArea;

-        if ( NULL == pStart )

-            {

-            CAMHAL_LOGEA("Parsing of the left area coordinate failed!");

-            ret = -EINVAL;

-            break;

-            }

-        else

-            {

-            left = static_cast<ssize_t>(strtol(pStart, &pEnd, 10));

-            }

-

-        if ( sep != *pEnd )

-            {

-            CAMHAL_LOGEA("Parsing of the top area coordinate failed!");

-            ret = -EINVAL;

-            break;

-            }

-        else

-            {

-            top = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));

-            }

-

-        if ( sep != *pEnd )

-            {

-            CAMHAL_LOGEA("Parsing of the right area coordinate failed!");

-            ret = -EINVAL;

-            break;

-            }

-        else

-            {

-            right = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));

-            }

-

-        if ( sep != *pEnd )

-            {

-            CAMHAL_LOGEA("Parsing of the bottom area coordinate failed!");

-            ret = -EINVAL;

-            break;

-            }

-        else

-            {

-            bottom = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));

-            }

-

-        if ( sep != *pEnd )

-            {

-            CAMHAL_LOGEA("Parsing of the weight area coordinate failed!");

-            ret = -EINVAL;

-            break;

-            }

-        else

-            {

-            weight = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));

-            }

-

-        if ( endToken != *pEnd )

-            {

-            CAMHAL_LOGEA("Malformed area!");

-            ret = -EINVAL;

-            break;

-            }

-

-        ret = checkArea(top, left, bottom, right, weight);

-        if ( NO_ERROR != ret ) {

-            break;

-        }

-

-        currentArea = new CameraArea(top, left, bottom, right, weight);

-        CAMHAL_LOGDB("Area parsed [%dx%d, %dx%d] %d",

-                     ( int ) top,

-                     ( int ) left,

-                     ( int ) bottom,

-                     ( int ) right,

-                     ( int ) weight);

-        if ( NULL != currentArea.get() )

-            {

-            areas.add(currentArea);

-            }

-        else

-            {

-            ret = -ENOMEM;

-            break;

-            }

-

-        pArea = strtok_r(NULL, startToken, &ctx);

-

-        }

-    while ( NULL != pArea );

-

-    if ( NULL != tmpBuffer )

-        {

-        free(tmpBuffer);

-        }

-

-    LOG_FUNCTION_NAME_EXIT

-

-    return ret;

-}

-

-bool CameraArea::areAreasDifferent(Vector< sp<CameraArea> > &area1,

-                                    Vector< sp<CameraArea> > &area2) {

-    if (area1.size() != area2.size()) {

-        return true;

-    }

-

-    // not going to care about sorting order for now

-    for (int i = 0; i < area1.size(); i++) {

-        if (!area1.itemAt(i)->compare(area2.itemAt(i))) {

-            return true;

-        }

-    }

-

-    return false;

-}

-

-bool CameraArea::compare(const sp<CameraArea> &area) {

-    return ((mTop == area->mTop) && (mLeft == area->mLeft) &&

-            (mBottom == area->mBottom) && (mRight == area->mRight) &&

-            (mWeight == area->mWeight));

-}

-

-

-/*--------------------CameraArea Class ENDS here-----------------------------*/

-

-};

+/*
+ * Copyright (C) Texas Instruments - http://www.ti.com/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @file CameraHalUtilClasses.cpp
+*
+* This file maps the CameraHardwareInterface to the Camera interfaces on OMAP4 (mainly OMX).
+*
+*/
+
+#define LOG_TAG "CameraHAL"
+
+
+#include "CameraHal.h"
+
+namespace android {
+
+/*--------------------FrameProvider Class STARTS here-----------------------------*/
+
+int FrameProvider::enableFrameNotification(int32_t frameTypes)
+{
+    LOG_FUNCTION_NAME;
+    status_t ret = NO_ERROR;
+
+    ///Enable the frame notification to CameraAdapter (which implements FrameNotifier interface)
+    mFrameNotifier->enableMsgType(frameTypes<<MessageNotifier::FRAME_BIT_FIELD_POSITION
+                                    , mFrameCallback
+                                    , NULL
+                                    , mCookie
+                                    );
+
+    LOG_FUNCTION_NAME_EXIT;
+    return ret;
+}
+
+int FrameProvider::disableFrameNotification(int32_t frameTypes)
+{
+    LOG_FUNCTION_NAME;
+    status_t ret = NO_ERROR;
+
+    mFrameNotifier->disableMsgType(frameTypes<<MessageNotifier::FRAME_BIT_FIELD_POSITION
+                                    , mCookie
+                                    );
+
+    LOG_FUNCTION_NAME_EXIT;
+    return ret;
+}
+
+int FrameProvider::returnFrame(void *frameBuf, CameraFrame::FrameType frameType)
+{
+    status_t ret = NO_ERROR;
+
+    mFrameNotifier->returnFrame(frameBuf, frameType);
+
+    return ret;
+}
+
+void FrameProvider::addFramePointers(void *frameBuf, void *buf)
+{
+  mFrameNotifier->addFramePointers(frameBuf, buf);
+  return;
+}
+
+void FrameProvider::removeFramePointers()
+{
+  mFrameNotifier->removeFramePointers();
+  return;
+}
+
+/*--------------------FrameProvider Class ENDS here-----------------------------*/
+
+/*--------------------EventProvider Class STARTS here-----------------------------*/
+
+int EventProvider::enableEventNotification(int32_t frameTypes)
+{
+    LOG_FUNCTION_NAME;
+    status_t ret = NO_ERROR;
+
+    ///Enable the frame notification to CameraAdapter (which implements FrameNotifier interface)
+    mEventNotifier->enableMsgType(frameTypes<<MessageNotifier::EVENT_BIT_FIELD_POSITION
+                                    , NULL
+                                    , mEventCallback
+                                    , mCookie
+                                    );
+
+    LOG_FUNCTION_NAME_EXIT;
+    return ret;
+}
+
+int EventProvider::disableEventNotification(int32_t frameTypes)
+{
+    LOG_FUNCTION_NAME;
+    status_t ret = NO_ERROR;
+
+    mEventNotifier->disableMsgType(frameTypes<<MessageNotifier::FRAME_BIT_FIELD_POSITION
+                                    , mCookie
+                                    );
+
+    LOG_FUNCTION_NAME_EXIT;
+    return ret;
+}
+
+/*--------------------EventProvider Class ENDS here-----------------------------*/
+
+/*--------------------CameraArea Class STARTS here-----------------------------*/
+
+status_t CameraArea::transfrom(size_t width,
+                               size_t height,
+                               size_t &top,
+                               size_t &left,
+                               size_t &areaWidth,
+                               size_t &areaHeight)
+{
+    status_t ret = NO_ERROR;
+    size_t hRange, vRange;
+    double hScale, vScale;
+
+    LOG_FUNCTION_NAME
+
+    hRange = CameraArea::RIGHT - CameraArea::LEFT;
+    vRange = CameraArea::BOTTOM - CameraArea::TOP;
+    hScale = ( double ) width / ( double ) hRange;
+    vScale = ( double ) height / ( double ) vRange;
+
+    top = ( mTop + vRange / 2 ) * vScale;
+    left = ( mLeft + hRange / 2 ) * hScale;
+    areaHeight = ( mBottom + vRange / 2 ) * vScale;
+    areaHeight -= top;
+    areaWidth = ( mRight + hRange / 2) * hScale;
+    areaWidth -= left;
+
+    LOG_FUNCTION_NAME_EXIT
+
+    return ret;
+}
+
+status_t CameraArea::checkArea(ssize_t top,
+                               ssize_t left,
+                               ssize_t bottom,
+                               ssize_t right,
+                               ssize_t weight)
+{
+
+    //Handles the invalid regin corner case.
+    if ( ( 0 == top ) && ( 0 == left ) && ( 0 == bottom ) && ( 0 == right ) && ( 0 == weight ) ) {
+        return NO_ERROR;
+    }
+
+    if ( ( CameraArea::WEIGHT_MIN > weight ) ||  ( CameraArea::WEIGHT_MAX < weight ) ) {
+        CAMHAL_LOGEB("Camera area weight is invalid %d", weight);
+        return -EINVAL;
+    }
+
+    if ( ( CameraArea::TOP > top ) || ( CameraArea::BOTTOM < top ) ) {
+        CAMHAL_LOGEB("Camera area top coordinate is invalid %d", top );
+        return -EINVAL;
+    }
+
+    if ( ( CameraArea::TOP > bottom ) || ( CameraArea::BOTTOM < bottom ) ) {
+        CAMHAL_LOGEB("Camera area bottom coordinate is invalid %d", bottom );
+        return -EINVAL;
+    }
+
+    if ( ( CameraArea::LEFT > left ) || ( CameraArea::RIGHT < left ) ) {
+        CAMHAL_LOGEB("Camera area left coordinate is invalid %d", left );
+        return -EINVAL;
+    }
+
+    if ( ( CameraArea::LEFT > right ) || ( CameraArea::RIGHT < right ) ) {
+        CAMHAL_LOGEB("Camera area right coordinate is invalid %d", right );
+        return -EINVAL;
+    }
+
+    if ( left >= right ) {
+        CAMHAL_LOGEA("Camera area left larger than right");
+        return -EINVAL;
+    }
+
+    if ( top >= bottom ) {
+        CAMHAL_LOGEA("Camera area top larger than bottom");
+        return -EINVAL;
+    }
+
+    return NO_ERROR;
+}
+
+status_t CameraArea::parseAreas(const char *area,
+                                size_t areaLength,
+                                Vector< sp<CameraArea> > &areas)
+{
+    status_t ret = NO_ERROR;
+    char *ctx;
+    char *pArea = NULL;
+    char *pStart = NULL;
+    char *pEnd = NULL;
+    const char *startToken = "(";
+    const char endToken = ')';
+    const char sep = ',';
+    ssize_t top, left, bottom, right, weight;
+    char *tmpBuffer = NULL;
+    sp<CameraArea> currentArea;
+
+    LOG_FUNCTION_NAME
+
+    if ( ( NULL == area ) ||
+         ( 0 >= areaLength ) )
+        {
+        return -EINVAL;
+        }
+
+    tmpBuffer = ( char * ) malloc(areaLength);
+    if ( NULL == tmpBuffer )
+        {
+        return -ENOMEM;
+        }
+
+    memcpy(tmpBuffer, area, areaLength);
+
+    pArea = strtok_r(tmpBuffer, startToken, &ctx);
+
+    do
+        {
+
+        pStart = pArea;
+        if ( NULL == pStart )
+            {
+            CAMHAL_LOGEA("Parsing of the left area coordinate failed!");
+            ret = -EINVAL;
+            break;
+            }
+        else
+            {
+            left = static_cast<ssize_t>(strtol(pStart, &pEnd, 10));
+            }
+
+        if ( sep != *pEnd )
+            {
+            CAMHAL_LOGEA("Parsing of the top area coordinate failed!");
+            ret = -EINVAL;
+            break;
+            }
+        else
+            {
+            top = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
+            }
+
+        if ( sep != *pEnd )
+            {
+            CAMHAL_LOGEA("Parsing of the right area coordinate failed!");
+            ret = -EINVAL;
+            break;
+            }
+        else
+            {
+            right = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
+            }
+
+        if ( sep != *pEnd )
+            {
+            CAMHAL_LOGEA("Parsing of the bottom area coordinate failed!");
+            ret = -EINVAL;
+            break;
+            }
+        else
+            {
+            bottom = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
+            }
+
+        if ( sep != *pEnd )
+            {
+            CAMHAL_LOGEA("Parsing of the weight area coordinate failed!");
+            ret = -EINVAL;
+            break;
+            }
+        else
+            {
+            weight = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
+            }
+
+        if ( endToken != *pEnd )
+            {
+            CAMHAL_LOGEA("Malformed area!");
+            ret = -EINVAL;
+            break;
+            }
+
+        ret = checkArea(top, left, bottom, right, weight);
+        if ( NO_ERROR != ret ) {
+            break;
+        }
+
+        currentArea = new CameraArea(top, left, bottom, right, weight);
+        CAMHAL_LOGDB("Area parsed [%dx%d, %dx%d] %d",
+                     ( int ) top,
+                     ( int ) left,
+                     ( int ) bottom,
+                     ( int ) right,
+                     ( int ) weight);
+        if ( NULL != currentArea.get() )
+            {
+            areas.add(currentArea);
+            }
+        else
+            {
+            ret = -ENOMEM;
+            break;
+            }
+
+        pArea = strtok_r(NULL, startToken, &ctx);
+
+        }
+    while ( NULL != pArea );
+
+    if ( NULL != tmpBuffer )
+        {
+        free(tmpBuffer);
+        }
+
+    LOG_FUNCTION_NAME_EXIT
+
+    return ret;
+}
+
+bool CameraArea::areAreasDifferent(Vector< sp<CameraArea> > &area1,
+                                    Vector< sp<CameraArea> > &area2) {
+    if (area1.size() != area2.size()) {
+        return true;
+    }
+
+    // not going to care about sorting order for now
+    for (int i = 0; i < area1.size(); i++) {
+        if (!area1.itemAt(i)->compare(area2.itemAt(i))) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
+bool CameraArea::compare(const sp<CameraArea> &area) {
+    return ((mTop == area->mTop) && (mLeft == area->mLeft) &&
+            (mBottom == area->mBottom) && (mRight == area->mRight) &&
+            (mWeight == area->mWeight));
+}
+
+
+/*--------------------CameraArea Class ENDS here-----------------------------*/
+
+};
diff --git a/camera/CameraHal_Module.cpp b/camera/CameraHal_Module.cpp
index 511cbc2..daff31e 100644
--- a/camera/CameraHal_Module.cpp
+++ b/camera/CameraHal_Module.cpp
@@ -78,7 +78,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -99,7 +99,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return;
@@ -113,7 +113,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return;
@@ -127,7 +127,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return;
@@ -141,7 +141,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return 0;
@@ -156,7 +156,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -172,7 +172,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return;
@@ -187,7 +187,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -203,7 +203,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -221,7 +221,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -236,7 +236,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return;
@@ -251,7 +251,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -267,7 +267,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return;
@@ -282,7 +282,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -298,7 +298,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -314,7 +314,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -330,7 +330,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -346,7 +346,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -362,7 +362,7 @@
     char* param = NULL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return NULL;
@@ -378,7 +378,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return;
@@ -394,7 +394,7 @@
     int rv = -EINVAL;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return rv;
@@ -409,7 +409,7 @@
 {
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     if(!device)
         return;
@@ -440,7 +440,7 @@
     int ret = 0;
     ti_camera_device_t* ti_dev = NULL;
 
-    LOGV("%s", __FUNCTION__);
+    ALOGV("%s", __FUNCTION__);
 
     android::Mutex::Autolock lock(gCameraHalDeviceLock);
 
diff --git a/camera/CameraProperties.cpp b/camera/CameraProperties.cpp
index 0e83fc9..9d2b632 100644
--- a/camera/CameraProperties.cpp
+++ b/camera/CameraProperties.cpp
@@ -114,7 +114,7 @@
         }
     }
 
-    LOGV("mCamerasSupported = %d", mCamerasSupported);
+    ALOGV("mCamerasSupported = %d", mCamerasSupported);
     LOG_FUNCTION_NAME_EXIT;
     return ret;
 }
diff --git a/camera/Encoder_libjpeg.cpp b/camera/Encoder_libjpeg.cpp
index 7a6054f..ae20edb 100644
--- a/camera/Encoder_libjpeg.cpp
+++ b/camera/Encoder_libjpeg.cpp
@@ -44,6 +44,7 @@
 }
 
 #define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0]))
+#define MIN(x,y) ((x < y) ? x : y)
 
 namespace android {
 struct string_pair {
@@ -305,7 +306,7 @@
 }
 
 status_t ExifElementsTable::insertElement(const char* tag, const char* value) {
-    int value_length = 0;
+    unsigned int value_length = 0;
     status_t ret = NO_ERROR;
 
     if (!value || !tag) {
@@ -331,6 +332,13 @@
         table[position].GpsTag = FALSE;
         table[position].Tag = TagNameToValue(tag);
         exif_tag_count++;
+
+        // jhead isn't taking datetime tag...this is a WA
+        if (strcmp(tag, TAG_DATETIME) == 0) {
+            ImageInfo.numDateTimeTags = 1;
+            memcpy(ImageInfo.DateTime, value,
+                   MIN(ARRAY_SIZE(ImageInfo.DateTime), value_length + 1));
+        }
     }
 
     table[position].DataLength = 0;
diff --git a/camera/MemoryManager.cpp b/camera/MemoryManager.cpp
index 55675d9..1333666 100644
--- a/camera/MemoryManager.cpp
+++ b/camera/MemoryManager.cpp
@@ -1,167 +1,173 @@
-/*

- * Copyright (C) Texas Instruments - http://www.ti.com/

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-

-

-#define LOG_TAG "CameraHAL"

-

-

-#include "CameraHal.h"

-#include "TICameraParameters.h"

-

-extern "C" {

-

+/*
+ * Copyright (C) Texas Instruments - http://www.ti.com/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#define LOG_TAG "CameraHAL"
+
+
+#include "CameraHal.h"
+#include "TICameraParameters.h"
+
+extern "C" {
+
 #include <ion.h>
 
-//#include <timm_osal_interfaces.h>

-//#include <timm_osal_trace.h>

-

-

-};

-

-namespace android {

-

-///@todo Move these constants to a common header file, preferably in tiler.h

-#define STRIDE_8BIT (4 * 1024)

-#define STRIDE_16BIT (4 * 1024)

-

-#define ALLOCATION_2D 2

-

-///Utility Macro Declarations

-

-/*--------------------MemoryManager Class STARTS here-----------------------------*/

-void* MemoryManager::allocateBuffer(int width, int height, const char* format, int &bytes, int numBufs)

-{

-    LOG_FUNCTION_NAME;

+//#include <timm_osal_interfaces.h>
+//#include <timm_osal_trace.h>
 
-    if(mIonFd == 0)
+
+};
+
+namespace android {
+
+///@todo Move these constants to a common header file, preferably in tiler.h
+#define STRIDE_8BIT (4 * 1024)
+#define STRIDE_16BIT (4 * 1024)
+
+#define ALLOCATION_2D 2
+
+///Utility Macro Declarations
+
+/*--------------------MemoryManager Class STARTS here-----------------------------*/
+void* MemoryManager::allocateBuffer(int width, int height, const char* format, int &bytes, int numBufs)
+{
+    LOG_FUNCTION_NAME;
+
+    if(mIonFd < 0)
         {
         mIonFd = ion_open();
-        if(mIonFd == 0)
+        if(mIonFd < 0)
             {
             CAMHAL_LOGEA("ion_open failed!!!");
             return NULL;
             }
         }
 
-    ///We allocate numBufs+1 because the last entry will be marked NULL to indicate end of array, which is used when freeing

-    ///the buffers

-    const uint numArrayEntriesC = (uint)(numBufs+1);

-

-    ///Allocate a buffer array

-    uint32_t *bufsArr = new uint32_t [numArrayEntriesC];

-    if(!bufsArr)

-        {

-        CAMHAL_LOGEB("Allocation failed when creating buffers array of %d uint32_t elements", numArrayEntriesC);

-        LOG_FUNCTION_NAME_EXIT;

-        return NULL;

-        }

-

-    ///Initialize the array with zeros - this will help us while freeing the array in case of error

-    ///If a value of an array element is NULL, it means we didnt allocate it

-    memset(bufsArr, 0, sizeof(*bufsArr) * numArrayEntriesC);

-

+    ///We allocate numBufs+1 because the last entry will be marked NULL to indicate end of array, which is used when freeing
+    ///the buffers
+    const uint numArrayEntriesC = (uint)(numBufs+1);
+
+    ///Allocate a buffer array
+    uint32_t *bufsArr = new uint32_t [numArrayEntriesC];
+    if(!bufsArr)
+        {
+        CAMHAL_LOGEB("Allocation failed when creating buffers array of %d uint32_t elements", numArrayEntriesC);
+        goto error;
+        }
+
+    ///Initialize the array with zeros - this will help us while freeing the array in case of error
+    ///If a value of an array element is NULL, it means we didnt allocate it
+    memset(bufsArr, 0, sizeof(*bufsArr) * numArrayEntriesC);
+
     //2D Allocations are not supported currently
     if(bytes != 0)
-        {

+        {
         struct ion_handle *handle;
         int mmap_fd;
 
-        ///1D buffers

-        for (int i = 0; i < numBufs; i++)

-            {

+        ///1D buffers
+        for (int i = 0; i < numBufs; i++)
+            {
             int ret = ion_alloc(mIonFd, bytes, 0, 1 << ION_HEAP_TYPE_CARVEOUT, &handle);
             if(ret < 0)
-                {

+                {
                 CAMHAL_LOGEB("ion_alloc resulted in error %d", ret);
-                goto error;

-                }

+                goto error;
+                }
 
             CAMHAL_LOGDB("Before mapping, handle = %x, nSize = %d", handle, bytes);
             if ((ret = ion_map(mIonFd, handle, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, 0,
                           (unsigned char**)&bufsArr[i], &mmap_fd)) < 0)
-                {

+                {
                 CAMHAL_LOGEB("Userspace mapping of ION buffers returned error %d", ret);
                 ion_free(mIonFd, handle);
                 goto error;
-                }

+                }
 
             mIonHandleMap.add(bufsArr[i], (unsigned int)handle);
             mIonFdMap.add(bufsArr[i], (unsigned int) mmap_fd);
             mIonBufLength.add(bufsArr[i], (unsigned int) bytes);
-            }

-

-        }

+            }
+
+        }
     else // If bytes is not zero, then it is a 2-D tiler buffer request
-        {

-        }

-

-        LOG_FUNCTION_NAME_EXIT;

-

-        return (void*)bufsArr;

-

+        {
+        }
+
+        LOG_FUNCTION_NAME_EXIT;
+
+        return (void*)bufsArr;
+
 error:
     LOGE("Freeing buffers already allocated after error occurred");
-    freeBuffer(bufsArr);
-

+    if(bufsArr)
+        freeBuffer(bufsArr);
+
     if ( NULL != mErrorNotifier.get() )
         {
         mErrorNotifier->errorNotify(-ENOMEM);
         }
-

+
+    if (mIonFd >= 0)
+    {
+        ion_close(mIonFd);
+        mIonFd = -1;
+    }
+
     LOG_FUNCTION_NAME_EXIT;
     return NULL;
-}

-

-//TODO: Get needed data to map tiler buffers

-//Return dummy data for now

-uint32_t * MemoryManager::getOffsets()

-{

-    LOG_FUNCTION_NAME;

-

-    LOG_FUNCTION_NAME_EXIT;

-

-    return NULL;

-}

-

-int MemoryManager::getFd()

-{

-    LOG_FUNCTION_NAME;

-

-    LOG_FUNCTION_NAME_EXIT;

-

-    return -1;

-}

-

-int MemoryManager::freeBuffer(void* buf)

-{

-    status_t ret = NO_ERROR;

-    LOG_FUNCTION_NAME;

-

-    uint32_t *bufEntry = (uint32_t*)buf;

-

-    if(!bufEntry)

-        {

-        CAMHAL_LOGEA("NULL pointer passed to freebuffer");

-        LOG_FUNCTION_NAME_EXIT;

-        return BAD_VALUE;

-        }

-

-    while(*bufEntry)

-        {

+}
+
+//TODO: Get needed data to map tiler buffers
+//Return dummy data for now
+uint32_t * MemoryManager::getOffsets()
+{
+    LOG_FUNCTION_NAME;
+
+    LOG_FUNCTION_NAME_EXIT;
+
+    return NULL;
+}
+
+int MemoryManager::getFd()
+{
+    LOG_FUNCTION_NAME;
+
+    LOG_FUNCTION_NAME_EXIT;
+
+    return -1;
+}
+
+int MemoryManager::freeBuffer(void* buf)
+{
+    status_t ret = NO_ERROR;
+    LOG_FUNCTION_NAME;
+
+    uint32_t *bufEntry = (uint32_t*)buf;
+
+    if(!bufEntry)
+        {
+        CAMHAL_LOGEA("NULL pointer passed to freebuffer");
+        LOG_FUNCTION_NAME_EXIT;
+        return BAD_VALUE;
+        }
+
+    while(*bufEntry)
+        {
         unsigned int ptr = (unsigned int) *bufEntry++;
         if(mIonBufLength.valueFor(ptr))
             {
@@ -176,47 +182,47 @@
             {
             CAMHAL_LOGEA("Not a valid Memory Manager buffer");
             }
-        }

-

-    ///@todo Check if this way of deleting array is correct, else use malloc/free

-    uint32_t * bufArr = (uint32_t*)buf;

-    delete [] bufArr;

-

+        }
+
+    ///@todo Check if this way of deleting array is correct, else use malloc/free
+    uint32_t * bufArr = (uint32_t*)buf;
+    delete [] bufArr;
+
     if(mIonBufLength.size() == 0)
         {
-        if(mIonFd)
+        if(mIonFd >= 0)
             {
             ion_close(mIonFd);
-            mIonFd = 0;
+            mIonFd = -1;
             }
         }
-    LOG_FUNCTION_NAME_EXIT;

-    return ret;

-}

-

-status_t MemoryManager::setErrorHandler(ErrorNotifier *errorNotifier)

-{

-    status_t ret = NO_ERROR;

-

-    LOG_FUNCTION_NAME;

-

-    if ( NULL == errorNotifier )

-        {

-        CAMHAL_LOGEA("Invalid Error Notifier reference");

-        ret = -EINVAL;

-        }

-

-    if ( NO_ERROR == ret )

-        {

-        mErrorNotifier = errorNotifier;

-        }

-

-    LOG_FUNCTION_NAME_EXIT;

-

-    return ret;

-}

-

-};

-

-

-/*--------------------MemoryManager Class ENDS here-----------------------------*/

+    LOG_FUNCTION_NAME_EXIT;
+    return ret;
+}
+
+status_t MemoryManager::setErrorHandler(ErrorNotifier *errorNotifier)
+{
+    status_t ret = NO_ERROR;
+
+    LOG_FUNCTION_NAME;
+
+    if ( NULL == errorNotifier )
+        {
+        CAMHAL_LOGEA("Invalid Error Notifier reference");
+        ret = -EINVAL;
+        }
+
+    if ( NO_ERROR == ret )
+        {
+        mErrorNotifier = errorNotifier;
+        }
+
+    LOG_FUNCTION_NAME_EXIT;
+
+    return ret;
+}
+
+};
+
+
+/*--------------------MemoryManager Class ENDS here-----------------------------*/
diff --git a/camera/NV12_resize.c b/camera/NV12_resize.c
index 03c049e..63f8212 100644
--- a/camera/NV12_resize.c
+++ b/camera/NV12_resize.c
@@ -31,7 +31,7 @@
  mmUint16 dummy                         /* Transparent pixel value              */
  )
 {
-  LOGV("VT_resizeFrame_Video_opt2_lp+");
+  ALOGV("VT_resizeFrame_Video_opt2_lp+");
 
   mmUint16 row,col;
   mmUint32 resizeFactorX;
@@ -55,11 +55,11 @@
 	{
 		if(i_img_ptr->uHeight == o_img_ptr->uHeight)
 			{
-				LOGV("************************f(i_img_ptr->uHeight == o_img_ptr->uHeight) are same *********************\n");
-				LOGV("************************(i_img_ptr->width == %d" , i_img_ptr->uWidth );
-				LOGV("************************(i_img_ptr->uHeight == %d" , i_img_ptr->uHeight );
-				LOGV("************************(o_img_ptr->width == %d" ,o_img_ptr->uWidth );
-				LOGV("************************(o_img_ptr->uHeight == %d" , o_img_ptr->uHeight );
+				ALOGV("************************f(i_img_ptr->uHeight == o_img_ptr->uHeight) are same *********************\n");
+				ALOGV("************************(i_img_ptr->width == %d" , i_img_ptr->uWidth );
+				ALOGV("************************(i_img_ptr->uHeight == %d" , i_img_ptr->uHeight );
+				ALOGV("************************(o_img_ptr->width == %d" ,o_img_ptr->uWidth );
+				ALOGV("************************(o_img_ptr->uHeight == %d" , o_img_ptr->uHeight );
 			}
 	}
 
@@ -67,7 +67,7 @@
     !o_img_ptr || !o_img_ptr->imgPtr)
   {
 	LOGE("Image Point NULL");
-	LOGV("VT_resizeFrame_Video_opt2_lp-");
+	ALOGV("VT_resizeFrame_Video_opt2_lp-");
 	return FALSE;
   }
 
@@ -96,7 +96,7 @@
   if (idx < 1 || idy < 1 || i_img_ptr->uStride < 1)
 	{
 	LOGE("idx or idy less then 1 idx = %d idy = %d stride = %d", idx, idy, i_img_ptr->uStride);
-	LOGV("VT_resizeFrame_Video_opt2_lp-");
+	ALOGV("VT_resizeFrame_Video_opt2_lp-");
 	return FALSE;
 	}
 
@@ -298,10 +298,10 @@
   else
   {
 	LOGE("eFormat not supported");
-	LOGV("VT_resizeFrame_Video_opt2_lp-");
+	ALOGV("VT_resizeFrame_Video_opt2_lp-");
 	return FALSE;
   }
-  LOGV("success");
-  LOGV("VT_resizeFrame_Video_opt2_lp-");
+  ALOGV("success");
+  ALOGV("VT_resizeFrame_Video_opt2_lp-");
   return TRUE;
 }
diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
index aa32ede..a58ca45 100755
--- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
+++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
@@ -78,12 +78,6 @@
         return NO_INIT;
         }
 
-    if (mComponentState != OMX_StateLoaded && mComponentState != OMX_StateInvalid) {
-       CAMHAL_LOGEB("Error mComponentState %d is invalid!", mComponentState);
-       LOG_FUNCTION_NAME_EXIT;
-       return NO_INIT;
-    }
-
     ///Update the preview and image capture port indexes
     mCameraAdapterParameters.mPrevPortIndex = OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW;
     // temp changed in order to build OMX_CAMERA_PORT_VIDEO_OUT_IMAGE;
@@ -94,9 +88,10 @@
 
     eError = OMX_Init();
     if (eError != OMX_ErrorNone) {
-      CAMHAL_LOGEB("Error OMX_Init -0x%x", eError);
-      return eError;
+        CAMHAL_LOGEB("OMX_Init() failed, error: 0x%x", eError);
+        return ErrorUtils::omxToAndroidError(eError);
     }
+    mOmxInitialized = true;
 
     ///Get the handle to the OMX Component
     eError = OMXCameraAdapter::OMXCameraGetHandle(&mCameraAdapterParameters.mHandleComp, (OMX_PTR)this);
@@ -105,6 +100,8 @@
     }
     GOTO_EXIT_IF((eError != OMX_ErrorNone), eError);
 
+    mComponentState = OMX_StateLoaded;
+
     CAMHAL_LOGVB("OMX_GetHandle -0x%x sensor_index = %lu", eError, mSensorIndex);
     eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp,
                                   OMX_CommandPortDisable,
@@ -176,7 +173,6 @@
     mRecording = false;
     mWaitingForSnapshot = false;
     mSnapshotCount = 0;
-    mComponentState = OMX_StateLoaded;
 
     mCapMode = HIGH_QUALITY;
     mIPP = IPP_NULL;
@@ -1758,7 +1754,6 @@
     OMX_ERRORTYPE eError = OMX_ErrorNone;
     OMXCameraPortParameters *mPreviewData = NULL;
     OMXCameraPortParameters *measurementData = NULL;
-    OMX_CONFIG_EXTRADATATYPE extraDataControl;
 
     LOG_FUNCTION_NAME;
 
@@ -1870,15 +1865,7 @@
     // whether the preview frame is a snapshot
     if ( OMX_ErrorNone == eError)
         {
-        OMX_INIT_STRUCT_PTR (&extraDataControl, OMX_CONFIG_EXTRADATATYPE);
-        extraDataControl.nPortIndex = OMX_ALL;
-        extraDataControl.eExtraDataType = OMX_AncillaryData;
-        extraDataControl.bEnable = OMX_TRUE;
-
-        eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
-                               ( OMX_INDEXTYPE ) OMX_IndexConfigOtherExtraDataControl,
-                               &extraDataControl);
-        GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError);
+        ret =  setExtraData(true, OMX_ALL, OMX_AncillaryData);
         }
 
 
@@ -2919,7 +2906,7 @@
     CameraFrame cameraFrame;
     OMX_TI_PLATFORMPRIVATE *platformPrivate;
     OMX_OTHER_EXTRADATATYPE *extraData;
-    OMX_TI_ANCILLARYDATATYPE *ancillaryData;
+    OMX_TI_ANCILLARYDATATYPE *ancillaryData = NULL;
     bool snapshotFrame = false;
 
     res1 = res2 = NO_ERROR;
@@ -2952,7 +2939,6 @@
             }
 
         recalculateFPS();
-
             {
             Mutex::Autolock lock(mFaceDetectionLock);
             if ( mFaceDetectionRunning && !mFaceDetectionPaused ) {
@@ -2978,6 +2964,16 @@
             {
             typeOfFrame = CameraFrame::SNAPSHOT_FRAME;
             mask = (unsigned int)CameraFrame::SNAPSHOT_FRAME;
+
+            // video snapshot gets ancillary data and wb info from last snapshot frame
+            mCaptureAncillaryData = ancillaryData;
+            mWhiteBalanceData = NULL;
+            extraData = getExtradata((OMX_OTHER_EXTRADATATYPE*) platformPrivate->pMetaDataBuffer,
+                                     (OMX_EXTRADATATYPE) OMX_WhiteBalance);
+            if ( NULL != extraData )
+                {
+                mWhiteBalanceData = (OMX_TI_WHITEBALANCERESULTTYPE*) extraData->data;
+                }
             }
         else
             {
@@ -2991,7 +2987,7 @@
             mFramesWithEncoder++;
             }
 
-        //LOGV("FBD pBuffer = 0x%x", pBuffHeader->pBuffer);
+        //ALOGV("FBD pBuffer = 0x%x", pBuffHeader->pBuffer);
 
         if( mWaitingForSnapshot )
           {
@@ -3064,7 +3060,7 @@
             // populate exif data and pass to subscribers via quirk
             // subscriber is in charge of freeing exif data
             ExifElementsTable* exif = new ExifElementsTable();
-            setupEXIF_libjpeg(exif);
+            setupEXIF_libjpeg(exif, mCaptureAncillaryData, mWhiteBalanceData);
             cameraFrame.mQuirks |= CameraFrame::HAS_EXIF_DATA;
             cameraFrame.mCookie2 = (void*) exif;
             }
@@ -3381,6 +3377,40 @@
     return false;
 }
 
+status_t OMXCameraAdapter::setExtraData(bool enable, OMX_U32 nPortIndex, OMX_EXT_EXTRADATATYPE eType) {
+    status_t ret = NO_ERROR;
+    OMX_ERRORTYPE eError = OMX_ErrorNone;
+    OMX_CONFIG_EXTRADATATYPE extraDataControl;
+
+    LOG_FUNCTION_NAME;
+
+    if (OMX_StateInvalid == mComponentState) {
+        CAMHAL_LOGEA("OMX component is in invalid state");
+        return -EINVAL;
+    }
+
+    OMX_INIT_STRUCT_PTR (&extraDataControl, OMX_CONFIG_EXTRADATATYPE);
+
+    extraDataControl.nPortIndex = nPortIndex;
+    extraDataControl.eExtraDataType = eType;
+    extraDataControl.eCameraView = OMX_2D;
+
+    if (enable) {
+        extraDataControl.bEnable = OMX_TRUE;
+    } else {
+        extraDataControl.bEnable = OMX_FALSE;
+    }
+
+    eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
+                           (OMX_INDEXTYPE) OMX_IndexConfigOtherExtraDataControl,
+                            &extraDataControl);
+
+    LOG_FUNCTION_NAME_EXIT;
+
+    return (ret | ErrorUtils::omxToAndroidError(eError));
+}
+
+
 OMX_OTHER_EXTRADATATYPE *OMXCameraAdapter::getExtradata(OMX_OTHER_EXTRADATATYPE *extraData, OMX_EXTRADATATYPE type)
 {
   if ( NULL != extraData )
@@ -3398,10 +3428,12 @@
   return NULL;
 }
 
-OMXCameraAdapter::OMXCameraAdapter(size_t sensor_index): mComponentState (OMX_StateLoaded)
+OMXCameraAdapter::OMXCameraAdapter(size_t sensor_index)
 {
     LOG_FUNCTION_NAME;
 
+    mOmxInitialized = false;
+    mComponentState = OMX_StateInvalid;
     mSensorIndex = sensor_index;
     mPictureRotation = 0;
     // Initial values
@@ -3441,22 +3473,22 @@
 
     Mutex::Autolock lock(gAdapterLock);
 
-    //Return to OMX Loaded state
-    switchToLoaded();
+    if ( mOmxInitialized ) {
+        // return to OMX Loaded state
+        switchToLoaded();
 
-    ///De-init the OMX
-    if( (mComponentState==OMX_StateLoaded) || (mComponentState==OMX_StateInvalid))
-        {
-        ///Free the handle for the Camera component
-        if(mCameraAdapterParameters.mHandleComp)
-            {
-            OMX_FreeHandle(mCameraAdapterParameters.mHandleComp);
-             mCameraAdapterParameters.mHandleComp = NULL;
+        // deinit the OMX
+        if ( mComponentState == OMX_StateLoaded || mComponentState == OMX_StateInvalid ) {
+            // free the handle for the Camera component
+            if ( mCameraAdapterParameters.mHandleComp ) {
+                OMX_FreeHandle(mCameraAdapterParameters.mHandleComp);
+                mCameraAdapterParameters.mHandleComp = NULL;
             }
-
-        OMX_Deinit();
         }
 
+        OMX_Deinit();
+        mOmxInitialized = false;
+    }
 
     //Remove any unhandled events
     if ( !mEventSignalQ.isEmpty() )
@@ -3526,28 +3558,30 @@
 {
     OMX_ERRORTYPE eError = OMX_ErrorUndefined;
 
-    int retries = 5;
-    while(eError!=OMX_ErrorNone && --retries>=0) {
+    for ( int i = 0; i < 5; ++i ) {
+        if ( i > 0 ) {
+            // sleep for 100 ms before next attempt
+            usleep(100000);
+        }
 
-      // Setup key parameters to send to Ducati during init
-      OMX_CALLBACKTYPE oCallbacks;
+        // setup key parameters to send to Ducati during init
+        OMX_CALLBACKTYPE oCallbacks;
 
-      // Initialize the callback handles
-      oCallbacks.EventHandler    = android::OMXCameraAdapterEventHandler;
-      oCallbacks.EmptyBufferDone = android::OMXCameraAdapterEmptyBufferDone;
-      oCallbacks.FillBufferDone  = android::OMXCameraAdapterFillBufferDone;
+        // initialize the callback handles
+        oCallbacks.EventHandler    = android::OMXCameraAdapterEventHandler;
+        oCallbacks.EmptyBufferDone = android::OMXCameraAdapterEmptyBufferDone;
+        oCallbacks.FillBufferDone  = android::OMXCameraAdapterFillBufferDone;
 
-      // Get Handle
-      eError = OMX_GetHandle(handle, (OMX_STRING)"OMX.TI.DUCATI1.VIDEO.CAMERA", pAppData, &oCallbacks);
-      if (eError != OMX_ErrorNone) {
-        CAMHAL_LOGEB("OMX_GetHandle -0x%x", eError);
-        //Sleep for 100 mS
-        usleep(100000);
-      } else {
-        break;
-      }
+        // get handle
+        eError = OMX_GetHandle(handle, (OMX_STRING)"OMX.TI.DUCATI1.VIDEO.CAMERA", pAppData, &oCallbacks);
+        if ( eError == OMX_ErrorNone ) {
+            return OMX_ErrorNone;
+        }
+
+        CAMHAL_LOGEB("OMX_GetHandle() failed, error: 0x%x", eError);
     }
 
+    *handle = 0;
     return eError;
 }
 
diff --git a/camera/OMXCameraAdapter/OMXCapture.cpp b/camera/OMXCameraAdapter/OMXCapture.cpp
index 77fdb05..e479b2c 100644
--- a/camera/OMXCameraAdapter/OMXCapture.cpp
+++ b/camera/OMXCameraAdapter/OMXCapture.cpp
@@ -775,6 +775,12 @@
         }
     }
 
+    // need to enable wb data for video snapshot to fill in exif data
+    if ((ret == NO_ERROR) && (mCapMode == VIDEO_MODE)) {
+        // video snapshot uses wb data from snapshot frame
+        ret = setExtraData(true, mCameraAdapterParameters.mPrevPortIndex, OMX_WhiteBalance);
+    }
+
     //OMX shutter callback events are only available in hq mode
     if ( (HIGH_QUALITY == mCapMode) || (HIGH_QUALITY_ZSL== mCapMode))
         {
@@ -866,6 +872,7 @@
 
 EXIT:
     CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError);
+    setExtraData(false, mCameraAdapterParameters.mPrevPortIndex, OMX_WhiteBalance);
     mWaitingForSnapshot = false;
     mCaptureSignalled = false;
     performCleanupAfterError();
@@ -945,6 +952,13 @@
             goto EXIT;
         }
     }
+
+    // had to enable wb data for video snapshot to fill in exif data
+    // now that we are done...disable
+    if ((ret == NO_ERROR) && (mCapMode == VIDEO_MODE)) {
+        ret = setExtraData(false, mCameraAdapterParameters.mPrevPortIndex, OMX_WhiteBalance);
+    }
+
     CAMHAL_LOGDB("Capture set - 0x%x", eError);
 
     mCaptureSignalled = true; //set this to true if we exited because of timeout
diff --git a/camera/OMXCameraAdapter/OMXExif.cpp b/camera/OMXCameraAdapter/OMXExif.cpp
old mode 100755
new mode 100644
index 9744cf4..32bfd7d
--- a/camera/OMXCameraAdapter/OMXExif.cpp
+++ b/camera/OMXCameraAdapter/OMXExif.cpp
@@ -497,7 +497,9 @@
     return ret;
 }
 
-status_t OMXCameraAdapter::setupEXIF_libjpeg(ExifElementsTable* exifTable)
+status_t OMXCameraAdapter::setupEXIF_libjpeg(ExifElementsTable* exifTable,
+                                             OMX_TI_ANCILLARYDATATYPE* pAncillaryData,
+                                             OMX_TI_WHITEBALANCERESULTTYPE* pWhiteBalanceData)
 {
     status_t ret = NO_ERROR;
     OMX_ERRORTYPE eError = OMX_ErrorNone;
@@ -544,7 +546,6 @@
                      pTime->tm_hour,
                      pTime->tm_min,
                      pTime->tm_sec );
-
             ret = exifTable->insertElement(TAG_DATETIME, temp_value);
         }
      }
@@ -658,6 +659,129 @@
         }
     }
 
+    // fill in short and ushort tags
+    if (NO_ERROR == ret) {
+        char temp_value[2];
+        temp_value[1] = '\0';
+
+        // AWB
+        if (mParameters3A.WhiteBallance == OMX_WhiteBalControlAuto) {
+            temp_value[0] = '0';
+        } else {
+            temp_value[0] = '1';
+        }
+        exifTable->insertElement(TAG_WHITEBALANCE, temp_value);
+
+        // MeteringMode
+        // TODO(XXX): only supporting this metering mode at the moment, may change in future
+        temp_value[0] = '2';
+        exifTable->insertElement(TAG_METERING_MODE, temp_value);
+
+        // ExposureProgram
+        // TODO(XXX): only supporting this exposure program at the moment, may change in future
+        temp_value[0] = '3';
+        exifTable->insertElement(TAG_EXPOSURE_PROGRAM, temp_value);
+
+        // ColorSpace
+        temp_value[0] = '1';
+        exifTable->insertElement(TAG_COLOR_SPACE, temp_value);
+
+        temp_value[0] = '2';
+        exifTable->insertElement(TAG_SENSING_METHOD, temp_value);
+
+        temp_value[0] = '1';
+        exifTable->insertElement(TAG_CUSTOM_RENDERED, temp_value);
+    }
+
+    if (pAncillaryData && (NO_ERROR == ret)) {
+        unsigned int numerator = 0, denominator = 0;
+        char temp_value[256];
+        unsigned int temp_num = 0;
+
+        // DigitalZoomRatio
+        snprintf(temp_value,
+                 sizeof(temp_value)/sizeof(char),
+                 "%u/%u",
+                 pAncillaryData->nDigitalZoomFactor, 1024);
+        exifTable->insertElement(TAG_DIGITALZOOMRATIO, temp_value);
+
+        // ExposureTime
+        snprintf(temp_value,
+                 sizeof(temp_value)/sizeof(char),
+                 "%u/%u",
+                 pAncillaryData->nExposureTime, 1000000);
+        exifTable->insertElement(TAG_EXPOSURETIME, temp_value);
+
+        // ApertureValue and FNumber
+        snprintf(temp_value,
+                 sizeof(temp_value)/sizeof(char),
+                 "%u/%u",
+                 pAncillaryData->nApertureValue, 100);
+        exifTable->insertElement(TAG_FNUMBER, temp_value);
+        exifTable->insertElement(TAG_APERTURE, temp_value);
+
+        // ISO
+        snprintf(temp_value,
+                 sizeof(temp_value)/sizeof(char),
+                 "%u,0,0",
+                 pAncillaryData->nCurrentISO);
+        exifTable->insertElement(TAG_ISO_EQUIVALENT, temp_value);
+
+        // ShutterSpeed
+        snprintf(temp_value,
+                 sizeof(temp_value)/sizeof(char),
+                 "%f",
+                 log(pAncillaryData->nExposureTime) / log(2));
+        ExifElementsTable::stringToRational(temp_value, &numerator, &denominator);
+        snprintf(temp_value, sizeof(temp_value)/sizeof(char), "%u/%u", numerator, denominator);
+        exifTable->insertElement(TAG_SHUTTERSPEED, temp_value);
+
+        // Flash
+        if (mParameters3A.FlashMode == OMX_IMAGE_FlashControlAuto) {
+            if(pAncillaryData->nFlashStatus) temp_num = 0x19; // Flash fired, auto mode
+            else temp_num = 0x18; // Flash did not fire, auto mode
+        } else if (mParameters3A.FlashMode == OMX_IMAGE_FlashControlOn) {
+            if(pAncillaryData->nFlashStatus) temp_num = 0x9; // Flash fired, compulsory flash mode
+            else temp_num = 0x10; // Flash did not fire, compulsory flash mode
+        } else if(pAncillaryData->nFlashStatus) {
+            temp_num = 0x1; // Flash fired
+        } else {
+            temp_num = 0x0; // Flash did not fire
+        }
+        snprintf(temp_value,
+                 sizeof(temp_value)/sizeof(char),
+                 "%u", temp_num);
+        exifTable->insertElement(TAG_FLASH, temp_value);
+
+        if (pWhiteBalanceData) {
+            unsigned int lightsource = 0;
+            unsigned int colourtemp = pWhiteBalanceData->nColorTemperature;
+            bool flash_fired = (temp_num & 0x1); // value from flash above
+
+            // stole this from framework/tools_library/src/tools_sys_exif_tags.c
+            if( colourtemp <= 3200 ) {
+                lightsource = 3; // Tungsten
+            } else if( colourtemp > 3200 && colourtemp <= 4800 ) {
+                lightsource = 2; // Fluorescent
+            } else if( colourtemp > 4800 && colourtemp <= 5500 ) {
+                lightsource = 1; // Daylight
+            } else if( colourtemp > 5500 && colourtemp <= 6500 ) {
+                lightsource = 9; // Fine weather
+            } else if( colourtemp > 6500 ) {
+                lightsource = 10; // Cloudy weather
+            }
+
+            if(flash_fired) {
+                lightsource = 4; // Flash
+            }
+
+            snprintf(temp_value,
+                    sizeof(temp_value)/sizeof(char),
+                    "%u", lightsource);
+            exifTable->insertElement(TAG_LIGHT_SOURCE, temp_value);
+        }
+    }
+
     LOG_FUNCTION_NAME_EXIT;
 
     return ret;
diff --git a/camera/OMXCameraAdapter/OMXFD.cpp b/camera/OMXCameraAdapter/OMXFD.cpp
index 38c7a6e..dbebe79 100644
--- a/camera/OMXCameraAdapter/OMXFD.cpp
+++ b/camera/OMXCameraAdapter/OMXFD.cpp
@@ -125,7 +125,6 @@
 {
     status_t ret = NO_ERROR;
     OMX_ERRORTYPE eError = OMX_ErrorNone;
-    OMX_CONFIG_EXTRADATATYPE extraDataControl;
     OMX_CONFIG_OBJDETECTIONTYPE objDetection;
 
     LOG_FUNCTION_NAME;
@@ -170,27 +169,11 @@
 
     if ( NO_ERROR == ret )
         {
-        OMX_INIT_STRUCT_PTR (&extraDataControl, OMX_CONFIG_EXTRADATATYPE);
-        extraDataControl.nPortIndex = mCameraAdapterParameters.mPrevPortIndex;
-        extraDataControl.eExtraDataType = OMX_FaceDetection;
-        extraDataControl.eCameraView = OMX_2D;
-        if  ( enable )
-            {
-            extraDataControl.bEnable = OMX_TRUE;
-            }
-        else
-            {
-            extraDataControl.bEnable = OMX_FALSE;
-            }
+        ret = setExtraData(enable, mCameraAdapterParameters.mPrevPortIndex, OMX_FaceDetection);
 
-        eError =  OMX_SetConfig(mCameraAdapterParameters.mHandleComp,
-                                ( OMX_INDEXTYPE ) OMX_IndexConfigOtherExtraDataControl,
-                                &extraDataControl);
-        if ( OMX_ErrorNone != eError )
+        if ( NO_ERROR != ret )
             {
-            CAMHAL_LOGEB("Error while configuring face detection extra data 0x%x",
-                         eError);
-            ret = -1;
+            CAMHAL_LOGEA("Error while configuring face detection extra data");
             }
         else
             {
@@ -248,7 +231,7 @@
             CAMHAL_LOGEB("OMX_TI_PLATFORMPRIVATE size mismatch: expected = %d, received = %d",
                          ( unsigned int ) sizeof(OMX_TI_PLATFORMPRIVATE),
                          ( unsigned int ) platformPrivate->nSize);
-            ret = -EINVAL;
+            return -EINVAL;
         }
     }  else {
         CAMHAL_LOGEA("Invalid OMX_TI_PLATFORMPRIVATE");
diff --git a/camera/inc/ANativeWindowDisplayAdapter.h b/camera/inc/ANativeWindowDisplayAdapter.h
index e4698d0..acab47c 100644
--- a/camera/inc/ANativeWindowDisplayAdapter.h
+++ b/camera/inc/ANativeWindowDisplayAdapter.h
@@ -1,189 +1,189 @@
-/*

- * Copyright (C) Texas Instruments - http://www.ti.com/

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-

-

-#include "CameraHal.h"

-#include <ui/egl/android_natives.h>

-#include <ui/GraphicBufferMapper.h>

-#include <hal_public.h>

-

-//temporarily define format here

-#define HAL_PIXEL_FORMAT_TI_NV12 0x100

-

-namespace android {

-

-/**

- * Display handler class - This class basically handles the buffer posting to display

- */

-

-class ANativeWindowDisplayAdapter : public DisplayAdapter

-{

-public:

-

-    typedef struct

-        {

-        void *mBuffer;

-        void *mUser;

-        int mOffset;

-        int mWidth;

-        int mHeight;

-        int mWidthStride;

-        int mHeightStride;

-        int mLength;

-        CameraFrame::FrameType mType;

-        } DisplayFrame;

-

-    enum DisplayStates

-        {

-        DISPLAY_INIT = 0,

-        DISPLAY_STARTED,

-        DISPLAY_STOPPED,

-        DISPLAY_EXITED

-        };

-

-public:

-

-    ANativeWindowDisplayAdapter();

-    virtual ~ANativeWindowDisplayAdapter();

-

-    ///Initializes the display adapter creates any resources required

-    virtual status_t initialize();

-

-    virtual int setPreviewWindow(struct preview_stream_ops *window);

-    virtual int setFrameProvider(FrameNotifier *frameProvider);

-    virtual int setErrorHandler(ErrorNotifier *errorNotifier);

-    virtual int enableDisplay(int width, int height, struct timeval *refTime = NULL, S3DParameters *s3dParams = NULL);

-    virtual int disableDisplay(bool cancel_buffer = true);

-    virtual status_t pauseDisplay(bool pause);

-

-#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS

-

-    //Used for shot to snapshot measurement

-    virtual status_t setSnapshotTimeRef(struct timeval *refTime = NULL);

-

-#endif

-

-    virtual int useBuffers(void* bufArr, int num);

-    virtual bool supportsExternalBuffering();

-

-    //Implementation of inherited interfaces

-    virtual void* allocateBuffer(int width, int height, const char* format, int &bytes, int numBufs);

-    virtual uint32_t * getOffsets() ;

-    virtual int getFd() ;

-    virtual int freeBuffer(void* buf);

-

-    virtual int maxQueueableBuffers(unsigned int& queueable);

-

-    ///Class specific functions

-    static void frameCallbackRelay(CameraFrame* caFrame);

-    void frameCallback(CameraFrame* caFrame);

-

-    void displayThread();

-

-    private:

-    void destroy();

-    bool processHalMsg();

-    status_t PostFrame(ANativeWindowDisplayAdapter::DisplayFrame &dispFrame);

-    bool handleFrameReturn();

-    status_t returnBuffersToWindow();

-

-public:

-

-    static const int DISPLAY_TIMEOUT;

-    static const int FAILED_DQS_TO_SUSPEND;

-

-    class DisplayThread : public Thread

-        {

-        ANativeWindowDisplayAdapter* mDisplayAdapter;

-        TIUTILS::MessageQueue mDisplayThreadQ;

-

-        public:

-            DisplayThread(ANativeWindowDisplayAdapter* da)

-            : Thread(false), mDisplayAdapter(da) { }

-

-        ///Returns a reference to the display message Q for display adapter to post messages

-            TIUTILS::MessageQueue& msgQ()

-                {

-                return mDisplayThreadQ;

-                }

-

-            virtual bool threadLoop()

-                {

-                mDisplayAdapter->displayThread();

-                return false;

-                }

-

-            enum DisplayThreadCommands

-                {

-                DISPLAY_START,

-                DISPLAY_STOP,

-                DISPLAY_FRAME,

-                DISPLAY_EXIT

-                };

-        };

-

-    //friend declarations

-friend class DisplayThread;

-

-private:

-    int postBuffer(void* displayBuf);

-

-private:

-    bool mFirstInit;

-    bool mSuspend;

-    int mFailedDQs;

-    bool mPaused; //Pause state

-    preview_stream_ops_t*  mANativeWindow;

-    sp<DisplayThread> mDisplayThread;

-    FrameProvider *mFrameProvider; ///Pointer to the frame provider interface

-    TIUTILS::MessageQueue mDisplayQ;

-    unsigned int mDisplayState;

-    ///@todo Have a common class for these members

-    mutable Mutex mLock;

-    bool mDisplayEnabled;

-    int mBufferCount;

-    buffer_handle_t** mBufferHandleMap;

-    IMG_native_handle_t** mGrallocHandleMap;

-    uint32_t* mOffsetsMap;

-    int mFD;

-    KeyedVector<int, int> mFramesWithCameraAdapterMap;

-    sp<ErrorNotifier> mErrorNotifier;

-

-    uint32_t mFrameWidth;

-    uint32_t mFrameHeight;

-    uint32_t mPreviewWidth;

-    uint32_t mPreviewHeight;

-

-    uint32_t mXOff;

-    uint32_t mYOff;

-

-    const char *mPixelFormat;

-

-#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS

-    //Used for calculating standby to first shot

-    struct timeval mStandbyToShot;

-    bool mMeasureStandby;

-    //Used for shot to snapshot/shot calculation

-    struct timeval mStartCapture;

-    bool mShotToShot;

-

-#endif

-

-};

-

-};

-

+/*
+ * Copyright (C) Texas Instruments - http://www.ti.com/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include "CameraHal.h"
+#include <ui/egl/android_natives.h>
+#include <ui/GraphicBufferMapper.h>
+#include <hal_public.h>
+
+//temporarily define format here
+#define HAL_PIXEL_FORMAT_TI_NV12 0x100
+
+namespace android {
+
+/**
+ * Display handler class - This class basically handles the buffer posting to display
+ */
+
+class ANativeWindowDisplayAdapter : public DisplayAdapter
+{
+public:
+
+    typedef struct
+        {
+        void *mBuffer;
+        void *mUser;
+        int mOffset;
+        int mWidth;
+        int mHeight;
+        int mWidthStride;
+        int mHeightStride;
+        int mLength;
+        CameraFrame::FrameType mType;
+        } DisplayFrame;
+
+    enum DisplayStates
+        {
+        DISPLAY_INIT = 0,
+        DISPLAY_STARTED,
+        DISPLAY_STOPPED,
+        DISPLAY_EXITED
+        };
+
+public:
+
+    ANativeWindowDisplayAdapter();
+    virtual ~ANativeWindowDisplayAdapter();
+
+    ///Initializes the display adapter creates any resources required
+    virtual status_t initialize();
+
+    virtual int setPreviewWindow(struct preview_stream_ops *window);
+    virtual int setFrameProvider(FrameNotifier *frameProvider);
+    virtual int setErrorHandler(ErrorNotifier *errorNotifier);
+    virtual int enableDisplay(int width, int height, struct timeval *refTime = NULL, S3DParameters *s3dParams = NULL);
+    virtual int disableDisplay(bool cancel_buffer = true);
+    virtual status_t pauseDisplay(bool pause);
+
+#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS
+
+    //Used for shot to snapshot measurement
+    virtual status_t setSnapshotTimeRef(struct timeval *refTime = NULL);
+
+#endif
+
+    virtual int useBuffers(void* bufArr, int num);
+    virtual bool supportsExternalBuffering();
+
+    //Implementation of inherited interfaces
+    virtual void* allocateBuffer(int width, int height, const char* format, int &bytes, int numBufs);
+    virtual uint32_t * getOffsets() ;
+    virtual int getFd() ;
+    virtual int freeBuffer(void* buf);
+
+    virtual int maxQueueableBuffers(unsigned int& queueable);
+
+    ///Class specific functions
+    static void frameCallbackRelay(CameraFrame* caFrame);
+    void frameCallback(CameraFrame* caFrame);
+
+    void displayThread();
+
+    private:
+    void destroy();
+    bool processHalMsg();
+    status_t PostFrame(ANativeWindowDisplayAdapter::DisplayFrame &dispFrame);
+    bool handleFrameReturn();
+    status_t returnBuffersToWindow();
+
+public:
+
+    static const int DISPLAY_TIMEOUT;
+    static const int FAILED_DQS_TO_SUSPEND;
+
+    class DisplayThread : public Thread
+        {
+        ANativeWindowDisplayAdapter* mDisplayAdapter;
+        TIUTILS::MessageQueue mDisplayThreadQ;
+
+        public:
+            DisplayThread(ANativeWindowDisplayAdapter* da)
+            : Thread(false), mDisplayAdapter(da) { }
+
+        ///Returns a reference to the display message Q for display adapter to post messages
+            TIUTILS::MessageQueue& msgQ()
+                {
+                return mDisplayThreadQ;
+                }
+
+            virtual bool threadLoop()
+                {
+                mDisplayAdapter->displayThread();
+                return false;
+                }
+
+            enum DisplayThreadCommands
+                {
+                DISPLAY_START,
+                DISPLAY_STOP,
+                DISPLAY_FRAME,
+                DISPLAY_EXIT
+                };
+        };
+
+    //friend declarations
+friend class DisplayThread;
+
+private:
+    int postBuffer(void* displayBuf);
+
+private:
+    bool mFirstInit;
+    bool mSuspend;
+    int mFailedDQs;
+    bool mPaused; //Pause state
+    preview_stream_ops_t*  mANativeWindow;
+    sp<DisplayThread> mDisplayThread;
+    FrameProvider *mFrameProvider; ///Pointer to the frame provider interface
+    TIUTILS::MessageQueue mDisplayQ;
+    unsigned int mDisplayState;
+    ///@todo Have a common class for these members
+    mutable Mutex mLock;
+    bool mDisplayEnabled;
+    int mBufferCount;
+    buffer_handle_t** mBufferHandleMap;
+    IMG_native_handle_t** mGrallocHandleMap;
+    uint32_t* mOffsetsMap;
+    int mFD;
+    KeyedVector<int, int> mFramesWithCameraAdapterMap;
+    sp<ErrorNotifier> mErrorNotifier;
+
+    uint32_t mFrameWidth;
+    uint32_t mFrameHeight;
+    uint32_t mPreviewWidth;
+    uint32_t mPreviewHeight;
+
+    uint32_t mXOff;
+    uint32_t mYOff;
+
+    const char *mPixelFormat;
+
+#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS
+    //Used for calculating standby to first shot
+    struct timeval mStandbyToShot;
+    bool mMeasureStandby;
+    //Used for shot to snapshot/shot calculation
+    struct timeval mStartCapture;
+    bool mShotToShot;
+
+#endif
+
+};
+
+};
+
diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h
index e34f4df..6c3da0a 100644
--- a/camera/inc/CameraHal.h
+++ b/camera/inc/CameraHal.h
@@ -678,7 +678,7 @@
 class MemoryManager : public BufferProvider, public virtual RefBase
 {
 public:
-    MemoryManager():mIonFd(0){ }
+    MemoryManager():mIonFd(-1){ }
 
     ///Initializes the memory manager creates any resources required
     status_t initialize() { return NO_ERROR; }
diff --git a/camera/inc/CameraProperties.h b/camera/inc/CameraProperties.h
index a220af7..6f05877 100644
--- a/camera/inc/CameraProperties.h
+++ b/camera/inc/CameraProperties.h
@@ -1,198 +1,198 @@
-/*

- * Copyright (C) Texas Instruments - http://www.ti.com/

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-

-

-

-#ifndef CAMERA_PROPERTIES_H

-#define CAMERA_PROPERTIES_H

-

-#include <utils/KeyedVector.h>

-#include <utils/String8.h>

-#include <stdio.h>

-#include <dirent.h>

-#include <errno.h>

-#include <stdio.h>

-#include <string.h>

-#include <ctype.h>

-#include "cutils/properties.h"

-

-namespace android {

-

-#define MAX_CAMERAS_SUPPORTED 2

-#define MAX_SIMUL_CAMERAS_SUPPORTED 1

-#define MAX_PROP_NAME_LENGTH 50

-#define MAX_PROP_VALUE_LENGTH 2048

-

-#define EXIF_MAKE_DEFAULT "default_make"

-#define EXIF_MODEL_DEFAULT "default_model"

-

-// Class that handles the Camera Properties

-class CameraProperties

-{

-public:

-    static const char INVALID[];

-    static const char CAMERA_NAME[];

-    static const char CAMERA_SENSOR_INDEX[];

-    static const char ORIENTATION_INDEX[];

-    static const char FACING_INDEX[];

-    static const char S3D_SUPPORTED[];

-    static const char SUPPORTED_PREVIEW_SIZES[];

-    static const char SUPPORTED_PREVIEW_FORMATS[];

-    static const char SUPPORTED_PREVIEW_FRAME_RATES[];

-    static const char SUPPORTED_PICTURE_SIZES[];

-    static const char SUPPORTED_PICTURE_FORMATS[];

-    static const char SUPPORTED_THUMBNAIL_SIZES[];

-    static const char SUPPORTED_WHITE_BALANCE[];

-    static const char SUPPORTED_EFFECTS[];

-    static const char SUPPORTED_ANTIBANDING[];

-    static const char SUPPORTED_EXPOSURE_MODES[];

-    static const char SUPPORTED_EV_MIN[];

-    static const char SUPPORTED_EV_MAX[];

-    static const char SUPPORTED_EV_STEP[];

-    static const char SUPPORTED_ISO_VALUES[];

-    static const char SUPPORTED_SCENE_MODES[];

-    static const char SUPPORTED_FLASH_MODES[];

-    static const char SUPPORTED_FOCUS_MODES[];

-    static const char REQUIRED_PREVIEW_BUFS[];

-    static const char REQUIRED_IMAGE_BUFS[];

-    static const char SUPPORTED_ZOOM_RATIOS[];

-    static const char SUPPORTED_ZOOM_STAGES[];

-    static const char SUPPORTED_IPP_MODES[];

-    static const char SMOOTH_ZOOM_SUPPORTED[];

-    static const char ZOOM_SUPPORTED[];

-    static const char PREVIEW_SIZE[];

-    static const char PREVIEW_FORMAT[];

-    static const char PREVIEW_FRAME_RATE[];

-    static const char ZOOM[];

-    static const char PICTURE_SIZE[];

-    static const char PICTURE_FORMAT[];

-    static const char JPEG_THUMBNAIL_SIZE[];

-    static const char WHITEBALANCE[];

-    static const char EFFECT[];

-    static const char ANTIBANDING[];

-    static const char EXPOSURE_MODE[];

-    static const char EV_COMPENSATION[];

-    static const char ISO_MODE[];

-    static const char FOCUS_MODE[];

-    static const char SCENE_MODE[];

-    static const char FLASH_MODE[];

-    static const char JPEG_QUALITY[];

-    static const char BRIGHTNESS[];

-    static const char SATURATION[];

-    static const char SHARPNESS[];

-    static const char CONTRAST[];

-    static const char IPP[];

-    static const char GBCE[];

-    static const char AUTOCONVERGENCE[];

-    static const char AUTOCONVERGENCE_MODE[];

-    static const char MANUALCONVERGENCE_VALUES[];

-    static const char SENSOR_ORIENTATION[];

-    static const char SENSOR_ORIENTATION_VALUES[];

-    static const char REVISION[];

-    static const char FOCAL_LENGTH[];

-    static const char HOR_ANGLE[];

-    static const char VER_ANGLE[];

-    static const char EXIF_MAKE[];

-    static const char EXIF_MODEL[];

-    static const char JPEG_THUMBNAIL_QUALITY[];

-    static const char MAX_FOCUS_AREAS[];

-    static const char MAX_FD_HW_FACES[];

-    static const char MAX_FD_SW_FACES[];

-

-    static const char PARAMS_DELIMITER [];

-

-    static const char S3D2D_PREVIEW[];

-    static const char S3D2D_PREVIEW_MODES[];

-    static const char VSTAB[];

-    static const char VSTAB_SUPPORTED[];

-    static const char FRAMERATE_RANGE[];

-    static const char FRAMERATE_RANGE_IMAGE[];

-    static const char FRAMERATE_RANGE_VIDEO[];

-    static const char FRAMERATE_RANGE_SUPPORTED[];

-

-    static const char DEFAULT_VALUE[];

-

-    static const char AUTO_EXPOSURE_LOCK[];

-    static const char AUTO_EXPOSURE_LOCK_SUPPORTED[];

-    static const char AUTO_WHITEBALANCE_LOCK[];

-    static const char AUTO_WHITEBALANCE_LOCK_SUPPORTED[];

-    static const char MAX_NUM_METERING_AREAS[];

-    static const char METERING_AREAS[];

-    static const char MAX_NUM_FOCUS_AREAS[];

-

-    static const char VIDEO_SNAPSHOT_SUPPORTED[];

-

-    static const char VIDEO_SIZE[];

-    static const char SUPPORTED_VIDEO_SIZES[];

-    static const char PREFERRED_PREVIEW_SIZE_FOR_VIDEO[];

-

-    CameraProperties();

-    ~CameraProperties();

-

-    // container class passed around for accessing properties

-    class Properties

-    {

-        public:

-            Properties()

-            {

-                mProperties = new DefaultKeyedVector<String8, String8>(String8(DEFAULT_VALUE));

-                char property[PROPERTY_VALUE_MAX];

-                property_get("ro.product.manufacturer", property, EXIF_MAKE_DEFAULT);

-                property[0] = toupper(property[0]);

-                set(EXIF_MAKE, property);

-                property_get("ro.product.model", property, EXIF_MODEL_DEFAULT);

-                property[0] = toupper(property[0]);

-                set(EXIF_MODEL, property);

-            }

-            ~Properties()

-            {

-                delete mProperties;

-            }

-            ssize_t set(const char *prop, const char *value);

-            ssize_t set(const char *prop, int value);

-            const char* get(const char * prop);

-            void dump();

-

-        protected:

-            const char* keyAt(unsigned int);

-            const char* valueAt(unsigned int);

-

-        private:

-            DefaultKeyedVector<String8, String8>* mProperties;

-

-    };

-

-    ///Initializes the CameraProperties class

-    status_t initialize();

-    status_t loadProperties();

-    int camerasSupported();

-    int getProperties(int cameraIndex, Properties** properties);

-

-private:

-

-    uint32_t mCamerasSupported;

-    int mInitialized;

-    mutable Mutex mLock;

-

-    Properties mCameraProps[MAX_CAMERAS_SUPPORTED];

-

-};

-

-};

-

-#endif //CAMERA_PROPERTIES_H

-

+/*
+ * Copyright (C) Texas Instruments - http://www.ti.com/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+
+#ifndef CAMERA_PROPERTIES_H
+#define CAMERA_PROPERTIES_H
+
+#include <utils/KeyedVector.h>
+#include <utils/String8.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include "cutils/properties.h"
+
+namespace android {
+
+#define MAX_CAMERAS_SUPPORTED 2
+#define MAX_SIMUL_CAMERAS_SUPPORTED 1
+#define MAX_PROP_NAME_LENGTH 50
+#define MAX_PROP_VALUE_LENGTH 2048
+
+#define EXIF_MAKE_DEFAULT "default_make"
+#define EXIF_MODEL_DEFAULT "default_model"
+
+// Class that handles the Camera Properties
+class CameraProperties
+{
+public:
+    static const char INVALID[];
+    static const char CAMERA_NAME[];
+    static const char CAMERA_SENSOR_INDEX[];
+    static const char ORIENTATION_INDEX[];
+    static const char FACING_INDEX[];
+    static const char S3D_SUPPORTED[];
+    static const char SUPPORTED_PREVIEW_SIZES[];
+    static const char SUPPORTED_PREVIEW_FORMATS[];
+    static const char SUPPORTED_PREVIEW_FRAME_RATES[];
+    static const char SUPPORTED_PICTURE_SIZES[];
+    static const char SUPPORTED_PICTURE_FORMATS[];
+    static const char SUPPORTED_THUMBNAIL_SIZES[];
+    static const char SUPPORTED_WHITE_BALANCE[];
+    static const char SUPPORTED_EFFECTS[];
+    static const char SUPPORTED_ANTIBANDING[];
+    static const char SUPPORTED_EXPOSURE_MODES[];
+    static const char SUPPORTED_EV_MIN[];
+    static const char SUPPORTED_EV_MAX[];
+    static const char SUPPORTED_EV_STEP[];
+    static const char SUPPORTED_ISO_VALUES[];
+    static const char SUPPORTED_SCENE_MODES[];
+    static const char SUPPORTED_FLASH_MODES[];
+    static const char SUPPORTED_FOCUS_MODES[];
+    static const char REQUIRED_PREVIEW_BUFS[];
+    static const char REQUIRED_IMAGE_BUFS[];
+    static const char SUPPORTED_ZOOM_RATIOS[];
+    static const char SUPPORTED_ZOOM_STAGES[];
+    static const char SUPPORTED_IPP_MODES[];
+    static const char SMOOTH_ZOOM_SUPPORTED[];
+    static const char ZOOM_SUPPORTED[];
+    static const char PREVIEW_SIZE[];
+    static const char PREVIEW_FORMAT[];
+    static const char PREVIEW_FRAME_RATE[];
+    static const char ZOOM[];
+    static const char PICTURE_SIZE[];
+    static const char PICTURE_FORMAT[];
+    static const char JPEG_THUMBNAIL_SIZE[];
+    static const char WHITEBALANCE[];
+    static const char EFFECT[];
+    static const char ANTIBANDING[];
+    static const char EXPOSURE_MODE[];
+    static const char EV_COMPENSATION[];
+    static const char ISO_MODE[];
+    static const char FOCUS_MODE[];
+    static const char SCENE_MODE[];
+    static const char FLASH_MODE[];
+    static const char JPEG_QUALITY[];
+    static const char BRIGHTNESS[];
+    static const char SATURATION[];
+    static const char SHARPNESS[];
+    static const char CONTRAST[];
+    static const char IPP[];
+    static const char GBCE[];
+    static const char AUTOCONVERGENCE[];
+    static const char AUTOCONVERGENCE_MODE[];
+    static const char MANUALCONVERGENCE_VALUES[];
+    static const char SENSOR_ORIENTATION[];
+    static const char SENSOR_ORIENTATION_VALUES[];
+    static const char REVISION[];
+    static const char FOCAL_LENGTH[];
+    static const char HOR_ANGLE[];
+    static const char VER_ANGLE[];
+    static const char EXIF_MAKE[];
+    static const char EXIF_MODEL[];
+    static const char JPEG_THUMBNAIL_QUALITY[];
+    static const char MAX_FOCUS_AREAS[];
+    static const char MAX_FD_HW_FACES[];
+    static const char MAX_FD_SW_FACES[];
+
+    static const char PARAMS_DELIMITER [];
+
+    static const char S3D2D_PREVIEW[];
+    static const char S3D2D_PREVIEW_MODES[];
+    static const char VSTAB[];
+    static const char VSTAB_SUPPORTED[];
+    static const char FRAMERATE_RANGE[];
+    static const char FRAMERATE_RANGE_IMAGE[];
+    static const char FRAMERATE_RANGE_VIDEO[];
+    static const char FRAMERATE_RANGE_SUPPORTED[];
+
+    static const char DEFAULT_VALUE[];
+
+    static const char AUTO_EXPOSURE_LOCK[];
+    static const char AUTO_EXPOSURE_LOCK_SUPPORTED[];
+    static const char AUTO_WHITEBALANCE_LOCK[];
+    static const char AUTO_WHITEBALANCE_LOCK_SUPPORTED[];
+    static const char MAX_NUM_METERING_AREAS[];
+    static const char METERING_AREAS[];
+    static const char MAX_NUM_FOCUS_AREAS[];
+
+    static const char VIDEO_SNAPSHOT_SUPPORTED[];
+
+    static const char VIDEO_SIZE[];
+    static const char SUPPORTED_VIDEO_SIZES[];
+    static const char PREFERRED_PREVIEW_SIZE_FOR_VIDEO[];
+
+    CameraProperties();
+    ~CameraProperties();
+
+    // container class passed around for accessing properties
+    class Properties
+    {
+        public:
+            Properties()
+            {
+                mProperties = new DefaultKeyedVector<String8, String8>(String8(DEFAULT_VALUE));
+                char property[PROPERTY_VALUE_MAX];
+                property_get("ro.product.manufacturer", property, EXIF_MAKE_DEFAULT);
+                property[0] = toupper(property[0]);
+                set(EXIF_MAKE, property);
+                property_get("ro.product.model", property, EXIF_MODEL_DEFAULT);
+                property[0] = toupper(property[0]);
+                set(EXIF_MODEL, property);
+            }
+            ~Properties()
+            {
+                delete mProperties;
+            }
+            ssize_t set(const char *prop, const char *value);
+            ssize_t set(const char *prop, int value);
+            const char* get(const char * prop);
+            void dump();
+
+        protected:
+            const char* keyAt(unsigned int);
+            const char* valueAt(unsigned int);
+
+        private:
+            DefaultKeyedVector<String8, String8>* mProperties;
+
+    };
+
+    ///Initializes the CameraProperties class
+    status_t initialize();
+    status_t loadProperties();
+    int camerasSupported();
+    int getProperties(int cameraIndex, Properties** properties);
+
+private:
+
+    uint32_t mCamerasSupported;
+    int mInitialized;
+    mutable Mutex mLock;
+
+    Properties mCameraProps[MAX_CAMERAS_SUPPORTED];
+
+};
+
+};
+
+#endif //CAMERA_PROPERTIES_H
+
diff --git a/camera/inc/Encoder_libjpeg.h b/camera/inc/Encoder_libjpeg.h
old mode 100755
new mode 100644
index fef873f..26136fa
--- a/camera/inc/Encoder_libjpeg.h
+++ b/camera/inc/Encoder_libjpeg.h
@@ -30,6 +30,9 @@
 extern "C" {
 #include "jhead.h"
 }
+
+#define CANCEL_TIMEOUT 3000000 // 3 seconds
+
 namespace android {
 /**
  * libjpeg encoder class - uses libjpeg to encode yuv
@@ -41,8 +44,10 @@
                                             CameraFrame::FrameType type,
                                             void* cookie1,
                                             void* cookie2,
-                                            void* cookie3);
+                                            void* cookie3,
+                                            bool canceled);
 
+// these have to match strings defined in external/jhead/exif.c
 static const char TAG_MODEL[] = "Model";
 static const char TAG_MAKE[] = "Make";
 static const char TAG_FOCALLENGTH[] = "FocalLength";
@@ -61,6 +66,21 @@
 static const char TAG_GPS_TIMESTAMP[] = "GPSTimeStamp";
 static const char TAG_GPS_DATESTAMP[] = "GPSDateStamp";
 static const char TAG_ORIENTATION[] = "Orientation";
+static const char TAG_FLASH[] = "Flash";
+static const char TAG_DIGITALZOOMRATIO[] = "DigitalZoomRatio";
+static const char TAG_EXPOSURETIME[] = "ExposureTime";
+static const char TAG_APERTURE[] = "ApertureValue";
+static const char TAG_ISO_EQUIVALENT[] = "ISOSpeedRatings";
+static const char TAG_WHITEBALANCE[] = "WhiteBalance";
+static const char TAG_LIGHT_SOURCE[] = "LightSource";
+static const char TAG_METERING_MODE[] = "MeteringMode";
+static const char TAG_EXPOSURE_PROGRAM[] = "ExposureProgram";
+static const char TAG_COLOR_SPACE[] = "ColorSpace";
+static const char TAG_CPRS_BITS_PER_PIXEL[] = "CompressedBitsPerPixel";
+static const char TAG_FNUMBER[] = "FNumber";
+static const char TAG_SHUTTERSPEED[] = "ShutterSpeedValue";
+static const char TAG_SENSING_METHOD[] = "SensingMethod";
+static const char TAG_CUSTOM_RENDERED[] = "CustomRendered";
 
 class ExifElementsTable {
     public:
@@ -115,6 +135,7 @@
               mCancelEncoding(false), mCookie1(cookie1), mCookie2(cookie2), mCookie3(cookie3),
               mType(type), mThumb(NULL) {
             this->incStrong(this);
+            mCancelSem.Create(0);
         }
 
         ~Encoder_libjpeg() {
@@ -133,6 +154,9 @@
             // encode our main image
             size = encode(mMainInput);
 
+            // signal cancel semaphore incase somebody is waiting
+            mCancelSem.Signal();
+
             // check if it is main jpeg thread
             if(mThumb.get()) {
                 // wait until tn jpeg thread exits.
@@ -142,7 +166,7 @@
             }
 
             if(mCb) {
-                mCb(mMainInput, mThumbnailInput, mType, mCookie1, mCookie2, mCookie3);
+                mCb(mMainInput, mThumbnailInput, mType, mCookie1, mCookie2, mCookie3, mCancelEncoding);
             }
 
             // encoder thread runs, self-destructs, and then exits
@@ -151,10 +175,17 @@
         }
 
         void cancel() {
+           mCancelEncoding = true;
            if (mThumb.get()) {
                mThumb->cancel();
+               mCancelSem.WaitTimeout(CANCEL_TIMEOUT);
            }
-           mCancelEncoding = true;
+        }
+
+        void getCookies(void **cookie1, void **cookie2, void **cookie3) {
+            if (cookie1) *cookie1 = mCookie1;
+            if (cookie2) *cookie2 = mCookie2;
+            if (cookie3) *cookie3 = mCookie3;
         }
 
     private:
@@ -167,6 +198,7 @@
         void* mCookie3;
         CameraFrame::FrameType mType;
         sp<Encoder_libjpeg> mThumb;
+        Semaphore mCancelSem;
 
         size_t encode(params*);
 };
diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
index 463032a..4786f82 100644
--- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
+++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
@@ -446,7 +446,8 @@
                                BaseCameraAdapter::AdapterState state);
     status_t convertGPSCoord(double coord, int &deg, int &min, int &sec, int &secDivisor);
     status_t setupEXIF();
-    status_t setupEXIF_libjpeg(ExifElementsTable*);
+    status_t setupEXIF_libjpeg(ExifElementsTable*, OMX_TI_ANCILLARYDATATYPE*,
+                               OMX_TI_WHITEBALANCERESULTTYPE*);
 
     //Focus functionality
     status_t doAutoFocus();
@@ -640,6 +641,7 @@
     status_t setAutoConvergence(OMX_TI_AUTOCONVERGENCEMODETYPE pACMode, OMX_S32 pManualConverence);
     status_t getAutoConvergence(OMX_TI_AUTOCONVERGENCEMODETYPE *pACMode, OMX_S32 *pManualConverence);
 
+    status_t setExtraData(bool enable, OMX_U32, OMX_EXT_EXTRADATATYPE);
     OMX_OTHER_EXTRADATATYPE *getExtradata(OMX_OTHER_EXTRADATATYPE *extraData, OMX_EXTRADATATYPE type);
 
     class CommandHandler : public Thread {
@@ -873,6 +875,8 @@
     int mSnapshotCount;
     bool mCaptureConfigured;
     unsigned int mPendingCaptureSettings;
+    OMX_TI_ANCILLARYDATATYPE* mCaptureAncillaryData;
+    OMX_TI_WHITEBALANCERESULTTYPE* mWhiteBalanceData;
 
     //Temporal bracketing management data
     mutable Mutex mBracketingLock;
@@ -883,6 +887,7 @@
     int mBracketingRange;
 
     CameraParameters mParameters;
+    bool mOmxInitialized;
     OMXCameraAdapterComponentContext mCameraAdapterParameters;
     bool mFirstTimeInit;
 
diff --git a/camera/inc/TICameraParameters.h b/camera/inc/TICameraParameters.h
index 633e5b6..4701cae 100644
--- a/camera/inc/TICameraParameters.h
+++ b/camera/inc/TICameraParameters.h
@@ -1,242 +1,242 @@
-/*

- * Copyright (C) Texas Instruments - http://www.ti.com/

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-

-

-

-#ifndef TI_CAMERA_PARAMETERS_H

-#define TI_CAMERA_PARAMETERS_H

-

-#include <utils/KeyedVector.h>

-#include <utils/String8.h>

-

-namespace android {

-

-///TI Specific Camera Parameters

-class TICameraParameters

-{

-public:

-

-// Supported Camera indexes

-// Example value: "0,1,2,3", where 0-primary, 1-secondary1, 2-secondary2, 3-sterocamera

-static const  char KEY_SUPPORTED_CAMERAS[];

-// Select logical Camera index

-static const char KEY_CAMERA[];

-static const char KEY_CAMERA_NAME[];

-static const  char KEY_S3D_SUPPORTED[];

-static const char  KEY_BURST[];

-static const  char KEY_CAP_MODE[];

-static const  char KEY_VNF[];

-static const  char KEY_SATURATION[];

-static const  char KEY_BRIGHTNESS[];

-static const  char KEY_EXPOSURE_MODE[];

-static const  char KEY_SUPPORTED_EXPOSURE[];

-static const  char KEY_CONTRAST[];

-static const  char KEY_SHARPNESS[];

-static const  char KEY_ISO[];

-static const  char KEY_SUPPORTED_ISO_VALUES[];

-static const  char KEY_SUPPORTED_IPP[];

-static const  char KEY_IPP[];

-static const  char KEY_MAN_EXPOSURE[];

-static const  char KEY_METERING_MODE[];

-static const  char KEY_PADDED_WIDTH[];

-static const  char KEY_PADDED_HEIGHT[];

-static const char  KEY_EXP_BRACKETING_RANGE[];

-static const char  KEY_TEMP_BRACKETING[];

-static const char  KEY_TEMP_BRACKETING_RANGE_POS[];

-static const char  KEY_TEMP_BRACKETING_RANGE_NEG[];

-static const char  KEY_SHUTTER_ENABLE[];

-static const char  KEY_MEASUREMENT_ENABLE[];

-static const char  KEY_INITIAL_VALUES[];

-static const char  KEY_GBCE[];

-static const char  KEY_GLBCE[];

-static const char  KEY_MINFRAMERATE[];

-static const char  KEY_MAXFRAMERATE[];

-

-// TI recording hint to notify camera adapters of possible recording

-static const char  KEY_RECORDING_HINT[];

-static const char  KEY_AUTO_FOCUS_LOCK[];

-static const char  KEY_CURRENT_ISO[];

-

-static const char KEY_SENSOR_ORIENTATION[];

-static const char KEY_SENSOR_ORIENTATION_VALUES[];

-

-//TI extensions for zoom

-static const char ZOOM_SUPPORTED[];

-static const char ZOOM_UNSUPPORTED[];

-

-//TI extensions for camera capabilies

-static const char INITIAL_VALUES_TRUE[];

-static const char INITIAL_VALUES_FALSE[];

-

-//TI extensions for enabling/disabling measurements

-static const char MEASUREMENT_ENABLE[];

-static const char MEASUREMENT_DISABLE[];

-

-//  TI extensions to add values for ManualConvergence and AutoConvergence mode

-static const char KEY_AUTOCONVERGENCE[];

-static const char KEY_AUTOCONVERGENCE_MODE[];

-static const char KEY_MANUALCONVERGENCE_VALUES[];

-

-//TI extensions for enabling/disabling GLBCE

-static const char GLBCE_ENABLE[];

-static const char GLBCE_DISABLE[];

-

-//TI extensions for enabling/disabling GBCE

-static const char GBCE_ENABLE[];

-static const char GBCE_DISABLE[];

-

-// TI extensions to add Min frame rate Values

-static const char VIDEO_MINFRAMERATE_5[];

-static const char VIDEO_MINFRAMERATE_10[];

-static const char VIDEO_MINFRAMERATE_15[];

-static const char VIDEO_MINFRAMERATE_20[];

-static const char VIDEO_MINFRAMERATE_24[];

-static const char VIDEO_MINFRAMERATE_25[];

-static const char VIDEO_MINFRAMERATE_30[];

-static const char VIDEO_MINFRAMERATE_33[];

-

-//  TI extensions for Manual Gain and Manual Exposure

-static const char KEY_MANUAL_EXPOSURE_LEFT[];

-static const char KEY_MANUAL_EXPOSURE_RIGHT[];

-static const char KEY_MANUAL_EXPOSURE_MODES[];

-static const char KEY_MANUAL_GAIN_EV_RIGHT[];

-static const char KEY_MANUAL_GAIN_EV_LEFT[];

-static const char KEY_MANUAL_GAIN_ISO_RIGHT[];

-static const char KEY_MANUAL_GAIN_ISO_LEFT[];

-static const char KEY_MANUAL_GAIN_MODES[];

-

-//TI extensions for setting EXIF tags

-static const char KEY_EXIF_MODEL[];

-static const char KEY_EXIF_MAKE[];

-

-//TI extensions for additional GPS data

-static const char  KEY_GPS_MAPDATUM[];

-static const char  KEY_GPS_VERSION[];

-static const char  KEY_GPS_DATESTAMP[];

-

-//TI extensions for enabling/disabling shutter sound

-static const char SHUTTER_ENABLE[];

-static const char SHUTTER_DISABLE[];

-

-//TI extensions for Temporal bracketing

-static const char BRACKET_ENABLE[];

-static const char BRACKET_DISABLE[];

-

-//TI extensions to Image post-processing

-static const char IPP_LDCNSF[];

-static const char IPP_LDC[];

-static const char IPP_NSF[];

-static const char IPP_NONE[];

-

-//TI extensions to camera mode

-static const char HIGH_PERFORMANCE_MODE[];

-static const char HIGH_QUALITY_MODE[];

-static const char HIGH_QUALITY_ZSL_MODE[];

-static const char VIDEO_MODE[];

-

-

-// TI extensions to standard android pixel formats

-static const char PIXEL_FORMAT_RAW[];

-static const char PIXEL_FORMAT_JPS[];

-static const char PIXEL_FORMAT_MPO[];

-static const char PIXEL_FORMAT_RAW_JPEG[];

-static const char PIXEL_FORMAT_RAW_MPO[];

-

-// TI extensions to standard android scene mode settings

-static const  char SCENE_MODE_SPORT[];

-static const  char SCENE_MODE_CLOSEUP[];

-static const  char SCENE_MODE_AQUA[];

-static const  char SCENE_MODE_SNOWBEACH[];

-static const  char SCENE_MODE_MOOD[];

-static const  char SCENE_MODE_NIGHT_INDOOR[];

-static const  char SCENE_MODE_DOCUMENT[];

-static const  char SCENE_MODE_BARCODE[];

-static const  char SCENE_MODE_VIDEO_SUPER_NIGHT[];

-static const  char SCENE_MODE_VIDEO_CINE[];

-static const  char SCENE_MODE_VIDEO_OLD_FILM[];

-

-// TI extensions to standard android white balance settings.

-static const  char WHITE_BALANCE_TUNGSTEN[];

-static const  char WHITE_BALANCE_HORIZON[];

-static const  char WHITE_BALANCE_SUNSET[];

-static const  char WHITE_BALANCE_FACE[];

-

-// TI extensions to add exposure preset modes to android api

-static const  char EXPOSURE_MODE_OFF[];

-static const  char EXPOSURE_MODE_AUTO[];

-static const  char EXPOSURE_MODE_NIGHT[];

-static const  char EXPOSURE_MODE_BACKLIGHT[];

-static const  char EXPOSURE_MODE_SPOTLIGHT[];

-static const  char EXPOSURE_MODE_SPORTS[];

-static const  char EXPOSURE_MODE_SNOW[];

-static const  char EXPOSURE_MODE_BEACH[];

-static const  char EXPOSURE_MODE_APERTURE[];

-static const  char EXPOSURE_MODE_SMALL_APERTURE[];

-static const  char EXPOSURE_MODE_FACE[];

-

-// TI extensions to standard android focus presets.

-static const  char FOCUS_MODE_PORTRAIT[];

-static const  char FOCUS_MODE_EXTENDED[];

-static const char  FOCUS_MODE_FACE[];

-

-// TI extensions to add iso values

-static const char ISO_MODE_AUTO[];

-static const char ISO_MODE_100[];

-static const char ISO_MODE_200[];

-static const char ISO_MODE_400[];

-static const char ISO_MODE_800[];

-static const char ISO_MODE_1000[];

-static const char ISO_MODE_1200[];

-static const char ISO_MODE_1600[];

-

-//  TI extensions to add  values for effect settings.

-static const char EFFECT_NATURAL[];

-static const char EFFECT_VIVID[];

-static const char EFFECT_COLOR_SWAP[];

-static const char EFFECT_BLACKWHITE[];

-

-static const char KEY_S3D2D_PREVIEW[];

-static const char KEY_S3D2D_PREVIEW_MODE[];

-

-//  TI extensions to add values for AutoConvergence settings.

-static const char AUTOCONVERGENCE_MODE_DISABLE[];

-static const char AUTOCONVERGENCE_MODE_FRAME[];

-static const char AUTOCONVERGENCE_MODE_CENTER[];

-static const char AUTOCONVERGENCE_MODE_FFT[];

-static const char AUTOCONVERGENCE_MODE_MANUAL[];

-

-

-//TI extensions for flash mode settings

-static const char FLASH_MODE_FILL_IN[];

-

-//TI extensions to add sensor orientation parameters

-static const char ORIENTATION_SENSOR_NONE[];

-static const char ORIENTATION_SENSOR_90[];

-static const char ORIENTATION_SENSOR_180[];

-static const char ORIENTATION_SENSOR_270[];

-

-

-//TI values for camera direction

-static const char FACING_FRONT[];

-static const char FACING_BACK[];

-

-};

-

-};

-

-#endif

-

+/*
+ * Copyright (C) Texas Instruments - http://www.ti.com/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+
+#ifndef TI_CAMERA_PARAMETERS_H
+#define TI_CAMERA_PARAMETERS_H
+
+#include <utils/KeyedVector.h>
+#include <utils/String8.h>
+
+namespace android {
+
+///TI Specific Camera Parameters
+class TICameraParameters
+{
+public:
+
+// Supported Camera indexes
+// Example value: "0,1,2,3", where 0-primary, 1-secondary1, 2-secondary2, 3-sterocamera
+static const  char KEY_SUPPORTED_CAMERAS[];
+// Select logical Camera index
+static const char KEY_CAMERA[];
+static const char KEY_CAMERA_NAME[];
+static const  char KEY_S3D_SUPPORTED[];
+static const char  KEY_BURST[];
+static const  char KEY_CAP_MODE[];
+static const  char KEY_VNF[];
+static const  char KEY_SATURATION[];
+static const  char KEY_BRIGHTNESS[];
+static const  char KEY_EXPOSURE_MODE[];
+static const  char KEY_SUPPORTED_EXPOSURE[];
+static const  char KEY_CONTRAST[];
+static const  char KEY_SHARPNESS[];
+static const  char KEY_ISO[];
+static const  char KEY_SUPPORTED_ISO_VALUES[];
+static const  char KEY_SUPPORTED_IPP[];
+static const  char KEY_IPP[];
+static const  char KEY_MAN_EXPOSURE[];
+static const  char KEY_METERING_MODE[];
+static const  char KEY_PADDED_WIDTH[];
+static const  char KEY_PADDED_HEIGHT[];
+static const char  KEY_EXP_BRACKETING_RANGE[];
+static const char  KEY_TEMP_BRACKETING[];
+static const char  KEY_TEMP_BRACKETING_RANGE_POS[];
+static const char  KEY_TEMP_BRACKETING_RANGE_NEG[];
+static const char  KEY_SHUTTER_ENABLE[];
+static const char  KEY_MEASUREMENT_ENABLE[];
+static const char  KEY_INITIAL_VALUES[];
+static const char  KEY_GBCE[];
+static const char  KEY_GLBCE[];
+static const char  KEY_MINFRAMERATE[];
+static const char  KEY_MAXFRAMERATE[];
+
+// TI recording hint to notify camera adapters of possible recording
+static const char  KEY_RECORDING_HINT[];
+static const char  KEY_AUTO_FOCUS_LOCK[];
+static const char  KEY_CURRENT_ISO[];
+
+static const char KEY_SENSOR_ORIENTATION[];
+static const char KEY_SENSOR_ORIENTATION_VALUES[];
+
+//TI extensions for zoom
+static const char ZOOM_SUPPORTED[];
+static const char ZOOM_UNSUPPORTED[];
+
+//TI extensions for camera capabilies
+static const char INITIAL_VALUES_TRUE[];
+static const char INITIAL_VALUES_FALSE[];
+
+//TI extensions for enabling/disabling measurements
+static const char MEASUREMENT_ENABLE[];
+static const char MEASUREMENT_DISABLE[];
+
+//  TI extensions to add values for ManualConvergence and AutoConvergence mode
+static const char KEY_AUTOCONVERGENCE[];
+static const char KEY_AUTOCONVERGENCE_MODE[];
+static const char KEY_MANUALCONVERGENCE_VALUES[];
+
+//TI extensions for enabling/disabling GLBCE
+static const char GLBCE_ENABLE[];
+static const char GLBCE_DISABLE[];
+
+//TI extensions for enabling/disabling GBCE
+static const char GBCE_ENABLE[];
+static const char GBCE_DISABLE[];
+
+// TI extensions to add Min frame rate Values
+static const char VIDEO_MINFRAMERATE_5[];
+static const char VIDEO_MINFRAMERATE_10[];
+static const char VIDEO_MINFRAMERATE_15[];
+static const char VIDEO_MINFRAMERATE_20[];
+static const char VIDEO_MINFRAMERATE_24[];
+static const char VIDEO_MINFRAMERATE_25[];
+static const char VIDEO_MINFRAMERATE_30[];
+static const char VIDEO_MINFRAMERATE_33[];
+
+//  TI extensions for Manual Gain and Manual Exposure
+static const char KEY_MANUAL_EXPOSURE_LEFT[];
+static const char KEY_MANUAL_EXPOSURE_RIGHT[];
+static const char KEY_MANUAL_EXPOSURE_MODES[];
+static const char KEY_MANUAL_GAIN_EV_RIGHT[];
+static const char KEY_MANUAL_GAIN_EV_LEFT[];
+static const char KEY_MANUAL_GAIN_ISO_RIGHT[];
+static const char KEY_MANUAL_GAIN_ISO_LEFT[];
+static const char KEY_MANUAL_GAIN_MODES[];
+
+//TI extensions for setting EXIF tags
+static const char KEY_EXIF_MODEL[];
+static const char KEY_EXIF_MAKE[];
+
+//TI extensions for additional GPS data
+static const char  KEY_GPS_MAPDATUM[];
+static const char  KEY_GPS_VERSION[];
+static const char  KEY_GPS_DATESTAMP[];
+
+//TI extensions for enabling/disabling shutter sound
+static const char SHUTTER_ENABLE[];
+static const char SHUTTER_DISABLE[];
+
+//TI extensions for Temporal bracketing
+static const char BRACKET_ENABLE[];
+static const char BRACKET_DISABLE[];
+
+//TI extensions to Image post-processing
+static const char IPP_LDCNSF[];
+static const char IPP_LDC[];
+static const char IPP_NSF[];
+static const char IPP_NONE[];
+
+//TI extensions to camera mode
+static const char HIGH_PERFORMANCE_MODE[];
+static const char HIGH_QUALITY_MODE[];
+static const char HIGH_QUALITY_ZSL_MODE[];
+static const char VIDEO_MODE[];
+
+
+// TI extensions to standard android pixel formats
+static const char PIXEL_FORMAT_RAW[];
+static const char PIXEL_FORMAT_JPS[];
+static const char PIXEL_FORMAT_MPO[];
+static const char PIXEL_FORMAT_RAW_JPEG[];
+static const char PIXEL_FORMAT_RAW_MPO[];
+
+// TI extensions to standard android scene mode settings
+static const  char SCENE_MODE_SPORT[];
+static const  char SCENE_MODE_CLOSEUP[];
+static const  char SCENE_MODE_AQUA[];
+static const  char SCENE_MODE_SNOWBEACH[];
+static const  char SCENE_MODE_MOOD[];
+static const  char SCENE_MODE_NIGHT_INDOOR[];
+static const  char SCENE_MODE_DOCUMENT[];
+static const  char SCENE_MODE_BARCODE[];
+static const  char SCENE_MODE_VIDEO_SUPER_NIGHT[];
+static const  char SCENE_MODE_VIDEO_CINE[];
+static const  char SCENE_MODE_VIDEO_OLD_FILM[];
+
+// TI extensions to standard android white balance settings.
+static const  char WHITE_BALANCE_TUNGSTEN[];
+static const  char WHITE_BALANCE_HORIZON[];
+static const  char WHITE_BALANCE_SUNSET[];
+static const  char WHITE_BALANCE_FACE[];
+
+// TI extensions to add exposure preset modes to android api
+static const  char EXPOSURE_MODE_OFF[];
+static const  char EXPOSURE_MODE_AUTO[];
+static const  char EXPOSURE_MODE_NIGHT[];
+static const  char EXPOSURE_MODE_BACKLIGHT[];
+static const  char EXPOSURE_MODE_SPOTLIGHT[];
+static const  char EXPOSURE_MODE_SPORTS[];
+static const  char EXPOSURE_MODE_SNOW[];
+static const  char EXPOSURE_MODE_BEACH[];
+static const  char EXPOSURE_MODE_APERTURE[];
+static const  char EXPOSURE_MODE_SMALL_APERTURE[];
+static const  char EXPOSURE_MODE_FACE[];
+
+// TI extensions to standard android focus presets.
+static const  char FOCUS_MODE_PORTRAIT[];
+static const  char FOCUS_MODE_EXTENDED[];
+static const char  FOCUS_MODE_FACE[];
+
+// TI extensions to add iso values
+static const char ISO_MODE_AUTO[];
+static const char ISO_MODE_100[];
+static const char ISO_MODE_200[];
+static const char ISO_MODE_400[];
+static const char ISO_MODE_800[];
+static const char ISO_MODE_1000[];
+static const char ISO_MODE_1200[];
+static const char ISO_MODE_1600[];
+
+//  TI extensions to add  values for effect settings.
+static const char EFFECT_NATURAL[];
+static const char EFFECT_VIVID[];
+static const char EFFECT_COLOR_SWAP[];
+static const char EFFECT_BLACKWHITE[];
+
+static const char KEY_S3D2D_PREVIEW[];
+static const char KEY_S3D2D_PREVIEW_MODE[];
+
+//  TI extensions to add values for AutoConvergence settings.
+static const char AUTOCONVERGENCE_MODE_DISABLE[];
+static const char AUTOCONVERGENCE_MODE_FRAME[];
+static const char AUTOCONVERGENCE_MODE_CENTER[];
+static const char AUTOCONVERGENCE_MODE_FFT[];
+static const char AUTOCONVERGENCE_MODE_MANUAL[];
+
+
+//TI extensions for flash mode settings
+static const char FLASH_MODE_FILL_IN[];
+
+//TI extensions to add sensor orientation parameters
+static const char ORIENTATION_SENSOR_NONE[];
+static const char ORIENTATION_SENSOR_90[];
+static const char ORIENTATION_SENSOR_180[];
+static const char ORIENTATION_SENSOR_270[];
+
+
+//TI values for camera direction
+static const char FACING_FRONT[];
+static const char FACING_BACK[];
+
+};
+
+};
+
+#endif
+
diff --git a/domx/omx_core/src/OMX_Core_Wrapper.c b/domx/omx_core/src/OMX_Core_Wrapper.c
index d049ee0..8d61dd4 100755
--- a/domx/omx_core/src/OMX_Core_Wrapper.c
+++ b/domx/omx_core/src/OMX_Core_Wrapper.c
@@ -58,12 +58,12 @@
 OMX_BOOL TIOMXConfigParserRedirect(OMX_PTR aInputParameters,
     OMX_PTR aOutputParameters)
 {
-	LOGV("OMXConfigParserRedirect +\n");
+	ALOGV("OMXConfigParserRedirect +\n");
 	OMX_BOOL Status = OMX_FALSE;
 
 	Status = TIOMXConfigParser(aInputParameters, aOutputParameters);
 
-	LOGV("OMXConfigParserRedirect -\n");
+	ALOGV("OMXConfigParserRedirect -\n");
 	return Status;
 }
 #endif
@@ -92,14 +92,14 @@
 
 OMX_API OMX_ERRORTYPE TIOMX_Init(void)
 {
-	LOGV("TIOMX_Init\n");
+	ALOGV("TIOMX_Init\n");
 
 	return OMX_Init();
 }
 
 OMX_API OMX_ERRORTYPE TIOMX_Deinit(void)
 {
-	LOGV("TIOMX_Deinit\n");
+	ALOGV("TIOMX_Deinit\n");
 
 	return OMX_Deinit();
 }
@@ -108,7 +108,7 @@
     cComponentName, OMX_IN OMX_U32 nNameLength, OMX_IN OMX_U32 nIndex)
 {
 
-	LOGV("TIOMX_ComponentNameEnum\n");
+	ALOGV("TIOMX_ComponentNameEnum\n");
 
 	return OMX_ComponentNameEnum(cComponentName, nNameLength, nIndex);
 }
@@ -118,14 +118,14 @@
     OMX_IN OMX_PTR pAppData, OMX_IN OMX_CALLBACKTYPE * pCallBacks)
 {
 
-	LOGV("TIOMX_GetHandle\n");
+	ALOGV("TIOMX_GetHandle\n");
 
 	return OMX_GetHandle(pHandle, cComponentName, pAppData, pCallBacks);
 }
 
 OMX_API OMX_ERRORTYPE TIOMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
 {
-	LOGV("TIOMX_FreeHandle\n");
+	ALOGV("TIOMX_FreeHandle\n");
 
 	return OMX_FreeHandle(hComponent);
 }
@@ -134,7 +134,7 @@
     OMX_INOUT OMX_U32 * pNumComps, OMX_INOUT OMX_U8 ** compNames)
 {
 
-	LOGV("TIOMX_GetComponentsOfRole\n");
+	ALOGV("TIOMX_GetComponentsOfRole\n");
 
 	return OMX_GetComponentsOfRole(role, pNumComps, compNames);
 }
@@ -143,7 +143,7 @@
     OMX_INOUT OMX_U32 * pNumRoles, OMX_OUT OMX_U8 ** roles)
 {
 
-	LOGV("TIOMX_GetRolesOfComponent\n");
+	ALOGV("TIOMX_GetRolesOfComponent\n");
 
 	return OMX_GetRolesOfComponent(compName, pNumRoles, roles);
 }
@@ -153,7 +153,7 @@
     OMX_IN OMX_HANDLETYPE hInput, OMX_IN OMX_U32 nPortInput)
 {
 
-	LOGV("TIOMX_SetupTunnel\n");
+	ALOGV("TIOMX_SetupTunnel\n");
 
 	return OMX_SetupTunnel(hOutput, nPortOutput, hInput, nPortInput);
 }
@@ -162,7 +162,7 @@
     OMX_IN OMX_STRING szURI)
 {
 
-	LOGV("TIOMX_GetContentPipe\n");
+	ALOGV("TIOMX_GetContentPipe\n");
 
 	//return OMX_GetContentPipe(
 	//      hPipe,
diff --git a/hwc/hwc.c b/hwc/hwc.c
index e9580af..c55c3a4 100644
--- a/hwc/hwc.c
+++ b/hwc/hwc.c
@@ -409,7 +409,7 @@
 
     default:
         /* Should have been filtered out */
-        LOGV("Unsupported pixel format");
+        ALOGV("Unsupported pixel format");
         return;
     }
 
diff --git a/libtiutils/Android.mk b/libtiutils/Android.mk
old mode 100755
new mode 100644
diff --git a/libtiutils/DebugUtils.h b/libtiutils/DebugUtils.h
index 54edfc7..a8734b7 100644
--- a/libtiutils/DebugUtils.h
+++ b/libtiutils/DebugUtils.h
@@ -20,14 +20,14 @@
 #define DEBUG_UTILS_H
 
 ///Defines for debug statements - Macro LOG_TAG needs to be defined in the respective files
-#define DBGUTILS_LOGVA(str)         LOGV("%s:%d %s - " str,__FILE__, __LINE__,__FUNCTION__);
-#define DBGUTILS_LOGVB(str,...)     LOGV("%s:%d %s - " str,__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);
+#define DBGUTILS_LOGVA(str)         ALOGV("%s:%d %s - " str,__FILE__, __LINE__,__FUNCTION__);
+#define DBGUTILS_LOGVB(str,...)     ALOGV("%s:%d %s - " str,__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);
 #define DBGUTILS_LOGDA(str)         LOGD("%s:%d %s - " str,__FILE__, __LINE__,__FUNCTION__);
 #define DBGUTILS_LOGDB(str, ...)    LOGD("%s:%d %s - " str,__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);
 #define DBGUTILS_LOGEA(str)         LOGE("%s:%d %s - " str,__FILE__, __LINE__, __FUNCTION__);
 #define DBGUTILS_LOGEB(str, ...)    LOGE("%s:%d %s - " str,__FILE__, __LINE__,__FUNCTION__, __VA_ARGS__);
-#define LOG_FUNCTION_NAME           LOGV("%d: %s() ENTER", __LINE__, __FUNCTION__);
-#define LOG_FUNCTION_NAME_EXIT      LOGV("%d: %s() EXIT", __LINE__, __FUNCTION__);
+#define LOG_FUNCTION_NAME           ALOGV("%d: %s() ENTER", __LINE__, __FUNCTION__);
+#define LOG_FUNCTION_NAME_EXIT      ALOGV("%d: %s() EXIT", __LINE__, __FUNCTION__);
 
 
 
diff --git a/libtiutils/MessageQueue.cpp b/libtiutils/MessageQueue.cpp
old mode 100755
new mode 100644
diff --git a/libtiutils/MessageQueue.h b/libtiutils/MessageQueue.h
old mode 100755
new mode 100644
diff --git a/libtiutils/Semaphore.cpp b/libtiutils/Semaphore.cpp
index 41fa99c..37f3a89 100644
--- a/libtiutils/Semaphore.cpp
+++ b/libtiutils/Semaphore.cpp
@@ -1,232 +1,232 @@
-/*

- * Copyright (C) Texas Instruments - http://www.ti.com/

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-

-

-#include "Semaphore.h"

-#include "ErrorUtils.h"

-#include <utils/Log.h>

-#include <time.h>

-

-namespace android {

-

-/**

-   @brief Constructor for the semaphore class

-

-   @param none

-   @return none

- */

-Semaphore::Semaphore()

-{

-    ///Initialize the semaphore to NULL

-    mSemaphore = NULL;

-}

-

-/**

-   @brief Destructor of the semaphore class

-

-   @param none

-   @return none

-

- */

-Semaphore::~Semaphore()

-{

-    Release();

-}

-

-/**

-   @brief: Releases semaphore

-

-   @param count >=0

-   @return NO_ERROR On Success

-   @return One of the android error codes based on semaphore de-initialization

- */

-

-status_t Semaphore::Release()

-{

-    int status = 0;

-

-    ///Destroy only if the semaphore has been created

-    if(mSemaphore)

-        {

-        status = sem_destroy(mSemaphore);

-

-        free(mSemaphore);

-

-        mSemaphore = NULL;

-        }

-

-    ///Initialize the semaphore and return the status

-    return ErrorUtils::posixToAndroidError(status);

-

-}

-

-/**

-   @brief Create the semaphore with initial count value

-

-   @param count >=0

-   @return NO_ERROR On Success

-   @return NO_MEMORY If unable to allocate memory for the semaphore

-   @return BAD_VALUE If an invalid count value is passed (<0)

-   @return One of the android error codes based on semaphore initialization

- */

-

-status_t Semaphore::Create(int count)

-{

-    status_t ret = NO_ERROR;

-

-    ///count cannot be less than zero

-    if(count<0)

-        {

-        return BAD_VALUE;

-        }

-

-    ret = Release();

-    if ( NO_ERROR != ret )

-        {

-        return ret;

-        }

-

-    ///allocate memory for the semaphore

-    mSemaphore = (sem_t*)malloc(sizeof(sem_t)) ;

-

-    ///if memory is unavailable, return error

-    if(!mSemaphore)

-        {

-        return NO_MEMORY;

-        }

-

-    ///Initialize the semaphore and return the status

-    return ErrorUtils::posixToAndroidError(sem_init(mSemaphore, 0x00, count));

-

-}

-

-/**

-   @brief Wait operation

-

-   @param none

-   @return BAD_VALUE if the semaphore is not initialized

-   @return NO_ERROR On success

-   @return One of the android error codes based on semaphore wait operation

- */

-status_t Semaphore::Wait()

-{

-    ///semaphore should have been created first

-    if(!mSemaphore)

-        {

-        return BAD_VALUE;

-        }

-

-    ///Wait and return the status after signalling

-    return ErrorUtils::posixToAndroidError(sem_wait(mSemaphore));

-

-

-}

-

-

-/**

-   @brief Signal operation

-

-   @param none

-     @return BAD_VALUE if the semaphore is not initialized

-     @return NO_ERROR On success

-     @return One of the android error codes based on semaphore signal operation

-   */

-

-status_t Semaphore::Signal()

-{

-    ///semaphore should have been created first

-    if(!mSemaphore)

-        {

-        return BAD_VALUE;

-        }

-

-    ///Post to the semaphore

-    return ErrorUtils::posixToAndroidError(sem_post(mSemaphore));

-

-}

-

-/**

-   @brief Current semaphore count

-

-   @param none

-   @return Current count value of the semaphore

- */

-int Semaphore::Count()

-{

-    int val;

-

-    ///semaphore should have been created first

-    if(!mSemaphore)

-        {

-        return BAD_VALUE;

-        }

-

-    ///get the value of the semaphore

-    sem_getvalue(mSemaphore, &val);

-

-    return val;

-}

-

-/**

-   @brief Wait operation with a timeout

-

-     @param timeoutMicroSecs The timeout period in micro seconds

-     @return BAD_VALUE if the semaphore is not initialized

-     @return NO_ERROR On success

-     @return One of the android error codes based on semaphore wait operation

-   */

-

-status_t Semaphore::WaitTimeout(int timeoutMicroSecs)

-{

-    status_t ret = NO_ERROR;

-

-    struct timespec timeSpec;

-    struct timeval currentTime;

-

-    ///semaphore should have been created first

-    if( NULL == mSemaphore)

-        {

-        ret = BAD_VALUE;

-        }

-

-    if ( NO_ERROR == ret )

-        {

-

-        ///setup the timeout values - timeout is specified in seconds and nanoseconds

-        gettimeofday(&currentTime, NULL);

-        timeSpec.tv_sec = currentTime.tv_sec;

-        timeSpec.tv_nsec = currentTime.tv_usec * 1000;

-        timeSpec.tv_sec += ( timeoutMicroSecs / 1000000 );

-        timeSpec.tv_nsec += ( timeoutMicroSecs % 1000000) * 1000;

-

-        ///Wait for the timeout or signal and return the result based on whichever event occurred first

-        ret = sem_timedwait(mSemaphore, &timeSpec);

-        }

-

-    if ( NO_ERROR != ret )

-      {

-        Signal();

-        Create(0);

-      }

-

-    return ret;

-}

-

-

-};

-

-

+/*
+ * Copyright (C) Texas Instruments - http://www.ti.com/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include "Semaphore.h"
+#include "ErrorUtils.h"
+#include <utils/Log.h>
+#include <time.h>
+
+namespace android {
+
+/**
+   @brief Constructor for the semaphore class
+
+   @param none
+   @return none
+ */
+Semaphore::Semaphore()
+{
+    ///Initialize the semaphore to NULL
+    mSemaphore = NULL;
+}
+
+/**
+   @brief Destructor of the semaphore class
+
+   @param none
+   @return none
+
+ */
+Semaphore::~Semaphore()
+{
+    Release();
+}
+
+/**
+   @brief: Releases semaphore
+
+   @param count >=0
+   @return NO_ERROR On Success
+   @return One of the android error codes based on semaphore de-initialization
+ */
+
+status_t Semaphore::Release()
+{
+    int status = 0;
+
+    ///Destroy only if the semaphore has been created
+    if(mSemaphore)
+        {
+        status = sem_destroy(mSemaphore);
+
+        free(mSemaphore);
+
+        mSemaphore = NULL;
+        }
+
+    ///Initialize the semaphore and return the status
+    return ErrorUtils::posixToAndroidError(status);
+
+}
+
+/**
+   @brief Create the semaphore with initial count value
+
+   @param count >=0
+   @return NO_ERROR On Success
+   @return NO_MEMORY If unable to allocate memory for the semaphore
+   @return BAD_VALUE If an invalid count value is passed (<0)
+   @return One of the android error codes based on semaphore initialization
+ */
+
+status_t Semaphore::Create(int count)
+{
+    status_t ret = NO_ERROR;
+
+    ///count cannot be less than zero
+    if(count<0)
+        {
+        return BAD_VALUE;
+        }
+
+    ret = Release();
+    if ( NO_ERROR != ret )
+        {
+        return ret;
+        }
+
+    ///allocate memory for the semaphore
+    mSemaphore = (sem_t*)malloc(sizeof(sem_t)) ;
+
+    ///if memory is unavailable, return error
+    if(!mSemaphore)
+        {
+        return NO_MEMORY;
+        }
+
+    ///Initialize the semaphore and return the status
+    return ErrorUtils::posixToAndroidError(sem_init(mSemaphore, 0x00, count));
+
+}
+
+/**
+   @brief Wait operation
+
+   @param none
+   @return BAD_VALUE if the semaphore is not initialized
+   @return NO_ERROR On success
+   @return One of the android error codes based on semaphore wait operation
+ */
+status_t Semaphore::Wait()
+{
+    ///semaphore should have been created first
+    if(!mSemaphore)
+        {
+        return BAD_VALUE;
+        }
+
+    ///Wait and return the status after signalling
+    return ErrorUtils::posixToAndroidError(sem_wait(mSemaphore));
+
+
+}
+
+
+/**
+   @brief Signal operation
+
+   @param none
+     @return BAD_VALUE if the semaphore is not initialized
+     @return NO_ERROR On success
+     @return One of the android error codes based on semaphore signal operation
+   */
+
+status_t Semaphore::Signal()
+{
+    ///semaphore should have been created first
+    if(!mSemaphore)
+        {
+        return BAD_VALUE;
+        }
+
+    ///Post to the semaphore
+    return ErrorUtils::posixToAndroidError(sem_post(mSemaphore));
+
+}
+
+/**
+   @brief Current semaphore count
+
+   @param none
+   @return Current count value of the semaphore
+ */
+int Semaphore::Count()
+{
+    int val;
+
+    ///semaphore should have been created first
+    if(!mSemaphore)
+        {
+        return BAD_VALUE;
+        }
+
+    ///get the value of the semaphore
+    sem_getvalue(mSemaphore, &val);
+
+    return val;
+}
+
+/**
+   @brief Wait operation with a timeout
+
+     @param timeoutMicroSecs The timeout period in micro seconds
+     @return BAD_VALUE if the semaphore is not initialized
+     @return NO_ERROR On success
+     @return One of the android error codes based on semaphore wait operation
+   */
+
+status_t Semaphore::WaitTimeout(int timeoutMicroSecs)
+{
+    status_t ret = NO_ERROR;
+
+    struct timespec timeSpec;
+    struct timeval currentTime;
+
+    ///semaphore should have been created first
+    if( NULL == mSemaphore)
+        {
+        ret = BAD_VALUE;
+        }
+
+    if ( NO_ERROR == ret )
+        {
+
+        ///setup the timeout values - timeout is specified in seconds and nanoseconds
+        gettimeofday(&currentTime, NULL);
+        timeSpec.tv_sec = currentTime.tv_sec;
+        timeSpec.tv_nsec = currentTime.tv_usec * 1000;
+        timeSpec.tv_sec += ( timeoutMicroSecs / 1000000 );
+        timeSpec.tv_nsec += ( timeoutMicroSecs % 1000000) * 1000;
+
+        ///Wait for the timeout or signal and return the result based on whichever event occurred first
+        ret = sem_timedwait(mSemaphore, &timeSpec);
+        }
+
+    if ( NO_ERROR != ret )
+      {
+        Signal();
+        Create(0);
+      }
+
+    return ret;
+}
+
+
+};
+
+