Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright (C) Texas Instruments - http://www.ti.com/ |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | /* ==================================================================== |
| 22 | * Texas Instruments OMAP(TM) Platform Software |
| 23 | * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. |
| 24 | * |
| 25 | * Use of this software is controlled by the terms and conditions found |
| 26 | * in the license agreement under which this software has been supplied. |
| 27 | * ==================================================================== */ |
| 28 | /** |
| 29 | * @file LCML_DspCodec.c |
| 30 | * |
| 31 | * This file implements LCML for Linux 8.x |
| 32 | * |
| 33 | * @path $(CSLPATH)\ |
| 34 | * |
| 35 | * @rev 1.0 |
| 36 | */ |
| 37 | /* ---------------------------------------------------------------------------- |
| 38 | *! |
| 39 | *! Revision History |
| 40 | *! =================================== |
| 41 | *! |
| 42 | *! |
| 43 | * ============================================================================= */ |
| 44 | |
| 45 | #ifdef UNDER_CE |
| 46 | #include <windows.h> |
| 47 | #else |
| 48 | #include <errno.h> |
| 49 | #endif |
| 50 | |
Andreas Huber | 5807caa | 2010-03-12 14:20:45 -0800 | [diff] [blame] | 51 | #ifdef ANDROID |
Elliott Hughes | 0546008 | 2014-07-18 18:03:06 -0700 | [diff] [blame] | 52 | #include <sys/prctl.h> |
Andreas Huber | 5807caa | 2010-03-12 14:20:45 -0800 | [diff] [blame] | 53 | #endif |
| 54 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 55 | #include <pthread.h> |
| 56 | |
| 57 | /* Common WinCE and Linux Headers */ |
| 58 | #include "LCML_DspCodec.h" |
| 59 | #include <stdlib.h> |
| 60 | #include <stdio.h> |
| 61 | #include <string.h> |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 62 | #include "usn.h" |
| 63 | #include <sys/time.h> |
| 64 | |
| 65 | #define CEXEC_DONE 1 |
| 66 | /*DSP_HNODE hDasfNode;*/ |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 67 | #define ABS_DLL_NAME_LENGTH 128 |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 68 | #undef LOG_TAG |
| 69 | #define LOG_TAG "TI_LCML" |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 70 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 71 | #define LCML_MALLOC(p,s,t) \ |
| 72 | p = (t*)malloc(s); \ |
| 73 | if (NULL == p){ \ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 74 | OMXDBG_PRINT(stderr, ERROR, 4, OMX_DBG_BASEMASK, "LCML:::::::: ERROR(#%d F:%s)!!! Ran out of memory while trying to allocate %d bytes!!!\n",__LINE__,__FUNCTION__,s); \ |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 75 | }else { \ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 76 | OMXDBG_PRINT(stderr, PRINT, 2, OMX_DBG_BASEMASK, "LCML:::::::: (#%d F:%s)Success to allocate %d bytes ... pointer %p\n",__LINE__,__FUNCTION__,s,p); \ |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | #define LCML_FREE(p) \ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 80 | OMXDBG_PRINT(stderr, PRINT, 2, OMX_DBG_BASEMASK, "LCML:::::::: (#%d F:%s)Freeing pointer %p done",__LINE__,__FUNCTION__,p); \ |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 81 | free(p); |
| 82 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 83 | /*Prototyping*/ |
| 84 | static OMX_ERRORTYPE InitMMCodec(OMX_HANDLETYPE hInt, |
| 85 | OMX_STRING codecName, |
| 86 | void *toCodecInitParams, |
| 87 | void *fromCodecInfoStruct, |
| 88 | LCML_CALLBACKTYPE *pCallbacks); |
| 89 | static OMX_ERRORTYPE InitMMCodecEx(OMX_HANDLETYPE hInt, |
| 90 | OMX_STRING codecName, |
| 91 | void *toCodecInitParams, |
| 92 | void *fromCodecInfoStruct, |
| 93 | LCML_CALLBACKTYPE *pCallbacks, |
| 94 | OMX_STRING Args); |
| 95 | static OMX_ERRORTYPE WaitForEvent(OMX_HANDLETYPE hComponent, |
| 96 | TUsnCodecEvent event, |
| 97 | void *args[10]); |
| 98 | static OMX_ERRORTYPE QueueBuffer(OMX_HANDLETYPE hComponent, |
| 99 | TMMCodecBufferType bufType, |
| 100 | OMX_U8 *buffer, |
| 101 | OMX_S32 bufferLen, |
| 102 | OMX_S32 bufferSizeUsed , |
| 103 | OMX_U8 *auxInfo, |
| 104 | OMX_S32 auxInfoLen, |
| 105 | OMX_U8 *usrArg); |
| 106 | static OMX_ERRORTYPE ControlCodec(OMX_HANDLETYPE hComponent, |
| 107 | TControlCmd iCodecCmd, |
| 108 | void *args[10]); |
| 109 | static OMX_ERRORTYPE DmmMap(DSP_HPROCESSOR ProcHandle, |
| 110 | OMX_U32 size, |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 111 | void* pArmPtr, |
Rebecca Schultz Zavin | b44cdb1 | 2009-07-29 17:23:50 -0700 | [diff] [blame] | 112 | DMM_BUFFER_OBJ* pDmmBuf, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 113 | struct OMX_TI_Debug dbg); |
| 114 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 115 | static OMX_ERRORTYPE DmmUnMap(DSP_HPROCESSOR ProcHandle, |
| 116 | void *pMapPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 117 | void *pResPtr, |
| 118 | struct OMX_TI_Debug dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 119 | static OMX_ERRORTYPE DeleteDspResource(LCML_DSP_INTERFACE *hInterface); |
| 120 | static OMX_ERRORTYPE FreeResources(LCML_DSP_INTERFACE *hInterface); |
| 121 | |
| 122 | void* MessagingThread(void *arg); |
| 123 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 124 | static int append_dsp_path(char * dll64p_name, char *absDLLname); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 125 | |
| 126 | |
| 127 | /** ======================================================================== |
| 128 | * GetHandle function is called by OMX component to get LCML handle |
| 129 | * @param hInterface - Handle of the component to be accessed |
| 130 | * @return OMX_ERRORTYPE |
| 131 | * If the command successfully executes, the return code will be |
| 132 | * OMX_NoError. Otherwise the appropriate OMX error will be returned. |
| 133 | ** =========================================================================*/ |
| 134 | OMX_ERRORTYPE GetHandle(OMX_HANDLETYPE *hInterface ) |
| 135 | { |
| 136 | OMX_ERRORTYPE err = 0 ; |
| 137 | LCML_DSP_INTERFACE* pHandle; |
| 138 | struct LCML_CODEC_INTERFACE *dspcodecinterface ; |
| 139 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 140 | OMXDBG_PRINT(stderr, PRINT, 2, OMX_DBG_BASEMASK, "%d :: GetHandle application\n",__LINE__); |
| 141 | LCML_MALLOC(*hInterface,sizeof(LCML_DSP_INTERFACE),LCML_DSP_INTERFACE); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 142 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 143 | if (hInterface == NULL) |
| 144 | { |
| 145 | err = OMX_ErrorInsufficientResources; |
| 146 | goto EXIT; |
| 147 | } |
| 148 | memset(*hInterface, 0, sizeof(LCML_DSP_INTERFACE)); |
| 149 | |
| 150 | pHandle = (LCML_DSP_INTERFACE*)*hInterface; |
| 151 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 152 | LCML_MALLOC(dspcodecinterface,sizeof(LCML_CODEC_INTERFACE),LCML_CODEC_INTERFACE); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 153 | if (dspcodecinterface == NULL) |
| 154 | { |
| 155 | err = OMX_ErrorInsufficientResources; |
| 156 | goto EXIT; |
| 157 | } |
| 158 | memset(dspcodecinterface, 0, sizeof(LCML_CODEC_INTERFACE)); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 159 | OMX_DBG_INIT (dspcodecinterface->dbg, "TI_LCML"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 160 | |
| 161 | pHandle->pCodecinterfacehandle = dspcodecinterface; |
| 162 | dspcodecinterface->InitMMCodec = InitMMCodec; |
| 163 | dspcodecinterface->InitMMCodecEx = InitMMCodecEx; |
| 164 | dspcodecinterface->WaitForEvent = WaitForEvent; |
| 165 | dspcodecinterface->QueueBuffer = QueueBuffer; |
| 166 | dspcodecinterface->ControlCodec = ControlCodec; |
| 167 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 168 | LCML_MALLOC(pHandle->dspCodec,sizeof(LCML_DSP),LCML_DSP); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 169 | if(pHandle->dspCodec == NULL) |
| 170 | { |
| 171 | err = OMX_ErrorInsufficientResources; |
| 172 | goto EXIT; |
| 173 | } |
| 174 | memset(pHandle->dspCodec, 0, sizeof(LCML_DSP)); |
| 175 | |
| 176 | pthread_mutex_init (&pHandle->mutex, NULL); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 177 | dspcodecinterface->pCodec = *hInterface; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 178 | OMX_PRINT2 (dspcodecinterface->dbg, "GetHandle application handle %p dspCodec %p",pHandle, pHandle->dspCodec); |
| 179 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 180 | EXIT: |
| 181 | return (err); |
| 182 | } |
| 183 | |
| 184 | |
| 185 | |
| 186 | /** ======================================================================== |
| 187 | * InitMMCodecEx initialise the OMX Component specific handle to LCML. |
| 188 | * The memory is allocated and the dsp node is created. Add notification object |
| 189 | * to listener thread. |
| 190 | * |
| 191 | * @param hInterface - Handle to LCML which is allocated and filled |
| 192 | * @param codecName - not used |
| 193 | * @param toCodecInitParams - not used yet |
| 194 | * @param fromCodecInfoStruct - not used yet |
| 195 | * @param pCallbacks - List of callback that uses to call OMX |
| 196 | * @param Args - additional arguments |
| 197 | * @return OMX_ERRORTYPE |
| 198 | * If the command successfully executes, the return code will be |
| 199 | * OMX_NoError. Otherwise the appropriate OMX error will be returned. |
| 200 | * ==========================================================================*/ |
| 201 | static OMX_ERRORTYPE InitMMCodecEx(OMX_HANDLETYPE hInt, |
| 202 | OMX_STRING codecName, |
| 203 | void * toCodecInitParams, |
| 204 | void * fromCodecInfoStruct, |
| 205 | LCML_CALLBACKTYPE *pCallbacks, |
| 206 | OMX_STRING Args) |
| 207 | |
| 208 | { |
| 209 | |
| 210 | OMX_ERRORTYPE eError = OMX_ErrorNone; |
| 211 | OMX_U32 dllinfo; |
| 212 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 213 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: InitMMCodecEx application\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 214 | |
James Dong | c22b4b5 | 2009-09-28 13:27:45 -0700 | [diff] [blame] | 215 | if (hInt == NULL ) |
| 216 | { |
| 217 | eError = OMX_ErrorInsufficientResources; |
| 218 | goto ERROR; |
| 219 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 220 | if(Args ==NULL) |
| 221 | { |
| 222 | InitMMCodec(hInt, codecName, toCodecInitParams, fromCodecInfoStruct, pCallbacks); |
| 223 | } |
| 224 | else |
| 225 | { |
| 226 | LCML_DSP_INTERFACE * phandle; |
| 227 | LCML_CREATEPHASEARGS crData; |
| 228 | DSP_STATUS status; |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 229 | int i = 0, k = 0; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 230 | struct DSP_NODEATTRIN NodeAttrIn; |
| 231 | struct DSP_CBDATA *pArgs; |
| 232 | BYTE argsBuf[32 + sizeof(ULONG)]; |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 233 | char abs_dsp_path[ABS_DLL_NAME_LENGTH]; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 234 | #ifndef CEXEC_DONE |
| 235 | UINT argc = 1; |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 236 | char argv[ABS_DLL_NAME_LENGTH]; |
| 237 | k = append_dsp_path(DSP_DOF_IMAGE, argv); |
| 238 | if (k < 0) |
| 239 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 240 | OMX_PRDSP4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: append_dsp_path returned an error!\n", __LINE__); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 241 | eError = OMX_ErrorBadParameter; |
| 242 | goto ERROR; |
| 243 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 244 | #endif |
| 245 | int tmperr; |
| 246 | |
| 247 | phandle = (LCML_DSP_INTERFACE *)(((LCML_CODEC_INTERFACE *)hInt)->pCodec); |
| 248 | |
| 249 | #ifdef __PERF_INSTRUMENTATION__ |
| 250 | phandle->pPERF = PERF_Create(PERF_FOURCC('C','M','L',' '), |
| 251 | PERF_ModuleAudioDecode | PERF_ModuleAudioEncode | |
| 252 | PERF_ModuleVideoDecode | PERF_ModuleVideoEncode | |
| 253 | PERF_ModuleImageDecode | PERF_ModuleImageEncode | |
| 254 | PERF_ModuleCommonLayer); |
| 255 | PERF_Boundary(phandle->pPERF, |
| 256 | PERF_BoundaryStart | PERF_BoundarySetup); |
| 257 | #endif |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 258 | /* 720p implementation */ |
| 259 | { |
| 260 | pthread_mutex_init(&phandle->m_isStopped_mutex, NULL); |
| 261 | phandle->mapped_buffer_count = 0; |
| 262 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 263 | /* INIT DSP RESOURCE */ |
| 264 | if(pCallbacks) |
| 265 | phandle->dspCodec->Callbacks.LCML_Callback = pCallbacks->LCML_Callback; |
| 266 | else |
| 267 | { |
| 268 | eError = OMX_ErrorBadParameter; |
| 269 | goto ERROR; |
| 270 | } |
| 271 | |
| 272 | /* INITIALIZATION OF DSP */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 273 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Entering Init_DSPSubSystem\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 274 | status = DspManager_Open(0, NULL); |
| 275 | DSP_ERROR_EXIT(status, "DSP Manager Open", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 276 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "DspManager_Open Successful\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 277 | |
| 278 | /* Attach and get handle to processor */ |
| 279 | status = DSPProcessor_Attach(TI_PROCESSOR_DSP, NULL, &(phandle->dspCodec->hProc)); |
| 280 | DSP_ERROR_EXIT(status, "Attach processor", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 281 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "DSPProcessor_Attach Successful\n"); |
| 282 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "Base Image is Already Loaded\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 283 | |
| 284 | for (dllinfo=0; dllinfo < phandle->dspCodec->NodeInfo.nNumOfDLLs; dllinfo++) |
| 285 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 286 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Register Component Node\n",phandle->dspCodec->NodeInfo.AllUUIDs[dllinfo].eDllType); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 287 | |
| 288 | k = append_dsp_path((char*)phandle->dspCodec->NodeInfo.AllUUIDs[dllinfo].DllName, abs_dsp_path); |
| 289 | if (k < 0) |
| 290 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 291 | OMX_PRDSP4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: append_dsp_path returned an error!\n", __LINE__); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 292 | eError = OMX_ErrorBadParameter; |
| 293 | goto ERROR; |
| 294 | } |
| 295 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 296 | status = DSPManager_RegisterObject((struct DSP_UUID *)phandle->dspCodec->NodeInfo.AllUUIDs[dllinfo].uuid, |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 297 | phandle->dspCodec->NodeInfo.AllUUIDs[dllinfo].eDllType, abs_dsp_path); |
| 298 | |
| 299 | DSP_ERROR_EXIT (status, "Register Component Library", ERROR); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | /* NODE specific data */ |
| 303 | NodeAttrIn.cbStruct = sizeof(struct DSP_NODEATTRIN); |
| 304 | NodeAttrIn.iPriority = phandle->dspCodec->Priority; |
| 305 | NodeAttrIn.uTimeout = phandle->dspCodec->Timeout; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 306 | NodeAttrIn.uTimeout = 1000; /* WORKAROUND */ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 307 | NodeAttrIn.uProfileID= phandle->dspCodec->ProfileID; |
| 308 | /* Prepare Create Phase Argument */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 309 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Prepare Create Phase Argument \n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 310 | /* TO DO check is application setting it properly */ |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 311 | i = 0; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 312 | if(phandle->dspCodec->pCrPhArgs !=NULL) |
| 313 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 314 | while((phandle->dspCodec->pCrPhArgs[i] != END_OF_CR_PHASE_ARGS) && (i < LCML_DATA_SIZE)) |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 315 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 316 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: copying Create Phase Argument \n", i); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 317 | crData.cData[i] = phandle->dspCodec->pCrPhArgs[i]; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 318 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: CR PH arg[%d] = %d \n",__LINE__, i, crData.cData[i]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 319 | i++; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 320 | } |
| 321 | } |
| 322 | else |
| 323 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 324 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: ILLEGAL CREATEPHASE SET IT ..\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 325 | eError = OMX_ErrorBadParameter; |
| 326 | goto ERROR; |
| 327 | } |
| 328 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 329 | if (i >= LCML_DATA_SIZE) |
| 330 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 331 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, |
| 332 | "%d :: Reached end of Create Phase Args Array. Did not find END_OF_CR_PHASE_ARGS marker. \n", __LINE__); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 333 | eError = OMX_ErrorBadParameter; |
| 334 | goto ERROR; |
| 335 | } |
| 336 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 337 | /* LCML_DPRINT("Create Phase args strlen = %d\n",strlen(crData.cData)); */ |
| 338 | /* crData.cbData = sizeof (ULONG) + strlen(crData.cData); */ |
| 339 | crData.cbData = i*2; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 340 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "Create Phase args strlen = %ld\n", crData.cbData); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 341 | |
| 342 | status = DSPNode_Allocate(phandle->dspCodec->hProc, |
| 343 | (struct DSP_UUID *)phandle->dspCodec->NodeInfo.AllUUIDs[0].uuid, |
| 344 | (struct DSP_CBDATA*)&crData, |
| 345 | &NodeAttrIn,&(phandle->dspCodec->hNode)); |
| 346 | DSP_ERROR_EXIT(status, "Allocate Component", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 347 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: DSPNode_Allocate Successfully\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 348 | |
| 349 | pArgs = (struct DSP_CBDATA *)argsBuf; |
| 350 | strcpy((char*)pArgs->cData, Args); |
| 351 | pArgs->cbData = (ULONG)strlen ((char *)pArgs->cData); |
| 352 | |
| 353 | /* For debugging on connect DSP nodes */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 354 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "[LCML] - struct DSP_CBDATA.cbData (length): %d %s\n", (int)pArgs->cbData, (char *)pArgs->cData); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 355 | |
| 356 | if (phandle->dspCodec->DeviceInfo.TypeofDevice == 1) |
| 357 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 358 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Audio Device Selected\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 359 | status = DSPNode_Allocate(phandle->dspCodec->hProc, |
| 360 | (struct DSP_UUID *)phandle->dspCodec->DeviceInfo.AllUUIDs[0].uuid, |
| 361 | NULL, |
| 362 | NULL, |
| 363 | &(phandle->dspCodec->hDasfNode)); |
| 364 | DSP_ERROR_EXIT(status, "DASF Allocate Component", ERROR); |
| 365 | |
| 366 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 367 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: DASF DSPNode_Allocate Successfully\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 368 | if(phandle->dspCodec->DeviceInfo.DspStream != NULL) |
| 369 | { |
| 370 | if(phandle->dspCodec->DeviceInfo.TypeofRender == 0) |
| 371 | { |
| 372 | /* render for playback */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 373 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Render for playback\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 374 | status = DSPNode_ConnectEx(phandle->dspCodec->hNode, |
| 375 | 0, |
| 376 | (phandle->dspCodec->hDasfNode), |
| 377 | 0, |
| 378 | (struct DSP_STRMATTR *)phandle->dspCodec->DeviceInfo.DspStream, |
| 379 | pArgs); |
| 380 | DSP_ERROR_EXIT(status, "Node Connect", ERROR); |
| 381 | } |
| 382 | else if(phandle->dspCodec->DeviceInfo.TypeofRender == 1) |
| 383 | { |
| 384 | /* render for record */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 385 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Render for record\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 386 | status = DSPNode_ConnectEx(phandle->dspCodec->hDasfNode, |
| 387 | 0, |
| 388 | phandle->dspCodec->hNode, |
| 389 | 0, |
| 390 | (struct DSP_STRMATTR *)phandle->dspCodec->DeviceInfo.DspStream, |
| 391 | pArgs); |
| 392 | DSP_ERROR_EXIT(status, "Node Connect", ERROR); |
| 393 | } |
| 394 | } |
| 395 | else |
| 396 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 397 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: ILLEGAL STREAM PARAMETER SET IT ..\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 398 | eError = OMX_ErrorBadParameter; |
| 399 | goto ERROR; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | status = DSPNode_Create(phandle->dspCodec->hNode); |
| 404 | DSP_ERROR_EXIT(status, "Create the Node", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 405 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: After DSPNode_Create !!! \n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 406 | |
| 407 | status = DSPNode_Run(phandle->dspCodec->hNode); |
| 408 | DSP_ERROR_EXIT (status, "Goto RUN mode", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 409 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: DSPNode_Run Successfully\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 410 | |
| 411 | if ((phandle->dspCodec->In_BufInfo.DataTrMethod == DMM_METHOD) || (phandle->dspCodec->Out_BufInfo.DataTrMethod == DMM_METHOD)) |
| 412 | { |
| 413 | struct DSP_NOTIFICATION* notification; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 414 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Registering the Node for Messaging\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 415 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 416 | LCML_MALLOC(notification,sizeof(struct DSP_NOTIFICATION),struct DSP_NOTIFICATION) |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 417 | if(notification == NULL) |
| 418 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 419 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: malloc failed....\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 420 | goto ERROR; |
| 421 | } |
| 422 | memset(notification, 0, sizeof(struct DSP_NOTIFICATION)); |
| 423 | |
| 424 | status = DSPNode_RegisterNotify(phandle->dspCodec->hNode, DSP_NODEMESSAGEREADY, DSP_SIGNALEVENT, notification); |
| 425 | DSP_ERROR_EXIT(status, "DSP node register notify", ERROR); |
| 426 | phandle->g_aNotificationObjects[0] = notification; |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 427 | #ifdef __ERROR_PROPAGATION__ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 428 | struct DSP_NOTIFICATION* notification_mmufault; |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 429 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 430 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Registering the Node for Messaging\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 431 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 432 | LCML_MALLOC(notification_mmufault,sizeof(struct DSP_NOTIFICATION),struct DSP_NOTIFICATION); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 433 | if(notification_mmufault == NULL) |
| 434 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 435 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: malloc failed....\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 436 | goto ERROR; |
| 437 | } |
| 438 | memset(notification_mmufault,0,sizeof(struct DSP_NOTIFICATION)); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 439 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 440 | status = DSPProcessor_RegisterNotify(phandle->dspCodec->hProc, DSP_MMUFAULT, DSP_SIGNALEVENT, notification_mmufault); |
| 441 | DSP_ERROR_EXIT(status, "DSP node register notify DSP_MMUFAULT", ERROR); |
| 442 | phandle->g_aNotificationObjects[1] = notification_mmufault; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 443 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 444 | struct DSP_NOTIFICATION* notification_syserror ; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 445 | |
| 446 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Registering the Node for Messaging\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 447 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 448 | LCML_MALLOC(notification_syserror,sizeof(struct DSP_NOTIFICATION),struct DSP_NOTIFICATION); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 449 | if(notification_syserror == NULL) |
| 450 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 451 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: malloc failed....\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 452 | goto ERROR; |
| 453 | } |
| 454 | memset(notification_syserror,0,sizeof(struct DSP_NOTIFICATION)); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 455 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 456 | status = DSPProcessor_RegisterNotify(phandle->dspCodec->hProc, DSP_SYSERROR, DSP_SIGNALEVENT, notification_syserror); |
| 457 | DSP_ERROR_EXIT(status, "DSP node register notify DSP_SYSERROR", ERROR); |
| 458 | phandle->g_aNotificationObjects[2] = notification_syserror; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 459 | #endif |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | /* Listener thread */ |
| 463 | phandle->pshutdownFlag = 0; |
| 464 | phandle->g_tidMessageThread = 0; |
| 465 | phandle->bUsnEos = OMX_FALSE; |
| 466 | tmperr = pthread_create(&phandle->g_tidMessageThread, |
| 467 | NULL, |
| 468 | MessagingThread, |
| 469 | (void*)phandle); |
Andreas Huber | 5807caa | 2010-03-12 14:20:45 -0800 | [diff] [blame] | 470 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 471 | if (tmperr || !phandle->g_tidMessageThread) |
| 472 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 473 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "Thread creation failed: 0x%x",tmperr); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 474 | eError = OMX_ErrorInsufficientResources; |
| 475 | goto ERROR; |
| 476 | } |
| 477 | |
| 478 | #ifdef __PERF_INSTRUMENTATION__ |
| 479 | PERF_ThreadCreated(phandle->pPERF, |
| 480 | phandle->g_tidMessageThread, |
| 481 | PERF_FOURCC('C','M','L','T')); |
| 482 | #endif |
| 483 | /* init buffers buffer counter */ |
| 484 | phandle->iBufinputcount = 0; |
| 485 | phandle->iBufoutputcount = 0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 486 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 487 | for (i = 0; i < QUEUE_SIZE; i++) |
| 488 | { |
| 489 | phandle->Arminputstorage[i] = NULL; |
| 490 | phandle->Armoutputstorage[i] = NULL; |
| 491 | phandle->pAlgcntlDmmBuf[i] = NULL; |
| 492 | phandle->pStrmcntlDmmBuf[i] = NULL; |
| 493 | phandle->algcntlmapped[i] = 0; |
| 494 | phandle->strmcntlmapped[i] = 0; |
| 495 | } |
| 496 | #ifdef __PERF_INSTRUMENTATION__ |
| 497 | PERF_Boundary(phandle->pPERF, |
| 498 | PERF_BoundaryComplete | PERF_BoundarySetup); |
| 499 | #endif |
| 500 | } |
| 501 | |
| 502 | ERROR: |
| 503 | #ifndef CEXEC_DONE |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 504 | LCML_FREE(argv); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 505 | #endif |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 506 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Exiting Init_DSPSubSystem\n error = %x\n", __LINE__, eError); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 507 | return eError; |
| 508 | } |
| 509 | |
| 510 | /** ======================================================================== |
| 511 | * InitMMCodec initialise the OMX Component specific handle to LCML. |
| 512 | * The memory is allocated and the dsp node is created. Add notification object |
| 513 | * to listener thread. |
| 514 | * |
| 515 | * @param hInterface - Handle to LCML which is allocated and filled |
| 516 | * @param codecName - not used |
| 517 | * @param toCodecInitParams - not used yet |
| 518 | * @param fromCodecInfoStruct - not used yet |
| 519 | * @param pCallbacks - List of callback that uses to call OMX |
| 520 | * @return OMX_ERRORTYPE |
| 521 | * If the command successfully executes, the return code will be |
| 522 | * OMX_NoError. Otherwise the appropriate OMX error will be returned. |
| 523 | * ==========================================================================*/ |
| 524 | static OMX_ERRORTYPE InitMMCodec(OMX_HANDLETYPE hInt, |
| 525 | OMX_STRING codecName, |
| 526 | void * toCodecInitParams, |
| 527 | void * fromCodecInfoStruct, |
| 528 | LCML_CALLBACKTYPE *pCallbacks) |
| 529 | { |
| 530 | OMX_ERRORTYPE eError = OMX_ErrorNone; |
| 531 | OMX_U32 dllinfo; |
| 532 | LCML_DSP_INTERFACE * phandle; |
| 533 | #ifndef CEXEC_DONE |
| 534 | UINT argc = 1; |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 535 | char argv[ABS_DLL_NAME_LENGTH]; |
| 536 | k = append_dsp_path(DSP_DOF_IMAGE, argv); |
| 537 | if (k < 0) |
| 538 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 539 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: append_dsp_path returned an error!\n", __LINE__); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 540 | eError = OMX_ErrorBadParameter; |
| 541 | goto ERROR; |
| 542 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 543 | #endif |
| 544 | LCML_CREATEPHASEARGS crData; |
| 545 | DSP_STATUS status; |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 546 | int i = 0, k =0; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 547 | struct DSP_NODEATTRIN NodeAttrIn; |
| 548 | int tmperr; |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 549 | char abs_dsp_path[ABS_DLL_NAME_LENGTH]; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 550 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 551 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: InitMMCodec application\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 552 | |
James Dong | c22b4b5 | 2009-09-28 13:27:45 -0700 | [diff] [blame] | 553 | if (hInt == NULL ) |
| 554 | { |
| 555 | eError = OMX_ErrorInsufficientResources; |
| 556 | goto ERROR; |
| 557 | } |
| 558 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 559 | phandle = (LCML_DSP_INTERFACE *)(((LCML_CODEC_INTERFACE *)hInt)->pCodec); |
| 560 | #ifdef __PERF_INSTRUMENTATION__ |
| 561 | phandle->pPERF = PERF_Create(PERF_FOURCC('C','M','L',' '), |
| 562 | PERF_ModuleAudioDecode | PERF_ModuleAudioEncode | |
| 563 | PERF_ModuleVideoDecode | PERF_ModuleVideoEncode | |
| 564 | PERF_ModuleImageDecode | PERF_ModuleImageEncode | |
| 565 | PERF_ModuleCommonLayer); |
| 566 | PERF_Boundary(phandle->pPERF, |
| 567 | PERF_BoundaryStart | PERF_BoundarySetup); |
| 568 | #endif |
| 569 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 570 | /* 720p implementation */ |
| 571 | { |
| 572 | pthread_mutex_init(&phandle->m_isStopped_mutex, NULL); |
| 573 | phandle->mapped_buffer_count = 0; |
| 574 | } |
| 575 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 576 | /* INIT DSP RESOURCE */ |
| 577 | if(pCallbacks) |
| 578 | { |
| 579 | phandle->dspCodec->Callbacks.LCML_Callback = pCallbacks->LCML_Callback; |
| 580 | } |
| 581 | else |
| 582 | { |
| 583 | eError = OMX_ErrorBadParameter; |
| 584 | goto ERROR; |
| 585 | } |
| 586 | |
| 587 | /* INITIALIZATION OF DSP */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 588 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Entering Init_DSPSubSystem\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 589 | status = DspManager_Open(0, NULL); |
| 590 | DSP_ERROR_EXIT(status, "DSP Manager Open", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 591 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "DspManager_Open Successful\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 592 | |
| 593 | /* Attach and get handle to processor */ |
| 594 | status = DSPProcessor_Attach(TI_PROCESSOR_DSP, NULL, &(phandle->dspCodec->hProc)); |
| 595 | DSP_ERROR_EXIT(status, "Attach processor", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 596 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "DSPProcessor_Attach Successful\n"); |
| 597 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "Base Image is Already Loaded\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 598 | |
| 599 | for(dllinfo=0; dllinfo < phandle->dspCodec->NodeInfo.nNumOfDLLs; dllinfo++) |
| 600 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 601 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Register Component Node\n",phandle->dspCodec->NodeInfo.AllUUIDs[dllinfo].eDllType); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 602 | |
| 603 | k = append_dsp_path((char*)phandle->dspCodec->NodeInfo.AllUUIDs[dllinfo].DllName, abs_dsp_path); |
| 604 | if (k < 0) |
| 605 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 606 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: append_dsp_path returned an error!\n", __LINE__); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 607 | eError = OMX_ErrorBadParameter; |
| 608 | goto ERROR; |
| 609 | } |
| 610 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 611 | status = DSPManager_RegisterObject((struct DSP_UUID *)phandle->dspCodec->NodeInfo.AllUUIDs[dllinfo].uuid, |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 612 | phandle->dspCodec->NodeInfo.AllUUIDs[dllinfo].eDllType, |
| 613 | abs_dsp_path); |
| 614 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 615 | DSP_ERROR_EXIT (status, "Register Component Library", ERROR) |
| 616 | } |
| 617 | |
| 618 | /* NODE specific data */ |
| 619 | |
| 620 | NodeAttrIn.cbStruct = sizeof(struct DSP_NODEATTRIN); |
| 621 | NodeAttrIn.iPriority = phandle->dspCodec->Priority; |
| 622 | NodeAttrIn.uTimeout = phandle->dspCodec->Timeout; |
| 623 | NodeAttrIn.uTimeout = 1000; /* WORKAROUND */ |
| 624 | NodeAttrIn.uProfileID= phandle->dspCodec->ProfileID; |
| 625 | /* Prepare Create Phase Argument */ |
| 626 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 627 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Prepare Create Phase Argument \n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 628 | /* TO DO check is application setting it properly */ |
| 629 | if(phandle->dspCodec->pCrPhArgs !=NULL) |
| 630 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 631 | while((phandle->dspCodec->pCrPhArgs[i] != END_OF_CR_PHASE_ARGS) && (i < LCML_DATA_SIZE)) |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 632 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 633 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: copying Create Phase Argument \n",i); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 634 | crData.cData[i] =phandle->dspCodec->pCrPhArgs[i]; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 635 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: CR PH arg[%d] = %d \n",__LINE__,i,crData.cData[i]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 636 | i++; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 637 | } |
| 638 | } |
| 639 | else |
| 640 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 641 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: ILLEGAL CREATEPHASE SET IT ..\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 642 | eError = OMX_ErrorBadParameter; |
| 643 | goto ERROR; |
| 644 | } |
| 645 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 646 | if (i >= LCML_DATA_SIZE) |
| 647 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 648 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, |
| 649 | "%d :: Reached end of Create Phase Args Array. Did not find END_OF_CR_PHASE_ARGS marker. \n", __LINE__); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 650 | eError = OMX_ErrorBadParameter; |
| 651 | goto ERROR; |
| 652 | } |
| 653 | |
| 654 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 655 | /* LCML_DPRINT ("Create Phase args strlen = %d\n",strlen(crData.cData)); */ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 656 | /* crData.cbData = sizeof (ULONG) + strlen(crData.cData); */ |
| 657 | crData.cbData = i * 2; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 658 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "Create Phase args strlen = %ld\n", crData.cbData); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 659 | |
| 660 | status = DSPNode_Allocate(phandle->dspCodec->hProc, |
| 661 | (struct DSP_UUID *)phandle->dspCodec->NodeInfo.AllUUIDs[0].uuid, |
| 662 | (struct DSP_CBDATA*)&crData, &NodeAttrIn, |
| 663 | &(phandle->dspCodec->hNode)); |
| 664 | DSP_ERROR_EXIT(status, "Allocate Component", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 665 | OMX_PRDSP1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: DSPNode_Allocate Successfully\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 666 | |
| 667 | if(phandle->dspCodec->DeviceInfo.TypeofDevice == 1) |
| 668 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 669 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Audio Device Selected\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 670 | status = DSPNode_Allocate(phandle->dspCodec->hProc, |
| 671 | (struct DSP_UUID *)phandle->dspCodec->DeviceInfo.AllUUIDs[0].uuid, |
| 672 | NULL, |
| 673 | NULL, |
| 674 | &(phandle->dspCodec->hDasfNode)); |
| 675 | DSP_ERROR_EXIT(status, "DASF Allocate Component", ERROR); |
| 676 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 677 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: DASF DSPNode_Allocate Successfully\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 678 | if(phandle->dspCodec->DeviceInfo.DspStream !=NULL) |
| 679 | { |
| 680 | if(phandle->dspCodec->DeviceInfo.TypeofRender == 0) |
| 681 | { |
| 682 | /* render for playback */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 683 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Render for playback\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 684 | status = DSPNode_Connect(phandle->dspCodec->hNode, |
| 685 | 0, |
| 686 | phandle->dspCodec->hDasfNode, |
| 687 | 0, |
| 688 | (struct DSP_STRMATTR *)phandle->dspCodec->DeviceInfo.DspStream); |
| 689 | DSP_ERROR_EXIT(status, "Node Connect", ERROR); |
| 690 | } |
| 691 | else if(phandle->dspCodec->DeviceInfo.TypeofRender == 1) |
| 692 | { |
| 693 | /* render for record */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 694 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Render for record\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 695 | status = DSPNode_Connect(phandle->dspCodec->hDasfNode, |
| 696 | 0, |
| 697 | phandle->dspCodec->hNode, |
| 698 | 0, |
| 699 | (struct DSP_STRMATTR *)phandle->dspCodec->DeviceInfo.DspStream); |
| 700 | DSP_ERROR_EXIT(status, "Node Connect", ERROR); |
| 701 | } |
| 702 | } |
| 703 | else |
| 704 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 705 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: ILLEGAL STREAM PARAMETER SET IT ..\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 706 | eError = OMX_ErrorBadParameter; |
| 707 | goto ERROR; |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | status = DSPNode_Create(phandle->dspCodec->hNode); |
| 712 | DSP_ERROR_EXIT(status, "Create the Node", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 713 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: After DSPNode_Create !!! \n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 714 | |
| 715 | status = DSPNode_Run (phandle->dspCodec->hNode); |
| 716 | DSP_ERROR_EXIT (status, "Goto RUN mode", ERROR); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 717 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: DSPNode_Run Successfully\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 718 | |
| 719 | if ((phandle->dspCodec->In_BufInfo.DataTrMethod == DMM_METHOD) || |
| 720 | (phandle->dspCodec->Out_BufInfo.DataTrMethod == DMM_METHOD)) |
| 721 | { |
| 722 | struct DSP_NOTIFICATION* notification; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 723 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Registering the Node for Messaging\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 724 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 725 | LCML_MALLOC(notification,sizeof(struct DSP_NOTIFICATION),struct DSP_NOTIFICATION); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 726 | if(notification == NULL) |
| 727 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 728 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: malloc failed....\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 729 | goto ERROR; |
| 730 | } |
| 731 | memset(notification,0,sizeof(struct DSP_NOTIFICATION)); |
| 732 | |
| 733 | status = DSPNode_RegisterNotify(phandle->dspCodec->hNode, DSP_NODEMESSAGEREADY, DSP_SIGNALEVENT, notification); |
| 734 | DSP_ERROR_EXIT(status, "DSP node register notify", ERROR); |
| 735 | phandle->g_aNotificationObjects[0] = notification; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 736 | #ifdef __ERROR_PROPAGATION__ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 737 | struct DSP_NOTIFICATION* notification_mmufault; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 738 | |
| 739 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Registering the Node for Messaging\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 740 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 741 | LCML_MALLOC(notification_mmufault,sizeof(struct DSP_NOTIFICATION),struct DSP_NOTIFICATION); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 742 | if(notification_mmufault == NULL) |
| 743 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 744 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: malloc failed....\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 745 | goto ERROR; |
| 746 | } |
| 747 | memset(notification_mmufault,0,sizeof(struct DSP_NOTIFICATION)); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 748 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 749 | status = DSPProcessor_RegisterNotify(phandle->dspCodec->hProc, DSP_MMUFAULT, DSP_SIGNALEVENT, notification_mmufault); |
| 750 | DSP_ERROR_EXIT(status, "DSP node register notify DSP_MMUFAULT", ERROR); |
| 751 | phandle->g_aNotificationObjects[1] = notification_mmufault; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 752 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 753 | struct DSP_NOTIFICATION* notification_syserror ; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 754 | |
| 755 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Registering the Node for Messaging\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 756 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 757 | LCML_MALLOC(notification_syserror,sizeof(struct DSP_NOTIFICATION),struct DSP_NOTIFICATION); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 758 | if(notification_syserror == NULL) |
| 759 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 760 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: malloc failed....\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 761 | goto ERROR; |
| 762 | } |
| 763 | memset(notification_syserror,0,sizeof(struct DSP_NOTIFICATION)); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 764 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 765 | status = DSPProcessor_RegisterNotify(phandle->dspCodec->hProc, DSP_SYSERROR, DSP_SIGNALEVENT, notification_syserror); |
| 766 | DSP_ERROR_EXIT(status, "DSP node register notify DSP_SYSERROR", ERROR); |
| 767 | phandle->g_aNotificationObjects[2] = notification_syserror; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 768 | #endif |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | /* Listener thread */ |
| 772 | phandle->pshutdownFlag = 0; |
| 773 | phandle->g_tidMessageThread = 0; |
| 774 | |
| 775 | tmperr = pthread_create(&phandle->g_tidMessageThread, |
| 776 | NULL, |
| 777 | MessagingThread, |
| 778 | (void*)phandle); |
Andreas Huber | 5807caa | 2010-03-12 14:20:45 -0800 | [diff] [blame] | 779 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 780 | if(tmperr || !phandle->g_tidMessageThread) |
| 781 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 782 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "Thread creation failed: 0x%x",tmperr); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 783 | eError = OMX_ErrorInsufficientResources; |
| 784 | goto ERROR; |
| 785 | } |
| 786 | |
| 787 | #ifdef __PERF_INSTRUMENTATION__ |
| 788 | PERF_ThreadCreated(phandle->pPERF, |
| 789 | phandle->g_tidMessageThread, |
| 790 | PERF_FOURCC('C','M','L','T')); |
| 791 | #endif |
| 792 | /* init buffers buffer counter */ |
| 793 | phandle->iBufinputcount =0; |
| 794 | phandle->iBufoutputcount =0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 795 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 796 | for (i = 0; i < QUEUE_SIZE; i++) |
| 797 | { |
| 798 | phandle->Arminputstorage[i] = NULL; |
| 799 | phandle->Armoutputstorage[i] = NULL; |
| 800 | phandle->pAlgcntlDmmBuf[i] = NULL; |
| 801 | phandle->pStrmcntlDmmBuf[i] = NULL; |
| 802 | phandle->algcntlmapped[i] = 0; |
| 803 | phandle->strmcntlmapped[i] = 0; |
| 804 | } |
| 805 | |
| 806 | #ifdef __PERF_INSTRUMENTATION__ |
| 807 | PERF_Boundary(phandle->pPERF, |
| 808 | PERF_BoundaryComplete | PERF_BoundarySetup); |
| 809 | #endif |
Rebecca Schultz Zavin | b44cdb1 | 2009-07-29 17:23:50 -0700 | [diff] [blame] | 810 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 811 | ERROR: |
| 812 | #ifndef CEXEC_DONE |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 813 | LCML_FREE(argv); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 814 | #endif |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 815 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInt)->dbg, "%d :: Exiting Init_DSPSubSystem\n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 816 | return eError; |
| 817 | } |
| 818 | |
| 819 | |
| 820 | |
| 821 | /** ======================================================================== |
| 822 | * The LCML_WaitForEvent Wait for a event sychronously |
| 823 | * @param hInterface - Handle of the component to be accessed. This is the |
| 824 | * component handle returned by the call to the GetHandle function. |
| 825 | * @param event - Event occured |
| 826 | * @param args - Array of "void *" that contains the associated arguments for |
| 827 | * occured event |
| 828 | * |
| 829 | * @return OMX_ERRORTYPE |
| 830 | * If the command successfully executes, the return code will be |
| 831 | * OMX_NoError. Otherwise the appropriate OMX error will be returned. |
| 832 | ** ==========================================================================*/ |
| 833 | static OMX_ERRORTYPE WaitForEvent(OMX_HANDLETYPE hComponent, |
| 834 | TUsnCodecEvent event, |
| 835 | void * args[10] ) |
| 836 | { |
| 837 | OMX_ERRORTYPE eError = OMX_ErrorUndefined; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 838 | return eError; |
| 839 | } |
| 840 | |
| 841 | |
| 842 | /** ======================================================================== |
| 843 | * The LCML_QueueBuffer send data to DSP convert it into USN format and send |
| 844 | * it to DSP via setbuff |
| 845 | * @param [in] hInterface - Handle of the component to be accessed. This is |
| 846 | * the component handle returned by the call to the GetHandle function. |
| 847 | * @param bufType - type of buffer |
| 848 | * @param buffer - pointer to buffer |
| 849 | * @param bufferLen - length of buffer |
| 850 | * @param bufferSizeUsed - length of used buffer |
| 851 | * @param auxInfo - pointer to parameter |
| 852 | * @param auxInfoLen - length of parameter |
| 853 | * @param usrArg - not used |
| 854 | * @return OMX_ERRORTYPE |
| 855 | * If the command successfully executes, the return code will be |
| 856 | * OMX_NoError. Otherwise the appropriate OMX error will be returned. |
| 857 | * ==========================================================================*/ |
| 858 | static OMX_ERRORTYPE QueueBuffer (OMX_HANDLETYPE hComponent, |
| 859 | TMMCodecBufferType bufType, |
| 860 | OMX_U8 * buffer, OMX_S32 bufferLen, |
| 861 | OMX_S32 bufferSizeUsed ,OMX_U8 * auxInfo, |
| 862 | OMX_S32 auxInfoLen ,OMX_U8 * usrArg ) |
| 863 | { |
| 864 | LCML_DSP_INTERFACE * phandle; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 865 | OMX_U32 streamId = 0; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 866 | DSP_STATUS status; |
| 867 | OMX_ERRORTYPE eError = OMX_ErrorNone; |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 868 | char * tmp2=NULL; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 869 | DMM_BUFFER_OBJ* pDmmBuf=NULL; |
| 870 | int commandId; |
| 871 | struct DSP_MSG msg; |
Rebecca Schultz Zavin | b44cdb1 | 2009-07-29 17:23:50 -0700 | [diff] [blame] | 872 | OMX_U32 MapBufLen=0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 873 | OMX_BOOL mappedBufferFound = false; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 874 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 875 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "%d :: QueueBuffer application\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 876 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 877 | if (hComponent == NULL ) |
James Dong | c22b4b5 | 2009-09-28 13:27:45 -0700 | [diff] [blame] | 878 | { |
| 879 | eError = OMX_ErrorInsufficientResources; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 880 | goto EXIT; |
James Dong | c22b4b5 | 2009-09-28 13:27:45 -0700 | [diff] [blame] | 881 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 882 | |
| 883 | phandle = (LCML_DSP_INTERFACE *)(((LCML_CODEC_INTERFACE *)hComponent)->pCodec); |
| 884 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 885 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "LCML QueueBuffer: phandle->iBufinputcount is %lu (%p) \n", phandle->iBufinputcount, phandle); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 886 | |
| 887 | #ifdef __PERF_INSTRUMENTATION__ |
| 888 | PERF_XferingBuffer(phandle->pPERF, |
| 889 | buffer, |
| 890 | bufferSizeUsed, |
| 891 | PERF_ModuleComponent, |
| 892 | PERF_ModuleSocketNode); |
| 893 | #endif |
| 894 | pthread_mutex_lock(&phandle->mutex); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 895 | LCML_MALLOC(tmp2,sizeof(TArmDspCommunicationStruct) + 256,char); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 896 | if (tmp2 == NULL) |
| 897 | { |
| 898 | eError = OMX_ErrorInsufficientResources; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 899 | goto MUTEX_UNLOCK; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 900 | } |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 901 | memset(tmp2,0,sizeof(TArmDspCommunicationStruct)+256); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 902 | phandle->commStruct = (TArmDspCommunicationStruct *)(tmp2 + 128); |
| 903 | phandle->commStruct->iBufferPtr = (OMX_U32) buffer; |
| 904 | phandle->commStruct->iBufferSize = bufferLen; |
| 905 | phandle->commStruct->iParamPtr = (OMX_U32) auxInfo; |
| 906 | phandle->commStruct->iParamSize = auxInfoLen; |
| 907 | /*USN updation */ |
| 908 | phandle->commStruct->iBufSizeUsed = bufferSizeUsed ; |
| 909 | phandle->commStruct->iArmArg = (OMX_U32) buffer; |
| 910 | phandle->commStruct->iArmParamArg = (OMX_U32) auxInfo; |
| 911 | |
| 912 | /* if the bUsnEos flag is set interpret the usrArg as a buffer header */ |
| 913 | if (phandle->bUsnEos == OMX_TRUE) { |
| 914 | phandle->commStruct->iEOSFlag = (((OMX_BUFFERHEADERTYPE*)usrArg)->nFlags & 0x00000001); |
| 915 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 916 | else { |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 917 | phandle->commStruct->iEOSFlag = 0; |
| 918 | } |
| 919 | phandle->commStruct->iUsrArg = (OMX_U32) usrArg; |
| 920 | phandle->iBufoutputcount = phandle->iBufoutputcount % QUEUE_SIZE; |
| 921 | phandle->iBufinputcount = phandle->iBufinputcount % QUEUE_SIZE; |
| 922 | phandle->commStruct->Bufoutindex = phandle->iBufoutputcount; |
| 923 | phandle->commStruct->BufInindex = phandle->iBufinputcount; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 924 | switch (bufType) |
Rebecca Schultz Zavin | b44cdb1 | 2009-07-29 17:23:50 -0700 | [diff] [blame] | 925 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 926 | case EMMCodecInputBufferMapBufLen: |
| 927 | bufType = EMMCodecInputBuffer; |
| 928 | MapBufLen = 1; |
| 929 | break; |
| 930 | case EMMCodecOutputBufferMapBufLen: |
| 931 | bufType = EMMCodecOuputBuffer; |
| 932 | MapBufLen = 1; |
| 933 | break; |
| 934 | case EMMCodecInputBufferMapReuse: |
| 935 | bufType = EMMCodecInputBuffer; |
| 936 | phandle->ReUseMap = 1; |
| 937 | break; |
| 938 | case EMMCodecOutputBufferMapReuse: |
| 939 | bufType = EMMCodecOuputBuffer; |
| 940 | phandle->ReUseMap = 1; |
| 941 | break; |
| 942 | default: |
| 943 | break; |
Rebecca Schultz Zavin | b44cdb1 | 2009-07-29 17:23:50 -0700 | [diff] [blame] | 944 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 945 | |
| 946 | if ((bufType >= EMMCodecStream0) && (bufType <= (EMMCodecStream0 + 20))) |
| 947 | { |
| 948 | streamId = bufType - EMMCodecStream0; |
| 949 | } |
| 950 | |
| 951 | phandle->commStruct->iStreamID = streamId; |
| 952 | |
| 953 | if (bufType == EMMCodecInputBuffer || !(streamId % 2)) |
| 954 | { |
| 955 | phandle->Arminputstorage[phandle->iBufinputcount] = phandle->commStruct; |
| 956 | pDmmBuf = phandle->dspCodec->InDmmBuffer; |
| 957 | pDmmBuf = pDmmBuf + phandle->iBufinputcount; |
| 958 | phandle->iBufinputcount++; |
| 959 | phandle->iBufinputcount = phandle->iBufinputcount % QUEUE_SIZE; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 960 | OMX_PRBUFFER1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "VPP port %lu use InDmmBuffer (%lu) %p\n", streamId, phandle->iBufinputcount, pDmmBuf); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 961 | |
| 962 | } |
| 963 | else if (bufType == EMMCodecOuputBuffer || streamId % 2) |
| 964 | { |
| 965 | phandle->Armoutputstorage[phandle->iBufoutputcount] = phandle->commStruct; |
| 966 | pDmmBuf = phandle->dspCodec->OutDmmBuffer; |
| 967 | pDmmBuf = pDmmBuf + phandle->iBufoutputcount; |
| 968 | phandle->iBufoutputcount++; |
| 969 | phandle->iBufoutputcount = phandle->iBufoutputcount % QUEUE_SIZE; |
| 970 | } |
| 971 | else |
| 972 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 973 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Unrecognized buffer type.."); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 974 | eError = OMX_ErrorBadParameter; |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 975 | if(tmp2) |
| 976 | { |
| 977 | free(tmp2); |
| 978 | phandle->commStruct = NULL; |
| 979 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 980 | goto MUTEX_UNLOCK; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 981 | } |
| 982 | commandId = USN_GPPMSG_SET_BUFF|streamId; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 983 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Sending command ID 0x%x",commandId); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 984 | if( pDmmBuf == NULL) |
| 985 | { |
| 986 | eError = OMX_ErrorInsufficientResources; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 987 | goto MUTEX_UNLOCK; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 988 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 989 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "buffer = 0x%p bufferlen = %ld auxInfo = 0x%p auxInfoLen %ld\n", |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 990 | buffer, bufferLen, auxInfo, auxInfoLen ); |
| 991 | |
| 992 | phandle->commStruct->iArmbufferArg = (OMX_U32)buffer; |
| 993 | if ((buffer != NULL) && (bufferLen != 0)) |
| 994 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 995 | OMX_U32 i; |
| 996 | DSP_STATUS status; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 997 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 998 | if (phandle->ReUseMap) |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 999 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1000 | mappedBufferFound = false; |
| 1001 | for(i = 0; i <= phandle->mapped_buffer_count; i++) |
| 1002 | { |
| 1003 | if(phandle->mapped_dmm_buffers[i].pAllocated == buffer) |
| 1004 | { |
| 1005 | mappedBufferFound = true; |
| 1006 | *pDmmBuf = phandle->mapped_dmm_buffers[i]; |
| 1007 | OMX_PRBUFFER1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Re-using pDmmBuf %p mapped %p\n", pDmmBuf, pDmmBuf->pMapped); |
| 1008 | |
| 1009 | if(bufType == EMMCodecInputBuffer) |
| 1010 | { |
| 1011 | /* Issue a memory flush for input buffer to ensure cache coherency */ |
| 1012 | status = DSPProcessor_FlushMemory(phandle->dspCodec->hProc, pDmmBuf->pAllocated, bufferSizeUsed, (bufferSizeUsed > 512*1024) ? 3: 0); |
| 1013 | if(DSP_FAILED(status)) |
| 1014 | { |
| 1015 | goto MUTEX_UNLOCK; |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | else if(bufType == EMMCodecOuputBuffer) |
| 1020 | { |
| 1021 | /* Issue an memory invalidate for output buffer */ |
| 1022 | if (bufferLen > 512*1024) |
| 1023 | { |
| 1024 | status = DSPProcessor_FlushMemory(phandle->dspCodec->hProc, pDmmBuf->pAllocated, bufferLen, 3); |
| 1025 | if(DSP_FAILED(status)) |
| 1026 | { |
| 1027 | goto MUTEX_UNLOCK; |
| 1028 | } |
| 1029 | } |
| 1030 | else |
| 1031 | { |
| 1032 | status = DSPProcessor_InvalidateMemory(phandle->dspCodec->hProc, pDmmBuf->pAllocated, bufferLen); |
| 1033 | if(DSP_FAILED(status)) |
| 1034 | { |
| 1035 | goto MUTEX_UNLOCK; |
| 1036 | } |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | break; |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | if(false == mappedBufferFound) |
| 1045 | { |
| 1046 | if (bufType == EMMCodecInputBuffer || !(streamId % 2)) |
| 1047 | { |
| 1048 | phandle->commStruct->iBufferSize = bufferSizeUsed ? bufferSizeUsed : bufferLen; |
| 1049 | eError = DmmMap(phandle->dspCodec->hProc, bufferLen,buffer, (pDmmBuf), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
| 1050 | } |
| 1051 | else if (bufType == EMMCodecOuputBuffer || streamId % 2) { |
| 1052 | eError = DmmMap(phandle->dspCodec->hProc, bufferLen, buffer, (pDmmBuf), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
| 1053 | } |
| 1054 | if (eError != OMX_ErrorNone) |
| 1055 | { |
| 1056 | goto MUTEX_UNLOCK; |
| 1057 | } |
| 1058 | |
| 1059 | /*720p implementation */ |
| 1060 | phandle->commStruct->iBufferPtr = (OMX_U32) pDmmBuf->pMapped; |
| 1061 | /* storing reserve address for buffer */ |
| 1062 | pDmmBuf->bufReserved = pDmmBuf->pReserved; |
| 1063 | if(phandle->mapped_buffer_count <= MAX_DMM_BUFFERS) |
| 1064 | { |
| 1065 | phandle->mapped_dmm_buffers[phandle->mapped_buffer_count++] = *pDmmBuf; |
| 1066 | } |
| 1067 | } |
| 1068 | phandle->commStruct->iBufferPtr = (OMX_U32) pDmmBuf->pMapped; |
| 1069 | } |
| 1070 | else |
| 1071 | { |
| 1072 | |
| 1073 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Mapping buffer continously\n"); |
| 1074 | if (bufType == EMMCodecInputBuffer || !(streamId % 2)) |
| 1075 | { |
| 1076 | if (MapBufLen) |
| 1077 | { |
| 1078 | /*using this option only when not mapping the entire memory region |
| 1079 | * can cause a DSP MMU FAULT or DSP SYS ERROR */ |
| 1080 | eError = DmmMap(phandle->dspCodec->hProc, bufferLen, buffer, (pDmmBuf), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
| 1081 | } |
| 1082 | else |
| 1083 | { |
| 1084 | phandle->commStruct->iBufferSize = bufferSizeUsed ? bufferSizeUsed : bufferLen; |
| 1085 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Mapping Size %ld out of %ld", bufferSizeUsed, bufferLen); |
| 1086 | eError = DmmMap(phandle->dspCodec->hProc, bufferSizeUsed ? bufferSizeUsed : bufferLen,buffer, (pDmmBuf), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
| 1087 | } |
| 1088 | } |
| 1089 | else if (bufType == EMMCodecOuputBuffer || streamId % 2) { |
| 1090 | eError = DmmMap(phandle->dspCodec->hProc, bufferLen, buffer, (pDmmBuf), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
| 1091 | } |
| 1092 | if (eError != OMX_ErrorNone) |
| 1093 | { |
| 1094 | goto MUTEX_UNLOCK; |
| 1095 | } |
| 1096 | phandle->commStruct->iBufferPtr = (OMX_U32) pDmmBuf->pMapped; |
| 1097 | pDmmBuf->bufReserved = pDmmBuf->pReserved; |
James Dong | eaaadaf | 2010-02-01 17:29:02 -0800 | [diff] [blame] | 1098 | } |
James Dong | 36733d6 | 2010-01-28 13:53:05 -0800 | [diff] [blame] | 1099 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | if (auxInfoLen != 0 && auxInfo != NULL ) |
| 1103 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1104 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "mapping parameter \n"); |
| 1105 | eError = DmmMap(phandle->dspCodec->hProc, phandle->commStruct->iParamSize, (void*)phandle->commStruct->iParamPtr, (pDmmBuf), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1106 | if (eError != OMX_ErrorNone) |
| 1107 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1108 | goto MUTEX_UNLOCK; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | phandle->commStruct->iParamPtr = (OMX_U32 )pDmmBuf->pMapped ; |
| 1112 | /* storing reserve address for param */ |
| 1113 | pDmmBuf->paramReserved = pDmmBuf->pReserved; |
| 1114 | } |
| 1115 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1116 | eError = DmmMap(phandle->dspCodec->hProc, sizeof(TArmDspCommunicationStruct),(void *)phandle->commStruct, (pDmmBuf), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1117 | if (eError != OMX_ErrorNone) |
| 1118 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1119 | goto MUTEX_UNLOCK; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1120 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1121 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1122 | /* storing mapped address of struct */ |
| 1123 | phandle->commStruct->iArmArg = (OMX_U32)pDmmBuf->pMapped; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1124 | |
| 1125 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "sending SETBUFF \n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1126 | msg.dwCmd = commandId; |
| 1127 | msg.dwArg1 = (int)pDmmBuf->pMapped; |
| 1128 | msg.dwArg2 = 0; |
| 1129 | |
| 1130 | status = DSPNode_PutMessage (phandle->dspCodec->hNode, &msg, DSP_FOREVER); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1131 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "after SETBUFF \n"); |
| 1132 | DSP_ERROR_EXIT (status, "Send message to node", MUTEX_UNLOCK); |
| 1133 | MUTEX_UNLOCK: |
James Dong | eaaadaf | 2010-02-01 17:29:02 -0800 | [diff] [blame] | 1134 | pthread_mutex_unlock(&phandle->mutex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1135 | EXIT: |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1136 | return eError; |
| 1137 | } |
| 1138 | |
| 1139 | |
| 1140 | /** ======================================================================== |
| 1141 | * The LCML_ControlCodec send command to DSP convert it into USN format and |
| 1142 | * send it to DSP |
| 1143 | * @param hInterface - Handle of the component to be accessed. This is the |
| 1144 | * component handle returned by the call to the GetHandle function. |
| 1145 | * @param bufType - type of buffer |
| 1146 | * @param iCodecCmd - command refer TControlCmd |
| 1147 | * @param args - pointer to send some specific command to DSP |
| 1148 | * |
| 1149 | * @return OMX_ERRORTYPE |
| 1150 | * If the command successfully executes, the return code will be |
| 1151 | * OMX_NoError. Otherwise the appropriate OMX error will be returned. |
| 1152 | ** ==========================================================================*/ |
| 1153 | static OMX_ERRORTYPE ControlCodec(OMX_HANDLETYPE hComponent, |
| 1154 | TControlCmd iCodecCmd, |
| 1155 | void * args[10]) |
| 1156 | { |
| 1157 | LCML_DSP_INTERFACE * phandle; |
| 1158 | DSP_STATUS status; |
| 1159 | OMX_ERRORTYPE eError = OMX_ErrorNone; |
| 1160 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1161 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "%d :: ControlCodec application\n",__LINE__); |
James Dong | c22b4b5 | 2009-09-28 13:27:45 -0700 | [diff] [blame] | 1162 | if (hComponent == NULL ) |
| 1163 | { |
| 1164 | eError= OMX_ErrorInsufficientResources; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1165 | goto EXIT; |
James Dong | c22b4b5 | 2009-09-28 13:27:45 -0700 | [diff] [blame] | 1166 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1167 | phandle = (LCML_DSP_INTERFACE *)(((LCML_CODEC_INTERFACE *)hComponent)->pCodec); |
| 1168 | |
| 1169 | #ifdef __PERF_INSTRUMENTATION__ |
| 1170 | PERF_ReceivedCommand(phandle->pPERF, |
| 1171 | (OMX_U32) iCodecCmd, |
| 1172 | (OMX_U32) args, |
| 1173 | PERF_ModuleLLMM); |
| 1174 | #endif |
| 1175 | switch (iCodecCmd) |
| 1176 | { |
| 1177 | case EMMCodecControlPause: |
| 1178 | { |
| 1179 | struct DSP_MSG msg = {USN_GPPMSG_PAUSE, 0, 0}; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1180 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Sending PAUSE command"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1181 | #ifdef __PERF_INSTRUMENTATION__ |
| 1182 | PERF_SendingCommand(phandle->pPERF, |
| 1183 | msg.dwCmd, |
| 1184 | msg.dwArg1, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1185 | PERF_ModuleSocketNode); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1186 | #endif |
| 1187 | status = DSPNode_PutMessage (phandle->dspCodec->hNode, &msg, DSP_FOREVER); |
| 1188 | DSP_ERROR_EXIT (status, "Send message to node", EXIT); |
| 1189 | break; |
| 1190 | } |
| 1191 | case EMMCodecControlStart: |
| 1192 | { |
| 1193 | struct DSP_MSG msg = {USN_GPPMSG_PLAY, 0, 0}; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1194 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Sending PLAY --1 command"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1195 | #ifdef __PERF_INSTRUMENTATION__ |
| 1196 | PERF_SendingCommand(phandle->pPERF, |
| 1197 | msg.dwCmd, |
| 1198 | msg.dwArg1, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1199 | PERF_ModuleSocketNode); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1200 | #endif |
| 1201 | status = DSPNode_PutMessage (phandle->dspCodec->hNode, &msg, DSP_FOREVER); |
| 1202 | DSP_ERROR_EXIT (status, "Send message to node", EXIT); |
| 1203 | break; |
| 1204 | } |
| 1205 | case MMCodecControlStop: |
| 1206 | { |
| 1207 | struct DSP_MSG msg = {USN_GPPMSG_STOP, 0, 0}; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1208 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Sending STOP command\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1209 | #ifdef __PERF_INSTRUMENTATION__ |
| 1210 | PERF_SendingCommand(phandle->pPERF, |
| 1211 | msg.dwCmd, |
| 1212 | msg.dwArg1, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1213 | PERF_ModuleSocketNode); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1214 | #endif |
| 1215 | status = DSPNode_PutMessage (phandle->dspCodec->hNode, &msg, DSP_FOREVER); |
| 1216 | DSP_ERROR_EXIT (status, "Send message to node", EXIT); |
| 1217 | break; |
| 1218 | } |
| 1219 | case EMMCodecControlDestroy: |
| 1220 | { |
| 1221 | int pthreadError = 0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1222 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Destroy the codec"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1223 | #ifdef __PERF_INSTRUMENTATION__ |
| 1224 | PERF_Boundary(phandle->pPERF, |
| 1225 | PERF_BoundaryStart | PERF_BoundaryCleanup); |
| 1226 | PERF_SendingCommand(phandle->pPERF, |
| 1227 | -1, 0, PERF_ModuleComponent); |
| 1228 | #endif |
| 1229 | phandle->pshutdownFlag = 1; |
| 1230 | pthreadError = pthread_join(phandle->g_tidMessageThread, NULL); |
| 1231 | if (0 != pthreadError) |
| 1232 | { |
| 1233 | eError = OMX_ErrorHardware; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1234 | OMX_ERROR4 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "%d :: Error while closing Component Thread\n", pthreadError); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1235 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1236 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "Destroy the codec %d",eError); |
| 1237 | /* 720p implementation */ |
| 1238 | /*DeleteDspResource (phandle);*/ |
| 1239 | if (phandle->ReUseMap) |
| 1240 | { |
| 1241 | pthread_mutex_lock(&phandle->m_isStopped_mutex); |
| 1242 | /*If you are able to obtain the lock then the Messaging thread has exited*/ |
| 1243 | pthread_mutex_unlock(&phandle->m_isStopped_mutex); |
| 1244 | } |
| 1245 | |
| 1246 | if (phandle->ReUseMap) |
| 1247 | { |
| 1248 | OMX_U32 i; |
| 1249 | |
| 1250 | /* Unmap buffers */ |
| 1251 | for(i=0; i< phandle->mapped_buffer_count; i++) |
| 1252 | { |
| 1253 | DmmUnMap(phandle->dspCodec->hProc,(void*)phandle->mapped_dmm_buffers[i].pMapped, |
| 1254 | phandle->mapped_dmm_buffers[i].bufReserved, ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
| 1255 | } |
| 1256 | |
| 1257 | for(i = 0; i <= phandle->mapped_buffer_count; i++) |
| 1258 | { |
| 1259 | phandle->mapped_dmm_buffers[i].pAllocated = 0; |
| 1260 | phandle->mapped_dmm_buffers[i].pReserved = 0; |
| 1261 | phandle->mapped_dmm_buffers[i].pMapped = 0; |
| 1262 | phandle->mapped_dmm_buffers[i].bufReserved = 0; |
| 1263 | phandle->mapped_dmm_buffers[i].paramReserved = 0; |
| 1264 | phandle->mapped_dmm_buffers[i].nSize = 0; |
| 1265 | } |
| 1266 | |
| 1267 | phandle->mapped_buffer_count = 0; |
| 1268 | } |
| 1269 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1270 | DeleteDspResource (phandle); |
| 1271 | |
| 1272 | #ifdef __PERF_INSTRUMENTATION__ |
| 1273 | PERF_OBJHANDLE pPERF = phandle->pPERF; |
| 1274 | #endif |
| 1275 | |
| 1276 | FreeResources(phandle); |
| 1277 | |
| 1278 | #ifdef __PERF_INSTRUMENTATION__ |
| 1279 | PERF_Boundary(pPERF, PERF_BoundaryComplete | PERF_BoundaryCleanup); |
| 1280 | PERF_Done(pPERF); |
| 1281 | #endif |
| 1282 | |
| 1283 | break; |
| 1284 | } |
| 1285 | |
| 1286 | /* this case is for sending extra custom commands to DSP socket node */ |
| 1287 | case EMMCodecControlSendDspMessage: |
| 1288 | { |
| 1289 | /* todo: Check to see if the arguments are valid */ |
| 1290 | struct DSP_MSG msg = {(int)args[0], (int)args[1], (int)args[2]}; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1291 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "message to codec"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1292 | #ifdef __PERF_INSTRUMENTATION__ |
| 1293 | PERF_SendingCommand(phandle->pPERF, |
| 1294 | msg.dwCmd, |
| 1295 | msg.dwArg1, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1296 | PERF_ModuleSocketNode); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1297 | #endif |
| 1298 | status = DSPNode_PutMessage (phandle->dspCodec->hNode, &msg, DSP_FOREVER); |
| 1299 | DSP_ERROR_EXIT (status, "Send message to node", EXIT); |
| 1300 | break; |
| 1301 | } |
| 1302 | case EMMCodecControlAlgCtrl: |
| 1303 | { |
| 1304 | struct DSP_MSG msg; |
| 1305 | int i; |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 1306 | pthread_mutex_lock(&phandle->mutex); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1307 | for (i = 0; i < QUEUE_SIZE; i++) |
| 1308 | { |
| 1309 | /* searching for empty slot */ |
| 1310 | if (phandle->pAlgcntlDmmBuf[i] == NULL) |
| 1311 | break; |
| 1312 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1313 | if(i >= QUEUE_SIZE) |
| 1314 | { |
| 1315 | pthread_mutex_unlock(&phandle->mutex); |
| 1316 | eError = OMX_ErrorUndefined; |
| 1317 | goto EXIT; |
| 1318 | } |
| 1319 | |
| 1320 | LCML_MALLOC(phandle->pAlgcntlDmmBuf[i],sizeof(DMM_BUFFER_OBJ),DMM_BUFFER_OBJ); |
| 1321 | if(phandle->pAlgcntlDmmBuf[i] == NULL) |
| 1322 | { |
| 1323 | eError = OMX_ErrorInsufficientResources; |
| 1324 | pthread_mutex_unlock(&phandle->mutex); |
| 1325 | goto EXIT; |
| 1326 | } |
| 1327 | |
| 1328 | memset(phandle->pAlgcntlDmmBuf[i],0,sizeof(DMM_BUFFER_OBJ)); |
| 1329 | |
| 1330 | eError = DmmMap(phandle->dspCodec->hProc,(int)args[2], args[1],(phandle->pAlgcntlDmmBuf[i]), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
| 1331 | if (eError != OMX_ErrorNone) |
| 1332 | { |
| 1333 | pthread_mutex_unlock(&phandle->mutex); |
| 1334 | goto EXIT; |
| 1335 | } |
| 1336 | phandle->algcntlmapped[i] = 1; |
| 1337 | msg.dwCmd = USN_GPPMSG_ALGCTRL; |
| 1338 | msg.dwArg1 = (int)args[0]; |
| 1339 | msg.dwArg2 = (int)phandle->pAlgcntlDmmBuf[i]->pMapped; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1340 | #ifdef __PERF_INSTRUMENTATION__ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1341 | PERF_SendingCommand(phandle->pPERF, |
| 1342 | msg.dwCmd, |
| 1343 | msg.dwArg1, |
| 1344 | PERF_ModuleSocketNode); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1345 | #endif |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1346 | status = DSPNode_PutMessage (phandle->dspCodec->hNode, &msg, DSP_FOREVER); |
| 1347 | pthread_mutex_unlock(&phandle->mutex); |
| 1348 | DSP_ERROR_EXIT (status, "Send message to node", EXIT); |
| 1349 | break; |
| 1350 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1351 | case EMMCodecControlStrmCtrl: |
| 1352 | { |
| 1353 | struct DSP_MSG msg; |
James Dong | eaaadaf | 2010-02-01 17:29:02 -0800 | [diff] [blame] | 1354 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1355 | pthread_mutex_lock(&phandle->mutex); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1356 | if ((int)args[0] == USN_STRMCMD_FLUSH) { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1357 | msg.dwCmd = USN_GPPMSG_STRMCTRL | (int)args[1]; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1358 | msg.dwArg1 = USN_STRMCMD_FLUSH; |
| 1359 | msg.dwArg2 = 0; |
| 1360 | phandle->flush_pending[(int)args[1]]= 1; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1361 | #ifdef __PERF_INSTRUMENTATION__ |
| 1362 | PERF_SendingCommand(phandle->pPERF, |
| 1363 | msg.dwCmd, |
| 1364 | msg.dwArg1, |
| 1365 | PERF_ModuleSocketNode); |
| 1366 | #endif |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1367 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1368 | else |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1369 | { |
| 1370 | int i; |
| 1371 | for (i = 0; i < QUEUE_SIZE; i++) |
| 1372 | { |
| 1373 | /* searching for empty slot */ |
| 1374 | if (phandle->pStrmcntlDmmBuf[i] == NULL) |
| 1375 | break; |
| 1376 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1377 | if(i >= QUEUE_SIZE) |
| 1378 | { |
| 1379 | eError=OMX_ErrorUndefined; |
| 1380 | pthread_mutex_unlock(&phandle->mutex); |
| 1381 | goto EXIT; |
| 1382 | } |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 1383 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1384 | LCML_MALLOC(phandle->pStrmcntlDmmBuf[i],sizeof(DMM_BUFFER_OBJ),DMM_BUFFER_OBJ); |
| 1385 | if(phandle->pStrmcntlDmmBuf[i] == NULL) |
| 1386 | { |
| 1387 | eError = OMX_ErrorInsufficientResources; |
| 1388 | pthread_mutex_unlock(&phandle->mutex); |
| 1389 | goto EXIT; |
| 1390 | } |
| 1391 | |
| 1392 | memset(phandle->pStrmcntlDmmBuf[i],0,sizeof(DMM_BUFFER_OBJ)); //ATC |
| 1393 | |
| 1394 | eError = DmmMap(phandle->dspCodec->hProc, (int)args[2], args[1],(phandle->pStrmcntlDmmBuf[i]), ((LCML_CODEC_INTERFACE *)hComponent)->dbg); |
| 1395 | if (eError != OMX_ErrorNone) |
| 1396 | { |
| 1397 | pthread_mutex_unlock(&phandle->mutex); |
| 1398 | goto EXIT; |
| 1399 | } |
| 1400 | phandle->strmcntlmapped[i] = 1; |
| 1401 | if(phandle->dspCodec->DeviceInfo.TypeofRender == 0) |
| 1402 | { |
| 1403 | /* playback mode */ |
| 1404 | msg.dwCmd = USN_GPPMSG_STRMCTRL | 0x01; |
| 1405 | msg.dwArg1 = (int)args[0]; |
| 1406 | msg.dwArg2 = (int)phandle->pStrmcntlDmmBuf[i]->pMapped; |
| 1407 | } |
| 1408 | else if(phandle->dspCodec->DeviceInfo.TypeofRender == 1) |
| 1409 | { |
| 1410 | /* record mode */ |
| 1411 | msg.dwCmd = USN_GPPMSG_STRMCTRL; |
| 1412 | msg.dwArg1 = (int)args[0]; |
| 1413 | msg.dwArg2 = (int)phandle->pStrmcntlDmmBuf[i]->pMapped; |
| 1414 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1415 | } |
| 1416 | #ifdef __PERF_INSTRUMENTATION__ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1417 | PERF_SendingCommand(phandle->pPERF, |
| 1418 | msg.dwCmd, |
| 1419 | msg.dwArg1, |
| 1420 | PERF_ModuleSocketNode); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1421 | #endif |
| 1422 | status = DSPNode_PutMessage (phandle->dspCodec->hNode, &msg, DSP_FOREVER); |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 1423 | pthread_mutex_unlock(&phandle->mutex); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1424 | DSP_ERROR_EXIT (status, "Send message to node", EXIT); |
| 1425 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1426 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "STRMControl: arg[0]: message = %x\n",(int)args[0]); |
| 1427 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "STRMControl: arg[1]: address = %p\n",args[1]); |
| 1428 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)hComponent)->dbg, "STRMControl: arg[2]: size = %d\n",(int)args[2]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1429 | break; |
| 1430 | } |
| 1431 | case EMMCodecControlUsnEos: |
| 1432 | { |
| 1433 | phandle->bUsnEos = OMX_TRUE; |
| 1434 | break; |
| 1435 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1436 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1437 | } |
| 1438 | |
| 1439 | EXIT: |
| 1440 | return eError; |
| 1441 | } |
| 1442 | |
| 1443 | |
| 1444 | /** ======================================================================== |
| 1445 | * DmmMap () method is used to allocate the memory using DMM. |
| 1446 | * |
| 1447 | * @param ProcHandle - Component identification number |
| 1448 | * @param size - Buffer header address, that needs to be sent to codec |
| 1449 | * @param pArmPtr - Message used to send the buffer to codec |
| 1450 | * @param pDmmBuf - buffer id |
| 1451 | * |
| 1452 | * @retval OMX_ErrorNone - Success |
| 1453 | * OMX_ErrorHardware - Hardware Error |
| 1454 | ** ==========================================================================*/ |
| 1455 | OMX_ERRORTYPE DmmMap(DSP_HPROCESSOR ProcHandle, |
| 1456 | OMX_U32 size, |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1457 | void* pArmPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1458 | DMM_BUFFER_OBJ* pDmmBuf, |
| 1459 | struct OMX_TI_Debug dbg) |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1460 | { |
| 1461 | OMX_ERRORTYPE eError = OMX_ErrorUndefined; |
| 1462 | DSP_STATUS status; |
| 1463 | int nSizeReserved = 0; |
| 1464 | |
| 1465 | if(pDmmBuf == NULL) |
| 1466 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1467 | OMX_ERROR4 (dbg, "pBuf is NULL\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1468 | eError = OMX_ErrorBadParameter; |
| 1469 | goto EXIT; |
| 1470 | } |
| 1471 | |
| 1472 | if(pArmPtr == NULL) |
| 1473 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1474 | OMX_ERROR4 (dbg, "pBuf is NULL\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1475 | eError = OMX_ErrorBadParameter; |
| 1476 | goto EXIT; |
| 1477 | } |
| 1478 | |
| 1479 | /* Allocate */ |
| 1480 | pDmmBuf->pAllocated = pArmPtr; |
| 1481 | |
| 1482 | /* Reserve */ |
| 1483 | nSizeReserved = ROUND_TO_PAGESIZE(size) + 2*DMM_PAGE_SIZE ; |
| 1484 | status = DSPProcessor_ReserveMemory(ProcHandle, nSizeReserved, &(pDmmBuf->pReserved)); |
| 1485 | if(DSP_FAILED(status)) |
| 1486 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1487 | OMX_ERROR4 (dbg, "DSPProcessor_ReserveMemory() failed - error 0x%x", (int)status); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1488 | eError = OMX_ErrorInsufficientResources; |
| 1489 | goto EXIT; |
| 1490 | } |
| 1491 | pDmmBuf->nSize = size; |
| 1492 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1493 | |
| 1494 | OMX_PRBUFFER2 (dbg, " DMM MAP Reserved: %p (for buf %p), size 0x%x (%d)", pDmmBuf->pReserved, pArmPtr, nSizeReserved,nSizeReserved); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1495 | |
| 1496 | /* Map */ |
| 1497 | status = DSPProcessor_Map(ProcHandle, |
| 1498 | pDmmBuf->pAllocated,/* malloc'd data here*/ |
| 1499 | size , /* size */ |
| 1500 | pDmmBuf->pReserved, /* reserved space */ |
| 1501 | &(pDmmBuf->pMapped), /* returned map pointer */ |
| 1502 | 0); /* final param is reserved. set to zero. */ |
| 1503 | if(DSP_FAILED(status)) |
| 1504 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1505 | OMX_ERROR4 (dbg, "DSPProcessor_Map() failed - error 0x%x", (int)status); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1506 | eError = OMX_ErrorInsufficientResources; |
| 1507 | goto EXIT; |
| 1508 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1509 | OMX_PRBUFFER1 (dbg, "DMM Mapped: %p, size 0x%lx (%ld)",pDmmBuf->pMapped, size,size); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1510 | |
Rebecca Schultz Zavin | b44cdb1 | 2009-07-29 17:23:50 -0700 | [diff] [blame] | 1511 | /* Previously we used to Flush or Invalidate the mapped buffer. This was |
| 1512 | * removed due to bridge is now handling the flush/invalidate operation */ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1513 | eError = OMX_ErrorNone; |
| 1514 | |
| 1515 | EXIT: |
| 1516 | return eError; |
| 1517 | } |
| 1518 | |
| 1519 | |
| 1520 | /** ======================================================================== |
| 1521 | * DmmUnMap () method is used to de-allocate the memory using DMM. |
| 1522 | * |
| 1523 | * @param ProcHandle - Component identification number |
| 1524 | * @param pMapPtr - Map address |
| 1525 | * @param pResPtr - reserve adress |
| 1526 | * |
| 1527 | * @retval OMX_ErrorNone - Success |
| 1528 | * OMX_ErrorHardware - Hardware Error |
| 1529 | ** ==========================================================================*/ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1530 | OMX_ERRORTYPE DmmUnMap(DSP_HPROCESSOR ProcHandle, void* pMapPtr, void* pResPtr, struct OMX_TI_Debug dbg ) |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1531 | { |
| 1532 | DSP_STATUS status = DSP_SOK; |
| 1533 | OMX_ERRORTYPE eError = OMX_ErrorNone; |
| 1534 | |
| 1535 | if(pMapPtr == NULL) |
| 1536 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1537 | OMX_ERROR4 (dbg, "pMapPtr is NULL\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1538 | eError = OMX_ErrorBadParameter; |
| 1539 | goto EXIT; |
| 1540 | } |
| 1541 | if(pResPtr == NULL) |
| 1542 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1543 | OMX_ERROR4 (dbg, "pResPtr is NULL\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1544 | eError = OMX_ErrorBadParameter; |
| 1545 | goto EXIT; |
| 1546 | } |
| 1547 | status = DSPProcessor_UnMap(ProcHandle,pMapPtr); |
| 1548 | if(DSP_FAILED(status)) |
| 1549 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1550 | OMX_PRDSP4 (dbg, "DSPProcessor_UnMap() failed - error 0x%x",(int)status); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1551 | } |
| 1552 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1553 | OMX_PRINT2 (dbg, "unreserving structure =0x%p\n",pResPtr ); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1554 | status = DSPProcessor_UnReserveMemory(ProcHandle,pResPtr); |
| 1555 | if(DSP_FAILED(status)) |
| 1556 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1557 | OMX_PRDSP4 (dbg, "DSPProcessor_UnReserveMemory() failed - error 0x%x", (int)status); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1558 | } |
| 1559 | |
| 1560 | EXIT: |
| 1561 | return eError; |
| 1562 | } |
| 1563 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1564 | /** ======================================================================== |
| 1565 | * FreeResources () method is used to allocate the memory using DMM. |
| 1566 | * |
| 1567 | * @param hInterface - Component identification number |
| 1568 | * |
| 1569 | * @retval OMX_ErrorNone Success |
| 1570 | * OMX_ErrorHardware Hardware Error |
| 1571 | ** ==========================================================================*/ |
| 1572 | OMX_ERRORTYPE FreeResources (LCML_DSP_INTERFACE *hInterface) |
| 1573 | { |
| 1574 | OMX_ERRORTYPE eError = OMX_ErrorNone; |
| 1575 | LCML_DSP_INTERFACE *codec; |
| 1576 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1577 | OMX_PRINT1 ((struct OMX_TI_Debug)(((LCML_CODEC_INTERFACE *)hInterface->pCodecinterfacehandle)->dbg), "%d :: LCML:: FreeResources\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1578 | if(hInterface->dspCodec != NULL) |
| 1579 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 1580 | LCML_FREE(hInterface->dspCodec); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1581 | hInterface->dspCodec = NULL; |
| 1582 | } |
| 1583 | codec = (LCML_DSP_INTERFACE *)(((LCML_CODEC_INTERFACE*)hInterface->pCodecinterfacehandle)->pCodec); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1584 | if(codec != NULL) |
| 1585 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1586 | pthread_mutex_destroy(&codec->m_isStopped_mutex); |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 1587 | pthread_mutex_lock(&codec->mutex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1588 | |
| 1589 | OMX_PRINT1 ((struct OMX_TI_Debug)(((LCML_CODEC_INTERFACE *)hInterface->pCodecinterfacehandle)->dbg), "%d :: LCML:: FreeResources\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1590 | if(codec->g_aNotificationObjects[0]!= NULL) |
| 1591 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 1592 | LCML_FREE(codec->g_aNotificationObjects[0]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1593 | codec->g_aNotificationObjects[0] = NULL; |
| 1594 | #ifdef __ERROR_PROPAGATION__ |
| 1595 | if(codec->g_aNotificationObjects[1]!= NULL) |
| 1596 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 1597 | LCML_FREE(codec->g_aNotificationObjects[1]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1598 | codec->g_aNotificationObjects[1] = NULL; |
| 1599 | } |
| 1600 | if(codec->g_aNotificationObjects[2]!= NULL) |
| 1601 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 1602 | LCML_FREE(codec->g_aNotificationObjects[2]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1603 | codec->g_aNotificationObjects[2] = NULL; |
| 1604 | } |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 1605 | #endif |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1606 | OMX_DBG_CLOSE((struct OMX_TI_Debug )(((LCML_CODEC_INTERFACE*)hInterface->pCodecinterfacehandle)->dbg)); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 1607 | LCML_FREE(((LCML_CODEC_INTERFACE*)hInterface->pCodecinterfacehandle)); |
Rebecca Schultz Zavin | b44cdb1 | 2009-07-29 17:23:50 -0700 | [diff] [blame] | 1608 | hInterface->pCodecinterfacehandle = NULL; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1609 | } |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 1610 | pthread_mutex_unlock(&codec->mutex); |
| 1611 | pthread_mutex_destroy (&codec->mutex); |
| 1612 | LCML_FREE(codec); |
| 1613 | codec = NULL; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1614 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1615 | return eError; |
| 1616 | } |
| 1617 | |
| 1618 | /** ======================================================================== |
| 1619 | * DeleteDspResource () method is used to allocate the memory using DMM. |
| 1620 | * |
| 1621 | * @param hInterface Component identification number |
| 1622 | * |
| 1623 | * @retval OMX_ErrorNone Success |
| 1624 | * OMX_ErrorHardware Hardware Error |
| 1625 | ** ==========================================================================*/ |
| 1626 | OMX_ERRORTYPE DeleteDspResource(LCML_DSP_INTERFACE *hInterface) |
| 1627 | { |
| 1628 | OMX_ERRORTYPE eError = OMX_ErrorNone; |
| 1629 | DSP_STATUS status; |
| 1630 | DSP_STATUS nExit; |
| 1631 | struct DSP_NODEATTR nodeAttr; |
| 1632 | OMX_U32 dllinfo; |
| 1633 | LCML_DSP_INTERFACE *codec; |
| 1634 | |
| 1635 | /* Get current state of node, if it is running, then only terminate it */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1636 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1637 | status = DSPNode_GetAttr(hInterface->dspCodec->hNode, &nodeAttr, sizeof(nodeAttr)); |
| 1638 | DSP_ERROR_EXIT (status, "DeInit: Error in Node GetAtt ", EXIT); |
| 1639 | status = DSPNode_Terminate(hInterface->dspCodec->hNode, &nExit); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1640 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInterface->pCodecinterfacehandle)->dbg, "%d :: LCML:: Node Has Been Terminated --1\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1641 | codec = (LCML_DSP_INTERFACE *)(((LCML_CODEC_INTERFACE*)hInterface->pCodecinterfacehandle)->pCodec); |
| 1642 | if(codec->g_aNotificationObjects[0]!= NULL) |
| 1643 | { |
| 1644 | } |
| 1645 | #ifdef __ERROR_PROPAGATION__ |
| 1646 | if(codec->g_aNotificationObjects[1]!= NULL) |
| 1647 | { |
| 1648 | /* status = DSPNode_RegisterNotify(hInterface->dspCodec->hProc, 0, DSP_SIGNALEVENT, codec->g_aNotificationObjects[1]); |
| 1649 | DSP_ERROR_EXIT(status, "DSP node de-register notify", EXIT);*/ |
| 1650 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1651 | #endif |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1652 | if (hInterface->dspCodec->DeviceInfo.TypeofDevice == 1) { |
| 1653 | /* delete DASF node */ |
| 1654 | status = DSPNode_Delete(hInterface->dspCodec->hDasfNode); |
| 1655 | DSP_ERROR_EXIT (status, "DeInit: DASF Node Delete ", EXIT); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1656 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInterface->pCodecinterfacehandle)->dbg, "%d :: Deleted the DASF node Successfully\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1657 | } |
| 1658 | /* delete SN */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1659 | status = DSPNode_Delete(hInterface->dspCodec->hNode); |
| 1660 | DSP_ERROR_EXIT (status, "DeInit: Codec Node Delete ", EXIT); |
| 1661 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)hInterface->pCodecinterfacehandle)->dbg, "%d :: Deleted the node Successfully\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1662 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1663 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInterface->pCodecinterfacehandle)->dbg, "%d :: Entering UnLoadDLLs \n", __LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1664 | for(dllinfo=0;dllinfo < hInterface->dspCodec->NodeInfo.nNumOfDLLs ;dllinfo++) |
| 1665 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1666 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)hInterface->pCodecinterfacehandle)->dbg, "%d :: Register Component Node\n",hInterface->dspCodec->NodeInfo.AllUUIDs[dllinfo].eDllType); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1667 | status = DSPManager_UnregisterObject ((struct DSP_UUID *) hInterface->dspCodec->NodeInfo.AllUUIDs[dllinfo].uuid, |
| 1668 | hInterface->dspCodec->NodeInfo.AllUUIDs[dllinfo].eDllType); |
| 1669 | /*DSP_ERROR_EXIT (status, "Unregister DSP Object, Socket UUID ", EXIT);*/ |
| 1670 | } |
| 1671 | |
| 1672 | /* detach processor from gpp */ |
| 1673 | status = DSPProcessor_Detach(hInterface->dspCodec->hProc); |
| 1674 | DSP_ERROR_EXIT (status, "DeInit: DSP Processor Detach ", EXIT); |
| 1675 | |
| 1676 | status = DspManager_Close(0, NULL); |
| 1677 | DSP_ERROR_EXIT (status, "DeInit: DSPManager Close ", EXIT); |
| 1678 | |
| 1679 | EXIT: |
| 1680 | return eError; |
| 1681 | |
| 1682 | } |
| 1683 | |
| 1684 | |
| 1685 | /** ======================================================================== |
| 1686 | * This is the function run in the message thread. It waits for an event |
| 1687 | * signal from Bridge and then reads all available messages. |
| 1688 | * |
| 1689 | * @param[in] arg Unused - Required by pthreads API |
| 1690 | * |
| 1691 | * @retval OMX_ErrorNone Success, ready to roll |
| 1692 | ** ==========================================================================*/ |
| 1693 | void* MessagingThread(void* arg) |
| 1694 | { |
| 1695 | /* OMX_ERRORTYPE eError = OMX_ErrorUndefined; */ |
| 1696 | DSP_STATUS status = DSP_SOK; |
| 1697 | struct DSP_MSG msg = {0,0,0}; |
| 1698 | unsigned int index=0; |
| 1699 | LCML_MESSAGINGTHREAD_STATE threadState = EMessagingThreadCodecStopped; |
| 1700 | int waitForEventsTimeout = 1000; |
James Dong | 9c3bf94 | 2010-02-05 16:30:43 -0800 | [diff] [blame] | 1701 | |
| 1702 | // There is no need to set a timeout value for message retrieval. |
| 1703 | // Just in case that we need to change it to a different value |
| 1704 | // such as 10 ms? |
| 1705 | const int getMessageTimeout = 0; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1706 | |
Andreas Huber | 5807caa | 2010-03-12 14:20:45 -0800 | [diff] [blame] | 1707 | #ifdef ANDROID |
| 1708 | prctl(PR_SET_NAME, (unsigned long)"Messaging", 0, 0, 0); |
| 1709 | #endif |
| 1710 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1711 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "Inside the Messaging thread\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1712 | #ifdef __PERF_INSTRUMENTATION__ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1713 | ((LCML_DSP_INTERFACE *)arg)->pPERFcomp = |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1714 | PERF_Create(PERF_FOURCC('C','M','L','T'), |
| 1715 | PERF_ModuleAudioDecode | PERF_ModuleAudioEncode | |
| 1716 | PERF_ModuleVideoDecode | PERF_ModuleVideoEncode | |
| 1717 | PERF_ModuleImageDecode | PERF_ModuleImageEncode | |
| 1718 | PERF_ModuleCommonLayer); |
| 1719 | #endif |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1720 | if (((LCML_DSP_INTERFACE *)arg)->ReUseMap) |
| 1721 | { |
| 1722 | pthread_mutex_lock(&((LCML_DSP_INTERFACE *)arg)->m_isStopped_mutex); |
| 1723 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1724 | |
| 1725 | /* get message from DSP */ |
| 1726 | while (1) |
| 1727 | { |
| 1728 | if (((LCML_DSP_INTERFACE *)arg)->pshutdownFlag == 1) |
| 1729 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1730 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "Breaking out of loop inmessaging thread \n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1731 | break; |
| 1732 | } |
| 1733 | |
| 1734 | if (threadState == EMessagingThreadCodecRunning) { |
| 1735 | waitForEventsTimeout = 10000; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1736 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1737 | /* set the timeouts lower when the codec is stopped so that thread deletion response will be faster */ |
| 1738 | else if (threadState == EMessagingThreadCodecStopped) { |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1739 | waitForEventsTimeout = 10; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1740 | } |
| 1741 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1742 | #ifdef __ERROR_PROPAGATION__ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1743 | status = DSPManager_WaitForEvents(((LCML_DSP_INTERFACE *)arg)->g_aNotificationObjects, 3, &index, waitForEventsTimeout); |
| 1744 | #else |
| 1745 | status = DSPManager_WaitForEvents(((LCML_DSP_INTERFACE *)arg)->g_aNotificationObjects, 1, &index, waitForEventsTimeout); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1746 | #endif |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1747 | if (DSP_SUCCEEDED(status)) |
| 1748 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1749 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "GOT notofication FROM DSP HANDLE IT \n"); |
| 1750 | #ifdef __ERROR_PROPAGATION__ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1751 | if (index == 0){ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1752 | #endif |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1753 | /* Pull all available messages out of the message loop */ |
| 1754 | while (DSP_SUCCEEDED(status)) |
| 1755 | { |
| 1756 | /* since there is a message waiting, grab it and pass */ |
| 1757 | status = DSPNode_GetMessage(((LCML_DSP_INTERFACE *)arg)->dspCodec->hNode, &msg, getMessageTimeout); |
| 1758 | if (DSP_SUCCEEDED(status)) |
| 1759 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1760 | OMX_U32 streamId = (msg.dwCmd & 0x000000ff); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1761 | int commandId = msg.dwCmd & 0xffffff00; |
| 1762 | TMMCodecBufferType bufType ;/* = EMMCodecScratchBuffer; */ |
| 1763 | TUsnCodecEvent event = EMMCodecInternalError; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1764 | void * args[10] = {}; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1765 | TArmDspCommunicationStruct *tmpDspStructAddress = NULL; |
| 1766 | LCML_DSP_INTERFACE *hDSPInterface = ((LCML_DSP_INTERFACE *)arg) ; |
| 1767 | DMM_BUFFER_OBJ* pDmmBuf = NULL; |
| 1768 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1769 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1770 | "GOT MESSAGE FROM DSP HANDLE IT %d \n", index); |
| 1771 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1772 | "msg = 0x%lx arg1 = 0x%lx arg2 = 0x%lx", msg.dwCmd, msg.dwArg1, msg.dwArg2); |
| 1773 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1774 | "Message EMMCodecOuputBuffer outside loop"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1775 | #ifdef __PERF_INSTRUMENTATION__ |
| 1776 | PERF_ReceivedCommand(hDSPInterface->pPERFcomp, |
| 1777 | msg.dwCmd, msg.dwArg1, |
| 1778 | PERF_ModuleSocketNode); |
| 1779 | #endif |
| 1780 | |
| 1781 | if (commandId == USN_DSPMSG_BUFF_FREE ) |
| 1782 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1783 | threadState = EMessagingThreadCodecRunning; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1784 | #ifdef __PERF_INSTRUMENTATION__ |
| 1785 | PERF_XferingBuffer(hDSPInterface->pPERFcomp, |
| 1786 | args [1], |
| 1787 | (OMX_U32) args [8], |
| 1788 | PERF_ModuleSocketNode, |
| 1789 | PERF_ModuleLLMM); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1790 | #endif |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1791 | pthread_mutex_lock(&hDSPInterface->mutex); |
| 1792 | if (!(streamId % 2)) |
| 1793 | { |
| 1794 | int i = 0; |
| 1795 | int j = 0; |
| 1796 | bufType = streamId + EMMCodecStream0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1797 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1798 | "Address Arminputstorage %p \n", ((LCML_DSP_INTERFACE *)arg)->Arminputstorage); |
| 1799 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1800 | "Address dspinterface %p \n", ((LCML_DSP_INTERFACE *)arg)); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1801 | |
| 1802 | hDSPInterface->iBufinputcount = hDSPInterface->iBufinputcount % QUEUE_SIZE; |
| 1803 | i = hDSPInterface->iBufinputcount; |
| 1804 | while(j++ < QUEUE_SIZE) |
| 1805 | { |
| 1806 | if (hDSPInterface->Arminputstorage[i] != NULL && hDSPInterface ->Arminputstorage[i]->iArmArg == msg.dwArg1) |
| 1807 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1808 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "InputBuffer loop"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1809 | tmpDspStructAddress = ((LCML_DSP_INTERFACE *)arg)->Arminputstorage[i] ; |
| 1810 | hDSPInterface->Arminputstorage[i] =NULL; |
| 1811 | pDmmBuf = hDSPInterface ->dspCodec->InDmmBuffer; |
| 1812 | pDmmBuf = pDmmBuf + (tmpDspStructAddress->BufInindex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1813 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "Address output matching index= %ld \n ",tmpDspStructAddress->BufInindex); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1814 | break; |
| 1815 | } |
| 1816 | i++; |
| 1817 | i = i % QUEUE_SIZE; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1818 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "Message EMMCodecInputBuffer loop"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1819 | } |
| 1820 | } |
| 1821 | else if (streamId % 2) |
| 1822 | { |
| 1823 | int i = 0; |
| 1824 | int j = 0; |
| 1825 | bufType = streamId + EMMCodecStream0;; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1826 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "Address Armoutputstorage %p \n ",((LCML_DSP_INTERFACE *)arg)->Armoutputstorage); |
| 1827 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "Address dspinterface %p \n ",((LCML_DSP_INTERFACE *)arg)); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1828 | |
| 1829 | hDSPInterface->iBufoutputcount = hDSPInterface->iBufoutputcount % QUEUE_SIZE; |
| 1830 | i = hDSPInterface->iBufoutputcount; |
| 1831 | while(j++ < QUEUE_SIZE) |
| 1832 | { |
| 1833 | if( hDSPInterface ->Armoutputstorage[i] != NULL |
| 1834 | && hDSPInterface ->Armoutputstorage[i]->iArmArg == msg.dwArg1) |
| 1835 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1836 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "output buffer loop"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1837 | tmpDspStructAddress = hDSPInterface->Armoutputstorage[i] ; |
| 1838 | hDSPInterface ->Armoutputstorage[i] =NULL; |
| 1839 | pDmmBuf = hDSPInterface ->dspCodec->OutDmmBuffer; |
| 1840 | pDmmBuf = pDmmBuf + (tmpDspStructAddress->Bufoutindex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1841 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1842 | "Address output matching index= %ld\n ",tmpDspStructAddress->Bufoutindex); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1843 | break; |
| 1844 | } |
| 1845 | i++; |
| 1846 | i = i % QUEUE_SIZE; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1847 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1848 | "Message EMMCodecOuputBuffer loop"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1849 | } |
| 1850 | } |
| 1851 | |
| 1852 | if (tmpDspStructAddress != NULL) |
| 1853 | { |
| 1854 | char *tmp2 = NULL; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1855 | |
James Dong | 2ad8941 | 2010-04-07 12:55:43 -0700 | [diff] [blame] | 1856 | status = DSPProcessor_InvalidateMemory(hDSPInterface->dspCodec->hProc, |
| 1857 | tmpDspStructAddress, sizeof(TArmDspCommunicationStruct)); |
| 1858 | if (DSP_FAILED(status)) { |
Steve Block | a0a88cf | 2012-01-08 10:18:17 +0000 | [diff] [blame] | 1859 | ALOGE("Invalidate for communication structure failed. status = 0x%x\n", status); |
James Dong | 2ad8941 | 2010-04-07 12:55:43 -0700 | [diff] [blame] | 1860 | } |
James Dong | 08cf2e8 | 2010-03-09 16:23:46 -0800 | [diff] [blame] | 1861 | |
James Dong | 2ad8941 | 2010-04-07 12:55:43 -0700 | [diff] [blame] | 1862 | // Only invalidate the memory when the pointer points to some valid memory region |
| 1863 | // otherwise, we will get logging spam |
| 1864 | if (tmpDspStructAddress->iArmParamArg != NULL && tmpDspStructAddress->iParamSize > 0) { |
| 1865 | status = DSPProcessor_InvalidateMemory(hDSPInterface->dspCodec->hProc, |
| 1866 | tmpDspStructAddress->iArmParamArg, tmpDspStructAddress->iParamSize); |
| 1867 | if (DSP_FAILED(status)) { |
Steve Block | a0a88cf | 2012-01-08 10:18:17 +0000 | [diff] [blame] | 1868 | ALOGE("Invalidate for arm parameter arguments failed. status = 0x%x\n", status); |
James Dong | 2ad8941 | 2010-04-07 12:55:43 -0700 | [diff] [blame] | 1869 | } |
| 1870 | } |
James Dong | 08cf2e8 | 2010-03-09 16:23:46 -0800 | [diff] [blame] | 1871 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1872 | event = EMMCodecBufferProcessed; |
| 1873 | args[0] = (void *) bufType; |
| 1874 | args[1] = (void *) tmpDspStructAddress->iArmbufferArg; /* arm address fpr buffer */ |
| 1875 | args[2] = (void *) tmpDspStructAddress->iBufferSize; |
| 1876 | args[3] = (void *) tmpDspStructAddress->iArmParamArg; /* arm address for param */ |
| 1877 | args[4] = (void *) tmpDspStructAddress->iParamSize; |
| 1878 | args[5] = (void *) tmpDspStructAddress->iArmArg; |
| 1879 | args[6] = (void *) arg; /* handle */ |
| 1880 | args[7] = (void *) tmpDspStructAddress->iUsrArg; /* user arguments */ |
| 1881 | |
| 1882 | if (((LCML_DSP_INTERFACE *)arg)->bUsnEos) { |
| 1883 | ((OMX_BUFFERHEADERTYPE*)args[7])->nFlags |= tmpDspStructAddress->iEOSFlag; |
| 1884 | } |
| 1885 | /* USN updates*/ |
| 1886 | args[8] = (void *) tmpDspStructAddress->iBufSizeUsed ; |
| 1887 | /* managing buffers and free buffer logic */ |
| 1888 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1889 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1890 | "GOT MESSAGE EMMCodecBufferProcessed and now unmapping buffer type %p \n", args[2]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1891 | |
| 1892 | if (tmpDspStructAddress ->iBufferPtr != (OMX_U32)NULL) |
| 1893 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1894 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1895 | "GOT MESSAGE EMMCodecBufferProcessed and now unmapping buufer %lx\n size=%ld", |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1896 | tmpDspStructAddress ->iBufferPtr, tmpDspStructAddress ->iBufferSize); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1897 | /* 720p implementation */ |
| 1898 | if (!hDSPInterface->ReUseMap) |
| 1899 | { |
| 1900 | DmmUnMap(hDSPInterface->dspCodec->hProc, |
| 1901 | (void*)tmpDspStructAddress->iBufferPtr, |
| 1902 | pDmmBuf->bufReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
| 1903 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1904 | } |
| 1905 | |
| 1906 | if (tmpDspStructAddress->iParamPtr != (OMX_U32)NULL) |
| 1907 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1908 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1909 | "GOT MESSAGE EMMCodecBufferProcessed and now unmapping parameter buufer\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1910 | |
| 1911 | DmmUnMap(hDSPInterface ->dspCodec->hProc, |
| 1912 | (void*)tmpDspStructAddress->iParamPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1913 | pDmmBuf->paramReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1914 | } |
| 1915 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1916 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1917 | "GOT MESSAGE EMMCodecBufferProcessed and now unmapping structure =0x%p\n",tmpDspStructAddress ); |
| 1918 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1919 | tmp2 = (char *)tmpDspStructAddress; |
| 1920 | tmp2 = (tmp2 - 128); |
| 1921 | if (tmp2) |
| 1922 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 1923 | LCML_FREE(tmp2); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1924 | tmp2 = NULL; |
| 1925 | } |
| 1926 | |
| 1927 | /* free(tmpDspStructAddress); */ |
| 1928 | tmpDspStructAddress = NULL; |
| 1929 | } |
| 1930 | pthread_mutex_unlock(&hDSPInterface->mutex); |
| 1931 | } /* End of USN_DSPMSG_BUFF_FREE */ |
| 1932 | |
| 1933 | else if (commandId == USN_DSPACK_STOP) |
| 1934 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1935 | threadState = EMessagingThreadCodecStopped; |
| 1936 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1937 | /* Start of USN_DSPACK_STOP */ |
| 1938 | int i = 0; |
| 1939 | int j = 0; |
| 1940 | int k = 0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1941 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1942 | "GOT MESSAGE EMMCodecProcessingStoped \n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1943 | pthread_mutex_lock(&hDSPInterface->mutex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1944 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1945 | "LCMLSTOP: hDSPInterface->dspCodec->DeviceInfo.TypeofDevice %d\n", hDSPInterface->dspCodec->DeviceInfo.TypeofDevice); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1946 | if (hDSPInterface->dspCodec->DeviceInfo.TypeofDevice == 0) |
| 1947 | { |
| 1948 | j = 0; |
| 1949 | hDSPInterface->iBufinputcount = hDSPInterface->iBufinputcount % QUEUE_SIZE; |
| 1950 | i = hDSPInterface->iBufinputcount; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1951 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1952 | hDSPInterface->iBufoutputcount = hDSPInterface->iBufoutputcount % QUEUE_SIZE; |
| 1953 | k = hDSPInterface->iBufoutputcount; |
| 1954 | |
| 1955 | while(j++ < QUEUE_SIZE) |
| 1956 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1957 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1958 | "LCMLSTOP: %d hDSPInterface->Arminputstorage[i] = %p\n", i, hDSPInterface->Arminputstorage[i]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1959 | if (hDSPInterface->Arminputstorage[i] != NULL) |
| 1960 | { |
| 1961 | char *tmp2 = NULL; |
| 1962 | /* callback the component with the buffers that are being freed */ |
| 1963 | tmpDspStructAddress = hDSPInterface->Arminputstorage[i] ; |
| 1964 | |
| 1965 | pDmmBuf = hDSPInterface ->dspCodec->InDmmBuffer; |
| 1966 | pDmmBuf = pDmmBuf + (tmpDspStructAddress->BufInindex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1967 | OMX_PRBUFFER1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1968 | "pDmmBuf->pMapped %p\n", pDmmBuf->pMapped); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1969 | |
| 1970 | event = EMMCodecBufferProcessed; |
| 1971 | args[0] = (void *) EMMCodecInputBuffer; |
| 1972 | args[1] = (void *) tmpDspStructAddress->iArmbufferArg; /* arm address fpr buffer */ |
| 1973 | args[2] = (void *) tmpDspStructAddress->iBufferSize; |
| 1974 | args[3] = (void *) tmpDspStructAddress->iArmParamArg; /* arm address for param */ |
| 1975 | args[4] = (void *) tmpDspStructAddress->iParamSize; |
| 1976 | args[5] = (void *) tmpDspStructAddress->iArmArg; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1977 | args[6] = (void *) arg; /* handle */ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1978 | args[7] = (void *) tmpDspStructAddress->iUsrArg; /* user arguments */ |
| 1979 | /* USN updates*/ |
| 1980 | args[8] = (void *) tmpDspStructAddress->iBufSizeUsed ; |
| 1981 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1982 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 1983 | "LCMLSTOP: tmpDspStructAddress->iBufferPtr %p, tmpDspStructAddress->iParamPtr %p, msg.dwArg1 %p\n", |
| 1984 | (void *)tmpDspStructAddress->iBufferPtr, |
| 1985 | (void *)tmpDspStructAddress->iParamPtr, |
| 1986 | (void *)msg.dwArg1); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1987 | if (tmpDspStructAddress->iBufferPtr != (OMX_U32)NULL) |
| 1988 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 1989 | if (!hDSPInterface->ReUseMap) |
| 1990 | { |
| 1991 | DmmUnMap(hDSPInterface->dspCodec->hProc, |
| 1992 | (void*)tmpDspStructAddress->iBufferPtr, |
| 1993 | pDmmBuf->bufReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
| 1994 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 1995 | } |
| 1996 | |
| 1997 | if (tmpDspStructAddress->iParamPtr != (OMX_U32)NULL) |
| 1998 | { |
| 1999 | DmmUnMap(hDSPInterface ->dspCodec->hProc, |
| 2000 | (void*)tmpDspStructAddress->iParamPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2001 | pDmmBuf->paramReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2002 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2003 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2004 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2005 | if (NULL != tmpDspStructAddress) |
| 2006 | { |
| 2007 | tmp2 = (char*)tmpDspStructAddress; |
| 2008 | tmp2 = ( tmp2 - 128); |
| 2009 | } |
| 2010 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2011 | "%d :: LCML:: FreeResources\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2012 | if (tmp2) |
| 2013 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2014 | LCML_FREE(tmp2); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2015 | tmp2 = NULL; |
| 2016 | } |
| 2017 | hDSPInterface->Arminputstorage[i] = NULL; |
| 2018 | tmpDspStructAddress = NULL; |
| 2019 | #ifdef __PERF_INSTRUMENTATION__ |
| 2020 | PERF_XferingBuffer(hDSPInterface->pPERFcomp, |
| 2021 | args [1], |
| 2022 | (OMX_U32) args [2], |
| 2023 | PERF_ModuleSocketNode, |
| 2024 | PERF_ModuleLLMM); |
| 2025 | #endif |
| 2026 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
| 2027 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2028 | |
| 2029 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2030 | "LCMLSTOP: %d hDSPInterface->Armoutputstorage[k] = %p\n", k, hDSPInterface->Armoutputstorage[k]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2031 | if (hDSPInterface->Armoutputstorage[k] != NULL) |
| 2032 | { |
| 2033 | char * tmp2 = NULL; |
| 2034 | tmpDspStructAddress = hDSPInterface->Armoutputstorage[k] ; |
| 2035 | |
| 2036 | pDmmBuf = hDSPInterface ->dspCodec->OutDmmBuffer; |
| 2037 | pDmmBuf = pDmmBuf + (tmpDspStructAddress->Bufoutindex); |
| 2038 | |
| 2039 | event = EMMCodecBufferProcessed; |
| 2040 | args[0] = (void *) EMMCodecOuputBuffer; |
| 2041 | args[1] = (void *) tmpDspStructAddress->iArmbufferArg; /* arm address fpr buffer */ |
| 2042 | args[2] = (void *) tmpDspStructAddress->iBufferSize; |
| 2043 | args[3] = (void *) tmpDspStructAddress->iArmParamArg; /* arm address for param */ |
| 2044 | args[4] = (void *) tmpDspStructAddress->iParamSize; |
| 2045 | args[5] = (void *) tmpDspStructAddress->iArmArg; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2046 | args[6] = (void *) arg; /* handle */ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2047 | args[7] = (void *) tmpDspStructAddress->iUsrArg; /* user arguments */ |
| 2048 | /* USN updates*/ |
| 2049 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2050 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2051 | "LCMLSTOP: tmpDspStructAddress->iBufferPtr %p, tmpDspStructAddress->iParamPtr %p, msg.dwArg1 %p\n", |
| 2052 | (void *)tmpDspStructAddress->iBufferPtr, |
| 2053 | (void *)tmpDspStructAddress->iParamPtr, |
| 2054 | (void *)msg.dwArg1); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2055 | if (tmpDspStructAddress ->iBufferPtr != (OMX_U32)NULL) |
| 2056 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2057 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2058 | "tmpDspStructAddress ->iBufferPtr is not NULL\n"); |
| 2059 | if (!hDSPInterface->ReUseMap) |
| 2060 | { |
| 2061 | DmmUnMap(hDSPInterface->dspCodec->hProc, |
| 2062 | (void*)tmpDspStructAddress->iBufferPtr, |
| 2063 | pDmmBuf->bufReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
| 2064 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2065 | } |
| 2066 | |
| 2067 | if (tmpDspStructAddress->iParamPtr != (OMX_U32)NULL) |
| 2068 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2069 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2070 | "tmpDspStructAddress->iParamPtr is not NULL\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2071 | DmmUnMap(hDSPInterface ->dspCodec->hProc, |
| 2072 | (void*)tmpDspStructAddress->iParamPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2073 | pDmmBuf->paramReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2074 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2075 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2076 | |
| 2077 | tmp2 = (char *) tmpDspStructAddress; |
| 2078 | tmp2 = ( tmp2 - 128); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2079 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2080 | "%d :: LCML:: FreeResources\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2081 | if(tmp2) |
| 2082 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2083 | LCML_FREE(tmp2); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2084 | tmp2 = NULL; |
| 2085 | } |
| 2086 | tmpDspStructAddress->iBufSizeUsed = 0; |
| 2087 | args[8] = (void *) tmpDspStructAddress->iBufSizeUsed ; |
| 2088 | |
| 2089 | hDSPInterface->Armoutputstorage[k] = NULL; |
| 2090 | tmpDspStructAddress = NULL; |
| 2091 | #ifdef __PERF_INSTRUMENTATION__ |
| 2092 | PERF_XferingBuffer(hDSPInterface->pPERFcomp, |
| 2093 | args[1], |
| 2094 | (OMX_U32) args[2], |
| 2095 | PERF_ModuleSocketNode, |
| 2096 | PERF_ModuleLLMM); |
| 2097 | #endif |
| 2098 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
| 2099 | } |
| 2100 | i++; |
| 2101 | i = i % QUEUE_SIZE; |
| 2102 | k++; |
| 2103 | k = k % QUEUE_SIZE; |
| 2104 | } |
| 2105 | } |
| 2106 | pthread_mutex_unlock(&hDSPInterface->mutex); |
| 2107 | args[6] = (void *) arg; /* handle */ |
| 2108 | event = EMMCodecProcessingStoped; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2109 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2110 | } /* end of USN_DSPACK_STOP */ |
| 2111 | else if (commandId == USN_DSPACK_PAUSE) |
| 2112 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2113 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2114 | event = EMMCodecProcessingPaused; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2115 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2116 | "GOT MESSAGE EMMCodecProcessingPaused \n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2117 | args[6] = (void *) arg; /* handle */ |
| 2118 | } |
| 2119 | else if (commandId == USN_DSPMSG_EVENT) |
| 2120 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2121 | threadState = EMessagingThreadCodecStopped; |
| 2122 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2123 | event = EMMCodecDspError; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2124 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2125 | "GOT MESSAGE EMMCodecDspError \n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2126 | args[0] = (void *) msg.dwCmd; |
| 2127 | args[4] = (void *) msg.dwArg1; |
| 2128 | args[5] = (void *) msg.dwArg2; |
| 2129 | args[6] = (void *) arg; /* handle */ |
| 2130 | } |
| 2131 | else if (commandId == USN_DSPACK_ALGCTRL) |
| 2132 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2133 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2134 | int i; |
| 2135 | event = EMMCodecAlgCtrlAck; |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 2136 | pthread_mutex_lock(&hDSPInterface->mutex); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2137 | for (i = 0; i < QUEUE_SIZE; i++) |
| 2138 | { |
| 2139 | pDmmBuf = ((LCML_DSP_INTERFACE *)arg)->pAlgcntlDmmBuf[i]; |
| 2140 | if ((pDmmBuf) && |
| 2141 | (((LCML_DSP_INTERFACE *)arg)->algcntlmapped[i]) && |
| 2142 | (pDmmBuf->pMapped == (void *)msg.dwArg2)) |
| 2143 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2144 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, |
| 2145 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2146 | LCML_FREE(pDmmBuf); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2147 | pDmmBuf = NULL; |
| 2148 | ((LCML_DSP_INTERFACE *)arg)->algcntlmapped[i] = 0; |
| 2149 | ((LCML_DSP_INTERFACE *)arg)->pAlgcntlDmmBuf[i] = NULL; |
| 2150 | break; |
| 2151 | } |
| 2152 | } |
| 2153 | args[0] = (void *) msg.dwArg1; |
| 2154 | args[6] = (void *) arg; /* handle */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2155 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "GOT MESSAGE USN_DSPACK_ALGCTRL \n"); |
Anu Sundararajan | 7576307 | 2009-10-08 22:21:48 -0500 | [diff] [blame] | 2156 | pthread_mutex_unlock(&hDSPInterface->mutex); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2157 | } |
| 2158 | else if (commandId == USN_DSPACK_STRMCTRL) |
| 2159 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2160 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2161 | int i = 0; |
| 2162 | int j = 0; |
| 2163 | int ackType = 0; |
| 2164 | pthread_mutex_lock(&hDSPInterface->mutex); |
| 2165 | if (hDSPInterface->flush_pending[0] && (streamId == 0) && (msg.dwArg1 == USN_ERR_NONE)) |
| 2166 | { |
| 2167 | hDSPInterface->flush_pending[0] = 0; |
| 2168 | ackType = USN_STRMCMD_FLUSH; |
| 2169 | j = 0; |
| 2170 | hDSPInterface->iBufinputcount = hDSPInterface->iBufinputcount % QUEUE_SIZE; |
| 2171 | i = hDSPInterface->iBufinputcount; |
| 2172 | while(j++ < QUEUE_SIZE) |
| 2173 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2174 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2175 | "LCMLFLUSH: %d hDSPInterface->Arminputstorage[i] = %p\n", i, hDSPInterface->Arminputstorage[i]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2176 | if (hDSPInterface->Arminputstorage[i] != NULL) |
| 2177 | { |
| 2178 | char *tmp2 = NULL; |
| 2179 | tmpDspStructAddress = hDSPInterface->Arminputstorage[i] ; |
| 2180 | |
| 2181 | pDmmBuf = hDSPInterface ->dspCodec->InDmmBuffer; |
| 2182 | pDmmBuf = pDmmBuf + (tmpDspStructAddress->BufInindex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2183 | OMX_PRBUFFER2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2184 | "pDmmBuf->pMapped %p\n", pDmmBuf->pMapped); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2185 | |
| 2186 | event = EMMCodecBufferProcessed; |
| 2187 | args[0] = (void *) EMMCodecInputBuffer; |
| 2188 | args[1] = (void *) tmpDspStructAddress->iArmbufferArg; |
| 2189 | args[2] = (void *) tmpDspStructAddress->iBufferSize; |
| 2190 | args[3] = (void *) tmpDspStructAddress->iArmParamArg; |
| 2191 | args[4] = (void *) tmpDspStructAddress->iParamSize; |
| 2192 | args[5] = (void *) tmpDspStructAddress->iArmArg; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2193 | args[6] = (void *) arg; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2194 | args[7] = (void *) tmpDspStructAddress->iUsrArg; |
| 2195 | |
| 2196 | args[8] = (void *) tmpDspStructAddress->iBufSizeUsed ; |
| 2197 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2198 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2199 | "LCMLFLUSH: tmpDspStructAddress->iBufferPtr %p, tmpDspStructAddress->iParamPtr %p, msg.dwArg1 %p\n", |
| 2200 | (void *)tmpDspStructAddress->iBufferPtr, |
| 2201 | (void *)tmpDspStructAddress->iParamPtr, |
| 2202 | (void *)msg.dwArg1); |
| 2203 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2204 | if (tmpDspStructAddress->iBufferPtr != (OMX_U32)NULL) |
| 2205 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2206 | /* 720p implementation */ |
| 2207 | if (!hDSPInterface->ReUseMap) |
| 2208 | { |
| 2209 | DmmUnMap(hDSPInterface->dspCodec->hProc, |
| 2210 | (void*)tmpDspStructAddress->iBufferPtr, |
| 2211 | pDmmBuf->bufReserved, |
| 2212 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
| 2213 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2214 | } |
| 2215 | |
| 2216 | if (tmpDspStructAddress->iParamPtr != (OMX_U32)NULL) |
| 2217 | { |
| 2218 | DmmUnMap(hDSPInterface ->dspCodec->hProc, |
| 2219 | (void*)tmpDspStructAddress->iParamPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2220 | pDmmBuf->paramReserved, |
| 2221 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2222 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2223 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, |
| 2224 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2225 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2226 | if (NULL != tmpDspStructAddress) |
| 2227 | { |
| 2228 | tmp2 = (char*)tmpDspStructAddress; |
| 2229 | tmp2 = ( tmp2 - 128); |
| 2230 | } |
| 2231 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2232 | "%d :: LCML:: FreeResources\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2233 | if (tmp2) |
| 2234 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2235 | LCML_FREE(tmp2); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2236 | tmp2 = NULL; |
| 2237 | } |
| 2238 | hDSPInterface->Arminputstorage[i] = NULL; |
| 2239 | tmpDspStructAddress = NULL; |
| 2240 | #ifdef __PERF_INSTRUMENTATION__ |
| 2241 | PERF_XferingBuffer(hDSPInterface->pPERFcomp, |
| 2242 | args [1], |
| 2243 | (OMX_U32) args [2], |
| 2244 | PERF_ModuleSocketNode, |
| 2245 | PERF_ModuleLLMM); |
| 2246 | #endif |
| 2247 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
| 2248 | } |
| 2249 | i++; |
| 2250 | i = i % QUEUE_SIZE; |
| 2251 | } |
| 2252 | for (i = 0; i < QUEUE_SIZE; i++) |
| 2253 | { |
| 2254 | pDmmBuf = ((LCML_DSP_INTERFACE *)arg)->pStrmcntlDmmBuf[i]; |
| 2255 | if ((pDmmBuf) && |
| 2256 | (((LCML_DSP_INTERFACE *)arg)->strmcntlmapped[i]) && |
| 2257 | (pDmmBuf->pMapped == (void *)msg.dwArg2)) |
| 2258 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2259 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, |
| 2260 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2261 | LCML_FREE(pDmmBuf); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2262 | pDmmBuf = NULL; |
| 2263 | ((LCML_DSP_INTERFACE *)arg)->strmcntlmapped[i] = 0; |
| 2264 | ((LCML_DSP_INTERFACE *)arg)->pStrmcntlDmmBuf[i] = NULL; |
| 2265 | break; |
| 2266 | } |
| 2267 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2268 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2269 | else if (hDSPInterface->flush_pending[1] && (streamId == 1) && (msg.dwArg1 == USN_ERR_NONE)) |
| 2270 | { |
| 2271 | hDSPInterface->flush_pending[1] = 0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2272 | ackType = USN_STRMCMD_FLUSH; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2273 | j = 0; |
| 2274 | hDSPInterface->iBufoutputcount = hDSPInterface->iBufoutputcount % QUEUE_SIZE; |
| 2275 | i = hDSPInterface->iBufoutputcount; |
| 2276 | while(j++ < QUEUE_SIZE) |
| 2277 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2278 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2279 | "LCMLFLUSH: %d hDSPInterface->Armoutputstorage[i] = %p\n", i, hDSPInterface->Armoutputstorage[i]); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2280 | if (hDSPInterface->Armoutputstorage[i] != NULL) |
| 2281 | { |
| 2282 | char * tmp2 = NULL; |
| 2283 | tmpDspStructAddress = hDSPInterface->Armoutputstorage[i] ; |
| 2284 | |
| 2285 | pDmmBuf = hDSPInterface ->dspCodec->OutDmmBuffer; |
| 2286 | pDmmBuf = pDmmBuf + (tmpDspStructAddress->Bufoutindex); |
| 2287 | |
| 2288 | event = EMMCodecBufferProcessed; |
| 2289 | args[0] = (void *) EMMCodecOuputBuffer; |
| 2290 | args[1] = (void *) tmpDspStructAddress->iArmbufferArg; |
| 2291 | args[2] = (void *) tmpDspStructAddress->iBufferSize; |
| 2292 | args[3] = (void *) tmpDspStructAddress->iArmParamArg; |
| 2293 | args[4] = (void *) tmpDspStructAddress->iParamSize; |
| 2294 | args[5] = (void *) tmpDspStructAddress->iArmArg; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2295 | args[6] = (void *) arg; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2296 | args[7] = (void *) tmpDspStructAddress->iUsrArg; |
| 2297 | |
| 2298 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2299 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2300 | "LCMLFLUSH: tmpDspStructAddress->iBufferPtr %p, tmpDspStructAddress->iParamPtr %p, msg.dwArg1 %p\n", |
| 2301 | (void *)tmpDspStructAddress->iBufferPtr, |
| 2302 | (void *)tmpDspStructAddress->iParamPtr, |
| 2303 | (void *)msg.dwArg1); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2304 | if (tmpDspStructAddress ->iBufferPtr != (OMX_U32)NULL) |
| 2305 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2306 | /* 720p implementation */ |
| 2307 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2308 | "tmpDspStructAddress ->iBufferPtr is not NULL\n"); |
| 2309 | if (!hDSPInterface->ReUseMap) |
| 2310 | { |
| 2311 | DmmUnMap(hDSPInterface->dspCodec->hProc, |
| 2312 | (void*)tmpDspStructAddress->iBufferPtr, |
| 2313 | pDmmBuf->bufReserved, |
| 2314 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
| 2315 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2316 | } |
| 2317 | |
| 2318 | if (tmpDspStructAddress->iParamPtr != (OMX_U32)NULL) |
| 2319 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2320 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2321 | "tmpDspStructAddress->iParamPtr is not NULL\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2322 | DmmUnMap(hDSPInterface ->dspCodec->hProc, |
| 2323 | (void*)tmpDspStructAddress->iParamPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2324 | pDmmBuf->paramReserved, |
| 2325 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2326 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2327 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, |
| 2328 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2329 | |
| 2330 | tmp2 = (char *) tmpDspStructAddress; |
| 2331 | tmp2 = ( tmp2 - 128); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2332 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2333 | "%d :: LCML:: FreeResources\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2334 | if(tmp2) |
| 2335 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2336 | LCML_FREE(tmp2); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2337 | tmp2 = NULL; |
| 2338 | } |
| 2339 | tmpDspStructAddress->iBufSizeUsed = 0; |
| 2340 | args[8] = (void *) tmpDspStructAddress->iBufSizeUsed ; |
| 2341 | |
| 2342 | hDSPInterface->Armoutputstorage[i] = NULL; |
| 2343 | tmpDspStructAddress = NULL; |
| 2344 | #ifdef __PERF_INSTRUMENTATION__ |
| 2345 | PERF_XferingBuffer(hDSPInterface->pPERFcomp, |
| 2346 | args[1], |
| 2347 | (OMX_U32) args[2], |
| 2348 | PERF_ModuleSocketNode, |
| 2349 | PERF_ModuleLLMM); |
| 2350 | #endif |
| 2351 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
| 2352 | } |
| 2353 | i++; |
| 2354 | i = i % QUEUE_SIZE; |
| 2355 | } |
| 2356 | for (i = 0; i < QUEUE_SIZE; i++) |
| 2357 | { |
| 2358 | pDmmBuf = ((LCML_DSP_INTERFACE *)arg)->pStrmcntlDmmBuf[i]; |
| 2359 | if ((pDmmBuf) && |
| 2360 | (((LCML_DSP_INTERFACE *)arg)->strmcntlmapped[i]) && |
| 2361 | (pDmmBuf->pMapped == (void *)msg.dwArg2)) |
| 2362 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2363 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, |
| 2364 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2365 | LCML_FREE(pDmmBuf); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2366 | pDmmBuf = NULL; |
| 2367 | ((LCML_DSP_INTERFACE *)arg)->strmcntlmapped[i] = 0; |
| 2368 | ((LCML_DSP_INTERFACE *)arg)->pStrmcntlDmmBuf[i] = NULL; |
| 2369 | break; |
| 2370 | } |
| 2371 | } |
| 2372 | } |
| 2373 | if (hDSPInterface->flush_pending[2] && (streamId == 2) && (msg.dwArg1 == USN_ERR_NONE)) |
| 2374 | { |
| 2375 | hDSPInterface->flush_pending[0] = 0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2376 | ackType = USN_STRMCMD_FLUSH; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2377 | j = 0; |
| 2378 | hDSPInterface->iBufinputcount = hDSPInterface->iBufinputcount % QUEUE_SIZE; |
| 2379 | i = hDSPInterface->iBufinputcount; |
| 2380 | while(j++ < QUEUE_SIZE) |
| 2381 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2382 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2383 | "LCMLFLUSH (port 2): %d hDSPInterface->Arminputstorage[i] = %p (stream ID %lu)\n", i, hDSPInterface->Arminputstorage[i], streamId); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2384 | if ((hDSPInterface->Arminputstorage[i] != NULL) && (hDSPInterface->Arminputstorage[i]->iStreamID == streamId)) |
| 2385 | { |
| 2386 | char *tmp2 = NULL; |
| 2387 | tmpDspStructAddress = hDSPInterface->Arminputstorage[i] ; |
| 2388 | |
| 2389 | pDmmBuf = hDSPInterface ->dspCodec->InDmmBuffer; |
| 2390 | pDmmBuf = pDmmBuf + (tmpDspStructAddress->BufInindex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2391 | OMX_PRBUFFER2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2392 | "pDmmBuf->pMapped %p\n", pDmmBuf->pMapped); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2393 | |
| 2394 | event = EMMCodecBufferProcessed; |
| 2395 | args[0] = (void *) EMMCodecInputBuffer; |
| 2396 | args[1] = (void *) tmpDspStructAddress->iArmbufferArg; |
| 2397 | args[2] = (void *) tmpDspStructAddress->iBufferSize; |
| 2398 | args[3] = (void *) tmpDspStructAddress->iArmParamArg; |
| 2399 | args[4] = (void *) tmpDspStructAddress->iParamSize; |
| 2400 | args[5] = (void *) tmpDspStructAddress->iArmArg; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2401 | args[6] = (void *) arg; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2402 | args[7] = (void *) tmpDspStructAddress->iUsrArg; |
| 2403 | |
| 2404 | args[8] = (void *) tmpDspStructAddress->iBufSizeUsed ; |
| 2405 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2406 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2407 | "LCMLFLUSH: tmpDspStructAddress->iBufferPtr %p, tmpDspStructAddress->iParamPtr %p, msg.dwArg1 %p\n", |
| 2408 | (void *)tmpDspStructAddress->iBufferPtr, |
| 2409 | (void *)tmpDspStructAddress->iParamPtr, |
| 2410 | (void *)msg.dwArg1); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2411 | if (tmpDspStructAddress->iBufferPtr != (OMX_U32)NULL) |
| 2412 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2413 | /* 720p implementation */ |
| 2414 | if (!hDSPInterface->ReUseMap) |
| 2415 | { |
| 2416 | DmmUnMap(hDSPInterface->dspCodec->hProc, |
| 2417 | (void*)tmpDspStructAddress->iBufferPtr, |
| 2418 | pDmmBuf->bufReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
| 2419 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2420 | } |
| 2421 | |
| 2422 | if (tmpDspStructAddress->iParamPtr != (OMX_U32)NULL) |
| 2423 | { |
| 2424 | DmmUnMap(hDSPInterface ->dspCodec->hProc, |
| 2425 | (void*)tmpDspStructAddress->iParamPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2426 | pDmmBuf->paramReserved, ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2427 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2428 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, |
| 2429 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2430 | |
| 2431 | tmp2 = (char*)tmpDspStructAddress; |
| 2432 | tmp2 = ( tmp2 - 128); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2433 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2434 | "%d :: LCML:: FreeResources\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2435 | if (tmp2) |
| 2436 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2437 | LCML_FREE(tmp2); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2438 | tmp2 = NULL; |
| 2439 | } |
| 2440 | hDSPInterface->Arminputstorage[i] = NULL; |
| 2441 | tmpDspStructAddress = NULL; |
| 2442 | #ifdef __PERF_INSTRUMENTATION__ |
| 2443 | PERF_XferingBuffer(hDSPInterface->pPERFcomp, |
| 2444 | args [1], |
| 2445 | (OMX_U32) args [2], |
| 2446 | PERF_ModuleSocketNode, |
| 2447 | PERF_ModuleLLMM); |
| 2448 | #endif |
| 2449 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
| 2450 | } |
| 2451 | i++; |
| 2452 | i = i % QUEUE_SIZE; |
| 2453 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2454 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2455 | else if (hDSPInterface->flush_pending[3] && (streamId == 3) && (msg.dwArg1 == USN_ERR_NONE)) |
| 2456 | { |
| 2457 | hDSPInterface->flush_pending[1] = 0; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2458 | ackType = USN_STRMCMD_FLUSH; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2459 | j = 0; |
| 2460 | hDSPInterface->iBufoutputcount = hDSPInterface->iBufoutputcount % QUEUE_SIZE; |
| 2461 | i = hDSPInterface->iBufoutputcount; |
| 2462 | while(j++ < QUEUE_SIZE) |
| 2463 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2464 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2465 | "LCMLFLUSH: %d hDSPInterface->Armoutputstorage[i] = %p (stream id %lu)\n", i, hDSPInterface->Armoutputstorage[i], streamId); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2466 | if ((hDSPInterface->Armoutputstorage[i] != NULL) && (hDSPInterface->Armoutputstorage[i]->iStreamID == streamId)) |
| 2467 | { |
| 2468 | char * tmp2 = NULL; |
| 2469 | tmpDspStructAddress = hDSPInterface->Armoutputstorage[i] ; |
| 2470 | |
| 2471 | pDmmBuf = hDSPInterface ->dspCodec->OutDmmBuffer; |
| 2472 | pDmmBuf = pDmmBuf + (tmpDspStructAddress->Bufoutindex); |
| 2473 | |
| 2474 | event = EMMCodecBufferProcessed; |
| 2475 | args[0] = (void *) EMMCodecOuputBuffer; |
| 2476 | args[1] = (void *) tmpDspStructAddress->iArmbufferArg; |
| 2477 | args[2] = (void *) tmpDspStructAddress->iBufferSize; |
| 2478 | args[3] = (void *) tmpDspStructAddress->iArmParamArg; |
| 2479 | args[4] = (void *) tmpDspStructAddress->iParamSize; |
| 2480 | args[5] = (void *) tmpDspStructAddress->iArmArg; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2481 | args[6] = (void *) arg; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2482 | args[7] = (void *) tmpDspStructAddress->iUsrArg; |
| 2483 | |
| 2484 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2485 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2486 | "LCMLFLUSH: tmpDspStructAddress->iBufferPtr %p, tmpDspStructAddress->iParamPtr %p, msg.dwArg1 %p\n", |
| 2487 | (void *)tmpDspStructAddress->iBufferPtr, |
| 2488 | (void *)tmpDspStructAddress->iParamPtr, |
| 2489 | (void *)msg.dwArg1); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2490 | if (tmpDspStructAddress ->iBufferPtr != (OMX_U32)NULL) |
| 2491 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2492 | /* 720p implementation */ |
| 2493 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2494 | "tmpDspStructAddress ->iBufferPtr is not NULL\n"); |
| 2495 | if (!hDSPInterface->ReUseMap) |
| 2496 | { |
| 2497 | DmmUnMap(hDSPInterface->dspCodec->hProc, |
| 2498 | (void*)tmpDspStructAddress->iBufferPtr, |
| 2499 | pDmmBuf->bufReserved, |
| 2500 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
| 2501 | } |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2502 | } |
| 2503 | |
| 2504 | if (tmpDspStructAddress->iParamPtr != (OMX_U32)NULL) |
| 2505 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2506 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2507 | "tmpDspStructAddress->iParamPtr is not NULL\n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2508 | DmmUnMap(hDSPInterface ->dspCodec->hProc, |
| 2509 | (void*)tmpDspStructAddress->iParamPtr, |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2510 | pDmmBuf->paramReserved, |
| 2511 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2512 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2513 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, |
| 2514 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2515 | |
| 2516 | tmp2 = (char *) tmpDspStructAddress; |
| 2517 | tmp2 = ( tmp2 - 128); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2518 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, |
| 2519 | "%d :: LCML:: FreeResources\n",__LINE__); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2520 | if(tmp2) |
| 2521 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2522 | LCML_FREE(tmp2); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2523 | tmp2 = NULL; |
| 2524 | } |
| 2525 | tmpDspStructAddress->iBufSizeUsed = 0; |
| 2526 | args[8] = (void *) tmpDspStructAddress->iBufSizeUsed ; |
| 2527 | |
| 2528 | hDSPInterface->Armoutputstorage[i] = NULL; |
| 2529 | tmpDspStructAddress = NULL; |
| 2530 | #ifdef __PERF_INSTRUMENTATION__ |
| 2531 | PERF_XferingBuffer(hDSPInterface->pPERFcomp, |
| 2532 | args[1], |
| 2533 | (OMX_U32) args[2], |
| 2534 | PERF_ModuleSocketNode, |
| 2535 | PERF_ModuleLLMM); |
| 2536 | #endif |
| 2537 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
| 2538 | } |
| 2539 | i++; |
| 2540 | i = i % QUEUE_SIZE; |
| 2541 | } |
| 2542 | } |
| 2543 | |
| 2544 | if (ackType != USN_STRMCMD_FLUSH) { |
| 2545 | for (i = 0; i < QUEUE_SIZE; i++) |
| 2546 | { |
| 2547 | pDmmBuf = ((LCML_DSP_INTERFACE *)arg)->pStrmcntlDmmBuf[i]; |
| 2548 | if ((pDmmBuf) && |
| 2549 | (((LCML_DSP_INTERFACE *)arg)->strmcntlmapped[i]) && |
| 2550 | (pDmmBuf->pMapped == (void *)msg.dwArg2)) |
| 2551 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2552 | DmmUnMap(hDSPInterface->dspCodec->hProc, pDmmBuf->pMapped, pDmmBuf->pReserved, |
| 2553 | ((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg); |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2554 | LCML_FREE(pDmmBuf); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2555 | pDmmBuf = NULL; |
| 2556 | ((LCML_DSP_INTERFACE *)arg)->strmcntlmapped[i] = 0; |
| 2557 | ((LCML_DSP_INTERFACE *)arg)->pStrmcntlDmmBuf[i] = NULL; |
| 2558 | break; |
| 2559 | } |
| 2560 | } |
| 2561 | } |
| 2562 | pthread_mutex_unlock(&hDSPInterface->mutex); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2563 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2564 | event = EMMCodecStrmCtrlAck; |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2565 | bufType = streamId + EMMCodecStream0; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2566 | args[0] = (void *) msg.dwArg1; /* SN error status */ |
| 2567 | args[1] = (void *) ackType; /* acknowledge Id */ |
| 2568 | args[2] = (void *) bufType; /* port Id */ |
| 2569 | args[6] = (void *) arg; /* handle */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2570 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "GOT MESSAGE USN_DSPACK_STRMCTRL \n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2571 | } |
| 2572 | else |
| 2573 | { |
| 2574 | event = EMMCodecDspMessageRecieved; |
| 2575 | args[0] = (void *) msg.dwCmd; |
| 2576 | args[1] = (void *) msg.dwArg1; |
| 2577 | args[2] = (void *) msg.dwArg2; |
| 2578 | args[6] = (void *) arg; /* handle */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2579 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "GOT MESSAGE EMMCodecDspMessageRecieved \n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2580 | } |
| 2581 | |
| 2582 | /* call callback */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2583 | OMX_PRINT2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "calling callback in application %p \n",((LCML_DSP_INTERFACE *)arg)->dspCodec); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2584 | #ifdef __PERF_INSTRUMENTATION__ |
| 2585 | PERF_SendingCommand(hDSPInterface->pPERFcomp, |
| 2586 | msg.dwCmd, |
| 2587 | msg.dwArg1, |
| 2588 | PERF_ModuleLLMM); |
| 2589 | #endif |
| 2590 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
| 2591 | |
| 2592 | }/* end of internal if(DSP_SUCCEEDED(status)) */ |
| 2593 | else |
| 2594 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2595 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "%d :: DSPManager_getmessage() failed: 0x%lx",__LINE__, status); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2596 | } |
| 2597 | |
| 2598 | }/* end of internal while loop*/ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2599 | #ifdef __ERROR_PROPAGATION__ |
| 2600 | }/*end of if(index == 0)*/ |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2601 | if (index == 1){ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2602 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2603 | struct DSP_PROCESSORSTATE procState; |
| 2604 | DSPProcessor_GetState(((LCML_DSP_INTERFACE *)arg)->dspCodec->hProc, &procState, sizeof(procState)); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2605 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2606 | /* |
| 2607 | fprintf(stdout, " dwErrMask = %0x \n",procState.errInfo.dwErrMask); |
| 2608 | fprintf(stdout, " dwVal1 = %0x \n",procState.errInfo.dwVal1); |
| 2609 | fprintf(stdout, " dwVal2 = %0x \n",procState.errInfo.dwVal2); |
| 2610 | fprintf(stdout, " dwVal3 = %0x \n",procState.errInfo.dwVal3); |
| 2611 | fprintf(stdout, "MMU Fault Error.\n"); |
| 2612 | */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2613 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2614 | TUsnCodecEvent event = EMMCodecDspError; |
| 2615 | void * args[10]; |
| 2616 | LCML_DSP_INTERFACE *hDSPInterface = ((LCML_DSP_INTERFACE *)arg) ; |
| 2617 | args[0] = NULL; |
| 2618 | args[4] = NULL; |
| 2619 | args[5] = NULL; |
| 2620 | args[6] = (void *) arg; /* handle */ |
| 2621 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2622 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2623 | } |
| 2624 | if (index == 2){ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2625 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2626 | struct DSP_PROCESSORSTATE procState; |
| 2627 | DSPProcessor_GetState(((LCML_DSP_INTERFACE *)arg)->dspCodec->hProc, &procState, sizeof(procState)); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2628 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2629 | /* |
| 2630 | fprintf(stdout, " dwErrMask = %0x \n",procState.errInfo.dwErrMask); |
| 2631 | fprintf(stdout, " dwVal1 = %0x \n",procState.errInfo.dwVal1); |
| 2632 | fprintf(stdout, " dwVal2 = %0x \n",procState.errInfo.dwVal2); |
| 2633 | fprintf(stdout, " dwVal3 = %0x \n",procState.errInfo.dwVal3); |
| 2634 | fprintf(stdout, "SYS_ERROR Error.\n"); |
| 2635 | */ |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2636 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2637 | TUsnCodecEvent event = EMMCodecDspError; |
| 2638 | void * args[10]; |
| 2639 | LCML_DSP_INTERFACE *hDSPInterface = ((LCML_DSP_INTERFACE *)arg) ; |
| 2640 | args[0] = NULL; |
| 2641 | args[4] = NULL; |
| 2642 | args[5] = NULL; |
| 2643 | args[6] = (void *) arg; /* handle */ |
| 2644 | hDSPInterface->dspCodec->Callbacks.LCML_Callback(event,args); |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2645 | |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2646 | } |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2647 | #endif |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2648 | } /* end of external if(DSP_SUCCEEDED(status)) */ |
| 2649 | else |
| 2650 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2651 | OMX_PRDSP2 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "%d :: DSPManager_WaitForEvents() failed: 0x%lx",__LINE__, status); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2652 | } |
| 2653 | |
| 2654 | } /* end of external while(1) loop */ |
| 2655 | |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2656 | /* 720p implementation */ |
| 2657 | if (((LCML_DSP_INTERFACE *)arg)->ReUseMap) |
| 2658 | { |
| 2659 | pthread_mutex_unlock(&((LCML_DSP_INTERFACE *)arg)->m_isStopped_mutex); |
| 2660 | } |
| 2661 | OMX_PRINT1 (((LCML_CODEC_INTERFACE *)((LCML_DSP_INTERFACE *)arg)->pCodecinterfacehandle)->dbg, "Exiting LOOP of LCML \n"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2662 | #ifdef __PERF_INSTRUMENTATION__ |
| 2663 | PERF_Done(((LCML_DSP_INTERFACE *)arg)->pPERFcomp); |
| 2664 | #endif |
| 2665 | return (void*)OMX_ErrorNone; |
| 2666 | } |
| 2667 | |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2668 | |
| 2669 | static int append_dsp_path(char * dll64p_name, char *absDLLname) |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2670 | { |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2671 | int len = 0; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2672 | char *dsp_path = NULL; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2673 | if (!(dsp_path = getenv("DSP_PATH"))) |
| 2674 | { |
James Dong | b65f253 | 2010-02-04 11:00:34 -0800 | [diff] [blame] | 2675 | OMXDBG_PRINT(stderr, PRINT, 2, OMX_DBG_BASEMASK, "DSP_PATH Environment variable not set using /system/lib/dsp default"); |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2676 | dsp_path = "/system/lib/dsp"; |
| 2677 | } |
Anu Sundararajan | 69ee5a1 | 2009-09-27 09:17:41 -0500 | [diff] [blame] | 2678 | len = strlen(dsp_path) + strlen("/") + strlen(dll64p_name) + 1 /* null terminator */; |
| 2679 | if (len >= ABS_DLL_NAME_LENGTH) return -1; |
| 2680 | |
| 2681 | strcpy(absDLLname,dsp_path); |
| 2682 | strcat(absDLLname,"/"); |
| 2683 | strcat(absDLLname,dll64p_name); |
| 2684 | return 0; |
Rebecca Schultz Zavin | fb3766f | 2009-07-16 17:22:42 -0700 | [diff] [blame] | 2685 | } |