camera: update to AU_LINUX_ANDROID_LA.BF64.1.2.9.05.01.00.089.309

e1dfbec Camera3: Bundle all streams configured

Change-Id: I2fd8eff5b72170dddb530eef46962be7fb659c90
diff --git a/QCamera2/HAL3/QCamera3Channel.cpp b/QCamera2/HAL3/QCamera3Channel.cpp
index 93f4880..ceed552 100644
--- a/QCamera2/HAL3/QCamera3Channel.cpp
+++ b/QCamera2/HAL3/QCamera3Channel.cpp
@@ -68,6 +68,7 @@
  * RETURN     : none
  *==========================================================================*/
 QCamera3Channel::QCamera3Channel(uint32_t cam_handle,
+                               uint32_t channel_handle,
                                mm_camera_ops_t *cam_ops,
                                channel_cb_routine cb_routine,
                                cam_padding_info_t *paddingInfo,
@@ -75,10 +76,10 @@
                                void *userData, uint32_t numBuffers)
 {
     m_camHandle = cam_handle;
+    m_handle = channel_handle;
     m_camOps = cam_ops;
     m_bIsActive = false;
 
-    m_handle = 0;
     m_numStreams = 0;
     memset(mStreams, 0, sizeof(mStreams));
     mUserData = userData;
@@ -98,33 +99,6 @@
 }
 
 /*===========================================================================
- * FUNCTION   : QCamera3Channel
- *
- * DESCRIPTION: default constrcutor of QCamera3Channel
- *
- * PARAMETERS : none
- *
- * RETURN     : none
- *==========================================================================*/
-QCamera3Channel::QCamera3Channel()
-{
-    m_camHandle = 0;
-    m_camOps = NULL;
-    m_bIsActive = false;
-
-    m_handle = 0;
-    m_numStreams = 0;
-    memset(mStreams, 0, sizeof(mStreams));
-    mUserData = NULL;
-
-    mStreamInfoBuf = NULL;
-    mChannelCB = NULL;
-    mPaddingInfo = NULL;
-
-    mPostProcMask = 0;
-}
-
-/*===========================================================================
  * FUNCTION   : ~QCamera3Channel
  *
  * DESCRIPTION: destructor of QCamera3Channel
@@ -144,43 +118,10 @@
             mStreams[i] = 0;
         }
     }
-    if (m_handle) {
-        m_camOps->delete_channel(m_camHandle, m_handle);
-        ALOGE("%s: deleting channel %d", __func__, m_handle);
-        m_handle = 0;
-    }
     m_numStreams = 0;
 }
 
 /*===========================================================================
- * FUNCTION   : init
- *
- * DESCRIPTION: initialization of channel
- *
- * PARAMETERS :
- *   @attr    : channel bundle attribute setting
- *   @dataCB  : data notify callback
- *   @userData: user data ptr
- *
- * RETURN     : int32_t type of status
- *              NO_ERROR  -- success
- *              none-zero failure code
- *==========================================================================*/
-int32_t QCamera3Channel::init(mm_camera_channel_attr_t *attr,
-                             mm_camera_buf_notify_t dataCB)
-{
-    m_handle = m_camOps->add_channel(m_camHandle,
-                                      attr,
-                                      dataCB,
-                                      this);
-    if (m_handle == 0) {
-        ALOGE("%s: Add channel failed", __func__);
-        return UNKNOWN_ERROR;
-    }
-    return NO_ERROR;
-}
-
-/*===========================================================================
  * FUNCTION   : addStream
  *
  * DESCRIPTION: add a stream into channel
@@ -274,17 +215,8 @@
             mStreams[i]->start();
         }
     }
-    rc = m_camOps->start_channel(m_camHandle, m_handle);
 
-    if (rc != NO_ERROR) {
-        for (uint32_t i = 0; i < m_numStreams; i++) {
-            if (mStreams[i] != NULL) {
-                mStreams[i]->stop();
-            }
-        }
-    } else {
-        m_bIsActive = true;
-    }
+    m_bIsActive = true;
 
     return rc;
 }
@@ -315,8 +247,6 @@
         }
     }
 
-    rc = m_camOps->stop_channel(m_camHandle, m_handle);
-
     m_bIsActive = false;
     return rc;
 }
@@ -405,6 +335,21 @@
     return rc;
 }
 
+int32_t QCamera3Channel::setBundleInfo(const cam_bundle_config_t &bundleInfo)
+{
+    int32_t rc = NO_ERROR;
+    cam_stream_parm_buffer_t param;
+    memset(&param, 0, sizeof(cam_stream_parm_buffer_t));
+    param.type = CAM_STREAM_PARAM_TYPE_SET_BUNDLE_INFO;
+    param.bundleInfo = bundleInfo;
+    rc = mStreams[0]->setParameter(param);
+    if (rc != NO_ERROR) {
+        ALOGE("%s: stream setParameter for set bundle failed", __func__);
+    }
+
+    return rc;
+}
+
 /*===========================================================================
  * FUNCTION   : getStreamTypeMask
  *
@@ -560,6 +505,7 @@
  * RETURN     : none
  *==========================================================================*/
 QCamera3ProcessingChannel::QCamera3ProcessingChannel(uint32_t cam_handle,
+        uint32_t channel_handle,
         mm_camera_ops_t *cam_ops,
         channel_cb_routine cb_routine,
         cam_padding_info_t *paddingInfo,
@@ -569,7 +515,7 @@
         uint32_t postprocess_mask,
         QCamera3Channel *metadataChannel,
         uint32_t numBuffers) :
-            QCamera3Channel(cam_handle, cam_ops, cb_routine,
+            QCamera3Channel(cam_handle, channel_handle, cam_ops, cb_routine,
                     paddingInfo, postprocess_mask, userData, numBuffers),
             m_postprocessor(this),
             mMemory(numBuffers),
@@ -1385,6 +1331,7 @@
  * RETURN     : none
  *==========================================================================*/
 QCamera3RegularChannel::QCamera3RegularChannel(uint32_t cam_handle,
+        uint32_t channel_handle,
         mm_camera_ops_t *cam_ops,
         channel_cb_routine cb_routine,
         cam_padding_info_t *paddingInfo,
@@ -1394,8 +1341,8 @@
         uint32_t postprocess_mask,
         QCamera3Channel *metadataChannel,
         uint32_t numBuffers) :
-            QCamera3ProcessingChannel(cam_handle, cam_ops, cb_routine,
-                    paddingInfo, userData, stream, stream_type,
+            QCamera3ProcessingChannel(cam_handle, channel_handle, cam_ops,
+                    cb_routine, paddingInfo, userData, stream, stream_type,
                     postprocess_mask, metadataChannel, numBuffers),
             mRotation(ROTATE_0),
             mBatchSize(0)
@@ -1443,12 +1390,6 @@
         return NO_ERROR;
     }
 
-    rc = init(NULL, NULL);
-    if (rc < 0) {
-        ALOGE("%s: init failed", __func__);
-        return rc;
-    }
-
     mIsType  = isType;
 
     rc = translateStreamTypeAndFormat(mCamera3Stream, mStreamType,
@@ -1513,28 +1454,6 @@
 }
 
 /*===========================================================================
-* FUNCTION   : start
-*
-* DESCRIPTION: start a regular channel
-*
-* PARAMETERS :
-*
-* RETURN     : int32_t type of status
-*              NO_ERROR  -- success
-*              none-zero failure code
-*==========================================================================*/
-int32_t QCamera3RegularChannel::start()
-{
-    ATRACE_CALL();
-    int32_t rc = NO_ERROR;
-
-    if (0 < mMemory.getCnt()) {
-        rc = QCamera3Channel::start();
-    }
-    return rc;
-}
-
-/*===========================================================================
  * FUNCTION   : setBatchSize
  *
  * DESCRIPTION: Set batch size for the channel.
@@ -1682,12 +1601,13 @@
 }
 
 QCamera3MetadataChannel::QCamera3MetadataChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     channel_cb_routine cb_routine,
                     cam_padding_info_t *paddingInfo,
                     uint32_t postprocess_mask,
                     void *userData, uint32_t numBuffers) :
-                        QCamera3Channel(cam_handle, cam_ops,
+                        QCamera3Channel(cam_handle, channel_handle, cam_ops,
                                 cb_routine, paddingInfo, postprocess_mask,
                                 userData, numBuffers),
                         mMemory(NULL)
@@ -1717,12 +1637,6 @@
         return -EINVAL;
     }
 
-    rc = init(NULL, NULL);
-    if (rc < 0) {
-        ALOGE("%s: init failed", __func__);
-        return rc;
-    }
-
     streamDim.width = (int32_t)sizeof(metadata_buffer_t),
     streamDim.height = 1;
 
@@ -1793,6 +1707,7 @@
 /*************************************************************************************/
 // RAW Channel related functions
 QCamera3RawChannel::QCamera3RawChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     channel_cb_routine cb_routine,
                     cam_padding_info_t *paddingInfo,
@@ -1801,7 +1716,7 @@
                     uint32_t postprocess_mask,
                     QCamera3Channel *metadataChannel,
                     bool raw_16, uint32_t numBuffers) :
-                        QCamera3RegularChannel(cam_handle, cam_ops,
+                        QCamera3RegularChannel(cam_handle, channel_handle, cam_ops,
                                 cb_routine, paddingInfo, userData, stream,
                                 CAM_STREAM_TYPE_RAW, postprocess_mask, metadataChannel, numBuffers),
                         mIsRaw16(raw_16)
@@ -2012,12 +1927,13 @@
  * RETURN           : NA
  *==========================================================================*/
 QCamera3RawDumpChannel::QCamera3RawDumpChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     cam_dimension_t rawDumpSize,
                     cam_padding_info_t *paddingInfo,
                     void *userData,
                     uint32_t postprocess_mask, uint32_t numBuffers) :
-                        QCamera3Channel(cam_handle, cam_ops, NULL,
+                        QCamera3Channel(cam_handle, channel_handle, cam_ops, NULL,
                                 paddingInfo, postprocess_mask,
                                 userData, numBuffers),
                         mDim(rawDumpSize),
@@ -2216,11 +2132,6 @@
 {
     int32_t rc;
 
-    rc = init(NULL, NULL);
-    if (rc < 0) {
-        ALOGE("%s: init failed", __func__);
-        return rc;
-    }
     mIsType = isType;
     rc = QCamera3Channel::addStream(CAM_STREAM_TYPE_RAW,
         CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG, mDim, ROTATE_0, (uint8_t)mNumBuffers,
@@ -2251,6 +2162,7 @@
  * RETURN     : none
  *==========================================================================*/
 QCamera3YUVChannel::QCamera3YUVChannel(uint32_t cam_handle,
+        uint32_t channel_handle,
         mm_camera_ops_t *cam_ops,
         channel_cb_routine cb_routine,
         cam_padding_info_t *paddingInfo,
@@ -2259,9 +2171,9 @@
         cam_stream_type_t stream_type,
         uint32_t postprocess_mask,
         QCamera3Channel *metadataChannel) :
-            QCamera3ProcessingChannel(cam_handle, cam_ops, cb_routine,
-                    paddingInfo, userData, stream, stream_type, postprocess_mask,
-                    metadataChannel)
+            QCamera3ProcessingChannel(cam_handle, channel_handle, cam_ops,
+                    cb_routine, paddingInfo, userData, stream, stream_type,
+                    postprocess_mask, metadataChannel)
 {
 
     mBypass = (postprocess_mask == CAM_QCOM_FEATURE_NONE);
@@ -2316,12 +2228,6 @@
         return NO_ERROR;
     }
 
-    rc = init(NULL, NULL);
-    if (rc < 0) {
-        ALOGE("%s: init failed", __func__);
-        return rc;
-    }
-
     mIsType  = isType;
     mStreamFormat = CALLBACK_FORMAT;
     streamDim.width = mCamera3Stream->width;
@@ -2373,28 +2279,6 @@
 }
 
 /*===========================================================================
-* FUNCTION   : start
-*
-* DESCRIPTION: start a YUV channel
-*
-* PARAMETERS :
-*
-* RETURN     : int32_t type of status
-*              NO_ERROR  -- success
-*              none-zero failure code
-*==========================================================================*/
-int32_t QCamera3YUVChannel::start()
-{
-    ATRACE_CALL();
-    int32_t rc = NO_ERROR;
-
-    if (0 < mMemory.getCnt()) {
-        rc = QCamera3Channel::start();
-    }
-    return rc;
-}
-
-/*===========================================================================
  * FUNCTION   : request
  *
  * DESCRIPTION: entry function for a request on a YUV stream. This function
@@ -2443,6 +2327,14 @@
         return QCamera3ProcessingChannel::request(buffer, frameNumber,
                 pInputBuffer, metadata);
     } else {
+        if(!m_bIsActive) {
+            rc = start();
+            if (NO_ERROR != rc)
+                return rc;
+        } else {
+            CDBG("%s: Request on an existing stream",__func__);
+        }
+
         //we need to send this frame through the CPP
         //Allocate heap memory, then buf done on the buffer
         uint32_t bufIdx;
@@ -2475,15 +2367,6 @@
         mMemory.markFrameNumber(bufIdx, frameNumber);
         mStreams[0]->bufDone(bufIdx);
 
-        // Currently start() function needs at least one
-        // buffer queued before starting the stream.
-        if(!m_bIsActive) {
-            rc = start();
-            if (NO_ERROR != rc)
-                return rc;
-        } else {
-            CDBG("%s: Request on an existing stream",__func__);
-        }
     }
     return rc;
 }
@@ -2928,6 +2811,7 @@
 }
 
 QCamera3PicChannel::QCamera3PicChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     channel_cb_routine cb_routine,
                     cam_padding_info_t *paddingInfo,
@@ -2938,8 +2822,9 @@
                     bool isInputStreamConfigured,
                     QCamera3Channel *metadataChannel,
                     uint32_t numBuffers) :
-                        QCamera3ProcessingChannel(cam_handle, cam_ops, cb_routine,
-                                paddingInfo, userData, stream, CAM_STREAM_TYPE_SNAPSHOT,
+                        QCamera3ProcessingChannel(cam_handle, channel_handle,
+                                cam_ops, cb_routine, paddingInfo, userData,
+                                stream, CAM_STREAM_TYPE_SNAPSHOT,
                                 postprocess_mask, metadataChannel, numBuffers),
                         mNumSnapshotBufs(0),
                         mInputBufferHint(isInputStreamConfigured),
@@ -2980,18 +2865,6 @@
         return NO_ERROR;
     }
 
-    memset(&attr, 0, sizeof(mm_camera_channel_attr_t));
-    attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_BURST;
-    attr.look_back = 1;
-    attr.post_frame_skip = 1;
-    attr.water_mark = 1;
-    attr.max_unmatched_frames = 1;
-
-    rc = init(&attr, NULL);
-    if (rc < 0) {
-        ALOGE("%s: init failed", __func__);
-        return rc;
-    }
     mIsType = isType;
     streamType = mStreamType;
     streamFormat = mStreamFormat;
@@ -3394,13 +3267,15 @@
  * RETURN     : none
  *==========================================================================*/
 QCamera3ReprocessChannel::QCamera3ReprocessChannel(uint32_t cam_handle,
+                                                 uint32_t channel_handle,
                                                  mm_camera_ops_t *cam_ops,
                                                  channel_cb_routine cb_routine,
                                                  cam_padding_info_t *paddingInfo,
                                                  uint32_t postprocess_mask,
                                                  void *userData, void *ch_hdl) :
-    QCamera3Channel(cam_handle, cam_ops, cb_routine, paddingInfo, postprocess_mask,
-                    userData, ((QCamera3ProcessingChannel *)ch_hdl)->getNumBuffers()),
+    QCamera3Channel(cam_handle, channel_handle, cam_ops, cb_routine, paddingInfo,
+                    postprocess_mask, userData,
+                    ((QCamera3ProcessingChannel *)ch_hdl)->getNumBuffers()),
     inputChHandle(ch_hdl),
     mOfflineBuffersIndex(-1),
     mReprocessType(REPROCESS_TYPE_NONE),
@@ -3436,10 +3311,15 @@
     attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS;
     attr.max_unmatched_frames = 1;
 
-    rc = init(&attr, NULL);
-    if (rc < 0) {
-        ALOGE("%s: init failed", __func__);
+    m_handle = m_camOps->add_channel(m_camHandle,
+                                      &attr,
+                                      NULL,
+                                      this);
+    if (m_handle == 0) {
+        ALOGE("%s: Add channel failed", __func__);
+        return UNKNOWN_ERROR;
     }
+
     mIsType = isType;
     return rc;
 }
@@ -3588,22 +3468,6 @@
 }
 
 /*===========================================================================
- * FUNCTION   : QCamera3ReprocessChannel
- *
- * DESCRIPTION: default constructor of QCamera3ReprocessChannel
- *
- * PARAMETERS : none
- *
- * RETURN     : none
- *==========================================================================*/
-QCamera3ReprocessChannel::QCamera3ReprocessChannel() :
-    m_pSrcChannel(NULL),
-    m_pMetaChannel(NULL),
-    mGrallocMemory(0)
-{
-}
-
-/*===========================================================================
  * FUNCTION   : getStreamBufs
  *
  * DESCRIPTION: register the buffers of the reprocess channel
@@ -3664,6 +3528,76 @@
  *==========================================================================*/
 QCamera3ReprocessChannel::~QCamera3ReprocessChannel()
 {
+    if (m_bIsActive)
+        stop();
+
+    for (uint32_t i = 0; i < m_numStreams; i++) {
+        if (mStreams[i] != NULL) {
+            delete mStreams[i];
+            mStreams[i] = 0;
+        }
+    }
+    if (m_handle) {
+        m_camOps->delete_channel(m_camHandle, m_handle);
+        ALOGE("%s: deleting channel %d", __func__, m_handle);
+        m_handle = 0;
+    }
+    m_numStreams = 0;
+}
+
+/*===========================================================================
+ * FUNCTION   : start
+ *
+ * DESCRIPTION: start reprocess channel.
+ *
+ * PARAMETERS :
+ *
+ * RETURN     : int32_t type of status
+ *              NO_ERROR  -- success
+ *              none-zero failure code
+ *==========================================================================*/
+int32_t QCamera3ReprocessChannel::start()
+{
+    ATRACE_CALL();
+    int32_t rc = NO_ERROR;
+
+    rc = QCamera3Channel::start();
+
+    if (rc == NO_ERROR) {
+       rc = m_camOps->start_channel(m_camHandle, m_handle);
+
+       // Check failure
+       if (rc != NO_ERROR) {
+           ALOGE("%s: start_channel failed %d", __func__, rc);
+           QCamera3Channel::stop();
+       }
+    }
+    return rc;
+}
+
+/*===========================================================================
+ * FUNCTION   : stop
+ *
+ * DESCRIPTION: stop reprocess channel.
+ *
+ * PARAMETERS : none
+ *
+ * RETURN     : int32_t type of status
+ *              NO_ERROR  -- success
+ *              none-zero failure code
+ *==========================================================================*/
+int32_t QCamera3ReprocessChannel::stop()
+{
+    ATRACE_CALL();
+    int32_t rc = NO_ERROR;
+
+    unmapOfflineBuffers(true);
+
+    rc = QCamera3Channel::stop();
+
+    rc != m_camOps->stop_channel(m_camHandle, m_handle);
+
+    return rc;
 }
 
 /*===========================================================================
@@ -3717,24 +3651,6 @@
 }
 
 /*===========================================================================
- * FUNCTION   : stop
- *
- * DESCRIPTION: stop channel
- *
- * PARAMETERS : none
- *
- * RETURN     : int32_t type of status
- *              NO_ERROR  -- success
- *              none-zero failure code
- *==========================================================================*/
-int32_t QCamera3ReprocessChannel::stop()
-{
-    unmapOfflineBuffers(true);
-
-    return QCamera3Channel::stop();
-}
-
-/*===========================================================================
  * FUNCTION   : unmapOfflineBuffers
  *
  * DESCRIPTION: Unmaps offline buffers
@@ -4289,6 +4205,7 @@
 cam_dimension_t QCamera3SupportChannel::kDim = {640, 480};
 
 QCamera3SupportChannel::QCamera3SupportChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     cam_padding_info_t *paddingInfo,
                     uint32_t postprocess_mask,
@@ -4296,7 +4213,7 @@
                     cam_dimension_t *dim,
                     cam_format_t streamFormat,
                     void *userData, uint32_t numBuffers) :
-                        QCamera3Channel(cam_handle, cam_ops,
+                        QCamera3Channel(cam_handle, channel_handle, cam_ops,
                                 NULL, paddingInfo, postprocess_mask,
                                 userData, numBuffers),
                         mMemory(NULL)
@@ -4327,11 +4244,6 @@
         return -EINVAL;
     }
 
-    rc = init(NULL, NULL);
-    if (rc < 0) {
-        ALOGE("%s: init failed", __func__);
-        return rc;
-    }
     mIsType = isType;
     rc = QCamera3Channel::addStream(mStreamType,
         mStreamFormat, mDim, ROTATE_0, MIN_STREAMING_BUFFER_NUM,
diff --git a/QCamera2/HAL3/QCamera3Channel.h b/QCamera2/HAL3/QCamera3Channel.h
index 7c5a399..afe1036 100644
--- a/QCamera2/HAL3/QCamera3Channel.h
+++ b/QCamera2/HAL3/QCamera3Channel.h
@@ -56,12 +56,12 @@
 {
 public:
     QCamera3Channel(uint32_t cam_handle,
+                   uint32_t channel_handle,
                    mm_camera_ops_t *cam_ops,
                    channel_cb_routine cb_routine,
                    cam_padding_info_t *paddingInfo,
                    uint32_t postprocess_mask,
                    void *userData, uint32_t numBuffers);
-    QCamera3Channel();
     virtual ~QCamera3Channel();
 
     virtual int32_t start();
@@ -70,6 +70,7 @@
     virtual int32_t queueBatchBuf();
     virtual int32_t setPerFrameMapUnmap(bool enable);
     int32_t bufDone(mm_camera_super_buf_t *recvd_frame);
+    int32_t setBundleInfo(const cam_bundle_config_t &bundleInfo);
 
     virtual uint32_t getStreamTypeMask();
     uint32_t getStreamID(uint32_t streamMask);
@@ -104,8 +105,6 @@
     uint32_t m_numStreams;
 protected:
 
-    virtual int32_t init(mm_camera_channel_attr_t *attr,
-                         mm_camera_buf_notify_t dataCB);
     int32_t addStream(cam_stream_type_t streamType,
                       cam_format_t streamFormat,
                       cam_dimension_t streamDim,
@@ -147,6 +146,7 @@
 {
 public:
    QCamera3ProcessingChannel(uint32_t cam_handle,
+           uint32_t channel_handle,
            mm_camera_ops_t *cam_ops,
            channel_cb_routine cb_routine,
            cam_padding_info_t *paddingInfo,
@@ -235,6 +235,7 @@
 {
 public:
     QCamera3RegularChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     channel_cb_routine cb_routine,
                     cam_padding_info_t *paddingInfo,
@@ -247,7 +248,6 @@
 
     virtual ~QCamera3RegularChannel();
 
-    virtual int32_t start();
     virtual int32_t setBatchSize(uint32_t batchSize);
     virtual uint32_t getStreamTypeMask();
     virtual int32_t queueBatchBuf();
@@ -268,6 +268,7 @@
 {
 public:
     QCamera3MetadataChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     channel_cb_routine cb_routine,
                     cam_padding_info_t *paddingInfo,
@@ -297,6 +298,7 @@
 {
 public:
     QCamera3RawChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     channel_cb_routine cb_routine,
                     cam_padding_info_t *paddingInfo,
@@ -333,6 +335,7 @@
 {
 public:
     QCamera3RawDumpChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     cam_dimension_t rawDumpSize,
                     cam_padding_info_t *paddingInfo,
@@ -364,6 +367,7 @@
 {
 public:
     QCamera3YUVChannel(uint32_t cam_handle,
+            uint32_t channel_handle,
             mm_camera_ops_t *cam_ops,
             channel_cb_routine cb_routine,
             cam_padding_info_t *paddingInfo,
@@ -379,7 +383,6 @@
             camera3_stream_buffer_t* pInputBuffer,
             metadata_buffer_t* metadata, bool &needMetadata);
     virtual reprocess_type_t getReprocessType();
-    virtual int32_t start();
     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
             QCamera3Stream *stream);
     virtual void reprocessCbRoutine(buffer_handle_t *resultBuffer,
@@ -422,6 +425,7 @@
 {
 public:
     QCamera3PicChannel(uint32_t cam_handle,
+            uint32_t channel_handle,
             mm_camera_ops_t *cam_ops,
             channel_cb_routine cb_routine,
             cam_padding_info_t *paddingInfo,
@@ -479,6 +483,7 @@
 {
 public:
     QCamera3ReprocessChannel(uint32_t cam_handle,
+                            uint32_t channel_handle,
                             mm_camera_ops_t *cam_ops,
                             channel_cb_routine cb_routine,
                             cam_padding_info_t *paddingInfo,
@@ -487,6 +492,8 @@
     QCamera3ReprocessChannel();
     virtual ~QCamera3ReprocessChannel();
     // offline reprocess
+    virtual int32_t start();
+    virtual int32_t stop();
     int32_t doReprocessOffline(qcamera_fwk_input_pp_data_t *frame);
     int32_t doReprocess(int buf_fd, size_t buf_length, int32_t &ret_val,
                         mm_camera_super_buf_t *meta_buf);
@@ -499,7 +506,6 @@
     virtual void putStreamBufs();
     virtual int32_t initialize(cam_is_type_t isType);
     int32_t unmapOfflineBuffers(bool all);
-    virtual int32_t stop();
     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
                             QCamera3Stream *stream);
     static void dataNotifyCB(mm_camera_super_buf_t *recvd_frame,
@@ -540,6 +546,7 @@
 {
 public:
     QCamera3SupportChannel(uint32_t cam_handle,
+                    uint32_t channel_handle,
                     mm_camera_ops_t *cam_ops,
                     cam_padding_info_t *paddingInfo,
                     uint32_t postprocess_mask,
diff --git a/QCamera2/HAL3/QCamera3HWI.cpp b/QCamera2/HAL3/QCamera3HWI.cpp
index a168eb6..1394d63 100644
--- a/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/QCamera2/HAL3/QCamera3HWI.cpp
@@ -322,6 +322,7 @@
       mAnalysisChannel(NULL),
       mRawDumpChannel(NULL),
       mDummyBatchChannel(NULL),
+      mChannelHandle(0),
       mFirstRequest(false),
       mFirstConfiguration(true),
       mFlush(false),
@@ -435,6 +436,14 @@
     if (mAnalysisChannel) {
         mAnalysisChannel->stop();
     }
+    if (mMetadataChannel) {
+        mMetadataChannel->stop();
+    }
+    if (mChannelHandle) {
+        mCameraHandle->ops->stop_channel(mCameraHandle->camera_handle,
+                mChannelHandle);
+        ALOGI("%s: stopping channel %d", __func__, mChannelHandle);
+    }
 
     for (List<stream_info_t *>::iterator it = mStreamInfo.begin();
         it != mStreamInfo.end(); it++) {
@@ -462,13 +471,13 @@
     }
     mPictureChannel = NULL;
 
+    if (mMetadataChannel) {
+        delete mMetadataChannel;
+        mMetadataChannel = NULL;
+    }
+
     /* Clean up all channels */
     if (mCameraInitialized) {
-        if (mMetadataChannel) {
-            mMetadataChannel->stop();
-            delete mMetadataChannel;
-            mMetadataChannel = NULL;
-        }
         if(!mFirstConfiguration){
             //send the last unconfigure
             cam_stream_size_info_t stream_config_info;
@@ -485,6 +494,13 @@
         deinitParameters();
     }
 
+    if (mChannelHandle) {
+        mCameraHandle->ops->delete_channel(mCameraHandle->camera_handle,
+                mChannelHandle);
+        ALOGE("%s: deleting channel %d", __func__, mChannelHandle);
+        mChannelHandle = 0;
+    }
+
     if (mCameraOpened)
         closeCamera();
 
@@ -720,6 +736,15 @@
     }
     mCallbackOps = callback_ops;
 
+    mChannelHandle = mCameraHandle->ops->add_channel(
+            mCameraHandle->camera_handle, NULL, NULL, this);
+    if (mChannelHandle == 0) {
+        ALOGE("%s: add_channel failed", __func__);
+        rc = -ENOMEM;
+        pthread_mutex_unlock(&mMutex);
+        return rc;
+    }
+
     pthread_mutex_unlock(&mMutex);
     mCameraInitialized = true;
     return 0;
@@ -1096,6 +1121,11 @@
         /* If content of mStreamInfo is not 0, there is metadata stream */
         mMetadataChannel->stop();
     }
+    if (mChannelHandle) {
+        mCameraHandle->ops->stop_channel(mCameraHandle->camera_handle,
+                mChannelHandle);
+        ALOGI("%s: stopping channel %d", __func__, mChannelHandle);
+    }
 
     pthread_mutex_lock(&mMutex);
 
@@ -1443,7 +1473,7 @@
 
     //Create metadata channel and initialize it
     mMetadataChannel = new QCamera3MetadataChannel(mCameraHandle->camera_handle,
-                    mCameraHandle->ops, captureResultCb,
+                    mChannelHandle, mCameraHandle->ops, captureResultCb,
                     &gCamCapability[mCameraId]->padding_info, CAM_QCOM_FEATURE_NONE, this);
     if (mMetadataChannel == NULL) {
         ALOGE("%s: failed to allocate metadata channel", __func__);
@@ -1464,6 +1494,7 @@
     {
         mAnalysisChannel = new QCamera3SupportChannel(
                 mCameraHandle->camera_handle,
+                mChannelHandle,
                 mCameraHandle->ops,
                 &gCamCapability[mCameraId]->padding_info,
                 CAM_QCOM_FEATURE_PP_SUPERSET_HAL3,
@@ -1637,7 +1668,7 @@
                             CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE)
                     ) {
                         channel = new QCamera3RegularChannel(mCameraHandle->camera_handle,
-                                mCameraHandle->ops, captureResultCb,
+                                mChannelHandle, mCameraHandle->ops, captureResultCb,
                                 &gCamCapability[mCameraId]->padding_info,
                                 this,
                                 newStream,
@@ -1666,7 +1697,7 @@
                             mDummyBatchStream = *newStream;
                         }
                         channel = new QCamera3RegularChannel(mCameraHandle->camera_handle,
-                                mCameraHandle->ops, captureResultCb,
+                                mChannelHandle, mCameraHandle->ops, captureResultCb,
                                 &gCamCapability[mCameraId]->padding_info,
                                 this,
                                 newStream,
@@ -1686,6 +1717,7 @@
                     break;
                 case HAL_PIXEL_FORMAT_YCbCr_420_888: {
                     channel = new QCamera3YUVChannel(mCameraHandle->camera_handle,
+                            mChannelHandle,
                             mCameraHandle->ops, captureResultCb,
                             &gCamCapability[mCameraId]->padding_info,
                             this,
@@ -1707,7 +1739,7 @@
                 case HAL_PIXEL_FORMAT_RAW16:
                 case HAL_PIXEL_FORMAT_RAW10:
                     mRawChannel = new QCamera3RawChannel(
-                            mCameraHandle->camera_handle,
+                            mCameraHandle->camera_handle, mChannelHandle,
                             mCameraHandle->ops, captureResultCb,
                             &gCamCapability[mCameraId]->padding_info,
                             this, newStream, CAM_QCOM_FEATURE_NONE,
@@ -1725,7 +1757,8 @@
                     // Max live snapshot inflight buffer is 1. This is to mitigate
                     // frame drop issues for video snapshot. The more buffers being
                     // allocated, the more frame drops there are.
-                    mPictureChannel = new QCamera3PicChannel(mCameraHandle->camera_handle,
+                    mPictureChannel = new QCamera3PicChannel(
+                            mCameraHandle->camera_handle, mChannelHandle,
                             mCameraHandle->ops, captureResultCb,
                             &gCamCapability[mCameraId]->padding_info, this, newStream,
                             mStreamConfigInfo.postprocess_mask[mStreamConfigInfo.num_streams],
@@ -1778,6 +1811,7 @@
         cam_dimension_t rawDumpSize;
         rawDumpSize = getMaxRawSize(mCameraId);
         mRawDumpChannel = new QCamera3RawDumpChannel(mCameraHandle->camera_handle,
+                                  mChannelHandle,
                                   mCameraHandle->ops,
                                   rawDumpSize,
                                   &gCamCapability[mCameraId]->padding_info,
@@ -1796,13 +1830,14 @@
         mStreamConfigInfo.type[mStreamConfigInfo.num_streams] =
                 CAM_STREAM_TYPE_ANALYSIS;
         mStreamConfigInfo.postprocess_mask[mStreamConfigInfo.num_streams] =
-                CAM_QCOM_FEATURE_FACE_DETECTION;
+                CAM_QCOM_FEATURE_PP_SUPERSET_HAL3;
         mStreamConfigInfo.num_streams++;
     }
 
     if (isSupportChannelNeeded(streamList, mStreamConfigInfo)) {
         mSupportChannel = new QCamera3SupportChannel(
                 mCameraHandle->camera_handle,
+                mChannelHandle,
                 mCameraHandle->ops,
                 &gCamCapability[mCameraId]->padding_info,
                 CAM_QCOM_FEATURE_PP_SUPERSET_HAL3,
@@ -1844,6 +1879,7 @@
     if ((mOpMode == CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE) &&
             !m_bIsVideo) {
         mDummyBatchChannel = new QCamera3RegularChannel(mCameraHandle->camera_handle,
+                mChannelHandle,
                 mCameraHandle->ops, captureResultCb,
                 &gCamCapability[mCameraId]->padding_info,
                 this,
@@ -3024,26 +3060,6 @@
             }
         }
 
-        for (size_t i = 0; i < request->num_output_buffers; i++) {
-            const camera3_stream_buffer_t& output = request->output_buffers[i];
-            QCamera3Channel *channel = (QCamera3Channel *)output.stream->priv;
-            /*for livesnapshot stream is_type will be DIS*/
-            if ((((1U << CAM_STREAM_TYPE_VIDEO) == channel->getStreamTypeMask()) ||
-               ((1U << CAM_STREAM_TYPE_PREVIEW) == channel->getStreamTypeMask())) &&
-               setEis)
-                rc = channel->registerBuffer(output.buffer, is_type);
-            else
-                rc = channel->registerBuffer(output.buffer, IS_TYPE_NONE);
-
-            if (rc < 0) {
-                ALOGE("%s: registerBuffer failed",
-                        __func__);
-                pthread_mutex_unlock(&mMutex);
-                rc = -ENODEV;
-                goto error_exit;
-            }
-        }
-
         //First initialize all streams
         for (List<stream_info_t *>::iterator it = mStreamInfo.begin();
             it != mStreamInfo.end(); it++) {
@@ -3101,6 +3117,14 @@
             }
         }
 
+        // Set bundle info
+        rc = setBundleInfo();
+        if (rc < 0) {
+            ALOGE("%s: setBundleInfo failed %d", __func__, rc);
+            pthread_mutex_unlock(&mMutex);
+            goto error_exit;
+        }
+
         //Then start them.
         CDBG_HIGH("%s: Start META Channel", __func__);
         rc = mMetadataChannel->start();
@@ -3170,12 +3194,26 @@
                 goto error_exit;
             }
         }
+
+        if (mChannelHandle) {
+
+            rc = mCameraHandle->ops->start_channel(mCameraHandle->camera_handle,
+                    mChannelHandle);
+            if (rc != NO_ERROR) {
+                ALOGE("%s: start_channel failed %d", __func__, rc);
+                pthread_mutex_unlock(&mMutex);
+                goto error_exit;
+            }
+        }
+
+
         goto no_error;
 error_exit:
         m_perfLock.lock_rel();
         return rc;
 no_error:
         m_perfLock.lock_rel();
+
         mWokenUpByDaemon = false;
         mPendingLiveRequest = 0;
         mFirstConfiguration = false;
@@ -3603,6 +3641,17 @@
         ALOGE("%s: stopAllChannels failed", __func__);
         return rc;
     }
+    if (mChannelHandle) {
+        mCameraHandle->ops->stop_channel(mCameraHandle->camera_handle,
+                mChannelHandle);
+    }
+
+    // Reset bundle info
+    rc = setBundleInfo();
+    if (rc < 0) {
+        ALOGE("%s: setBundleInfo failed %d", __func__, rc);
+        return rc;
+    }
 
     // Mutex Lock
     pthread_mutex_lock(&mMutex);
@@ -3628,6 +3677,16 @@
         return rc;
     }
 
+    if (mChannelHandle) {
+        mCameraHandle->ops->start_channel(mCameraHandle->camera_handle,
+                    mChannelHandle);
+        if (rc < 0) {
+            ALOGE("%s: start_channel failed", __func__);
+            pthread_mutex_unlock(&mMutex);
+            return rc;
+        }
+    }
+
     pthread_mutex_unlock(&mMutex);
 
     return 0;
@@ -8644,7 +8703,8 @@
     QCamera3ReprocessChannel *pChannel = NULL;
 
     pChannel = new QCamera3ReprocessChannel(mCameraHandle->camera_handle,
-            mCameraHandle->ops, NULL, config.padding, CAM_QCOM_FEATURE_NONE, this, inputChHandle);
+            mChannelHandle, mCameraHandle->ops, NULL, config.padding,
+            CAM_QCOM_FEATURE_NONE, this, inputChHandle);
     if (NULL == pChannel) {
         ALOGE("%s: no mem for reprocess channel", __func__);
         return NULL;
@@ -9208,4 +9268,46 @@
             height > (uint32_t)max_viewfinder_size.height);
 }
 
+/*===========================================================================
+ * FUNCTION   : setBundleInfo
+ *
+ * DESCRIPTION: Set bundle info for all streams that are bundle.
+ *
+ * PARAMETERS : None
+ *
+ * RETURN     : NO_ERROR on success
+ *              Error codes on failure
+ *==========================================================================*/
+int32_t QCamera3HardwareInterface::setBundleInfo()
+{
+    int32_t rc = NO_ERROR;
+
+    if (mChannelHandle) {
+        cam_bundle_config_t bundleInfo;
+        memset(&bundleInfo, 0, sizeof(bundleInfo));
+        rc = mCameraHandle->ops->get_bundle_info(
+                mCameraHandle->camera_handle, mChannelHandle, &bundleInfo);
+        if (rc != NO_ERROR) {
+            ALOGE("%s: get_bundle_info failed", __func__);
+            return rc;
+        }
+        if (mAnalysisChannel) {
+            mAnalysisChannel->setBundleInfo(bundleInfo);
+        }
+        if (mSupportChannel) {
+            mSupportChannel->setBundleInfo(bundleInfo);
+        }
+        for (List<stream_info_t *>::iterator it = mStreamInfo.begin();
+                it != mStreamInfo.end(); it++) {
+            QCamera3Channel *channel = (QCamera3Channel *)(*it)->stream->priv;
+            channel->setBundleInfo(bundleInfo);
+        }
+        if (mRawDumpChannel) {
+            mRawDumpChannel->setBundleInfo(bundleInfo);
+        }
+    }
+
+    return rc;
+}
+
 }; //end namespace qcamera
diff --git a/QCamera2/HAL3/QCamera3HWI.h b/QCamera2/HAL3/QCamera3HWI.h
index fd1ddd8..aa841ae 100644
--- a/QCamera2/HAL3/QCamera3HWI.h
+++ b/QCamera2/HAL3/QCamera3HWI.h
@@ -267,6 +267,8 @@
     bool isOnEncoder(const cam_dimension_t max_viewfinder_size,
             uint32_t width, uint32_t height);
 
+    int32_t setBundleInfo();
+
     camera3_device_t   mCameraDevice;
     uint32_t           mCameraId;
     mm_camera_vtbl_t  *mCameraHandle;
@@ -284,6 +286,8 @@
     QCamera3RegularChannel *mDummyBatchChannel;
     QCameraPerfLock m_perfLock;
 
+    uint32_t mChannelHandle;
+
     void saveExifParams(metadata_buffer_t *metadata);
     mm_jpeg_exif_params_t mExifParams;
 
diff --git a/QCamera2/stack/common/cam_types.h b/QCamera2/stack/common/cam_types.h
index 8210788..04a42b7 100644
--- a/QCamera2/stack/common/cam_types.h
+++ b/QCamera2/stack/common/cam_types.h
@@ -53,7 +53,7 @@
 #define MAX_SIZES_CNT 30
 #define MAX_EXP_BRACKETING_LENGTH 32
 #define MAX_ROI 5
-#define MAX_STREAM_NUM_IN_BUNDLE 6
+#define MAX_STREAM_NUM_IN_BUNDLE 8
 #define MAX_NUM_STREAMS          8
 #define CHROMATIX_SIZE 60000
 #define COMMONCHROMATIX_SIZE 45000