From d2e1446d81725c351dc73a03b397ce043fb18452 Mon Sep 17 00:00:00 2001 From: Meizu OpenSource Date: Mon, 15 Aug 2016 10:19:42 +0800 Subject: first commit --- include/linux/vcodec/bits_api.h | 319 ++++++ include/linux/vcodec/hal_api.h | 244 +++++ include/linux/vcodec/hal_types_private.h | 34 + include/linux/vcodec/hal_types_public.h | 65 ++ include/linux/vcodec/hevcd_if.h | 93 ++ include/linux/vcodec/kernel/val_log.h | 65 ++ include/linux/vcodec/libmtk_cipher_export.h | 86 ++ include/linux/vcodec/user/val_log.h | 74 ++ include/linux/vcodec/val_api_private.h | 72 ++ include/linux/vcodec/val_api_public.h | 391 +++++++ include/linux/vcodec/val_oal.h | 1331 +++++++++++++++++++++++ include/linux/vcodec/val_types_private.h | 256 +++++ include/linux/vcodec/val_types_public.h | 573 ++++++++++ include/linux/vcodec/val_vcodec_utility.h | 98 ++ include/linux/vcodec/vcodec_OAL_v2.h | 508 +++++++++ include/linux/vcodec/vcodec_customization.h | 19 + include/linux/vcodec/vcodec_dec_demuxer_if_v2.h | 115 ++ include/linux/vcodec/vcodec_if_v2.h | 1034 ++++++++++++++++++ include/linux/vcodec/vcodec_log.h | 106 ++ include/linux/vcodec/vdec_drv_base.h | 84 ++ include/linux/vcodec/vdec_drv_if_dep.h | 159 +++ include/linux/vcodec/vdec_drv_if_private.h | 432 ++++++++ include/linux/vcodec/vdec_drv_if_public.h | 827 ++++++++++++++ include/linux/vcodec/venc_drv_base.h | 82 ++ include/linux/vcodec/venc_drv_if_dep.h | 77 ++ include/linux/vcodec/venc_drv_if_private.h | 153 +++ include/linux/vcodec/venc_drv_if_public.h | 900 +++++++++++++++ include/linux/vcodec/video_custom_sp.h | 142 +++ 28 files changed, 8339 insertions(+) create mode 100644 include/linux/vcodec/bits_api.h create mode 100644 include/linux/vcodec/hal_api.h create mode 100644 include/linux/vcodec/hal_types_private.h create mode 100644 include/linux/vcodec/hal_types_public.h create mode 100644 include/linux/vcodec/hevcd_if.h create mode 100644 include/linux/vcodec/kernel/val_log.h create mode 100644 include/linux/vcodec/libmtk_cipher_export.h create mode 100644 include/linux/vcodec/user/val_log.h create mode 100644 include/linux/vcodec/val_api_private.h create mode 100644 include/linux/vcodec/val_api_public.h create mode 100644 include/linux/vcodec/val_oal.h create mode 100644 include/linux/vcodec/val_types_private.h create mode 100644 include/linux/vcodec/val_types_public.h create mode 100644 include/linux/vcodec/val_vcodec_utility.h create mode 100644 include/linux/vcodec/vcodec_OAL_v2.h create mode 100644 include/linux/vcodec/vcodec_customization.h create mode 100644 include/linux/vcodec/vcodec_dec_demuxer_if_v2.h create mode 100644 include/linux/vcodec/vcodec_if_v2.h create mode 100644 include/linux/vcodec/vcodec_log.h create mode 100644 include/linux/vcodec/vdec_drv_base.h create mode 100644 include/linux/vcodec/vdec_drv_if_dep.h create mode 100644 include/linux/vcodec/vdec_drv_if_private.h create mode 100644 include/linux/vcodec/vdec_drv_if_public.h create mode 100644 include/linux/vcodec/venc_drv_base.h create mode 100644 include/linux/vcodec/venc_drv_if_dep.h create mode 100644 include/linux/vcodec/venc_drv_if_private.h create mode 100644 include/linux/vcodec/venc_drv_if_public.h create mode 100644 include/linux/vcodec/video_custom_sp.h (limited to 'include/linux/vcodec') diff --git a/include/linux/vcodec/bits_api.h b/include/linux/vcodec/bits_api.h new file mode 100644 index 000000000..2afec58cb --- /dev/null +++ b/include/linux/vcodec/bits_api.h @@ -0,0 +1,319 @@ +/** + * @file + * bits_api.h + * + * @par Project: + * Video + * + * @par Description: + * bitstream parsing utility API for external use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + + +#ifndef _BITS_API_H_ +#define _BITS_API_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" +#include "hal_api.h" + +typedef VAL_UINT32_T(*fgPrepare32FN)(VAL_HANDLE_T *a_phBitsHandle); ///< fgPrepare32FN definition + +/** + * @par Structure + * VBITS_HANDLE_T + * @par Description + * This is a parameter for bitstream parsing utility related function + */ +typedef struct __VBITS_HANDLE_T +{ + VAL_HANDLE_T hHALHandle; ///< HAL Handle + VAL_HANDLE_T hVALHandle; ///< VAL Handle + VAL_MEM_ADDR_T BitsStart; ///< Bits Start + VAL_MEMORY_T rHandleMem; ///< Handle memory + VAL_UINT32_T nReadingMode; ///< 0 for software, 1 for mmap, 2 for hardware + VAL_ULONG_T StartAddr; ///< used for software mode fast access + VAL_ULONG_T nSize; ///< Size + VAL_UINT32_T nBitCnt; ///< bits count + VAL_UINT32_T nZeroCnt; ///< zero count + VAL_UINT32_T Cur32Bits; ///< current 32 bits + VAL_UINT32_T CurBitCnt; ///< current bits count + VAL_UINT32_T n03RemoveCount; ///< 03 Remove Count + VAL_UINT32_T n03CountBit; ///< 03 Count Bit + VAL_INT32_T n03FirstIndex; ///< 03 First Index + VAL_INT32_T n03SecondIndex; ///< 03 Second Index + VAL_UINT32_T n03RemoveIgnore; ///< 03 Remove Ignore + VAL_BOOL_T bFirstCheck; ///< First Check + VAL_BOOL_T bEverRemove; ///< Ever Remove + VAL_BOOL_T bIgnoreByBS; ///< Ignore By BS + VAL_BOOL_T bEOF; ///< EOF + fgPrepare32FN Prepare32Bits; ///< Prepare 32 Bits + VAL_DRIVER_TYPE_T vFormat; ///< Format + VAL_UINT32_T value; ///< value +} VBITS_HANDLE_T; + + +/** + * @par Enumeration + * VBITS_READTYPE_T + * @par Description + * This is the item used for bits read type + */ +typedef enum VBITS_READTYPE_T +{ + VBITS_SOFTWARE = 0, ///< software + VBITS_MMAP, ///< mmap + VBITS_HARDWARE, ///< hardware + VBITS_MAX ///< MAX value +} VBITS_READTYPE_T; +/*============================================================================= + * Function Declaration + *===========================================================================*/ + + +/** + * @par Function + * eBufEnable + * @par Description + * The hal init & HW enable function + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * hHALHandle [IN/OUT] The hal handle + * @param + * nMode [IN] VBITS_READTYPE_T + * @param + * vFormat [IN] VAL_DRIVER_TYPE_T + * @par Returns + * VAL_UINT32_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed + */ +VAL_UINT32_T eBufEnable(VAL_HANDLE_T *a_phBitsHandle, VAL_HANDLE_T hHALHandle, VAL_UINT32_T nMode, VAL_DRIVER_TYPE_T vFormat); + + +/** + * @par Function + * eBufEnable + * @par Description + * The HW disable function + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * hHALHandle [IN/OUT] The hal handle + * @param + * nMode [IN] VBITS_READTYPE_T + * @param + * vFormat [IN] VAL_DRIVER_TYPE_T + * @par Returns + * VAL_UINT32_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed + */ +VAL_UINT32_T eBufDisable(VAL_HANDLE_T *a_phBitsHandle, VAL_HANDLE_T hHALHandle, VAL_UINT32_T nMode, VAL_DRIVER_TYPE_T vFormat); + + +/** + * @par Function + * eBufInit + * @par Description + * The common init function + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * hVALHandle [IN/OUT] The val handle + * @param + * hHALHandle [IN/OUT] The hal handle + * @param + * rBufAddrStart [IN] The buffer start address + * @param + * nMode [IN] VBITS_READTYPE_T + * @param + * vFormat [IN] VAL_DRIVER_TYPE_T + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return others if failed + */ +VAL_RESULT_T eBufInit(VAL_HANDLE_T *a_phBitsHandle, VAL_HANDLE_T hVALHandle, VAL_HANDLE_T hHALHandle, VAL_MEM_ADDR_T rBufAddrStart, VAL_UINT32_T nMode, VAL_DRIVER_TYPE_T vFormat); + + +/** + * @par Function + * eBufDeinit + * @par Description + * The common deinit function + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return others if failed + */ +VAL_RESULT_T eBufDeinit(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetBitCnt + * @par Description + * The function is used to get current bit count + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_UINT32_T, return current bit count + */ +VAL_UINT32_T eBufGetBitCnt(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetBits + * @par Description + * The function is used to get current bits by numBits + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * numBits [IN] The number bits + * @par Returns + * VAL_UINT32_T, return current bits by numBits + */ +VAL_UINT32_T eBufGetBits(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T numBits); + + +/** + * @par Function + * eBufNextBits + * @par Description + * The function is used to show current bits by numBits + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * numBits [IN] The number bits + * @par Returns + * VAL_UINT32_T, return current bits by numBits + */ +VAL_UINT32_T eBufNextBits(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T numBits); + + +/** + * @par Function + * eBufGetUEGolomb + * @par Description + * The function is used to get unsigned EGolomb bits + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_UINT32_T, return current unsigned EGolomb bits + */ +VAL_UINT32_T eBufGetUEGolomb(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetSEGolomb + * @par Description + * The function is used to get signed EGolomb bits + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_INT32_T, return current signed EGolomb bits + */ +VAL_INT32_T eBufGetSEGolomb(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufCheckEOF + * @par Description + * The function is used to check EOF bitstream + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_BOOL_T, return EOF or not + */ +VAL_BOOL_T eBufCheckEOF(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetBufSize + * @par Description + * The function is used to get buffer size + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_BOOL_T, return buffer size + */ +VAL_UINT32_T eBufGetBufSize(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * NextBytesAlignment + * @par Description + * The function is used to jump bitstream pointer to next bytesalignment + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * nBytesAlignment [IN] BytesAlignment + * @par Returns + * void + */ +void NextBytesAlignment(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T nBytesAlignment); + + +/** + * @par Function + * eBufInitBS + * @par Description + * The function is used to init bit stream + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * cmd_queue [IN] command queue + * @param + * pIndex [IN] command queue index + * @par Returns + * VAL_BOOL_T, return VAL_TRUE if success, return VAL_FALSE if failed + */ +VAL_BOOL_T eBufInitBS(VAL_HANDLE_T *a_phBitsHandle, P_VCODEC_DRV_CMD_T cmd_queue, VAL_UINT32_T *pIndex); + + +/** + * @par Function + * eBufGetPAddr + * @par Description + * The function is used to get physical address + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @par Returns + * VAL_UINT32_T, return physical address + */ +VAL_UINT32_T eBufGetPAddr(VAL_HANDLE_T *a_phBitsHandle); + + +/** + * @par Function + * eBufGetPAddr + * @par Description + * The function is used to re init + * @param + * a_phBitsHandle [IN/OUT] The bits handle + * @param + * nBytes [IN] The Bytes + * @param + * nBits [IN] The Bits + * @par Returns + * VAL_BOOL_T, return VAL_TRUE if success, return VAL_FALSE if failed + */ +VAL_BOOL_T eBufReInite(VAL_HANDLE_T *a_phBitsHandle, VAL_UINT32_T nBytes, VAL_UINT32_T nBits); + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VAL_API_H_ diff --git a/include/linux/vcodec/hal_api.h b/include/linux/vcodec/hal_api.h new file mode 100644 index 000000000..60260f5cc --- /dev/null +++ b/include/linux/vcodec/hal_api.h @@ -0,0 +1,244 @@ +/** + * @file + * hal_api.h + * + * @par Project: + * Video + * + * @par Description: + * Hardware Abstraction Layer API for external use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _HAL_API_H_ +#define _HAL_API_H_ +#include "val_types_public.h" + +#define DumpReg__ ///< Dump Reg for debug +#ifdef DumpReg__ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define ADD_QUEUE(queue, index, q_type, q_address, q_offset, q_value, q_mask) \ + { \ + queue[index].type = q_type; \ + queue[index].address = q_address; \ + queue[index].offset = q_offset; \ + queue[index].value = q_value; \ + queue[index].mask = q_mask; \ + index = index + 1; \ + } ///< ADD QUEUE command + + +/** + * @par Enumeration + * HAL_CODEC_TYPE_T + * @par Description + * This is the item used for codec type + */ +typedef enum __HAL_CODEC_TYPE_T +{ + HAL_CODEC_TYPE_VDEC, ///< VDEC + HAL_CODEC_TYPE_VENC, ///< VENC + HAL_CODEC_TYPE_MAX = 0xFFFFFFFF ///< MAX Value +} +HAL_CODEC_TYPE_T; + + +/** + * @par Enumeration + * HAL_CMD_T + * @par Description + * This is the item used for hal command type + */ +typedef enum _HAL_CMD_T +{ + HAL_CMD_SET_CMD_QUEUE, ///< set command queue + HAL_CMD_SET_POWER, ///< set power + HAL_CMD_SET_ISR, ///< set ISR + HAL_CMD_GET_CACHE_CTRL_ADDR, ///< get cahce control address + HAL_CMD_MAX = 0xFFFFFFFF ///< MAX value +} HAL_CMD_T; + + +/** + * @par Enumeration + * REGISTER_GROUP_T + * @par Description + * This is the item used for register group + */ +typedef enum _REGISTER_GROUP_T +{ + VDEC_SYS, ///< VDEC_SYS + VDEC_MISC, ///< VDEC_MISC + VDEC_VLD, ///< VDEC_VLD + VDEC_VLD_TOP, ///< VDEC_VLD_TOP + VDEC_MC, ///< VDEC_MC + VDEC_AVC_VLD, ///< VDEC_AVC_VLD + VDEC_AVC_MV, ///< VDEC_AVC_MV + VDEC_HEVC_VLD, ///< VDEC_HEVC_VLD + VDEC_HEVC_MV, ///< VDEC_HEVC_MV + VDEC_PP, ///< VDEC_PP + // VDEC_SQT, + VDEC_VP8_VLD, ///< VDEC_VP8_VLD + VDEC_VP6_VLD, ///< VDEC_VP6_VLD + VDEC_VP8_VLD2, ///< VDEC_VP8_VLD2 + VENC_HW_BASE, ///< VENC_HW_BASE + VENC_MP4_HW_BASE, ///< VENC_MP4_HW_BASE + VCODEC_MAX ///< VCODEC_MAX +} REGISTER_GROUP_T; + + +/** + * @par Enumeration + * REGISTER_GROUP_T + * @par Description + * This is the item used for driver command type + */ +typedef enum _VCODEC_DRV_CMD_TYPE +{ + ENABLE_HW_CMD, ///< ENABLE_HW_CMD + DISABLE_HW_CMD, ///< DISABLE_HW_CMD + WRITE_REG_CMD, ///< WRITE_REG_CMD + READ_REG_CMD, ///< READ_REG_CMD + WRITE_SYSRAM_CMD, ///< WRITE_SYSRAM_CMD + READ_SYSRAM_CMD, ///< READ_SYSRAM_CMD + MASTER_WRITE_CMD, ///< MASTER_WRITE_CMD + WRITE_SYSRAM_RANGE_CMD, ///< WRITE_SYSRAM_RANGE_CMD + READ_SYSRAM_RANGE_CMD, ///< READ_SYSRAM_RANGE_CMD + SETUP_ISR_CMD, ///< SETUP_ISR_CMD + WAIT_ISR_CMD, ///< WAIT_ISR_CMD + TIMEOUT_CMD, ///< TIMEOUT_CMD + MB_CMD, ///< MB_CMD + POLL_REG_STATUS_CMD, ///< POLL_REG_STATUS_CMD + END_CMD ///< END_CMD +} VCODEC_DRV_CMD_TYPE; + + +/** + * @par Structure + * P_VCODEC_DRV_CMD_T + * @par Description + * Pointer of VCODEC_DRV_CMD_T + */ +typedef struct __VCODEC_DRV_CMD_T *P_VCODEC_DRV_CMD_T; + + +/** + * @par Structure + * VCODEC_DRV_CMD_T + * @par Description + * driver command information + */ +typedef struct __VCODEC_DRV_CMD_T +{ + VAL_UINT32_T type; ///< type + VAL_ULONG_T address; ///< address + VAL_ULONG_T offset; ///< offset + VAL_ULONG_T value; ///< value + VAL_ULONG_T mask; ///< mask +} VCODEC_DRV_CMD_T; + + +/** + * @par Structure + * HAL_HANDLE_T + * @par Description + * hal handle information + */ +typedef struct _HAL_HANDLE_T_ +{ + VAL_INT32_T fd_vdec; ///< fd_vdec + VAL_INT32_T fd_venc; ///< fd_venc + VAL_MEMORY_T rHandleMem; ///< rHandleMem + VAL_ULONG_T mmap[VCODEC_MAX]; ///< mmap[VCODEC_MAX] + VAL_DRIVER_TYPE_T driverType; ///< driverType + VAL_UINT32_T u4TimeOut; ///< u4TimeOut + VAL_UINT32_T u4FrameCount; ///< u4FrameCount +#ifdef DumpReg__ + FILE *pf_out; ///< pf_out +#endif + VAL_BOOL_T bProfHWTime; ///< bProfHWTime + VAL_UINT64_T u8HWTime[2]; ///< u8HWTime +} HAL_HANDLE_T; + + +/** + * @par Function + * eHalInit + * @par Description + * The init hal driver function + * @param + * a_phHalHandle [IN/OUT] The hal handle + * @param + * a_eHalCodecType [IN] VDEC or VENC + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_INVALID_DRIVER or VAL_RESULT_INVALID_MEMORY if failed + */ +VAL_RESULT_T eHalInit(VAL_HANDLE_T *a_phHalHandle, HAL_CODEC_TYPE_T a_eHalCodecType); + + +/** + * @par Function + * eHalDeInit + * @par Description + * The deinit hal driver function + * @param + * a_phHalHandle [IN/OUT] The hal handle + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return else if failed + */ +VAL_RESULT_T eHalDeInit(VAL_HANDLE_T *a_phHalHandle); + + +/** + * @par Function + * eHalGetMMAP + * @par Description + * The get hw register memory map to vitural address function + * @param + * a_hHalHandle [IN/OUT] The hal handle + * @param + * RegAddr [IN] hw register address + * @par Returns + * VAL_UINT32_T, vitural address of hw register memory mapping + */ +VAL_ULONG_T eHalGetMMAP(VAL_HANDLE_T *a_hHalHandle, VAL_UINT32_T RegAddr); + + +/** + * @par Function + * eHalCmdProc + * @par Description + * The hal command processing function + * @param + * a_hHalHandle [IN/OUT] The hal handle + * @param + * a_eHalCmd [IN] The hal command structure + * @param + * a_pvInParam [IN] The hal input parameter + * @param + * a_pvOutParam [OUT] The hal output parameter + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return else if failed + */ +VAL_RESULT_T eHalCmdProc(VAL_HANDLE_T *a_hHalHandle, HAL_CMD_T a_eHalCmd, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); + + + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _HAL_API_H_ diff --git a/include/linux/vcodec/hal_types_private.h b/include/linux/vcodec/hal_types_private.h new file mode 100644 index 000000000..8d1d0308d --- /dev/null +++ b/include/linux/vcodec/hal_types_private.h @@ -0,0 +1,34 @@ +/** + * @file + * hal_types_private.h + * + * @par Project: + * Video + * + * @par Description: + * Hardware Abstraction Layer Type Definitions + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _HAL_TYPES_PRIVATE_H_ +#define _HAL_TYPES_PRIVATE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_private.h" +#include "hal_types_public.h" + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _HAL_TYPES_PRIVATE_H_ diff --git a/include/linux/vcodec/hal_types_public.h b/include/linux/vcodec/hal_types_public.h new file mode 100644 index 000000000..5bee082b9 --- /dev/null +++ b/include/linux/vcodec/hal_types_public.h @@ -0,0 +1,65 @@ +/** + * @file + * hal_types_public.h + * + * @par Project: + * Video + * + * @par Description: + * Hardware Abstraction Layer Type Definitions + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _HAL_TYPES_PUBLIC_H_ +#define _HAL_TYPES_PUBLIC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" + +/** + * @par Structure + * HAL_POWER_T + * @par Description + * This is a parameter for power related function + */ +typedef struct _HAL_POWER_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_DRIVER_TYPE_T eDriverType; ///< [IN] The driver type + VAL_BOOL_T fgEnable; ///< [IN] Enable or not + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +} HAL_POWER_T; + +/** + * @par Structure + * HAL_ISR_T + * @par Description + * This is a parameter for ISR related function + */ +typedef struct _HAL_ISR_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_DRIVER_TYPE_T eDriverType; ///< [IN] The driver type + VAL_BOOL_T fgRegister; ///< [IN] Register or un-register + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +} HAL_ISR_T; + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _HAL_TYPES_PUBLIC_H_ \ No newline at end of file diff --git a/include/linux/vcodec/hevcd_if.h b/include/linux/vcodec/hevcd_if.h new file mode 100644 index 000000000..fe61ad528 --- /dev/null +++ b/include/linux/vcodec/hevcd_if.h @@ -0,0 +1,93 @@ +#ifndef _HEVC_DECODE_IF_H_ +#define _HEVC_DECODE_IF_H_ + +//#include "hevcd.h" +//#include "hevc_common_if.h" +#include "vcodec_if_v2.h" +#include "vcodec_dec_demuxer_if_v2.h" +#define MAX_DECODE_BUFFERS 15 +#define _FILE_IO_ +//extern int frame_num; +typedef struct +{ + + void (*hevc_pfnMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + IN VCODEC_MEMORY_TYPE_T /* fgCacheable */, + OUT VCODEC_BUFFER_T * /* prBuf */ + ); /* buffer address must cache line align */ + + void (*pfnFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuf */ + ); /* same memory type with malloc */ + +} hevcd_callback_t; + +typedef struct +{ + unsigned char *buffer_origin; + unsigned char *luma; + unsigned char *cb, *cr; + int y_stride, uv_stride; + int width, height; + int ref_count; +} decode_picture_buffer_info_t; + + +typedef struct +{ + unsigned char *start_address; + int length; +} HEVC_ACCESS_UNIT_T; + +#define MAX_ACCESS_UNIT_NUMBER 32 + +typedef struct +{ + HEVC_ACCESS_UNIT_T au_list[MAX_ACCESS_UNIT_NUMBER]; + int au_number; + +} HEVC_DECODE_INP_T; + +typedef struct +{ + unsigned char *y; + unsigned char *u; + unsigned char *v; + + int y_stride; + int uv_stride; + + int width; + int height; +} HEVC_DECODE_PICTURE_T; + +typedef struct +{ + int width; + int height; +} HEVC_PICTURE_INFO_T; + + +VCODEC_DEC_ERROR_T HEVCDecoderGetMemoryRequired(VCODEC_DEC_INPUT_T *prInput, VCODEC_MEMORY_SIZE_T *prMemeorySize, VCODEC_DEC_OUTPUT_BUFFER_PARAM_T *prYUVBufferParameter, OUT VCODEC_MEMORY_TYPE_T *prBitStreamBufferMemType); +VCODEC_DEC_ERROR_T HEVCDecoderGetMemoryRequiredExtend(VCODEC_DEC_INPUT_T *prInput, VCODEC_MEMORY_SIZE_T *prMemeorySize, VCODEC_DEC_OUTPUT_BUFFER_PARAM_T *prYUVBufferParameter, OUT VCODEC_DEC_INPUT_BUFFER_PARAM_T *prBitStreamParam, INOUT void *prExtra); +VCODEC_DEC_ERROR_T HEVCDecoderInitAdapt(IN HANDLE hCodec); +VCODEC_DEC_ERROR_T HEVCDecoderDeInitAdapt(IN HANDLE hCodec); +VCODEC_DEC_ERROR_T HEVCDecoderOpenAdapt(IN HANDLE hDrv , + IN VCODEC_DEC_CALLBACK_T *pfnCallback, + IN void *prOpenSetting, + OUT HANDLE *hCodec + ); +VCODEC_DEC_ERROR_T HEVCDecoderStartAdapt(IN HANDLE hCodec, IN VCODEC_DEC_INPUT_T *prBufferHeader); +VCODEC_DEC_ERROR_T HEVCDecoderCloseAdapt(IN HANDLE hCodec); +VCODEC_DEC_ERROR_T HEVCDecoderGetNextDisplay(IN HANDLE hCodec, OUT VCODEC_DEC_PRIVATE_OUTPUT_T *prPrivateOutput); +VCODEC_DEC_ERROR_T HEVCDecoderGetParameterAdapt(IN HANDLE hCodec, IN VCODEC_DEC_PARAM_TYPE_T eCmd, INOUT void *pParam); +VCODEC_DEC_ERROR_T HEVCDecoderSetParameterAdapt(IN HANDLE hCodec, IN VCODEC_DEC_PARAM_TYPE_T eCmd, INOUT void *pParam); + +extern VCODEC_DEC_API_T *GetHEVCDecoderAPI(void); + +VCODEC_DEC_API_T *GetHEVCDecoderAPI(void); + + +#endif diff --git a/include/linux/vcodec/kernel/val_log.h b/include/linux/vcodec/kernel/val_log.h new file mode 100644 index 000000000..40c9bf8d5 --- /dev/null +++ b/include/linux/vcodec/kernel/val_log.h @@ -0,0 +1,65 @@ +/** + * @file + * val_log.h + * + * @par Project: + * MFlexVideo + * + * @par Description: + * Log System + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VAL_LOG_H_ +#define _VAL_LOG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +//#include +#include + + +#define MFV_LOG_ERROR //error +#ifdef MFV_LOG_ERROR +#define MFV_LOGE(...) pr_err(__VA_ARGS__); +#else +#define MFV_LOGE(...) +#endif + +#define MFV_LOG_WARNING //warning +#ifdef MFV_LOG_WARNING +#define MFV_LOGW(...) pr_warning(__VA_ARGS__); +#else +#define MFV_LOGW(...) +#endif + + +#define MFV_LOG_DEBUG //debug information +#ifdef MFV_LOG_DEBUG +#define MFV_LOGD(...) pr_debug(__VA_ARGS__); +#else +#define MFV_LOGD(...) +#endif + +#define MFV_LOG_INFO //info information +#ifdef MFV_LOG_INFO +#define MFV_LOGI(...) pr_info(__VA_ARGS__); +#else +#define MFV_LOGI(...) +#endif + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VAL_LOG_H_ diff --git a/include/linux/vcodec/libmtk_cipher_export.h b/include/linux/vcodec/libmtk_cipher_export.h new file mode 100644 index 000000000..34a85d343 --- /dev/null +++ b/include/linux/vcodec/libmtk_cipher_export.h @@ -0,0 +1,86 @@ +#ifndef _LIBMTK_CIPHER_EXPORT_H +#define _LIBMTK_CIPHER_EXPORT_H + +#define HEVC_BLK_LEN (20480) // bytes +#define HEVC_MOD "HEVC_MOD" +#define HEVC_NANO 1000000000ULL +#define HEVC_CIPHER_LEN (102400) // bytes + + +typedef struct +{ + unsigned char buf[HEVC_BLK_LEN]; + unsigned int len; +} HEVC_BLK; + +typedef enum +{ + VIDEO_ENCRYPT_CODEC_NONE = 0x0, + VIDEO_ENCRYPT_CODEC_HEVC_ENC = 0x1, + VIDEO_ENCRYPT_CODEC_HEVC_DEC = 0x2, + VIDEO_ENCRYPT_CODEC_MAX = 0xffffffff +} VIDEO_ENCRYPT_CODEC_T; + + +typedef int (*hevc_api_funp)(HEVC_BLK *p_hevc_blk); +typedef int (*hevc_api_initk_funp)(unsigned char *key, unsigned int klen); + + +#define SEC_OK 0x0 +#define SEC_FAIL 0x1 + +/* HEVC shared lib*/ +#define ERR_HEVC_NOT_CORRECT_MODE 0x10000 +#define ERR_HEVC_DATA_NOT_ALIGNED 0x10001 +#define ERR_HEVC_ENC_IOCTL_FAIL 0x10002 +#define ERR_HEVC_DEC_IOCTL_FAIL 0x10002 +#define ERR_HEVC_CIPHER_UT_FAIL 0x10003 +#define ERR_HEVC_DATA_IS_NULL 0x10004 +#define ERR_HEVC_DATA_LENGTH_NOT_VALID 0x10005 +#define ERR_HEVC_SW_ENC_ERROR 0x10006 +#define ERR_HEVC_SW_DEC_ERROR 0x10007 +#define ERR_HEVC_INIT_SW_KEY_ERROR 0x10008 + + +/* HEVC sample*/ +#define ERR_HEVC_CIPHER_LIB_NOT_FOUND 0x20001 +#define ERR_HEVC_SW_DEC_BLOCK_SYM_NOT_FOUND 0x20002 +#define ERR_HEVC_HW_ENC_BLOCK_SYM_NOT_FOUND 0x20003 +#define ERR_HEVC_INIT_SW_KEY_SYM_NOT_FOUND 0x20004 +#define ERR_HEVC_INPUT_FILE_NOT_FOUND 0x20005 +#define ERR_HEVC_OUTPUT_FILE_NOT_FOUND 0x20006 +#define ERR_HEVC_SW_DEC_FILE_SYM_NOT_FOUND 0x20007 +#define ERR_HEVC_SW_DEC_FILE_FAILED 0x20008 +#define ERR_HEVC_UNKNOWN 0x2FFFF + + +/* Define LOG LEVEL*/ +#define SEC_LOG_TRACE 0 //For source code trace +#define SEC_LOG_DEBUG 0 //For debug purpose +#define SEC_LOG_ERROR 1 //For critical error dump +#define SEC_LOG_INFO 1 //For information to know when processing in normal + +/* DEBUG MACRO */ +#define SMSG_TRACE(...) \ + do { if (SEC_LOG_TRACE) printf(__VA_ARGS__); } while (0) + +#define SMSG_DEBUG(...) \ + do { if (SEC_LOG_DEBUG) printf(__VA_ARGS__); } while (0) + +#define SMSG_ERROR(...) \ + do { if (SEC_LOG_ERROR) printf(__VA_ARGS__); } while (0) + +#define SMSG_INFO(...) \ + do { if (SEC_LOG_INFO) printf(__VA_ARGS__); } while (0) + + +#define HEVC_ENCRYTP_FILE_PATH "/data/mediaserver" +#define HEVC_ENC_SW_ENCRYPT_FILE_PATH "/system/lib/libhevce_sb.ca7.android.so" +#define HEVC_ENC_HW_ENCRYPT_FILE_PATH "/data/mediaserver/sb.ca7.android_hwenc.so" +#define HEVC_ENC_HW_DECRYPT_FILE_PATH "/data/mediaserver/sb.ca7.android_hwdec.so" +#define HEVC_DEC_SW_ENCRYTP_FILE_PATH "/system/lib/libHEVCdec_sa.ca7.android.so" +#define HEVC_DEC_HW_ENCRYPT_FILE_PATH "/data/mediaserver/dec_sa.ca7.android_hwenc.so" +#define HEVC_DEC_HW_DECRYPT_FILE_PATH "/data/mediaserver/dec_sa.ca7.android_hwdec.so" + +#endif /*_LIBMTK_CIPHER_EXPORT_H*/ + diff --git a/include/linux/vcodec/user/val_log.h b/include/linux/vcodec/user/val_log.h new file mode 100644 index 000000000..a117843fe --- /dev/null +++ b/include/linux/vcodec/user/val_log.h @@ -0,0 +1,74 @@ +/** + * @file + * val_log.h + * + * @par Project: + * Video + * + * @par Description: + * log system + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VAL_LOG_H_ +#define _VAL_LOG_H_ + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "MFV_COMMON" ///< LOG_TAG "MFV_COMMON" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MFV_LOG_ERROR ///< error +#ifdef MFV_LOG_ERROR +#define MFV_LOGE(...) xlog_printf(ANDROID_LOG_ERROR, "VDO_LOG", __VA_ARGS__); ///< show error log +#define VDO_LOGE(...) xlog_printf(ANDROID_LOG_ERROR, "VDO_LOG", __VA_ARGS__); ///< show error log +#else +#define MFV_LOGE(...) ///< NOT show error log +#define VDO_LOGE(...) ///< NOT show error log +#endif + +#define MFV_LOG_WARNING ///< warning +#ifdef MFV_LOG_WARNING +#define MFV_LOGW(...) xlog_printf(ANDROID_LOG_WARN, "VDO_LOG", __VA_ARGS__); ///< show warning log +#define VDO_LOGW(...) xlog_printf(ANDROID_LOG_WARN, "VDO_LOG", __VA_ARGS__); ///< show warning log +#else +#define MFV_LOGW(...) ///< NOT show warning log +#define VDO_LOGW(...) ///< NOT show warning log +#endif + +//#define MFV_LOG_DEBUG ///< debug information +#ifdef MFV_LOG_DEBUG +#define MFV_LOGD(...) xlog_printf(ANDROID_LOG_DEBUG, "VDO_LOG", __VA_ARGS__); ///< show debug information log +#define VDO_LOGD(...) xlog_printf(ANDROID_LOG_DEBUG, "VDO_LOG", __VA_ARGS__); ///< show debug information log +#else +#define MFV_LOGD(...) ///< NOT show debug information log +#define VDO_LOGD(...) ///< NOT show debug information log +#endif + +#define MFV_LOG_INFO ///< information +#ifdef MFV_LOG_INFO +#define MFV_LOGI(...) xlog_printf(ANDROID_LOG_INFO, "VDO_LOG", __VA_ARGS__); ///< show information log +#define VDO_LOGI(...) xlog_printf(ANDROID_LOG_INFO, "VDO_LOG", __VA_ARGS__); ///< show information log +#else +#define MFV_LOGI(...) ///< NOT show information log +#define VDO_LOGI(...) ///< NOT show information log +#endif + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VAL_LOG_H_ diff --git a/include/linux/vcodec/val_api_private.h b/include/linux/vcodec/val_api_private.h new file mode 100644 index 000000000..5ad131f30 --- /dev/null +++ b/include/linux/vcodec/val_api_private.h @@ -0,0 +1,72 @@ +/** + * @file + * val_api_public.h + * + * @par Project: + * Video + * + * @par Description: + * Video Abstraction Layer API for internal use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VAL_API_PRIVATE_H_ +#define _VAL_API_PRIVATE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_private.h" +#include "val_api_public.h" +#include "libmtk_cipher_export.h" + + +VAL_RESULT_T eValInit(VAL_HANDLE_T *a_phHalHandle); +VAL_RESULT_T eValDeInit(VAL_HANDLE_T *a_phHalHandle); + +VAL_RESULT_T eVideoIntMemAlloc(VAL_INTMEM_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoIntMemFree(VAL_INTMEM_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + +VAL_RESULT_T eVideoCreateEvent(VAL_EVENT_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoSetEvent(VAL_EVENT_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoCloseEvent(VAL_EVENT_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoWaitEvent(VAL_EVENT_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + +VAL_RESULT_T eVideoCreateMutex(VAL_MUTEX_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoCloseMutex(VAL_MUTEX_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoWaitMutex(VAL_MUTEX_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoReleaseMutex(VAL_MUTEX_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + +VAL_RESULT_T eVideoMMAP(VAL_MMAP_T *a_prParam, VAL_UINT32_T a_u4ParamSize); +VAL_RESULT_T eVideoUnMMAP(VAL_MMAP_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + +VAL_RESULT_T eVideoInitLockHW(VAL_VCODEC_OAL_HW_REGISTER_T *prParam, int size); +VAL_RESULT_T eVideoDeInitLockHW(VAL_VCODEC_OAL_HW_REGISTER_T *prParam, int size); + +VAL_RESULT_T eVideoVCodecCoreLoading(int CPUid, int *Loading); +VAL_RESULT_T eVideoVCodecCoreNumber(int *CPUNums); + +VAL_RESULT_T eVideoConfigMCIPort(VAL_UINT32_T u4PortConfig, VAL_UINT32_T *pu4PortResult, VAL_MEM_CODEC_T eMemCodec); + +VAL_UINT32_T eVideoHwM4UEnable(VAL_BOOL_T bEnable); // MTK_SEC_VIDEO_PATH_SUPPORT +VAL_UINT32_T eVideoLibDecrypt(VIDEO_ENCRYPT_CODEC_T a_eVIDEO_ENCRYPT_CODEC); + +/* for DirectLink Meta Mode + */ +VAL_RESULT_T eVideoAllocMetaHandleList(VAL_HANDLE_T *a_MetaHandleList); +VAL_RESULT_T eVideoGetBufInfoFromMetaHandle(VAL_HANDLE_T a_MetaHandleList, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); +VAL_RESULT_T eVideoFreeMetaHandleList(VAL_HANDLE_T a_MetaHandleList); +/* for DirectLink Meta Mode - */ + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VAL_API_PRIVATE_H_ diff --git a/include/linux/vcodec/val_api_public.h b/include/linux/vcodec/val_api_public.h new file mode 100644 index 000000000..2994278d3 --- /dev/null +++ b/include/linux/vcodec/val_api_public.h @@ -0,0 +1,391 @@ +/** + * @file + * val_api_public.h + * + * @par Project: + * Video + * + * @par Description: + * Video Abstraction Layer API for external use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VAL_API_PUBLIC_H_ +#define _VAL_API_PUBLIC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" + + +/** + * @par Function + * eVideoInitMVA + * @par Description + * Alloc the handle for MVA usage + * @param + * a_pvHandle [IN] The handle for MVA usage + * @par Returns + * VAL_UINT32_T [OUT] Non-Used + */ +VAL_UINT32_T eVideoInitMVA(VAL_VOID_T **a_pvHandle); + + +/** + * @par Function + * eVideoAllocMVA + * @par Description + * Use the given va and size, to get the MVA + * @param + * a_pvHandle [IN] The handle for MVA usage + * @param + * a_u4Va [IN] The given va used to get MVA + * @param + * ap_u4Pa [OUT] The MVA + * @param + * a_u4Size [IN] The given size used to get MVA + * @param + * a_pvM4uConfig [IN] The MVA config info + * @par Returns + * VAL_UINT32_T [OUT] Non-Used + */ +VAL_UINT32_T eVideoAllocMVA(VAL_VOID_T *a_pvHandle, VAL_UINT32_T a_u4Va, VAL_UINT32_T *ap_u4Pa, VAL_UINT32_T a_u4Size, VAL_VCODEC_M4U_BUFFER_CONFIG_T *a_pvM4uConfig); + + +/** + * @par Function + * eVideoFreeMVA + * @par Description + * Use the given va, MVA and size, to free the MVA + * @param + * a_pvHandle [IN] The handle for MVA usage + * @param + * a_u4Va [IN] The given va used to free MVA + * @param + * a_u4Pa [IN] The given MVA used to free MVA + * @param + * a_u4Size [IN] The given size used to get MVA + * @param + * a_pvM4uConfig [IN] The MVA config info + * @par Returns + * VAL_UINT32_T [OUT] Non-Used + */ +VAL_UINT32_T eVideoFreeMVA(VAL_VOID_T *a_pvHandle, VAL_UINT32_T a_u4Va, VAL_UINT32_T a_u4Pa, VAL_UINT32_T a_u4Size, VAL_VCODEC_M4U_BUFFER_CONFIG_T *a_pvM4uConfig); + + +/** + * @par Function + * eVideoDeInitMVA + * @par Description + * Free the handle for MVA usage + * @param + * a_pvHandle [IN] The handle for MVA usage + * @par Returns + * VAL_UINT32_T [OUT] Non-Used + */ +VAL_UINT32_T eVideoDeInitMVA(VAL_VOID_T *a_pvHandle); + + +/** + * @par Function + * eVideoGetM4UModuleID + * @par Description + * Get the M4U module port ID + * @param + * u4MemType [IN] The memory usage for VENC or VDEC + * @par Returns + * VAL_UINT32_T [OUT] The M4U module port ID for VENC or VDEC + */ +VAL_INT32_T eVideoGetM4UModuleID(VAL_UINT32_T u4MemType); + + +/** + * @par Function + * eVideoAtoi + * @par Description + * The abstraction layer for atoi() function + * @param + * a_prParam [IN] The structure contains used info for atoi() + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoAtoi(VAL_ATOI_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoStrStr + * @par Description + * The abstraction layer for strstr() function + * @param + * a_prParam [IN] The structure contains used info for strstr() + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoStrStr(VAL_STRSTR_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoFlushCache + * @par Description + * The flush cache usage function + * @param + * a_prParam [IN] The structure contains used info for flush cache + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @param + * optype [IN] 0 for flush all, 1 for flush by page + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_MEMORY for fail + */ +VAL_RESULT_T eVideoFlushCache(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize, VAL_UINT32_T optype); + + +/** + * @par Function + * eVideoInvalidateCache + * @par Description + * The invalidate cache usage function + * @param + * a_prParam [IN] The structure contains used info for invalidate cache + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @param + * optype [IN] 0 for flush all, 1 for invalidate by page + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_MEMORY for fail + */ +VAL_RESULT_T eVideoInvalidateCache(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize, VAL_UINT32_T optype); + + +/** + * @par Function + * eVideoMemAlloc + * @par Description + * The memory allocate usage function + * @param + * a_prParam [IN] The structure contains used info for allocate memory + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_MEMORY or VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemAlloc(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoMemFree + * @par Description + * The memory free usage function + * @param + * a_prParam [IN] The structure contains used info for free memory + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemFree(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoMemSet + * @par Description + * The memory set usage function + * @param + * a_prParam [IN] The structure contains used info for set memory + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @param + * a_u4Value [IN] The value for set to memory + * @param + * a_u4Size [IN] The size of "memory" want to be set + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemSet(VAL_MEMORY_T *a_prParam, VAL_UINT32_T a_u4ParamSize, VAL_INT32_T a_u4Value, VAL_UINT32_T a_u4Size); + + +/** + * @par Function + * eVideoMemCpy + * @par Description + * The memory copy usage function + * @param + * a_prParamDst [IN] The structure contains destination memory info for copy memory + * @param + * a_u4ParamDstSize [IN] The size of a_prParamDst structure + * @param + * a_prParamSrc [IN] The structure contains source memory info for copy memory + * @param + * a_u4ParamSrcSize [IN] The size of a_prParamSrc structure + * @param + * a_u4Size [IN] The size of "source memory" and "destination memory" want to be copied + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemCpy(VAL_MEMORY_T *a_prParamDst, VAL_UINT32_T a_u4ParamDstSize, VAL_MEMORY_T *a_prParamSrc, VAL_UINT32_T a_u4ParamSrcSize, VAL_UINT32_T a_u4Size); + + +/** + * @par Function + * eVideoMemCmp + * @par Description + * The memory compare usage function + * @param + * a_prParamSrc1 [IN] The structure contains memory 1 info for compare memory + * @param + * a_u4ParamSrc1Size [IN] The size of a_prParamSrc1 structure + * @param + * a_prParamSrc2 [IN] The structure contains memory 2 info for compare memory + * @param + * a_u4ParamSrc2Size [IN] The size of a_prParamSrc2 structure + * @param + * a_u4Size [IN] The size of "memory 1" and "memory 2" want to be compared + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_INVALID_PARAMETER for fail + */ +VAL_RESULT_T eVideoMemCmp(VAL_MEMORY_T *a_prParamSrc1, VAL_UINT32_T a_u4ParamSrc1Size, VAL_MEMORY_T *a_prParamSrc2, VAL_UINT32_T a_u4ParamSrc2Size, VAL_UINT32_T a_u4Size); + + +/** + * @par Function + * WaitISR + * @par Description + * The ISR usage related function, whene trigger HW, we will use to wait HW complete + * @param + * a_prParam [IN] The structure contains used info for ISR usage + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_ISR_TIMEOUT for fail + */ +VAL_RESULT_T WaitISR(VAL_ISR_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoLockHW + * @par Description + * The single/multiple instance usage function, to allow using HW + * @param + * a_prParam [IN] The structure contains used info for Lock HW + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_UNKNOWN_ERROR for fail + */ +VAL_RESULT_T eVideoLockHW(VAL_HW_LOCK_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoLockHW + * @par Description + * The single/multiple instance usage function, to release HW for another instance + * @param + * a_prParam [IN] The structure contains used info for unLock HW + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success, VAL_RESULT_UNKNOWN_ERROR for fail + */ +VAL_RESULT_T eVideoUnLockHW(VAL_HW_LOCK_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eVideoGetTimeOfDay + * @par Description + * The timing usage function, used to performance profiling + * @param + * a_prParam [IN] The structure contains used info for timing usage + * @param + * a_u4ParamSize [IN] The size of a_prParam structure + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eVideoGetTimeOfDay(VAL_TIME_T *a_prParam, VAL_UINT32_T a_u4ParamSize); + + +/** + * @par Function + * eHalEMICtrlForRecordSize + * @par Description + * The recording info function, to get the record size for setting to EMI controller + * @param + * a_prDrvRecordSize [IN] The structure contains used info for recording size + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eHalEMICtrlForRecordSize(VAL_RECORD_SIZE_T *a_prDrvRecordSize); + + +/** + * @par Function + * eVideoVcodecSetThreadID + * @par Description + * The thread info function, to set thread ID for used to lock/unlock HW and priority adjustment + * @param + * a_prThreadID [IN] The structure contains used info for thread info + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eVideoVcodecSetThreadID(VAL_VCODEC_THREAD_ID_T *a_prThreadID); + + +/** + * @par Function + * eVideoGetParam + * @par Description + * The parameter info function, to get val parameter + * @param + * a_eType [IN] The VAL_GET_TYPE_T enum + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eVideoGetParam(VAL_GET_TYPE_T a_eType, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); + +/** + * @par Function + * eVideoSetParam + * @par Description + * The parameter info function, to set val parameter + * @param + * a_eType [IN] The VAL_SET_TYPE_T enum + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VAL_RESULT_T [OUT] VAL_RESULT_NO_ERROR for success + */ +VAL_RESULT_T eVideoSetParam(VAL_SET_TYPE_T a_eType, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); + +VAL_RESULT_T eVideoE3TCMPowerON(VAL_UINT32_T a_u4E3TCMClk); +VAL_RESULT_T eVideoE3TCMPowerOFF(VAL_UINT32_T a_u4E3TCMClk); + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VAL_API_PUBLIC_H_ diff --git a/include/linux/vcodec/val_oal.h b/include/linux/vcodec/val_oal.h new file mode 100644 index 000000000..29316c34d --- /dev/null +++ b/include/linux/vcodec/val_oal.h @@ -0,0 +1,1331 @@ +/** + * @file + * val_oal.h + * + * @par Project: + * Video + * + * @par Description: + * Video Codec Driver & Codec Liabrary Interface + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _SP5_OAL_H_ +#define _SP5_OAL_H_ + +// SP5 interface +#include "vcodec_OAL_v2.h" + +// ME1 interface +#include "val_types_private.h" + +/** + * @par Enumeration + * __VAL_OAL_TYPE + * @par Description + * This is the item used to set OAL type + */ +typedef enum ___VAL_OAL_TYPE +{ + _BYTE_ = 0x5000, ///< BYTE + _WORD_, ///< WORD + _LONG_ ///< LONG +} __VAL_OAL_TYPE; + + +#define SP5_VCodecQueryMemType VCodecDrvQueryMemType ///< VCodecDrvQueryMemType definition for SW/hybrid codec +#define SP5_VCodecQueryPhysicalAddr VCodecDrvQueryPhysicalAddr ///< VCodecDrvQueryPhysicalAddr definition for SW/hybrid codec +#define SP5_VCodecSwitchMemType VCodecDrvSwitchMemType ///< VCodecDrvSwitchMemType definition for SW/hybrid codec +#define SP5_VCodecFlushCachedBuffer VCodecDrvFlushCachedBuffer ///< VCodecDrvFlushCachedBuffer definition for SW/hybrid codec +#define SP5_VCodecInvalidateCachedBuffer VCodecDrvInvalidateCachedBuffer ///< VCodecDrvInvalidateCachedBuffer definition for SW/hybrid codec +#define SP5_VCodecFlushCachedBufferAll VCodecDrvFlushCachedBufferAll ///< VCodecDrvFlushCachedBufferAll definition for SW/hybrid codec +#define SP5_VCodecInvalidateCachedBufferAll VCodecDrvInvalidateCachedBufferAll ///< VCodecDrvInvalidateCachedBufferAll definition for SW/hybrid codec +#define SP5_VCodecFlushInvalidateCacheBufferAll VCodecDrvFlushInvalidateCacheBufferAll ///< VCodecDrvFlushInvalidateCacheBufferAll definition for SW/hybrid codec +#define SP5_VCodecMemSet VCodecDrvMemSet ///< VCodecDrvMemSet definition for SW/hybrid codec +#define SP5_VCodecMemCopy VCodecDrvMemCopy ///< VCodecDrvMemCopy definition for SW/hybrid codec +#define SP5_VCodecAssertFail VCodecDrvAssertFail ///< VCodecDrvAssertFail definition for SW/hybrid codec +#define SP5_VCodecMMAP VCodecDrvMMAP ///< VCodecDrvMMAP definition for SW/hybrid codec +#define SP5_VCodecUnMMAP VCodecDrvUnMMAP ///< VCodecDrvUnMMAP definition for SW/hybrid codec +#define SP5_VCodecWaitISR VCodecDrvWaitISR ///< VCodecDrvWaitISR definition for SW/hybrid codec +#define SP5_VCodecLockHW VCodecDrvLockHW ///< VCodecDrvLockHW definition for SW/hybrid codec +#define SP5_VCodecUnLockHW VCodecDrvUnLockHW ///< VCodecDrvUnLockHW definition for SW/hybrid codec +#define SP5_VCodecInitHWLock VCodecDrvInitHWLock ///< VCodecDrvInitHWLock definition for SW/hybrid codec +#define SP5_VCodecDeInitHWLock VCodecDrvDeInitHWLock ///< VCodecDrvDeInitHWLock definition for SW/hybrid codec +#if 0 +#define SP5_VcodecTraceLog0 VCodecDrvTraceLog0 ///< VCodecDrvTraceLog0 definition for SW/hybrid codec +#define SP5_VcodecTraceLog1 VCodecDrvTraceLog1 ///< VCodecDrvTraceLog1 definition for SW/hybrid codec +#define SP5_VcodecTraceLog2 VCodecDrvTraceLog2 ///< VCodecDrvTraceLog2 definition for SW/hybrid codec +#define SP5_VcodecTraceLog4 VCodecDrvTraceLog4 ///< VCodecDrvTraceLog4 definition for SW/hybrid codec +#define SP5_VcodecTraceLog8 VCodecDrvTraceLog8 ///< VCodecDrvTraceLog8 definition for SW/hybrid codec +#else +#define SP5_VCodecPrintf VCodecPrintf ///< VCodecPrintf definition for SW/hybrid codec +#endif +#define SP5_VdoMemAllocAligned VCodecDrvMemAllocAligned ///< VCodecDrvMemAllocAligned definition for SW/hybrid codec +#define SP5_VdoMemFree VCodecDrvMemFree ///< VCodecDrvMemFree definition for SW/hybrid codec +#define SP5_VdoIntMalloc VCodecDrvIntMalloc ///< VCodecDrvIntMalloc definition for SW/hybrid codec +#define SP5_VdoIntFree VCodecDrvIntFree ///< VCodecDrvIntFree definition for SW/hybrid codec +#define SP5_RegSync VCodecDrvRegSync ///< VCodecDrvRegSync definition for SW/hybrid codec +#define SP5_RegSyncWriteB VCodecDrvRegSyncWriteB ///< VCodecDrvRegSyncWriteB definition for SW/hybrid codec +#define SP5_RegSyncWriteW VCodecDrvRegSyncWriteW ///< VCodecDrvRegSyncWriteW definition for SW/hybrid codec +#define SP5_RegSyncWriteL VCodecDrvRegSyncWriteL ///< VCodecDrvRegSyncWriteL definition for SW/hybrid codec +#define SP5_VMPEG4EncCodecWaitISR VMPEG4EncCodecDrvWaitISR ///< VMPEG4EncCodecDrvWaitISR definition for SW/hybrid codec +#define SP5_VMPEG4EncCodecLockHW VMPEG4EncCodecDrvLockHW ///< VMPEG4EncCodecDrvLockHW definition for SW/hybrid codec +#define SP5_VMPEG4EncCodecUnLockHW VMPEG4EncCodecDrvUnLockHW ///< VMPEG4EncCodecDrvUnLockHW definition for SW/hybrid codec + + +/** + * @par Function + * SP5_VCodecQueryMemType + * @par Description + * The function used to query memory type for SW/hybrid codec + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * u4Size [IN] The size of buffer + * @param + * peMemType [OUT] The memory type + * @par Returns + * void + */ +void SP5_VCodecQueryMemType(IN void *pBuffer_VA, + IN unsigned int u4Size, + OUT VCODEC_MEMORY_TYPE_T *peMemType); + + +/** + * @par Function + * SP5_VCodecQueryPhysicalAddr + * @par Description + * The function used to query physical address + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * pBufferOut_PA [OUT] The physical address + * @par Returns + * void + */ +void SP5_VCodecQueryPhysicalAddr(IN void *pBuffer_VA, + OUT void **pBufferOut_PA); + + +/** + * @par Function + * SP5_VCodecSwitchMemType + * @par Description + * The function used to switch memory type for SW/hybrid codec + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * u4Size [IN] The size of buffer + * @param + * eMemType [IN] The memory type + * @param + * pBufferOut_VA [OUT] The pointer of buffer address + * @par Returns + * int, return 0 if success, return -1 if failed + */ +int SP5_VCodecSwitchMemType(IN void *pBuffer_VA, + IN unsigned int u4Size, + IN VCODEC_MEMORY_TYPE_T eMemType, + OUT void **pBufferOut_VA); + + +/** + * @par Function + * SP5_VCodecFlushCachedBuffer + * @par Description + * The function used to flush cache by size + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * u4Size [IN] The size of buffer + * @par Returns + * void + */ +void SP5_VCodecFlushCachedBuffer(IN void *pBuffer_VA, + IN unsigned int u4Size); + + +/** + * @par Function + * SP5_VCodecInvalidateCachedBuffer + * @par Description + * The function used to invalidate cache by size + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * u4Size [IN] The size of buffer + * @par Returns + * void + */ +void SP5_VCodecInvalidateCachedBuffer(IN void *pBuffer_VA, + IN unsigned int u4Size); + + +/** + * @par Function + * SP5_VCodecFlushCachedBufferAll + * @par Description + * The function used to flush all cache + * @par Returns + * void + */ +void SP5_VCodecFlushCachedBufferAll(); + + +/** + * @par Function + * SP5_VCodecInvalidateCachedBufferAll + * @par Description + * The function used to invalidate all cache + * @par Returns + * void + */ +void SP5_VCodecInvalidateCachedBufferAll(); + + +/** + * @par Function + * SP5_VCodecFlushInvalidateCacheBufferAll + * @par Description + * The function used to flush & invalidate all cache + * @par Returns + * void + */ +void SP5_VCodecFlushInvalidateCacheBufferAll(); + + +/** + * @par Function + * SP5_VCodecMemSet + * @par Description + * The function used to memory set + * @param + * pBuffer_VA [IN] The pointer of buffer address + * @param + * cValue [IN] The value will be set to memory + * @param + * u4Length [IN] The length of memory will be set + * @par Returns + * void + */ +void SP5_VCodecMemSet(IN void *pBuffer_VA, + IN char cValue, + IN unsigned int u4Length); + + +/** + * @par Function + * SP5_VCodecMemCopy + * @par Description + * The function used to memory copy + * @param + * pvDest [IN] The pointer of destination memory + * @param + * pvSrc [IN] The pointer of source memory + * @param + * u4Length [IN] The length of memory will be copied + * @par Returns + * void + */ +void SP5_VCodecMemCopy(IN void *pvDest , + IN const void *pvSrc , + IN unsigned int u4Length); + + +/** + * @par Function + * SP5_VCodecAssertFail + * @par Description + * The function used to assert when occur error + * @param + * ptr [IN] The name of error source file + * @param + * i4Line [IN] The line of error source file + * @param + * i4Arg [IN] The argumnet of error source file + * @par Returns + * void + */ +void SP5_VCodecAssertFail(IN char *ptr, + IN int i4Line, + IN int i4Arg); + + +/** + * @par Function + * SP5_VCodecMMAP + * @par Description + * The function used to memory map + * @param + * prParam [IN/OUT] The structure contains memory info for memory map + * @par Returns + * void + */ +void SP5_VCodecMMAP(VCODEC_OAL_MMAP_T *prParam); + + +/** + * @par Function + * SP5_VCodecUnMMAP + * @par Description + * The function used to memory unmap + * @param + * prParam [IN/OUT] The structure contains memory info for memory unmap + * @par Returns + * void + */ +void SP5_VCodecUnMMAP(VCODEC_OAL_MMAP_T *prParam); + + +/** + * @par Function + * SP5_VCodecWaitISR + * @par Description + * The ISR usage related function, whene trigger HW, we will use to wait HW complete + * @param + * prParam [IN/OUT] The structure contains used info for ISR usage + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VCodecWaitISR(VCODEC_OAL_ISR_T *prParam); + + +/** + * @par Function + * SP5_VCodecLockHW + * @par Description + * The single/multiple instance usage function, to allow using HW + * @param + * prParam [IN/OUT] The structure contains used info for Lock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VCodecLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * SP5_VCodecUnLockHW + * @par Description + * The single/multiple instance usage function, to release HW for another instance + * @param + * prParam [IN/OUT] The structure contains used info for unLock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VCodecUnLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * SP5_VCodecInitHWLock + * @par Description + * The function used to init HW lock + * @param + * prParam [IN/OUT] The structure contains used info for init HW lock + * @par Returns + * void + */ +void SP5_VCodecInitHWLock(VCODEC_OAL_HW_REGISTER_T *prParam); + + +/** + * @par Function + * SP5_VCodecDeInitHWLock + * @par Description + * The function used to deinit HW lock + * @param + * prParam [IN/OUT] The structure contains used info for deinit HW lock + * @par Returns + * void + */ +void SP5_VCodecDeInitHWLock(VCODEC_OAL_HW_REGISTER_T *prParam); + + +#if 0 +/** + * @par Function + * SP5_VcodecTraceLog0 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @par Returns + * void + */ +void SP5_VcodecTraceLog0(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex + ); + + +/** + * @par Function + * SP5_VcodecTraceLog1 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @param + * arg [IN] The input argument + * @par Returns + * void + */ +void SP5_VcodecTraceLog1(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex, + IN UINT64 arg + ); + + +/** + * @par Function + * SP5_VcodecTraceLog2 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @param + * arg1 [IN] The input argument1 + * @param + * arg2 [IN] The input argument2 + * @par Returns + * void + */ +void SP5_VcodecTraceLog2(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex, + IN UINT64 arg1, + IN UINT64 arg2 + ); + + +/** + * @par Function + * SP5_VcodecTraceLog4 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @param + * arg1 [IN] The input argument1 + * @param + * arg2 [IN] The input argument2 + * @param + * arg3 [IN] The input argument3 + * @param + * arg4 [IN] The input argument4 + * @par Returns + * void + */ +void SP5_VcodecTraceLog4(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex, + IN UINT64 arg1, + IN UINT64 arg2, IN UINT64 arg3, + IN UINT64 arg4 + ); + + +/** + * @par Function + * SP5_VcodecTraceLog4 + * @par Description + * The function used to trace log for debug + * @param + * eGroup [IN] The value to define log importance priority + * @param + * eIndex [IN] The value to define log type + * @param + * arg1 [IN] The input argument1 + * @param + * arg2 [IN] The input argument2 + * @param + * arg3 [IN] The input argument3 + * @param + * arg4 [IN] The input argument4 + * @param + * arg5 [IN] The input argument5 + * @param + * arg6 [IN] The input argument6 + * @param + * arg7 [IN] The input argument7 + * @param + * arg8 [IN] The input argument8 + * @par Returns + * void + */ +void SP5_VcodecTraceLog8(IN VCODEC_LOG_GROUP_T eGroup, + IN VCODEC_LOG_INDEX_T eIndex, + IN UINT64 arg1, + IN UINT64 arg2, + IN UINT64 arg3, + IN UINT64 arg4, + IN UINT64 arg5, + IN UINT64 arg6, + IN UINT64 arg7, + IN UINT64 arg8 + ); +#else +/** + * @par Function + * SP5_VCodecPrintf + * @par Description + * The function used to trace log for debug + * @param + * format [IN] log string + * @param + * ... [IN] log argument + */ +VCODEC_OAL_ERROR_T SP5_VCodecPrintf(IN const char *_Format, ...); +#endif + + +/** + * @par Function + * SP5_VdoMemAllocAligned + * @par Description + * The function used to alloc external working memry + * @param + * handle [IN] codec/driver handle + * @param + * size [IN] allocated memory size + * @param + * u4AlignSize [IN] allocated memory byte alignment + * @param + * cachable [IN] memory type + * @param + * pBuf [OUT] allocated memory buffer info + * @param + * eMemCodec [IN] allocated memory used for venc/vdec + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_VdoMemAllocAligned(VAL_VOID_T *handle, VAL_UINT32_T size, unsigned int u4AlignSize, VCODEC_MEMORY_TYPE_T cachable, VCODEC_BUFFER_T *pBuf, VAL_MEM_CODEC_T eMemCodec); + + +/** + * @par Function + * SP5_VdoMemFree + * @par Description + * The function used to free external working memry + * @param + * handle [IN] codec/driver handle + * @param + * pBuf [IN] allocated memory buffer info + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_VdoMemFree(VAL_VOID_T *handle, VCODEC_BUFFER_T *pBuf); + + +/** + * @par Function + * SP5_VdoIntMalloc + * @par Description + * The function used to alloc internal working memry + * @param + * handle [IN] codec/driver handle + * @param + * size [IN] allocated memory size + * @param + * alignedsize [IN] allocated memory byte alignment + * @param + * prBuffer_adr [OUT] allocated memory buffer info + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_VdoIntMalloc(HANDLE handle, unsigned int size, unsigned int alignedsize, VCODEC_BUFFER_T *prBuffer_adr); + + +/** + * @par Function + * SP5_VdoIntFree + * @par Description + * The function used to free internal working memry + * @param + * handle [IN] codec/driver handle + * @param + * prBuffer_adr [IN] allocated memory buffer info + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_VdoIntFree(HANDLE handle, VCODEC_BUFFER_T *prBuffer_adr); + + +/** + * @par Function + * SP5_RegSync + * @par Description + * The function used to set register sync + * @param + * type [IN] BYTE/WORD/LONG + * @param + * v [IN] register value + * @param + * a [IN] register address + * @par Returns + * VAL_VOID_T + */ +VAL_VOID_T SP5_RegSync(int type, unsigned int v, unsigned int a); + + +/** + * @par Function + * SP5_VMPEG4EncCodecWaitISR + * @par Description + * The ISR usage related function, whene trigger HW, we will use to wait HW complete + * @param + * prParam [IN/OUT] The structure contains used info for ISR usage + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VMPEG4EncCodecWaitISR(VCODEC_OAL_ISR_T *prParam); + + +/** + * @par Function + * SP5_VMPEG4EncCodecLockHW + * @par Description + * The single/multiple instance usage function, to allow using HW + * @param + * prParam [IN/OUT] The structure contains used info for Lock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VMPEG4EncCodecLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * SP5_VMPEG4EncCodecUnLockHW + * @par Description + * The single/multiple instance usage function, to release HW for another instance + * @param + * prParam [IN/OUT] The structure contains used info for unLock HW + * @par Returns + * int, return 1 if success, return 0 if failed + */ +int SP5_VMPEG4EncCodecUnLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +/** + * @par Function + * eValInit + * @par Description + * The init driver function + * @param + * a_phHalHandle [IN/OUT] The codec/driver handle + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed + */ +VAL_RESULT_T eValInit(VAL_HANDLE_T *a_phHalHandle); + + +/** + * @par Function + * eValDeInit + * @par Description + * The deinit driver function + * @param + * a_phHalHandle [IN/OUT] The codec/driver handle + * @par Returns + * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return VAL_RESULT_UNKNOWN_ERROR if failed + */ +VAL_RESULT_T eValDeInit(VAL_HANDLE_T *a_phHalHandle); + + +/** + * @par Function + * VCodecDrvCheck_Version + * @par Description + * The function used to check codec library version + * @param + * version [IN/OUT] The codec library version + * @par Returns + * int, return 0 if success, return -1 if failed + */ +int VCodecDrvCheck_Version(int version); + +/************ Multi-thread function ***********/ + +/***** Thread Management Functions ******/ + + +/** + * @par Function + * VCodecDrvPthread_attr_init + * @par Description + * The pthread_attr_init wrapper function + * @param + * attr [OUT] attr + * @par Returns + * int, pthread_attr_init((pthread_attr_t *)attr); + */ +int VCodecDrvPthread_attr_init(OUT VCODEC_PTHREAD_ATTR_T *attr); + + +/** + * @par Function + * VCodecDrvPthread_attr_destroy + * @par Description + * The pthread_attr_destroy wrapper function + * @param + * attr [IN] attr + * @par Returns + * int, pthread_attr_destroy((pthread_attr_t *)attr); + */ +int VCodecDrvPthread_attr_destroy(IN VCODEC_PTHREAD_ATTR_T *attr); + + +/** + * @par Function + * VCodecDrvPthread_attr_getdetachstate + * @par Description + * The pthread_attr_getdetachstate wrapper function + * @param + * attr [IN] attr + * @param + * detachstate [OUT] detachstate + * @par Returns + * int, pthread_attr_getdetachstate((pthread_attr_t const *)attr, detachstate); + */ +int VCodecDrvPthread_attr_getdetachstate(IN const VCODEC_PTHREAD_ATTR_T *attr, OUT int *detachstate); + + +/** + * @par Function + * VCodecDrvPthread_attr_getdetachstate + * @par Description + * The pthread_attr_getdetachstate wrapper function + * @param + * attr [IN] attr + * @param + * detachstate [OUT] detachstate + * @par Returns + * int, pthread_attr_getdetachstate((pthread_attr_t const *)attr, detachstate); + */ +int VCodecDrvPthread_attr_setdetachstate(IN VCODEC_PTHREAD_ATTR_T *attr, IN int detachstate); + + +/** + * @par Function + * VCodecDrvPthread_create + * @par Description + * The pthread_create wrapper function + * @param + * thread [OUT] thread + * @param + * attr [IN] attr + * @param + * start_routine [IN] start_routine + * @param + * arg [IN] arg + * @par Returns + * int, pthread_create((pthread_t *)thread, (pthread_attr_t const *)attr, start_routine, arg); + */ +int VCodecDrvPthread_create(OUT VCODEC_PTHREAD_T *thread, IN const VCODEC_PTHREAD_ATTR_T *attr, IN void * (*start_routine)(void *), IN void *arg); + + +/** + * @par Function + * VCodecDrvPthread_kill + * @par Description + * The pthread_kill wrapper function + * @param + * tid [IN] tid + * @param + * sig [IN] sig + * @par Returns + * int, pthread_kill((pthread_t)tid, SIGUSR1); + */ +int VCodecDrvPthread_kill(IN VCODEC_PTHREAD_T tid, IN int sig); + + +/** + * @par Function + * VCodecDrvPthread_exit + * @par Description + * The pthread_exit wrapper function + * @param + * retval [OUT] retval + * @par Returns + * void + */ +void VCodecDrvPthread_exit(OUT void *retval); + + +/** + * @par Function + * VCodecDrvPthread_join + * @par Description + * The pthread_join wrapper function + * @param + * thid [IN] thid + * @param + * ret_val [OUT] ret_val + * @par Returns + * int, pthread_join((pthread_t)thid, ret_val); + */ +int VCodecDrvPthread_join(IN VCODEC_PTHREAD_T thid, OUT void **ret_val); + +//int VCodecDrvPthread_detach(IN VCODEC_PTHREAD_T thid); + + +/** + * @par Function + * VCodecDrvPthread_once + * @par Description + * The pthread_once wrapper function + * @param + * once_control [IN] once_control + * @param + * init_routine [IN] init_routine + * @par Returns + * int, pthread_once((pthread_once_t *)once_control, init_routine); + */ +int VCodecDrvPthread_once(IN VCODEC_PTHREAD_ONCE_T *once_control, IN void (*init_routine)(void)); + + +/** + * @par Function + * VCodecDrvPthread_self + * @par Description + * The pthread_self wrapper function + * @par Returns + * VCODEC_PTHREAD_T, (VCODEC_PTHREAD_T)pthread_self() + */ +VCODEC_PTHREAD_T VCodecDrvPthread_self(void); + +//VCODEC_OAL_ERROR_T VCodecDrvPthread_equal(IN VCODEC_PTHREAD_T one,IN VCODEC_PTHREAD_T two); + +/***** Mutex Functions ******/ + + +/** + * @par Function + * VCodecDrvPthread_mutexattr_init + * @par Description + * The pthread_mutexattr_init wrapper function + * @param + * attr [OUT] attr + * @par Returns + * int, pthread_mutexattr_init((pthread_mutexattr_t *)attr); + */ +int VCodecDrvPthread_mutexattr_init(OUT VCODEC_PTHREAD_MUTEXATTR_T *attr); + + +/** + * @par Function + * VCodecDrvPthread_mutexattr_destroy + * @par Description + * The pthread_mutexattr_destroy wrapper function + * @param + * attr [IN] attr + * @par Returns + * int, pthread_mutexattr_destroy((pthread_mutexattr_t *)attr); + */ +int VCodecDrvPthread_mutexattr_destroy(IN VCODEC_PTHREAD_MUTEXATTR_T *attr); + + +/** + * @par Function + * VCodecDrvPthread_mutex_init + * @par Description + * The pthread_mutex_init wrapper function + * @param + * mutex [OUT] mutex + * @param + * attr [IN] attr + * @par Returns + * int, pthread_mutex_init((pthread_mutex_t *)mutex, (const pthread_mutexattr_t *)attr); + */ +int VCodecDrvPthread_mutex_init(OUT VCODEC_PTHREAD_MUTEX_T *mutex, IN const VCODEC_PTHREAD_MUTEXATTR_T *attr); + + +/** + * @par Function + * VCodecDrvPthread_mutex_destroy + * @par Description + * The pthread_mutex_destroy wrapper function + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_mutex_destroy((pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_mutex_destroy(IN VCODEC_PTHREAD_MUTEX_T *mutex); + + +/** + * @par Function + * VCodecDrvPthread_mutex_lock + * @par Description + * The pthread_mutex_lock wrapper function + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_mutex_lock((pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_mutex_lock(IN VCODEC_PTHREAD_MUTEX_T *mutex); + + +/** + * @par Function + * VCodecDrvPthread_mutex_unlock + * @par Description + * The pthread_mutex_unlock wrapper function + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_mutex_unlock((pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_mutex_unlock(IN VCODEC_PTHREAD_MUTEX_T *mutex); + + +/** + * @par Function + * VCodecDrvPthread_mutex_trylock + * @par Description + * The pthread_mutex_trylock wrapper function + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_mutex_trylock((pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_mutex_trylock(IN VCODEC_PTHREAD_MUTEX_T *mutex); + +/***** Spin Functions ******/ + + +/** + * @par Function + * VCodecDrvPthread_spin_init + * @par Description + * The pthread_spin_init wrapper function + * @param + * lock [OUT] lock + * @param + * pshared [IN] pshared + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_init(OUT VCODEC_PTHREAD_SPINLOCK_T *lock, IN int pshared); + + +/** + * @par Function + * VCodecDrvPthread_spin_destroy + * @par Description + * The pthread_spin_destroy wrapper function + * @param + * lock [IN] lock + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_destroy(IN VCODEC_PTHREAD_SPINLOCK_T *lock); + + +/** + * @par Function + * VCodecDrvPthread_spin_lock + * @par Description + * The pthread_spin_lock wrapper function + * @param + * lock [IN] lock + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_lock(IN VCODEC_PTHREAD_SPINLOCK_T *lock); + + +/** + * @par Function + * VCodecDrvPthread_spin_trylock + * @par Description + * The pthread_spin_trylock wrapper function + * @param + * lock [IN] lock + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_trylock(IN VCODEC_PTHREAD_SPINLOCK_T *lock); + + +/** + * @par Function + * VCodecDrvPthread_spin_unlock + * @par Description + * The pthread_spin_unlock wrapper function + * @param + * lock [IN] lock + * @par Returns + * int, -1, NOT implement + */ +int VCodecDrvPthread_spin_unlock(IN VCODEC_PTHREAD_SPINLOCK_T *lock); + +/***** Condition Variable Functions ******/ + + +/** + * @par Function + * VCodecDrvPthread_condattr_init + * @par Description + * The pthread_condattr_init wrapper function + * @param + * attr [OUT] attr + * @par Returns + * int, pthread_condattr_init((pthread_condattr_t *)attr); + */ +int VCodecDrvPthread_condattr_init(OUT VCODEC_PTHREAD_CONDATTR_T *attr); + + +/** + * @par Function + * VCodecDrvPthread_condattr_destroy + * @par Description + * The pthread_condattr_destroy wrapper function + * @param + * attr [IN] attr + * @par Returns + * int, pthread_condattr_destroy((pthread_condattr_t *)attr); + */ +int VCodecDrvPthread_condattr_destroy(IN VCODEC_PTHREAD_CONDATTR_T *attr); + + +/** + * @par Function + * VCodecDrvPthread_cond_init + * @par Description + * The pthread_cond_init wrapper function + * @param + * cond [OUT] cond + * @param + * attr [IN] attr + * @par Returns + * int, pthread_cond_init((pthread_cond_t *)cond, (const pthread_condattr_t *)attr); + */ +int VCodecDrvPthread_cond_init(OUT VCODEC_PTHREAD_COND_T *cond, IN const VCODEC_PTHREAD_CONDATTR_T *attr); + + +/** + * @par Function + * VCodecDrvPthread_cond_destroy + * @par Description + * The pthread_cond_destroy wrapper function + * @param + * cond [IN] cond + * @par Returns + * int, pthread_cond_destroy((pthread_cond_t *)cond); + */ +int VCodecDrvPthread_cond_destroy(IN VCODEC_PTHREAD_COND_T *cond); + + +/** + * @par Function + * VCodecDrvPthread_cond_broadcast + * @par Description + * The pthread_cond_broadcast wrapper function + * @param + * cond [IN] cond + * @par Returns + * int, pthread_cond_broadcast((pthread_cond_t *)cond); + */ +int VCodecDrvPthread_cond_broadcast(IN VCODEC_PTHREAD_COND_T *cond); + + +/** + * @par Function + * VCodecDrvPthread_cond_signal + * @par Description + * The pthread_cond_signal wrapper function + * @param + * cond [IN] cond + * @par Returns + * int, pthread_cond_signal((pthread_cond_t *)cond); + */ +int VCodecDrvPthread_cond_signal(IN VCODEC_PTHREAD_COND_T *cond); + + +/** + * @par Function + * VCodecDrvPthread_cond_signal + * @par Description + * The pthread_cond_wait wrapper function + * @param + * cond [IN] cond + * @param + * mutex [IN] mutex + * @par Returns + * int, pthread_cond_wait((pthread_cond_t *)cond, (pthread_mutex_t *)mutex); + */ +int VCodecDrvPthread_cond_wait(IN VCODEC_PTHREAD_COND_T *cond, IN VCODEC_PTHREAD_MUTEX_T *mutex); + +/************ End of Multi-thread function ***********/ + +/***** Semaphore Functions ******/ + + +/** + * @par Function + * VCodecDrv_sem_init + * @par Description + * The sem_init wrapper function + * @param + * sem [IN] sem + * @param + * pshared [IN] pshared + * @param + * value [IN] value + * @par Returns + * int, sem_init((sem_t*)sem, pshared, value); + */ +int VCodecDrv_sem_init(IN VCODEC_OAL_SEM_T *sem, IN int pshared, IN unsigned int value); + + +/** + * @par Function + * VCodecDrv_sem_destroy + * @par Description + * The sem_destroy wrapper function + * @param + * sem [IN] sem + * @par Returns + * int, sem_destroy((sem_t*)sem); + */ +int VCodecDrv_sem_destroy(IN VCODEC_OAL_SEM_T *sem); + + +/** + * @par Function + * VCodecDrv_sem_post + * @par Description + * The sem_post wrapper function + * @param + * sem [IN] sem + * @par Returns + * int, sem_post((sem_t*)sem); + */ +int VCodecDrv_sem_post(IN VCODEC_OAL_SEM_T *sem); + + +/** + * @par Function + * VCodecDrv_sem_wait + * @par Description + * The sem_wait wrapper function + * @param + * sem [IN] sem + * @par Returns + * int, sem_wait((sem_t*)sem); + */ +int VCodecDrv_sem_wait(IN VCODEC_OAL_SEM_T *sem); + +/***** Binding Functions ******/ + + +/** + * @par Function + * VCodecDrvBindingCore + * @par Description + * The function used to set given thread to binding specific CPU Core + * @param + * ThreadHandle [IN] given thread + * @param + * u4Mask [IN] specific CPU Core + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvBindingCore(IN VCODEC_PTHREAD_T ThreadHandle, IN unsigned int u4Mask); + + +/** + * @par Function + * VCodecDrvDeBindingCore + * @par Description + * The function used to set given thread to debinding specific CPU Core + * @param + * ThreadHandle [IN] given thread + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvDeBindingCore(IN VCODEC_PTHREAD_T ThreadHandle); + + +/** + * @par Function + * VCodecDrvGetAffinity + * @par Description + * The function used to set given thread to get specific CPU Core affinity + * @param + * ThreadHandle [IN] given thread + * @param + * pu4Mask [OUT] CPU mask + * @param + * pu4SetMask [OUT] Set CPU mask + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvGetAffinity(IN VCODEC_PTHREAD_T ThreadHandle, OUT unsigned int *pu4Mask, OUT unsigned int *pu4SetMask); + + +/** + * @par Function + * VCodecDrvGetAffinity + * @par Description + * The function used to get specific CPU Core loading + * @param + * s4CPUid [IN] COU id + * @param + * ps4Loading [OUT] CPU loading + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvCoreLoading(IN int s4CPUid, OUT int *ps4Loading); + + +/** + * @par Function + * VCodecDrvGetAffinity + * @par Description + * The function used to get total CPU Core number + * @param + * ps4CPUNums [OUT] CPU number + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecDrvCoreNumber(OUT int *ps4CPUNums); + + +/** + * @par Function + * VCodecDrvSleep + * @par Description + * The function used to sleep a while + * @param + * u4Tick [IN] unit: us + * @par Returns + * void + */ +void VCodecDrvSleep(IN unsigned int u4Tick); + + +/** + * @par Function + * OAL_SMP_BindingCore + * @par Description + * The function used to set given thread to binding specific CPU Core (only for test) + * @param + * aCurrentTid [IN] given thread id + * @param + * aCPUid [IN] specific CPU Core + * @par Returns + * int, return 0 if success, return -1 if failed + */ +int OAL_SMP_BindingCore(int aCurrentTid, int aCPUid); //ONLY used for TEST in main.c + +/***** MCI Functions ******/ + + +/** + * @par Function + * VCodecConfigMCIPort + * @par Description + * The function used to config MCI port + * @param + * u4PortConfig [IN] port config + * @param + * pu4PortResult [OUT] port result + * @param + * eCodecType [OUT] VDEC or VENC + * @par Returns + * VCODEC_OAL_ERROR_T, return VCODEC_OAL_ERROR_NONE if success, return VCODEC_OAL_ERROR_ERROR or VAL_RESULT_UNKNOWN_ERROR if failed + */ +VCODEC_OAL_ERROR_T VCodecConfigMCIPort(IN unsigned int u4PortConfig, OUT unsigned int *pu4PortResult, IN VCODEC_CODEC_TYPE_T eCodecType); + + +/***** Software vdec lib Functions ******/ + + +/** + * @par Function + * VCodecDrvMemAllocAligned_NC + * @par Description + * The function used to alloc external working memry for non-cacheable + * @param + * hDrv [IN] codec/driver handle + * @param + * u4Size [IN] allocated memory size + * @param + * u4AlignSize [IN] allocated memory byte alignment + * @param + * fgCacheable [IN] memory type + * @param + * prBuf [OUT] allocated memory buffer info + * @par Returns + * void + */ +void VCodecDrvMemAllocAligned_NC(IN HANDLE hDrv, IN unsigned int u4Size, unsigned int u4AlignSize, IN VCODEC_MEMORY_TYPE_T fgCacheable, OUT VCODEC_BUFFER_T *prBuf); + + +/** + * @par Function + * VCodecDrvMemFree_NC + * @par Description + * The function used to free external working memry + * @param + * hDrv [IN] codec/driver handle + * @param + * prBuf [IN] allocated memory buffer info + * @par Returns + * void + */ +void VCodecDrvMemFree_NC(IN HANDLE hDrv, IN VCODEC_BUFFER_T *prBuf); + + +/** + * @par Function + * VDecCodecQueryInfo + * @par Description + * The function used to query info + * @param + * hDrv [IN] codec/driver handle + * @param + * ID [IN] query info type + * @param + * pvQueryData [OUT] query data + * @par Returns + * void + */ +VCODEC_DEC_ERROR_T VDecCodecQueryInfo(IN HANDLE hDrv, IN VCODEC_DEC_QUERY_INFO_TYPE_T ID, OUT void *pvQueryData); +#if 0 +// MACRO + +#include "mach/sync_write.h" + +#define SP5_REGSYNC_WriteB(v, a) \ + mt65xx_reg_sync_writeb(v, a); + +#define SP5_REGSYNC_WriteW(v, a) \ + mt65xx_reg_sync_writew(v, a); + +#define SP5_REGSYNC_WriteL(v, a) \ + mt65xx_reg_sync_writel(v, a); + + +VAL_VOID_T SP5_RegSyncWriteB(VAL_UINT32_T v, VAL_UINT32_T a); +VAL_VOID_T SP5_RegSyncWriteW(VAL_UINT32_T v, VAL_UINT32_T a); +VAL_VOID_T SP5_RegSyncWriteL(VAL_UINT32_T v, VAL_UINT32_T a); +#endif +#endif diff --git a/include/linux/vcodec/val_types_private.h b/include/linux/vcodec/val_types_private.h new file mode 100644 index 000000000..330e07215 --- /dev/null +++ b/include/linux/vcodec/val_types_private.h @@ -0,0 +1,256 @@ +/** + * @file + * val_types_private.h + * + * @par Project: + * Video + * + * @par Description: + * Video Abstraction Layer Type Definitions for internal use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VAL_TYPES_PRIVATE_H_ +#define _VAL_TYPES_PRIVATE_H_ + +#include "val_types_public.h" + +#ifdef __cplusplus +extern "C" { +#endif + +//#define __EARLY_PORTING__ + +#define OALMEM_STATUS_NUM 16 + +/** + * @par Enumeration + * VAL_HW_COMPLETE_T + * @par Description + * This is polling or interrupt for waiting for HW done + */ +typedef enum _VAL_HW_COMPLETE_T +{ + VAL_POLLING_MODE = 0, ///< polling + VAL_INTERRUPT_MODE, ///< interrupt + VAL_MODE_MAX = 0xFFFFFFFF ///< Max result +} +VAL_HW_COMPLETE_T; + + +/** + * @par Enumeration + * VAL_CODEC_TYPE_T + * @par Description + * This is the item in VAL_OBJECT_T for open driver type and + * in VAL_CLOCK_T for clock setting and + * in VAL_ISR_T for irq line setting + */ +typedef enum _VAL_CODEC_TYPE_T +{ + VAL_CODEC_TYPE_NONE = 0, ///< None + VAL_CODEC_TYPE_MP4_ENC, ///< MP4 encoder + VAL_CODEC_TYPE_MP4_DEC, ///< MP4 decoder + VAL_CODEC_TYPE_H263_ENC, ///< H.263 encoder + VAL_CODEC_TYPE_H263_DEC, ///< H.263 decoder + VAL_CODEC_TYPE_H264_ENC, ///< H.264 encoder + VAL_CODEC_TYPE_H264_DEC, ///< H.264 decoder + VAL_CODEC_TYPE_SORENSON_SPARK_DEC, ///< Sorenson Spark decoder + VAL_CODEC_TYPE_VC1_SP_DEC, ///< VC-1 simple profile decoder + VAL_CODEC_TYPE_RV9_DEC, ///< RV9 decoder + VAL_CODEC_TYPE_MP1_MP2_DEC, ///< MPEG1/2 decoder + VAL_CODEC_TYPE_XVID_DEC, ///< Xvid decoder + VAL_CODEC_TYPE_DIVX4_DIVX5_DEC, ///< Divx4/5 decoder + VAL_CODEC_TYPE_VC1_MP_WMV9_DEC, ///< VC-1 main profile (WMV9) decoder + VAL_CODEC_TYPE_RV8_DEC, ///< RV8 decoder + VAL_CODEC_TYPE_WMV7_DEC, ///< WMV7 decoder + VAL_CODEC_TYPE_WMV8_DEC, ///< WMV8 decoder + VAL_CODEC_TYPE_AVS_DEC, ///< AVS decoder + VAL_CODEC_TYPE_DIVX_3_11_DEC, ///< Divx3.11 decoder + VAL_CODEC_TYPE_H264_DEC_MAIN, ///< H.264 main profile decoder (due to different packet) == 20 + VAL_CODEC_TYPE_MAX = 0xFFFFFFFF ///< Max driver type +} VAL_CODEC_TYPE_T; + + +typedef enum _VAL_CACHE_TYPE_T +{ + + VAL_CACHE_TYPE_CACHABLE = 0, + VAL_CACHE_TYPE_NONCACHABLE, + VAL_CACHE_TYPE_MAX = 0xFFFFFFFF + +} VAL_CACHE_TYPE_T; + + +/** + * @par Structure + * VAL_INTMEM_T + * @par Description + * This is a parameter for eVideoIntMemUsed() + */ +typedef struct _VAL_INTMEM_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_UINT32_T u4MemSize; ///< [OUT] The size of internal memory + VAL_VOID_T *pvMemVa; ///< [OUT] The internal memory start virtual address + VAL_VOID_T *pvMemPa; ///< [OUT] The internal memory start physical address + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +} VAL_INTMEM_T; + + +/** + * @par Structure + * VAL_EVENT_T + * @par Description + * This is a parameter for eVideoWaitEvent() and eVideoSetEvent() + */ +typedef struct _VAL_EVENT_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_VOID_T *pvWaitQueue; ///< [IN] The waitqueue discription + VAL_VOID_T *pvEvent; ///< [IN] The event discription + VAL_UINT32_T u4TimeoutMs; ///< [IN] The timeout ms + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +} VAL_EVENT_T; + + +/** + * @par Structure + * VAL_MUTEX_T + * @par Description + * This is a parameter for eVideoWaitMutex() and eVideoReleaseMutex() + */ +typedef struct _VAL_MUTEX_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_VOID_T *pvMutex; ///< [IN] The Mutex discriptor + VAL_UINT32_T u4TimeoutMs; ///< [IN] The timeout ms + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +} VAL_MUTEX_T; + + +/** + * @par Structure + * VAL_POWER_T + * @par Description + * This is a parameter for eVideoHwPowerCtrl() + */ +typedef struct _VAL_POWER_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_DRIVER_TYPE_T eDriverType; ///< [IN] The driver type + VAL_BOOL_T fgEnable; ///< [IN] Enable or not. + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure + //VAL_UINT32_T u4L2CUser; ///< [OUT] The number of power user right now +} VAL_POWER_T; + + +/** + * @par Structure + * VAL_MMAP_T + * @par Description + * This is a parameter for eVideoMMAP() and eVideoUNMAP() + */ +typedef struct _VAL_MMAP_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_VOID_T *pvMemPa; ///< [IN] The physical memory address + VAL_UINT32_T u4MemSize; ///< [IN] The memory size + VAL_VOID_T *pvMemVa; ///< [IN] The mapped virtual memory address + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +} VAL_MMAP_T; + + +typedef struct +{ + VAL_ULONG_T u4ReadAddr; /// [IN] memory source address in VA + VAL_UINT32_T u4ReadData; /// [OUT] memory data +} VAL_VCODEC_OAL_MEM_STAUTS_T; + + +typedef struct +{ + VAL_UINT32_T u4HWIsCompleted; ///< [IN/OUT] HW is Completed or not, set by driver & clear by codec (0: not completed or still in lock status; 1: HW is completed or in unlock status) + VAL_UINT32_T u4HWIsTimeout; ///< [OUT] HW is Timeout or not, set by driver & clear by codec (0: not in timeout status; 1: HW is in timeout status) + VAL_UINT32_T u4NumOfRegister; ///< [IN] Number of HW register need to store; + VAL_VCODEC_OAL_MEM_STAUTS_T *pHWStatus; ///< [OUT] HW status based on input address. +} VAL_VCODEC_OAL_HW_REGISTER_T; + + +typedef struct +{ + VAL_VCODEC_OAL_HW_REGISTER_T *Oal_HW_reg; + VAL_UINT32_T *Oal_HW_mem_reg; + VAL_UINT32_T *kva_Oal_HW_mem_reg; + VAL_ULONG_T pa_Oal_HW_mem_reg; + VAL_ULONG_T ObjId; + VAL_EVENT_T IsrEvent; + VAL_UINT32_T slotindex; + VAL_UINT32_T u4VCodecThreadNum; + VAL_UINT32_T u4VCodecThreadID[VCODEC_THREAD_MAX_NUM]; + VAL_HANDLE_T pvHandle; // physical address of the owner handle + VAL_UINT32_T u4NumOfRegister; + VAL_VCODEC_OAL_MEM_STAUTS_T oalmem_status[OALMEM_STATUS_NUM]; // MAX 16 items could be read; //kernel space access register + VAL_ULONG_T kva_u4HWIsCompleted; + VAL_ULONG_T kva_u4HWIsTimeout; + VAL_UINT32_T tid1; + VAL_UINT32_T tid2; + + // record VA, PA + VAL_UINT32_T *va1; + VAL_UINT32_T *va2; + VAL_UINT32_T *va3; + VAL_UINT32_T pa1; + VAL_UINT32_T pa2; + VAL_UINT32_T pa3; + +} VAL_VCODEC_OAL_HW_CONTEXT_T; + + +typedef struct +{ + int CPUid; // [in] + int Loading; // [out] +} VAL_VCODEC_CORE_LOADING_T; + +typedef void (*ena)(int); +typedef void (*disa)(int); +typedef void (*ena_timeout)(int, int); +typedef int (*user_reg)(int, int); +typedef void (*user_unreg)(int); +typedef void (*user_enable)(int); +typedef void (*user_disable)(int); +typedef void (*user_enable_timeout)(int, int); +typedef int (*user_reg_scn)(void); +typedef void (*user_reg_scn_config)(int, int, int, int, int, int); +typedef void (*user_unreg_scn)(int); + + + +typedef struct _VAL_INIT_HANDLE +{ + int i4DriverType; + int i4VENCLivePhoto; +} VAL_INIT_HANDLE; +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VAL_TYPES_PRIVATE_H_ diff --git a/include/linux/vcodec/val_types_public.h b/include/linux/vcodec/val_types_public.h new file mode 100644 index 000000000..e93edd95d --- /dev/null +++ b/include/linux/vcodec/val_types_public.h @@ -0,0 +1,573 @@ +/** + * @file + * val_types_public.h + * + * @par Project: + * Video + * + * @par Description: + * Video Abstraction Layer Type Definitions for external use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VAL_TYPES_PUBLIC_H_ +#define _VAL_TYPES_PUBLIC_H_ + +//#include +//#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define IRQ_STATUS_MAX_NUM 16 ///< support max 16 return register values when HW done + +#define VCODEC_THREAD_MAX_NUM 16 ///< support max 16 multiple thread currently + +/*============================================================================= + * Type definition + *===========================================================================*/ + +typedef void VAL_VOID_T; ///< void type definition +typedef char VAL_BOOL_T; ///< char type definition +typedef char VAL_CHAR_T; ///< char type definition +typedef signed char VAL_INT8_T; ///< signed char type definition +typedef signed short VAL_INT16_T; ///< signed short type definition +typedef signed int VAL_INT32_T; ///< signed int type definition +typedef unsigned char VAL_UCHAR_T; ///< unsigned char type definition +typedef unsigned char VAL_UINT8_T; ///< unsigned char type definition +typedef unsigned short VAL_UINT16_T; ///< unsigned short definition +typedef unsigned int VAL_UINT32_T; ///< unsigned int type definition +typedef unsigned long long VAL_UINT64_T; ///< unsigned long long type definition +typedef long long VAL_INT64_T; ///< long long type definition +typedef unsigned long VAL_HANDLE_T; ///< unsigned int (handle) type definition +typedef signed long VAL_LONG_T; /// +typedef unsigned long VAL_ULONG_T; /// + +#define VAL_NULL (0) ///< VAL_NULL = 0 +#define VAL_TRUE (1) ///< VAL_TRUE = 1 +#define VAL_FALSE (0) ///< VAL_FALSE = 0 + +#define VAL_RESOLUTION_CHANGED (2) ///< VAL_RESOLUTION_CHANGED = 2, used to video resolution changed during playback + + +/** + * @par Enumeration + * VAL_MEM_CODEC_T + * @par Description + * This is the item used to memory usage for video encoder or video decoder + */ +typedef enum _VAL_MEM_CODEC_T +{ + VAL_MEM_CODEC_FOR_VENC = 0, ///< Memory for Video Encoder + VAL_MEM_CODEC_FOR_VDEC, ///< Memory for Video Decoder + VAL_MEM_CODEC_MAX = 0xFFFFFFFF ///< Max Value +} VAL_MEM_CODEC_T; + + +/** + * @par Enumeration + * VAL_CHIP_NAME_T + * @par Description + * This is the item for query chip name for HAL interface + */ +typedef enum _VAL_CHIP_NAME_T +{ + VAL_CHIP_NAME_MT6516 = 0, ///< MT6516 + VAL_CHIP_NAME_MT6571, ///< MT6571 + VAL_CHIP_NAME_MT6572, ///< MT6572 + VAL_CHIP_NAME_MT6573, ///< MT6573 + VAL_CHIP_NAME_MT6575, ///< MT6575 + VAL_CHIP_NAME_MT6577, ///< MT6577 + VAL_CHIP_NAME_MT6589, ///< MT6589 + VAL_CHIP_NAME_MT6582, ///< MT6582 + VAL_CHIP_NAME_MT8135, ///< MT8135 + VAL_CHIP_NAME_ROME, ///< ROME + VAL_CHIP_NAME_MT6592, ///< MT6592 + VAL_CHIP_NAME_MT8127, ///< MT8127 + VAL_CHIP_NAME_MT6752, ///< MT6752 + VAL_CHIP_NAME_MT6795, ///< MT6795 + VAL_CHIP_NAME_DENALI_1, ///< Denali-1 + VAL_CHIP_NAME_DENALI_2, ///< Denali-2 + VAL_CHIP_NAME_DENALI_3, ///< Denali-3 + VAL_CHIP_NAME_MT6570, ///< Rainier (2 core) + VAL_CHIP_NAME_MT6580, ///< Rainier (4 core) + VAL_CHIP_NAME_MT8163, + VAL_CHIP_NAME_MAX = 0xFFFFFFFF ///< Max Value +} VAL_CHIP_NAME_T; + +/** + * @par Enumeration + * VAL_CHIP_VARIANT_T + * @par Description + * This is the item for query chip variant for HAL interface + */ +typedef enum _VAL_CHIP_VARIANT_T +{ + VAL_CHIP_VARIANT_MT6571L = 0, ///< MT6571L + VAL_CHIP_VARIANT_MAX = 0xFFFFFFFF ///< Max Value +} VAL_CHIP_VARIANT_T; + + +/** + * @par Enumeration + * VAL_CHIP_VERSION_T + * @par Description + * This is the item used to GetChipVersionAPI() + */ +typedef enum _VAL_CHIP_VERSION_T +{ + VAL_CHIP_VERSION_HW_CODE = 0, ///< The data will be "6595" for 6595 series; "6795" for 6795 series, ... + VAL_CHIP_VERSION_SW_VER, ///< The data will be "0000" for E1; "0001" for E2, ... + VAL_CHIP_VERSION_MAX = 0xFFFFFFFF ///< Max Value +} VAL_CHIP_VERSION_T; + + +/** + * @par Enumeration + * VAL_DRIVER_TYPE_T + * @par Description + * This is the item for driver type + */ +typedef enum _VAL_DRIVER_TYPE_T +{ + VAL_DRIVER_TYPE_NONE = 0, ///< None + VAL_DRIVER_TYPE_MP4_ENC, ///< MP4 encoder + VAL_DRIVER_TYPE_MP4_DEC, ///< MP4 decoder + VAL_DRIVER_TYPE_H263_ENC, ///< H.263 encoder + VAL_DRIVER_TYPE_H263_DEC, ///< H.263 decoder + VAL_DRIVER_TYPE_H264_ENC, ///< H.264 encoder + VAL_DRIVER_TYPE_H264_DEC, ///< H.264 decoder + VAL_DRIVER_TYPE_SORENSON_SPARK_DEC, ///< Sorenson Spark decoder + VAL_DRIVER_TYPE_VC1_SP_DEC, ///< VC-1 simple profile decoder + VAL_DRIVER_TYPE_RV9_DEC, ///< RV9 decoder + VAL_DRIVER_TYPE_MP1_MP2_DEC, ///< MPEG1/2 decoder + VAL_DRIVER_TYPE_XVID_DEC, ///< Xvid decoder + VAL_DRIVER_TYPE_DIVX4_DIVX5_DEC, ///< Divx4/5 decoder + VAL_DRIVER_TYPE_VC1_MP_WMV9_DEC, ///< VC-1 main profile (WMV9) decoder + VAL_DRIVER_TYPE_RV8_DEC, ///< RV8 decoder + VAL_DRIVER_TYPE_WMV7_DEC, ///< WMV7 decoder + VAL_DRIVER_TYPE_WMV8_DEC, ///< WMV8 decoder + VAL_DRIVER_TYPE_AVS_DEC, ///< AVS decoder + VAL_DRIVER_TYPE_DIVX_3_11_DEC, ///< Divx3.11 decoder + VAL_DRIVER_TYPE_H264_DEC_MAIN, ///< H.264 main profile decoder (due to different packet) == 20 + VAL_DRIVER_TYPE_H264_DEC_MAIN_CABAC, ///< H.264 main profile decoder for CABAC type but packet is the same, just for reload. + VAL_DRIVER_TYPE_VP8_DEC, ///< VP8 decoder + VAL_DRIVER_TYPE_MP2_DEC, ///< MPEG2 decoder + VAL_DRIVER_TYPE_VP9_DEC, ///< VP9 decoder + VAL_DRIVER_TYPE_VP8_ENC, ///< VP8 encoder + VAL_DRIVER_TYPE_VC1_ADV_DEC, ///< VC1 advance decoder + VAL_DRIVER_TYPE_VC1_DEC, ///< VC1 simple/main/advance decoder + VAL_DRIVER_TYPE_JPEG_ENC, ///< JPEG encoder + VAL_DRIVER_TYPE_HEVC_ENC, ///< HEVC encoder + VAL_DRIVER_TYPE_HEVC_DEC, ///< HEVC decoder + VAL_DRIVER_TYPE_H264_ENC_LIVEPHOTO, // LivePhoto type + VAL_DRIVER_TYPE_MAX = 0xFFFFFFFF ///< Max driver type +} VAL_DRIVER_TYPE_T; + + +/** + * @par Enumeration + * VAL_RESULT_T + * @par Description + * This is the return status of each OSAL function + */ +typedef enum _VAL_RESULT_T +{ + VAL_RESULT_NO_ERROR = 0, ///< The function work successfully + VAL_RESULT_INVALID_DRIVER, ///< Error due to invalid driver + VAL_RESULT_INVALID_PARAMETER, ///< Error due to invalid parameter + VAL_RESULT_INVALID_MEMORY, ///< Error due to invalid memory + VAL_RESULT_INVALID_ISR, ///< Error due to invalid isr request + VAL_RESULT_ISR_TIMEOUT, ///< Error due to invalid isr request + VAL_RESULT_UNKNOWN_ERROR, ///< Unknown error + VAL_RESULT_RESTARTSYS, ///< Restart sys + VAL_RESULT_MAX = 0xFFFFFFFF ///< Max result +} VAL_RESULT_T; + + +/** + * @par Enumeration + * VAL_MEM_ALIGN_T + * @par Description + * This is the item for allocation memory byte alignment + */ +typedef enum _VAL_MEM_ALIGN_T +{ + VAL_MEM_ALIGN_1 = 1, ///< 1 byte alignment + VAL_MEM_ALIGN_2 = (1 << 1), ///< 2 byte alignment + VAL_MEM_ALIGN_4 = (1 << 2), ///< 4 byte alignment + VAL_MEM_ALIGN_8 = (1 << 3), ///< 8 byte alignment + VAL_MEM_ALIGN_16 = (1 << 4), ///< 16 byte alignment + VAL_MEM_ALIGN_32 = (1 << 5), ///< 32 byte alignment + VAL_MEM_ALIGN_64 = (1 << 6), ///< 64 byte alignment + VAL_MEM_ALIGN_128 = (1 << 7), ///< 128 byte alignment + VAL_MEM_ALIGN_256 = (1 << 8), ///< 256 byte alignment + VAL_MEM_ALIGN_512 = (1 << 9), ///< 512 byte alignment + VAL_MEM_ALIGN_1K = (1 << 10), ///< 1K byte alignment + VAL_MEM_ALIGN_2K = (1 << 11), ///< 2K byte alignment + VAL_MEM_ALIGN_4K = (1 << 12), ///< 4K byte alignment + VAL_MEM_ALIGN_8K = (1 << 13), ///< 8K byte alignment + VAL_MEM_ALIGN_MAX = 0xFFFFFFFF ///< Max memory byte alignment +} VAL_MEM_ALIGN_T; + + +/** + * @par Enumeration + * VAL_MEM_TYPE_T + * @par Description + * This is the item for allocation memory type + */ +typedef enum _VAL_MEM_TYPE_T +{ + VAL_MEM_TYPE_FOR_SW = 0, ///< External memory foe SW + VAL_MEM_TYPE_FOR_HW_CACHEABLE, ///< External memory for HW Cacheable + VAL_MEM_TYPE_FOR_HW_CACHEABLE_MCI, ///< External memory for HW Cacheable, with MCI port config + VAL_MEM_TYPE_FOR_HW_NONCACHEABLE, ///< External memory for HW Non-Cacheable + VAL_MEM_TYPE_MAX = 0xFFFFFFFF ///< Max memory type +} VAL_MEM_TYPE_T; + + +/** + * @par Structure + * VAL_MEM_ADDR_T + * @par Description + * This is a structure for memory address + */ +typedef struct _VAL_MEM_ADDR_T +{ + VAL_ULONG_T u4VA; ///< [IN/OUT] virtual address + VAL_ULONG_T u4PA; ///< [IN/OUT] physical address + VAL_ULONG_T u4Size; ///< [IN/OUT] size +} VAL_MEM_ADDR_T; + + +/** + * @par Structure + * VAL_VCODEC_THREAD_ID_T + * @par Description + * This is a structure for thread info + */ +typedef struct _VAL_VCODEC_THREAD_ID_T +{ + VAL_UINT32_T u4tid1; ///< [IN/OUT] thread id for single core + VAL_UINT32_T u4tid2; ///< [IN/OUT] thread id for single core + VAL_UINT32_T u4VCodecThreadNum; ///< [IN/OUT] thread num + VAL_UINT32_T u4VCodecThreadID[VCODEC_THREAD_MAX_NUM]; ///< [IN/OUT] thread id for each thread +} VAL_VCODEC_THREAD_ID_T; + + +/** + * @par Structure + * VAL_VCODEC_CPU_LOADING_INFO_T + * @par Description + * This is a structure for CPU loading info + */ +typedef struct _VAL_VCODEC_CPU_LOADING_INFO_T +{ + unsigned long long _cpu_idle_time; ///< [OUT] cpu idle time + unsigned long long _thread_cpu_time; ///< [OUT] thread cpu time + unsigned long long _sched_clock; ///< [OUT] sched clock + unsigned int _inst_count; ///< [OUT] inst count +} VAL_VCODEC_CPU_LOADING_INFO_T; + + +/** + * @par Structure + * VAL_VCODEC_CPU_OPP_LIMIT_T + * @par Description + * This is a structure for CPU opp limit info + */ +typedef struct _VAL_VCODEC_CPU_OPP_LIMIT_T +{ + int limited_freq; ///< [IN] limited freq + int limited_cpu; ///< [IN] limited cpu + int enable; ///< [IN] enable +} VAL_VCODEC_CPU_OPP_LIMIT_T; + + +/** + * @par Structure + * VAL_VCODEC_M4U_BUFFER_CONFIG_T + * @par Description + * This is a structure for m4u buffer config + */ +typedef struct _VAL_VCODEC_M4U_BUFFER_CONFIG_T +{ + VAL_MEM_CODEC_T eMemCodec; ///< [IN] memory usage for encoder or decoder + VAL_UINT32_T cache_coherent; ///< [IN] cache coherent or not + VAL_UINT32_T security; ///< [IN] security or not +} VAL_VCODEC_M4U_BUFFER_CONFIG_T; + + +/** + * @par Structure + * VAL_MEMORY_T + * @par Description + * This is a parameter for memory usaged function + */ +typedef struct _VAL_MEMORY_T +{ + VAL_MEM_TYPE_T eMemType; ///< [IN] The allocation memory type + VAL_ULONG_T u4MemSize; ///< [IN] The size of memory allocation + VAL_VOID_T *pvMemVa; ///< [IN/OUT] The memory virtual address + VAL_VOID_T *pvMemPa; ///< [IN/OUT] The memory physical address + VAL_MEM_ALIGN_T eAlignment; ///< [IN] The memory byte alignment setting + VAL_VOID_T *pvAlignMemVa; ///< [IN/OUT] The align memory virtual address + VAL_VOID_T *pvAlignMemPa; ///< [IN/OUT] The align memory physical address + VAL_MEM_CODEC_T eMemCodec; ///< [IN] The memory codec for VENC or VDEC + VAL_UINT32_T i4IonShareFd; + struct ion_handle *pIonBufhandle; + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_ULONG_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +#ifdef __EARLY_PORTING__ + VAL_VOID_T *pvReservedPmem; ///< [IN/OUT] The reserved parameter +#endif +} VAL_MEMORY_T; + +/** + * @par Structure + * VAL_RECORD_SIZE_T + * @par Description + * This is a parameter for setting record size to EMI controller + */ +typedef struct __VAL_RECORD_SIZE_T +{ + VAL_UINT32_T u4FrmWidth; ///< [IN] Frame Width, (may not 16 byte-align) + VAL_UINT32_T u4FrmHeight; ///< [IN] Frame Height, (may not 16 byte-align) + VAL_UINT32_T u4BufWidth; ///< [IN] Buffer Width, (must 16 byte-align) + VAL_UINT32_T u4BufHeight; ///< [IN] Buffer Height, (must 16 byte-align) +} VAL_RECORD_SIZE_T; + + +/** + * @par Structure + * VAL_ATOI_T + * @par Description + * This is a parameter for eVideoAtoi() + */ +typedef struct _VAL_ATOI_T +{ + VAL_VOID_T *pvStr; ///< [IN] Null-terminated String to be converted + VAL_INT32_T i4Result; ///< [Out] returns the int value produced by interpreting the input characters as a number. + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +} VAL_ATOI_T; + + +/** + * @par Structure + * VAL_STRSTR_T + * @par Description + * This is a parameter for eVideoStrStr() + */ +typedef struct _VAL_STRSTR_T +{ + VAL_VOID_T *pvStr; ///< [IN] Null-terminated string to search. + VAL_VOID_T *pvStrSearch; ///< [IN] Null-terminated string to search for + VAL_VOID_T *pvStrResult; ///< [Out] Returns a pointer to the first occurrence of strSearch in str, or NULL if strSearch does not appear in str. + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure +} VAL_STRSTR_T; + + +/** + * @par Structure + * VAL_ISR_T + * @par Description + * This is a parameter for ISR related function + */ +typedef struct _VAL_ISR_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_DRIVER_TYPE_T eDriverType; ///< [IN] The driver type + VAL_VOID_T *pvIsrFunction; ///< [IN] The isr function + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure + VAL_UINT32_T u4TimeoutMs; ///< [IN] The timeout in ms + VAL_UINT32_T u4IrqStatusNum; ///< [IN] The num of return registers when HW done + VAL_UINT32_T u4IrqStatus[IRQ_STATUS_MAX_NUM]; ///< [IN/OUT] The value of return registers when HW done +} VAL_ISR_T; + + +/** + * @par Structure + * VAL_HW_LOCK_T + * @par Description + * This is a parameter for HW Lock/UnLock related function + */ +typedef struct _VAL_HW_LOCK_T +{ + VAL_VOID_T *pvHandle; ///< [IN] The video codec driver handle + VAL_UINT32_T u4HandleSize; ///< [IN] The size of video codec driver handle + VAL_VOID_T *pvLock; ///< [IN/OUT] The Lock discriptor + VAL_UINT32_T u4TimeoutMs; ///< [IN] The timeout ms + VAL_VOID_T *pvReserved; ///< [IN/OUT] The reserved parameter + VAL_UINT32_T u4ReservedSize; ///< [IN] The size of reserved parameter structure + VAL_DRIVER_TYPE_T eDriverType; ///< [IN] The driver type + VAL_BOOL_T bSecureInst; ///< [IN] True if this is a secure instance // MTK_SEC_VIDEO_PATH_SUPPORT +} VAL_HW_LOCK_T; + + +/** + * @par Structure + * VAL_TIME_T + * @par Description + * This is a structure for system time. + */ +typedef struct _VAL_TIME_T +{ + VAL_UINT32_T u4Sec; ///< [IN/OUT] second + VAL_UINT32_T u4uSec; ///< [IN/OUT] micro second +} VAL_TIME_T; + + +/** + * @par Enumeration + * VAL_SET_TYPE_T + * @par Description + * This is the item for setting val parameter + */ +typedef enum _VAL_SET_TYPE_T +{ + VAL_SET_TYPE_CURRENT_SCENARIO, ///< Set current scenario + VAL_SET_TYPE_MCI_PORT_CONFIG, ///< Set MCI port config + VAL_SET_TYPE_M4U_PORT_CONFIG ///< Set M4U port config +} VAL_SET_TYPE_T; + +/** + * @par Enumeration + * VAL_GET_TYPE_T + * @par Description + * This is the item for getting val parameter + */ +typedef enum _VAL_GET_TYPE_T +{ + VAL_GET_TYPE_CURRENT_SCENARIO_CNT, ///< Get current scenario reference count + VAL_GET_TYPE_LCM_INFO, ///< Get LCM info +} VAL_GET_TYPE_T; + +/** + * @par Enumeration + * VAL_VCODEC_SCENARIO + * @par Description + * This is the item for get/setting current vcodec scenario + */ +typedef enum _VAL_VCODEC_SCENARIO_T +{ + VAL_VCODEC_SCENARIO_VENC_1080P = 0x1, ///< Camera recording 1080P + VAL_VCODEC_SCENARIO_VDEC_1080P = 0x2, ///< Playback 1080P + VAL_VCODEC_SCENARIO_VENC_WFD = 0x4, ///< Wifi-display encoding +} VAL_VCODEC_SCENARIO_T; + +/** + * @par Structure + * VAL_CURRENT_SCENARIO_T + * @par Description + * This is a structure for set/get current scenario + */ +typedef struct _VAL_CURRENT_SCENARIO_T +{ + VAL_UINT32_T u4Scenario; ///< [IN/OUT] set/get current scenario + VAL_UINT32_T u4OnOff; ///< [IN] set on/off (increment/decrement) 1 = inc, 0 = dec +} VAL_CURRENT_SCENARIO_T; + +/** + * @par Structure + * VAL_CURRENT_SCENARIO_CNT_T + * @par Description + * This is a structure for set/get current scenario reference count + */ +typedef struct _VAL_CURRENT_SCENARIO_CNT_T +{ + VAL_UINT32_T u4Scenario; ///< [IN] current scenario type + VAL_UINT32_T u4ScenarioRefCount; ///< [OUT] current scenario reference count +} VAL_CURRENT_SCENARIO_CNT_T; + + +/** + * @par Structure + * VAL_MCI_PORT_CONFIG_T + * @par Description + * This is a structure for set/get MCI port config + */ +typedef struct _VAL_MCI_PORT_CONFIG_T +{ + VAL_MEM_CODEC_T eMemCodecType; ///< [IN] memory type - decoder/encoder + VAL_UINT32_T u4Config; ///< [IN] set port config +} VAL_MCI_PORT_CONFIG_T; + +/** + * @par Structure + * VAL_LCM_INFO_T + * @par Description + * This is a structure for get LCM info + */ +typedef struct _VAL_LCM_INFO_T +{ + VAL_UINT32_T u4Width; ///< [OUT] width + VAL_UINT32_T u4Height; ///< [OUT] height +} VAL_LCM_INFO_T; + +#define VAL_M4U_PORT_ALL (-1) ///< VAL_M4UPORT_DEFAULT_ALL = 1, config all M4U port for VENC or VDEC + +/** + * @par Structure + * VAL_M4U_MPORT_CONFIG_T + * @par Description + * This is a parameter for eVideoSetParam() input structure + */ +typedef struct _VAL_M4U_MPORT_CONFIG_T +{ + VAL_MEM_CODEC_T eMemCodec; ///< [IN] The memory codec for VENC or VDEC + VAL_UINT32_T i4M4UPortID; ///< [IN] config port ID (VAL_M4U_PORT_ALL[-1] = config all VENC or VDEC) + VAL_BOOL_T bSecurity; ///< [IN] config port security + VAL_BOOL_T bVirtuality; ///< [IN] config port virtuality +} VAL_M4U_MPORT_CONFIG_T; + + +/* for DirectLink Meta Mode + */ +#define META_HANDLE_LIST_MAX 50 + +typedef struct _VAL_MetaBufInfo +{ + void *pNativeHandle; + VAL_ULONG_T u4VA; + VAL_ULONG_T u4PA; + VAL_UINT32_T u4BuffSize; + VAL_BOOL_T bUseION; + int fd; + struct ion_handle *pIonBufhandle; +} VAL_MetaBufInfo; + +typedef struct _VAL_MetaHandleList +{ + int mIonDevFd; + VAL_MetaBufInfo rMetaBufInfo[META_HANDLE_LIST_MAX]; + VAL_BOOL_T fgSeqHdrEncoded; +} VAL_MetaHandleList; + +typedef struct _VAL_BufInfo +{ + VAL_UINT8_T fgIsConfigData; + VAL_ULONG_T u4BSVA; + VAL_UINT8_T fgBSStatus; + VAL_UINT8_T fgIsKeyFrame; + VAL_UINT32_T u4BSSize; +} VAL_BufInfo; +/* for DirectLink Meta Mode - */ + + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VAL_TYPES_PUBLIC_H_ diff --git a/include/linux/vcodec/val_vcodec_utility.h b/include/linux/vcodec/val_vcodec_utility.h new file mode 100644 index 000000000..25dd84932 --- /dev/null +++ b/include/linux/vcodec/val_vcodec_utility.h @@ -0,0 +1,98 @@ +/** + * @file + * val_vcodec_utility.h + * + * @par Project: + * Video + * + * @par Description: + * video codec utility function interface + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VAL_VCODEC_UTILITY_H_ +#define _VAL_VCODEC_UTILITY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" +#include "hal_api.h" + +// for hardware vc1_dec + + +/** + * @par Function + * BPDec + * @par Description + * The function used to BP dec + * @param + * hHandle [IN/OUT] handle + * @param + * hBitHandle [IN/OUT] bits nandle + * @param + * bpType [IN] WMV_BP_TYPE + * @par Returns + * VDDRV_MRESULT_T, return VDDRV_MRESULT_SUCCESS is success, return others if fail + */ +VDDRV_MRESULT_T BPDec(VAL_HANDLE_T hHandle, VAL_HANDLE_T *hBitHandle, WMV_BP_TYPE bpType); + + +/** + * @par Function + * GetReadBSPt + * @par Description + * The function used to get bitstream pointer + * @param + * hHandle [IN/OUT] handle + * @param + * hBitsHandle [IN/OUT] bits nandle + * @param + * pBits [IN] Bits + * @par Returns + * VAL_UINT32_T, return bitstream pointer + */ +VAL_UINT32_T GetReadBSPt(VAL_HANDLE_T hHandle, VAL_HANDLE_T hBitsHandle, VAL_UINT32_T *pBits); + + +/** + * @par Function + * GetBPDecBits + * @par Description + * The function used to get decode bits + * @param + * hHandle [IN/OUT] handle + * @par Returns + * VAL_UINT32_T, return decode bits + */ +VAL_UINT32_T GetBPDecBits(VAL_HANDLE_T hHandle); + + +/** + * @par Function + * WMVDecode_HW + * @par Description + * The function used to decode WMV + * @param + * hHandle [IN/OUT] handle + * @param + * hBitHandle [IN/OUT] bits nandle + * @par Returns + * VDDRV_MRESULT_T, return VDDRV_MRESULT_SUCCESS is success, return others if fail + */ +VDDRV_MRESULT_T WMVDecode_HW(VAL_HANDLE_T hHandle, VAL_HANDLE_T *hBitHandle); +// for hardware vc1_dec - + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VAL_VCODEC_UTILITY_H_ diff --git a/include/linux/vcodec/vcodec_OAL_v2.h b/include/linux/vcodec/vcodec_OAL_v2.h new file mode 100644 index 000000000..59f86daa8 --- /dev/null +++ b/include/linux/vcodec/vcodec_OAL_v2.h @@ -0,0 +1,508 @@ +#ifndef VCODEC_OAL_V2_H +#define VCODEC_OAL_V2_H +#define IN +#define OUT + +#ifndef NULL +#define NULL 0 +#endif + +#include "vcodec_if_v2.h" + +#ifdef WIN32 +#include + +#endif +#define VCODEC_OAL_VERSION 20140812 +#define VCODEC_ASSERT(expr, a) do {if(!(expr)) rVCODEC_OAL_Function.VCodecAssertFail(__FILE__, __LINE__, a); } while (0) + +typedef enum +{ + VCODEC_OAL_H264_DEC, + VCODEC_OAL_HEVC_DEC, + VCODEC_OAL_VP8_DEC , + VCODEC_OAL_VP9_DEC , + VCODEC_OAL_RMVB_DEC , + VCODEC_OAL_MPEG2_DEC , + VCODEC_OAL_MPEG4_DEC, + VCODEC_OAL_H264_ENC, + VCODEC_OAL_HEVC_ENC, + VCODEC_OAL_VP8_ENC , + VCODEC_OAL_VP9_ENC , + VCODEC_OAL_MPEG4_ENC, + NUM_OF_VCODEC_OAL_CODEC_TYP, +} VCODEC_OAL_CODEC_TYPE; + +typedef struct +{ + VCODEC_OAL_CODEC_TYPE eCodec; + void *reserve1; + void *reserve2; + void *reserve3; + void *reserve4; +}VCODEC_OAL_HW_CTR_INFO_T; + +void VCodecQueryMemType(IN void *pBuffer_VA, + IN unsigned int u4Size, + OUT VCODEC_MEMORY_TYPE_T *peMemType + ); + +void VCodecQueryPhysicalAddr(IN void *pBuffer_VA, + OUT void **pBufferOut_PA + ); + +// VCodecSwitchMemType - return 0 if success. +// return -1 if failed, but pBufferOut_VA will be assigned with pBuffer_VA +int VCodecSwitchMemType(IN void *pBuffer_VA, + IN unsigned int u4Size, + IN VCODEC_MEMORY_TYPE_T eMemType, + OUT void **pBufferOut_VA + ); + +// VCodecFlushCachedBuffer - u4Size is in byte +void VCodecFlushCachedBuffer(IN void *pBuffer_VA, + IN unsigned int u4Size + ); + +// VCodecInvalidateCachedBuffer - u4Size is in byte +void VCodecInvalidateCachedBuffer(IN void *pBuffer_VA, + IN unsigned int u4Size + ); + +void VCodecFlushCachedBufferAll(void); + +void VCodecInvalidateCachedBufferAll(void); + +void VCodecFlushInvalidateCacheBufferAll(void); + +void VCodecMemSet(IN void *pBuffer_VA, + IN char cValue, + IN unsigned int u4Length + ); + +void VCodecMemCopy(IN void *pvDest , + IN const void *pvSrc , + IN unsigned int u4Length + ); +typedef struct +{ + void *pBuffer_PA; ///< [IN] The physical memory address + unsigned int u4MemSize; ///< [IN] The memory size to be mapped + void *pBuffer_VA; ///< [OUT] The mapped virtual memory address +} VCODEC_OAL_MMAP_T; + +void VCodecMMAP(VCODEC_OAL_MMAP_T *prParam); +void VCodecUnMMAP(VCODEC_OAL_MMAP_T *prParam); + + +typedef enum +{ + VCODEC_OAL_VDEC, + VCODEC_OAL_VENC +} VCODEC_OAL_CODEC; + +typedef struct +{ + unsigned int u4ReadAddr; /// [IN] memory source address in VA + unsigned int u4ReadData; /// [OUT] memory data +} VCODEC_OAL_MEM_STAUTS_T; + +typedef struct +{ + unsigned int u4HWIsCompleted; ///< [IOUT] HW is Completed or not, set by driver & clear by codec (0: not completed or still in lock status; 1: HW is completed or in unlock status) + unsigned int u4HWIsTimeout; ///< [OUT] HW is Timeout or not, set by driver & clear by codec (0: not in timeout status; 1: HW is in timeout status) + unsigned int u4NumOfRegister; ///< [IN] Number of HW register need to store; + VCODEC_OAL_MEM_STAUTS_T *pHWStatus; ///< [OUT] HW status based on input address. +} VCODEC_OAL_HW_REGISTER_T; + +typedef struct +{ + void *pvHandle; ///< [IN] The video codec handle + void *pvIsrFunction; ///< [IN] The isr function + unsigned int u4TimeoutMs; ///< [IN] The timeout in ms + VCODEC_OAL_CODEC eCodec; ///< [IN] VDEC or VENC interrupt +} VCODEC_OAL_ISR_T; + +// return value: HW is completed (1) or not (0) when function return +int VCodecWaitISR(VCODEC_OAL_ISR_T *prParam); + + +typedef struct +{ + void *pvHandle; ///< [IN] The video codec handle + unsigned int u4TimeoutMs; ///< [IN] The timeout ms +} VCODEC_OAL_HW_LOCK_T; + +// return value: HW is completed (1) or not (0) when function return +int VCodecLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + +// return value: HW is completed (1) or not (0) when function return +int VCodecUnLockHW(VCODEC_OAL_HW_LOCK_T *prParam); + + +void VCodecInitHWLock(VCODEC_OAL_HW_REGISTER_T *prParam); + +void VCodecDeInitHWLock(VCODEC_OAL_HW_REGISTER_T *prParam); + + +/****** Pthread define******/ +#ifdef WIN32 +#define VCODEC_PTHREAD_PROCESS_PRIVATE 0 +#define VCODEC_PTHREAD_PROCESS_SHARED 1 +#define VCODEC_PTHREAD_CREATE_JOINABLE 0 +#define VCODEC_PTHREAD_CREATE_DETACHED 1 +#define VCODEC_PTHREAD_SCOPE_PROCESS 0 +#define VCODEC_PTHREAD_SCOPE_SYSTEM 1 +#define VCODEC_PTHREAD_ONCE_INIT 0 +typedef volatile int VCODEC_PTHREAD_ONCE_T; + +typedef int VCODEC_PTHREAD_ATTR_T; + +typedef int VCODEC_PTHREAD_MUTEXATTR_T; +typedef int VCODEC_PTHREAD_CONDATTR_T; +typedef CRITICAL_SECTION VCODEC_PTHREAD_MUTEX_T; + +typedef struct +{ + void *handle; + void *(*func)( void* arg ); + void *arg; + void *ret; +} VCODEC_PTHREAD_T; + + +typedef struct +{ + int interlock; + VCODEC_PTHREAD_MUTEX_T mutex; +}VCODEC_PTHREAD_SPINLOCK_T; +typedef struct +{ + void *ptr; +} VCODEC_PTHREAD_COND_T; +#elif defined(ANDROID) +#define VCODEC_PTHREAD_PROCESS_PRIVATE 0 +#define VCODEC_PTHREAD_PROCESS_SHARED 1 +#define VCODEC_PTHREAD_CREATE_JOINABLE 0 +#define VCODEC_PTHREAD_CREATE_DETACHED 1 +#define VCODEC_PTHREAD_SCOPE_PROCESS 0 +#define VCODEC_PTHREAD_SCOPE_SYSTEM 1 +#define VCODEC_PTHREAD_ONCE_INIT 0 +typedef long VCODEC_PTHREAD_T; +typedef volatile int VCODEC_PTHREAD_ONCE_T; +typedef long VCODEC_PTHREAD_MUTEXATTR_T; +typedef long VCODEC_PTHREAD_CONDATTR_T; +typedef struct +{ + unsigned int flags; + void *stack_base; + unsigned int stack_size; + unsigned int guard_size; + unsigned int sched_policy; + unsigned int sched_priority; +} VCODEC_PTHREAD_ATTR_T; + +typedef struct +{ + int volatile value; +} VCODEC_PTHREAD_MUTEX_T; + +typedef struct +{ + int volatile value; +} VCODEC_PTHREAD_COND_T; + +typedef struct +{ + int interlock; + VCODEC_PTHREAD_MUTEX_T mutex; +} VCODEC_PTHREAD_SPINLOCK_T; +/****** End of Pthread define******/ +#elif defined(LINUX) +#define VCODEC_PTHREAD_CREATE_JOINABLE 0 +#define VCODEC_PTHREAD_CREATE_DETACHED 1 +#define VCODEC_SIZEOF_PTHREAD_ATTR_T 36 +#define VCODEC_SIZEOF_PTHREAD_MUTEX_T 24 +#define VCODEC_SIZEOF_PTHREAD_MUTEXATTR_T 4 +#define VCODEC_SIZEOF_PTHREAD_COND_T 48 +#define VCODEC_SIZEOF_PTHREAD_COND_COMPAT_T 12 +#define VCODEC_SIZEOF_PTHREAD_CONDATTR_T 4 +typedef unsigned long int VCODEC_PTHREAD_T; +typedef union +{ + char __size[VCODEC_SIZEOF_PTHREAD_ATTR_T]; + long int _align; +} VCODEC_PTHREAD_ATTR_T; +typedef struct VCODEC_PTHREAD_INTERNAL_SLIST +{ + struct VCODEC_PTHREAD_INTERNAL_SLIST *__next; +} VCODEC_PTHREAD_SLIST_T; +typedef union +{ + struct VCODEC_PTHREAD_MUTEX_S + { + int __lock; + unsigned int __count; + int __owner; + int __kind; + unsigned int __nusers; + __extension__ union + { + int __spins; + VCODEC_PTHREAD_SLIST_T __list; + }; + } __data; + char __size[VCODEC_SIZEOF_PTHREAD_MUTEX_T]; + long int _align; +} VCODEC_PTHREAD_MUTEX_T; +typedef union +{ + char __size[VCODEC_SIZEOF_PTHREAD_MUTEXATTR_T]; + long int _align; +} VCODEC_PTHREAD_MUTEXATTR_T; +typedef union +{ + struct + { + int __lock; + unsigned int __futex; + __extension__ unsigned long long int __total_seq; + __extension__ unsigned long long int __wakeup_seq; + __extension__ unsigned long long int __woken_seq; + void *__mutex; + unsigned int __nwaiters; + unsigned int __broadcast_seq; + } __data; + char __size[VCODEC_SIZEOF_PTHREAD_COND_T]; + __extension__ long long int _align; +} VCODEC_PTHREAD_COND_T; +typedef union +{ + char __size[VCODEC_SIZEOF_PTHREAD_CONDATTR_T]; + long int _align; +} VCODEC_PTHREAD_CONDATTR_T; +typedef int VCODEC_PTHREAD_ONCE_T; +typedef volatile int VCODEC_PTHREAD_SPINLOCK_T; +#else +#error "platform undefined. @ vcodec_OAL.h" +#endif //endif WIN32 + + +typedef enum +{ + VCODEC_OAL_ERROR_NONE, + VCODEC_OAL_ERROR_ERROR, + VCODEC_OAL_ERROR_ASSERT_FAIL, + VCODEC_OAL_ERROR_ATTR_NOT_SUPPORT, + NUM_OF_VCODEC_OAL_ERROR_TYPE +} VCODEC_OAL_ERROR_T; + +/* Semaphore */ + +typedef struct +{ + volatile unsigned int count; +} VCODEC_OAL_SEM_T; + + +int VCodecPthread_attr_init(OUT VCODEC_PTHREAD_ATTR_T *attr); +int VCodecPthread_attr_destroy(IN VCODEC_PTHREAD_ATTR_T *attr); +int VCodecPthread_attr_getdetachstate(IN const VCODEC_PTHREAD_ATTR_T *attr, + OUT int *detachstate); +int VCodecPthread_attr_setdetachstate(IN VCODEC_PTHREAD_ATTR_T *attr, + IN int detachstate); +int VCodecPthread_create(OUT VCODEC_PTHREAD_T *thread, + IN const VCODEC_PTHREAD_ATTR_T *attr, + IN void * (*start_routine)(void *), + IN void *arg); +int VCodecPthread_kill(IN VCODEC_PTHREAD_T tid, IN int sig); +void VCodecPthread_exit(OUT void *retval); +int VCodecPthread_join(IN VCODEC_PTHREAD_T thid, OUT void **ret_val); +int VCodecPthread_once(IN VCODEC_PTHREAD_ONCE_T *once_control, IN void (*init_routine)(void)); +VCODEC_PTHREAD_T VCodecPthread_self(void); +int VCodecPthread_mutexattr_init(OUT VCODEC_PTHREAD_MUTEXATTR_T *attr); +int VCodecPthread_mutexattr_destroy(IN VCODEC_PTHREAD_MUTEXATTR_T *attr); +int VCodecPthread_mutex_init(OUT VCODEC_PTHREAD_MUTEX_T *mutex, IN const VCODEC_PTHREAD_MUTEXATTR_T *attr); +int VCodecPthread_mutex_destroy(IN VCODEC_PTHREAD_MUTEX_T *mutex); +int VCodecPthread_mutex_lock(IN VCODEC_PTHREAD_MUTEX_T *mutex); +int VCodecPthread_mutex_unlock(IN VCODEC_PTHREAD_MUTEX_T *mutex); +int VCodecPthread_mutex_trylock(IN VCODEC_PTHREAD_MUTEX_T *mutex); +int VCodecPthread_spin_init(OUT VCODEC_PTHREAD_SPINLOCK_T *lock, IN int pshared); +int VCodecPthread_spin_destroy(IN VCODEC_PTHREAD_SPINLOCK_T *lock); +int VCodecPthread_spin_lock(IN VCODEC_PTHREAD_SPINLOCK_T *lock); +int VCodecPthread_spin_trylock(IN VCODEC_PTHREAD_SPINLOCK_T *lock); +int VCodecPthread_spin_unlock(IN VCODEC_PTHREAD_SPINLOCK_T *lock); +int VCodecPthread_condattr_init(OUT VCODEC_PTHREAD_CONDATTR_T *attr); +int VCodecPthread_condattr_destroy(IN VCODEC_PTHREAD_CONDATTR_T *attr); +int VCodecPthread_cond_init(OUT VCODEC_PTHREAD_COND_T *cond, IN const VCODEC_PTHREAD_CONDATTR_T *attr); +int VCodecPthread_cond_destroy(IN VCODEC_PTHREAD_COND_T *cond); +int VCodecPthread_cond_broadcast(IN VCODEC_PTHREAD_COND_T *cond); +int VCodecPthread_cond_signal(IN VCODEC_PTHREAD_COND_T *cond); +int VCodecPthread_cond_wait(IN VCODEC_PTHREAD_COND_T *cond, IN VCODEC_PTHREAD_MUTEX_T *mutex); + +VCODEC_OAL_ERROR_T VCodecBindingCore(IN VCODEC_PTHREAD_T tid, + IN unsigned int u4Mask); +VCODEC_OAL_ERROR_T VCodecDeBindingCore(IN VCODEC_PTHREAD_T tid); +VCODEC_OAL_ERROR_T VCodecGetAffinity(IN VCODEC_PTHREAD_T tid, + OUT unsigned int *pu4Mask, + OUT unsigned int *pu4SetMask); +VCODEC_OAL_ERROR_T VCodecCoreLoading(IN int s4CPUid, + OUT int *ps4Loading); +VCODEC_OAL_ERROR_T VCodecCoreNumber(OUT int *ps4CPUNums); +void VCodecSleep(IN unsigned int u4Tick); +int VCodec_sem_init(IN VCODEC_OAL_SEM_T *sem, + IN int pshared, + IN unsigned int value); +int VCodec_sem_destroy(IN VCODEC_OAL_SEM_T *sem); +int VCodec_sem_post(IN VCODEC_OAL_SEM_T *sem); +int VCodec_sem_wait(IN VCODEC_OAL_SEM_T *sem); + +int VCodecCheck_Version(IN int version); + +#define VCodecOALPrintf(...) rVCODEC_OAL_Function.VCodecPrintf(__VA_ARGS__); + +VCODEC_OAL_ERROR_T VCodecConfigMCIPort(IN unsigned int u4PortConfig, OUT unsigned int *pu4PortResult, IN VCODEC_CODEC_TYPE_T eCodecType); +typedef struct +{ + + void (*VCodecQueryMemType)(IN void *pBuffer_VA, + IN unsigned int u4Size, + OUT VCODEC_MEMORY_TYPE_T *peMemType); + + void (*VCodecQueryPhysicalAddr)(IN void *pBuffer_VA, + OUT void **pBufferOut_PA); + + // VCodecSwitchMemType - return 0 if success. + // return -1 if failed, but pBufferOut_VA will be assigned with pBuffer_VA + int (*VCodecSwitchMemType)(IN void *pBuffer_VA, + IN unsigned int u4Size, + IN VCODEC_MEMORY_TYPE_T eMemType, + OUT void **pBufferOut_VA); + + // VCodecFlushCachedBuffer - u4Size is in byte + void (*VCodecFlushCachedBuffer)(IN void *pBuffer_VA, + IN unsigned int u4Size); + + // VCodecInvalidateCachedBuffer - u4Size is in byte + void (*VCodecInvalidateCachedBuffer)(IN void *pBuffer_VA, + IN unsigned int u4Size); + + void (*VCodecFlushCachedBufferAll)(void); + + void (*VCodecInvalidateCachedBufferAll)(void); + + void (*VCodecFlushInvalidateCacheBufferAll)(void); + + void (*VCodecMemSet)(IN void *pBuffer_VA, + IN char cValue, + IN unsigned int u4Length); + + void (*VCodecMemCopy)(IN void *pvDest , + IN const void *pvSrc , + IN unsigned int u4Length); + + void (*VCodecAssertFail)(IN char *ptr, + IN int i4Line, + IN int i4Arg); + + void (*VCodecMMAP)(VCODEC_OAL_MMAP_T *prParam); + void (*VCodecUnMMAP)(VCODEC_OAL_MMAP_T *prParam); + int (*VCodecWaitISR)(VCODEC_OAL_ISR_T *prParam); + int (*VCodecLockHW)(VCODEC_OAL_HW_LOCK_T *prParam); + int (*VCodecUnLockHW)(VCODEC_OAL_HW_LOCK_T *prParam); + + void (*VCodecInitHWLock)(IN VCODEC_OAL_HW_REGISTER_T *prParam); + + void (*VCodecDeInitHWLock)(IN VCODEC_OAL_HW_REGISTER_T *prParam); + int (*VCodecCheck_Version)(IN int version); + /************ Multi-thread function ***********/ + + /***** Thread Management Functions ******/ + int (*VCodecPthread_attr_init)(OUT VCODEC_PTHREAD_ATTR_T *attr); + int (*VCodecPthread_attr_destroy)(IN VCODEC_PTHREAD_ATTR_T *attr); + int (*VCodecPthread_attr_getdetachstate)(IN const VCODEC_PTHREAD_ATTR_T *attr, + OUT int *detachstate); + int (*VCodecPthread_attr_setdetachstate)(IN VCODEC_PTHREAD_ATTR_T *attr, + IN int detachstate); + int (*VCodecPthread_create)(OUT VCODEC_PTHREAD_T *thread, + IN const VCODEC_PTHREAD_ATTR_T *attr, + IN void * (*start_routine)(void *), + IN void *arg); + int (*VCodecPthread_kill)(IN VCODEC_PTHREAD_T tid, + IN int sig); + void (*VCodecPthread_exit)(OUT void *retval); + int (*VCodecPthread_join)(IN VCODEC_PTHREAD_T thid, + OUT void **ret_val); + int (*VCodecPthread_once)(IN VCODEC_PTHREAD_ONCE_T *once_control, + IN void (*init_routine)(void)); + VCODEC_PTHREAD_T(*VCodecPthread_self)(void); + + /***** Mutex Functions ******/ + int (*VCodecPthread_mutexattr_init)(OUT VCODEC_PTHREAD_MUTEXATTR_T *attr); + int (*VCodecPthread_mutexattr_destroy)(IN VCODEC_PTHREAD_MUTEXATTR_T *attr); + int (*VCodecPthread_mutex_init)(OUT VCODEC_PTHREAD_MUTEX_T *mutex, + IN const VCODEC_PTHREAD_MUTEXATTR_T *attr); + int (*VCodecPthread_mutex_destroy)(IN VCODEC_PTHREAD_MUTEX_T *mutex); + int (*VCodecPthread_mutex_lock)(IN VCODEC_PTHREAD_MUTEX_T *mutex); + int (*VCodecPthread_mutex_unlock)(IN VCODEC_PTHREAD_MUTEX_T *mutex); + int (*VCodecPthread_mutex_trylock)(IN VCODEC_PTHREAD_MUTEX_T *mutex); + + /***** Spin Functions ******/ + int (*VCodecPthread_spin_init)(OUT VCODEC_PTHREAD_SPINLOCK_T *lock, + IN int pshared); + int (*VCodecPthread_spin_destroy)(IN VCODEC_PTHREAD_SPINLOCK_T *lock); + int (*VCodecPthread_spin_lock)(IN VCODEC_PTHREAD_SPINLOCK_T *lock); + int (*VCodecPthread_spin_trylock)(IN VCODEC_PTHREAD_SPINLOCK_T *lock); + int (*VCodecPthread_spin_unlock)(IN VCODEC_PTHREAD_SPINLOCK_T *lock); + + /***** Condition Variable Functions ******/ + int (*VCodecPthread_condattr_init)(OUT VCODEC_PTHREAD_CONDATTR_T *attr); + int (*VCodecPthread_condattr_destroy)(IN VCODEC_PTHREAD_CONDATTR_T *attr); + int (*VCodecPthread_cond_init)(OUT VCODEC_PTHREAD_COND_T *cond, + IN const VCODEC_PTHREAD_CONDATTR_T *attr); + int (*VCodecPthread_cond_destroy)(IN VCODEC_PTHREAD_COND_T *cond); + int (*VCodecPthread_cond_broadcast)(IN VCODEC_PTHREAD_COND_T *cond); + int (*VCodecPthread_cond_signal)(IN VCODEC_PTHREAD_COND_T *cond); + int (*VCodecPthread_cond_wait)(IN VCODEC_PTHREAD_COND_T *cond, + IN VCODEC_PTHREAD_MUTEX_T *mutex); + + /************ End of Multi-thread function ***********/ + + /***** Semaphore Functions ******/ + + int (*VCodec_sem_init)(IN VCODEC_OAL_SEM_T *sem, + IN int pshared, + IN unsigned int value); + + int (*VCodec_sem_destroy)(IN VCODEC_OAL_SEM_T *sem); + + int (*VCodec_sem_post)(IN VCODEC_OAL_SEM_T *sem); + + int (*VCodec_sem_wait)(IN VCODEC_OAL_SEM_T *sem); + + /***** Binding Functions ******/ + + VCODEC_OAL_ERROR_T(*VCodecBindingCore)(IN VCODEC_PTHREAD_T tid, + IN unsigned int u4SetMask); + VCODEC_OAL_ERROR_T(*VCodecDeBindingCore)(IN VCODEC_PTHREAD_T tid); + + VCODEC_OAL_ERROR_T(*VCodecGetAffinity)(IN VCODEC_PTHREAD_T tid, + OUT unsigned int *pu4CPUMask, + OUT unsigned int *pu4SetMask); + + VCODEC_OAL_ERROR_T(*VCodecCoreLoading)(IN int s4CPUid, + OUT int *ps4Loading); + VCODEC_OAL_ERROR_T(*VCodecCoreNumber)(OUT int *ps4CPUNums); + /***** Others Functions ******/ + void (*VCodecSleep)(IN unsigned int u4Tick); + + VCODEC_OAL_ERROR_T(*VCodecConfigMCIPort)(IN unsigned int u4PortConfig, OUT unsigned int *pu4PortResult, IN VCODEC_CODEC_TYPE_T eCodecType); + + VCODEC_OAL_ERROR_T(*VCodecPrintf)(IN const char *_Format, ...); + +} VCODEC_OAL_CALLBACK_T; + +extern VCODEC_OAL_CALLBACK_T rVCODEC_OAL_Function; +int VCodecOALInit(IN VCODEC_OAL_CALLBACK_T *prVCODEC_OAL_Function); + +#endif /* VCODEC_OAL_H */ \ No newline at end of file diff --git a/include/linux/vcodec/vcodec_customization.h b/include/linux/vcodec/vcodec_customization.h new file mode 100644 index 000000000..e76007c30 --- /dev/null +++ b/include/linux/vcodec/vcodec_customization.h @@ -0,0 +1,19 @@ +#ifndef VCODEC_CUSTOMIZATION_H +#define VCODEC_CUSTOMIZATION_H + +#include "vcodec_if_v2.h" + + + + + +extern VCODEC_DEC_API_T *GetH264DecoderAPI(void); +//VCODEC_DEC_API_T *GetRMDecoderAPI(void); //RV8,RV9,RV10 +//VCODEC_DEC_API_T *GetMPEG4DecoderAPI(void); +//VCODEC_DEC_API_T *GetMPEG4VTDecoderAPI(void); +//VCODEC_DEC_API_T *GetVP8DecoderAPI(void); + +//VCODEC_ENC_API_T *GetMPEG4EncoderAPI(void); +//VCODEC_ENC_API_T *GetMPEG4SWVTEncoderAPI(void); + +#endif /* VCODEC_CUSTOMIZATION_H */ \ No newline at end of file diff --git a/include/linux/vcodec/vcodec_dec_demuxer_if_v2.h b/include/linux/vcodec/vcodec_dec_demuxer_if_v2.h new file mode 100644 index 000000000..5a1d58414 --- /dev/null +++ b/include/linux/vcodec/vcodec_dec_demuxer_if_v2.h @@ -0,0 +1,115 @@ + +#ifndef VCODEC_DEC_DEMUXER_V2_IF_H +#define VCODEC_DEC_DEMUXER_V2_IF_H + + +typedef struct +{ + unsigned char *u4Address; + unsigned int u4Length; + int fgValid; +} RM_DECODER_PAYLOAD_INFO_T; + +typedef struct +{ + unsigned int u4PayloadNumber; + RM_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} RM_DECODER_INPUT_PARAM_T; + +typedef enum +{ + RV8 = 0, + RV9, + RV10 +} RM_CODEC_VERSION_T; + +#define MAX_NUM_RPR_SIZES 8 +typedef struct +{ + RM_CODEC_VERSION_T eDecoderVersion; + unsigned int u4MaxDimWidth; + unsigned int u4MaxDimHeight; + unsigned int u4NumRPRSizes; + unsigned int au4RPRSizes[2 * MAX_NUM_RPR_SIZES]; +} RM_DECODER_INIT_PARAM_T; + +typedef struct +{ + unsigned int MaxSupportWidthForYUV420_ASP; + unsigned int MaxSupportHeightForYUV420_ASP; + unsigned short u2FrameWidthInContainer; + unsigned short u2FrameHeightInContainer; +} MPEG4_DECODER_PRIVATE_PARAM_T; + +// The H264 uses the private data to transfer NAL units +// The related data structure informations are defined as below +// + +typedef struct +{ + unsigned char *u4Address; + unsigned int u4Length; +} H264_DECODER_PAYLOAD_INFO_T; + +typedef struct +{ + unsigned int u4PayloadNumber; + H264_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} H264_DECODER_INPUT_PARAM_T; + +typedef struct +{ + unsigned char *u4Address; + unsigned int u4Length; +} VC1_DECODER_PAYLOAD_INFO_T; + +typedef struct +{ + unsigned int u4PayloadNumber; + VC1_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} VC1_DECODER_INPUT_PARAM_T; + +typedef struct +{ + unsigned char *u4Address; + unsigned int u4Length; + unsigned short u2FrameWidthInContainer; + unsigned short u2FrameHeightInContainer; +} MPEG4_DECODER_PAYLOAD_INFO_T; + +typedef struct +{ + unsigned int u4PayloadNumber; + MPEG4_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} MPEG4_DECODER_INPUT_PARAM_T; +typedef struct +{ + unsigned char *u4Address; + unsigned int u4Length; +} MPEG4VT_DECODER_PAYLOAD_INFO_T; + +typedef struct +{ + unsigned int u4PayloadNumber; + MPEG4VT_DECODER_PAYLOAD_INFO_T *pu1PayloadAddress; +} MPEG4VT_DECODER_INPUT_PARAM_T; + +typedef struct +{ + VCODEC_BUFFER_T rPayload; + unsigned int u4Length; +} VP8_DECODER_INPUT_UNIT_T; + +typedef struct +{ + unsigned char *u4Address; + unsigned int u4Length; +} HEVC_DECODER_PAYLOAD_INFO_T; + +typedef struct +{ + unsigned int u4PayloadNumber; + HEVC_DECODER_PAYLOAD_INFO_T *pu1Payload; +} HEVC_DECODER_INPUT_PARAM_T; +#endif /* VCODEC_DEC_DEMUXER_IF_H */ + diff --git a/include/linux/vcodec/vcodec_if_v2.h b/include/linux/vcodec/vcodec_if_v2.h new file mode 100644 index 000000000..3eb9a9cd3 --- /dev/null +++ b/include/linux/vcodec/vcodec_if_v2.h @@ -0,0 +1,1034 @@ + +#ifndef VCODEC_IF_V2_H +#define VCODEC_IF_V2_H + +/*************************************************** +* +* Chip definitions and Series definitions +* +***************************************************/ + + +#ifndef TRUE +#define TRUE 1 +#elif TRUE != 1 +#error TRUE is not equal to 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#elif FALSE != 0 +#error FALSE is not equal to 0 +#endif +#define IN +#define OUT +#define INOUT +typedef void *HANDLE; +#ifdef WIN32 +typedef unsigned __int64 UINT64; +#else +typedef unsigned long long UINT64; +#endif + +typedef enum +{ + VCODEC_DECODER, + VCODEC_ENCODER, + NUM_OF_CODEC_TYPE +} VCODEC_CODEC_TYPE_T; + +typedef struct +{ + unsigned int u4YStride; + unsigned int u4UVStride; +} VCODEC_YUV_STRIDE_T; + +typedef enum +{ + VCODEC_COLOR_FORMAT_YUV420, + VCODEC_COLOR_FORMAT_YV12, +} VCODEC_COLOR_FORMAT_T; + +typedef struct +{ + unsigned int MaxSupportWidth; + unsigned int MaxSupportHeight; + unsigned int eFlag; //VCODEC_DEC_INPUT_FLAG_T + unsigned int ExternalMEMSize; + int OutBufferNum; // -1: .inf + VCODEC_YUV_STRIDE_T stride; + VCODEC_COLOR_FORMAT_T eColorFormat; + void *PrivateData[4]; +} VCODEC_OPEN_SETTING_T; + +typedef struct +{ + unsigned int MaxSupportWidthForYUV420_BP; + unsigned int MaxSupportHeightForYUV420_BP; + unsigned int MaxSupportWidthForYUV420_MPHP; + unsigned int MaxSupportHeightForYUV420_MPHP; + unsigned int ExternalMEMSize; + unsigned int DPBSize; +} H264_DEC_CUSTOM_SETTING_T; + +typedef struct +{ + unsigned int MaxSupportWidthForYUV420_MPHP; + unsigned int MaxSupportHeightForYUV420_MPHP; + unsigned int NormalMaxWidthForYUV420_MPHP; + unsigned int NormalMaxHeightForYUV420_MPHP; + unsigned int u4dpbSizes; + void *reserved[4]; +} H264_DECODER_PRIVATE_PARAM_T; +/* +typedef struct +{ + unsigned int MaxSupportWidthForYUV420_SP; + unsigned int MaxSupportHeightForYUV420_SP; + unsigned int MaxSupportWidthForYUV420_ASP; + unsigned int MaxSupportHeightForYUV420_ASP; + unsigned int ExternalMEMSize; +} MPEG4_DEC_CUSTOM_SETTING_T; + +typedef struct +{ + unsigned int MaxSupportWidthForYUV420; + unsigned int MaxSupportHeightForYUV420; + unsigned int eFlag; //VCODEC_DEC_INPUT_FLAG_T + unsigned int ExternalMEMSize; + void *PrivateData[4]; +} VC1_DEC_CUSTOM_SETTING_T; +*/ + +typedef enum +{ + VCODEC_FRAMETYPE_I, + VCODEC_FRAMETYPE_NS_I, // non-seek I, non-IDR frame + VCODEC_FRAMETYPE_P, + VCODEC_FRAMETYPE_B, + VCODEC_HEADER, + VCODEC_FRM_DROPPED, + VCODEC_UNKNOWN_TYPE, + NUM_OF_FRAME_TYPE +} VCODEC_FRAME_TYPE_T; + + + +typedef enum +{ + VA_NON_CACHED = 0x0, + VA_CACHED = 0x1, +} VCODEC_BUFFER_ATTRIBUTE_T; + +typedef enum +{ + VCODEC_BUFFER_CACHEABLE = 0, + VCODEC_BUFFER_NON_CACHEABLE = 1, + VCODEC_BUFFER_MCI_SHARABLE = 2 +} VCODEC_MEMORY_TYPE_T; +typedef struct +{ + unsigned int u4InternalSize; + unsigned int u4ExternalSize; +} VCODEC_MEMORY_SIZE_T; + +typedef struct +{ + unsigned char *pu1Buffer_VA; + unsigned char *pu1Buffer_PA; + unsigned int eBufferStatus;//VCODEC_BUFFER_ATTRIBUTE_T +} VCODEC_BUFFER_T; + +typedef enum +{ + VCODEC_DEC_ERROR_NONE, + VCODEC_DEC_ERROR_DECODE_ERROR, + VCODEC_DEC_ERROR_ASSERT_FAIL, + VCODEC_DEC_ERROR_FATAL_ERROR, + VCODEC_DEC_ERROR_NOT_SUPPORT, + VCODEC_DEC_ERROR_NOT_ENOUGH_MEM, + VCODEC_DEC_ERROR_PAYLOAD_DATA_ERROR, + VCODEC_DEC_ERROR_OAL_CHECK_VERSION_FAIL, + VCODEC_DEC_ERROR_DIMENSION_CHANGE, + NUM_OF_DEC_ERROR_TYPE +} VCODEC_DEC_ERROR_T; + + +typedef enum +{ + CUSTOM_SETTING, //custom setting + BEST_QUALITY, //standard mode + FAVOR_QUALITY, //adaptive control decode mode , quality first + FAVOR_FLUENCY, //adaptive control decode mode , fluency first + BEST_FLUENCY, //fast mode + NUM_OF_DECODE_MODE, +} VCODEC_DEC_DECODE_MODE_T; + + + +typedef enum +{ + VCODEC_DEC_PARAM_EOF, + VCODEC_DEC_PARAM_QUERY_RESOLUTION_AHEAD, + VCODEC_DEC_PARAM_QUERY_RESOLUTION, + VCODEC_DEC_PARAM_QUERY_PREDICATION_TIME, + VCODEC_DEC_PARAM_MEMORY_REQUIREMENT, + VCODEC_DEC_PARAM_CAPABILITY, + VCODEC_DEC_PARAM_NOT_BUFFERING, + VCODEC_DEC_PARAM_BUFFERING, + VCODEC_DEC_PARAM_BITRATE, + VCODEC_DEC_PARAM_FRAMERATE, + VCODEC_DEC_PARAM_EXCLUDE_BUF_NUM, + VCODEC_DEC_PARAM_NO_OUTPUT_REORDERING, + VCODEC_DEC_PARAM_FLUSH_BUFFER, + VCODEC_DEC_PARAM_SET_DECRYPTION_MODE, + VCODEC_DEC_PARAM_SET_DECODE_MODE, + VCODEC_DEC_PARAM_GET_DECODE_MODE, + VCODEC_DEC_PARAM_CTRL_VOS, + VCODEC_DEC_PARAM_GET_SBSFLAG, + VCODEC_DEC_PARAM_CONCEAL_LEVEL, + VCODEC_DEC_PARAM_NUM_OF_HW_CTRL_THID, + VCODEC_DEC_PARAM_GET_REG_HW_CTRL_THID, /*Get registered HW control thread id , output structure : VCODEC_REG_HW_CTRL_THID_T*/ + VCODEC_DEC_PARAM_SET_COLOR_FORMAT, + //VCODEC_DEC_PARAM_SET_STRIDE_ALIGNMENT, + VCODEC_DEC_PARAM_SET_AVAILABLE_CPU_NUM, + VCODEC_DEC_PARAM_SET_MCI, //enable or disable MCI mechanism + NUM_OF_DEC_PARAM_TYPE, +} VCODEC_DEC_PARAM_TYPE_T; + +typedef enum +{ + VCODEC_DEC_DISPLAY_CONCEALED_FRAME_DURING_PLAYBACK = 0x01, + VCODEC_DEC_DISPLAY_CONCEALED_FRAME_BEFORE_FIRST_I = 0X02, + VCODEC_DEC_DISPLAY_CONCEALED_FRAME_AFTER_FIRST_I = 0X04, + NUM_OF_DEC_CONCEAL_LEVEL_TYPE, +} VCODEC_DEC_CONCEAL_LEVEL_TYPE_T; +typedef enum +{ + //VCODEC_DEC_QUERY_INFO_AVAILABLE_YUV, //Total available YUV buffer + //VCODEC_DEC_QUERY_INFO_TOTAL_YUV, //Total number of YUV buffer + //VCODEC_DEC_QUERY_INFO_AVAILABLE_DISPLAY_FRAME, //Total available display frame(without frame repeat) + //VCODEC_DEC_QUERY_INFO_REAL_AVAILABLE_DISPLAY_FRAME, //Total real available display frame(including frame repeat) + VCODEC_DEC_QUERY_INFO_OAL_FUNCTION, //Query OAL Function pointer + VCODEC_DEC_QUERY_INFO_CURRENT_TIME, //Current play time + VCODEC_DEC_QUERY_INFO_LAST_VIDEO_TIME, // Last delivered frame time + //VCODEC_DEC_QUERY_INFO_OAL_FUNCTION_SMP, //Query OAL Function pointer + NUM_OF_QUERY_INFO_TYPE +} VCODEC_DEC_QUERY_INFO_TYPE_T; + +typedef struct +{ + VCODEC_COLOR_FORMAT_T eColorFormat; + unsigned int u4MaxWidth; + unsigned int u4MaxHeight; + unsigned int MaxVideoCodingResolution; +} VCODEC_ENC_GENERAL_SETTING_T; + +typedef struct +{ + VCODEC_COLOR_FORMAT_T eColorFormat; + unsigned int u4MaxWidth; + unsigned int u4MaxHeight; + unsigned int MaxVideoCodingResolution; + unsigned int complexityIndex; +} VCODEC_ENC_MPEG4_SETTING_T; + +typedef union +{ + VCODEC_ENC_MPEG4_SETTING_T rMPEG4; + VCODEC_ENC_GENERAL_SETTING_T rVT; + VCODEC_ENC_GENERAL_SETTING_T rH264; + VCODEC_ENC_GENERAL_SETTING_T rHEVC; + VCODEC_ENC_GENERAL_SETTING_T rVP9; + VCODEC_ENC_GENERAL_SETTING_T rVP8; +} VCODEC_ENC_SETTING_T; + +typedef struct +{ + unsigned char *pu1ParamStream; + unsigned int u4ParamLength; + unsigned int u4Width; + unsigned int u4Height; +} VCODEC_DEC_QUERY_FRAME_SIZE_TYPE_T; + +typedef enum +{ + DISPLAY_CURRENT, // Normal dispaly + REPEAT_LAST, // Frame skipping , error handling + NOT_DISPLAY, // for vp8, error handling + LAST_FRAME, // EOF + NO_PIC, // buffering + NOT_USED, // H.264 multi-slice + DISPLAY_CURRENT_INTERLACE, //interlace dispaly + NUM_OF_DISPLAY_FRAME_STATUS +} VCODEC_DEC_DISPLAY_FRAME_STATUS; + +typedef struct +{ + int i4AspectRatioWidth; //width aspect ratio + int i4AspectRatioHeight; //height aspect ratio + //unsigned int u4IntraMBNum; + //unsigned int u4InterFMBNum; + //unsigned int u4InterBMBNum; + //unsigned int u4SkipMBNum; + void *prExtra; +} VCODEC_DEC_PRIVATE_OUTPUT_EXTRA_T; + +typedef struct +{ + UINT64 u8TimeStamp; + int fgUpdateTime; //update time stamp + unsigned short u2FrameWidth; //Full Frame Size + unsigned short u2FrameHeight; //Full Frame Size + unsigned short u2ClipTop; + unsigned short u2ClipBottom; + unsigned short u2ClipLeft; + unsigned short u2ClipRight; + VCODEC_FRAME_TYPE_T eFrameType; + VCODEC_BUFFER_T rYStartAddr; /*YUV buffer start address, include padding up and left*/ + VCODEC_BUFFER_T rUStartAddr; + VCODEC_BUFFER_T rVStartAddr; + VCODEC_DEC_DISPLAY_FRAME_STATUS eDisplayFrameStatus; + void *prExtra; +} VCODEC_DEC_PRIVATE_OUTPUT_T; + + + +typedef void VCODEC_DEC_INPUT_DATA_T; + +typedef enum +{ + INPUT_FLAG_STREAM_DATA_TYPE = 0x01, /* Bit 0 = 1: Slice base data(non-frame base) ; 0: Frame base data*/ + INPUT_FLAG_STARTTIME = 0x02, /* seek start time at end of seek */ + INPUT_FLAG_DECODEONLY = 0x04, /* seek */ + INPUT_FLAG_PARAMETERSET = 0x08, /* H.264 for SPS,PPS issue,send first frame bitstream for set parameter */ + INPUT_FLAG_CUSTOM_SETTING = 0x10, /* Get max external memory size(VE)*/ + INPUT_FLAG_DECODE_INTRA_ONLY = 0x20, /* Only Decode Intra Frame */ + INPUT_FLAG_OPENAPI = 0x40, /* OPENAPI */ + INPUT_FLAG_DECODE_MODE = 0x80, /* Decode Mode */ + INPUT_FLAG_LEGACY_MODE = 0x100, /* legacy Mode */ + INPUT_FLAG_MAX_DEC +} VCODEC_DEC_INPUT_FLAG_T; + +typedef struct +{ + UINT64 u8TimeStamp; + unsigned int eFlags; // VCODEC_DEC_INPUT_FLAG_T + VCODEC_DEC_INPUT_DATA_T *prInputData; // MPEG4_DECODER_PAYLOAD_INFO_T, H264_DECODER_INPUT_PARAM_T, RM_DECODER_INPUT_PARAM_T, RM_DECODER_INIT_PARAM_T + VCODEC_BUFFER_T *prBuffer; // Input data address + unsigned int u4BuffSize; // Input buffer total size + void *prExtra; +} VCODEC_DEC_INPUT_T; + + + + + + +typedef struct +{ + unsigned int u4Width; //Full size 16 byte align + unsigned int u4Height; //Full size 16 byte align + unsigned short u2ClipTop; + unsigned short u2ClipBottom; + unsigned short u2ClipLeft; + unsigned short u2ClipRight; + unsigned int u4Offset; //Offset of YUV buffer start address + unsigned int u4ReduceLength; //Padding size(End of YUV buffer pool) + unsigned char u1Alignment; //YUV buffer address alignment + VCODEC_MEMORY_TYPE_T rYUVBUfferMemType; //YUV buffer memory type + unsigned int u4MaxBufferNum; + unsigned int u4ExtraBufferNum; + void *prExtra; +} VCODEC_DEC_OUTPUT_BUFFER_PARAM_T; + +typedef struct +{ + VCODEC_MEMORY_TYPE_T rBitStreamBufferMemType; //bitstream buffer memory type + unsigned int u4MaxBufferNum; + void *PrivateData[4]; +} VCODEC_DEC_INPUT_BUFFER_PARAM_T; + +typedef struct +{ + VCODEC_BUFFER_T rYBuffer; + VCODEC_BUFFER_T rUBuffer; + VCODEC_BUFFER_T rVBuffer; +} VCODEC_DEC_INPUT_YUV_INFO_T; + +// non-callback +#define MAX_BITSTREAM_BUFFER_INFO_NUM 10 +#define MAX_REF_FREE_YUV_BUFFER_NUM 18 +typedef struct +{ + VCODEC_BUFFER_T *prRetBitsBuf; // for mt6575, mt6577 + unsigned int u4ReturnInputCnt; + VCODEC_BUFFER_T rReturnInput[MAX_BITSTREAM_BUFFER_INFO_NUM]; + unsigned int u4RefFreeYUVBufCnt; + VCODEC_DEC_INPUT_YUV_INFO_T parRefFreeYUVBuf[MAX_REF_FREE_YUV_BUFFER_NUM]; +} VCODEC_DEC_OUTPUT_PARAM_T; +// ~non-callback + +typedef struct +{ + unsigned int u4SupportWidth; + unsigned int u4SupportHeight; + unsigned int u4SupportResolution; + unsigned int u4SupportProfile; + unsigned int u4SupportLevel; +} VCODEC_DEC_CAPABILITY_T; + +typedef struct +{ + void (*pfnMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + IN VCODEC_MEMORY_TYPE_T /* fgCacheable */, + OUT VCODEC_BUFFER_T * /* prBuf */ + ); /* buffer address must cache line align */ + + void (*pfnIntMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + OUT VCODEC_BUFFER_T * /* pBuffer_adr */ + ); + + void (*pfnFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuf */ + ); /* same memory type with malloc */ + + void (*pfnIntFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* pBuffer_adr */ + ); + + VCODEC_DEC_ERROR_T(*pfnSetYUVBuffer)(IN HANDLE /* hDrv */, + IN VCODEC_DEC_OUTPUT_BUFFER_PARAM_T * /* prYUVParam */ + ); + + VCODEC_DEC_ERROR_T(*pfnGetYUVBuffer)(IN HANDLE /* hDrv */, + OUT VCODEC_DEC_INPUT_YUV_INFO_T * /* prYUVBuf */ + ); + + void (*pfnRefFreeYUVBuffer)(IN HANDLE /* hDrv */, + IN VCODEC_DEC_INPUT_YUV_INFO_T * /* prYUVBuf */ + ); + + VCODEC_DEC_ERROR_T(*pfnQueryInfo)(IN HANDLE /* hDrv */, + IN VCODEC_DEC_QUERY_INFO_TYPE_T /* query id*/, + OUT void * /* pvParamData*/ /* */ + ); + + void (*pfnReturnBitstream)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuffer */ /* Input buffer address */, + IN unsigned int /* u4BuffSize */ /* Input buffer total size */ + ); + +} VCODEC_DEC_CALLBACK_T; + + +// non-callback +typedef struct +{ + VCODEC_DEC_INPUT_T *prInputData; + VCODEC_DEC_INPUT_YUV_INFO_T *prYUVBufAddr; // prYUVBuf +} VIDEO_DECODER_INPUT_NC_T; + + + +typedef struct +{ + VCODEC_DEC_ERROR_T(*pfnGetCodecRequired)(IN VCODEC_DEC_INPUT_T * /* prInput */ , + OUT VCODEC_MEMORY_SIZE_T * /* prMemSize */, + OUT VCODEC_DEC_OUTPUT_BUFFER_PARAM_T * /* prBufferParameter*/, + OUT VCODEC_DEC_INPUT_BUFFER_PARAM_T * /* prBitStreamParameter */, + INOUT void * /* reserve */ + ); + + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnOpen)(IN HANDLE, /* hDrv */ + IN VCODEC_DEC_CALLBACK_T *, /* pfnCallback */ + IN void *, /* open setting */ + OUT HANDLE * , /* hCodec */ + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnClose)(IN HANDLE , /* hCodec */ + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnInit)(IN HANDLE , /* hCodec */ + INOUT void * /* reserve */ + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnDeInit)(IN HANDLE, /* hCodec */ + IN HANDLE, /* hWrap */ + OUT VCODEC_DEC_OUTPUT_PARAM_T ** , /* for smart phone */ + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnGetParameter)(IN HANDLE, /* hCodec */ + IN VCODEC_DEC_PARAM_TYPE_T, + INOUT void * /* pvParamData */ + ); + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnSetParameter)(IN HANDLE, /* hCodec */ + IN HANDLE, /* hWrap */ + IN VCODEC_DEC_PARAM_TYPE_T, /* eParamType */ + IN void * , /* pvParamData */ + INOUT void * /* reserve */ + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnDecodeOneUnit)(IN HANDLE, /* hCodec */ + IN HANDLE, /* hWrap */ + IN VIDEO_DECODER_INPUT_NC_T *, /* prInput */ + OUT VCODEC_DEC_OUTPUT_PARAM_T ** , /* for smart phone */ + INOUT void * /* reserve */ + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_DEC_ERROR_T(*pfnGetNextDisplay)(IN HANDLE, /* hCodec */ + IN HANDLE, /* hWrap */ + OUT VCODEC_DEC_PRIVATE_OUTPUT_T * , /* prPrivOutput */ + INOUT void * /* reserve */ + ); +} VIDEO_DEC_API_T; +// ~non-callback + + + + + + + +typedef struct +{ + + VCODEC_DEC_ERROR_T(*pfnGetCodecRequired)(IN VCODEC_DEC_INPUT_T * /* prInput */ , + OUT VCODEC_MEMORY_SIZE_T * /* prMemSize */, + OUT VCODEC_DEC_OUTPUT_BUFFER_PARAM_T * /* prBufferParameter*/, + OUT VCODEC_DEC_INPUT_BUFFER_PARAM_T * /*prBitStreamParameter */, + INOUT void * /* reserve */ + ); + + + VCODEC_DEC_ERROR_T(*pfnOpen)(IN HANDLE /* hDrv */, + IN VCODEC_DEC_CALLBACK_T * /* pfnCallback */, + IN void * /* prOpenSetting */, + OUT HANDLE * /* hCodec */ , + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnClose)(IN HANDLE /* hCodec */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnInit)(IN HANDLE /* hCodec */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnDeInit)(IN HANDLE /* hCodec */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnGetParameter)(IN HANDLE /* hCodec */, + IN VCODEC_DEC_PARAM_TYPE_T /* eParamType */, + INOUT void * /* pvParamData */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnSetParameter)(IN HANDLE /* hCodec */, + IN VCODEC_DEC_PARAM_TYPE_T /* eParamType */, + IN void * /* pvParamData */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnDecodeOneUnit)(IN HANDLE /* hCodec */, + IN VCODEC_DEC_INPUT_T * /* prInput */, + INOUT void * /* reserve */ + ); + + VCODEC_DEC_ERROR_T(*pfnGetNextDisplay)(IN HANDLE /* hCodec */, + OUT VCODEC_DEC_PRIVATE_OUTPUT_T * /* prPrivOutput */, + INOUT void * /* reserve */ + ); + + + + +} VCODEC_DEC_API_T; + +typedef struct +{ + VIDEO_DEC_API_T rVideoDecAPI; + VCODEC_DEC_API_T *pfnVcodecDecAPI; + VCODEC_DEC_INPUT_YUV_INFO_T rGetYUVBuf; + VCODEC_BUFFER_T rRetBitsBuf; + VCODEC_DEC_OUTPUT_PARAM_T rDecoderOutputParam; + unsigned int fgTookYUVBuff; + HANDLE hDriver; +} VIDEO_WRAP_HANDLE_T; + + +#define VCODEC_ENC_MAX_PKTS_IN_SET 99 +#define VCODEC_ENC_MAX_NALS_IN_SET 10 + +typedef struct +{ + void *u4Addr; + unsigned int u4Size; +} VCODEC_ENC_CODEC_PACKET_INFO_T; + + +// Note the first two items in the next structure must be (in order): +// 1. number of Packets +// 2. pointer to the packet info +typedef struct +{ + unsigned int u4NumOfPkts; + VCODEC_ENC_CODEC_PACKET_INFO_T arPktInfo[VCODEC_ENC_MAX_PKTS_IN_SET]; +} VCODEC_ENC_PACKET_SET_T; + + +typedef struct +{ + int u4NalUnitType; + void *u4Addr; // p_payload + unsigned int u4Size; // i_payload +} VCODEC_ENC_CODEC_NAL_INFO_T; + +typedef struct +{ + unsigned int u4NumOfNals; + VCODEC_ENC_CODEC_NAL_INFO_T arNalInfo[VCODEC_ENC_MAX_NALS_IN_SET]; +} VCODEC_ENC_NAL_SET_T; + +typedef enum +{ + MPEG4_RECODER, + MPEG4_VT, + H264_RECODER, + H264_VT, + NUM_OF_ENC_CODEC_TYPE +} VCODEC_ENC_CODEC_TYPE_T; + +typedef struct +{ + VCODEC_FRAME_TYPE_T eFrameType; + VCODEC_BUFFER_T rBitstreamAddr; // added to merge remained individual parameters in the phototype + unsigned int u4BitstreamLength; + int fgEndOfFrame; + void *prChassis; + VCODEC_ENC_CODEC_TYPE_T eCodecType; + UINT64 u8TimeStamp; + void *reserved[4]; +} VCODEC_ENC_GENERAL_OUTPUT_T; + +typedef struct +{ + VCODEC_BUFFER_T rStartAddr; + VCODEC_BUFFER_T rEndAddr; + VCODEC_BUFFER_T rWriteAddr; + VCODEC_BUFFER_T rReadAddr; + unsigned int u4BufferLength; +} VCODEC_ENC_BUFFER_INFO_T; + + +typedef enum +{ + INPUT_FLAG_YUVBUFFER = 0x01, + INPUT_FLAG_NO_INPUT = 0x02, + INPUT_FLAG_NO_MORE_INPUT = 0x03, + INPUT_FLAG_MAX_ENC +} VCODEC_ENC_INPUT_FLAG_T; + +typedef struct +{ + VCODEC_BUFFER_T rYUVBuffer; + unsigned int u4Length; +} VCODEC_ENC_INPUT_INFO_T; + +typedef struct +{ + VCODEC_BUFFER_T rYBuffer; + VCODEC_BUFFER_T rUBuffer; + VCODEC_BUFFER_T rVBuffer; + unsigned int u4Length; +} VCODEC_ENC_INPUT_YUV_INFO_T; + + + +typedef struct +{ + UINT64 u8TimeStamp; + VCODEC_ENC_INPUT_FLAG_T eFlags; + VCODEC_ENC_INPUT_INFO_T rInput; +} VCODEC_ENC_INPUT_PARAM_T; + +typedef struct +{ + UINT64 u8TimeStamp; + VCODEC_ENC_INPUT_FLAG_T eFlags; + VCODEC_ENC_INPUT_YUV_INFO_T rInput; + void *prExtra; +} VCODEC_ENC_INPUT_YUV_PARAM_T; + +typedef struct +{ + VCODEC_BUFFER_T rWp; + int fgSliceContained; +} VCODEC_ENC_UPDATE_WP_INTO_T; + +typedef enum +{ + VCODEC_ENC_ERROR_NONE, + VCODEC_ENC_ERROR, + VCODEC_ENC_ASSERT_FAIL, + VCODEC_ENC_BS_BUFFER_NOT_ENOUGH, + VCODEC_ENC_INPUT_REJECT, + VCODEC_ENC_PARAM_NOT_SUPPORT, + NUM_OF_ENC_ERROR_TYPE +} VCODEC_ENC_ERROR_T; + + +typedef enum +{ + VCODEC_ENC_PARAM_MEMORY_REQUIREMENT, //Query ext/int memory requirement for adaptation + VCODEC_ENC_PARAM_BITSTREAM_IN_CACHE, //Query the prefer memory type of bitstream buffer, return true means cacheable buffer is preferred + VCODEC_ENC_PARAM_FRM_BUFFER_ALIGNMENT, //Query the alignment needed on frame buffer for codec + VCODEC_ENC_PARAM_HOLD_RES_TILL_RELEASE_FRM, + VCODEC_ENC_PARAM_IS_BLOCKBASED_YUV, + VCODEC_ENC_PARAM_DECODER_CONFIGURATION_RECORD, + VCODEC_ENC_PARAM_IF_ADAPTOR_MODIFY_TIMESTAMP, + VCODEC_ENC_PARAM_WIDTH, + VCODEC_ENC_PARAM_HEIGHT, + VCODEC_ENC_PARAM_BITRATE, + VCODEC_ENC_PARAM_FRAME_RATE, + VCODEC_ENC_PARAM_FRAME_RATE_NUM, + VCODEC_ENC_PARAM_FRAME_RATE_DEN, + VCDOEC_ENC_PARAM_AUD, + VCODEC_ENC_PARAM_REPEAD_HEADERS, + VCODEC_ENC_PARAM_ANNEXB, + VCODEC_ENC_PARAM_GEN_HEADER_FRM_RATE, + VCODEC_ENC_PARAM_SHORT_HEADER, + VCODEC_ENC_PARAM_SYNC_INTERVAL, + VCODEC_ENC_PARAM_MAX_PKG_SIZE, + VCODEC_ENC_PARAM_FORCE_ENCODE_I, + VCODEC_ENC_PARAM_QUALITY, + VCODEC_ENC_PARAM_SCENARIO, + VCODEC_ENC_PARAM_CODEC_TYPE, + VCODEC_ENC_PARAM_VT_RESTART, + VCODEC_ENC_PARAM_ROTATE, + VCODEC_ENC_PARAM_SET_CALLBACK, + VCODEC_ENC_PARAM_SET_NO_MORE_INPUT, + VCODEC_ENC_PARAM_NUM_OF_HW_CTRL_THID, + VCODEC_ENC_PARAM_GET_REG_HW_CTRL_THID, //Get registered HW control thread id , output structure : VCODEC_REG_HW_CTRL_THID_T + VCODEC_ENC_PARAM_SET_COLOR_FORMAT, + VCODEC_ENC_PARAM_SET_YUV_STRIDE_ALIGNMENT, + VCODEC_ENC_PARAM_SET_AVAILABLE_CPU_NUM, + VCODEC_ENC_PARAM_SET_MCI, //enable or disable MCI mechanism + VCODEC_ENC_PARAM_WPP, + VCODEC_ENC_PARAM_CONSTQ, + VCODEC_ENC_PARAM_RC_VERSION, + VCODEC_ENC_PARAM_INIT_QP, + VCODEC_ENC_PARAM_MAX_QP, + VCODEC_ENC_PARAM_MIN_QP, + VCODEC_ENC_PARAM_NUM_OF_SLICE, + VCODEC_ENC_PARAM_PROFILE, + VCODEC_ENC_PARAM_LEVEL, + VCODEC_ENC_PARAM_THREADS, + VCODEC_ENC_PARAM_VP8_TOKEN_PARTITIONS, + VCODEC_ENC_PARAM_VP9_ENABLE_TILES, + VCODEC_ENC_PARAM_VPX_ERR_RESILIENT, + VCODEC_ENC_PARAM_VPX_NUMBER_OF_LAYERS, + VCODEC_ENC_PARAM_VPX_MODE, + VCODEC_ENC_PARAM_VPX_CPU_USED, + VCODEC_ENC_PARAM_YUV_STRIDE, + NUM_OF_ENC_PARAM_TYPE +} VCODEC_ENC_PARAM_TYPE_T; + +typedef enum +{ + VCODEC_ENC_QUERY_INFO_TOTAL_FRAME_BUFFER, // Total frame buffer size + VCODEC_ENC_QUERY_INFO_FRAMES_QUEUED, // Number of frames waited to encoder + VCODEC_ENC_QUERY_INFO_VTBUFFER_FULLNESS_DENOM, // Denominator of VT buffer fullness + VCODEC_ENC_QUERY_INFO_VTBUFFER_FULLNESS_NUM, // Numerator of VT buffer fullness + VCODEC_ENC_QUERY_INFO_INIT_Q, // Used by codec + VCODEC_ENC_QUERY_INFO_MIN_QP, // Used by codec + VCODEC_ENC_QUERY_INFO_MAX_QP, // Used by codec + VCODEC_ENC_QUERY_INFO_INTRA_VOP_RATE, // Used by MED/codec + VCODEC_ENC_QUERY_INFO_ALGORITHM, // Used by codec + VCODEC_ENC_QUERY_INFO_BIT_RATE, // Used by MED/codec + VCODEC_ENC_QUERY_INFO_RATE_HARD_LIMIT, // Used by codec + VCODEC_ENC_QUERY_INFO_RATE_BALANCE, // Used by codec + VCODEC_ENC_QUERY_INFO_DYNAMIC_RANGE_REDUCTION, + VCODEC_ENC_QUERY_INFO_IF_CUSTOMER_SET_TABLE, + VCODEC_ENC_QUERY_INFO_DYNAMIC_RANGE_TABLE, + VCODEC_ENC_QUERY_INFO_OAL_FUNCTION, + VCODEC_ENC_QUERY_INFO_ENCODER_FRAME_RATE, // Used by H.264 recoder + VCODEC_ENC_QUERY_INFO_TARGET_COMPLEXITY, // Used by H.264 recoder + VCODEC_ENC_QUERY_INFO_THRESHOLD_AVG_LOW, // Used by H.264 recoder + VCODEC_ENC_QUERY_INFO_THRESHOLD_AVG_HIGH, // Used by H.264 recoder + VCODEC_ENC_QUERY_INFO_THRESHOLD_CUR_LOW, // Used by H.264 recoder + VCODEC_ENC_QUERY_INFO_THRESHOLD_CUR_HIGH, // Used by H.264 recoder + //VCODEC_ENC_QUERY_INFO_OAL_FUNCTION_SMP, + VCODEC_ENC_QUERY_INFO_VPX_CPU_USED, + VCODEC_ENC_QUERY_INFO_VPX_MODE, + VCODEC_ENC_QUERY_INFO_FIXED_QP, + VCODEC_ENC_QUERY_INFO_SCENARIO, + NUM_OF_ENC_QUERY_INFO_TYPE +} VCODEC_ENC_QUERY_INFO_TYPE_T; + +/********************************************************************** + + + Encoder enumerations + + **********************************************************************/ + +// clock-wise +typedef enum +{ + VCODEC_ENC_ROTATE_0 = 0, + VCODEC_ENC_ROTATE_90 = 1, + VCODEC_ENC_ROTATE_180 = 2, + VCODEC_ENC_ROTATE_270 = 3 +} VCODEC_ENC_ROTATE_ANGLE_T; + +typedef enum +{ + VCODEC_ENC_QUALITY_NONE, + VCODEC_ENC_QUALITY_LOW, + VCODEC_ENC_QUALITY_NORMAL, + VCODEC_ENC_QUALITY_GOOD, + VCODEC_ENC_QUALITY_FINE, + VCODEC_ENC_QUALITY_CUSTOM +} VCODEC_ENC_QUALITY_T; + +typedef enum +{ + VCODEC_ENC_CODEC_TYPE_NONE, + VCODEC_ENC_CODEC_TYPE_MPEG4, + VCODEC_ENC_CODEC_TYPE_H263, + VCODEC_ENC_CODEC_TYPE_H264 +} VCODEC_ENC_CODEC_T; + +typedef struct +{ + + void (*pfnMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + IN VCODEC_MEMORY_TYPE_T /* fgCacheable */, + OUT VCODEC_BUFFER_T * /* prBuf */ + ); /*buffer address must cache line align */ + + void (*pfnIntMalloc)(IN HANDLE /* hDrv */, + IN unsigned int /* u4Size */, + IN unsigned int /*u4AlignSize*/, + OUT VCODEC_BUFFER_T * /* prBuffer_adr */ + ); + + + void (*pfnFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuf */ + ); /* same memory type with malloc */ + + + void (*pfnIntFree)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBuffer_adr */ + ); + + void (*pfnReleaseYUV)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prYUVBuf */ + ); + + void (*pfnPaused)(IN HANDLE /* hDrv */, + IN VCODEC_BUFFER_T * /* prBitstreamBuf */ + ); + + void (*pfnAllocateBitstreamBuffer)(IN HANDLE /* hDrv */, + OUT VCODEC_ENC_BUFFER_INFO_T * /* prBitstreamBuf */ + ); + + void (*pfnUpdateBitstreamWP)(IN HANDLE /* hDrv */, + IN VCODEC_ENC_UPDATE_WP_INTO_T * /* prUpdateWritePointer */ + ); + VCODEC_ENC_ERROR_T(*pfnQueryInfo)(IN HANDLE /* hDrv */, + IN VCODEC_ENC_QUERY_INFO_TYPE_T /* query id*/, + OUT void * /* pvParamData*/ + ); + + +} VCODEC_ENC_CALLBACK_T; + +// non-callback +typedef struct +{ + UINT64 u8TimeStamp; + VCODEC_ENC_INPUT_FLAG_T eFlags; + VCODEC_ENC_INPUT_INFO_T rInput; + VCODEC_ENC_BUFFER_INFO_T pBuffInfo; + VCODEC_COLOR_FORMAT_T eVEncFormat; + unsigned int u4Width; + unsigned int u4Height; + unsigned int u4YStride; + unsigned int u4UVStride; + unsigned int u4SliceHeight; + void *reserved[4]; +} VIDEO_ENCODER_INPUT_PARAM_NC_T; +// non-callback +typedef struct +{ + UINT64 u8TimeStamp; + VCODEC_ENC_INPUT_FLAG_T eFlags; + VCODEC_ENC_INPUT_YUV_INFO_T rInput; + VCODEC_ENC_BUFFER_INFO_T pBuffInfo; + VCODEC_COLOR_FORMAT_T eVEncFormat; + unsigned int u4Width; + unsigned int u4Height; + unsigned int u4YStride; + unsigned int u4UVStride; + unsigned int u4SliceHeight; + void *reserved[4]; +} VIDEO_ENCODER_INPUT_YUV_PARAM_NC_T; + +typedef struct +{ + VCODEC_ENC_ERROR_T(*pfnGetMemoryRequired)(IN VCODEC_ENC_SETTING_T *rCodecFormat, + OUT VCODEC_MEMORY_SIZE_T *prExternalSize + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_ENC_ERROR_T(*pfnOpen)(IN HANDLE hDrv, + IN HANDLE hWrapper, + IN VCODEC_ENC_CALLBACK_T * , + OUT HANDLE *hCodec + ); + + VCODEC_ENC_ERROR_T(*pfnInit)(IN HANDLE hCodec + ); + + VCODEC_ENC_ERROR_T(*pfnGetParameter)(IN HANDLE hCodec, + OUT VCODEC_ENC_PARAM_TYPE_T, /*VIDEO_ENC_MEMORY_T,*/ + void * + ); + + VCODEC_ENC_ERROR_T(*pfnSetParameter)(IN HANDLE hCodec, + IN VCODEC_ENC_PARAM_TYPE_T, /*VIDEO_ENCODER_QUALITY_T,VIDEO_ENCODER_CODEC_T,VIDEO_CODEC_ROTATE_ANGLE_T,*/ + void * + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_ENC_ERROR_T(*pfnGenerateHeader)(IN HANDLE hCodec, + IN HANDLE hWrapper, + IN VCODEC_ENC_BUFFER_INFO_T *prBufferInfo // for smart phone + ); + + /******************************************************** + * wrapped for smart phone + ********************************************************/ + VCODEC_ENC_ERROR_T(*pfnEncodeOneUnit)(IN HANDLE hCodec, + IN HANDLE hWrapper, + IN VIDEO_ENCODER_INPUT_YUV_PARAM_NC_T *prEncoderInputParamNC // for smart phone + ); + + VCODEC_ENC_ERROR_T(*pfnDeInit)(IN HANDLE hCodec + ); + + VCODEC_ENC_ERROR_T(*pfnClose)(IN HANDLE hCodec + ); + + VCODEC_ENC_ERROR_T(*pfnGetNextBitstream)(IN HANDLE hCodec, + OUT VCODEC_ENC_GENERAL_OUTPUT_T * + ); +} VIDEO_ENC_API_T; + + +// ~non-callback + +typedef struct +{ + VCODEC_ENC_ERROR_T(*pfnGetMemoryRequired)(IN VCODEC_ENC_SETTING_T *, /*prInput*/ + OUT VCODEC_MEMORY_SIZE_T * /*prExternalSize*/ + ); + + VCODEC_ENC_ERROR_T(*pfnOpen)(IN HANDLE /* hDrv */, + IN VCODEC_ENC_CALLBACK_T * /* pfnCallback */, + OUT HANDLE * /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnInit)(IN HANDLE /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnGetParameter)(IN HANDLE /* hCodec */, + IN VCODEC_ENC_PARAM_TYPE_T /*VIDEO_ENC_MEMORY_T,*/, + OUT void * /* pvParamData */ + ); + + VCODEC_ENC_ERROR_T(*pfnSetParameter)(IN HANDLE /* hCodec */, + IN VCODEC_ENC_PARAM_TYPE_T /* rEncodeParam*/, /*VCODEC_ENC_QUALITY_T,VCODEC_ENC_CODEC_T,VIDEO_CODEC_ROTATE_ANGLE_T,*/ + IN void * /* pvParamData */ + ); + + VCODEC_ENC_ERROR_T(*pfnGenerateHeader)(IN HANDLE /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnEncodeOneUnit)(IN HANDLE /* hCodec */, + IN void * /*prInput*/ /*VCODEC_ENC_INPUT_YUV_INFO_T , VCODEC_ENC_INPUT_INFO_T*/ + ); + VCODEC_ENC_ERROR_T(*pfnDeInit)(IN HANDLE /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnClose)(IN HANDLE /* hCodec */ + ); + + VCODEC_ENC_ERROR_T(*pfnGetNextBitstream)(IN HANDLE /* hCodec */, + OUT VCODEC_ENC_GENERAL_OUTPUT_T * /* prPrivOutput*/ + ); +} VCODEC_ENC_API_T; + +typedef struct +{ + VIDEO_ENC_API_T rVideoEncAPI; + VCODEC_ENC_API_T *pfnVcodecEncAPI; + HANDLE hDriver; + VCODEC_BUFFER_T rReleaseYUV; + VCODEC_ENC_BUFFER_INFO_T rEncoderBuffInfoNC; +} VIDEO_ENC_WRAP_HANDLE_T; + +typedef struct +{ + unsigned int u4TimeIncrResolution; + unsigned int u4BufferSize; + VCODEC_BUFFER_T *prBuffer; +} MPEG4_VT_ENCODER_GEN_VT_HEADER_INPUT_T; + +VCODEC_ENC_ERROR_T MPEG4EncoderGenerateVTHeader( + IN MPEG4_VT_ENCODER_GEN_VT_HEADER_INPUT_T *prInput, + OUT unsigned int *pu4EncodedSize +); + + + + + + +#endif /* VCODEC_IF_H */ + diff --git a/include/linux/vcodec/vcodec_log.h b/include/linux/vcodec/vcodec_log.h new file mode 100644 index 000000000..703c5dfe1 --- /dev/null +++ b/include/linux/vcodec/vcodec_log.h @@ -0,0 +1,106 @@ +#ifndef VCODEC_LOG_H +#define VCODEC_LOG_H + +#include "vcodec_if_v2.h" + +#define lmx_prt(a,b,c) + +//Add your index here +typedef enum +{ + /* MPEG4 ENCODER */ + VCODEC_LOG_INDEX_MP4ENC_ENCODE_ERROR, + VCODEC_LOG_INDEX_MP4ENC_ERROR_GET_BITSTREAM, + VCODEC_LOG_INDEX_MP4ENC_ALLOCATE_EXT_MEMORY, + VCODEC_LOG_INDEX_MP4ENC_FREE_EXT_MEMORY, + VCODEC_LOG_INDEX_MP4ENC_QPHDR, + VCODEC_LOG_INDEX_MP4ENC_FRAMETYPE, + VCODEC_LOG_INDEX_MP4ENC_SETTING, + VCODEC_LOG_INDEX_MP4ENC_GET_BITSTREAM, + + /* MPEG4 DECODER */ + VCODEC_LOG_INDEX_MP4DEC_DECODE_ERROR, + VCODEC_LOG_INDEX_MP4DEC_DECODE_FIRST_FRAME, + VCODEC_LOG_INDEX_MP4DEC_DECODE_VOP_TYPE, + VCODEC_LOG_INDEX_MP4DEC_DECODE_RESOLUTION, + VCODEC_LOG_INDEX_MP4DEC_DECODE_EOF, + VCODEC_LOG_INDEX_MP4DEC_SET_FRAME_RATE, + VCODEC_LOG_INDEX_MP4DEC_SET_BIT_RATE, + VCODEC_LOG_INDEX_SWMP4DEC_LOSSY_INIT_QTY, + VCODEC_LOG_INDEX_SWMP4DEC_LOSSY_INIT_DSWITCH, + VCODEC_LOG_INDEX_SWMP4DEC_LOSSY_SWITCH_QTY, + + /* RMVB DECODER */ + VCODEC_LOG_INDEX_RMDEC_DECODE_RESULT1, + VCODEC_LOG_INDEX_RMDEC_DECODE_RESULT2, + VCODEC_LOG_INDEX_RMDEC_ERROR_FRM, + VCODEC_LOG_INDEX_RMDEC_DECODE_ERROR, + VCODEC_LOG_INDEX_RMDEC_HOLD_PIC_TYPE_ERROR, + VCODEC_LOG_INDEX_RMDEC_UNKNOW_ERROR, + VCODEC_LOG_INDEX_RMDEC_TIMESTAMP1, + VCODEC_LOG_INDEX_RMDEC_TIMESTAMP2, + VCODEC_LOG_INDEX_RMDEC_SKIP_FRM, + VCODEC_LOG_INDEX_RMDEC_SKIP_SETTING2, + VCODEC_LOG_INDEX_RMDEC_STANDARD_DEC, + VCODEC_LOG_INDEX_RMDEC_LOSSY_DEC, + VCODEC_LOG_INDEX_RMDEC_OPEN, + VCODEC_LOG_INDEX_RMDEC_CLOSE, + VCODEC_LOG_INDEX_RMDEC_UNSUPPORT, + + /* H.264 DECODER */ + VCODEC_LOG_INDEX_H264DEC_INIT, + VCODEC_LOG_INDEX_H264DEC_DEINIT, + VCODEC_LOG_INDEX_H264DEC_OPEN, + VCODEC_LOG_INDEX_H264DEC_CLOSE, + VCODEC_LOG_INDEX_H264DEC_INIT_ERROR, + VCODEC_LOG_INDEX_H264DEC_DECODE_RESULT, + VCODEC_LOG_INDEX_H264DEC_DECODE_ERROR, + VCODEC_LOG_INDEX_H264DEC_ARGUMENT_ERROR, + VCODEC_LOG_INDEX_H264DEC_SUPPORT_ERROR, + VCODEC_LOG_INDEX_H264DEC_DECODING_CONCEAL, + VCODEC_LOG_INDEX_H264DEC_DISPLAY_INFO, + VCODEC_LOG_INDEX_H264DEC_CROP_INFO, + VCODEC_LOG_INDEX_H264DEC_BITSTREAM_INFO, + VCODEC_LOG_INDEX_H264DEC_PAYLOAD_INFO, + VCODEC_LOG_INDEX_H264DEC_CHANGE_SPS, + VCODEC_LOG_INDEX_H264DEC_ABNORMAL_NALU_SIZE, + VCODEC_LOG_INDEX_H264DEC_HEADER_ERROR, + VCODEC_LOG_INDEX_H264DEC_OUTPUT_IDR, + VCODEC_LOG_INDEX_H264DEC_ALIGN_ERROR, + VCODEC_LOG_INDEX_H264DEC_ALLOCATE_ERROR, + VCODEC_LOG_INDEX_SWH264DEC_LOSSY_INIT_QTY, + VCODEC_LOG_INDEX_SWH264DEC_LOSSY_INIT_DSWITCH, + VCODEC_LOG_INDEX_SWH264DEC_LOSSY_SWITCH_QTY, + VCODEC_LOG_INDEX_SWH264DEC_MEM_ALLOCATE, + VCODEC_LOG_INDEX_SWH264DEC_DPB_INIT, + VCODEC_LOG_INDEX_SWH264DEC_DPB_MARK_REFPIC, + VCODEC_LOG_INDEX_SWH264DEC_CONCEAL, + VCODEC_LOG_INDEX_SWH264DEC_OUTPIC1, + VCODEC_LOG_INDEX_SWH264DEC_OUTPIC2, + VCODEC_LOG_INDEX_SWH264DEC_SPSDPB_CHECK, + VCODEC_LOG_INDEX_H264DEC_SKIPB, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_INIT, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_INFO, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_BP, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_MPHP, + VCODEC_LOG_INDEX_H264DEC_TIMESTAMP_STATUS, + VCODEC_LOG_INDEX_H264ENC_STREAMBUFFER_ALLOC, + VCODEC_LOG_INDEX_H264ENC_STREAMBUFFER_UPDATE, + VCODEC_LOG_INDEX_MAX +} VCODEC_LOG_INDEX_T; + +typedef enum +{ + VCODEC_LOG_GROUP_HIGH, + VCODEC_LOG_GROUP_MEDIUM, + VCODEC_LOG_GROUP_LOW, + VCODEC_LOG_GROUP_MAX +} VCODEC_LOG_GROUP_T; + +void VcodecTraceLog0(VCODEC_LOG_GROUP_T eGroup, VCODEC_LOG_INDEX_T eIndex); +void VcodecTraceLog1(VCODEC_LOG_GROUP_T eGroup, VCODEC_LOG_INDEX_T eIndex, UINT64 arg); +void VcodecTraceLog2(VCODEC_LOG_GROUP_T eGroup, VCODEC_LOG_INDEX_T eIndex, UINT64 arg1, UINT64 arg2); +void VcodecTraceLog4(VCODEC_LOG_GROUP_T eGroup, VCODEC_LOG_INDEX_T eIndex, UINT64 arg1, UINT64 arg2, UINT64 arg3, UINT64 arg4); +void VcodecTraceLog8(VCODEC_LOG_GROUP_T eGroup, VCODEC_LOG_INDEX_T eIndex, UINT64 arg1, UINT64 arg2, UINT64 arg3, UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7, UINT64 arg8); +#endif /* VCODEC_LOG_H */ \ No newline at end of file diff --git a/include/linux/vcodec/vdec_drv_base.h b/include/linux/vcodec/vdec_drv_base.h new file mode 100644 index 000000000..aa3c3e9a5 --- /dev/null +++ b/include/linux/vcodec/vdec_drv_base.h @@ -0,0 +1,84 @@ +#define DumpInput__ +#ifdef DumpInput__ +#include +#endif +#include "vdec_drv_if_private.h" + +#ifndef _VDEC_DRV_BASE_ +#define _VDEC_DRV_BASE_ +#define MAX_BUFFER_SIZE 37 + +#if 1 +#define WAITING_MODE VAL_INTERRUPT_MODE +#else +#define WAITING_MODE VAL_POLLING_MODE +#endif + +#define DO_VCODEC_RESET(cmd, index) \ + { \ + ADD_QUEUE(cmd, index, WRITE_REG_CMD, MT6589_VDEC_MISC, VDEC_INT_CFG, 0 , WAITING_MODE); \ + } + +typedef enum __VDDRV_MRESULT_T +{ + VDDRV_MRESULT_SUCCESS = VAL_TRUE, ///< Represent success + VDDRV_MRESULT_FAIL = VAL_FALSE, ///< Represent failure + VDDRV_MRESULT_RESOLUTION_CHANGED = VAL_RESOLUTION_CHANGED, ///< Represent resoluion changed + VDDRV_MRESULT_NEED_MORE_OUTPUT_BUFFER, ///< Represent need more output buffer + VDDRV_MRESULT_FATAL +} VDDRV_MRESULT_T; + +typedef struct __VDEC_DRV_BASE_T +{ + VAL_UINT32_T(*Init)(VAL_HANDLE_T *handle, VAL_HANDLE_T halhandle, VAL_HANDLE_T valhandle, P_VDEC_DRV_RINGBUF_T pBitstream, P_VDEC_DRV_SEQINFO_T pSeqinfo, VDEC_DRV_VIDEO_FORMAT_T eFormat); ///< Function to do driver Initialization + VAL_UINT32_T(*Decode)(VAL_HANDLE_T handle, P_VDEC_DRV_RINGBUF_T pBitstream, P_VDEC_DRV_FRAMEBUF_T pFrame); ///< Driver Decode Main Funciton + P_VDEC_DRV_FRAMEBUF_T(*GetDisplayBuffer)(VAL_HANDLE_T handle); ///< Get Buffer ready to display + P_VDEC_DRV_FRAMEBUF_T(*GetFreeBuffer)(VAL_HANDLE_T handle); ///< Get Buffer ready to release + VAL_UINT32_T(*GetParam)(VAL_HANDLE_T handle, VDEC_DRV_GET_TYPE_T a_eType, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); ///< get codec's required memory size. (Ex: VDEC_DRV_GET_TYPE_QUERY_REF_POOL_SIZE) + VAL_UINT32_T(*SetParam)(VAL_HANDLE_T handle, VDEC_DRV_SET_TYPE_T a_eType, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); ///< get codec's required memory size. (Ex: VDEC_DRV_GET_TYPE_QUERY_REF_POOL_SIZE) + VAL_UINT32_T(*DeInit)(VAL_HANDLE_T handle); ///< Function to do driver de-initialization + P_VDEC_DRV_RINGBUF_T(*GetFreeInputBuffer)(VAL_HANDLE_T handle); +} VDEC_DRV_BASE_T; + +typedef struct __VDEC_DRV_BUF_STATUS_T +{ + VAL_BOOL_T bDisplay; + VAL_BOOL_T bFree; + VDEC_DRV_FRAMEBUF_T *pFrameBuf; +} VDEC_DRV_BUF_STATUS_T, *P_VDEC_DRV_BUF_STATUS_T; + +typedef struct __VDEC_DRV_INPUT_BUF_STATUS_T +{ + VDEC_DRV_RINGBUF_T *pInputBuf; + VAL_UINT32_T u4RefCnt; +} VDEC_DRV_INPUT_BUF_STATUS_T, *P_VDEC_DRV_INPUT_BUF_STATUS_T; + +typedef struct __VDEC_HANDLE_T +{ + VDEC_DRV_VIDEO_FORMAT_T CodecFormat; + VDEC_DRV_BASE_T rFuncPtr; ///< Point to driver's proprietary function. + VAL_HANDLE_T hDrvHandle; ///< Handle of each format driver + VAL_BOOL_T fgDrvInitFlag; ///< hDrvHandle is available or not + VAL_HANDLE_T hHalHandle; ///< HAL handle + VAL_BOOL_T fgHalInitFlag; ///< hHalHandle is available or not + VAL_HANDLE_T hValHandle; ///< VAL handle + VAL_BOOL_T fgValInitFlag; ///< hValHandle is available or not + VAL_MEMORY_T rHandleMem; ///< Memory for vdec handle + P_VDEC_DRV_FRAMEBUF_T pDispFrameBuf; + P_VDEC_DRV_FRAMEBUF_T pFreeFrameBuf; + P_VDEC_DRV_RINGBUF_T pInputFreeBuf; + VDEC_DRV_BUF_STATUS_T pFrameBufArray[MAX_BUFFER_SIZE]; + VDEC_DRV_INPUT_BUF_STATUS_T pInputBufArray[MAX_BUFFER_SIZE]; + VAL_BOOL_T bFlushAll; + VAL_BOOL_T bInputFlushAll; + // for no VOS header when MPEG4 + VAL_UINT16_T nDefWidth; + VAL_UINT16_T nDefHeight; + VDEC_DRV_SET_DECODE_MODE_T rSetDecodeMode; + VAL_INT32_T nPerfServiceHandle; +#ifdef DumpInput__ + FILE *pf_out; +#endif +} VDEC_HANDLE_T; + +#endif diff --git a/include/linux/vcodec/vdec_drv_if_dep.h b/include/linux/vcodec/vdec_drv_if_dep.h new file mode 100644 index 000000000..145aaf547 --- /dev/null +++ b/include/linux/vcodec/vdec_drv_if_dep.h @@ -0,0 +1,159 @@ +#ifndef VDEC_DRV_IF_DEP_H // for 6572 only +#define VDEC_DRV_IF_DEP_H + +/*============================================================================= + * Include Files + *===========================================================================*/ + +#include "val_types_private.h" +#include "vcodec_if_v2.h" +//#include "rv_format_info.h" +#include "wmc_type.h" +//#include "strm_iem.h" +#include "vcodec_dec_demuxer_if_v2.h" +//#include "ts_vcodec_common.h" +#define DumpInput__ +#ifdef DumpInput__ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*============================================================================= + * Definition + *===========================================================================*/ +#define MAX_BUFFER_SIZE 21 +/*typedef struct +{ + // for speedy mode + VAL_UINT32_T nBufferStatus; + VAL_INT64_T llLastVideoTime; + VAL_INT64_T llCurrentPlayTime; +} DRIVER_HANDLER_T; +*/ +/* +typedef struct __RV9_DRV_DATA_T +{ + VAL_UINT32_T uStreamHdrWidth; + VAL_UINT32_T uStreamHdrHeight; + RM_DECODER_INPUT_PARAM_T rRM_INPUT_Data; + payload_inf_st payload_inf_tab_rv9[200]; //set up 200 + RM_DECODER_PAYLOAD_INFO_T payload_inf_tab_rv9_MAUI[200]; //set up 200 +} RV9_DRV_DATA_T, *P_RV9_DRV_DATA_T; +*/ + +typedef struct __H264_DRV_DATA_T +{ + H264_DECODER_PAYLOAD_INFO_T prH264Payload; + H264_DECODER_INPUT_PARAM_T prInputData; + H264_DECODER_PRIVATE_PARAM_T rPrivateData; +} H264_DRV_DATA_T, *P_H264_DRV_DATA_T; + +typedef struct __MPEG4_DRV_DATA_T +{ + MPEG4_DECODER_PAYLOAD_INFO_T prMPEG4Payload; + MPEG4_DECODER_INPUT_PARAM_T prInputData; +} MPEG4_DRV_DATA_T, *P_MPEG4_DRV_DATA_T; + +typedef struct __VP8_DRV_DATA_T +{ + //VP8_DEC_CUSTOM_SETTING_T VP8CustSetting; +} VP8_DRV_DATA_T, *P_VP8_DRV_DATA_T; + +typedef struct __VP9_DRV_DATA_T +{ + //VP9_DEC_CUSTOM_SETTING_T VP9CustSetting; +} VP9_DRV_DATA_T, *P_VP9_DRV_DATA_T; + +typedef struct __VC1_DRV_DATA_T +{ + VAL_BOOL_T bVC1FirstDecode; + VC1_DECODER_PAYLOAD_INFO_T prVC1Payload; + VC1_DECODER_INPUT_PARAM_T prInputData; + TEMP_INTERFACE VC1TempInterface; +} VC1_DRV_DATA_T, *P_VC1_DRV_DATA_T; + +typedef struct __VDEC_DRV_BUF_STATUS_T +{ + VAL_BOOL_T bDisplay; + VAL_BOOL_T bFree; + VDEC_DRV_FRAMEBUF_T *pFrameBuf; +} VDEC_DRV_BUF_STATUS_T, *P_VDEC_DRV_BUF_STATUS_T; + +typedef enum +{ + VDEC_DRV_STATUS_OPEN_DONE = 0x00000001, + VDEC_DRV_STATUS_INIT_DONE = 0x00000002, + VDEC_DRV_STATUS_DECODE_EVER = 0x00000004 +} VDEC_DRV_STATUS; + + +typedef struct __VDEC_HANDLE_T +{ + VAL_HANDLE_T hHalHandle; ///< HAL data. + VAL_HANDLE_T vHandle; ///< for MMSYS power on/off + VAL_MEMORY_T rHandleMem; ///< Save handle memory information to be used in release. + VAL_BOOL_T bFirstDecoded; /// < already pass first video data to codec + VAL_BOOL_T bHeaderPassed; /// < already pass video header to codec + VAL_BOOL_T bFlushAll; + VAL_BOOL_T bNewMemory; /// allocate buffer for first DOU + VAL_MEMORY_T HeaderBuf; + VAL_MEMORY_T HeaderBufwithFrame; + VAL_HANDLE_T hCodec; + DRIVER_HANDLER_T hDrv; + VIDEO_WRAP_HANDLE_T hWrapper; + VAL_UINT32_T CustomSetting; + VCODEC_BUFFER_T rVideoBitBuf; + VCODEC_DEC_INPUT_YUV_INFO_T rVideoFrameBuf; + VCODEC_MEMORY_TYPE_T rVideoDecMemType; + VAL_UINT32_T YUVBuffer[MAX_BUFFER_SIZE]; + VAL_UINT32_T nYUVBufferIndex; + VAL_UINT32_T nDrvStatus; + VDEC_DRV_BUF_STATUS_T pFrameBufArray[MAX_BUFFER_SIZE]; + VDEC_DRV_FRAMEBUF_T *DispFrameBuf, *FreeFrameBuf; + VCODEC_OPEN_SETTING_T codecOpenSetting; + VCODEC_DEC_INPUT_T rInputUnit; + VIDEO_DECODER_INPUT_NC_T rVideoDecInputNC; + VCODEC_DEC_OUTPUT_PARAM_T *rVideoDecOutputParam; + VCODEC_DEC_PRIVATE_OUTPUT_T rVideoDecOutput; + VCODEC_DEC_OUTPUT_BUFFER_PARAM_T rVideoDecYUVBufferParameter; + VCODEC_DEC_INPUT_BUFFER_PARAM_T rBitStreamParam; + // for seek and thumbnail mode optimization + VAL_BOOL_T bFirstDecodeForThumbnail; + VAL_BOOL_T bThumbnailModeOK; + VDEC_DRV_SET_DECODE_MODE_T rSetDecodeMode; + // for no VOS header when MPEG4 + VAL_UINT16_T nDefWidth; + VAL_UINT16_T nDefHeight; + + VDEC_DRV_VIDEO_FORMAT_T CodecFormat; + VAL_VOID_T *prExtraData; ///< Driver private data pointer. + VAL_MEMORY_T rExtraDataMem; ///< Save extra data memory information to be used in release. + VCODEC_DEC_PRIVATE_OUTPUT_EXTRA_T prExtraDecOutput; +#ifdef DumpInput__ + FILE *pf_out; +#endif + + // Morris Yang 20111101 [ + VAL_UINT32_T nOmxTids; + // ] +#if 1 //defined(MT6572) //VCODEC_MULTI_THREAD + // Jackal Chen [ + VAL_VOID_T *pDrvModule; ///< used for dlopen and dlclose + // ] +#endif + VAL_BOOL_T fgValInitFlag; ///< hValHandle is available or not +} VDEC_HANDLE_T; + +/*============================================================================= + * Function Declaration + *===========================================================================*/ + +#ifdef __cplusplus +} +#endif + +#endif /* VDEC_DRV_IF_DEP_H */ + diff --git a/include/linux/vcodec/vdec_drv_if_private.h b/include/linux/vcodec/vdec_drv_if_private.h new file mode 100644 index 000000000..d5d0c593b --- /dev/null +++ b/include/linux/vcodec/vdec_drv_if_private.h @@ -0,0 +1,432 @@ +/** + * @file + * vdec_drv_if_private.h + * + * @par Project: + * Video + * + * @par Description: + * Video Decoder Driver Interface for internal use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VDEC_DRV_IF_PRIVATE_H_ +#define _VDEC_DRV_IF_PRIVATE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_private.h" +#include "vdec_drv_if_public.h" + + +typedef enum +{ + UNKNOWN_FBTYPE = 0, ///< Unknown type + VDEC_DRV_FBTYPE_YUV420_BK_16x1 = (1 << 0), ///< YCbCr 420 block in three planar + VDEC_DRV_FBTYPE_YUV420_BK_8x2 = (1 << 1), ///< YCbCr 420 block in three planar + VDEC_DRV_FBTYPE_YUV420_BK_4x4 = (1 << 2), ///< YCbCr 420 block in three planar + VDEC_DRV_FBTYPE_YUV420_RS = (1 << 3), ///< YCbCr 420 raster scan in three planar + VDEC_DRV_FBTYPE_RGB565_RS = (1 << 4) ///< RGB565 in one planar +} +VDEC_DRV_FBTYPE_T; + + +/** + * @par Structure + * VDEC_DRV_BUFFER_CONTROL_T + * @par Description + * Type of buffer control + * - Here are two types of buffer + * - 1.Reference buffer + * - 2.Display buffer + * - Buffer can be fixed size or derived from memory pool. + * - Buffer can be created from internal or external memory. + */ +typedef enum +{ + VDEC_DRV_BUFFER_CONTROL_UNKNOWN = 0, ///< Unknown Type + VDEC_DRV_BUFFER_CONTROL_REF_IS_DISP_EXT = (1 << 0), ///< Reference frame and Display frame share the same external buffer + VDEC_DRV_BUFFER_CONTROL_REF_IS_DISP_INT = (1 << 1), ///< Reference frame and Display frame share the same internal buffer + VDEC_DRV_BUFFER_CONTROL_REF_IS_DISP_EXT_POOL = (1 << 2), ///< Reference frame and Display frame share the same external memory pool + VDEC_DRV_BUFFER_CONTROL_REF_IS_DISP_INT_POOL = (1 << 3), ///< Reference frame and Display frame share the same internal memory pool + VDEC_DRV_BUFFER_CONTROL_REF_EXT_DISP_EXT = (1 << 4), ///< Reference frame uses external buffer and Display frame use another external buffer + VDEC_DRV_BUFFER_CONTROL_REF_EXT_DISP_INT = (1 << 5), ///< Reference frame uses external buffer and Display frame uses internal buffer + VDEC_DRV_BUFFER_CONTROL_REF_EXT_DISP_EXT_POOL = (1 << 6), ///< Reference frame uses external buffer and Display frame uses external memory pool + VDEC_DRV_BUFFER_CONTROL_REF_EXT_DISP_INT_POOL = (1 << 7), ///< Reference frame uses external buffer and Display frame uses internal memory pool + VDEC_DRV_BUFFER_CONTROL_REF_EXT_POOL_DISP_EXT = (1 << 8), ///< Reference frame uses external memory pool and Display frame use external buffer + VDEC_DRV_BUFFER_CONTROL_REF_EXT_POOL_DISP_INT = (1 << 9), ///< Reference frame uses external memory pool and Display frame uses internal buffer + VDEC_DRV_BUFFER_CONTROL_REF_EXT_POOL_DISP_EXT_POOL = (1 << 10), ///< Reference frame uses external memory pool and Display frame uses external memory pool + VDEC_DRV_BUFFER_CONTROL_REF_EXT_POOL_DISP_INT_POOL = (1 << 11), ///< Reference frame uses external memory pool and Display frame uses internal memory pool + VDEC_DRV_BUFFER_CONTROL_REF_INT_DISP_EXT = (1 << 12), ///< Reference frame uses internal buffer and Display frame use external buffer + VDEC_DRV_BUFFER_CONTROL_REF_INT_DISP_INT = (1 << 13), ///< Reference frame uses internal buffer and Display frame uses internal buffer + VDEC_DRV_BUFFER_CONTROL_REF_INT_DISP_EXT_POOL = (1 << 14), ///< Reference frame uses internal buffer and Display frame uses external memory pool + VDEC_DRV_BUFFER_CONTROL_REF_INT_DISP_INT_POOL = (1 << 15), ///< Reference frame uses internal buffer and Display frame uses internal memory pool + VDEC_DRV_BUFFER_CONTROL_REF_INT_POOL_DISP_EXT = (1 << 16), ///< Reference frame uses internal memory pool and Display frame use external buffer + VDEC_DRV_BUFFER_CONTROL_REF_INT_POOL_DISP_INT = (1 << 17), ///< Reference frame uses internal memory pool and Display frame uses internal buffer + VDEC_DRV_BUFFER_CONTROL_REF_INT_POOL_DISP_EXT_POOL = (1 << 18), ///< Reference frame uses internal memory pool and Display frame uses external memory pool + VDEC_DRV_BUFFER_CONTROL_REF_INT_POOL_DISP_INT_POOL = (1 << 19) ///< Reference frame uses external memory pool and Display frame uses another internal memory pool +} VDEC_DRV_BUFFER_CONTROL_T; + + +/** + * @par Structure + * VDEC_DRV_DOWNSIZE_RATIO_T + * @par Description + * DownSize Ratio + * - The aspect ratio of frame is kept after downsizing. + */ +typedef enum +{ + VDEC_DRV_DOWNSIZE_RATIO_UNKNOWN = 0, ///< Unknown ratio + VDEC_DRV_DOWNSIZE_RATIO_1_1 = (1 << 0), ///< Original ratio + VDEC_DRV_DOWNSIZE_RATIO_1_2 = (1 << 1), ///< ratio = 1/2 + VDEC_DRV_DOWNSIZE_RATIO_1_3 = (1 << 2), ///< ratio = 1/3 + VDEC_DRV_DOWNSIZE_RATIO_1_4 = (1 << 3), ///< ratio = 1/4 + VDEC_DRV_DOWNSIZE_RATIO_1_5 = (1 << 4), ///< ratio = 1/5 + VDEC_DRV_DOWNSIZE_RATIO_1_6 = (1 << 5), ///< ratio = 1/6 + VDEC_DRV_DOWNSIZE_RATIO_1_7 = (1 << 6), ///< ratio = 1/7 + VDEC_DRV_DOWNSIZE_RATIO_1_8 = (1 << 7) ///< ratio = 1/8 +} VDEC_DRV_DOWNSIZE_RATIO_T; + + +/** + * @par Structure + * VDEC_DRV_PIC_STRUCT_T + * @par Description + * [Unused]Picture Struct + * - Consecutive Frame or filed + * - Separated top/bottom field + */ +typedef enum +{ + VDEC_DRV_PIC_STRUCT_UNKNOWN = 0, ///< Unknown + VDEC_DRV_PIC_STRUCT_CONSECUTIVE_FRAME, ///< Consecutive Frame + VDEC_DRV_PIC_STRUCT_CONSECUTIVE_TOP_FIELD, ///< Consecutive top field + VDEC_DRV_PIC_STRUCT_CONSECUTIVE_BOT_FIELD, ///< Consecutive bottom field + VDEC_DRV_PIC_STRUCT_SEPARATED_TOP_FIELD, ///< Separated top field + VDEC_DRV_PIC_STRUCT_SEPARATED_BOT_FIELD, ///< Separated bottom field + VDEC_DRV_PIC_STRUCT_FIELD, +} VDEC_DRV_PIC_STRUCT_T; + + +/** + * @par Structure + * VDEC_DRV_FRAME_RATE_T + * @par Description + * Frame rate types + */ +typedef enum +{ + VDEC_DRV_FRAME_RATE_UNKNOWN = 0, ///< Unknown fps + VDEC_DRV_FRAME_RATE_23_976, ///< fps = 24000/1001 (23.976...) + VDEC_DRV_FRAME_RATE_24, ///< fps = 24 + VDEC_DRV_FRAME_RATE_25, ///< fps = 25 + VDEC_DRV_FRAME_RATE_29_97, ///< fps = 30000/1001 (29.97...) + VDEC_DRV_FRAME_RATE_30, ///< fps = 30 + VDEC_DRV_FRAME_RATE_50, ///< fps = 50 + VDEC_DRV_FRAME_RATE_59_94, ///< fps = 60000/1001 (59.94...) + VDEC_DRV_FRAME_RATE_60, ///< fps = 60 + VDEC_DRV_FRAME_RATE_120, ///< fps = 120 + VDEC_DRV_FRAME_RATE_1, ///< fps = 1 + VDEC_DRV_FRAME_RATE_5, ///< fps = 5 + VDEC_DRV_FRAME_RATE_8, ///< fps = 8 + VDEC_DRV_FRAME_RATE_10, ///< fps = 10 + VDEC_DRV_FRAME_RATE_12, ///< fps = 12 + VDEC_DRV_FRAME_RATE_15, ///< fps = 15 + VDEC_DRV_FRAME_RATE_16, ///< fps = 16 + VDEC_DRV_FRAME_RATE_17, ///< fps = 17 + VDEC_DRV_FRAME_RATE_18, ///< fps = 18 + VDEC_DRV_FRAME_RATE_20, ///< fps = 20 + VDEC_DRV_FRAME_RATE_2, ///< fps = 2 + VDEC_DRV_FRAME_RATE_6, ///< fps = 6 + VDEC_DRV_FRAME_RATE_48, ///< fps = 48 + VDEC_DRV_FRAME_RATE_70, ///< fps = 70 + VDEC_DRV_FRAME_RATE_VARIABLE ///< fps = VBR +} VDEC_DRV_FRAME_RATE_T; + + +/** + * @par Structure + * VDEC_DRV_POST_PROC_T + * @par Description + * input of type SET_POST_PROC (output is NULL, use return value) + */ +typedef enum +{ + VDEC_DRV_POST_PROC_UNKNOWN = 0, ///< Unknown + VDEC_DRV_POST_PROC_DISABLE, ///< Do not do post-processing + VDEC_DRV_POST_PROC_DOWNSIZE, ///< Do downsize + VDEC_DRV_POST_PROC_RESIZE, ///< Do resize + VDEC_DRV_POST_PROC_DEBLOCK, ///< Do deblocking + VDEC_DRV_POST_PROC_DEINTERLACE ///< Do deinterlace +} VDEC_DRV_POST_PROC_T; + + +/** + * @par Structure + * VDEC_DRV_NALU_T + * @par Description + * Buffer Structure + * - Store NALU buffer base address + * - Store length of NALU buffer + */ + +typedef struct +{ + VAL_UINT32_T u4AddrOfNALu; ///< NALU buffer base address + VAL_UINT32_T u4LengthOfNALu; ///< Length of NALU buffer + void *pReseved; ///< reserved +} VDEC_DRV_NALU_T; + + +/** + * @par Structure + * VDEC_DRV_STATISTIC_T + * @par Description + * VDecDrv Statistic information + */ +typedef struct __VDEC_DRV_STATISTIC_T +{ + VAL_UINT32_T u4DecTimeMax; ///< [Out] Decode one frame period, Max. + VAL_UINT32_T u4DecTimeMin; ///< [Out] Decode one frame period, Min. + VAL_UINT32_T u4DecTimeAvg; ///< [Out] Decode one frame period, Average. +} VDEC_DRV_STATISTIC_T; + +/** + * @par Structure + * P_VDEC_DRV_STATISTIC_T + * @par Description + * Pointer of VDEC_DRV_STATISTIC_T + */ +typedef VDEC_DRV_STATISTIC_T *P_VDEC_DRV_STATISTIC_T; + + +/** + * @par Structure + * VDEC_DRV_FBTYPE_T + * @par Description + * Supported frame buffer type in driver layer + */ +typedef struct +{ + // for speedy mode + VAL_UINT32_T nBufferStatus; + VAL_INT64_T llLastVideoTime; + VAL_INT64_T llCurrentPlayTime; +} DRIVER_HANDLER_T; + + +/** + * @par Structure + * VDEC_DRV_VIDEO_FBTYPE_T + * @par Description + * Both input and output of type QUERY_FBTYPE + */ +typedef struct __VDEC_DRV_VIDEO_FBTYPE_T +{ + VAL_UINT32_T u4FBType; ///< VDEC_DRV_FBTYPE +} VDEC_DRV_VIDEO_FBTYPE_T; + +/** + * @par Structure + * P_VDEC_DRV_VIDEO_FBTYPE_T + * @par Description + * Pointer of VDEC_DRV_VIDEO_FBTYPE_T + */ +typedef VDEC_DRV_VIDEO_FBTYPE_T *P_VDEC_DRV_VIDEO_FBTYPE_T; + + +/** + * @par Structure + * VDEC_DRV_QUERY_BUFFER_MODE_T + * @par Description + * Both input and output of type QUERY_BUFFER_CONTROL + */ +typedef struct __VDEC_DRV_QUERY_BUFFER_MODE_T +{ + VAL_UINT32_T u4BufCtrl; ///< VDEC_DRV_BUFFER_CONTROL +} VDEC_DRV_QUERY_BUFFER_MODE_T; + +/** + * @par Structure + * P_VDEC_DRV_QUERY_BUFFER_MODE_T + * @par Description + * Pointer of VDEC_DRV_QUERY_BUFFER_MODE_T + */ +typedef VDEC_DRV_QUERY_BUFFER_MODE_T *P_VDEC_DRV_QUERY_BUFFER_MODE_T; + + +/** + * @par Structure + * VDEC_DRV_QUERY_POOL_SIZE_T + * @par Description + * output of type QUERY_REF_POOL_SIZE and QUERY_DISP_POOL_SIZE (input is NULL) + */ +typedef struct __VDEC_DRV_QUERY_POOL_SIZE_T +{ + VAL_UINT32_T u4Size; ///< buffer size of the memory pool +} VDEC_DRV_QUERY_POOL_SIZE_T; + +/** + * @par Structure + * P_VDEC_DRV_QUERY_POOL_SIZE_T + * @par Description + * Pointer of VDEC_DRV_QUERY_POOL_SIZE_T + */ +typedef VDEC_DRV_QUERY_POOL_SIZE_T *P_VDEC_DRV_QUERY_POOL_SIZE_T; + +// output of type DISP_FRAME_BUFFER and FREE_FRAME_BUFFER is P_VDEC_DRV_FRAMEBUF_T (input is NULL) +// output of type GET_PICTURE_INFO is P_VDEC_DRV_PICINFO_T (input is NULL) +// both input and output of type QUERY_REORDER_ABILITY are NULL (use return value) + + +/** + * @par Structure + * VDEC_DRV_QUERY_POOL_DOWNSIZE_T + * @par Description + * output of type QUERY_DOWNSIZE_ABILITY (input is NULL) + */ +typedef struct __VDEC_DRV_QUERY_POOL_DOWNSIZE_T +{ + VAL_UINT32_T u4Ratio; ///< VDEC_DRV_DOWNSIZE_RATIO +} VDEC_DRV_QUERY_POOL_DOWNSIZE_T; + +/** + * @par Structure + * P_VDEC_DRV_QUERY_POOL_DOWNSIZE_T + * @par Description + * Pointer of VDEC_DRV_QUERY_POOL_DOWNSIZE_T + */ +typedef VDEC_DRV_QUERY_POOL_DOWNSIZE_T *P_VDEC_DRV_QUERY_POOL_DOWNSIZE_T; + + +/** + * @par Structure + * VDEC_DRV_QUERY_POOL_RESIZE_T + * @par Description + * input of type QUERY_RESIZE_ABILITY (output is NULL, use return value) + */ +typedef struct __VDEC_DRV_QUERY_POOL_RESIZE_T +{ + VAL_UINT32_T u4OutWidth; /// + +#ifndef _VENC_DRV_BASE_ +#define _VENC_DRV_BASE_ + +#define DO_VCODEC_RESET(cmd, index) \ + { \ + } + +typedef enum __VDDRV_MRESULT_T +{ + VDDRV_MRESULT_SUCCESS = VAL_TRUE, ///< Represent success + VDDRV_MRESULT_FAIL = VAL_FALSE ///< Represent failure +} VDDRV_MRESULT_T; + +typedef struct __VENC_DRV_BASE_T +{ + VAL_UINT32_T(*Init)(VAL_HANDLE_T *handle, VAL_HANDLE_T halhandle, VAL_HANDLE_T valhandle); ///< Function to do driver Initialization + VAL_UINT32_T(*Encode)(VAL_HANDLE_T handle, VENC_DRV_START_OPT_T eOpt, P_VENC_DRV_PARAM_FRM_BUF_T pFrameBuf, P_VENC_DRV_PARAM_BS_BUF_T pBitstreamBuf, VENC_DRV_DONE_RESULT_T *pResult); + VAL_UINT32_T(*GetParam)(VAL_HANDLE_T handle, VENC_DRV_GET_TYPE_T a_eType, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); ///< get codec's required memory size. + VAL_UINT32_T(*SetParam)(VAL_HANDLE_T handle, VENC_DRV_SET_TYPE_T a_eType, VAL_VOID_T *a_pvInParam, VAL_VOID_T *a_pvOutParam); ///< set codec's required memory size. + VAL_UINT32_T(*DeInit)(VAL_HANDLE_T handle); ///< Function to do driver de-initialization +} VENC_DRV_BASE_T; + +/** + * @par Structure + * mhalVdoDrv_t + * @par Description + * This is a structure which store common video enc driver information + */ +typedef struct mhalVdoDrv_s +{ + VAL_VOID_T *prCodecHandle; + VAL_UINT32_T u4EncodedFrameCount; + VCODEC_ENC_CALLBACK_T rCodecCb; + VIDEO_ENC_API_T *prCodecAPI; + VENC_BS_T pBSBUF; + + VCODEC_ENC_BUFFER_INFO_T EncoderInputParamNC; + VENC_DRV_PARAM_BS_BUF_T BSout; + VENC_HYBRID_ENCSETTING rVencSetting; + VAL_UINT8_T *ptr; +} mhalVdoDrv_t; + + +typedef struct __VENC_HYBRID_HANDLE_T +{ + mhalVdoDrv_t rMhalVdoDrv; + VAL_MEMORY_T rBSDrvWorkingMem; + VAL_UINT32_T nOmxTids; + VAL_VCODEC_THREAD_ID_T rThreadID; + VIDEO_ENC_WRAP_HANDLE_T hWrapper; + VAL_VOID_T *pDrvModule; ///< used for dlopen and dlclose +} VENC_HYBRID_HANDLE_T; + + +typedef struct __VENC_HANDLE_T +{ + VENC_DRV_VIDEO_FORMAT_T CodecFormat; + VENC_DRV_BASE_T rFuncPtr; ///< Point to driver's proprietary function. + VAL_HANDLE_T hDrvHandle; ///< Handle of each format driver + VAL_HANDLE_T hHalHandle; ///< HAL handle + VAL_HANDLE_T hValHandle; ///< VAL handle + VAL_MEMORY_T rHandleMem; ///< Memory for venc handle + VAL_VOID_T *prExtraData; ///< Driver private data pointer. + VAL_MEMORY_T rExtraDataMem; ///< Save extra data memory information to be used in release. + VENC_HYBRID_HANDLE_T rHybridHandle; ///< Hybrid handle + FILE *pfDump; ///< Dump file + VAL_UINT32_T u4ShowInfo; ///< Flag for show FPS and BitRate + VAL_UINT32_T u4FPS; ///< FPS + VAL_UINT32_T u4Bitrate; ///< Bitrate + struct timeval tStart; ///< Start time counting FPS and bitrate + VENC_DRV_SCENARIO_T eScenario; ///< VENC Senario +} VENC_HANDLE_T; + +VENC_DRV_MRESULT_T ParseConfig(const char *cfgFileName, const char *ParameterItem, VAL_UINT32_T *val); + + +#endif diff --git a/include/linux/vcodec/venc_drv_if_dep.h b/include/linux/vcodec/venc_drv_if_dep.h new file mode 100644 index 000000000..6185ae10c --- /dev/null +++ b/include/linux/vcodec/venc_drv_if_dep.h @@ -0,0 +1,77 @@ +#ifndef VENC_DRV_IF_DEP_H +#define VENC_DRV_IF_DEP_H + +/*============================================================================= + * Include Files + *===========================================================================*/ + +#include "val_types_private.h" +#include "vcodec_if_v2.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*============================================================================= + * Type definition + *===========================================================================*/ + +/** + * @par Structure + * mhalVdoDrv_t + * @par Description + * This is a structure which store common video enc driver information + */ +typedef struct mhalVdoDrv_s +{ + VAL_VOID_T *prCodecHandle; + VAL_UINT32_T u4EncodedFrameCount; + VCODEC_ENC_CALLBACK_T rCodecCb; + VIDEO_ENC_API_T *prCodecAPI; + VENC_BS_T pBSBUF; + + VCODEC_ENC_BUFFER_INFO_T EncoderInputParamNC; + VENC_DRV_PARAM_BS_BUF_T BSout; + VENC_HYBRID_ENCSETTING rVencSetting; + VAL_UINT8_T *ptr; +} mhalVdoDrv_t; + +typedef struct __VENC_HANDLE_T +{ + VAL_HANDLE_T hHalHandle; ///< HAL data. + VAL_HANDLE_T vdriver_Handle; ///< for MMSYS power on/off + VAL_MEMORY_T rHandleMem; ///< Save handle memory information to be used in release. + VAL_BOOL_T bFirstDecoded; /// < already pass first video data to codec + VAL_BOOL_T bHeaderPassed; /// < already pass video header to codec + VAL_BOOL_T bFlushAll; + VAL_MEMORY_T HeaderBuf; + VAL_HANDLE_T hCodec; + // DRIVER_HANDLER_T hDrv; + VAL_UINT32_T CustomSetting; + VCODEC_MEMORY_TYPE_T rVideoDecMemType; + VAL_UINT32_T nYUVBufferIndex; + VCODEC_OPEN_SETTING_T codecOpenSetting; + + mhalVdoDrv_t rMhalVdoDrv; + VAL_MEMORY_T bs_driver_workingmem; + + // Morris Yang 20110411 [ + VENC_DRV_VIDEO_FORMAT_T CodecFormat; + VAL_VOID_T *prExtraData; ///< Driver private data pointer. + VAL_MEMORY_T rExtraDataMem; ///< Save extra data memory information to be used in release. + // ] + VAL_UINT32_T nOmxTids; +#if 1 //defined(MT6572) //VCODEC_MULTI_THREAD + // Jackal Chen [ + VAL_VOID_T *pDrvModule; ///< used for dlopen and dlclose + // ] +#endif + VIDEO_ENC_WRAP_HANDLE_T hWrapper; +} VENC_HANDLE_T; + + +#ifdef __cplusplus +} +#endif + +#endif /* VENC_DRV_IF_DEP_H */ \ No newline at end of file diff --git a/include/linux/vcodec/venc_drv_if_private.h b/include/linux/vcodec/venc_drv_if_private.h new file mode 100644 index 000000000..231ff63d0 --- /dev/null +++ b/include/linux/vcodec/venc_drv_if_private.h @@ -0,0 +1,153 @@ +/** + * @file + * venc_drv_if_private.h + * + * @par Project: + * Video + * + * @par Description: + * Video Encoder Driver Interface for internal use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VENC_DRV_IF_PRIVATE_H_ +#define _VENC_DRV_IF_PRIVATE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_private.h" +#include "venc_drv_if_public.h" + + +typedef enum __VENC_DRV_COLOR_FORMAT_T +{ + VENC_DRV_COLOR_FORMAT_YUV420, + VENC_DRV_COLOR_FORMAT_YV12, +} +VENC_DRV_COLOR_FORMAT_T; + + +typedef struct __VENC_DRV_YUV_STRIDE_T +{ + unsigned int u4YStride; + unsigned int u4UVStride; +} VENC_DRV_YUV_STRIDE_T; + + +/** + * @par Structure + * VENC_DRV_PARAM_EIS_T + * @par Description + * This is the EIS information and used as input or output parameter for\n + * eVEncDrvSetParam() or eVEncDrvGetParam()\n + */ +typedef struct __VENC_DRV_PARAM_EIS_T +{ + VAL_BOOL_T fgEISEnable; ///<: EIS Enable/disable. + VAL_UINT32_T u4EISFrameWidth; ///<: EIS FrameWidth + VAL_UINT32_T u4EISFrameHeight; ///<: EIS FrameHeight + VAL_UINT32_T u4GMV_X; ///<: Golbal Motion Vector (GMV) of the VOP Frame used for EIS + VAL_UINT32_T u4GMV_Y; ///<: Golbal Motion Vector (GMV) of the VOP Frame used for EIS +} VENC_DRV_PARAM_EIS_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_EIS_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_EIS_T + */ +typedef VENC_DRV_PARAM_EIS_T *P_VENC_DRV_PARAM_EIS_T; + + +/** + * @par Structure + * VENC_DRV_STATISTIC_T + * @par Description + * This is statistic information and used as output parameter for\n + * eVEncDrvGetParam()\n + */ +typedef struct __VENC_DRV_STATISTIC_T +{ + VAL_UINT32_T u4EncTimeMax; ///<: Encode one frame time. Max + VAL_UINT32_T u4EncTimeMin; ///<: Encode one frame time. Min + VAL_UINT32_T u4EncTimeAvg; ///<: Encode one frame time. Average + VAL_UINT32_T u4EncTimeSum; ///<: Encode one frame time. Sum +} VENC_DRV_STATISTIC_T; + +/** + * @par Structure + * P_VENC_DRV_STATISTIC_T + * @par Description + * This is the pointer of VENC_DRV_STATISTIC_T + */ +typedef VENC_DRV_STATISTIC_T *P_VENC_DRV_STATISTIC_T; + + +typedef struct __VENC_HYB_ENCSETTING +{ + + // used in SetParameter + VAL_UINT32_T u4Width; + VAL_UINT32_T u4Height; + VAL_UINT32_T u4IntraVOPRate; //u4NumPFrm; + VAL_UINT32_T eFrameRate; + VAL_UINT32_T u4VEncBitrate; + VAL_UINT32_T u4QualityLevel; + VAL_UINT32_T u4ShortHeaderMode; + VAL_UINT32_T u4CodecType; // mepg4, h263, h264... + VAL_UINT32_T u4RotateAngle; + + // used in QueryFunctions + VENC_DRV_COLOR_FORMAT_T eVEncFormat; // YUV420, I420 ..... + VENC_DRV_YUV_STRIDE_T rVCodecYUVStride; + VAL_UINT32_T u4Profile; + VAL_UINT32_T u4Level; + VAL_UINT32_T u4BufWidth; + VAL_UINT32_T u4BufHeight; + VAL_UINT32_T u4NumBFrm; + VAL_UINT32_T fgInterlace; + + // used in Query + VAL_UINT32_T u4InitQ; + VAL_UINT32_T u4MinQ; + VAL_UINT32_T u4MaxQ; + VAL_UINT32_T u4Algorithm; + VAL_UINT32_T u4_Rate_Hard_Limit; + VAL_UINT32_T u4RateBalance; + VAL_UINT32_T u4ForceIntraEnable; + VAL_UINT32_T u4VEncMinBitrate; //Min bit-rate + + // hardware dependent function settings + VAL_BOOL_T fgUseMCI; + VAL_UINT32_T u4VEncThreadNum; +} VENC_HYBRID_ENCSETTING; + + +typedef struct VENC_BS_s +{ + VAL_UINT8_T *u4BS_addr; + VAL_UINT8_T *u4BS_addr_PA; + VAL_UINT32_T u4BSSize; + VAL_UINT32_T u4BS_frmSize; + VAL_UINT32_T u4BS_frmCount; + VAL_UINT32_T u4BS_index; + VAL_UINT32_T u4BS_preindex; + VAL_UINT32_T u4Fillcnt; + VAL_UINT32_T Handle; +} VENC_BS_T; + + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VENC_DRV_IF_PRIVATE_H_ diff --git a/include/linux/vcodec/venc_drv_if_public.h b/include/linux/vcodec/venc_drv_if_public.h new file mode 100644 index 000000000..0ec532e9e --- /dev/null +++ b/include/linux/vcodec/venc_drv_if_public.h @@ -0,0 +1,900 @@ +/** + * @file + * venc_drv_if_public.h + * + * @par Project: + * Video + * + * @par Description: + * Video Encoder Driver Interface for external use + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef _VENC_DRV_IF_PUBLIC_H_ +#define _VENC_DRV_IF_PUBLIC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "val_types_public.h" + + +/** + * @par Enumeration + * VENC_DRV_QUERY_TYPE_T + * @par Description + * This is the item used for query driver + */ +typedef enum __VENC_DRV_QUERY_TYPE_T +{ + VENC_DRV_QUERY_TYPE_NONE, ///< Default value (not used) + VENC_DRV_QUERY_TYPE_VIDEO_FORMAT, ///< Query the driver capability + VENC_DRV_QUERY_TYPE_VIDEO_PROPERTY, ///< Query the video property + VENC_DRV_QUERY_TYPE_VIDEO_PROPERTY_LIST, ///< Query the video property list + VENC_DRV_QUERY_TYPE_PROPERTY, ///< Get the driver property + VENC_DRV_QUERY_TYPE_MCI_SUPPORTED, ///< Query if the codec support MCI + VENC_DRV_QUERY_TYPE_CHIP_NAME, ///< Query chip name + VENC_DRV_QUERY_TYPE_INPUT_BUF_LIMIT, ///< Query input buffer stride and sliceheight + VENC_DRV_QUERY_TYPE_NORMAL_PRIO, ///< Query if recorder scenario adjust to normal priority, for 6571. + VENC_DRV_QUERY_TYPE_VIDEO_CAMCORDER_CAP, ///< Query spec. for MediaProfile + VENC_DRV_QUERY_TYPE_CHIP_VARIANT, ///< Query chip variant + VENC_DRV_QUERY_TYPE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_QUERY_TYPE_T value +} +VENC_DRV_QUERY_TYPE_T; + + +/** + * @par Enumeration + * VENC_DRV_YUV_FORMAT_T + * @par Description + * This is the item used for input YUV buffer format + */ +typedef enum __VENC_DRV_YUV_FORMAT_T +{ + VENC_DRV_YUV_FORMAT_NONE, ///< Default value (not used) + VENC_DRV_YUV_FORMAT_GRAY, ///< GRAY YUV format + VENC_DRV_YUV_FORMAT_422, ///< 422 YUV format + VENC_DRV_YUV_FORMAT_420, ///< 420 YUV format + VENC_DRV_YUV_FORMAT_411, ///< 411 YUV format + VENC_DRV_YUV_FORMAT_YV12, ///< Android YV12 (16/16/16) YUV format + VENC_DRV_YUV_FORMAT_NV12, ///< NV12 YUV format + VENC_DRV_YUV_FORMAT_NV21, ///< NV21 YUV format + VENC_DRV_YUV_FORMAT_BLK16X32, ///< Block 16x32 YUV format + VENC_DRV_YUV_FORMAT_BLK64X32, ///< Block 64x32 YUV format + VENC_DRV_YUV_FORMAT_YV12_1688, ///< YV12 YUV format + VENC_DRV_YUV_FORMAT_MAX = 0xFFFFFFFF ///< Max VENC_DRV_YUV_FORMAT_T value +} VENC_DRV_YUV_FORMAT_T; + + +/** + * @par Enumeration + * VENC_DRV_VIDEO_FORMAT_T + * @par Description + * This is the item used for encode video format + */ +typedef enum __VENC_DRV_VIDEO_FORMAT_T +{ + VENC_DRV_VIDEO_FORMAT_NONE, ///< Default value (not used) + VENC_DRV_VIDEO_FORMAT_MPEG4, ///< MPEG4 video format + VENC_DRV_VIDEO_FORMAT_MPEG4_1080P, ///< MPEG4 video format for 1080p + VENC_DRV_VIDEO_FORMAT_MPEG4_SHORT, ///< MPEG4_SHORT (H.263 baseline profile) video format + VENC_DRV_VIDEO_FORMAT_H263, ///< H.263 video format + VENC_DRV_VIDEO_FORMAT_H264, ///< H.264 video format + VENC_DRV_VIDEO_FORMAT_H264_VGA, ///< H.264 video format for VGA + VENC_DRV_VIDEO_FORMAT_WMV9, ///< WMV9 video format + VENC_DRV_VIDEO_FORMAT_VC1, ///< VC1 video format + VENC_DRV_VIDEO_FORMAT_VP8, ///< VP8 video format + VENC_DRV_VIDEO_FORMAT_JPEG, ///< JPEG picture format + VENC_DRV_VIDEO_FORMAT_HEVC, ///< HEVC video format + VENC_DRV_VIDEO_FORMAT_H264SEC, ///<: Secure H.264 + VENC_DRV_VIDEO_FORMAT_MAX = 0xFFFFFFFF ///< Max VENC_DRV_VIDEO_FORMAT_T value +} VENC_DRV_VIDEO_FORMAT_T; + + +/** + * @par Enumeration + * VENC_DRV_FRAME_RATE_T + * @par Description + * This is the item used for encode frame rate + */ +typedef enum __VENC_DRV_FRAME_RATE_T +{ + VENC_DRV_FRAME_RATE_NONE = 0, ///< Default value (not used) + VENC_DRV_FRAME_RATE_7_5 = 75, ///< 7.5 + VENC_DRV_FRAME_RATE_10 = 10, ///< 10 + VENC_DRV_FRAME_RATE_15 = 15, ///< 15 + VENC_DRV_FRAME_RATE_20 = 20, ///< 20 + VENC_DRV_FRAME_RATE_24 = 24, ///< 24 + VENC_DRV_FRAME_RATE_25 = 25, ///< 25 + VENC_DRV_FRAME_RATE_29_97 = 2997, ///< 29.97 + VENC_DRV_FRAME_RATE_30 = 30, ///< 30 + VENC_DRV_FRAME_RATE_60 = 60, ///< 60 + VENC_DRV_FRAME_RATE_120 = 120, ///< 120 + VENC_DRV_FRAME_RATE_180 = 180, ///< 180 + VENC_DRV_FRAME_RATE_240 = 240, ///< 240 + VENC_DRV_FRAME_RATE_480 = 480, ///< 480 + VENC_DRV_FRAME_RATE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_FRAME_RATE_T value +} VENC_DRV_FRAME_RATE_T; + + +/** + * @par Enumeration + * VENC_DRV_START_OPT_T + * @par Description + * This is the item used for encode frame type + */ +typedef enum __VENC_DRV_START_OPT_T +{ + VENC_DRV_START_OPT_NONE, ///< Default value (not used) + VENC_DRV_START_OPT_ENCODE_SEQUENCE_HEADER, ///< Encode a Sequence header + VENC_DRV_START_OPT_ENCODE_SEQUENCE_HEADER_H264_SPS, ///< Encode a Sequence header H264 SPS + VENC_DRV_START_OPT_ENCODE_SEQUENCE_HEADER_H264_PPS, ///< Encode a Sequence header H264 PPS + VENC_DRV_START_OPT_ENCODE_FRAME, ///< Encode a frame + VENC_DRV_START_OPT_ENCODE_KEY_FRAME, ///< Encode a key frame + VENC_DRV_START_OPT_ENCODE_FINAL, ///< Final encode (Only use to encode final frame) + VENC_DRV_START_OPT_ENCODE_DUMMY_NAL, ///< Encode a dummy NAL for WFD + VENC_DRV_START_OPT_MAX = 0xFFFFFFFF ///< Max VENC_DRV_START_OPT_T value +} VENC_DRV_START_OPT_T; + + +/** + * @par Enumeration + * VENC_DRV_MESSAGE_T + * @par Description + * This is the item used for encode frame status + */ +typedef enum __VENC_DRV_MESSAGE_T +{ + VENC_DRV_MESSAGE_NONE, ///< Default value (not used) + VENC_DRV_MESSAGE_OK, ///< Encode ok + VENC_DRV_MESSAGE_ERR, ///< Encode error + VENC_DRV_MESSAGE_TIMEOUT, ///< Encode timeout + VENC_DRV_MESSAGE_PARTIAL, ///< Encode partial frame (ok means EOF) + VENC_DRV_MESSAGE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_MESSAGE_T value +} VENC_DRV_MESSAGE_T; + + +/** + * @par Enumeration + * VENC_DRV_H264_VIDEO_PROFILE_T + * @par Description + * This is the item used for h.264 encoder profile capability + */ +typedef enum __VENC_DRV_H264_VIDEO_PROFILE_T +{ + VENC_DRV_H264_VIDEO_PROFILE_UNKNOWN = 0, ///< Default value (not used) + VENC_DRV_H264_VIDEO_PROFILE_BASELINE = (1 << 0), ///< Baseline + VENC_DRV_H264_VIDEO_PROFILE_CONSTRAINED_BASELINE = (1 << 1), ///< Constrained Baseline + VENC_DRV_H264_VIDEO_PROFILE_MAIN = (1 << 2), ///< Main + VENC_DRV_H264_VIDEO_PROFILE_EXTENDED = (1 << 3), ///< Extended + VENC_DRV_H264_VIDEO_PROFILE_HIGH = (1 << 4), ///< High + VENC_DRV_H264_VIDEO_PROFILE_HIGH_10 = (1 << 5), ///< High 10 + VENC_DRV_H264_VIDEO_PROFILE_HIGH422 = (1 << 6), ///< High 422 + VENC_DRV_H264_VIDEO_PROFILE_HIGH444 = (1 << 7), ///< High 444 + VENC_DRV_H264_VIDEO_PROFILE_HIGH_10_INTRA = (1 << 8), ///< High 10 Intra (Amendment 2) + VENC_DRV_H264_VIDEO_PROFILE_HIGH422_INTRA = (1 << 9), ///< High 422 Intra (Amendment 2) + VENC_DRV_H264_VIDEO_PROFILE_HIGH444_INTRA = (1 << 10), ///< High 444 Intra (Amendment 2) + VENC_DRV_H264_VIDEO_PROFILE_CAVLC444_INTRA = (1 << 11), ///< CAVLC 444 Intra (Amendment 2) + VENC_DRV_H264_VIDEO_PROFILE_HIGH444_PREDICTIVE = (1 << 12), ///< High 444 Predictive (Amendment 2) + VENC_DRV_H264_VIDEO_PROFILE_SCALABLE_BASELINE = (1 << 13), ///< Scalable Baseline (Amendment 3) + VENC_DRV_H264_VIDEO_PROFILE_SCALABLE_HIGH = (1 << 14), ///< Scalable High (Amendment 3) + VENC_DRV_H264_VIDEO_PROFILE_SCALABLE_HIGH_INTRA = (1 << 15), ///< Scalable High Intra (Amendment 3) + VENC_DRV_H264_VIDEO_PROFILE_MULTIVIEW_HIGH = (1 << 16), ///< Multiview High (Corrigendum 1 (2009)) + VENC_DRV_H264_VIDEO_PROFILE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_H264_VIDEO_PROFILE_T value +} VENC_DRV_H264_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VENC_DRV_HEVC_VIDEO_PROFILE_T + * @par Description + * This is the item used for hevc encoder profile capability + */ +typedef enum __VENC_DRV_HEVC_VIDEO_PROFILE_T +{ + VENC_DRV_HEVC_VIDEO_PROFILE_UNKNOWN = 0, ///< Default value (not used) + VENC_DRV_HEVC_VIDEO_PROFILE_BASELINE = (1 << 0), ///< Baseline + VENC_DRV_HEVC_VIDEO_PROFILE_CONSTRAINED_BASELINE = (1 << 1), ///< Constrained Baseline + VENC_DRV_HEVC_VIDEO_PROFILE_MAIN = (1 << 2), ///< Main + VENC_DRV_HEVC_VIDEO_PROFILE_EXTENDED = (1 << 3), ///< Extended + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH = (1 << 4), ///< High + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH_10 = (1 << 5), ///< High 10 + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH422 = (1 << 6), ///< High 422 + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH444 = (1 << 7), ///< High 444 + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH_10_INTRA = (1 << 8), ///< High 10 Intra (Amendment 2) + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH422_INTRA = (1 << 9), ///< High 422 Intra (Amendment 2) + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH444_INTRA = (1 << 10), ///< High 444 Intra (Amendment 2) + VENC_DRV_HEVC_VIDEO_PROFILE_CAVLC444_INTRA = (1 << 11), ///< CAVLC 444 Intra (Amendment 2) + VENC_DRV_HEVC_VIDEO_PROFILE_HIGH444_PREDICTIVE = (1 << 12), ///< High 444 Predictive (Amendment 2) + VENC_DRV_HEVC_VIDEO_PROFILE_SCALABLE_BASELINE = (1 << 13), ///< Scalable Baseline (Amendment 3) + VENC_DRV_HEVC_VIDEO_PROFILE_SCALABLE_HIGH = (1 << 14), ///< Scalable High (Amendment 3) + VENC_DRV_HEVC_VIDEO_PROFILE_SCALABLE_HIGH_INTRA = (1 << 15), ///< Scalable High Intra (Amendment 3) + VENC_DRV_HEVC_VIDEO_PROFILE_MULTIVIEW_HIGH = (1 << 16), ///< Multiview High (Corrigendum 1 (2009)) + VENC_DRV_HEVC_VIDEO_PROFILE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_HEVC_VIDEO_PROFILE_T value +} VENC_DRV_HEVC_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VENC_DRV_MPEG_VIDEO_PROFILE_T + * @par Description + * This is the item used for h.263, mpeg2, mpeg4 encoder profile capability + */ +typedef enum __VENC_DRV_MPEG_VIDEO_PROFILE_T +{ + VENC_DRV_MPEG_VIDEO_PROFILE_UNKNOWN = 0, ///< Default value (not used) + VENC_DRV_MPEG_VIDEO_PROFILE_H263_0 = (1 << 0), ///< H.263 0 + VENC_DRV_MPEG_VIDEO_PROFILE_H263_1 = (1 << 1), ///< H.263 1 + VENC_DRV_MPEG_VIDEO_PROFILE_H263_2 = (1 << 2), ///< H.263 2 + VENC_DRV_MPEG_VIDEO_PROFILE_H263_3 = (1 << 3), ///< H.263 3 + VENC_DRV_MPEG_VIDEO_PROFILE_H263_4 = (1 << 4), ///< H.263 4 + VENC_DRV_MPEG_VIDEO_PROFILE_H263_5 = (1 << 5), ///< H.263 5 + VENC_DRV_MPEG_VIDEO_PROFILE_H263_6 = (1 << 6), ///< H.263 6 + VENC_DRV_MPEG_VIDEO_PROFILE_H263_7 = (1 << 7), ///< H.263 7 + VENC_DRV_MPEG_VIDEO_PROFILE_H263_8 = (1 << 8), ///< H.263 8 + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SIMPLE = (1 << 9), ///< MPEG2 Simple + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_MAIN = (1 << 10), ///< MPEG2 Main + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SNR = (1 << 11), ///< MPEG2 SNR + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_SPATIAL = (1 << 12), ///< MPEG2 Spatial + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG2_HIGH = (1 << 13), ///< MPEG2 High + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG4_SIMPLE = (1 << 14), ///< MPEG4 Simple + VENC_DRV_MPEG_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE = (1 << 15), ///< MPEG4 Advanced Simple + VENC_DRV_MPEG_VIDEO_PROFILE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_MPEG_VIDEO_PROFILE_T value +} VENC_DRV_MPEG_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VENC_DRV_MS_VIDEO_PROFILE_T + * @par Description + * This is the item used for MS encoder profile capability + */ +typedef enum __VENC_DRV_MS_VIDEO_PROFILE_T +{ + VENC_DRV_MS_VIDEO_PROFILE_UNKNOWN = 0, ///< Default value (not used) + VENC_DRV_MS_VIDEO_PROFILE_VC1_SIMPLE = (1 << 0), ///< VC1 Simple + VENC_DRV_MS_VIDEO_PROFILE_VC1_MAIN = (1 << 1), ///< VC1 Main + VENC_DRV_MS_VIDEO_PROFILE_VC1_ADVANCED = (1 << 2), ///< VC1 Advanced + VENC_DRV_MS_VIDEO_PROFILE_WMV9_SIMPLE = (1 << 3), ///< WMV9 Simple + VENC_DRV_MS_VIDEO_PROFILE_WMV9_MAIN = (1 << 4), ///< WMV9 Main + VENC_DRV_MS_VIDEO_PROFILE_WMV9_COMPLEX = (1 << 5), ///< WMV9 Complex + VENC_DRV_MS_VIDEO_PROFILE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_MS_VIDEO_PROFILE_T value +} VENC_DRV_MS_VIDEO_PROFILE_T; + + +/** + * @par Enumeration + * VENC_DRV_VIDEO_LEVEL_T + * @par Description + * This is the item used for encoder level capability + */ +typedef enum __VENC_DRV_VIDEO_LEVEL_T +{ + VENC_DRV_VIDEO_LEVEL_UNKNOWN = 0, ///< Default value (not used) + VENC_DRV_VIDEO_LEVEL_0, ///< VC1 + VENC_DRV_VIDEO_LEVEL_1, ///< H264, HEVC, VC1, MPEG4 + VENC_DRV_VIDEO_LEVEL_1b, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_1_1, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_1_2, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_1_3, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_2, ///< H264, HEVC, VC1, MPEG4 + VENC_DRV_VIDEO_LEVEL_2_1, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_2_2, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_3, ///< H264, HEVC, VC1, MPEG4 + VENC_DRV_VIDEO_LEVEL_3_1, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_3_2, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_4, ///< H264, HEVC, VC1 + VENC_DRV_VIDEO_LEVEL_4_1, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_4_2, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_5, ///< H264, HEVC, HEVC + VENC_DRV_VIDEO_LEVEL_5_1, ///< H264, HEVC + VENC_DRV_VIDEO_LEVEL_LOW, ///< VC1, MPEG2 + VENC_DRV_VIDEO_LEVEL_MEDIUM, ///< VC1, MPEG2 + VENC_DRV_VIDEO_LEVEL_HIGH1440, ///< MPEG2 + VENC_DRV_VIDEO_LEVEL_HIGH, ///< VC1, MPEG2 + VENC_DRV_VIDEO_LEVEL_6, ///< H263 + VENC_DRV_VIDEO_LEVEL_7, ///< H263 + VENC_DRV_VIDEO_LEVEL_MAX = 0xFFFFFFFF ///< Max VENC_DRV_VIDEO_LEVEL_T value +} VENC_DRV_VIDEO_LEVEL_T; + + +/** + * @par Enumeration + * VENC_DRV_RESOLUTION_T + * @par Description + * This is the item used for encoder resolution capability + */ +typedef enum __VENC_DRV_RESOLUTION_T +{ + VENC_DRV_RESOLUTION_UNKNOWN = 0, ///< Default value (not used) + VENC_DRV_RESOLUTION_SUPPORT_QCIF, ///< CIF + VENC_DRV_RESOLUTION_SUPPORT_QVGA, ///< QVGA + VENC_DRV_RESOLUTION_SUPPORT_CIF, ///< QCIF + VENC_DRV_RESOLUTION_SUPPORT_HVGA, ///< HVGA: 480x320 + VENC_DRV_RESOLUTION_SUPPORT_VGA, ///< VGA: 640x480 + VENC_DRV_RESOLUTION_SUPPORT_480I, ///< 480I + VENC_DRV_RESOLUTION_SUPPORT_480P, ///< 480P + VENC_DRV_RESOLUTION_SUPPORT_576I, ///< 576I + VENC_DRV_RESOLUTION_SUPPORT_576P, ///< 480P + VENC_DRV_RESOLUTION_SUPPORT_FWVGA, ///< FWVGA: 864x480 + VENC_DRV_RESOLUTION_SUPPORT_720I, ///< 720I + VENC_DRV_RESOLUTION_SUPPORT_720P, ///< 720P + VENC_DRV_RESOLUTION_SUPPORT_1080I, ///< 1080I + VENC_DRV_RESOLUTION_SUPPORT_1080P, ///< 1080P + VENC_DRV_RESOLUTION_SUPPORT_2160P, ///< 2160P + VENC_DRV_RESOLUTION_SUPPORT_MAX = 0xFFFFFFFF ///< Max VENC_DRV_RESOLUTION_T value +} VENC_DRV_RESOLUTION_T; + + +/** + * @par Enumeration + * VENC_DRV_SET_TYPE_T + * @par Description + * This is the input parameter for eVEncDrvSetParam() + */ +typedef enum __VENC_DRV_SET_TYPE_T +{ + VENC_DRV_SET_TYPE_UNKONW = 0, ///< Default value (not used) + VENC_DRV_SET_TYPE_RST, ///< Set reset + VENC_DRV_SET_TYPE_CB, ///< Set callback function + VENC_DRV_SET_TYPE_PARAM_RC, ///< Set rate control parameter + VENC_DRV_SET_TYPE_PARAM_ME, ///< Set motion estimation parameter + VENC_DRV_SET_TYPE_PARAM_EIS, ///< Set EIS parameter + VENC_DRV_SET_TYPE_PARAM_ENC, ///< Set encoder parameters such as I-frame period, etc. + VENC_DRV_SET_TYPE_STATISTIC_ON, ///< Enable statistic function + VENC_DRV_SET_TYPE_STATISTIC_OFF, ///< Disable statistic function + VENC_DRV_SET_TYPE_SET_OMX_TIDS, ///< Set OMX thread IDs + VENC_DRV_SET_TYPE_MPEG4_SHORT, ///< Set MPEG4 short header mode + VENC_DRV_SET_TYPE_FORCE_INTRA_ON, ///< Set Force Intra Frame on + VENC_DRV_SET_TYPE_FORCE_INTRA_OFF, ///< Set Force Intra Frame off + VENC_DRV_SET_TYPE_TIME_LAPSE, ///< Set time lapse + VENC_DRV_SET_TYPE_ALLOC_WORK_BUF, ///< Set to alloc working buffer + VENC_DRV_SET_TYPE_DUMP_WORK_BUF, ///< Set to dump working buffer + VENC_DRV_SET_TYPE_FREE_WORK_BUF, ///< Set to free working buffer + VENC_DRV_SET_TYPE_ADJUST_BITRATE, ///< Set to adjust bitrate + VENC_DRV_SET_TYPE_I_FRAME_INTERVAL, ///< Set I Frame interval + VENC_DRV_SET_TYPE_WFD_MODE, ///< Set Wifi-Display Mode + VENC_DRV_SET_TYPE_RECORD_SIZE, ///< Ser record size + VENC_DRV_SET_TYPE_USE_MCI_BUF, ///< Set to use MCI buffer + VENC_DRV_SET_TYPE_ADJUST_FRAMERATE, ///< Set frame rate + VENC_DRV_SET_TYPE_INIT_QP, ///< Set init QP + VENC_DRV_SET_TYPE_SKIP_FRAME, ///< Set skip one frame + VENC_DRV_SET_TYPE_SCENARIO, ///< Set VENC Scenario + VENC_DRV_SET_TYPE_PREPEND_HEADER, ///< Set prepend SPS/PPS before IDR + VENC_DRV_SET_TYPE_SLOW_MOTION_ENCODE, ///< Set to Slow Motion Video Recording for header or frame + VENC_DRV_SET_TYPE_SLOW_MOTION_POST_PROC, ///< Set to Slow Motion Video Recording for encoded bs with post processing + VENC_DRV_SET_TYPE_SLOW_MOTION_LOCK_HW, ///< Set to Slow Motion Video Recording for Lock HW + VENC_DRV_SET_TYPE_SLOW_MOTION_UNLOCK_HW, ///< Set to Slow Motion Video Recording for UnLock HW + VENC_DRV_SET_TYPE_NONREFP, ///< Set Enable/Disable Non reference P frame + VENC_DRV_SET_TYPE_CONFIG_QP, ///< Set init QP + VENC_DRV_SET_TYPE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_SET_TYPE_T value +} VENC_DRV_SET_TYPE_T; + + +/** + * @par Enumeration + * VENC_DRV_GET_TYPE_T + * @par Description + * This is the input parameter for eVEncDrvGetParam() + */ +typedef enum __VENC_DRV_GET_TYPE_T +{ + VENC_DRV_GET_TYPE_UNKONW = 0, ///< Default value (not used) + VENC_DRV_GET_TYPE_PARAM_RC, ///< Get rate control parameter + VENC_DRV_GET_TYPE_PARAM_ME, ///< Get motion estimation parameter + VENC_DRV_GET_TYPE_PARAM_EIS, ///< Get EIS parameter + VENC_DRV_GET_TYPE_PARAM_ENC, ///< Get encoder parameters such as I-frame period, etc. + VENC_DRV_GET_TYPE_STATISTIC, ///< Get statistic. + VENC_DRV_GET_TYPE_GET_CPU_LOADING_INFO, ///< query the cpu loading info from kernel driver + VENC_DRV_GET_TYPE_GET_YUV_FORMAT, ///< Get YUV format + VENC_DRV_GET_TYPE_GET_CODEC_TIDS, + /* for DirectLink Meta Mode + */ + VENC_DRV_GET_TYPE_ALLOC_META_HANDLE_LIST, ///< Alloc a handle to store meta handle list + VENC_DRV_GET_TYPE_GET_BUF_INFO_FROM_META_HANDLE, ///< Get buffer virtual address from meta buffer handle + VENC_DRV_GET_TYPE_FREE_META_HANDLE_LIST, ///< free a handle allocated from VENC_DRV_GET_TYPE_ALLOC_META_HANDLE_LIST + /* for DirectLink Meta Mode - */ + VENC_DRV_GET_TYPE_MAX = 0xFFFFFFFF ///< Max VENC_DRV_GET_TYPE_MAX value +} VENC_DRV_GET_TYPE_T; + + +/** + * @par Enumeration + * VENC_DRV_MRESULT_T + * @par Description + * This is the return value for eVEncDrvXXX() + */ +typedef enum __VENC_DRV_MRESULT_T +{ + VENC_DRV_MRESULT_OK = 0, ///< Return Success + VENC_DRV_MRESULT_FAIL, ///< Return Fail + VENC_DRV_MRESULT_MAX = 0x0FFFFFFF ///< Max VENC_DRV_MRESULT_T value +} VENC_DRV_MRESULT_T; + + +/** + * @par Enumeration + * VENC_DRV_SCENARIO_T + * @par Description + * This is the scenario for VENC scenario + */ +typedef enum __VENC_DRV_SCENARIO_T +{ + VENC_DRV_SCENARIO_CAMERA_REC = 1, ///< Camera recording + VENC_DRV_SCENARIO_LIVEPHOTO_CAPTURE = (1 << 1), ///< LivePhoto recording + VENC_DRV_SCENARIO_LIVEPHOTO_EFFECT = (1 << 2), ///< LivePhoto effect transcoding + VENC_DRV_SCENARIO_CAMERA_REC_SLOW_MOTION = (1 << 3), ///< Camera recording with slow motion + VENC_DRV_SCENARIO_SCREEN_REC = (1 << 4), ///< Screen recording +} VENC_DRV_SCENARIO_T; + + +/** + * @par Structure + * VENC_DRV_QUERY_VIDEO_FORMAT_T + * @par Description + * This is a input parameter for eVEncDrvQueryCapability() + */ +typedef struct __VENC_DRV_QUERY_VIDEO_FORMAT_T +{ + VENC_DRV_VIDEO_FORMAT_T eVideoFormat; ///< [OUT] video format capability + VAL_UINT32_T u4Profile; ///< [OUT] video profile capability (VENC_DRV_H264_VIDEO_PROFILE_T, VENC_DRV_MPEG_VIDEO_PROFILE_T, VENC_DRV_MS_VIDEO_PROFILE_T) + VENC_DRV_VIDEO_LEVEL_T eLevel; ///< [OUT] video level capability + VENC_DRV_RESOLUTION_T eResolution; ///< [OUT] video resolution capability + VAL_UINT32_T u4Width; ///< [OUT] video width capability + VAL_UINT32_T u4Height; ///< [OUT] video height capability + VAL_UINT32_T u4Bitrate; ///< [OUT] video bitrate capability + VAL_UINT32_T u4FrameRate; ///< [OUT] video FrameRate capability, 15, 30,... +} VENC_DRV_QUERY_VIDEO_FORMAT_T; + +/** + * @par Structure + * P_VENC_DRV_QUERY_VIDEO_FORMAT_T + * @par Description + * This is the pointer of VENC_DRV_QUERY_VIDEO_FORMAT_T + */ +typedef VENC_DRV_QUERY_VIDEO_FORMAT_T *P_VENC_DRV_QUERY_VIDEO_FORMAT_T; + + +/** + * @par Structure + * VENC_DRV_QUERY_INPUT_BUF_LIMIT + * @par Description + * This is a input parameter for eVEncDrvQueryCapability() + */ +typedef struct __VENC_DRV_QUERY_INPUT_BUF_LIMIT +{ + VENC_DRV_VIDEO_FORMAT_T eVideoFormat; ///< [IN] video format + VAL_UINT32_T u4Width; ///< [IN] video width + VAL_UINT32_T u4Height; ///< [IN] video height + VAL_UINT32_T u4Stride; ///< [OUT] video stride + VAL_UINT32_T u4SliceHeight; ///< [OUT] video sliceheight + VENC_DRV_SCENARIO_T eScenario; ///< [IN] venc scenario +} VENC_DRV_QUERY_INPUT_BUF_LIMIT; + + +/** + * @par Structure + * VENC_DRV_PARAM_ENC_T + * @par Description + * This is the encoder settings and used as input or output parameter for eVEncDrvSetParam() or eVEncDrvGetParam() + */ +typedef struct __VENC_DRV_PARAM_ENC_T +{ + VENC_DRV_YUV_FORMAT_T eVEncFormat; ///< [IN/OUT] YUV format + VAL_UINT32_T u4Profile; ///< [IN/OUT] Profile + VAL_UINT32_T u4Level; ///< [IN/OUT] Level + VAL_UINT32_T u4Width; ///< [IN/OUT] Image Width + VAL_UINT32_T u4Height; ///< [IN/OUT] Image Height + VAL_UINT32_T u4BufWidth; ///< [IN/OUT] Buffer Width + VAL_UINT32_T u4BufHeight; ///< [IN/OUT] Buffer Heigh + VAL_UINT32_T u4NumPFrm; ///< [IN/OUT] The number of P frame between two I frame. + VAL_UINT32_T u4NumBFrm; ///< [IN/OUT] The number of B frame between two reference frame. + VENC_DRV_FRAME_RATE_T eFrameRate; ///< [IN/OUT] Frame rate + VAL_BOOL_T fgInterlace; ///< [IN/OUT] Interlace coding. + VAL_VOID_T *pvExtraEnc; ///< [IN/OUT] For VENC_DRV_PARAM_ENC_H264_T or ... + VAL_MEMORY_T rExtraEncMem; ///< [IN/OUT] Extra Encoder Memory Info + VAL_BOOL_T fgUseMCI; ///< [IN/OUT] Use MCI + VAL_BOOL_T fgMultiSlice; ///< [IN/OUT] Is multi-slice bitstream ? + VAL_BOOL_T fgMBAFF; +} VENC_DRV_PARAM_ENC_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_ENC_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_ENC_T + */ +typedef VENC_DRV_PARAM_ENC_T *P_VENC_DRV_PARAM_ENC_T; + + +/** + * @par Structure + * VENC_DRV_PARAM_ENC_EXTRA_T + * @par Description + * This is the encoder settings and used as input or output parameter for eVEncDrvSetParam() or eVEncDrvGetParam() + */ +typedef struct __VENC_DRV_PARAM_ENC_EXTRA_T +{ + VAL_UINT32_T u4IntraFrameRate; ///< [IN/OUT] Intra frame rate + VAL_UINT32_T u4BitRate; ///< [IN/OUT] BitRate kbps + VAL_UINT32_T u4FrameRateQ16; ///< [IN/OUT] Frame rate in Q16 format + VAL_UINT32_T u4UseMBAFF; ///< [IN/OUT] Use MBAFF +} VENC_DRV_PARAM_ENC_EXTRA_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_ENC_EXTRA_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_ENC_EXTRA_T + */ +typedef VENC_DRV_PARAM_ENC_EXTRA_T *pVENC_DRV_PARAM_ENC_EXTRA_T; + + +#define VENC_DRV_VDO_PROP_LIST_MAX (64) + +/** + * @par Structure + * VENC_DRV_VIDEO_PROPERTY_T + * @par Description + * This is used to get the "target bitrate" according to "resolution and frame rate" + */ +typedef struct __VENC_DRV_VIDEO_PROPERTY_T +{ + VENC_DRV_VIDEO_FORMAT_T eVideoFormat; + VAL_UINT32_T u4Width; + VAL_UINT32_T u4Height; + VAL_UINT32_T u4FrameRate; + VAL_UINT32_T u4BitRate; // used for query table + VAL_BOOL_T fgPropIsValid; +} VENC_DRV_VIDEO_PROPERTY_T; + +/** + * @par Structure + * P_VENC_DRV_VIDEO_PROPERTY_T + * @par Description + * This is the pointer of VENC_DRV_VIDEO_PROPERTY_T + */ +typedef VENC_DRV_VIDEO_PROPERTY_T *P_VENC_DRV_VIDEO_PROPERTY_T; + + +/** + * @par Structure + * VENC_DRV_TIMESTAMP_T + * @par Description + * This is timestamp information and used as items for VENC_DRV_PARAM_FRM_BUF_T and VENC_DRV_PARAM_BS_BUF_T + */ +typedef struct __VENC_DRV_TIMESTAMP_T +{ + VAL_UINT32_T u4TimeStamp[2]; ///< [IN] Timestamp information +} VENC_DRV_TIMESTAMP_T; + +/** + * @par Structure + * P_VENC_DRV_TIMESTAMP_T + * @par Description + * This is the pointer of VENC_DRV_TIMESTAMP_T + */ +typedef VENC_DRV_TIMESTAMP_T *P_VENC_DRV_TIMESTAMP_T; + + +/** + * @par Structure + * VENC_DRV_EIS_INPUT_T + * @par Description + * This is EIS information and used as items for VENC_DRV_PARAM_FRM_BUF_T + */ +typedef struct __VENC_DRV_EIS_INPUT_T +{ + VAL_UINT32_T u4X; ///< [IN] Start coordination X + VAL_UINT32_T u4Y; ///< [IN] Start coordination Y +} VENC_DRV_EIS_INPUT_T; + +/** + * @par Structure + * P_VENC_DRV_EIS_INPUT_T + * @par Description + * This is the pointer of VENC_DRV_EIS_INPUT_T + */ +typedef VENC_DRV_EIS_INPUT_T *P_VENC_DRV_EIS_INPUT_T; + + +/** + * @par Structure + * VENC_DRV_PARAM_FRM_BUF_T + * @par Description + * This is frame buffer information and used as input parameter for eVEncDrvEncode() + */ +typedef struct __VENC_DRV_PARAM_FRM_BUF_T +{ + VAL_MEM_ADDR_T rFrmBufAddr; ///< [IN] Frame buffer address + VAL_MEM_ADDR_T rCoarseAddr; ///< [IN] Coarse address + VENC_DRV_TIMESTAMP_T rTimeStamp; ///< [IN] Timestamp information + VENC_DRV_EIS_INPUT_T rEISInput; ///< [IN] EIS information + VAL_UINT32_T rSecMemHandle; ///< [IN/OUT] security memory handle for SVP +} VENC_DRV_PARAM_FRM_BUF_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_FRM_BUF_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_FRM_BUF_T + */ +typedef VENC_DRV_PARAM_FRM_BUF_T *P_VENC_DRV_PARAM_FRM_BUF_T; + + +/** + * @par Structure + * VENC_DRV_PARAM_BS_BUF_T + * @par Description + * This is bitstream buffer information and used as input parameter for\n + * eVEncDrvEncode()\n + */ +typedef struct __VENC_DRV_PARAM_BS_BUF_T +{ + VAL_MEM_ADDR_T rBSAddr; ///< [IN] Bitstream buffer address + VAL_ULONG_T u4BSStartVA; ///< [IN] Bitstream fill start address + VAL_ULONG_T u4BSSize; ///< [IN] Bitstream size (filled bitstream in bytes) + VENC_DRV_TIMESTAMP_T rTimeStamp; ///< [IN] Time stamp information + VAL_UINT32_T rSecMemHandle; ///< [IN/OUT] security memory handle for SVP +} VENC_DRV_PARAM_BS_BUF_T; + +/** + * @par Structure + * P_VENC_DRV_PARAM_BS_BUF_T + * @par Description + * This is the pointer of VENC_DRV_PARAM_BS_BUF_T + */ +typedef VENC_DRV_PARAM_BS_BUF_T *P_VENC_DRV_PARAM_BS_BUF_T; + + +/** + * @par Structure + * VENC_DRV_DONE_RESULT_T + * @par Description + * This is callback and return information and used as output parameter for eVEncDrvEncode() + */ +typedef struct __VENC_DRV_DONE_RESULT_T +{ + VENC_DRV_MESSAGE_T eMessage; ///< [OUT] Message, such as success or error code + P_VENC_DRV_PARAM_BS_BUF_T prBSBuf; ///< [OUT] Bitstream information + P_VENC_DRV_PARAM_FRM_BUF_T prFrmBuf; ///< [OUT] Input frame buffer information. if address is null, don't use this buffer, else reuse + VAL_BOOL_T fgIsKeyFrm; ///< [OUT] output is key frame or not + VAL_UINT32_T u4HWEncodeTime; ///< [OUT] HW encode Time +} VENC_DRV_DONE_RESULT_T; + +/** + * @par Structure + * P_VENC_DRV_DONE_RESULT_T + * @par Description + * This is the pointer of VENC_DRV_DONE_RESULT_T + */ +typedef VENC_DRV_DONE_RESULT_T *P_VENC_DRV_DONE_RESULT_T; + + +/** + * @par Structure + * VENC_DRV_PROPERTY_T + * @par Description + * This is property information and used as output parameter for eVEncDrvQueryCapability() + */ +typedef struct __VENC_DRV_PROPERTY_T +{ + VAL_UINT32_T u4BufAlign; ///< [OUT] Buffer alignment requirement + VAL_UINT32_T u4BufUnitSize; ///< [OUT] Buffer unit size is N bytes (e.g., 8, 16, or 64 bytes per unit.) + VAL_UINT32_T u4ExtraBufSize; ///< [OUT] Extra buffer size in initial stage + VAL_BOOL_T fgOutputRingBuf; ///< [OUT] Output is ring buffer + VAL_BOOL_T fgCoarseMESupport; ///< [OUT] Support ME coarse search + VAL_BOOL_T fgEISSupport; ///< [OUT] Support EIS +} VENC_DRV_PROPERTY_T; + +/** + * @par Structure + * P_VENC_DRV_PROPERTY_T + * @par Description + * This is the pointer of VENC_DRV_PROPERTY_T + */ +typedef VENC_DRV_PROPERTY_T *P_VENC_DRV_PROPERTY_T; + +/** + * @par Structure + * SEC_VENC_INIT_CONFIG + * @par Description + * This is the structure for initial Venc TLC + */ +typedef struct sec_venc_init_config { + int width; + int height; + void *pVencHandle; + uint32_t uVencHandleLen; + unsigned char *pRCCode; +} SEC_VENC_INIT_CONFIG; + +/** + * @par Structure + * SEC_VENC_INIT_CONFIG + * @par Description + * This is the structure for setting Venc TLC + */ +typedef struct sec_venc_enc_parameter { + uint32_t bitstreamSecHandle; + uint32_t uBitstreamBufSize; + uint32_t uBitstreamDataLen; + + uint32_t frameSecHandle; + uint32_t uFrameBufSize; + uint32_t uFrameDataLen; +} SEC_VENC_ENC_PARAM; + +/** + * @par Function + * eVEncDrvQueryCapability + * @par Description + * Query the driver capability + * @param + * a_eType [IN/OUT] The VENC_DRV_QUERY_TYPE_T structure + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvQueryCapability( + VENC_DRV_QUERY_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function + * eVEncDrvCreate + * @par Description + * Create the driver handle + * @param + * a_phHandle [OUT] The driver handle + * @param + * a_eVideoFormat [IN] The VENC_DRV_VIDEO_FORMAT_T structure + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvCreate( + VAL_HANDLE_T *a_phHandle, + VENC_DRV_VIDEO_FORMAT_T a_eVideoFormat +); + + +/** + * @par Function + * eVEncDrvRelease + * @par Description + * Release the driver handle + * @param + * a_hHandle [IN] The driver handle + * @param + * a_eVideoFormat [IN] The VENC_DRV_VIDEO_FORMAT_T structure + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvRelease( + VAL_HANDLE_T a_hHandle, + VENC_DRV_VIDEO_FORMAT_T a_eVideoFormat +); + + +/** + * @par Function + * eVEncDrvInit + * @par Description + * Init the driver setting, alloc working memory ... etc. + * @param + * a_hHandle [IN] The driver handle + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvInit( + VAL_HANDLE_T a_hHandle +); + +/** + * @par Function + * eVEncDrvDeInit + * @par Description + * DeInit the driver setting, free working memory ... etc. + * @param + * a_hHandle [IN] The driver handle + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvDeInit( + VAL_HANDLE_T a_hHandle +); + + +/** + * @par Function + * eVEncDrvSetParam + * @par Description + * Set parameter to driver + * @param + * a_hHandle [IN] The driver handle + * @param + * a_eType [IN] The VENC_DRV_SET_TYPE_T structure + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvSetParam( + VAL_HANDLE_T a_hHandle, + VENC_DRV_SET_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function + * eVEncDrvGetParam + * @par Description + * Get parameter from driver + * @param + * a_hHandle [IN] The driver handle + * @param + * a_eType [IN] The VENC_DRV_SET_TYPE_T structure + * @param + * a_pvInParam [IN] The input parameter + * @param + * a_pvOutParam [OUT] The output parameter + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvGetParam( + VAL_HANDLE_T a_hHandle, + VENC_DRV_GET_TYPE_T a_eType, + VAL_VOID_T *a_pvInParam, + VAL_VOID_T *a_pvOutParam +); + + +/** + * @par Function + * eVEncDrvEncode + * @par Description + * Encode frame + * @param + * a_hHandle [IN] The driver handle + * @param + * a_eOpt [IN] The VENC_DRV_START_OPT_T structure + * @param + * a_prFrmBuf [IN] The input frame buffer with VENC_DRV_PARAM_FRM_BUF_T structure + * @param + * a_prBSBuf [IN] The input bitstream buffer with VENC_DRV_PARAM_BS_BUF_T structure + * @param + * a_prResult [OUT] The output result with VENC_DRV_DONE_RESULT_T structure + * @par Returns + * VENC_DRV_MRESULT_T [OUT] VENC_DRV_MRESULT_OK for success, VENC_DRV_MRESULT_FAIL for fail + */ +VENC_DRV_MRESULT_T eVEncDrvEncode( + VAL_HANDLE_T a_hHandle, + VENC_DRV_START_OPT_T a_eOpt, + VENC_DRV_PARAM_FRM_BUF_T *a_prFrmBuf, + VENC_DRV_PARAM_BS_BUF_T *a_prBSBuf, + VENC_DRV_DONE_RESULT_T *a_prResult +); + + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _VENC_DRV_IF_PUBLIC_H_ diff --git a/include/linux/vcodec/video_custom_sp.h b/include/linux/vcodec/video_custom_sp.h new file mode 100644 index 000000000..7be05e1c0 --- /dev/null +++ b/include/linux/vcodec/video_custom_sp.h @@ -0,0 +1,142 @@ +/** + * @file + * video_custom_sp.h + * + * @par Project: + * Video + * + * @par Description: + * Video Codec Driver & Codec Liabrary Interface + * + * @par Author: + * Jackal Chen (mtk02532) + * + * @par $Revision: #1 $ + * @par $Modtime:$ + * @par $Log:$ + * + */ + +#ifndef VIDEO_CUSTOM_SP_H +#define VIDEO_CUSTOM_SP_H + +//#include "video_codec_if_sp.h" +#include "vcodec_if_v2.h" + +#define ASSERT(expr) \ + do { \ + if (!(expr)) \ + AssertionFailed(__FUNCTION__,__FILE__, __LINE__); \ + } while (0) ///< ASSERT definition + +/****************************************************************************** + * + * + * decode + * + * +******************************************************************************/ + + +/** + * @par Enumeration + * VIDEO_DECODER_T + * @par Description + * This is the item for video decoder format + */ +typedef enum _VIDEO_DECODER_T +{ + CODEC_DEC_NONE = 0, ///< NONE + CODEC_DEC_H263 = (0x1 << 0), ///< H263 + CODEC_DEC_MPEG4 = (0x1 << 1), ///< MPEG4 + CODEC_DEC_H264 = (0x1 << 2), ///< H264 + CODEC_DEC_RV = (0x1 << 3), ///< RV + CODEC_DEC_VC1 = (0x1 << 4), ///< VC1 + CODEC_DEC_VP8 = (0x1 << 5), ///< VP8 + CODEC_DEC_VP9 = (0x1 << 6), ///< VP9 + CODEC_DEC_HEVC = (0x1 << 7), ///< HEVC + CODEC_DEC_MPEG2 = (0x1 << 8), ///< MPEG2 + CODEC_DEC_MAX = (0x1 << 9) ///< MAX +} VIDEO_DECODER_T; + +#if 1 //defined(MT6572) //VCODEC_MULTI_THREAD + + +/** + * @par Function + * GetDecoderAPI + * @par Description + * The function used to get decoder API for codec library + * @param + * eDecType [IN] decoder type + * @param + * hWrapper [IN] wrapper + * @param + * ppDrvModule [IN/OUT] driver module + * @param + * bUseMultiCoreCodec [IN] multi core codec flag + * @par Returns + * VIDEO_DEC_API_T, the decoder API + */ +VIDEO_DEC_API_T *GetDecoderAPI(VIDEO_DECODER_T eDecType, HANDLE hWrapper, void **ppDrvModule, unsigned int bUseMultiCoreCodec); +#else +VIDEO_DEC_API_T *GetDecoderAPI(VIDEO_DECODER_T, HANDLE); // HANDLE : wrapper's handle +#endif +//VCODEC_DEC_API_T *GetMPEG4DecoderAPI(void); +//VCODEC_DEC_API_T *GetH264DecoderAPI(void); +//VCODEC_DEC_API_T *GetRVDecoderAPI(void); +//VCODEC_DEC_API_T *GetVP8DecoderAPI(void); +//VCODEC_DEC_API_T *GetVC1DecoderAPI(void); + + +/****************************************************************************** +* +* +* encode +* +* +******************************************************************************/ + + +/** + * @par Enumeration + * VIDEO_ENCODER_T + * @par Description + * This is the item for video decoder format + */ +typedef enum _VIDEO_ENCODER_T +{ + CODEC_ENC_NONE = 0, ///< NONE + CODEC_ENC_H263 = (0x1 << 0), ///< H263 + CODEC_ENC_MPEG4 = (0x1 << 1), ///< MPEG4 + CODEC_ENC_H264 = (0x1 << 2), ///< H264 + CODEC_ENC_HEVC = (0x1 << 3), ///< HEVC + CODEC_ENC_VP8 = (0x1 << 5), ///< VP8 + CODEC_ENC_VP9 = (0x1 << 6), ///< VP9 + CODEC_ENC_MAX = (0x1 << 7) ///< MAX +} VIDEO_ENCODER_T; + + +/** + * @par Function + * GetEncoderAPI + * @par Description + * The function used to get encoder API for codec library + * @param + * eEncType [IN] encoder type + * @param + * hWrapper [IN] wrapper + * @param + * ppDrvModule [IN/OUT] driver module + * @param + * bUseMultiCoreCodec [IN] multi core codec flag + * @par Returns + * VIDEO_DEC_API_T, the encoder API + */ +VIDEO_ENC_API_T *GetEncoderAPI(VIDEO_ENCODER_T eEncType, HANDLE hWrapper, void **ppDrvModule, unsigned int bUseMultiCoreCodec); +//VCODEC_ENC_API_T *GetMPEG4EncoderAPI(void); +//VCODEC_ENC_API_T* GetH264EncoderAPI(void); +//VIDEO_ENCODER_API_T *GetVP8EncoderAPI(void); + + +#endif /* VIDEO_CUSTOM_SP_H */ -- cgit v1.2.3