2 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file Exynos_OSAL_Android.cpp
20 * @author Seungbeom Kim (sbcrux.kim@samsung.com)
21 * @author Hyeyeon Chung (hyeon.chung@samsung.com)
22 * @author Yunji Kim (yunji.kim@samsung.com)
23 * @author Jinsung Yang (jsgood.yang@samsung.com)
32 #include <system/window.h>
33 #include <ui/GraphicBuffer.h>
34 #include <ui/GraphicBufferMapper.h>
36 #include <media/hardware/HardwareAPI.h>
37 #include <hardware/hardware.h>
38 #include <media/hardware/OMXPluginBase.h>
39 #include <media/hardware/MetadataBufferType.h>
41 #include <gralloc_priv.h>
44 #include "exynos_format.h"
45 #include "Exynos_OSAL_Semaphore.h"
46 #include "Exynos_OMX_Baseport.h"
47 #include "Exynos_OMX_Basecomponent.h"
48 #include "Exynos_OMX_Macros.h"
49 #include "Exynos_OSAL_Android.h"
51 #include "ExynosVideoApi.h"
54 #define EXYNOS_LOG_TAG "Exynos_OSAL_Android"
55 #define EXYNOS_LOG_OFF
56 #include "Exynos_OSAL_Log.h"
58 using namespace android
;
64 static int lockCnt
= 0;
66 OMX_ERRORTYPE
Exynos_OSAL_LockANBHandle(
67 OMX_IN OMX_U32 handle
,
69 OMX_IN OMX_U32 height
,
70 OMX_IN OMX_COLOR_FORMATTYPE format
,
71 OMX_OUT OMX_PTR planes
)
75 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
76 GraphicBufferMapper
&mapper
= GraphicBufferMapper::get();
77 buffer_handle_t bufferHandle
= (buffer_handle_t
) handle
;
79 private_handle_t
*priv_hnd
= (private_handle_t
*) bufferHandle
;
81 Rect
bounds(width
, height
);
82 ExynosVideoPlane
*vplanes
= (ExynosVideoPlane
*) planes
;
83 void *vaddr
[MAX_BUFFER_PLANE
];
85 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: handle: 0x%x", __func__
, handle
);
90 case OMX_COLOR_FormatYUV420Planar
:
91 case OMX_COLOR_FormatYUV420SemiPlanar
:
92 case OMX_SEC_COLOR_FormatNV12Tiled
:
93 usage
= GRALLOC_USAGE_SW_READ_OFTEN
| GRALLOC_USAGE_SW_WRITE_OFTEN
;
95 case OMX_COLOR_FormatAndroidOpaque
:
97 OMX_COLOR_FORMATTYPE formatType
;
98 formatType
= Exynos_OSAL_GetANBColorFormat((OMX_U32
)priv_hnd
);
99 if ((formatType
== OMX_COLOR_FormatYUV420SemiPlanar
) ||
100 (formatType
== OMX_SEC_COLOR_FormatNV12Tiled
))
101 usage
= GRALLOC_USAGE_SW_READ_OFTEN
| GRALLOC_USAGE_SW_WRITE_OFTEN
;
103 usage
= GRALLOC_USAGE_SW_READ_OFTEN
| GRALLOC_USAGE_SW_WRITE_OFTEN
| GRALLOC_USAGE_HW_VIDEO_ENCODER
;
107 usage
= GRALLOC_USAGE_SW_READ_OFTEN
| GRALLOC_USAGE_SW_WRITE_OFTEN
;
111 if (mapper
.lock(bufferHandle
, usage
, bounds
, vaddr
) != 0) {
112 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: mapper.lock() fail", __func__
);
113 ret
= OMX_ErrorUndefined
;
117 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: lockCnt:%d", __func__
, lockCnt
);
120 vplanes
[0].fd
= priv_hnd
->fd
;
121 vplanes
[0].offset
= 0;
122 vplanes
[1].fd
= priv_hnd
->fd1
;
123 vplanes
[1].offset
= 0;
124 vplanes
[2].fd
= priv_hnd
->fd2
;
125 vplanes
[2].offset
= 0;
127 vplanes
[0].addr
= vaddr
[0];
128 vplanes
[1].addr
= vaddr
[1];
129 vplanes
[2].addr
= vaddr
[2];
131 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: buffer locked: 0x%x", __func__
, *vaddr
);
139 OMX_ERRORTYPE
Exynos_OSAL_UnlockANBHandle(OMX_IN OMX_U32 handle
)
143 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
144 GraphicBufferMapper
&mapper
= GraphicBufferMapper::get();
145 buffer_handle_t bufferHandle
= (buffer_handle_t
) handle
;
147 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: handle: 0x%x", __func__
, handle
);
149 if (mapper
.unlock(bufferHandle
) != 0) {
150 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: mapper.unlock() fail", __func__
);
151 ret
= OMX_ErrorUndefined
;
155 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: lockCnt:%d", __func__
, lockCnt
);
157 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: buffer unlocked: 0x%x", __func__
, handle
);
165 OMX_COLOR_FORMATTYPE
Exynos_OSAL_GetANBColorFormat(OMX_IN OMX_U32 handle
)
169 OMX_COLOR_FORMATTYPE ret
= OMX_COLOR_FormatUnused
;
170 private_handle_t
*priv_hnd
= (private_handle_t
*) handle
;
172 ret
= Exynos_OSAL_Hal2OMXPixelFormat(priv_hnd
->format
);
173 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "ColorFormat: 0x%x", ret
);
181 OMX_ERRORTYPE
Exynos_OSAL_LockANB(
182 OMX_IN OMX_PTR pBuffer
,
183 OMX_IN OMX_U32 width
,
184 OMX_IN OMX_U32 height
,
185 OMX_IN OMX_COLOR_FORMATTYPE format
,
186 OMX_OUT OMX_U32
*pStride
,
187 OMX_OUT OMX_PTR planes
)
191 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
192 android_native_buffer_t
*pANB
= (android_native_buffer_t
*) pBuffer
;
194 ret
= Exynos_OSAL_LockANBHandle((OMX_U32
)pANB
->handle
, width
, height
, format
, planes
);
195 *pStride
= pANB
->stride
;
203 OMX_ERRORTYPE
Exynos_OSAL_UnlockANB(OMX_IN OMX_PTR pBuffer
)
207 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
208 android_native_buffer_t
*pANB
= (android_native_buffer_t
*) pBuffer
;
210 ret
= Exynos_OSAL_UnlockANBHandle((OMX_U32
)pANB
->handle
);
218 OMX_ERRORTYPE
useAndroidNativeBuffer(
219 EXYNOS_OMX_BASEPORT
*pExynosPort
,
220 OMX_BUFFERHEADERTYPE
**ppBufferHdr
,
226 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
227 OMX_BUFFERHEADERTYPE
*temp_bufferHeader
= NULL
;
229 OMX_U32 width
, height
;
231 ExynosVideoPlane planes
[MAX_BUFFER_PLANE
];
235 if (pExynosPort
== NULL
) {
236 ret
= OMX_ErrorBadParameter
;
239 if (pExynosPort
->portState
!= OMX_StateIdle
) {
240 ret
= OMX_ErrorIncorrectStateOperation
;
243 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
244 ret
= OMX_ErrorBadPortIndex
;
248 temp_bufferHeader
= (OMX_BUFFERHEADERTYPE
*)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE
));
249 if (temp_bufferHeader
== NULL
) {
250 ret
= OMX_ErrorInsufficientResources
;
253 Exynos_OSAL_Memset(temp_bufferHeader
, 0, sizeof(OMX_BUFFERHEADERTYPE
));
255 for (i
= 0; i
< pExynosPort
->portDefinition
.nBufferCountActual
; i
++) {
256 if (pExynosPort
->bufferStateAllocate
[i
] == BUFFER_STATE_FREE
) {
257 pExynosPort
->extendBufferHeader
[i
].OMXBufferHeader
= temp_bufferHeader
;
258 pExynosPort
->bufferStateAllocate
[i
] = (BUFFER_STATE_ASSIGNED
| HEADER_STATE_ALLOCATED
);
259 INIT_SET_SIZE_VERSION(temp_bufferHeader
, OMX_BUFFERHEADERTYPE
);
260 temp_bufferHeader
->pBuffer
= pBuffer
;
261 temp_bufferHeader
->nAllocLen
= nSizeBytes
;
262 temp_bufferHeader
->pAppPrivate
= pAppPrivate
;
263 if (nPortIndex
== INPUT_PORT_INDEX
)
264 temp_bufferHeader
->nInputPortIndex
= INPUT_PORT_INDEX
;
266 temp_bufferHeader
->nOutputPortIndex
= OUTPUT_PORT_INDEX
;
268 width
= pExynosPort
->portDefinition
.format
.video
.nFrameWidth
;
269 height
= pExynosPort
->portDefinition
.format
.video
.nFrameHeight
;
270 Exynos_OSAL_LockANB(temp_bufferHeader
->pBuffer
, width
, height
,
271 pExynosPort
->portDefinition
.format
.video
.eColorFormat
,
274 pExynosPort
->extendBufferHeader
[i
].buf_fd
[0] = planes
[0].fd
;
275 pExynosPort
->extendBufferHeader
[i
].buf_fd
[1] = planes
[1].fd
;
276 pExynosPort
->extendBufferHeader
[i
].buf_fd
[2] = planes
[2].fd
;
278 pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[0] = planes
[0].addr
;
279 pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[1] = planes
[1].addr
;
280 pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[2] = planes
[2].addr
;
281 Exynos_OSAL_UnlockANB(temp_bufferHeader
->pBuffer
);
282 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "useAndroidNativeBuffer: buf %d pYUVBuf[0]:0x%x , pYUVBuf[1]:0x%x ",
283 i
, pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[0],
284 pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[1]);
286 pExynosPort
->assignedBufferNum
++;
287 if (pExynosPort
->assignedBufferNum
== pExynosPort
->portDefinition
.nBufferCountActual
) {
288 pExynosPort
->portDefinition
.bPopulated
= OMX_TRUE
;
289 /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
290 Exynos_OSAL_SemaphorePost(pExynosPort
->loadedResource
);
291 /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
293 *ppBufferHdr
= temp_bufferHeader
;
300 Exynos_OSAL_Free(temp_bufferHeader
);
301 ret
= OMX_ErrorInsufficientResources
;
309 OMX_ERRORTYPE
Exynos_OSAL_GetANBParameter(
310 OMX_IN OMX_HANDLETYPE hComponent
,
311 OMX_IN OMX_INDEXTYPE nIndex
,
312 OMX_INOUT OMX_PTR ComponentParameterStructure
)
314 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
315 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
316 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
320 if (hComponent
== NULL
) {
321 ret
= OMX_ErrorBadParameter
;
325 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
326 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
327 if (ret
!= OMX_ErrorNone
) {
331 if (pOMXComponent
->pComponentPrivate
== NULL
) {
332 ret
= OMX_ErrorBadParameter
;
336 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
337 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
338 ret
= OMX_ErrorInvalidState
;
342 if (ComponentParameterStructure
== NULL
) {
343 ret
= OMX_ErrorBadParameter
;
348 case OMX_IndexParamGetAndroidNativeBuffer
:
350 GetAndroidNativeBufferUsageParams
*pANBParams
= (GetAndroidNativeBufferUsageParams
*) ComponentParameterStructure
;
351 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
353 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamGetAndroidNativeBuffer", __func__
);
355 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(GetAndroidNativeBufferUsageParams
));
356 if (ret
!= OMX_ErrorNone
) {
357 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(GetAndroidNativeBufferUsageParams) is failed", __func__
);
361 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
362 ret
= OMX_ErrorBadPortIndex
;
366 /* NOTE: OMX_IndexParamGetAndroidNativeBuffer returns original 'nUsage' without any
367 * modifications since currently not defined what the 'nUsage' is for.
369 pANBParams
->nUsage
|= (GRALLOC_USAGE_HW_TEXTURE
| GRALLOC_USAGE_EXTERNAL_DISP
);
370 #if defined(USE_IMPROVED_BUFFER) && !defined(USE_CSC_HW)
371 pANBParams
->nUsage
|= (GRALLOC_USAGE_SW_READ_OFTEN
| GRALLOC_USAGE_SW_WRITE_OFTEN
);
373 #if defined(USE_MFC5X_ALIGNMENT)
374 if ((pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
].bufferProcessType
& BUFFER_SHARE
) &&
375 (pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
== OMX_VIDEO_CodingAVC
)) {
376 pANBParams
->nUsage
|= GRALLOC_USAGE_PRIVATE_0
;
384 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Unsupported index (%d)", __func__
, nIndex
);
385 ret
= OMX_ErrorUnsupportedIndex
;
397 OMX_ERRORTYPE
Exynos_OSAL_SetANBParameter(
398 OMX_IN OMX_HANDLETYPE hComponent
,
399 OMX_IN OMX_INDEXTYPE nIndex
,
400 OMX_IN OMX_PTR ComponentParameterStructure
)
402 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
403 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
404 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
408 if (hComponent
== NULL
) {
409 ret
= OMX_ErrorBadParameter
;
413 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
414 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
415 if (ret
!= OMX_ErrorNone
) {
419 if (pOMXComponent
->pComponentPrivate
== NULL
) {
420 ret
= OMX_ErrorBadParameter
;
424 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
425 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
426 ret
= OMX_ErrorInvalidState
;
430 if (ComponentParameterStructure
== NULL
) {
431 ret
= OMX_ErrorBadParameter
;
436 case OMX_IndexParamEnableAndroidBuffers
:
438 EnableAndroidNativeBuffersParams
*pANBParams
= (EnableAndroidNativeBuffersParams
*) ComponentParameterStructure
;
439 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
440 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
442 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamEnableAndroidNativeBuffers", __func__
);
444 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(EnableAndroidNativeBuffersParams
));
445 if (ret
!= OMX_ErrorNone
) {
446 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(EnableAndroidNativeBuffersParams) is failed", __func__
);
450 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
451 ret
= OMX_ErrorBadPortIndex
;
455 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
456 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
457 ret
= OMX_ErrorBadPortIndex
;
461 pExynosPort
->bIsANBEnabled
= pANBParams
->enable
;
463 #ifdef USE_ANB_OUTBUF_SHARE
464 /* ANB and DPB Buffer Sharing */
465 if ((portIndex
== OUTPUT_PORT_INDEX
) &&
466 (pExynosPort
->bIsANBEnabled
== OMX_TRUE
)) {
467 if ((pExynosPort
->bufferProcessType
& BUFFER_ANBSHARE
) == BUFFER_ANBSHARE
) {
468 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
469 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV12Tiled
;
470 Exynos_OSAL_Log(EXYNOS_LOG_INFO
, "output buffer sharing mode is on");
472 pExynosPort
->bufferProcessType
= BUFFER_COPY
;
473 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
477 if ((portIndex
== OUTPUT_PORT_INDEX
) &&
478 (pExynosPort
->bufferProcessType
& BUFFER_COPY
)) {
479 pExynosPort
->bufferProcessType
= BUFFER_COPY
;
480 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
486 case OMX_IndexParamUseAndroidNativeBuffer
:
488 UseAndroidNativeBufferParams
*pANBParams
= (UseAndroidNativeBufferParams
*) ComponentParameterStructure
;
489 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
490 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
491 android_native_buffer_t
*pANB
;
494 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamUseAndroidNativeBuffer, portIndex: %d", __func__
, portIndex
);
496 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(UseAndroidNativeBufferParams
));
497 if (ret
!= OMX_ErrorNone
) {
498 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(UseAndroidNativeBufferParams) is failed", __func__
);
502 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
503 ret
= OMX_ErrorBadPortIndex
;
507 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
508 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
509 ret
= OMX_ErrorBadPortIndex
;
513 if (pExynosPort
->portState
!= OMX_StateIdle
) {
514 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Port state should be IDLE", __func__
);
515 ret
= OMX_ErrorIncorrectStateOperation
;
519 pANB
= pANBParams
->nativeBuffer
.get();
521 /* MALI alignment restriction */
522 nSizeBytes
= ALIGN(pANB
->width
, 16) * ALIGN(pANB
->height
, 16);
523 nSizeBytes
+= ALIGN(pANB
->width
/ 2, 16) * ALIGN(pANB
->height
/ 2, 16) * 2;
525 ret
= useAndroidNativeBuffer(pExynosPort
,
526 pANBParams
->bufferHeader
,
527 pANBParams
->nPortIndex
,
528 pANBParams
->pAppPrivate
,
531 if (ret
!= OMX_ErrorNone
) {
532 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: useAndroidNativeBuffer is failed: err=0x%x", __func__
,ret
);
538 case OMX_IndexParamStoreMetaDataBuffer
:
540 StoreMetaDataInBuffersParams
*pANBParams
= (StoreMetaDataInBuffersParams
*) ComponentParameterStructure
;
541 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
542 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
544 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamStoreMetaDataBuffer", __func__
);
546 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(StoreMetaDataInBuffersParams
));
547 if (ret
!= OMX_ErrorNone
) {
548 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(StoreMetaDataInBuffersParams) is failed", __func__
);
552 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
553 ret
= OMX_ErrorBadPortIndex
;
557 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
558 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
559 ret
= OMX_ErrorBadPortIndex
;
563 pExynosPort
->bStoreMetaData
= pANBParams
->bStoreMetaData
;
569 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Unsupported index (%d)", __func__
, nIndex
);
570 ret
= OMX_ErrorUnsupportedIndex
;
582 OMX_ERRORTYPE
Exynos_OSAL_GetInfoFromMetaData(OMX_IN OMX_BYTE pBuffer
,
583 OMX_OUT OMX_PTR
*ppBuf
)
585 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
586 MetadataBufferType type
;
591 * meta data contains the following data format.
592 * payload depends on the MetadataBufferType
593 * --------------------------------------------------------------
594 * | MetadataBufferType | payload |
595 * --------------------------------------------------------------
597 * If MetadataBufferType is kMetadataBufferTypeCameraSource, then
598 * --------------------------------------------------------------
599 * | kMetadataBufferTypeCameraSource | physical addr. of Y |physical addr. of CbCr |
600 * --------------------------------------------------------------
602 * If MetadataBufferType is kMetadataBufferTypeGrallocSource, then
603 * --------------------------------------------------------------
604 * | kMetadataBufferTypeGrallocSource | buffer_handle_t |
605 * --------------------------------------------------------------
608 /* MetadataBufferType */
609 Exynos_OSAL_Memcpy(&type
, (MetadataBufferType
*)pBuffer
, sizeof(MetadataBufferType
));
612 case kMetadataBufferTypeCameraSource
:
614 void *pAddress
= NULL
;
617 Exynos_OSAL_Memcpy(&pAddress
, pBuffer
+ sizeof(MetadataBufferType
), sizeof(void *));
618 ppBuf
[0] = (void *)pAddress
;
620 /* Address. of CbCr */
621 Exynos_OSAL_Memcpy(&pAddress
, pBuffer
+ sizeof(MetadataBufferType
) + sizeof(void *), sizeof(void *));
622 ppBuf
[1] = (void *)pAddress
;
624 if ((ppBuf
[0] == NULL
) || (ppBuf
[1] == NULL
))
625 ret
= OMX_ErrorBadParameter
;
628 case kMetadataBufferTypeGrallocSource
:
630 buffer_handle_t pBufHandle
;
632 /* buffer_handle_t */
633 Exynos_OSAL_Memcpy(&pBufHandle
, pBuffer
+ sizeof(MetadataBufferType
), sizeof(buffer_handle_t
));
634 ppBuf
[0] = (OMX_PTR
)pBufHandle
;
636 if (ppBuf
[0] == NULL
)
637 ret
= OMX_ErrorBadParameter
;
642 ret
= OMX_ErrorBadParameter
;
653 OMX_ERRORTYPE
Exynos_OSAL_SetPrependSPSPPSToIDR(
654 OMX_PTR pComponentParameterStructure
,
655 OMX_PTR pbPrependSpsPpsToIdr
)
657 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
658 PrependSPSPPSToIDRFramesParams
*pANBParams
= (PrependSPSPPSToIDRFramesParams
*)pComponentParameterStructure
;
659 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(PrependSPSPPSToIDRFramesParams
));
660 if (ret
!= OMX_ErrorNone
) {
661 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(PrependSPSPPSToIDRFramesParams) is failed", __func__
);
665 (*((OMX_BOOL
*)pbPrependSpsPpsToIdr
)) = pANBParams
->bEnable
;
671 OMX_COLOR_FORMATTYPE
Exynos_OSAL_Hal2OMXPixelFormat(
672 unsigned int hal_format
)
674 OMX_COLOR_FORMATTYPE omx_format
;
675 switch (hal_format
) {
676 case HAL_PIXEL_FORMAT_YCbCr_422_I
:
677 omx_format
= OMX_COLOR_FormatYCbYCr
;
679 case HAL_PIXEL_FORMAT_YCbCr_420_P
:
680 omx_format
= OMX_COLOR_FormatYUV420Planar
;
682 case HAL_PIXEL_FORMAT_YCbCr_420_SP
:
683 omx_format
= OMX_COLOR_FormatYUV420SemiPlanar
;
685 case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED
:
686 omx_format
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV12Tiled
;
688 case HAL_PIXEL_FORMAT_BGRA_8888
:
689 omx_format
= OMX_COLOR_Format32bitARGB8888
;
691 case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP
:
692 omx_format
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV21Linear
;
694 case HAL_PIXEL_FORMAT_EXYNOS_YV12
:
695 omx_format
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatYVU420Planar
;
697 case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888
:
698 omx_format
= OMX_COLOR_Format32bitBGRA8888
;
701 omx_format
= OMX_COLOR_FormatYUV420Planar
;
707 unsigned int Exynos_OSAL_OMX2HalPixelFormat(
708 OMX_COLOR_FORMATTYPE omx_format
)
710 unsigned int hal_format
;
711 switch (omx_format
) {
712 case OMX_COLOR_FormatYCbYCr
:
713 hal_format
= HAL_PIXEL_FORMAT_YCbCr_422_I
;
715 case OMX_COLOR_FormatYUV420Planar
:
716 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_P
;
718 case OMX_COLOR_FormatYUV420SemiPlanar
:
719 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_SP
;
721 case OMX_SEC_COLOR_FormatNV12Tiled
:
722 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED
;
724 case OMX_COLOR_Format32bitARGB8888
:
725 hal_format
= HAL_PIXEL_FORMAT_BGRA_8888
;
727 case OMX_SEC_COLOR_FormatNV21Linear
:
728 hal_format
= HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP
;
730 case OMX_SEC_COLOR_FormatYVU420Planar
:
731 hal_format
= HAL_PIXEL_FORMAT_EXYNOS_YV12
;
733 case OMX_COLOR_Format32bitBGRA8888
:
734 hal_format
= HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888
;
737 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_P
;