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>
40 #include <gralloc_priv.h>
42 #include "Exynos_OSAL_Semaphore.h"
43 #include "Exynos_OMX_Baseport.h"
44 #include "Exynos_OMX_Basecomponent.h"
45 #include "Exynos_OMX_Macros.h"
46 #include "Exynos_OMX_Vdec.h"
47 #include "Exynos_OMX_Venc.h"
48 #include "Exynos_OSAL_Android.h"
49 #include "exynos_format.h"
52 #define EXYNOS_LOG_TAG "Exynos_OSAL_Android"
53 #define EXYNOS_LOG_OFF
54 #include "Exynos_OSAL_Log.h"
56 using namespace android
;
63 OMX_ERRORTYPE
Exynos_OSAL_LockANBHandle(
64 OMX_IN OMX_U32 handle
,
66 OMX_IN OMX_U32 height
,
67 OMX_IN OMX_COLOR_FORMATTYPE format
,
68 OMX_OUT OMX_PTR planes
)
72 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
73 GraphicBufferMapper
&mapper
= GraphicBufferMapper::get();
74 buffer_handle_t bufferHandle
= (buffer_handle_t
) handle
;
75 private_handle_t
*priv_hnd
= (private_handle_t
*) bufferHandle
;
76 Rect
bounds(width
, height
);
77 ExynosVideoPlane
*vplanes
= (ExynosVideoPlane
*) planes
;
78 void *vaddr
[MAX_BUFFER_PLANE
];
80 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: handle: 0x%x", __func__
, handle
);
85 case OMX_COLOR_FormatYUV420Planar
:
86 case OMX_COLOR_FormatYUV420SemiPlanar
:
87 case OMX_SEC_COLOR_FormatNV12Tiled
:
88 usage
= GRALLOC_USAGE_SW_READ_OFTEN
| GRALLOC_USAGE_SW_WRITE_OFTEN
;
91 usage
= GRALLOC_USAGE_SW_READ_OFTEN
| GRALLOC_USAGE_SW_WRITE_OFTEN
;
95 if (mapper
.lock(bufferHandle
, usage
, bounds
, vaddr
) != 0) {
96 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: mapper.lock() fail", __func__
);
97 ret
= OMX_ErrorUndefined
;
101 vplanes
[0].fd
= priv_hnd
->fd
;
102 vplanes
[0].offset
= 0;
103 vplanes
[0].addr
= vaddr
[0];
104 vplanes
[1].fd
= priv_hnd
->fd1
;
105 vplanes
[1].offset
= 0;
106 vplanes
[1].addr
= vaddr
[1];
107 vplanes
[2].fd
= priv_hnd
->fd2
;
108 vplanes
[2].offset
= 0;
109 vplanes
[2].addr
= vaddr
[2];
111 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: buffer locked: 0x%x", __func__
, *vaddr
);
119 OMX_ERRORTYPE
Exynos_OSAL_UnlockANBHandle(OMX_IN OMX_U32 handle
)
123 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
124 GraphicBufferMapper
&mapper
= GraphicBufferMapper::get();
125 buffer_handle_t bufferHandle
= (buffer_handle_t
) handle
;
127 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: handle: 0x%x", __func__
, handle
);
129 if (mapper
.unlock(bufferHandle
) != 0) {
130 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: mapper.unlock() fail", __func__
);
131 ret
= OMX_ErrorUndefined
;
135 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: buffer unlocked: 0x%x", __func__
, handle
);
143 OMX_COLOR_FORMATTYPE
Exynos_OSAL_GetANBColorFormat(OMX_IN OMX_U32 handle
)
147 OMX_COLOR_FORMATTYPE ret
= OMX_COLOR_FormatUnused
;
148 private_handle_t
*priv_hnd
= (private_handle_t
*) handle
;
150 ret
= Exynos_OSAL_Hal2OMXPixelFormat(priv_hnd
->format
);
151 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "ColorFormat: 0x%x", ret
);
159 OMX_ERRORTYPE
Exynos_OSAL_LockANB(
160 OMX_IN OMX_PTR pBuffer
,
161 OMX_IN OMX_U32 width
,
162 OMX_IN OMX_U32 height
,
163 OMX_IN OMX_COLOR_FORMATTYPE format
,
164 OMX_OUT OMX_U32
*pStride
,
165 OMX_OUT OMX_PTR planes
)
169 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
170 android_native_buffer_t
*pANB
= (android_native_buffer_t
*) pBuffer
;
172 ret
= Exynos_OSAL_LockANBHandle((OMX_U32
)pANB
->handle
, width
, height
, format
, planes
);
173 *pStride
= pANB
->stride
;
181 OMX_ERRORTYPE
Exynos_OSAL_UnlockANB(OMX_IN OMX_PTR pBuffer
)
185 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
186 android_native_buffer_t
*pANB
= (android_native_buffer_t
*) pBuffer
;
188 ret
= Exynos_OSAL_UnlockANBHandle((OMX_U32
)pANB
->handle
);
196 OMX_ERRORTYPE
useAndroidNativeBuffer(
197 EXYNOS_OMX_BASEPORT
*pExynosPort
,
198 OMX_BUFFERHEADERTYPE
**ppBufferHdr
,
204 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
205 OMX_BUFFERHEADERTYPE
*temp_bufferHeader
= NULL
;
207 OMX_U32 width
, height
;
209 ExynosVideoPlane planes
[MAX_BUFFER_PLANE
];
213 if (pExynosPort
== NULL
) {
214 ret
= OMX_ErrorBadParameter
;
217 if (pExynosPort
->portState
!= OMX_StateIdle
) {
218 ret
= OMX_ErrorIncorrectStateOperation
;
221 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
222 ret
= OMX_ErrorBadPortIndex
;
226 temp_bufferHeader
= (OMX_BUFFERHEADERTYPE
*)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE
));
227 if (temp_bufferHeader
== NULL
) {
228 ret
= OMX_ErrorInsufficientResources
;
231 Exynos_OSAL_Memset(temp_bufferHeader
, 0, sizeof(OMX_BUFFERHEADERTYPE
));
233 for (i
= 0; i
< pExynosPort
->portDefinition
.nBufferCountActual
; i
++) {
234 if (pExynosPort
->bufferStateAllocate
[i
] == BUFFER_STATE_FREE
) {
235 pExynosPort
->extendBufferHeader
[i
].OMXBufferHeader
= temp_bufferHeader
;
236 pExynosPort
->bufferStateAllocate
[i
] = (BUFFER_STATE_ASSIGNED
| HEADER_STATE_ALLOCATED
);
237 INIT_SET_SIZE_VERSION(temp_bufferHeader
, OMX_BUFFERHEADERTYPE
);
238 temp_bufferHeader
->pBuffer
= pBuffer
;
239 temp_bufferHeader
->nAllocLen
= nSizeBytes
;
240 temp_bufferHeader
->pAppPrivate
= pAppPrivate
;
241 if (nPortIndex
== INPUT_PORT_INDEX
)
242 temp_bufferHeader
->nInputPortIndex
= INPUT_PORT_INDEX
;
244 temp_bufferHeader
->nOutputPortIndex
= OUTPUT_PORT_INDEX
;
246 width
= pExynosPort
->portDefinition
.format
.video
.nFrameWidth
;
247 height
= pExynosPort
->portDefinition
.format
.video
.nFrameHeight
;
248 Exynos_OSAL_LockANB(temp_bufferHeader
->pBuffer
, width
, height
,
249 pExynosPort
->portDefinition
.format
.video
.eColorFormat
,
251 pExynosPort
->extendBufferHeader
[i
].buf_fd
[0] = planes
[0].fd
;
252 pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[0] = planes
[0].addr
;
253 pExynosPort
->extendBufferHeader
[i
].buf_fd
[1] = planes
[1].fd
;
254 pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[1] = planes
[1].addr
;
255 pExynosPort
->extendBufferHeader
[i
].buf_fd
[2] = planes
[2].fd
;
256 pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[2] = planes
[2].addr
;
257 Exynos_OSAL_UnlockANB(temp_bufferHeader
->pBuffer
);
258 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "useAndroidNativeBuffer: buf %d pYUVBuf[0]:0x%x (fd:%d), pYUVBuf[1]:0x%x (fd:%d)",
259 i
, pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[0], planes
[0].fd
,
260 pExynosPort
->extendBufferHeader
[i
].pYUVBuf
[1], planes
[1].fd
);
262 pExynosPort
->assignedBufferNum
++;
263 if (pExynosPort
->assignedBufferNum
== pExynosPort
->portDefinition
.nBufferCountActual
) {
264 pExynosPort
->portDefinition
.bPopulated
= OMX_TRUE
;
265 /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
266 Exynos_OSAL_SemaphorePost(pExynosPort
->loadedResource
);
267 /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
269 *ppBufferHdr
= temp_bufferHeader
;
276 Exynos_OSAL_Free(temp_bufferHeader
);
277 ret
= OMX_ErrorInsufficientResources
;
285 OMX_ERRORTYPE
Exynos_OSAL_GetANBParameter(
286 OMX_IN OMX_HANDLETYPE hComponent
,
287 OMX_IN OMX_INDEXTYPE nIndex
,
288 OMX_INOUT OMX_PTR ComponentParameterStructure
)
290 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
291 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
292 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
296 if (hComponent
== NULL
) {
297 ret
= OMX_ErrorBadParameter
;
301 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
302 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
303 if (ret
!= OMX_ErrorNone
) {
307 if (pOMXComponent
->pComponentPrivate
== NULL
) {
308 ret
= OMX_ErrorBadParameter
;
312 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
313 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
314 ret
= OMX_ErrorInvalidState
;
318 if (ComponentParameterStructure
== NULL
) {
319 ret
= OMX_ErrorBadParameter
;
324 case OMX_IndexParamGetAndroidNativeBuffer
:
326 GetAndroidNativeBufferUsageParams
*pANBParams
= (GetAndroidNativeBufferUsageParams
*) ComponentParameterStructure
;
327 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
329 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamGetAndroidNativeBuffer", __func__
);
331 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(GetAndroidNativeBufferUsageParams
));
332 if (ret
!= OMX_ErrorNone
) {
333 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(GetAndroidNativeBufferUsageParams) is failed", __func__
);
337 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
338 ret
= OMX_ErrorBadPortIndex
;
342 /* NOTE: OMX_IndexParamGetAndroidNativeBuffer returns original 'nUsage' without any
343 * modifications since currently not defined what the 'nUsage' is for.
345 pANBParams
->nUsage
|= (GRALLOC_USAGE_HW_TEXTURE
| GRALLOC_USAGE_EXTERNAL_DISP
);
351 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Unsupported index (%d)", __func__
, nIndex
);
352 ret
= OMX_ErrorUnsupportedIndex
;
364 OMX_ERRORTYPE
Exynos_OSAL_SetANBParameter(
365 OMX_IN OMX_HANDLETYPE hComponent
,
366 OMX_IN OMX_INDEXTYPE nIndex
,
367 OMX_IN OMX_PTR ComponentParameterStructure
)
369 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
370 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
371 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
375 if (hComponent
== NULL
) {
376 ret
= OMX_ErrorBadParameter
;
380 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
381 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
382 if (ret
!= OMX_ErrorNone
) {
386 if (pOMXComponent
->pComponentPrivate
== NULL
) {
387 ret
= OMX_ErrorBadParameter
;
391 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
392 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
393 ret
= OMX_ErrorInvalidState
;
397 if (ComponentParameterStructure
== NULL
) {
398 ret
= OMX_ErrorBadParameter
;
404 case OMX_IndexParamEnableAndroidBuffers
:
406 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
407 EnableAndroidNativeBuffersParams
*pANBParams
= (EnableAndroidNativeBuffersParams
*) ComponentParameterStructure
;
408 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
409 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
411 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamEnableAndroidNativeBuffers", __func__
);
413 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(EnableAndroidNativeBuffersParams
));
414 if (ret
!= OMX_ErrorNone
) {
415 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(EnableAndroidNativeBuffersParams) is failed", __func__
);
419 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
420 ret
= OMX_ErrorBadPortIndex
;
424 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
425 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
426 ret
= OMX_ErrorBadPortIndex
;
430 /* ANB and DPB Buffer Sharing */
431 pExynosPort
->bIsANBEnabled
= pANBParams
->enable
;
432 if ((portIndex
== OUTPUT_PORT_INDEX
) &&
433 (pExynosPort
->bIsANBEnabled
== OMX_TRUE
) &&
434 ((pExynosPort
->bufferProcessType
& BUFFER_ANBSHARE
) == BUFFER_ANBSHARE
)) {
435 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
436 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV12Tiled
;
437 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "OMX_IndexParamEnableAndroidBuffers & bufferProcessType change to BUFFER_SHARE");
442 case OMX_IndexParamUseAndroidNativeBuffer
:
444 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
445 UseAndroidNativeBufferParams
*pANBParams
= (UseAndroidNativeBufferParams
*) ComponentParameterStructure
;
446 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
447 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
448 android_native_buffer_t
*pANB
;
451 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamUseAndroidNativeBuffer, portIndex: %d", __func__
, portIndex
);
453 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(UseAndroidNativeBufferParams
));
454 if (ret
!= OMX_ErrorNone
) {
455 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(UseAndroidNativeBufferParams) is failed", __func__
);
459 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
460 ret
= OMX_ErrorBadPortIndex
;
464 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
465 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
466 ret
= OMX_ErrorBadPortIndex
;
470 if (pExynosPort
->portState
!= OMX_StateIdle
) {
471 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Port state should be IDLE", __func__
);
472 ret
= OMX_ErrorIncorrectStateOperation
;
476 pANB
= pANBParams
->nativeBuffer
.get();
478 /* MALI alignment restriction */
479 nSizeBytes
= ALIGN(pANB
->width
, 16) * ALIGN(pANB
->height
, 16);
480 nSizeBytes
+= ALIGN(pANB
->width
/ 2, 16) * ALIGN(pANB
->height
/ 2, 16) * 2;
482 ret
= useAndroidNativeBuffer(pExynosPort
,
483 pANBParams
->bufferHeader
,
484 pANBParams
->nPortIndex
,
485 pANBParams
->pAppPrivate
,
488 if (ret
!= OMX_ErrorNone
) {
489 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: useAndroidNativeBuffer is failed: err=0x%x", __func__
,ret
);
495 case OMX_IndexParamStoreMetaDataBuffer
:
497 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;;
498 StoreMetaDataInBuffersParams
*pANBParams
= (StoreMetaDataInBuffersParams
*) ComponentParameterStructure
;
499 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
500 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
502 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamStoreMetaDataBuffer", __func__
);
504 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(StoreMetaDataInBuffersParams
));
505 if (ret
!= OMX_ErrorNone
) {
506 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(StoreMetaDataInBuffersParams) is failed", __func__
);
510 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
511 ret
= OMX_ErrorBadPortIndex
;
515 if (portIndex
== OUTPUT_PORT_INDEX
) {
516 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: metadata is not supported on output port", __func__
);
517 ret
= OMX_ErrorBadPortIndex
;
521 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
522 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
523 ret
= OMX_ErrorBadPortIndex
;
527 pExynosPort
->bStoreMetaData
= pANBParams
->bStoreMetaData
;
528 pVideoEnc
->bFirstInput
= OMX_TRUE
;
534 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Unsupported index (%d)", __func__
, nIndex
);
535 ret
= OMX_ErrorUnsupportedIndex
;
547 OMX_ERRORTYPE
Exynos_OSAL_GetInfoFromMetaData(OMX_IN OMX_BYTE pBuffer
,
548 OMX_OUT OMX_PTR
*ppBuf
)
550 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
551 MetadataBufferType type
;
556 * meta data contains the following data format.
557 * payload depends on the MetadataBufferType
558 * --------------------------------------------------------------
559 * | MetadataBufferType | payload |
560 * --------------------------------------------------------------
562 * If MetadataBufferType is kMetadataBufferTypeCameraSource, then
563 * --------------------------------------------------------------
564 * | kMetadataBufferTypeCameraSource | physical addr. of Y |physical addr. of CbCr |
565 * --------------------------------------------------------------
567 * If MetadataBufferType is kMetadataBufferTypeGrallocSource, then
568 * --------------------------------------------------------------
569 * | kMetadataBufferTypeGrallocSource | buffer_handle_t |
570 * --------------------------------------------------------------
573 /* MetadataBufferType */
574 Exynos_OSAL_Memcpy(&type
, (MetadataBufferType
*)pBuffer
, sizeof(MetadataBufferType
));
576 if (type
== kMetadataBufferTypeCameraSource
) {
577 void *pAddress
= NULL
;
580 Exynos_OSAL_Memcpy(&pAddress
, pBuffer
+ sizeof(MetadataBufferType
), sizeof(void *));
581 ppBuf
[0] = (void *)pAddress
;
583 /* Address. of CbCr */
584 Exynos_OSAL_Memcpy(&pAddress
, pBuffer
+ sizeof(MetadataBufferType
) + sizeof(void *), sizeof(void *));
585 ppBuf
[1] = (void *)pAddress
;
587 } else if (type
== kMetadataBufferTypeGrallocSource
) {
588 buffer_handle_t pBufHandle
;
590 /* buffer_handle_t */
591 Exynos_OSAL_Memcpy(&pBufHandle
, pBuffer
+ sizeof(MetadataBufferType
), sizeof(buffer_handle_t
));
592 ppBuf
[0] = (OMX_PTR
)pBufHandle
;
601 OMX_COLOR_FORMATTYPE
Exynos_OSAL_Hal2OMXPixelFormat(
602 unsigned int hal_format
)
604 OMX_COLOR_FORMATTYPE omx_format
;
605 switch (hal_format
) {
606 case HAL_PIXEL_FORMAT_YCbCr_422_I
:
607 omx_format
= OMX_COLOR_FormatYCbYCr
;
609 case HAL_PIXEL_FORMAT_YCbCr_420_P
:
610 omx_format
= OMX_COLOR_FormatYUV420Planar
;
612 case HAL_PIXEL_FORMAT_YCbCr_420_SP
:
613 omx_format
= OMX_COLOR_FormatYUV420SemiPlanar
;
615 case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED
:
616 omx_format
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV12TPhysicalAddress
;
618 case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED
:
619 omx_format
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV12Tiled
;
621 case HAL_PIXEL_FORMAT_BGRA_8888
:
622 case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888
:
623 omx_format
= OMX_COLOR_Format32bitARGB8888
;
626 omx_format
= OMX_COLOR_FormatYUV420Planar
;
632 unsigned int Exynos_OSAL_OMX2HalPixelFormat(
633 OMX_COLOR_FORMATTYPE omx_format
)
635 unsigned int hal_format
;
636 switch (omx_format
) {
637 case OMX_COLOR_FormatYCbYCr
:
638 hal_format
= HAL_PIXEL_FORMAT_YCbCr_422_I
;
640 case OMX_COLOR_FormatYUV420Planar
:
641 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_P
;
643 case OMX_COLOR_FormatYUV420SemiPlanar
:
644 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_SP
;
646 case OMX_SEC_COLOR_FormatNV12TPhysicalAddress
:
647 hal_format
= HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED
;
649 case OMX_SEC_COLOR_FormatNV12Tiled
:
650 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED
;
652 case OMX_COLOR_Format32bitARGB8888
:
653 hal_format
= HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888
;
656 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_P
;