1 /* 2 * 3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* 19 * @file Exynos_OMX_Baseport.h 20 * @brief 21 * @author SeungBeom Kim (sbcrux.kim (at) samsung.com) 22 * HyeYeon Chung (hyeon.chung (at) samsung.com) 23 * @version 2.0.0 24 * @history 25 * 2012.02.20 : Create 26 */ 27 28 #ifndef EXYNOS_OMX_BASE_PORT 29 #define EXYNOS_OMX_BASE_PORT 30 31 32 #include "OMX_Component.h" 33 #include "Exynos_OMX_Def.h" 34 #include "Exynos_OSAL_Queue.h" 35 #include "Exynos_OMX_Def.h" 36 37 38 #define BUFFER_STATE_ALLOCATED (1 << 0) 39 #define BUFFER_STATE_ASSIGNED (1 << 1) 40 #define HEADER_STATE_ALLOCATED (1 << 2) 41 #define BUFFER_STATE_FREE 0 42 43 #define MAX_BUFFER_NUM 40 44 45 #define INPUT_PORT_INDEX 0 46 #define OUTPUT_PORT_INDEX 1 47 #define ALL_PORT_INDEX -1 48 #define ALL_PORT_NUM 2 49 50 51 typedef struct _EXYNOS_OMX_BUFFERHEADERTYPE 52 { 53 OMX_BUFFERHEADERTYPE *OMXBufferHeader; 54 OMX_BOOL bBufferInOMX; 55 OMX_HANDLETYPE ANBHandle; 56 void *pYUVBuf[MAX_BUFFER_PLANE]; 57 int buf_fd[MAX_BUFFER_PLANE]; 58 } EXYNOS_OMX_BUFFERHEADERTYPE; 59 60 typedef struct _EXYNOS_OMX_DATABUFFER 61 { 62 OMX_HANDLETYPE bufferMutex; 63 OMX_BUFFERHEADERTYPE* bufferHeader; 64 OMX_BOOL dataValid; 65 OMX_U32 allocSize; 66 OMX_U32 dataLen; 67 OMX_U32 usedDataLen; 68 OMX_U32 remainDataLen; 69 OMX_U32 nFlags; 70 OMX_TICKS timeStamp; 71 OMX_PTR pPrivate; 72 } EXYNOS_OMX_DATABUFFER; 73 74 typedef void* CODEC_EXTRA_BUFFERINFO; 75 76 typedef struct _EXYNOS_OMX_SINGLEPLANE_DATA 77 { 78 OMX_PTR dataBuffer; 79 int fd; 80 } EXYNOS_OMX_SINGLEPLANE_DATA; 81 82 typedef struct _EXYNOS_OMX_MULTIPLANE_DATA 83 { 84 OMX_U32 validPlaneNum; 85 OMX_PTR dataBuffer[MAX_BUFFER_PLANE]; 86 int fd[MAX_BUFFER_PLANE]; 87 } EXYNOS_OMX_MULTIPLANE_DATA; 88 89 typedef struct _EXYNOS_OMX_DATA 90 { 91 union { 92 EXYNOS_OMX_SINGLEPLANE_DATA singlePlaneBuffer; 93 EXYNOS_OMX_MULTIPLANE_DATA multiPlaneBuffer; 94 } buffer; 95 OMX_U32 allocSize; 96 OMX_U32 dataLen; 97 OMX_U32 usedDataLen; 98 OMX_U32 remainDataLen; 99 OMX_U32 nFlags; 100 OMX_TICKS timeStamp; 101 OMX_PTR pPrivate; 102 CODEC_EXTRA_BUFFERINFO extInfo; 103 104 /* For Share Buffer */ 105 OMX_BUFFERHEADERTYPE* bufferHeader; 106 } EXYNOS_OMX_DATA; 107 108 typedef struct _EXYNOS_OMX_WAY1_PORT_DATABUFFER 109 { 110 EXYNOS_OMX_DATABUFFER dataBuffer; 111 } EXYNOS_OMX_PORT_1WAY_DATABUFFER; 112 113 typedef struct _EXYNOS_OMX_WAY2_PORT_DATABUFFER 114 { 115 EXYNOS_OMX_DATABUFFER inputDataBuffer; 116 EXYNOS_OMX_DATABUFFER outputDataBuffer; 117 } EXYNOS_OMX_PORT_2WAY_DATABUFFER; 118 119 typedef enum _EXYNOS_OMX_PORT_WAY_TYPE 120 { 121 WAY1_PORT = 0x00, 122 WAY2_PORT 123 } EXYNOS_OMX_PORT_WAY_TYPE; 124 125 typedef enum _EXYNOS_OMX_EXCEPTION_STATE 126 { 127 GENERAL_STATE = 0x00, 128 NEED_PORT_FLUSH, 129 NEED_PORT_DISABLE, 130 INVALID_STATE, 131 } EXYNOS_OMX_EXCEPTION_STATE; 132 133 typedef enum _EXYNOS_OMX_PLANE 134 { 135 ONE_PLANE = 0x01, 136 TWO_PLANE = 0x02, 137 THREE_PLANE = 0x03, 138 /* 139 ANB_START_PLANE = 0x10, 140 ANB_ONE_PLANE = 0x11, 141 ANB_TWO_PLANE = 0x12, 142 ANB_THREE_PLANE = 0x13, 143 */ 144 } EXYNOS_OMX_PLANE; 145 146 typedef struct _EXYNOS_OMX_BASEPORT 147 { 148 EXYNOS_OMX_BUFFERHEADERTYPE *extendBufferHeader; 149 OMX_U32 *bufferStateAllocate; 150 OMX_PARAM_PORTDEFINITIONTYPE portDefinition; 151 OMX_HANDLETYPE bufferSemID; 152 EXYNOS_QUEUE bufferQ; 153 OMX_U32 assignedBufferNum; 154 OMX_STATETYPE portState; 155 OMX_HANDLETYPE loadedResource; 156 OMX_HANDLETYPE unloadedResource; 157 158 OMX_BOOL bIsPortFlushed; 159 OMX_BOOL bIsPortDisabled; 160 OMX_MARKTYPE markType; 161 162 OMX_CONFIG_RECTTYPE cropRectangle; 163 164 /* Tunnel Info */ 165 OMX_HANDLETYPE tunneledComponent; 166 OMX_U32 tunneledPort; 167 OMX_U32 tunnelBufferNum; 168 OMX_BUFFERSUPPLIERTYPE bufferSupplier; 169 OMX_U32 tunnelFlags; 170 171 OMX_BOOL bIsANBEnabled; 172 OMX_BOOL bStoreMetaData; 173 174 EXYNOS_OMX_BUFFERPROCESS_TYPE bufferProcessType; 175 EXYNOS_OMX_PORT_WAY_TYPE portWayType; 176 OMX_HANDLETYPE codecSemID; 177 EXYNOS_QUEUE codecBufferQ; 178 179 OMX_HANDLETYPE pauseEvent; 180 181 /* Buffer */ 182 union { 183 EXYNOS_OMX_PORT_1WAY_DATABUFFER port1WayDataBuffer; 184 EXYNOS_OMX_PORT_2WAY_DATABUFFER port2WayDataBuffer; 185 } way; 186 187 /* Data */ 188 EXYNOS_OMX_DATA processData; 189 190 /* for flush of Shared buffer scheme */ 191 OMX_HANDLETYPE hAllCodecBufferReturnEvent; 192 OMX_HANDLETYPE hPortMutex; 193 EXYNOS_OMX_EXCEPTION_STATE exceptionFlag; 194 195 OMX_PARAM_PORTDEFINITIONTYPE newPortDefinition; 196 OMX_CONFIG_RECTTYPE newCropRectangle; 197 } EXYNOS_OMX_BASEPORT; 198 199 200 #ifdef __cplusplus 201 extern "C" { 202 #endif 203 204 OMX_ERRORTYPE Exynos_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); 205 OMX_ERRORTYPE Exynos_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); 206 OMX_ERRORTYPE Exynos_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent); 207 OMX_ERRORTYPE Exynos_OMX_Port_Constructor(OMX_HANDLETYPE hComponent); 208 OMX_ERRORTYPE Exynos_OMX_Port_Destructor(OMX_HANDLETYPE hComponent); 209 OMX_ERRORTYPE Exynos_ResetDataBuffer(EXYNOS_OMX_DATABUFFER *pDataBuffer); 210 OMX_ERRORTYPE Exynos_ResetCodecData(EXYNOS_OMX_DATA *pData); 211 OMX_ERRORTYPE Exynos_Shared_BufferToData(EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_DATA *pData, EXYNOS_OMX_PLANE nPlane); 212 OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer); 213 214 #ifdef __cplusplus 215 }; 216 #endif 217 218 219 #endif 220