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 } EXYNOS_OMX_EXCEPTION_STATE; 131 132 typedef enum _EXYNOS_OMX_PLANE 133 { 134 ONE_PLANE = 0x01, 135 TWO_PLANE = 0x02, 136 THREE_PLANE = 0x03, 137 /* 138 ANB_START_PLANE = 0x10, 139 ANB_ONE_PLANE = 0x11, 140 ANB_TWO_PLANE = 0x12, 141 ANB_THREE_PLANE = 0x13, 142 */ 143 } EXYNOS_OMX_PLANE; 144 145 typedef struct _EXYNOS_OMX_BASEPORT 146 { 147 EXYNOS_OMX_BUFFERHEADERTYPE *extendBufferHeader; 148 OMX_U32 *bufferStateAllocate; 149 OMX_PARAM_PORTDEFINITIONTYPE portDefinition; 150 OMX_HANDLETYPE bufferSemID; 151 EXYNOS_QUEUE bufferQ; 152 OMX_U32 assignedBufferNum; 153 OMX_STATETYPE portState; 154 OMX_HANDLETYPE loadedResource; 155 OMX_HANDLETYPE unloadedResource; 156 157 OMX_BOOL bIsPortFlushed; 158 OMX_BOOL bIsPortDisabled; 159 OMX_MARKTYPE markType; 160 161 OMX_CONFIG_RECTTYPE cropRectangle; 162 163 /* Tunnel Info */ 164 OMX_HANDLETYPE tunneledComponent; 165 OMX_U32 tunneledPort; 166 OMX_U32 tunnelBufferNum; 167 OMX_BUFFERSUPPLIERTYPE bufferSupplier; 168 OMX_U32 tunnelFlags; 169 170 OMX_BOOL bIsANBEnabled; 171 OMX_BOOL bStoreMetaData; 172 173 EXYNOS_OMX_BUFFERPROCESS_TYPE bufferProcessType; 174 EXYNOS_OMX_PORT_WAY_TYPE portWayType; 175 OMX_HANDLETYPE codecSemID; 176 EXYNOS_QUEUE codecBufferQ; 177 178 OMX_HANDLETYPE pauseEvent; 179 180 /* Buffer */ 181 union { 182 EXYNOS_OMX_PORT_1WAY_DATABUFFER port1WayDataBuffer; 183 EXYNOS_OMX_PORT_2WAY_DATABUFFER port2WayDataBuffer; 184 } way; 185 186 /* Data */ 187 EXYNOS_OMX_DATA processData; 188 189 /* for flush of Shared buffer scheme */ 190 OMX_HANDLETYPE hAllCodecBufferReturnEvent; 191 OMX_HANDLETYPE hPortMutex; 192 EXYNOS_OMX_EXCEPTION_STATE exceptionFlag; 193 } EXYNOS_OMX_BASEPORT; 194 195 196 #ifdef __cplusplus 197 extern "C" { 198 #endif 199 200 OMX_ERRORTYPE Exynos_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); 201 OMX_ERRORTYPE Exynos_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); 202 OMX_ERRORTYPE Exynos_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent); 203 OMX_ERRORTYPE Exynos_OMX_Port_Constructor(OMX_HANDLETYPE hComponent); 204 OMX_ERRORTYPE Exynos_OMX_Port_Destructor(OMX_HANDLETYPE hComponent); 205 OMX_ERRORTYPE Exynos_ResetDataBuffer(EXYNOS_OMX_DATABUFFER *pDataBuffer); 206 OMX_ERRORTYPE Exynos_ResetCodecData(EXYNOS_OMX_DATA *pData); 207 OMX_ERRORTYPE Exynos_Shared_BufferToData(EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_DATA *pData, EXYNOS_OMX_PLANE nPlane); 208 OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer); 209 210 #ifdef __cplusplus 211 }; 212 #endif 213 214 215 #endif 216