openmax: only build for insignal SLSI variant
[GitHub/LineageOS/android_hardware_samsung_slsi_openmax.git] / osal / Exynos_OSAL_Android.cpp
index c2346f3aab7e94c2718cd0615634040c2df5a6b0..4ee57aa026164f4956f7d5cd374c5149c75b4dd8 100644 (file)
@@ -45,8 +45,6 @@
 #include "Exynos_OMX_Baseport.h"
 #include "Exynos_OMX_Basecomponent.h"
 #include "Exynos_OMX_Macros.h"
-#include "Exynos_OMX_Vdec.h"
-#include "Exynos_OMX_Venc.h"
 #include "Exynos_OSAL_Android.h"
 #include "exynos_format.h"
 
@@ -63,6 +61,7 @@ using namespace android;
 extern "C" {
 #endif
 
+static int lockCnt = 0;
 
 OMX_ERRORTYPE Exynos_OSAL_LockANBHandle(
     OMX_IN OMX_U32 handle,
@@ -93,6 +92,17 @@ OMX_ERRORTYPE Exynos_OSAL_LockANBHandle(
     case OMX_SEC_COLOR_FormatNV12Tiled:
         usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
         break;
+    case OMX_COLOR_FormatAndroidOpaque:
+    {
+        OMX_COLOR_FORMATTYPE formatType;
+        formatType = Exynos_OSAL_GetANBColorFormat((OMX_U32)priv_hnd);
+        if ((formatType == OMX_COLOR_FormatYUV420SemiPlanar) ||
+            (formatType == OMX_SEC_COLOR_FormatNV12Tiled))
+            usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
+        else
+            usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_HW_VIDEO_ENCODER;
+    }
+        break;
     default:
         usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
         break;
@@ -103,6 +113,8 @@ OMX_ERRORTYPE Exynos_OSAL_LockANBHandle(
         ret = OMX_ErrorUndefined;
         goto EXIT;
     }
+    lockCnt++;
+    Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s: lockCnt:%d", __func__, lockCnt);
 
 #ifdef USE_DMA_BUF
     vplanes[0].fd = priv_hnd->fd;
@@ -139,6 +151,8 @@ OMX_ERRORTYPE Exynos_OSAL_UnlockANBHandle(OMX_IN OMX_U32 handle)
         ret = OMX_ErrorUndefined;
         goto EXIT;
     }
+    lockCnt--;
+    Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s: lockCnt:%d", __func__, lockCnt);
 
     Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s: buffer unlocked: 0x%x", __func__, handle);
 
@@ -353,6 +367,9 @@ OMX_ERRORTYPE Exynos_OSAL_GetANBParameter(
          * modifications since currently not defined what the 'nUsage' is for.
          */
         pANBParams->nUsage |= (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP);
+#if defined(USE_IMPROVED_BUFFER) && !defined(USE_CSC_HW)
+        pANBParams->nUsage |= (GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
+#endif
     }
         break;
 
@@ -412,7 +429,6 @@ OMX_ERRORTYPE Exynos_OSAL_SetANBParameter(
     switch (nIndex) {
     case OMX_IndexParamEnableAndroidBuffers:
     {
-        EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
         EnableAndroidNativeBuffersParams *pANBParams = (EnableAndroidNativeBuffersParams *) ComponentParameterStructure;
         OMX_U32 portIndex = pANBParams->nPortIndex;
         EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
@@ -436,21 +452,29 @@ OMX_ERRORTYPE Exynos_OSAL_SetANBParameter(
             goto EXIT;
         }
 
-        /* ANB and DPB Buffer Sharing */
         pExynosPort->bIsANBEnabled = pANBParams->enable;
+
+#ifdef USE_ANB_OUTBUF_SHARE
+         /* ANB and DPB Buffer Sharing */
         if ((portIndex == OUTPUT_PORT_INDEX) &&
             (pExynosPort->bIsANBEnabled == OMX_TRUE) &&
             ((pExynosPort->bufferProcessType & BUFFER_ANBSHARE) == BUFFER_ANBSHARE)) {
             pExynosPort->bufferProcessType = BUFFER_SHARE;
             pExynosPort->portDefinition.format.video.eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatNV12Tiled;
-            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "OMX_IndexParamEnableAndroidBuffers & bufferProcessType change to BUFFER_SHARE");
+            Exynos_OSAL_Log(EXYNOS_LOG_INFO, "output buffer sharing mode is on");
         }
+#else
+        if ((portIndex == OUTPUT_PORT_INDEX) &&
+            (pExynosPort->bufferProcessType & BUFFER_COPY)) {
+            pExynosPort->bufferProcessType = BUFFER_COPY;
+            pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+        }
+#endif
     }
         break;
 
     case OMX_IndexParamUseAndroidNativeBuffer:
     {
-        EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
         UseAndroidNativeBufferParams *pANBParams = (UseAndroidNativeBufferParams *) ComponentParameterStructure;
         OMX_U32 portIndex = pANBParams->nPortIndex;
         EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
@@ -503,7 +527,6 @@ OMX_ERRORTYPE Exynos_OSAL_SetANBParameter(
 
     case OMX_IndexParamStoreMetaDataBuffer:
     {
-        EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;;
         StoreMetaDataInBuffersParams *pANBParams = (StoreMetaDataInBuffersParams *) ComponentParameterStructure;
         OMX_U32 portIndex = pANBParams->nPortIndex;
         EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
@@ -528,7 +551,6 @@ OMX_ERRORTYPE Exynos_OSAL_SetANBParameter(
         }
 
         pExynosPort->bStoreMetaData = pANBParams->bStoreMetaData;
-        pVideoEnc->bFirstInput = OMX_TRUE;
     }
         break;
 
@@ -601,6 +623,24 @@ EXIT:
     return ret;
 }
 
+OMX_ERRORTYPE Exynos_OSAL_SetPrependSPSPPSToIDR(
+    OMX_PTR pComponentParameterStructure,
+    OMX_PTR pbPrependSpsPpsToIdr)
+{
+    OMX_ERRORTYPE                    ret        = OMX_ErrorNone;
+    PrependSPSPPSToIDRFramesParams  *pANBParams = (PrependSPSPPSToIDRFramesParams *)pComponentParameterStructure;
+    ret = Exynos_OMX_Check_SizeVersion(pANBParams, sizeof(PrependSPSPPSToIDRFramesParams));
+    if (ret != OMX_ErrorNone) {
+        Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: Exynos_OMX_Check_SizeVersion(PrependSPSPPSToIDRFramesParams) is failed", __func__);
+        goto EXIT;
+    }
+
+    (*((OMX_BOOL *)pbPrependSpsPpsToIdr)) = pANBParams->bEnable;
+
+EXIT:
+    return ret;
+}
+
 OMX_COLOR_FORMATTYPE Exynos_OSAL_Hal2OMXPixelFormat(
     unsigned int hal_format)
 {
@@ -618,7 +658,7 @@ OMX_COLOR_FORMATTYPE Exynos_OSAL_Hal2OMXPixelFormat(
     case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
         omx_format = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatNV12Tiled;
         break;
-    case HAL_PIXEL_FORMAT_ARGB888:
+    case HAL_PIXEL_FORMAT_RGBA_8888:
         omx_format = OMX_COLOR_Format32bitARGB8888;
         break;
     default:
@@ -646,7 +686,7 @@ unsigned int Exynos_OSAL_OMX2HalPixelFormat(
         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED;
         break;
     case OMX_COLOR_Format32bitARGB8888:
-        hal_format = HAL_PIXEL_FORMAT_ARGB888;
+        hal_format = HAL_PIXEL_FORMAT_RGBA_8888;
         break;
     default:
         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;