Merge "mm-video-v4l2: vdec: udpate error based on return value"
diff --git a/mm-video-v4l2/vidc/vdec/src/omx_vdec_v4l2.cpp b/mm-video-v4l2/vidc/vdec/src/omx_vdec_v4l2.cpp
index 260081e..ab2bbc4 100644
--- a/mm-video-v4l2/vidc/vdec/src/omx_vdec_v4l2.cpp
+++ b/mm-video-v4l2/vidc/vdec/src/omx_vdec_v4l2.cpp
@@ -7181,8 +7181,7 @@
             return OMX_ErrorHardware;
         }
         drv_ctx.ip_buf.mincount = control.value;
-        if (drv_ctx.ip_buf.actualcount < control.value)
-            drv_ctx.ip_buf.actualcount = control.value;
+        drv_ctx.ip_buf.actualcount = control.value;
 
         portDefn->eDir =  OMX_DirInput;
         portDefn->nBufferCountActual = drv_ctx.ip_buf.actualcount;
diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
index 906a0be..56aa24f 100644
--- a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
+++ b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
@@ -2235,9 +2235,49 @@
                         pParam->sAspects.mTransfer = ColorAspects::TransferSMPTE170M;
                         pParam->sAspects.mMatrixCoeffs = ColorAspects::MatrixBT601_6;
                     } else {
-                        // For IMPLEMENTATION_DEFINED (or anything else), stick to client's defaults.
-                        DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: use client-default for format=%x",
-                                pParam->nPixelFormat);
+                         DEBUG_PRINT_INFO("get_config (dataspace changed): dataspace=0x%x", pParam->nDataSpace);
+                         if (pParam->nDataSpace == HAL_DATASPACE_JFIF || pParam->nDataSpace == HAL_DATASPACE_V0_JFIF) {
+                             DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: for HAL_DATASPACE_JFIF");
+                             pParam->sAspects.mPrimaries = ColorAspects::PrimariesBT601_6_625;
+                             pParam->sAspects.mRange = ColorAspects::RangeFull;
+                             pParam->sAspects.mTransfer = ColorAspects::TransferSMPTE170M;
+                             pParam->sAspects.mMatrixCoeffs = ColorAspects::MatrixBT601_6;
+                         } else if (pParam->nDataSpace == HAL_DATASPACE_BT601_525 || pParam->nDataSpace == HAL_DATASPACE_V0_BT601_525) {
+                             DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: for HAL_DATASPACE_BT601_525");
+                             pParam->sAspects.mPrimaries = ColorAspects::PrimariesBT601_6_525;
+                             pParam->sAspects.mRange = ColorAspects::RangeLimited;
+                             pParam->sAspects.mTransfer = ColorAspects::TransferSMPTE170M;
+                             pParam->sAspects.mMatrixCoeffs = ColorAspects::MatrixBT601_6;
+                         } else if (pParam->nDataSpace == HAL_DATASPACE_BT601_625 || pParam->nDataSpace == HAL_DATASPACE_V0_BT601_625) {
+                             DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: for HAL_DATASPACE_BT601_625");
+                             pParam->sAspects.mPrimaries = ColorAspects::PrimariesBT601_6_625;
+                             pParam->sAspects.mRange = ColorAspects::RangeLimited;
+                             pParam->sAspects.mTransfer = ColorAspects::TransferSMPTE170M;
+                             pParam->sAspects.mMatrixCoeffs = ColorAspects::MatrixBT601_6;
+                         } else if (pParam->nDataSpace == HAL_DATASPACE_BT709 || pParam->nDataSpace == HAL_DATASPACE_V0_BT709) {
+                             DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: for HAL_DATASPACE_BT709");
+                             pParam->sAspects.mPrimaries = ColorAspects::PrimariesBT709_5;
+                             pParam->sAspects.mRange = ColorAspects::RangeLimited;
+                             pParam->sAspects.mTransfer = ColorAspects::TransferSMPTE170M;
+                             pParam->sAspects.mMatrixCoeffs = ColorAspects::MatrixBT709_5;
+                         } else if (pParam->nDataSpace == HAL_DATASPACE_BT2020) {
+                             DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: for HAL_DATASPACE_BT2020");
+                             pParam->sAspects.mPrimaries = ColorAspects::PrimariesBT2020;
+                             pParam->sAspects.mRange = ColorAspects::RangeFull;
+                             pParam->sAspects.mTransfer = ColorAspects::TransferSMPTE170M;
+                             pParam->sAspects.mMatrixCoeffs = ColorAspects::MatrixBT2020;
+                         } else if (pParam->nDataSpace == (HAL_DATASPACE_STANDARD_BT2020|HAL_DATASPACE_TRANSFER_HLG|HAL_DATASPACE_RANGE_LIMITED)) {
+                             //For SONY HDR
+                             DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: for HAL_DATASPACE_STANDARD_BT2020|HAL_DATASPACE_TRANSFER_HLG|HAL_DATASPACE_RANGE_LIMITED");
+                             pParam->sAspects.mPrimaries = ColorAspects::PrimariesBT2020;
+                             pParam->sAspects.mRange = ColorAspects::RangeLimited;
+                             pParam->sAspects.mTransfer = ColorAspects::TransferHLG;
+                             pParam->sAspects.mMatrixCoeffs = ColorAspects::MatrixBT2020;
+                         } else {
+                             // Stick to client's defaults.
+                             DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: use client-default for format=%x",
+                             pParam->nPixelFormat);
+                         }
                     }
                     print_debug_color_aspects(&(pParam->sAspects), "get_config (dataspace changed) recommended");
                 } else {
diff --git a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
index 2cbfa43..0e080ba 100644
--- a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
+++ b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
@@ -4272,6 +4272,10 @@
 bool venc_dev::venc_cvp_enable(private_handle_t *handle)
 {
     cvpMetadata.size = 0;
+    if (temporal_layers_config.nMaxLayers > 1) {
+        DEBUG_PRINT_INFO("venc_cvp_enable: disabling CVP as max layers %u", temporal_layers_config.nMaxLayers);
+        return true;
+    }
     if (getMetaData(handle, GET_CVP_METADATA, &cvpMetadata) == 0) {
         if (cvpMetadata.size == CVP_METADATA_SIZE) {
             struct v4l2_control control;