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_OSAL_Semaphore.h"
45 #include "Exynos_OMX_Baseport.h"
46 #include "Exynos_OMX_Basecomponent.h"
47 #include "Exynos_OMX_Macros.h"
48 #include "Exynos_OSAL_Android.h"
49 #include "exynos_format.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
);
378 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Unsupported index (%d)", __func__
, nIndex
);
379 ret
= OMX_ErrorUnsupportedIndex
;
391 OMX_ERRORTYPE
Exynos_OSAL_SetANBParameter(
392 OMX_IN OMX_HANDLETYPE hComponent
,
393 OMX_IN OMX_INDEXTYPE nIndex
,
394 OMX_IN OMX_PTR ComponentParameterStructure
)
396 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
397 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
398 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
402 if (hComponent
== NULL
) {
403 ret
= OMX_ErrorBadParameter
;
407 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
408 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
409 if (ret
!= OMX_ErrorNone
) {
413 if (pOMXComponent
->pComponentPrivate
== NULL
) {
414 ret
= OMX_ErrorBadParameter
;
418 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
419 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
420 ret
= OMX_ErrorInvalidState
;
424 if (ComponentParameterStructure
== NULL
) {
425 ret
= OMX_ErrorBadParameter
;
430 case OMX_IndexParamEnableAndroidBuffers
:
432 EnableAndroidNativeBuffersParams
*pANBParams
= (EnableAndroidNativeBuffersParams
*) ComponentParameterStructure
;
433 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
434 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
436 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamEnableAndroidNativeBuffers", __func__
);
438 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(EnableAndroidNativeBuffersParams
));
439 if (ret
!= OMX_ErrorNone
) {
440 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(EnableAndroidNativeBuffersParams) is failed", __func__
);
444 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
445 ret
= OMX_ErrorBadPortIndex
;
449 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
450 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
451 ret
= OMX_ErrorBadPortIndex
;
455 pExynosPort
->bIsANBEnabled
= pANBParams
->enable
;
457 #ifdef USE_ANB_OUTBUF_SHARE
458 /* ANB and DPB Buffer Sharing */
459 if ((portIndex
== OUTPUT_PORT_INDEX
) &&
460 (pExynosPort
->bIsANBEnabled
== OMX_TRUE
) &&
461 ((pExynosPort
->bufferProcessType
& BUFFER_ANBSHARE
) == BUFFER_ANBSHARE
)) {
462 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
463 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV12Tiled
;
464 Exynos_OSAL_Log(EXYNOS_LOG_INFO
, "output buffer sharing mode is on");
467 if ((portIndex
== OUTPUT_PORT_INDEX
) &&
468 (pExynosPort
->bufferProcessType
& BUFFER_COPY
)) {
469 pExynosPort
->bufferProcessType
= BUFFER_COPY
;
470 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
476 case OMX_IndexParamUseAndroidNativeBuffer
:
478 UseAndroidNativeBufferParams
*pANBParams
= (UseAndroidNativeBufferParams
*) ComponentParameterStructure
;
479 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
480 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
481 android_native_buffer_t
*pANB
;
484 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamUseAndroidNativeBuffer, portIndex: %d", __func__
, portIndex
);
486 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(UseAndroidNativeBufferParams
));
487 if (ret
!= OMX_ErrorNone
) {
488 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(UseAndroidNativeBufferParams) is failed", __func__
);
492 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
493 ret
= OMX_ErrorBadPortIndex
;
497 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
498 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
499 ret
= OMX_ErrorBadPortIndex
;
503 if (pExynosPort
->portState
!= OMX_StateIdle
) {
504 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Port state should be IDLE", __func__
);
505 ret
= OMX_ErrorIncorrectStateOperation
;
509 pANB
= pANBParams
->nativeBuffer
.get();
511 /* MALI alignment restriction */
512 nSizeBytes
= ALIGN(pANB
->width
, 16) * ALIGN(pANB
->height
, 16);
513 nSizeBytes
+= ALIGN(pANB
->width
/ 2, 16) * ALIGN(pANB
->height
/ 2, 16) * 2;
515 ret
= useAndroidNativeBuffer(pExynosPort
,
516 pANBParams
->bufferHeader
,
517 pANBParams
->nPortIndex
,
518 pANBParams
->pAppPrivate
,
521 if (ret
!= OMX_ErrorNone
) {
522 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: useAndroidNativeBuffer is failed: err=0x%x", __func__
,ret
);
528 case OMX_IndexParamStoreMetaDataBuffer
:
530 StoreMetaDataInBuffersParams
*pANBParams
= (StoreMetaDataInBuffersParams
*) ComponentParameterStructure
;
531 OMX_U32 portIndex
= pANBParams
->nPortIndex
;
532 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
534 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s: OMX_IndexParamStoreMetaDataBuffer", __func__
);
536 ret
= Exynos_OMX_Check_SizeVersion(pANBParams
, sizeof(StoreMetaDataInBuffersParams
));
537 if (ret
!= OMX_ErrorNone
) {
538 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Exynos_OMX_Check_SizeVersion(StoreMetaDataInBuffersParams) is failed", __func__
);
542 if (portIndex
>= pExynosComponent
->portParam
.nPorts
) {
543 ret
= OMX_ErrorBadPortIndex
;
547 pExynosPort
= &pExynosComponent
->pExynosPort
[portIndex
];
548 if (CHECK_PORT_TUNNELED(pExynosPort
) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort
)) {
549 ret
= OMX_ErrorBadPortIndex
;
553 pExynosPort
->bStoreMetaData
= pANBParams
->bStoreMetaData
;
559 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: Unsupported index (%d)", __func__
, nIndex
);
560 ret
= OMX_ErrorUnsupportedIndex
;
572 OMX_ERRORTYPE
Exynos_OSAL_GetInfoFromMetaData(OMX_IN OMX_BYTE pBuffer
,
573 OMX_OUT OMX_PTR
*ppBuf
)
575 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
576 MetadataBufferType type
;
581 * meta data contains the following data format.
582 * payload depends on the MetadataBufferType
583 * --------------------------------------------------------------
584 * | MetadataBufferType | payload |
585 * --------------------------------------------------------------
587 * If MetadataBufferType is kMetadataBufferTypeCameraSource, then
588 * --------------------------------------------------------------
589 * | kMetadataBufferTypeCameraSource | physical addr. of Y |physical addr. of CbCr |
590 * --------------------------------------------------------------
592 * If MetadataBufferType is kMetadataBufferTypeGrallocSource, then
593 * --------------------------------------------------------------
594 * | kMetadataBufferTypeGrallocSource | buffer_handle_t |
595 * --------------------------------------------------------------
598 /* MetadataBufferType */
599 Exynos_OSAL_Memcpy(&type
, (MetadataBufferType
*)pBuffer
, sizeof(MetadataBufferType
));
601 if (type
== kMetadataBufferTypeCameraSource
) {
602 void *pAddress
= NULL
;
605 Exynos_OSAL_Memcpy(&pAddress
, pBuffer
+ sizeof(MetadataBufferType
), sizeof(void *));
606 ppBuf
[0] = (void *)pAddress
;
608 /* Address. of CbCr */
609 Exynos_OSAL_Memcpy(&pAddress
, pBuffer
+ sizeof(MetadataBufferType
) + sizeof(void *), sizeof(void *));
610 ppBuf
[1] = (void *)pAddress
;
612 } else if (type
== kMetadataBufferTypeGrallocSource
) {
613 buffer_handle_t pBufHandle
;
615 /* buffer_handle_t */
616 Exynos_OSAL_Memcpy(&pBufHandle
, pBuffer
+ sizeof(MetadataBufferType
), sizeof(buffer_handle_t
));
617 ppBuf
[0] = (OMX_PTR
)pBufHandle
;
626 OMX_COLOR_FORMATTYPE
Exynos_OSAL_Hal2OMXPixelFormat(
627 unsigned int hal_format
)
629 OMX_COLOR_FORMATTYPE omx_format
;
630 switch (hal_format
) {
631 case HAL_PIXEL_FORMAT_YCbCr_422_I
:
632 omx_format
= OMX_COLOR_FormatYCbYCr
;
634 case HAL_PIXEL_FORMAT_YCbCr_420_P
:
635 omx_format
= OMX_COLOR_FormatYUV420Planar
;
637 case HAL_PIXEL_FORMAT_YCbCr_420_SP
:
638 omx_format
= OMX_COLOR_FormatYUV420SemiPlanar
;
640 case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED
:
641 omx_format
= (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV12Tiled
;
643 case HAL_PIXEL_FORMAT_RGBA_8888
:
644 omx_format
= OMX_COLOR_Format32bitARGB8888
;
647 omx_format
= OMX_COLOR_FormatYUV420Planar
;
653 unsigned int Exynos_OSAL_OMX2HalPixelFormat(
654 OMX_COLOR_FORMATTYPE omx_format
)
656 unsigned int hal_format
;
657 switch (omx_format
) {
658 case OMX_COLOR_FormatYCbYCr
:
659 hal_format
= HAL_PIXEL_FORMAT_YCbCr_422_I
;
661 case OMX_COLOR_FormatYUV420Planar
:
662 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_P
;
664 case OMX_COLOR_FormatYUV420SemiPlanar
:
665 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_SP
;
667 case OMX_SEC_COLOR_FormatNV12Tiled
:
668 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED
;
670 case OMX_COLOR_Format32bitARGB8888
:
671 hal_format
= HAL_PIXEL_FORMAT_RGBA_8888
;
674 hal_format
= HAL_PIXEL_FORMAT_YCbCr_420_P
;