Camera3: Use ZSL size for Picture Channel override

-Use ZSL stream size for overriding Picture Non ZSL
 fallback stream
-Extend usage of support channel to usecases where
 no PP streams present

Change-Id: I11b6d41976a8b4ec47619533f81d0bf4a7951970
diff --git a/camera/QCamera2/HAL3/QCamera3HWI.cpp b/camera/QCamera2/HAL3/QCamera3HWI.cpp
index 88e7f06..8137d80 100644
--- a/camera/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/camera/QCamera2/HAL3/QCamera3HWI.cpp
@@ -729,9 +729,23 @@
  * RETURN     : Boolen true/false decision
  *
  *==========================================================================*/
-bool QCamera3HardwareInterface::isSupportChannelNeeded(camera3_stream_configuration_t *streamList)
+bool QCamera3HardwareInterface::isSupportChannelNeeded(camera3_stream_configuration_t *streamList,
+        size_t numStreamsOnEncoder, bool bUseCommonFeatureMask,uint32_t commonFeatureMask)
 {
     uint32_t i;
+    uint32_t numOutputStreams = 0;
+
+    /* Check for condition where PProc pipeline does not have any streams*/
+    for (i=0; i<streamList->num_streams; i++) {
+        if (streamList->streams[i]->stream_type != CAMERA3_STREAM_INPUT) {
+            numOutputStreams++;
+        }
+    }
+    if (numStreamsOnEncoder == numOutputStreams &&
+            bUseCommonFeatureMask &&
+            commonFeatureMask == CAM_QCOM_FEATURE_NONE) {
+        return true;
+    }
 
     /* Dummy stream needed if only raw or jpeg streams present */
     for (i = 0;i < streamList->num_streams;i++) {
@@ -1038,7 +1052,8 @@
     }
 
 
-    if (isSupportChannelNeeded(streamList)) {
+    if (isSupportChannelNeeded(streamList, numStreamsOnEncoder, bUseCommonFeatureMask,
+            commonFeatureMask)) {
         mSupportChannel = new QCamera3SupportChannel(
                 mCameraHandle->camera_handle,
                 mCameraHandle->ops,
@@ -1109,10 +1124,16 @@
                   }
               }
               if (isZsl) {
-                  stream_config_info.stream_sizes[stream_config_info.num_streams].width =
-                          gCamCapability[mCameraId]->active_array_size.width;
-                  stream_config_info.stream_sizes[stream_config_info.num_streams].height =
-                          gCamCapability[mCameraId]->active_array_size.height;
+                  if (zslStream) {
+                      stream_config_info.stream_sizes[stream_config_info.num_streams].width =
+                              zslStream->width;
+                      stream_config_info.stream_sizes[stream_config_info.num_streams].height =
+                              zslStream->height;
+                  } else {
+                      ALOGE("%s: Error, No ZSL stream identified",__func__);
+                      pthread_mutex_unlock(&mMutex);
+                      return -EINVAL;
+                  }
               } else if (m_bIs4KVideo) {
                   stream_config_info.stream_sizes[stream_config_info.num_streams].width = videoWidth;
                   stream_config_info.stream_sizes[stream_config_info.num_streams].height = videoHeight;
diff --git a/camera/QCamera2/HAL3/QCamera3HWI.h b/camera/QCamera2/HAL3/QCamera3HWI.h
index 8f72d99..fa16ac4 100644
--- a/camera/QCamera2/HAL3/QCamera3HWI.h
+++ b/camera/QCamera2/HAL3/QCamera3HWI.h
@@ -226,7 +226,8 @@
     int queueReprocMetadata(metadata_buffer_t *metadata);
     void extractJpegMetadata(CameraMetadata& jpegMetadata,
             const camera3_capture_request_t *request);
-    bool isSupportChannelNeeded(camera3_stream_configuration_t *streamList);
+    bool isSupportChannelNeeded(camera3_stream_configuration_t *streamList,
+        size_t numStreamsOnEncoder, bool bUseCommonFeatureMask,uint32_t commonFeatureMask);
 public:
     cam_dimension_t calcMaxJpegDim();
     bool needOnlineRotation();