From c3fb36ed7a4d3d0a5a54f32b1113894651d3b9fe Mon Sep 17 00:00:00 2001 From: Greg Hackmann Date: Mon, 14 Jan 2013 15:30:24 -0800 Subject: [PATCH] csc: allow compiling with multiple HW types Once G2D support is added, the same binary should be usable for either Gscaler or G2D. The HW type is controlled through the new property CSC_HW_PROPERTY_HW_TYPE. Also return an error if any hardware properties are set after the device is already opened. This didn't work before and should never happen, but it's worth adding a check just in case. Change-Id: I6d3fab4e777395a7e14a1f54353100902c76f75e Signed-off-by: Greg Hackmann --- .../video/dec/h264/Exynos_OMX_H264dec.c | 1 + .../component/video/enc/Exynos_OMX_Venc.c | 1 + libcamera2/ExynosCameraHWInterface2.cpp | 2 ++ libcsc/csc.c | 20 +++++++++---------- libcsc/csc.h | 8 ++++++++ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c b/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c index 495fcae..3a831f0 100644 --- a/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c +++ b/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c @@ -1524,6 +1524,7 @@ OMX_ERRORTYPE Exynos_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) if (pVideoDec->bDRMPlayerMode == OMX_TRUE) { pVideoDec->csc_handle = csc_init(CSC_METHOD_HW); csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_FIXED_NODE, 2); + csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_HW_TYPE, CSC_HW_TYPE_GSCALER); csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_MODE_DRM, pVideoDec->bDRMPlayerMode); } else { pVideoDec->csc_handle = csc_init(csc_method); diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c index ca2b6ce..8831608 100644 --- a/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c +++ b/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c @@ -1152,6 +1152,7 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeComponentInit(OMX_IN OMX_HANDLETYPE hCompone pVideoEnc->csc_set_format = OMX_FALSE; #if defined(USE_CSC_GSCALER) csc_set_hw_property(pVideoEnc->csc_handle, CSC_HW_PROPERTY_FIXED_NODE, CSC_GSCALER_IDX); + csc_set_hw_property(pVideoEnc->csc_handle, CSC_HW_PROPERTY_HW_TYPE, CSC_HW_TYPE_GSCALER); #endif pExynosComponent->bMultiThreadProcess = OMX_TRUE; diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp index d6174bb..5dee2e7 100644 --- a/libcamera2/ExynosCameraHWInterface2.cpp +++ b/libcamera2/ExynosCameraHWInterface2.cpp @@ -1026,11 +1026,13 @@ ExynosCameraHWInterface2::ExynosCameraHWInterface2(int cameraId, camera2_device_ if (m_exynosPictureCSC == NULL) ALOGE("ERR(%s): csc_init() fail", __FUNCTION__); csc_set_hw_property(m_exynosPictureCSC, CSC_HW_PROPERTY_FIXED_NODE, PICTURE_GSC_NODE_NUM); + csc_set_hw_property(m_exynosPictureCSC, CSC_HW_PROPERTY_HW_TYPE, CSC_HW_TYPE_GSCALER); m_exynosVideoCSC = csc_init(cscMethod); if (m_exynosVideoCSC == NULL) ALOGE("ERR(%s): csc_init() fail", __FUNCTION__); csc_set_hw_property(m_exynosVideoCSC, CSC_HW_PROPERTY_FIXED_NODE, VIDEO_GSC_NODE_NUM); + csc_set_hw_property(m_exynosVideoCSC, CSC_HW_PROPERTY_HW_TYPE, CSC_HW_TYPE_GSCALER); m_setExifFixedAttribute(); diff --git a/libcsc/csc.c b/libcsc/csc.c index 385223c..11c5b1c 100644 --- a/libcsc/csc.c +++ b/libcsc/csc.c @@ -64,11 +64,6 @@ typedef enum _CSC_PLANE { CSC_V_PLANE = 2 } CSC_PLANE; -typedef enum _CSC_HW_TYPE { - CSC_HW_TYPE_FIMC = 0, - CSC_HW_TYPE_GSCALER -} CSC_HW_TYPE; - typedef struct _CSC_FORMAT { unsigned int width; unsigned int height; @@ -331,12 +326,6 @@ static CSC_ERRORCODE csc_init_hw( csc_handle = (CSC_HANDLE *)handle; if (csc_handle->csc_method == CSC_METHOD_HW) { -#ifdef ENABLE_FIMC - csc_handle->csc_hw_type = CSC_HW_TYPE_FIMC; -#endif -#ifdef ENABLE_GSCALER - csc_handle->csc_hw_type = CSC_HW_TYPE_GSCALER; -#endif switch (csc_handle->csc_hw_type) { #ifdef ENABLE_FIMC case CSC_HW_TYPE_FIMC: @@ -545,6 +534,12 @@ CSC_ERRORCODE csc_set_hw_property( return CSC_ErrorNotInit; csc_handle = (CSC_HANDLE *)handle; + + if (csc_handle->csc_hw_handle) { + ALOGE("%s:: cannot set hw property after hw is already initialized", __func__); + return CSC_ErrorUnsupportFormat; + } + switch (property) { case CSC_HW_PROPERTY_FIXED_NODE: csc_handle->hw_property.fixed_node = value; @@ -552,6 +547,9 @@ CSC_ERRORCODE csc_set_hw_property( case CSC_HW_PROPERTY_MODE_DRM: csc_handle->hw_property.mode_drm = value; break; + case CSC_HW_PROPERTY_HW_TYPE: + csc_handle->csc_hw_type = value; + break; default: ALOGE("%s:: not supported hw property", __func__); ret = CSC_ErrorUnsupportFormat; diff --git a/libcsc/csc.h b/libcsc/csc.h index f454f96..e580bd5 100644 --- a/libcsc/csc.h +++ b/libcsc/csc.h @@ -53,8 +53,16 @@ typedef enum _CSC_METHOD { typedef enum _CSC_HW_PROPERTY_TYPE { CSC_HW_PROPERTY_FIXED_NODE = 0, CSC_HW_PROPERTY_MODE_DRM, + CSC_HW_PROPERTY_HW_TYPE, } CSC_HW_PROPERTY_TYPE; +typedef enum _CSC_HW_TYPE { + CSC_HW_TYPE_NONE = 0, + CSC_HW_TYPE_FIMC, + CSC_HW_TYPE_GSCALER, + CSC_HW_TYPE_G2D, +} CSC_HW_TYPE; + /* * change hal pixel format to omx pixel format * -- 2.20.1